19 for (i = 0; i < 256; i++)
21 lutrangey8[i] = (
unsigned char)((255.0 / 219.0) * (i - 16));
28 void rangeY8(
unsigned char *buf,
unsigned int len)
30 unsigned char *s = buf;
32 for (
unsigned int i = 0; i < len; i++)
39 void linearize(
float *buf,
unsigned int len,
struct v4l2_format *fmt)
43 switch (fmt->fmt.pix.colorspace)
45 case V4L2_COLORSPACE_DEFAULT:
47 case V4L2_COLORSPACE_SMPTE240M:
50 for (i = 0; i < len; i++)
52 *src = (*src < 0.0913) ? *src / 4.0 : pow((*src + 0.1115) / 1.1115, 1.0 / 0.45);
56 case V4L2_COLORSPACE_SRGB:
58 for (i = 0; i < len; i++)
60 *src = (*src < -0.04045) ? -pow((-*src + 0.055) / 1.055, 2.4) :
61 ((*src <= 0.04045) ? *src / 12.92 : pow((*src + 0.055) / 1.055, 2.4));
68 case V4L2_COLORSPACE_REC709:
72 for (i = 0; i < len; i++)
74 *src = (*src <= -0.081) ? -pow((*src - 0.099) / -1.099, 1.0 / 0.45) :
75 ((*src < 0.081) ? *src / 4.5 : pow((*src + 0.099) / 1.099, 1.0 / 0.45));
83 switch (fmt->fmt.pix.colorspace)
85 case V4L2_COLORSPACE_SMPTE170M:
86 return "SMPTE170M (SDTV)";
87 case V4L2_COLORSPACE_SMPTE240M:
88 return "SMPTE240M (early HDTV)";
89 case V4L2_COLORSPACE_REC709:
90 return "REC709 (HDTV)";
91 case V4L2_COLORSPACE_BT878:
93 case V4L2_COLORSPACE_470_SYSTEM_M:
94 return "470 SYSTEM M (old NTSC)";
95 case V4L2_COLORSPACE_470_SYSTEM_BG:
96 return "470 SYSTEM BG (old PAL/SECAM)";
97 case V4L2_COLORSPACE_JPEG:
99 case V4L2_COLORSPACE_SRGB:
114 switch (fmt->fmt.pix.colorspace)
116 case V4L2_COLORSPACE_SMPTE170M:
117 case V4L2_COLORSPACE_BT878:
118 case V4L2_COLORSPACE_470_SYSTEM_M:
119 case V4L2_COLORSPACE_470_SYSTEM_BG:
120 case V4L2_COLORSPACE_JPEG:
122 case V4L2_COLORSPACE_REC709:
124 case V4L2_COLORSPACE_SRGB:
126 case V4L2_COLORSPACE_SMPTE240M:
144 return "ITU-R 601 -- SDTV";
146 return "Rec. 709 -- HDTV";
148 return "sYCC (Y'CbCr encoding of sRGB)";
150 return "SMPTE 240M -- Obsolete HDTV";
158 switch (fmt->fmt.pix.colorspace)
164 case V4L2_COLORSPACE_SMPTE170M:
165 case V4L2_COLORSPACE_BT878:
166 case V4L2_COLORSPACE_470_SYSTEM_M:
167 case V4L2_COLORSPACE_470_SYSTEM_BG:
168 case V4L2_COLORSPACE_JPEG:
169 case V4L2_COLORSPACE_REC709:
170 case V4L2_COLORSPACE_SMPTE240M:
172 case V4L2_COLORSPACE_SRGB:
186 return "Limited Range";
unsigned char lutrangecbcr8[256]
unsigned char lutrangey8[256]
unsigned short lutrangey10[1024]
const char * getYCbCrEncodingName(struct v4l2_format *fmt)
unsigned short lutrangey12[4096]
unsigned short lutrangecbcr12[4096]
void rangeY8(unsigned char *buf, unsigned int len)
unsigned short lutrangey16[65536]
unsigned int getQuantization(struct v4l2_format *fmt)
unsigned short lutrangecbcr16[65536]
const char * getQuantizationName(struct v4l2_format *fmt)
void linearize(float *buf, unsigned int len, struct v4l2_format *fmt)
unsigned short lutrangecbcr10[1024]
unsigned int getYCbCrEncoding(struct v4l2_format *fmt)
const char * getColorSpaceName(struct v4l2_format *fmt)
#define QUANTIZATION_FULL_RANGE
#define QUANTIZATION_LIM_RANGE
#define YCBCR_ENC_SMPTE240M