Mercurial > mplayer.hg
annotate libvo/vo_yuv4mpeg.c @ 5915:f716aa9e2df2
Convert printf to mp_msg in the network layer
author | albeu |
---|---|
date | Tue, 30 Apr 2002 16:58:54 +0000 |
parents | 041bd56e41dc |
children | 7accc81d6f04 |
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 * |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
11 * |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
12 * 2002/04/17 Juergen Hammelmann <juergen.hammelmann@gmx.de> |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
13 * - added support for output of subtitles |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
14 * best, if you give option '-osdlevel 0' to mplayer for |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
15 * no watching the seek+timer |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
16 */ |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
17 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
18 #include <stdio.h> |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
19 #include <stdlib.h> |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
20 #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
|
21 #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
|
22 #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
|
23 #include <fcntl.h> |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
24 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
25 #include "config.h" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
26 #include "video_out.h" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
27 #include "video_out_internal.h" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
28 |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
29 #include "sub.h" |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
30 |
4640
ea3bd3328fc6
removed unused includes, added fastmemcpy support, removed local copy of rgb24toyv12 (using one in postproc/rgb2rgb.c)
alex
parents:
4633
diff
changeset
|
31 #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
|
32 #include "../postproc/rgb2rgb.h" |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
33 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
34 LIBVO_EXTERN (yuv4mpeg) |
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 static vo_info_t vo_info = |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
37 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
38 "yuv4mpeg output for mjpegtools (to \"stream.yuv\")", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
39 "yuv4mpeg", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
40 "Robert Kesterson <robertk@robertk.com>", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
41 "" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
42 }; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
43 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
44 static int image_width; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
45 static int image_height; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
46 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
47 static uint8_t *image = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
48 static uint8_t *image_y = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
49 static uint8_t *image_u = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
50 static uint8_t *image_v = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
51 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
52 static int using_format = 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
53 static FILE *yuv_out; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
54 int write_bytes; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
55 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
56 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
|
57 uint32_t d_height, uint32_t fullscreen, char *title, |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
58 uint32_t format, const vo_tune_info_t *tuneinfo) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
59 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
60 image_height = height; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
61 image_width = width; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
62 write_bytes = image_width * image_height * 3 / 2; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
63 using_format = format; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
64 image = malloc(write_bytes); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
65 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
66 yuv_out = fopen("stream.yuv", "wb"); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
67 if (!yuv_out || image == NULL) |
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 perror("Can't get memory or file handle to stream.yuv"); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
70 return -1; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
71 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
72 image_y = image; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
73 image_u = image_y + image_width * image_height; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
74 image_v = image_u + (image_width * image_height) / 4; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
75 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
76 // This isn't right. |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
77 // 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
|
78 // or otherwise unusual (the "Ip A0:0" part). |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
79 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
|
80 image_width, image_height, (long)(vo_fps * 1000000.0), 1000000); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
81 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
82 fflush(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
83 return 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
84 } |
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 static const vo_info_t* get_info(void) |
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 return &vo_info; |
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 |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
91 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
92 unsigned char *srca, int stride) { |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
93 if(using_format == IMGFMT_YV12) |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
94 { |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
95 vo_draw_alpha_yv12(w, h, src, srca, stride, |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
96 image+(y0*image_width+x0), image_width); |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
97 } |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
98 } |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
99 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
100 static void draw_osd(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
101 { |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
102 vo_draw_text(image_width, image_height, draw_alpha); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
103 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
104 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
105 static void flip_page (void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
106 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
107 fprintf(yuv_out, "FRAME\n"); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
108 if(fwrite(image, 1, write_bytes, yuv_out) != write_bytes) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
109 perror("Error writing image to output!"); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
110 return; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
111 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
112 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
113 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
|
114 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
115 if(using_format == IMGFMT_YV12) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
116 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
117 int i; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
118 // copy Y: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
119 uint8_t *dst = image_y + image_width * y + x; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
120 uint8_t *src = srcimg[0]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
121 for (i = 0; i < h; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
122 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
123 memcpy(dst, src, w); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
124 src += stride[0]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
125 dst += image_width; |
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 // copy U + V: |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
129 int imgstride = image_width >> 1; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
130 uint8_t *src1 = srcimg[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
131 uint8_t *src2 = srcimg[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
132 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
|
133 uint8_t *dstv = image_v + imgstride * (y >> 1) + (x >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
134 for (i = 0; i < h / 2; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
135 { |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
136 memcpy(dstu, src1 , w >> 1); |
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
137 memcpy(dstv, src2, w >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
138 src1 += stride[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
139 src2 += stride[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
140 dstu += imgstride; |
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
141 dstv += imgstride; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
142 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
143 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
144 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
145 return 0; |
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 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
148 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
149 static uint32_t draw_frame(uint8_t * src[]) |
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 switch(using_format) |
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 case IMGFMT_YV12: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
154 // gets done in draw_slice |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
155 break; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
156 case IMGFMT_BGR|24: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
157 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
158 #ifdef GUESS_THIS_ISNT_NEEDED |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
159 int c; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
160 uint8_t temp; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
161 //switch BGR to RGB |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
162 for(c = 0; c < image_width * image_height; c++) |
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 temp = src[0][c * 3]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
165 src[0][c * 3] = src[0][c * 3 + 2]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
166 src[0][c * 3 + 2] = temp; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
167 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
168 #endif |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
169 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
170 // intentional fall-through |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
171 case IMGFMT_RGB|24: |
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 rgb24toyv12(src[0], image_y, image_u, image_v, |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
174 image_width, image_height, |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
175 image_width, image_width / 2, image_width * 3); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
176 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
177 break; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
178 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
179 return 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
180 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
181 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
182 static uint32_t query_format(uint32_t format) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
183 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
184 switch(format){ |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
185 case IMGFMT_YV12: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
186 case IMGFMT_BGR|24: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
187 case IMGFMT_RGB|24: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
188 return 1; |
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 return 0; |
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 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
193 static void uninit(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
194 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
195 if(image) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
196 free(image); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
197 image = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
198 if(yuv_out) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
199 fclose(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
200 yuv_out = NULL; |
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 |
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 static void check_events(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
205 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
206 } |
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 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
209 static uint32_t preinit(const char *arg) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
210 { |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4706
diff
changeset
|
211 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
|
212 { |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4706
diff
changeset
|
213 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
|
214 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
|
215 } |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4706
diff
changeset
|
216 return 0; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
217 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
218 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
219 static uint32_t control(uint32_t request, void *data, ...) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
220 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
221 switch (request) { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
222 case VOCTRL_QUERY_FORMAT: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
223 return query_format(*((uint32_t*)data)); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
224 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
225 return VO_NOTIMPL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
226 } |