Mercurial > mplayer.hg
annotate libvo/vo_yuv4mpeg.c @ 13614:67d8b385e7e2
Sync with 1.772: XviD's bvhq option desc
+ lots of french corrections. Kudows to Gigi
author | gpoirier |
---|---|
date | Mon, 11 Oct 2004 19:30:43 +0000 |
parents | 01cc6b0a6e72 |
children | e047e70a9767 |
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" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
32 #include "video_out.h" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
33 #include "video_out_internal.h" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
34 |
13462 | 35 #include "mp_msg.h" |
36 #include "help_mp.h" | |
37 | |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
38 #include "sub.h" |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
39 |
4640
ea3bd3328fc6
removed unused includes, added fastmemcpy support, removed local copy of rgb24toyv12 (using one in postproc/rgb2rgb.c)
alex
parents:
4633
diff
changeset
|
40 #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
|
41 #include "../postproc/rgb2rgb.h" |
10802 | 42 #include "../libmpcodecs/vf_scale.h" |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
43 |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7688
diff
changeset
|
44 static vo_info_t info = |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
45 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
46 "yuv4mpeg output for mjpegtools (to \"stream.yuv\")", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
47 "yuv4mpeg", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
48 "Robert Kesterson <robertk@robertk.com>", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
49 "" |
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 |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7688
diff
changeset
|
52 LIBVO_EXTERN (yuv4mpeg) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7688
diff
changeset
|
53 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
54 static int image_width; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
55 static int image_height; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
56 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
57 static uint8_t *image = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
58 static uint8_t *image_y = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
59 static uint8_t *image_u = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
60 static uint8_t *image_v = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
61 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
62 static uint8_t *rgb_buffer = NULL; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
63 static uint8_t *rgb_line_buffer = NULL; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
64 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
65 static int using_format = 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
66 static FILE *yuv_out; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
67 static int write_bytes; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
68 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
69 #define Y4M_ILACE_NONE 'p' /* non-interlaced, progressive frame */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
70 #define Y4M_ILACE_TOP_FIRST 't' /* interlaced, top-field first */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
71 #define Y4M_ILACE_BOTTOM_FIRST 'b' /* interlaced, bottom-field first */ |
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 /* Set progressive mode as default */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
74 static int config_interlace = Y4M_ILACE_NONE; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
75 #define Y4M_IS_INTERLACED (config_interlace != Y4M_ILACE_NONE) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
76 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
77 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
|
78 uint32_t d_height, uint32_t fullscreen, char *title, |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
6659
diff
changeset
|
79 uint32_t format) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
80 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
81 image_height = height; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
82 image_width = width; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
83 using_format = format; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
84 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
85 if (Y4M_IS_INTERLACED) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
86 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
87 if (height % 4) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
88 { |
13462 | 89 mp_msg(MSGT_VO,MSGL_FATAL, |
90 MSGTR_VO_YUV4MPEG_InterlacedHeightDivisibleBy4); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
91 return -1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
92 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
93 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
94 rgb_line_buffer = malloc(image_width * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
95 if (!rgb_line_buffer) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
96 { |
13462 | 97 mp_msg(MSGT_VO,MSGL_FATAL, |
98 MSGTR_VO_YUV4MPEG_InterlacedLineBufAllocFail); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
99 return -1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
100 } |
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 (using_format == IMGFMT_YV12) |
13462 | 103 mp_msg(MSGT_VO,MSGL_WARN, |
104 MSGTR_VO_YUV4MPEG_InterlacedInputNotRGB); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
105 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
106 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
107 if (width % 2) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
108 { |
13462 | 109 mp_msg(MSGT_VO,MSGL_FATAL, |
110 MSGTR_VO_YUV4MPEG_WidthDivisibleBy2); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
111 return -1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
112 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
113 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
114 if(using_format != IMGFMT_YV12) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
115 { |
10802 | 116 sws_rgb2rgb_init(get_sws_cpuflags()); |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
117 rgb_buffer = malloc(image_width * image_height * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
118 if (!rgb_buffer) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
119 { |
13462 | 120 mp_msg(MSGT_VO,MSGL_FATAL, |
121 MSGTR_VO_YUV4MPEG_NoMemRGBFrameBuf); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
122 return -1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
123 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
124 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
125 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
126 write_bytes = image_width * image_height * 3 / 2; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
127 image = malloc(write_bytes); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
128 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
129 yuv_out = fopen("stream.yuv", "wb"); |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
130 if (!yuv_out || image == 0) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
131 { |
13462 | 132 mp_msg(MSGT_VO,MSGL_FATAL, |
133 MSGTR_VO_YUV4MPEG_OutFileOpenError); | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
134 return -1; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
135 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
136 image_y = image; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
137 image_u = image_y + image_width * image_height; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
138 image_v = image_u + image_width * image_height / 4; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
139 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
140 // This isn't right. |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
141 // 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
|
142 // or otherwise unusual (the "Ip A0:0" part). |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
143 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
144 /* At least the interlacing is ok now */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
145 fprintf(yuv_out, "YUV4MPEG2 W%d H%d F%ld:%ld I%c A0:0\n", |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
146 image_width, image_height, (long)(vo_fps * 1000000.0), |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
147 (long)1000000, config_interlace); |
4597
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 fflush(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
150 return 0; |
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 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
153 /* Only use when h divisable by 2! */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
154 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
|
155 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
156 int i; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
157 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
158 for (i=0; i<h; i +=2) |
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 memcpy(rgb_line_buffer , ptr + stride * i , stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
161 memcpy(ptr + stride * i , ptr + stride * (i+1), stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
162 memcpy(ptr + stride * (i+1), rgb_line_buffer , stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
163 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
164 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
165 |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
166 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
|
167 unsigned char *srca, int stride) { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
168 switch (using_format) |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
169 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
170 case IMGFMT_YV12: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
171 vo_draw_alpha_yv12(w, h, src, srca, stride, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
172 image + y0 * image_width + x0, image_width); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
173 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
174 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
175 case IMGFMT_BGR|24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
176 case IMGFMT_RGB|24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
177 if (config_interlace != Y4M_ILACE_BOTTOM_FIRST) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
178 vo_draw_alpha_rgb24(w, h, src, srca, stride, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
179 rgb_buffer + (y0 * image_width + x0) * 3, image_width * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
180 else |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
181 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
182 swap_fields (rgb_buffer, image_height, image_width * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
183 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
184 vo_draw_alpha_rgb24(w, h, src, srca, stride, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
185 rgb_buffer + (y0 * image_width + x0) * 3, image_width * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
186 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
187 swap_fields (rgb_buffer, image_height, image_width * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
188 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
189 break; |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
190 } |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
191 } |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
192 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
193 static void draw_osd(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
194 { |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
195 vo_draw_text(image_width, image_height, draw_alpha); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
196 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
197 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
198 static void deinterleave_fields(uint8_t *ptr, const int stride, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
199 const int img_height) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
200 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
201 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
|
202 unsigned char *line_state = malloc(modv); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
203 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
204 for (i=0; i<modv; i++) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
205 line_state[i] = 0; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
206 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
207 line_state[0] = 1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
208 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
209 while(k_start < modv) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
210 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
211 i = j = k_start; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
212 memcpy(rgb_line_buffer, ptr + stride * i, stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
213 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
214 while (!line_state[j]) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
215 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
216 line_state[j] = 1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
217 i = j; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
218 j = j * 2 % modv; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
219 memcpy(ptr + stride * i, ptr + stride * j, stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
220 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
221 memcpy(ptr + stride * i, rgb_line_buffer, stride); |
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 while(k_start < modv && line_state[k_start]) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
224 k_start++; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
225 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
226 free(line_state); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
227 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
228 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
229 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
|
230 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
231 if (fwrite(ptr, 1, num_bytes, yuv_out) != num_bytes) |
13462 | 232 mp_msg(MSGT_VO,MSGL_ERR, |
233 MSGTR_VO_YUV4MPEG_OutFileWriteError); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
234 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
235 |
8450 | 236 static int write_last_frame(void) |
237 { | |
238 | |
239 uint8_t *upper_y, *upper_u, *upper_v, *rgb_buffer_lower; | |
240 int rgb_stride, uv_stride, field_height; | |
241 unsigned int i, low_ofs; | |
242 | |
243 fprintf(yuv_out, "FRAME\n"); | |
244 | |
245 if (using_format != IMGFMT_YV12) | |
246 { | |
247 rgb_stride = image_width * 3; | |
248 uv_stride = image_width / 2; | |
249 | |
250 if (Y4M_IS_INTERLACED) | |
251 { | |
252 field_height = image_height / 2; | |
253 | |
254 upper_y = image; | |
255 upper_u = upper_y + image_width * field_height; | |
256 upper_v = upper_u + image_width * field_height / 4; | |
257 low_ofs = image_width * field_height * 3 / 2; | |
258 rgb_buffer_lower = rgb_buffer + rgb_stride * field_height; | |
259 | |
260 /* Write Y plane */ | |
261 for(i = 0; i < field_height; i++) | |
262 { | |
263 vo_y4m_write(upper_y + image_width * i, image_width); | |
264 vo_y4m_write(upper_y + image_width * i + low_ofs, image_width); | |
265 } | |
266 | |
267 /* Write U and V plane */ | |
268 for(i = 0; i < field_height / 2; i++) | |
269 { | |
270 vo_y4m_write(upper_u + uv_stride * i, uv_stride); | |
271 vo_y4m_write(upper_u + uv_stride * i + low_ofs, uv_stride); | |
272 } | |
273 for(i = 0; i < field_height / 2; i++) | |
274 { | |
275 vo_y4m_write(upper_v + uv_stride * i, uv_stride); | |
276 vo_y4m_write(upper_v + uv_stride * i + low_ofs, uv_stride); | |
277 } | |
278 return VO_TRUE; /* Image written; We have to stop here */ | |
279 } | |
280 } | |
281 /* Write progressive frame */ | |
282 vo_y4m_write(image, write_bytes); | |
283 return VO_TRUE; | |
284 } | |
285 | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
286 static void flip_page (void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
287 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
288 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
|
289 int rgb_stride, uv_stride, field_height; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
290 unsigned int i, low_ofs; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
291 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
292 fprintf(yuv_out, "FRAME\n"); |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
293 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
294 if (using_format != IMGFMT_YV12) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
295 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
296 rgb_stride = image_width * 3; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
297 uv_stride = image_width / 2; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
298 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
299 if (Y4M_IS_INTERLACED) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
300 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
301 field_height = image_height / 2; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
302 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
303 upper_y = image; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
304 upper_u = upper_y + image_width * field_height; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
305 upper_v = upper_u + image_width * field_height / 4; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
306 low_ofs = image_width * field_height * 3 / 2; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
307 rgb_buffer_lower = rgb_buffer + rgb_stride * field_height; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
308 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
309 deinterleave_fields(rgb_buffer, rgb_stride, image_height); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
310 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
311 rgb24toyv12(rgb_buffer, upper_y, upper_u, upper_v, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
312 image_width, field_height, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
313 image_width, uv_stride, rgb_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
314 rgb24toyv12(rgb_buffer_lower, upper_y + low_ofs, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
315 upper_u + low_ofs, upper_v + low_ofs, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
316 image_width, field_height, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
317 image_width, uv_stride, rgb_stride); |
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 /* Write Y plane */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
320 for(i = 0; i < field_height; i++) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
321 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
322 vo_y4m_write(upper_y + image_width * i, image_width); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
323 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
|
324 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
325 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
326 /* Write U and V plane */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
327 for(i = 0; i < field_height / 2; i++) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
328 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
329 vo_y4m_write(upper_u + uv_stride * i, uv_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
330 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
|
331 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
332 for(i = 0; i < field_height / 2; i++) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
333 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
334 vo_y4m_write(upper_v + uv_stride * i, uv_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
335 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
|
336 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
337 return; /* Image written; We have to stop here */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
338 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
339 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
340 rgb24toyv12(rgb_buffer, image_y, image_u, image_v, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
341 image_width, image_height, |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
342 image_width, uv_stride, rgb_stride); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
343 } |
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 /* Write progressive frame */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
346 vo_y4m_write(image, write_bytes); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
347 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
348 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
349 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
|
350 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
351 int i; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
352 uint8_t *dst, *src = srcimg[0]; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
353 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
354 switch (using_format) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
355 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
356 case IMGFMT_YV12: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
357 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
358 // copy Y: |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
359 dst = image_y + image_width * y + x; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
360 for (i = 0; i < h; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
361 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
362 memcpy(dst, src, w); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
363 src += stride[0]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
364 dst += image_width; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
365 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
366 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
367 // copy U + V: |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
368 int imgstride = image_width >> 1; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
369 uint8_t *src1 = srcimg[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
370 uint8_t *src2 = srcimg[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
371 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
|
372 uint8_t *dstv = image_v + imgstride * (y >> 1) + (x >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
373 for (i = 0; i < h / 2; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
374 { |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
375 memcpy(dstu, src1 , w >> 1); |
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
376 memcpy(dstv, src2, w >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
377 src1 += stride[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
378 src2 += stride[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
379 dstu += imgstride; |
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
380 dstv += imgstride; |
4597
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 } |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
383 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
384 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
385 case IMGFMT_BGR24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
386 case IMGFMT_RGB24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
387 dst = rgb_buffer + (image_width * y + x) * 3; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
388 for (i = 0; i < h; i++) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
389 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
390 memcpy(dst, src, w * 3); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
391 src += stride[0]; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
392 dst += image_width * 3; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
393 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
394 break; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
395 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
396 return 0; |
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 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
399 static uint32_t draw_frame(uint8_t * src[]) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
400 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
401 switch(using_format) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
402 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
403 case IMGFMT_YV12: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
404 // gets done in draw_slice |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
405 break; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
406 |
7688
41d242c5bee1
since draw_slice() can handle packed RGB too, set the VFCAP_ACCEPT_STRIDE flag
arpi
parents:
7124
diff
changeset
|
407 case IMGFMT_BGR24: |
41d242c5bee1
since draw_slice() can handle packed RGB too, set the VFCAP_ACCEPT_STRIDE flag
arpi
parents:
7124
diff
changeset
|
408 case IMGFMT_RGB24: |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
409 memcpy(rgb_buffer, src[0], image_width * image_height * 3); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
410 break; |
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 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
415 static uint32_t query_format(uint32_t format) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
416 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
417 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
418 if (Y4M_IS_INTERLACED) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
419 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
420 /* 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
|
421 * 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
|
422 * information sampled correct. */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
423 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
424 switch(format) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
425 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
426 case IMGFMT_YV12: |
7688
41d242c5bee1
since draw_slice() can handle packed RGB too, set the VFCAP_ACCEPT_STRIDE flag
arpi
parents:
7124
diff
changeset
|
427 return VFCAP_CSP_SUPPORTED|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
428 case IMGFMT_BGR|24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
429 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
|
430 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
|
431 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
432 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
433 else |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
434 { |
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 switch(format) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
437 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
438 case IMGFMT_YV12: |
7688
41d242c5bee1
since draw_slice() can handle packed RGB too, set the VFCAP_ACCEPT_STRIDE flag
arpi
parents:
7124
diff
changeset
|
439 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
|
440 case IMGFMT_BGR|24: |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
441 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
|
442 return VFCAP_CSP_SUPPORTED|VFCAP_OSD|VFCAP_ACCEPT_STRIDE; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
443 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
444 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
445 return 0; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
446 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
447 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
448 static void uninit(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
449 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
450 if(image) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
451 free(image); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
452 image = NULL; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
453 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
454 if(yuv_out) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
455 fclose(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
456 yuv_out = NULL; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
457 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
458 if(rgb_buffer) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
459 free(rgb_buffer); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
460 rgb_buffer = NULL; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
461 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
462 if(rgb_line_buffer) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
463 free(rgb_line_buffer); |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
464 rgb_line_buffer = NULL; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
465 } |
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 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
468 static void check_events(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
469 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
470 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
471 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
472 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
473 static uint32_t preinit(const char *arg) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
474 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
475 int arg_unrecognized = 0; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
476 |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4706
diff
changeset
|
477 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
|
478 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
479 /* configure output mode */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
480 if (strcmp(arg, "interlaced")) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
481 arg_unrecognized++; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
482 else |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
483 config_interlace = Y4M_ILACE_TOP_FIRST; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
484 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
485 if (strcmp(arg, "interlaced_bf")) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
486 arg_unrecognized++; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
487 else |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
488 config_interlace = Y4M_ILACE_BOTTOM_FIRST; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
489 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
490 /* If both tests failed the argument is invalid */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
491 if (arg_unrecognized == 2) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
492 { |
13462 | 493 mp_msg(MSGT_VO,MSGL_FATAL, |
494 MSGTR_VO_YUV4MPEG_UnknownSubDev,arg); | |
495 return -ENOSYS; | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
496 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
497 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
498 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
499 /* Inform user which output mode is used */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
500 switch (config_interlace) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
501 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
502 case Y4M_ILACE_TOP_FIRST: |
13462 | 503 mp_msg(MSGT_VO,MSGL_STATUS, |
504 MSGTR_VO_YUV4MPEG_InterlacedTFFMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
505 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
506 case Y4M_ILACE_BOTTOM_FIRST: |
13462 | 507 mp_msg(MSGT_VO,MSGL_STATUS, |
508 MSGTR_VO_YUV4MPEG_InterlacedBFFMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
509 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
510 default: |
13462 | 511 mp_msg(MSGT_VO,MSGL_STATUS, |
512 MSGTR_VO_YUV4MPEG_ProgressiveMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
513 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
|
514 } |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4706
diff
changeset
|
515 return 0; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
516 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
517 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
518 static uint32_t control(uint32_t request, void *data, ...) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
519 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
520 switch (request) { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
521 case VOCTRL_QUERY_FORMAT: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
522 return query_format(*((uint32_t*)data)); |
8450 | 523 case VOCTRL_DUPLICATE_FRAME: |
524 return write_last_frame(); | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
525 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
526 return VO_NOTIMPL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
527 } |