Skip to content

Commit 58ac5f8

Browse files
Mr-DaveDevMr-Dave
authored andcommitted
Revised Pixel format (Motion-Project#756)
* YUV422P format * RGB format
1 parent dff5dd2 commit 58ac5f8

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

video_bktr.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -590,11 +590,12 @@ static int bktr_capture(struct video_dev *viddev, unsigned char *map, int width,
590590
break;
591591
case METEOR_GEO_YUV_PACKED:
592592
/*FALLTHROUGH*/
593-
case METEOR_GEO_YUV_PLANAR:
594-
/*FALLTHROUGH*/
595593
case METEOR_GEO_YUV_422:
596594
vid_yuv422to420p(map, cap_map, width, height);
597595
break;
596+
case METEOR_GEO_YUV_PLANAR:
597+
vid_yuv422pto420p(map, cap_map, width, height);
598+
break;
598599
case METEOR_GEO_YUV_9:
599600
/*FALLTHROUGH*/
600601
case METEOR_GEO_YUV_12:

video_common.c

+41-3
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,43 @@ void vid_yuv422to420p(unsigned char *map, unsigned char *cap_map, int width, int
288288
}
289289
}
290290

291+
void vid_yuv422pto420p(unsigned char *map, unsigned char *cap_map, int width, int height)
292+
{
293+
unsigned char *src, *dest, *dest2;
294+
unsigned char *src_u, *src_u2, *src_v, *src_v2;
295+
296+
int i, j;
297+
/*Planar version of 422 */
298+
/* Create the Y plane. */
299+
src = cap_map;
300+
dest = map;
301+
for (i = width * height; i > 0; i--) {
302+
*dest++ = *src++;
303+
}
304+
305+
/* Create U and V planes. */
306+
dest = map + width * height;
307+
dest2 = dest + (width * height) / 4;
308+
for (i = 0; i< (height / 2)-2; i++) {
309+
src_u = cap_map + (width * height) + ((i*2) * (width/2));
310+
src_u2 = src_u + (width/2);
311+
src_v = src_u + (width/2 * height);
312+
src_v2 = src_v + (width/2);
313+
314+
for (j = 0; j < (width / 2); j++) {
315+
*dest = ((int) *src_u + (int) *src_u2) / 2;
316+
src_u ++;
317+
src_u2++;
318+
dest++;
319+
320+
*dest2 = ((int) *src_v + (int) *src_v2) / 2;
321+
src_v ++;
322+
src_v2++;
323+
dest2++;
324+
}
325+
}
326+
}
327+
291328
void vid_uyvyto420p(unsigned char *map, unsigned char *cap_map, int width, int height)
292329
{
293330
uint8_t *pY = map;
@@ -329,9 +366,10 @@ void vid_rgb24toyuv420p(unsigned char *map, unsigned char *cap_map, int width, i
329366
unsigned char *r, *g, *b;
330367
int i, loop;
331368

332-
b = cap_map;
333-
g = b + 1;
334-
r = g + 1;
369+
r = cap_map;
370+
g = r + 1;
371+
b = g + 1;
372+
335373
y = map;
336374
u = y + width * height;
337375
v = u + (width * height) / 4;

video_common.h

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void vid_mutex_init(void);
5959
int vid_parms_parse(struct context *cnt);
6060

6161
void vid_yuv422to420p(unsigned char *map, unsigned char *cap_map, int width, int height);
62+
void vid_yuv422pto420p(unsigned char *map, unsigned char *cap_map, int width, int height);
6263
void vid_uyvyto420p(unsigned char *map, unsigned char *cap_map, int width, int height);
6364
void vid_rgb24toyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height);
6465
void vid_bayer2rgb24(unsigned char *dst, unsigned char *src, long int width, long int height);

video_v4l2.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1068,10 +1068,11 @@ static int v4l2_capture(struct context *cnt, struct video_dev *curdev, unsigned
10681068
return 0;
10691069

10701070
case V4L2_PIX_FMT_YUYV:
1071-
/*FALLTHROUGH*/
1072-
case V4L2_PIX_FMT_YUV422P:
10731071
vid_yuv422to420p(map, the_buffer->ptr, width, height);
10741072
return 0;
1073+
case V4L2_PIX_FMT_YUV422P:
1074+
vid_yuv422pto420p(map, the_buffer->ptr, width, height);
1075+
return 0;
10751076

10761077
case V4L2_PIX_FMT_YUV420:
10771078
memcpy(map, the_buffer->ptr, the_buffer->content_length);

0 commit comments

Comments
 (0)