Instrument Neutral Distributed Interface INDI 2.2.5
v4l2_builtin_decoder.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2005 by Jasem Mutlaq <[email protected]>
3 Copyright (C) 2014 by geehalel <[email protected]>
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 <cstdint>
28#include <map>
29
31{
32 struct format
33 {
34 unsigned int fourcc; // V4L2 format
35 unsigned char bpp; // bytes per pixel implementation
36 bool softcrop; // softcropping available
37 format(unsigned int f, unsigned char b = 8, bool sc = false) : fourcc(f), bpp(b), softcrop(sc) {}
38 };
39
40 public:
42 virtual ~V4L2_Builtin_Decoder();
43 virtual void init();
44 virtual bool setcrop(struct v4l2_crop c);
45 virtual void resetcrop();
46 virtual void usesoftcrop(bool c);
47 virtual void setformat(struct v4l2_format f, bool use_ext_pix_format);
48 virtual uint32_t getFormat();
49 virtual bool issupportedformat(unsigned int format);
50 virtual const std::vector<unsigned int> &getsupportedformats();
51 virtual void decode(unsigned char *frame, struct v4l2_buffer *buf, bool native);
52 virtual unsigned char *getY();
53 virtual unsigned char *getU();
54 virtual unsigned char *getV();
55 virtual unsigned char *getRGBBuffer();
56 virtual unsigned char *getMJPEGBuffer(int &size);
57 virtual float *getLinearY();
58 virtual int getBpp();
59 virtual void setQuantization(bool);
60 virtual void setLinearization(bool);
61
62 protected:
64 std::map<unsigned int, struct format *> supported_formats;
65 std::vector<unsigned int> vsuppformats;
66 void allocBuffers();
67 void makeY();
68 void makeLinearY();
69
70 struct v4l2_crop crop;
71 struct v4l2_format fmt;
72 bool useSoftCrop; // uses software cropping
73 bool doCrop; // do software cropping when decoding frames
76
77 unsigned char *YBuf;
78 unsigned char *UBuf;
79 unsigned char *VBuf;
80 unsigned char *yuvBuffer;
81 unsigned char *yuyvBuffer;
82 unsigned char *colorBuffer;
83 unsigned char *rgb24_buffer;
85 //unsigned char *cropbuf;
86 unsigned int bufwidth;
87 unsigned int bufheight;
88 char lut5[32];
89 char lut6[64];
90 unsigned char bpp;
91 int m_Size;
92};
virtual void usesoftcrop(bool c)
virtual void decode(unsigned char *frame, struct v4l2_buffer *buf, bool native)
virtual const std::vector< unsigned int > & getsupportedformats()
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)
virtual void setformat(struct v4l2_format f, bool use_ext_pix_format)
virtual bool issupportedformat(unsigned int format)
virtual void setLinearization(bool)
virtual unsigned char * getV()
std::map< unsigned int, struct format * > supported_formats
std::vector< unsigned int > vsuppformats