Mercurial > mplayer.hg
annotate libvo/vo_yuv4mpeg.c @ 36647:e5b30a00c9db
Cosmetic: Adjust spacings.
author | ib |
---|---|
date | Sun, 26 Jan 2014 16:11:56 +0000 |
parents | 5d3f93051de9 |
children |
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" |
36517 | 50 #define NO_DRAW_FRAME |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
51 #include "video_out_internal.h" |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
52 |
13462 | 53 #include "mp_msg.h" |
54 #include "help_mp.h" | |
55 | |
32467 | 56 #include "sub/sub.h" |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
57 |
4640
ea3bd3328fc6
removed unused includes, added fastmemcpy support, removed local copy of rgb24toyv12 (using one in postproc/rgb2rgb.c)
alex
parents:
4633
diff
changeset
|
58 #include "fastmemcpy.h" |
20398 | 59 #include "libavutil/rational.h" |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
60 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
61 static const vo_info_t info = |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
62 { |
14095 | 63 "yuv4mpeg output for mjpegtools", |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
64 "yuv4mpeg", |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
65 "Robert Kesterson <robertk@robertk.com>", |
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 }; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
68 |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
69 const LIBVO_EXTERN (yuv4mpeg) |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7688
diff
changeset
|
70 |
14145 | 71 static int image_width = 0; |
72 static int image_height = 0; | |
73 static float image_fps = 0; | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
74 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
75 static uint8_t *image = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
76 static uint8_t *image_y = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
77 static uint8_t *image_u = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
78 static uint8_t *image_v = NULL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
79 |
14095 | 80 static char *yuv_filename = NULL; |
81 | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
82 static int using_format = 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
83 static FILE *yuv_out; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
84 static int write_bytes; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
85 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
86 #define Y4M_ILACE_NONE 'p' /* non-interlaced, progressive frame */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
87 #define Y4M_ILACE_TOP_FIRST 't' /* interlaced, top-field first */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
88 #define Y4M_ILACE_BOTTOM_FIRST 'b' /* interlaced, bottom-field first */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
89 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
90 /* Set progressive mode as default */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
91 static int config_interlace = Y4M_ILACE_NONE; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
92 #define Y4M_IS_INTERLACED (config_interlace != Y4M_ILACE_NONE) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
93 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
94 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
|
95 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
|
96 uint32_t format) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
97 { |
20398 | 98 AVRational pixelaspect = av_div_q((AVRational){d_width, d_height}, |
99 (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
|
100 AVRational fps_frac = av_d2q(vo_fps, vo_fps * 1001 + 2); |
14145 | 101 if (image_width == width && image_height == height && |
102 image_fps == vo_fps && vo_config_count) | |
103 return 0; | |
104 if (vo_config_count) { | |
105 mp_msg(MSGT_VO, MSGL_WARN, | |
106 "Video formats differ (w:%i=>%i, h:%i=>%i, fps:%f=>%f), " | |
107 "restarting output.\n", | |
108 image_width, width, image_height, height, image_fps, vo_fps); | |
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; |
34774
2402be2e296f
Allow using -vo yuv4mpeg for files with resolution changes.
reimar
parents:
34773
diff
changeset
|
133 free(image); |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
134 image = malloc(write_bytes); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
135 |
34774
2402be2e296f
Allow using -vo yuv4mpeg for files with resolution changes.
reimar
parents:
34773
diff
changeset
|
136 if (!yuv_out) |
2402be2e296f
Allow using -vo yuv4mpeg for files with resolution changes.
reimar
parents:
34773
diff
changeset
|
137 yuv_out = strcmp(yuv_filename, "-") ? fopen(yuv_filename, "wb") : stdout; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
138 if (!yuv_out || image == 0) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
139 { |
13462 | 140 mp_msg(MSGT_VO,MSGL_FATAL, |
14095 | 141 MSGTR_VO_YUV4MPEG_OutFileOpenError, |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
142 yuv_filename); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
143 return -1; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
144 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
145 image_y = image; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
146 image_u = image_y + image_width * image_height; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
147 image_v = image_u + image_width * image_height / 4; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
148 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
149 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
|
150 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
|
151 config_interlace, |
20398 | 152 pixelaspect.num, pixelaspect.den); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
153 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
154 fflush(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
155 return 0; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
156 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
157 |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
158 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
|
159 unsigned char *srca, int stride) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
160 vo_draw_alpha_yv12(w, h, src, srca, stride, |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
161 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
|
162 } |
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
163 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
164 static void draw_osd(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
165 { |
5832
041bd56e41dc
added support for output of subtitles - Juergen Hammelmann <juergen.hammelmann@gmx.de>
arpi
parents:
4737
diff
changeset
|
166 vo_draw_text(image_width, image_height, draw_alpha); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
167 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
168 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
169 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
|
170 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
171 if (fwrite(ptr, 1, num_bytes, yuv_out) != num_bytes) |
13462 | 172 mp_msg(MSGT_VO,MSGL_ERR, |
173 MSGTR_VO_YUV4MPEG_OutFileWriteError); | |
34791
9c1083333ad1
vo_yuv4mpeg: flush userspace FILE buffers after each frame.
reimar
parents:
34774
diff
changeset
|
174 fflush(yuv_out); |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
175 } |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
176 |
8450 | 177 static int write_last_frame(void) |
178 { | |
179 fprintf(yuv_out, "FRAME\n"); | |
180 | |
181 vo_y4m_write(image, write_bytes); | |
182 return VO_TRUE; | |
183 } | |
184 | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
185 static void flip_page (void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
186 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
187 fprintf(yuv_out, "FRAME\n"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
188 |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
189 vo_y4m_write(image, write_bytes); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
190 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
191 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
192 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
|
193 { |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
194 int i; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
195 uint8_t *dst, *src = srcimg[0]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
196 |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
197 // copy Y: |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
198 dst = image_y + image_width * y + x; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
199 for (i = 0; i < h; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
200 { |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
21805
diff
changeset
|
201 fast_memcpy(dst, src, w); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
202 src += stride[0]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
203 dst += image_width; |
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 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
206 // copy U + V: |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
207 int imgstride = image_width >> 1; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
208 uint8_t *src1 = srcimg[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
209 uint8_t *src2 = srcimg[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
210 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
|
211 uint8_t *dstv = image_v + imgstride * (y >> 1) + (x >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
212 for (i = 0; i < h / 2; i++) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
213 { |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
21805
diff
changeset
|
214 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
|
215 fast_memcpy(dstv, src2, w >> 1); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
216 src1 += stride[1]; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
217 src2 += stride[2]; |
4706
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
218 dstu += imgstride; |
a4400910be9f
yv12 slices fix by Robert Kesterson <robertk@robertk.com>
arpi
parents:
4640
diff
changeset
|
219 dstv += imgstride; |
4597
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 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
222 return 0; |
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 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
225 static int query_format(uint32_t format) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
226 { |
31254
e888e262e3f0
Remove colorspace conversion code from -vo yuv4mpeg, -vf scale should
reimar
parents:
31248
diff
changeset
|
227 if (format == IMGFMT_YV12) |
e888e262e3f0
Remove colorspace conversion code from -vo yuv4mpeg, -vf scale should
reimar
parents:
31248
diff
changeset
|
228 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
|
229 return 0; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
230 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
231 |
14145 | 232 // WARNING: config(...) also uses this |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
233 static void uninit(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
234 { |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
235 free(image); |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
236 image = NULL; |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
237 |
34773
37af463fd7fc
yuv4mpeg: support writing to stdout instead of file.
reimar
parents:
33305
diff
changeset
|
238 if(yuv_out && yuv_out != stdout) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
239 fclose(yuv_out); |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
240 yuv_out = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
241 |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
242 free(yuv_filename); |
14095 | 243 yuv_filename = NULL; |
14145 | 244 image_width = 0; |
245 image_height = 0; | |
246 image_fps = 0; | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
247 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
248 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
249 |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
250 static void check_events(void) |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
251 { |
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 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
254 static int preinit(const char *arg) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
255 { |
14284 | 256 int il, il_bf; |
28828
56eee6ffba9b
Make data related to suboption parsing const in libvo
reimar
parents:
28615
diff
changeset
|
257 const opt_t subopts[] = { |
14284 | 258 {"interlaced", OPT_ARG_BOOL, &il, NULL}, |
259 {"interlaced_bf", OPT_ARG_BOOL, &il_bf, NULL}, | |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
260 {"file", OPT_ARG_MSTRZ, &yuv_filename, NULL}, |
14284 | 261 {NULL} |
262 }; | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
263 |
14284 | 264 il = 0; |
265 il_bf = 0; | |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14284
diff
changeset
|
266 yuv_filename = strdup("stream.yuv"); |
14284 | 267 if (subopt_parse(arg, subopts) != 0) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28828
diff
changeset
|
268 mp_msg(MSGT_VO, MSGL_FATAL, MSGTR_VO_YUV4MPEG_UnknownSubDev, arg); |
14284 | 269 return -1; |
270 } | |
271 | |
272 config_interlace = Y4M_ILACE_NONE; | |
273 if (il) | |
274 config_interlace = Y4M_ILACE_TOP_FIRST; | |
275 if (il_bf) | |
276 config_interlace = Y4M_ILACE_BOTTOM_FIRST; | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
277 |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
278 /* Inform user which output mode is used */ |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
279 switch (config_interlace) |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
280 { |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
281 case Y4M_ILACE_TOP_FIRST: |
13462 | 282 mp_msg(MSGT_VO,MSGL_STATUS, |
283 MSGTR_VO_YUV4MPEG_InterlacedTFFMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
284 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
285 case Y4M_ILACE_BOTTOM_FIRST: |
13462 | 286 mp_msg(MSGT_VO,MSGL_STATUS, |
287 MSGTR_VO_YUV4MPEG_InterlacedBFFMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
288 break; |
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
289 default: |
13462 | 290 mp_msg(MSGT_VO,MSGL_STATUS, |
291 MSGTR_VO_YUV4MPEG_ProgressiveMode); | |
6659
715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
arpi
parents:
6213
diff
changeset
|
292 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
|
293 } |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4706
diff
changeset
|
294 return 0; |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
295 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
296 |
33305
ddb45e9443ec
Remove the variable arguments from the libvo control() functions.
iive
parents:
32537
diff
changeset
|
297 static int control(uint32_t request, void *data) |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
298 { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
299 switch (request) { |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
300 case VOCTRL_QUERY_FORMAT: |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
301 return query_format(*((uint32_t*)data)); |
8450 | 302 case VOCTRL_DUPLICATE_FRAME: |
303 return write_last_frame(); | |
4597
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
304 } |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
305 return VO_NOTIMPL; |
4ba62f7d04c6
yuv4mpeg output, by Robert Kesterson <robertk@robertk.com>
arpi
parents:
diff
changeset
|
306 } |