Mercurial > mplayer.hg
annotate libvo/vo_yuv4mpeg.c @ 35447:825d6e1cad3e
demux_lavf: support subtitle-only formats.
author | reimar |
---|---|
date | Fri, 30 Nov 2012 21:31:14 +0000 |
parents | 9c1083333ad1 |
children | 5d3f93051de9 |
rev | line source |
---|---|
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
1 /* |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
2 * yuv4mpeg (mjpegtools) interface |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
3 * |
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
4 * Thrown together by Robert Kesterson <robertk@robertk.com> |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
5 * Based on the pgm output plugin, the rgb2rgb postproc filter, divxdec, |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
6 * and probably others. |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
7 * |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
8 * This is undoubtedly incomplete, inaccurate, or just plain wrong. :-) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
9 * |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
10 * 2002/06/19 Klaus Stengel <Klaus.Stengel@asamnet.de> |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
11 * - added support for interlaced output |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
12 * Activate by using '-vo yuv4mpeg:interlaced' |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
13 * or '-vo yuv4mpeg:interlaced_bf' if your source has |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
14 * bottom fields first |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
15 * - 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
|
16 * |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
17 * 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
|
18 * - added support for output of subtitles |
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
19 * best, if you give option '-osdlevel 0' to mplayer for |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
20 * no watching the seek+timer |
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
21 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
22 * This file is part of MPlayer. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
23 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
24 * MPlayer is free software; you can redistribute it and/or modify |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
25 * it under the terms of the GNU General Public License as published by |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
26 * the Free Software Foundation; either version 2 of the License, or |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
27 * (at your option) any later version. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
28 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
29 * MPlayer is distributed in the hope that it will be useful, |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
32 * GNU General Public License for more details. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
33 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
34 * You should have received a copy of the GNU General Public License along |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
35 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
25220
diff
changeset
|
36 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
37 */ |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
38 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
39 #include <stdio.h> |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
40 #include <stdlib.h> |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
41 #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
|
42 #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
|
43 #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
|
44 #include <fcntl.h> |
21805
924da043b8ce
Use av_d2q to produce the fps fraction, this usually produces more sane fractions
reimar
parents:
21804
diff
changeset
|
45 #include <limits.h> |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
46 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
47 #include "config.h" |
14284 | 48 #include "subopt-helper.h" |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
49 #include "video_out.h" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
50 #include "video_out_internal.h" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
51 |
13462 | 52 #include "mp_msg.h" |
53 #include "help_mp.h" | |
54 | |
32467 | 55 #include "sub/sub.h" |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
56 |
4640
ea3bd3328fc6
removed unused includes, added fastmemcpy support, removed local copy of rgb24toyv12 (using one in postproc/rgb2rgb.c)
alex
parents:
4633
diff
changeset
|
57 #include "fastmemcpy.h" |
20398 | 58 #include "libavutil/rational.h" |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
59 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
60 static const vo_info_t info = |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
61 { |
14095 | 62 "yuv4mpeg output for mjpegtools", |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
63 "yuv4mpeg", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
64 "Robert Kesterson <robertk@robertk.com>", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
65 "" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
66 }; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
67 |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
68 const LIBVO_EXTERN (yuv4mpeg) |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7688
diff
changeset
|
69 |
14145 | 70 static int image_width = 0; |
71 static int image_height = 0; | |
72 static float image_fps = 0; | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
73 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
74 static uint8_t *image = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
75 static uint8_t *image_y = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
76 static uint8_t *image_u = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
77 static uint8_t *image_v = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
78 |
14095 | 79 static char *yuv_filename = NULL; |
80 | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
81 static int using_format = 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
82 static FILE *yuv_out; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
83 static int write_bytes; |
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 #define Y4M_ILACE_NONE 'p' /* non-interlaced, progressive frame */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
86 #define Y4M_ILACE_TOP_FIRST 't' /* interlaced, top-field first */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
87 #define Y4M_ILACE_BOTTOM_FIRST 'b' /* interlaced, bottom-field first */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
88 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
89 /* Set progressive mode as default */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
90 static int config_interlace = Y4M_ILACE_NONE; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
91 #define Y4M_IS_INTERLACED (config_interlace != Y4M_ILACE_NONE) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
92 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
93 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
94 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
|
95 uint32_t format) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
96 { |
20398 | 97 AVRational pixelaspect = av_div_q((AVRational){d_width, d_height}, |
98 (AVRational){width, height}); | |
28615
15e7abed4291
Use the same code to convert fps in float to fraction as used in mencoder,
reimar
parents:
28446
diff
changeset
|
99 AVRational fps_frac = av_d2q(vo_fps, vo_fps * 1001 + 2); |
14145 | 100 if (image_width == width && image_height == height && |
101 image_fps == vo_fps && vo_config_count) | |
102 return 0; | |
103 if (vo_config_count) { | |
104 mp_msg(MSGT_VO, MSGL_WARN, | |
105 "Video formats differ (w:%i=>%i, h:%i=>%i, fps:%f=>%f), " | |
106 "restarting output.\n", | |
107 image_width, width, image_height, height, image_fps, vo_fps); | |
108 } | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
109 image_height = height; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
110 image_width = width; |
14145 | 111 image_fps = vo_fps; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
112 using_format = format; |
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 (Y4M_IS_INTERLACED) |
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 if (height % 4) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
117 { |
13462 | 118 mp_msg(MSGT_VO,MSGL_FATAL, |
119 MSGTR_VO_YUV4MPEG_InterlacedHeightDivisibleBy4); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
120 return -1; |
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 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
123 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
124 if (width % 2) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
125 { |
13462 | 126 mp_msg(MSGT_VO,MSGL_FATAL, |
127 MSGTR_VO_YUV4MPEG_WidthDivisibleBy2); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
128 return -1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
129 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
130 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
131 write_bytes = image_width * image_height * 3 / 2; |
34774
2402be2e296f
Allow using -vo yuv4mpeg for files with resolution changes.
reimar
parents:
34773
diff
changeset
|
132 free(image); |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
133 image = malloc(write_bytes); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
134 |
34774
2402be2e296f
Allow using -vo yuv4mpeg for files with resolution changes.
reimar
parents:
34773
diff
changeset
|
135 if (!yuv_out) |
2402be2e296f
Allow using -vo yuv4mpeg for files with resolution changes.
reimar
parents:
34773
diff
changeset
|
136 yuv_out = strcmp(yuv_filename, "-") ? fopen(yuv_filename, "wb") : stdout; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
137 if (!yuv_out || image == 0) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
138 { |
13462 | 139 mp_msg(MSGT_VO,MSGL_FATAL, |
14095 | 140 MSGTR_VO_YUV4MPEG_OutFileOpenError, |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
141 yuv_filename); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
142 return -1; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
143 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
144 image_y = image; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
145 image_u = image_y + image_width * image_height; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
146 image_v = image_u + image_width * image_height / 4; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
147 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
148 fprintf(yuv_out, "YUV4MPEG2 W%d H%d F%d:%d I%c A%d:%d\n", |
21805
924da043b8ce
Use av_d2q to produce the fps fraction, this usually produces more sane fractions
reimar
parents:
21804
diff
changeset
|
149 image_width, image_height, fps_frac.num, fps_frac.den, |
924da043b8ce
Use av_d2q to produce the fps fraction, this usually produces more sane fractions
reimar
parents:
21804
diff
changeset
|
150 config_interlace, |
20398 | 151 pixelaspect.num, pixelaspect.den); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
152 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
153 fflush(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
154 return 0; |
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 |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
157 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
|
158 unsigned char *srca, int stride) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
159 vo_draw_alpha_yv12(w, h, src, srca, stride, |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
160 image + y0 * image_width + x0, image_width); |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
161 } |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
162 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
163 static void draw_osd(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
164 { |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
165 vo_draw_text(image_width, image_height, draw_alpha); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
166 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
167 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
168 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
|
169 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
170 if (fwrite(ptr, 1, num_bytes, yuv_out) != num_bytes) |
13462 | 171 mp_msg(MSGT_VO,MSGL_ERR, |
172 MSGTR_VO_YUV4MPEG_OutFileWriteError); | |
34791
9c1083333ad1
vo_yuv4mpeg: flush userspace FILE buffers after each frame.
reimar
parents:
34774
diff
changeset
|
173 fflush(yuv_out); |
6659
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 |
8450 | 176 static int write_last_frame(void) |
177 { | |
178 fprintf(yuv_out, "FRAME\n"); | |
179 | |
180 vo_y4m_write(image, write_bytes); | |
181 return VO_TRUE; | |
182 } | |
183 | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
184 static void flip_page (void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
185 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
186 fprintf(yuv_out, "FRAME\n"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
187 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
188 vo_y4m_write(image, write_bytes); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
189 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
190 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
191 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
|
192 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
193 int i; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
194 uint8_t *dst, *src = srcimg[0]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
195 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
196 // copy Y: |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
197 dst = image_y + image_width * y + x; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
198 for (i = 0; i < h; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
199 { |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
21805
diff
changeset
|
200 fast_memcpy(dst, src, w); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
201 src += stride[0]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
202 dst += image_width; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
203 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
204 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
205 // copy U + V: |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
206 int imgstride = image_width >> 1; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
207 uint8_t *src1 = srcimg[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
208 uint8_t *src2 = srcimg[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
209 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
|
210 uint8_t *dstv = image_v + imgstride * (y >> 1) + (x >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
211 for (i = 0; i < h / 2; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
212 { |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
21805
diff
changeset
|
213 fast_memcpy(dstu, src1 , w >> 1); |
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
21805
diff
changeset
|
214 fast_memcpy(dstv, src2, w >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
215 src1 += stride[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
216 src2 += stride[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
217 dstu += imgstride; |
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
218 dstv += imgstride; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
219 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
220 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
221 return 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
222 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
223 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
224 static int draw_frame(uint8_t * src[]) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
225 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
226 // gets done in draw_slice |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
227 return 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
228 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
229 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
230 static int query_format(uint32_t format) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
231 { |
31254
e888e262e3f0
Remove colorspace conversion code from -vo yuv4mpeg, -vf scale should
reimar
parents:
31248
diff
changeset
|
232 if (format == IMGFMT_YV12) |
e888e262e3f0
Remove colorspace conversion code from -vo yuv4mpeg, -vf scale should
reimar
parents:
31248
diff
changeset
|
233 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
|
234 return 0; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
235 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
236 |
14145 | 237 // WARNING: config(...) also uses this |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
238 static void uninit(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
239 { |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
240 free(image); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
241 image = NULL; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
242 |
34773
37af463fd7fc
yuv4mpeg: support writing to stdout instead of file.
reimar
parents:
33305
diff
changeset
|
243 if(yuv_out && yuv_out != stdout) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
244 fclose(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
245 yuv_out = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
246 |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
247 free(yuv_filename); |
14095 | 248 yuv_filename = NULL; |
14145 | 249 image_width = 0; |
250 image_height = 0; | |
251 image_fps = 0; | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
252 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
253 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
254 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
255 static void check_events(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
256 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
257 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
258 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
259 static int preinit(const char *arg) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
260 { |
14284 | 261 int il, il_bf; |
28828
56eee6ffba9b
Make data related to suboption parsing const in libvo
reimar
parents:
28615
diff
changeset
|
262 const opt_t subopts[] = { |
14284 | 263 {"interlaced", OPT_ARG_BOOL, &il, NULL}, |
264 {"interlaced_bf", OPT_ARG_BOOL, &il_bf, NULL}, | |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
265 {"file", OPT_ARG_MSTRZ, &yuv_filename, NULL}, |
14284 | 266 {NULL} |
267 }; | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
268 |
14284 | 269 il = 0; |
270 il_bf = 0; | |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
271 yuv_filename = strdup("stream.yuv"); |
14284 | 272 if (subopt_parse(arg, subopts) != 0) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
273 mp_msg(MSGT_VO, MSGL_FATAL, MSGTR_VO_YUV4MPEG_UnknownSubDev, arg); |
14284 | 274 return -1; |
275 } | |
276 | |
277 config_interlace = Y4M_ILACE_NONE; | |
278 if (il) | |
279 config_interlace = Y4M_ILACE_TOP_FIRST; | |
280 if (il_bf) | |
281 config_interlace = Y4M_ILACE_BOTTOM_FIRST; | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
282 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
283 /* Inform user which output mode is used */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
284 switch (config_interlace) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
285 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
286 case Y4M_ILACE_TOP_FIRST: |
13462 | 287 mp_msg(MSGT_VO,MSGL_STATUS, |
288 MSGTR_VO_YUV4MPEG_InterlacedTFFMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
289 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
290 case Y4M_ILACE_BOTTOM_FIRST: |
13462 | 291 mp_msg(MSGT_VO,MSGL_STATUS, |
292 MSGTR_VO_YUV4MPEG_InterlacedBFFMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
293 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
294 default: |
13462 | 295 mp_msg(MSGT_VO,MSGL_STATUS, |
296 MSGTR_VO_YUV4MPEG_ProgressiveMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
297 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
|
298 } |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4706
diff
changeset
|
299 return 0; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
300 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
301 |
33305
ddb45e9443ec
Remove the variable arguments from the libvo control() functions.
iive
parents:
32537
diff
changeset
|
302 static int control(uint32_t request, void *data) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
303 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
304 switch (request) { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
305 case VOCTRL_QUERY_FORMAT: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
306 return query_format(*((uint32_t*)data)); |
8450 | 307 case VOCTRL_DUPLICATE_FRAME: |
308 return write_last_frame(); | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
309 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
310 return VO_NOTIMPL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
311 } |