Mercurial > mplayer.hg
annotate libvo/vo_yuv4mpeg.c @ 32181:1d9847c0e86d
swscale-test: cosmetic alignment
author | ramiro |
---|---|
date | Thu, 16 Sep 2010 13:30:02 +0000 |
parents | e888e262e3f0 |
children | fbe5c829c69b |
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 | |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
55 #include "sub.h" |
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 uninit(); | |
109 } | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
110 image_height = height; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
111 image_width = width; |
14145 | 112 image_fps = vo_fps; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
113 using_format = format; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
114 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
115 if (Y4M_IS_INTERLACED) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
116 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
117 if (height % 4) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
118 { |
13462 | 119 mp_msg(MSGT_VO,MSGL_FATAL, |
120 MSGTR_VO_YUV4MPEG_InterlacedHeightDivisibleBy4); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
121 return -1; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
122 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
123 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
124 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
125 if (width % 2) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
126 { |
13462 | 127 mp_msg(MSGT_VO,MSGL_FATAL, |
128 MSGTR_VO_YUV4MPEG_WidthDivisibleBy2); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
129 return -1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
130 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
131 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
132 write_bytes = image_width * image_height * 3 / 2; |
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 |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
135 yuv_out = fopen(yuv_filename, "wb"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
136 if (!yuv_out || image == 0) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
137 { |
13462 | 138 mp_msg(MSGT_VO,MSGL_FATAL, |
14095 | 139 MSGTR_VO_YUV4MPEG_OutFileOpenError, |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
140 yuv_filename); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
141 return -1; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
142 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
143 image_y = image; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
144 image_u = image_y + image_width * image_height; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
145 image_v = image_u + image_width * image_height / 4; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
146 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
147 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
|
148 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
|
149 config_interlace, |
20398 | 150 pixelaspect.num, pixelaspect.den); |
4597
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 fflush(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
153 return 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
154 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
155 |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
156 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
|
157 unsigned char *srca, int stride) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
158 vo_draw_alpha_yv12(w, h, src, srca, stride, |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
159 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
|
160 } |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
161 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
162 static void draw_osd(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
163 { |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
164 vo_draw_text(image_width, image_height, draw_alpha); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
165 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
166 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
167 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
|
168 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
169 if (fwrite(ptr, 1, num_bytes, yuv_out) != num_bytes) |
13462 | 170 mp_msg(MSGT_VO,MSGL_ERR, |
171 MSGTR_VO_YUV4MPEG_OutFileWriteError); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
172 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
173 |
8450 | 174 static int write_last_frame(void) |
175 { | |
176 fprintf(yuv_out, "FRAME\n"); | |
177 | |
178 vo_y4m_write(image, write_bytes); | |
179 return VO_TRUE; | |
180 } | |
181 | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
182 static void flip_page (void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
183 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
184 fprintf(yuv_out, "FRAME\n"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
185 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
186 vo_y4m_write(image, write_bytes); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
187 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
188 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
189 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
|
190 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
191 int i; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
192 uint8_t *dst, *src = srcimg[0]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
193 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
194 // copy Y: |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
195 dst = image_y + image_width * y + x; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
196 for (i = 0; i < h; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
197 { |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
21805
diff
changeset
|
198 fast_memcpy(dst, src, w); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
199 src += stride[0]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
200 dst += image_width; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
201 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
202 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
203 // copy U + V: |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
204 int imgstride = image_width >> 1; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
205 uint8_t *src1 = srcimg[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
206 uint8_t *src2 = srcimg[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
207 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
|
208 uint8_t *dstv = image_v + imgstride * (y >> 1) + (x >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
209 for (i = 0; i < h / 2; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
210 { |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
21805
diff
changeset
|
211 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
|
212 fast_memcpy(dstv, src2, w >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
213 src1 += stride[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
214 src2 += stride[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
215 dstu += imgstride; |
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
216 dstv += imgstride; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
217 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
218 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
219 return 0; |
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 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
222 static int draw_frame(uint8_t * src[]) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
223 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
224 // gets done in draw_slice |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
225 return 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
226 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
227 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
228 static int query_format(uint32_t format) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
229 { |
31254
e888e262e3f0
Remove colorspace conversion code from -vo yuv4mpeg, -vf scale should
reimar
parents:
31248
diff
changeset
|
230 if (format == IMGFMT_YV12) |
e888e262e3f0
Remove colorspace conversion code from -vo yuv4mpeg, -vf scale should
reimar
parents:
31248
diff
changeset
|
231 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
|
232 return 0; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
233 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
234 |
14145 | 235 // WARNING: config(...) also uses this |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
236 static void uninit(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
237 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
238 if(image) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
239 free(image); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
240 image = NULL; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
241 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
242 if(yuv_out) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
243 fclose(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
244 yuv_out = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
245 |
14095 | 246 if (yuv_filename) |
247 free(yuv_filename); | |
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 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
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 } |