Mercurial > mplayer.hg
annotate libvo/vo_yuv4mpeg.c @ 20135:7079d029d27c
Free track data if error occurs while reading trackentry
author | reimar |
---|---|
date | Mon, 09 Oct 2006 18:48:55 +0000 |
parents | 8579acff875e |
children | 69cb57c406a8 |
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 * |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
11 * 2002/06/19 Klaus Stengel <Klaus.Stengel@asamnet.de> |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
12 * - added support for interlaced output |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
13 * Activate by using '-vo yuv4mpeg:interlaced' |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
14 * or '-vo yuv4mpeg:interlaced_bf' if your source has |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
15 * bottom fields first |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
16 * - added some additional checks to catch problems |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
17 * |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
18 * 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
|
19 * - added support for output of subtitles |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
20 * 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
|
21 * no watching the seek+timer |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
22 */ |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
23 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
24 #include <stdio.h> |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
25 #include <stdlib.h> |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
26 #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
|
27 #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
|
28 #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
|
29 #include <fcntl.h> |
4597
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 #include "config.h" |
14284 | 32 #include "subopt-helper.h" |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
33 #include "video_out.h" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
34 #include "video_out_internal.h" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
35 |
13462 | 36 #include "mp_msg.h" |
37 #include "help_mp.h" | |
38 | |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
39 #include "sub.h" |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
40 |
4640
ea3bd3328fc6
removed unused includes, added fastmemcpy support, removed local copy of rgb24toyv12 (using one in postproc/rgb2rgb.c)
alex
parents:
4633
diff
changeset
|
41 #include "fastmemcpy.h" |
18861 | 42 #include "libswscale/swscale.h" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13462
diff
changeset
|
43 #include "libmpcodecs/vf_scale.h" |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
44 |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7688
diff
changeset
|
45 static vo_info_t info = |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
46 { |
14095 | 47 "yuv4mpeg output for mjpegtools", |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
48 "yuv4mpeg", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
49 "Robert Kesterson <robertk@robertk.com>", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
50 "" |
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 |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7688
diff
changeset
|
53 LIBVO_EXTERN (yuv4mpeg) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7688
diff
changeset
|
54 |
14145 | 55 static int image_width = 0; |
56 static int image_height = 0; | |
57 static float image_fps = 0; | |
4597
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 static uint8_t *image = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
60 static uint8_t *image_y = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
61 static uint8_t *image_u = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
62 static uint8_t *image_v = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
63 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
64 static uint8_t *rgb_buffer = NULL; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
65 static uint8_t *rgb_line_buffer = NULL; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
66 |
14095 | 67 static char *yuv_filename = NULL; |
68 | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
69 static int using_format = 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
70 static FILE *yuv_out; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
71 static int write_bytes; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
72 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
73 #define Y4M_ILACE_NONE 'p' /* non-interlaced, progressive frame */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
74 #define Y4M_ILACE_TOP_FIRST 't' /* interlaced, top-field first */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
75 #define Y4M_ILACE_BOTTOM_FIRST 'b' /* interlaced, bottom-field first */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
76 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
77 /* Set progressive mode as default */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
78 static int config_interlace = Y4M_ILACE_NONE; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
79 #define Y4M_IS_INTERLACED (config_interlace != Y4M_ILACE_NONE) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
80 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
81 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14538
diff
changeset
|
82 uint32_t d_height, uint32_t flags, char *title, |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
6659
diff
changeset
|
83 uint32_t format) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
84 { |
14145 | 85 if (image_width == width && image_height == height && |
86 image_fps == vo_fps && vo_config_count) | |
87 return 0; | |
88 if (vo_config_count) { | |
89 mp_msg(MSGT_VO, MSGL_WARN, | |
90 "Video formats differ (w:%i=>%i, h:%i=>%i, fps:%f=>%f), " | |
91 "restarting output.\n", | |
92 image_width, width, image_height, height, image_fps, vo_fps); | |
93 uninit(); | |
94 } | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
95 image_height = height; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
96 image_width = width; |
14145 | 97 image_fps = vo_fps; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
98 using_format = format; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
99 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
100 if (Y4M_IS_INTERLACED) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
101 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
102 if (height % 4) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
103 { |
13462 | 104 mp_msg(MSGT_VO,MSGL_FATAL, |
105 MSGTR_VO_YUV4MPEG_InterlacedHeightDivisibleBy4); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
106 return -1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
107 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
108 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
109 rgb_line_buffer = malloc(image_width * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
110 if (!rgb_line_buffer) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
111 { |
13462 | 112 mp_msg(MSGT_VO,MSGL_FATAL, |
113 MSGTR_VO_YUV4MPEG_InterlacedLineBufAllocFail); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
114 return -1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
115 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
116 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
117 if (using_format == IMGFMT_YV12) |
13462 | 118 mp_msg(MSGT_VO,MSGL_WARN, |
119 MSGTR_VO_YUV4MPEG_InterlacedInputNotRGB); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
120 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
121 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
122 if (width % 2) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
123 { |
13462 | 124 mp_msg(MSGT_VO,MSGL_FATAL, |
125 MSGTR_VO_YUV4MPEG_WidthDivisibleBy2); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
126 return -1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
127 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
128 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
129 if(using_format != IMGFMT_YV12) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
130 { |
10802 | 131 sws_rgb2rgb_init(get_sws_cpuflags()); |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
132 rgb_buffer = malloc(image_width * image_height * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
133 if (!rgb_buffer) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
134 { |
13462 | 135 mp_msg(MSGT_VO,MSGL_FATAL, |
136 MSGTR_VO_YUV4MPEG_NoMemRGBFrameBuf); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
137 return -1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
138 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
139 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
140 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
141 write_bytes = image_width * image_height * 3 / 2; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
142 image = malloc(write_bytes); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
143 |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
144 yuv_out = fopen(yuv_filename, "wb"); |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
145 if (!yuv_out || image == 0) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
146 { |
13462 | 147 mp_msg(MSGT_VO,MSGL_FATAL, |
14095 | 148 MSGTR_VO_YUV4MPEG_OutFileOpenError, |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
149 yuv_filename); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
150 return -1; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
151 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
152 image_y = image; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
153 image_u = image_y + image_width * image_height; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
154 image_v = image_u + image_width * image_height / 4; |
4597
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 // This isn't right. |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
157 // 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
|
158 // or otherwise unusual (the "Ip A0:0" part). |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
159 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
160 /* At least the interlacing is ok now */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
161 fprintf(yuv_out, "YUV4MPEG2 W%d H%d F%ld:%ld I%c A0:0\n", |
14145 | 162 image_width, image_height, (long)(image_fps * 1000000.0), |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
163 (long)1000000, config_interlace); |
4597
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 fflush(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
166 return 0; |
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 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
169 /* Only use when h divisable by 2! */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
170 static void swap_fields(uint8_t *ptr, const int h, const int stride) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
171 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
172 int i; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
173 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
174 for (i=0; i<h; i +=2) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
175 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
176 memcpy(rgb_line_buffer , ptr + stride * i , stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
177 memcpy(ptr + stride * i , ptr + stride * (i+1), stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
178 memcpy(ptr + stride * (i+1), rgb_line_buffer , stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
179 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
180 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
181 |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
182 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
|
183 unsigned char *srca, int stride) { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
184 switch (using_format) |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
185 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
186 case IMGFMT_YV12: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
187 vo_draw_alpha_yv12(w, h, src, srca, stride, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
188 image + y0 * image_width + x0, image_width); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
189 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
190 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
191 case IMGFMT_BGR|24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
192 case IMGFMT_RGB|24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
193 if (config_interlace != Y4M_ILACE_BOTTOM_FIRST) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
194 vo_draw_alpha_rgb24(w, h, src, srca, stride, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
195 rgb_buffer + (y0 * image_width + x0) * 3, image_width * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
196 else |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
197 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
198 swap_fields (rgb_buffer, image_height, image_width * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
199 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
200 vo_draw_alpha_rgb24(w, h, src, srca, stride, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
201 rgb_buffer + (y0 * image_width + x0) * 3, image_width * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
202 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
203 swap_fields (rgb_buffer, image_height, image_width * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
204 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
205 break; |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
206 } |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
207 } |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
208 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
209 static void draw_osd(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
210 { |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
211 vo_draw_text(image_width, image_height, draw_alpha); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
212 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
213 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
214 static void deinterleave_fields(uint8_t *ptr, const int stride, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
215 const int img_height) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
216 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
217 unsigned int i, j, k_start = 1, modv = img_height - 1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
218 unsigned char *line_state = malloc(modv); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
219 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
220 for (i=0; i<modv; i++) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
221 line_state[i] = 0; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
222 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
223 line_state[0] = 1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
224 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
225 while(k_start < modv) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
226 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
227 i = j = k_start; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
228 memcpy(rgb_line_buffer, ptr + stride * i, stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
229 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
230 while (!line_state[j]) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
231 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
232 line_state[j] = 1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
233 i = j; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
234 j = j * 2 % modv; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
235 memcpy(ptr + stride * i, ptr + stride * j, stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
236 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
237 memcpy(ptr + stride * i, rgb_line_buffer, stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
238 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
239 while(k_start < modv && line_state[k_start]) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
240 k_start++; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
241 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
242 free(line_state); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
243 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
244 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
245 static void vo_y4m_write(const void *ptr, const size_t num_bytes) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
246 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
247 if (fwrite(ptr, 1, num_bytes, yuv_out) != num_bytes) |
13462 | 248 mp_msg(MSGT_VO,MSGL_ERR, |
249 MSGTR_VO_YUV4MPEG_OutFileWriteError); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
250 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
251 |
8450 | 252 static int write_last_frame(void) |
253 { | |
254 | |
255 uint8_t *upper_y, *upper_u, *upper_v, *rgb_buffer_lower; | |
256 int rgb_stride, uv_stride, field_height; | |
257 unsigned int i, low_ofs; | |
258 | |
259 fprintf(yuv_out, "FRAME\n"); | |
260 | |
261 if (using_format != IMGFMT_YV12) | |
262 { | |
263 rgb_stride = image_width * 3; | |
264 uv_stride = image_width / 2; | |
265 | |
266 if (Y4M_IS_INTERLACED) | |
267 { | |
268 field_height = image_height / 2; | |
269 | |
270 upper_y = image; | |
271 upper_u = upper_y + image_width * field_height; | |
272 upper_v = upper_u + image_width * field_height / 4; | |
273 low_ofs = image_width * field_height * 3 / 2; | |
274 rgb_buffer_lower = rgb_buffer + rgb_stride * field_height; | |
275 | |
276 /* Write Y plane */ | |
277 for(i = 0; i < field_height; i++) | |
278 { | |
279 vo_y4m_write(upper_y + image_width * i, image_width); | |
280 vo_y4m_write(upper_y + image_width * i + low_ofs, image_width); | |
281 } | |
282 | |
283 /* Write U and V plane */ | |
284 for(i = 0; i < field_height / 2; i++) | |
285 { | |
286 vo_y4m_write(upper_u + uv_stride * i, uv_stride); | |
287 vo_y4m_write(upper_u + uv_stride * i + low_ofs, uv_stride); | |
288 } | |
289 for(i = 0; i < field_height / 2; i++) | |
290 { | |
291 vo_y4m_write(upper_v + uv_stride * i, uv_stride); | |
292 vo_y4m_write(upper_v + uv_stride * i + low_ofs, uv_stride); | |
293 } | |
294 return VO_TRUE; /* Image written; We have to stop here */ | |
295 } | |
296 } | |
297 /* Write progressive frame */ | |
298 vo_y4m_write(image, write_bytes); | |
299 return VO_TRUE; | |
300 } | |
301 | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
302 static void flip_page (void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
303 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
304 uint8_t *upper_y, *upper_u, *upper_v, *rgb_buffer_lower; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
305 int rgb_stride, uv_stride, field_height; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
306 unsigned int i, low_ofs; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
307 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
308 fprintf(yuv_out, "FRAME\n"); |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
309 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
310 if (using_format != IMGFMT_YV12) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
311 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
312 rgb_stride = image_width * 3; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
313 uv_stride = image_width / 2; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
314 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
315 if (Y4M_IS_INTERLACED) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
316 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
317 field_height = image_height / 2; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
318 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
319 upper_y = image; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
320 upper_u = upper_y + image_width * field_height; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
321 upper_v = upper_u + image_width * field_height / 4; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
322 low_ofs = image_width * field_height * 3 / 2; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
323 rgb_buffer_lower = rgb_buffer + rgb_stride * field_height; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
324 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
325 deinterleave_fields(rgb_buffer, rgb_stride, image_height); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
326 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
327 rgb24toyv12(rgb_buffer, upper_y, upper_u, upper_v, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
328 image_width, field_height, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
329 image_width, uv_stride, rgb_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
330 rgb24toyv12(rgb_buffer_lower, upper_y + low_ofs, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
331 upper_u + low_ofs, upper_v + low_ofs, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
332 image_width, field_height, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
333 image_width, uv_stride, rgb_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
334 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
335 /* Write Y plane */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
336 for(i = 0; i < field_height; i++) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
337 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
338 vo_y4m_write(upper_y + image_width * i, image_width); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
339 vo_y4m_write(upper_y + image_width * i + low_ofs, image_width); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
340 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
341 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
342 /* Write U and V plane */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
343 for(i = 0; i < field_height / 2; i++) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
344 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
345 vo_y4m_write(upper_u + uv_stride * i, uv_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
346 vo_y4m_write(upper_u + uv_stride * i + low_ofs, uv_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
347 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
348 for(i = 0; i < field_height / 2; i++) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
349 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
350 vo_y4m_write(upper_v + uv_stride * i, uv_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
351 vo_y4m_write(upper_v + uv_stride * i + low_ofs, uv_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
352 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
353 return; /* Image written; We have to stop here */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
354 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
355 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
356 rgb24toyv12(rgb_buffer, image_y, image_u, image_v, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
357 image_width, image_height, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
358 image_width, uv_stride, rgb_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
359 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
360 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
361 /* Write progressive frame */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
362 vo_y4m_write(image, write_bytes); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
363 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
364 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
365 static int draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,int y) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
366 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
367 int i; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
368 uint8_t *dst, *src = srcimg[0]; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
369 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
370 switch (using_format) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
371 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
372 case IMGFMT_YV12: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
373 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
374 // copy Y: |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
375 dst = image_y + image_width * y + x; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
376 for (i = 0; i < h; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
377 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
378 memcpy(dst, src, w); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
379 src += stride[0]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
380 dst += image_width; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
381 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
382 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
383 // copy U + V: |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
384 int imgstride = image_width >> 1; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
385 uint8_t *src1 = srcimg[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
386 uint8_t *src2 = srcimg[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
387 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
|
388 uint8_t *dstv = image_v + imgstride * (y >> 1) + (x >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
389 for (i = 0; i < h / 2; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
390 { |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
391 memcpy(dstu, src1 , w >> 1); |
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
392 memcpy(dstv, src2, w >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
393 src1 += stride[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
394 src2 += stride[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
395 dstu += imgstride; |
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
396 dstv += imgstride; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
397 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
398 } |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
399 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
400 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
401 case IMGFMT_BGR24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
402 case IMGFMT_RGB24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
403 dst = rgb_buffer + (image_width * y + x) * 3; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
404 for (i = 0; i < h; i++) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
405 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
406 memcpy(dst, src, w * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
407 src += stride[0]; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
408 dst += image_width * 3; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
409 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
410 break; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
411 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
412 return 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
413 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
414 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
415 static int draw_frame(uint8_t * src[]) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
416 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
417 switch(using_format) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
418 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
419 case IMGFMT_YV12: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
420 // gets done in draw_slice |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
421 break; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
422 |
7688
41d242c5bee1
since draw_slice() can handle packed RGB too, set the VFCAP_ACCEPT_STRIDE flag
arpi
parents:
7124
diff
changeset
|
423 case IMGFMT_BGR24: |
41d242c5bee1
since draw_slice() can handle packed RGB too, set the VFCAP_ACCEPT_STRIDE flag
arpi
parents:
7124
diff
changeset
|
424 case IMGFMT_RGB24: |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
425 memcpy(rgb_buffer, src[0], image_width * image_height * 3); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
426 break; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
427 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
428 return 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
429 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
430 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
431 static int query_format(uint32_t format) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
432 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
433 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
434 if (Y4M_IS_INTERLACED) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
435 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
436 /* When processing interlaced material we want to get the raw RGB |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
437 * data and do the YV12 conversion ourselves to have the chrominance |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
438 * information sampled correct. */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
439 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
440 switch(format) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
441 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
442 case IMGFMT_YV12: |
7688
41d242c5bee1
since draw_slice() can handle packed RGB too, set the VFCAP_ACCEPT_STRIDE flag
arpi
parents:
7124
diff
changeset
|
443 return VFCAP_CSP_SUPPORTED|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
444 case IMGFMT_BGR|24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
445 case IMGFMT_RGB|24: |
7688
41d242c5bee1
since draw_slice() can handle packed RGB too, set the VFCAP_ACCEPT_STRIDE flag
arpi
parents:
7124
diff
changeset
|
446 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
447 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
448 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
449 else |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
450 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
451 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
452 switch(format) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
453 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
454 case IMGFMT_YV12: |
7688
41d242c5bee1
since draw_slice() can handle packed RGB too, set the VFCAP_ACCEPT_STRIDE flag
arpi
parents:
7124
diff
changeset
|
455 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
456 case IMGFMT_BGR|24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
457 case IMGFMT_RGB|24: |
7688
41d242c5bee1
since draw_slice() can handle packed RGB too, set the VFCAP_ACCEPT_STRIDE flag
arpi
parents:
7124
diff
changeset
|
458 return VFCAP_CSP_SUPPORTED|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
459 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
460 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
461 return 0; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
462 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
463 |
14145 | 464 // WARNING: config(...) also uses this |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
465 static void uninit(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
466 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
467 if(image) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
468 free(image); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
469 image = NULL; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
470 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
471 if(yuv_out) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
472 fclose(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
473 yuv_out = NULL; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
474 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
475 if(rgb_buffer) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
476 free(rgb_buffer); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
477 rgb_buffer = NULL; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
478 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
479 if(rgb_line_buffer) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
480 free(rgb_line_buffer); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
481 rgb_line_buffer = NULL; |
14095 | 482 |
483 if (yuv_filename) | |
484 free(yuv_filename); | |
485 yuv_filename = NULL; | |
14145 | 486 image_width = 0; |
487 image_height = 0; | |
488 image_fps = 0; | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
489 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
490 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
491 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
492 static void check_events(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
493 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
494 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
495 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
496 static int preinit(const char *arg) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
497 { |
14284 | 498 int il, il_bf; |
499 opt_t subopts[] = { | |
500 {"interlaced", OPT_ARG_BOOL, &il, NULL}, | |
501 {"interlaced_bf", OPT_ARG_BOOL, &il_bf, NULL}, | |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
502 {"file", OPT_ARG_MSTRZ, &yuv_filename, NULL}, |
14284 | 503 {NULL} |
504 }; | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
505 |
14284 | 506 il = 0; |
507 il_bf = 0; | |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
508 yuv_filename = strdup("stream.yuv"); |
14284 | 509 if (subopt_parse(arg, subopts) != 0) { |
510 mp_msg(MSGT_VO, MSGL_FATAL, MSGTR_VO_YUV4MPEG_UnknownSubDev, arg); | |
511 return -1; | |
512 } | |
513 | |
514 config_interlace = Y4M_ILACE_NONE; | |
515 if (il) | |
516 config_interlace = Y4M_ILACE_TOP_FIRST; | |
517 if (il_bf) | |
518 config_interlace = Y4M_ILACE_BOTTOM_FIRST; | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
519 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
520 /* Inform user which output mode is used */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
521 switch (config_interlace) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
522 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
523 case Y4M_ILACE_TOP_FIRST: |
13462 | 524 mp_msg(MSGT_VO,MSGL_STATUS, |
525 MSGTR_VO_YUV4MPEG_InterlacedTFFMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
526 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
527 case Y4M_ILACE_BOTTOM_FIRST: |
13462 | 528 mp_msg(MSGT_VO,MSGL_STATUS, |
529 MSGTR_VO_YUV4MPEG_InterlacedBFFMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
530 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
531 default: |
13462 | 532 mp_msg(MSGT_VO,MSGL_STATUS, |
533 MSGTR_VO_YUV4MPEG_ProgressiveMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
534 break; |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4706
diff
changeset
|
535 } |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4706
diff
changeset
|
536 return 0; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
537 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
538 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
539 static int control(uint32_t request, void *data, ...) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
540 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
541 switch (request) { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
542 case VOCTRL_QUERY_FORMAT: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
543 return query_format(*((uint32_t*)data)); |
8450 | 544 case VOCTRL_DUPLICATE_FRAME: |
545 return write_last_frame(); | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
546 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
547 return VO_NOTIMPL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
548 } |