annotate libvo/vo_yuv4mpeg.c @ 4810:bb6b9aca7195

10l accidently commited an already customized version with different default scaling algo.
author atmos4
date Fri, 22 Feb 2002 17:58:46 +0000
parents 32e1f5042f65
children 041bd56e41dc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4597
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
1 /*
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
2 * vo_yuv4mpeg.c, yuv4mpeg (mjpegtools) interface
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
3 *
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
4 * Thrown together by
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
5 * Robert Kesterson <robertk@robertk.com>
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
6 * Based on the pgm output plugin, the rgb2rgb postproc filter, divxdec,
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
7 * and probably others.
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
8 *
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
9 * This is undoubtedly incomplete, inaccurate, or just plain wrong. :-)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
10 *
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
11 */
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
12
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
13 #include <stdio.h>
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
14 #include <stdlib.h>
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
15 #include <string.h>
4640
ea3bd3328fc6 removed unused includes, added fastmemcpy support, removed local copy of rgb24toyv12 (using one in postproc/rgb2rgb.c)
alex
parents: 4633
diff changeset
16 #include <unistd.h>
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4706
diff changeset
17 #include <errno.h>
4640
ea3bd3328fc6 removed unused includes, added fastmemcpy support, removed local copy of rgb24toyv12 (using one in postproc/rgb2rgb.c)
alex
parents: 4633
diff changeset
18 #include <fcntl.h>
4597
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
19
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
20 #include "config.h"
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
21 #include "video_out.h"
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
22 #include "video_out_internal.h"
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
23
4640
ea3bd3328fc6 removed unused includes, added fastmemcpy support, removed local copy of rgb24toyv12 (using one in postproc/rgb2rgb.c)
alex
parents: 4633
diff changeset
24 #include "fastmemcpy.h"
ea3bd3328fc6 removed unused includes, added fastmemcpy support, removed local copy of rgb24toyv12 (using one in postproc/rgb2rgb.c)
alex
parents: 4633
diff changeset
25 #include "../postproc/rgb2rgb.h"
4597
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
26
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
27 LIBVO_EXTERN (yuv4mpeg)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
28
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
29 static vo_info_t vo_info =
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
30 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
31 "yuv4mpeg output for mjpegtools (to \"stream.yuv\")",
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
32 "yuv4mpeg",
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
33 "Robert Kesterson <robertk@robertk.com>",
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
34 ""
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
35 };
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
36
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
37 static int image_width;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
38 static int image_height;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
39
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
40 static uint8_t *image = NULL;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
41 static uint8_t *image_y = NULL;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
42 static uint8_t *image_u = NULL;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
43 static uint8_t *image_v = NULL;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
44
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
45 static int using_format = 0;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
46 static FILE *yuv_out;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
47 int write_bytes;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
48
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
49 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
50 uint32_t d_height, uint32_t fullscreen, char *title,
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
51 uint32_t format, const vo_tune_info_t *tuneinfo)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
52 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
53 image_height = height;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
54 image_width = width;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
55 write_bytes = image_width * image_height * 3 / 2;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
56 using_format = format;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
57 image = malloc(write_bytes);
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
58
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
59 yuv_out = fopen("stream.yuv", "wb");
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
60 if (!yuv_out || image == NULL)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
61 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
62 perror("Can't get memory or file handle to stream.yuv");
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
63 return -1;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
64 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
65 image_y = image;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
66 image_u = image_y + image_width * image_height;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
67 image_v = image_u + (image_width * image_height) / 4;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
68
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
69 // This isn't right.
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
70 // But it should work as long as the file isn't interlaced
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
71 // or otherwise unusual (the "Ip A0:0" part).
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
72 fprintf(yuv_out, "YUV4MPEG2 W%d H%d F%ld:%ld Ip A0:0\n",
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
73 image_width, image_height, (long)(vo_fps * 1000000.0), 1000000);
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
74
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
75 fflush(yuv_out);
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
76 return 0;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
77 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
78
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
79 static const vo_info_t* get_info(void)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
80 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
81 return &vo_info;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
82 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
83
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
84 static void draw_osd(void)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
85 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
86 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
87
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
88 static void flip_page (void)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
89 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
90 fprintf(yuv_out, "FRAME\n");
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
91 if(fwrite(image, 1, write_bytes, yuv_out) != write_bytes)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
92 perror("Error writing image to output!");
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
93 return;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
94 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
95
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
96 static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,int y)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
97 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
98 if(using_format == IMGFMT_YV12)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
99 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
100 int i;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
101 // copy Y:
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
102 uint8_t *dst = image_y + image_width * y + x;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
103 uint8_t *src = srcimg[0];
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
104 for (i = 0; i < h; i++)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
105 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
106 memcpy(dst, src, w);
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
107 src += stride[0];
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
108 dst += image_width;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
109 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
110 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
111 // copy U + V:
4706
a4400910be9f yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents: 4640
diff changeset
112 int imgstride = image_width >> 1;
4597
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
113 uint8_t *src1 = srcimg[1];
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
114 uint8_t *src2 = srcimg[2];
4706
a4400910be9f yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents: 4640
diff changeset
115 uint8_t *dstu = image_u + imgstride * (y >> 1) + (x >> 1);
a4400910be9f yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents: 4640
diff changeset
116 uint8_t *dstv = image_v + imgstride * (y >> 1) + (x >> 1);
4597
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
117 for (i = 0; i < h / 2; i++)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
118 {
4706
a4400910be9f yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents: 4640
diff changeset
119 memcpy(dstu, src1 , w >> 1);
a4400910be9f yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents: 4640
diff changeset
120 memcpy(dstv, src2, w >> 1);
4597
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
121 src1 += stride[1];
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
122 src2 += stride[2];
4706
a4400910be9f yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents: 4640
diff changeset
123 dstu += imgstride;
a4400910be9f yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents: 4640
diff changeset
124 dstv += imgstride;
4597
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
125 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
126 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
127 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
128 return 0;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
129 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
130
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
131
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
132 static uint32_t draw_frame(uint8_t * src[])
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
133 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
134 switch(using_format)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
135 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
136 case IMGFMT_YV12:
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
137 // gets done in draw_slice
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
138 break;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
139 case IMGFMT_BGR|24:
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
140 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
141 #ifdef GUESS_THIS_ISNT_NEEDED
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
142 int c;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
143 uint8_t temp;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
144 //switch BGR to RGB
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
145 for(c = 0; c < image_width * image_height; c++)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
146 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
147 temp = src[0][c * 3];
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
148 src[0][c * 3] = src[0][c * 3 + 2];
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
149 src[0][c * 3 + 2] = temp;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
150 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
151 #endif
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
152 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
153 // intentional fall-through
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
154 case IMGFMT_RGB|24:
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
155 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
156 rgb24toyv12(src[0], image_y, image_u, image_v,
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
157 image_width, image_height,
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
158 image_width, image_width / 2, image_width * 3);
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
159 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
160 break;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
161 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
162 return 0;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
163 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
164
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
165 static uint32_t query_format(uint32_t format)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
166 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
167 switch(format){
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
168 case IMGFMT_YV12:
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
169 case IMGFMT_BGR|24:
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
170 case IMGFMT_RGB|24:
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
171 return 1;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
172 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
173 return 0;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
174 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
175
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
176 static void uninit(void)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
177 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
178 if(image)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
179 free(image);
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
180 image = NULL;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
181 if(yuv_out)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
182 fclose(yuv_out);
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
183 yuv_out = NULL;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
184 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
185
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
186
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
187 static void check_events(void)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
188 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
189 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
190
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
191
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
192 static uint32_t preinit(const char *arg)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
193 {
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4706
diff changeset
194 if(arg)
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4706
diff changeset
195 {
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4706
diff changeset
196 printf("vo_yuv4mpeg: Unknown subdevice: %s\n",arg);
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4706
diff changeset
197 return ENOSYS;
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4706
diff changeset
198 }
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4706
diff changeset
199 return 0;
4597
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
200 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
201
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
202 static uint32_t control(uint32_t request, void *data, ...)
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
203 {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
204 switch (request) {
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
205 case VOCTRL_QUERY_FORMAT:
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
206 return query_format(*((uint32_t*)data));
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
207 }
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
208 return VO_NOTIMPL;
4ba62f7d04c6 yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff changeset
209 }