128 switch (
fmt.fmt.pix.pixelformat)
130 case V4L2_PIX_FMT_GREY:
133 unsigned char *src = frame +
crop.c.left + (
crop.c.top *
fmt.fmt.pix.width);
134 unsigned char *dest =
YBuf;
136 for (
unsigned int i = 0; i < (
unsigned int)
crop.c.height; i++)
138 memcpy(dest, src,
crop.c.width);
139 src +=
fmt.fmt.pix.width;
140 dest +=
crop.c.width;
149 case V4L2_PIX_FMT_Y16:
152 unsigned char *src = frame + 2 * (
crop.c.left) + (
crop.c.top *
fmt.fmt.pix.bytesperline);
155 for (
unsigned int i = 0; i < (
unsigned int)
crop.c.height; i++)
157 memcpy(dest, src, 2 *
crop.c.width);
158 src +=
fmt.fmt.pix.bytesperline;
159 dest += 2 *
crop.c.width;
164 unsigned char *src = frame;
166 for (
unsigned int i = 0; i <
bufheight; i++)
169 src +=
fmt.fmt.pix.bytesperline;
175 case V4L2_PIX_FMT_YUV420:
176 case V4L2_PIX_FMT_YVU420:
179 unsigned char *src = frame +
crop.c.left + (
crop.c.top *
fmt.fmt.pix.width);
180 unsigned char *dest =
YBuf;
183 for (
unsigned int i = 0; i < (
unsigned int)
crop.c.height; i++)
185 memcpy(dest, src,
crop.c.width);
186 src +=
fmt.fmt.pix.width;
187 dest +=
crop.c.width;
191 src = frame + (
fmt.fmt.pix.width *
fmt.fmt.pix.height) +
192 ((
crop.c.left + (
crop.c.top *
fmt.fmt.pix.width) / 2) / 2);
193 if (
fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_YVU420)
197 for (
unsigned int i = 0; i < (
unsigned int)
crop.c.height / 2; i++)
199 memcpy(dest, src,
crop.c.width / 2);
200 src +=
fmt.fmt.pix.width / 2;
201 dest +=
crop.c.width / 2;
205 src = frame + (
fmt.fmt.pix.width *
fmt.fmt.pix.height) +
206 ((
fmt.fmt.pix.width *
fmt.fmt.pix.height) / 4) +
207 ((
crop.c.left + (
crop.c.top *
fmt.fmt.pix.width) / 2) / 2);
208 if (
fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_YVU420)
212 for (
unsigned int i = 0; i < (
unsigned int)
crop.c.height / 2; i++)
214 memcpy(dest, src,
crop.c.width / 2);
215 src +=
fmt.fmt.pix.width / 2;
216 dest +=
crop.c.width / 2;
222 if (
fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_YUV420)
230 if (
fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_YVU420)
240 case V4L2_PIX_FMT_NV12:
241 case V4L2_PIX_FMT_NV21:
244 unsigned char *src = frame +
crop.c.left + (
crop.c.top *
fmt.fmt.pix.bytesperline);
245 unsigned char *dest =
YBuf, *destv =
nullptr;
248 for (
unsigned int i = 0; i < (
unsigned int)
crop.c.height; i++)
250 memcpy(dest, src,
crop.c.width);
251 src +=
fmt.fmt.pix.bytesperline;
252 dest +=
crop.c.width;
257 src = frame + (
fmt.fmt.pix.bytesperline *
fmt.fmt.pix.height) +
258 ((
crop.c.left + (
crop.c.top *
fmt.fmt.pix.bytesperline) / 2) / 2);
259 if (
fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_NV21)
264 for (
unsigned int i = 0; i < (
unsigned int)
crop.c.height / 2; i++)
266 unsigned char *s = src;
267 for (
unsigned int j = 0; j < (
unsigned int)
crop.c.width; j += 2)
272 src +=
fmt.fmt.pix.bytesperline;
277 unsigned char *src = frame;
278 unsigned char *dest =
YBuf;
279 unsigned char *destv =
VBuf;
280 unsigned char *s =
nullptr;
282 for (
unsigned int i = 0; i <
bufheight; i++)
285 src +=
fmt.fmt.pix.bytesperline;
290 if (
fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_NV21)
295 for (
unsigned int i = 0; i <
bufheight / 2; i++)
299 for (
unsigned int j = 0; j <
bufwidth; j += 2)
304 src +=
fmt.fmt.pix.bytesperline;
309 case V4L2_PIX_FMT_YUYV:
312 unsigned char *src = frame + 2 * (
crop.c.left) + (
crop.c.top *
fmt.fmt.pix.bytesperline);
315 for (
unsigned int i = 0; i < (
unsigned int)
crop.c.height; i++)
317 memcpy(dest, src, 2 *
crop.c.width);
318 src +=
fmt.fmt.pix.bytesperline;
319 dest += 2 *
crop.c.width;
328 case V4L2_PIX_FMT_UYVY:
329 case V4L2_PIX_FMT_VYUY:
330 case V4L2_PIX_FMT_YVYU:
332 unsigned char *src =
nullptr;
334 unsigned char *s =
nullptr, *s1 =
nullptr, *s2 =
nullptr, *s3 =
nullptr, *s4 =
nullptr;
338 src = frame + 2 * (
crop.c.left) + (
crop.c.top *
fmt.fmt.pix.bytesperline);
349 switch (
fmt.fmt.pix.pixelformat)
351 case V4L2_PIX_FMT_UYVY:
357 case V4L2_PIX_FMT_VYUY:
363 case V4L2_PIX_FMT_YVYU:
370 for (
int j = 0; j < (int)(
bufwidth / 2); j++)
381 src +=
fmt.fmt.pix.bytesperline;
386 case V4L2_PIX_FMT_RGB24:
392 src = frame + (3 * (
crop.c.left)) + (
crop.c.top *
fmt.fmt.pix.bytesperline);
398 for (
unsigned int i = 0; i <
bufheight; i++)
401 src +=
fmt.fmt.pix.bytesperline;
408 case V4L2_PIX_FMT_RGB555:
414 src = frame + (2 * (
crop.c.left)) + (
crop.c.top *
fmt.fmt.pix.bytesperline);
420 for (
unsigned int i = 0; i <
bufheight; i++)
422 unsigned char *s = src;
423 for (
unsigned int j = 0; j <
bufwidth; j++)
425 *(dest++) =
lut5[((*(s + 1) & 0x7C) >> 2)];
426 *(dest++) =
lut5[(((*(s + 1) & 0x03) << 3) | ((*(s) & 0xE0) >> 5))];
427 *(dest++) =
lut5[((*s) & 0x1F)];
430 src +=
fmt.fmt.pix.bytesperline;
435 case V4L2_PIX_FMT_RGB565:
441 src = frame + (2 * (
crop.c.left)) + (
crop.c.top *
fmt.fmt.pix.bytesperline);
447 for (
unsigned int i = 0; i <
bufheight; i++)
449 unsigned char *s = src;
450 for (
unsigned int j = 0; j <
bufwidth; j++)
452 *(dest++) =
lut5[((*(s + 1) & 0xF8) >> 3)];
453 *(dest++) =
lut6[(((*(s + 1) & 0x07) << 3) | ((*(s) & 0xE0) >> 5))];
454 *(dest++) =
lut5[((*s) & 0x1F)];
457 src +=
fmt.fmt.pix.bytesperline;
462 case V4L2_PIX_FMT_SBGGR8:
466 case V4L2_PIX_FMT_SRGGB8:
469 case V4L2_PIX_FMT_SGRBG8:
472 case V4L2_PIX_FMT_SBGGR16:
477 case V4L2_PIX_FMT_JPEG:
478 case V4L2_PIX_FMT_MJPEG:
480 memcpy(
yuvBuffer, frame, buf->bytesused);
487 unsigned char *src =
YBuf;
491 *(src++) = random() % 255;
885 std::make_pair(V4L2_PIX_FMT_RGB555,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_RGB555, 8,
true)));
888 std::make_pair(V4L2_PIX_FMT_RGB565,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_RGB565, 8,
true)));
895 std::make_pair(V4L2_PIX_FMT_RGB24,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_RGB24, 8,
true)));
902 std::make_pair(V4L2_PIX_FMT_GREY,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_GREY, 8,
true)));
909 std::make_pair(V4L2_PIX_FMT_Y16,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_Y16, 16,
true)));
924 std::make_pair(V4L2_PIX_FMT_YVU420,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_YVU420, 8,
true)));
927 std::make_pair(V4L2_PIX_FMT_YUYV,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_YUYV, 8,
true)));
931 std::make_pair(V4L2_PIX_FMT_YVYU,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_YVYU, 8,
true)));
934 std::make_pair(V4L2_PIX_FMT_UYVY,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_UYVY, 8,
true)));
937 std::make_pair(V4L2_PIX_FMT_VYUY,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_VYUY, 8,
true)));
948 std::make_pair(V4L2_PIX_FMT_YUV420,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_YUV420, 8,
true)));
956 std::make_pair(V4L2_PIX_FMT_NV12,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_NV12, 8,
true)));
959 std::make_pair(V4L2_PIX_FMT_NV21,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_NV21, 8,
true)));
980 std::make_pair(V4L2_PIX_FMT_SBGGR8,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_SBGGR8, 8,
false)));
984 std::make_pair(V4L2_PIX_FMT_SGRBG8,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_SGRBG8, 8,
false)));
987 std::make_pair(V4L2_PIX_FMT_SRGGB8,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_SRGGB8, 8,
false)));
1012 std::make_pair(V4L2_PIX_FMT_SBGGR16,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_SBGGR16, 16,
false)));
1017 std::make_pair(V4L2_PIX_FMT_MJPEG,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_MJPEG, 8,
false)));
1020 std::make_pair(V4L2_PIX_FMT_JPEG,
new V4L2_Builtin_Decoder::format(V4L2_PIX_FMT_JPEG, 8,
false)));
1063 for (std::map<unsigned int, struct format *>::iterator it =
supported_formats.begin();