Instrument Neutral Distributed Interface INDI  2.0.2
v4l2_builtin_decoder.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2005 by Jasem Mutlaq <mutlaqja@ikarustech.com>
3  Copyright (C) 2014 by geehalel <geehalel@gmail.com>
4 
5  V4L2 Builtin Decoder
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 */
22 
23 #pragma once
24 
25 #include "v4l2_decode.h"
26 
27 #include <map>
28 
30 {
31  struct format
32  {
33  unsigned int fourcc; // V4L2 format
34  unsigned char bpp; // bytes per pixel implementation
35  bool softcrop; // softcropping available
36  format(unsigned int f, unsigned char b = 8, bool sc = false) : fourcc(f), bpp(b), softcrop(sc) {}
37  };
38 
39  public:
41  virtual ~V4L2_Builtin_Decoder();
42  virtual void init();
43  virtual bool setcrop(struct v4l2_crop c);
44  virtual void resetcrop();
45  virtual void usesoftcrop(bool c);
46  virtual void setformat(struct v4l2_format f, bool use_ext_pix_format);
47  virtual __u32 getFormat();
48  virtual bool issupportedformat(unsigned int format);
49  virtual const std::vector<unsigned int> &getsupportedformats();
50  virtual void decode(unsigned char *frame, struct v4l2_buffer *buf, bool native);
51  virtual unsigned char *getY();
52  virtual unsigned char *getU();
53  virtual unsigned char *getV();
54  virtual unsigned char *getRGBBuffer();
55  virtual unsigned char *getMJPEGBuffer(int &size);
56  virtual float *getLinearY();
57  virtual int getBpp();
58  virtual void setQuantization(bool);
59  virtual void setLinearization(bool);
60 
61  protected:
63  std::map<unsigned int, struct format *> supported_formats;
64  std::vector<unsigned int> vsuppformats;
65  void allocBuffers();
66  void makeY();
67  void makeLinearY();
68 
69  struct v4l2_crop crop;
70  struct v4l2_format fmt;
71  bool useSoftCrop; // uses software cropping
72  bool doCrop; // do software cropping when decoding frames
75 
76  unsigned char *YBuf;
77  unsigned char *UBuf;
78  unsigned char *VBuf;
79  unsigned char *yuvBuffer;
80  unsigned char *yuyvBuffer;
81  unsigned char *colorBuffer;
82  unsigned char *rgb24_buffer;
83  float *linearBuffer;
84  //unsigned char *cropbuf;
85  unsigned int bufwidth;
86  unsigned int bufheight;
87  char lut5[32];
88  char lut6[64];
89  unsigned char bpp;
90  int m_Size;
91 };
virtual void usesoftcrop(bool c)
virtual void decode(unsigned char *frame, struct v4l2_buffer *buf, bool native)
unsigned char * yuyvBuffer
virtual const std::vector< unsigned int > & getsupportedformats()
virtual float * getLinearY()
virtual void setQuantization(bool)
virtual bool setcrop(struct v4l2_crop c)
virtual unsigned char * getU()
virtual unsigned char * getRGBBuffer()
virtual unsigned char * getY()
virtual unsigned char * getMJPEGBuffer(int &size)
unsigned char * colorBuffer
virtual void setformat(struct v4l2_format f, bool use_ext_pix_format)
virtual bool issupportedformat(unsigned int format)
struct v4l2_format fmt
virtual void setLinearization(bool)
virtual unsigned char * getV()
std::map< unsigned int, struct format * > supported_formats
std::vector< unsigned int > vsuppformats
unsigned char * rgb24_buffer