1 /*
2 * YUV4MPEG muxer
3 * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
26
27 #define Y4M_LINE_MAX 256
28
30 {
33 int raten, rated, aspectn, aspectd,
n;
34 char inter;
36
40
41 // TODO: should be avg_frame_rate
44
47
48 if (aspectn == 0 && aspectd == 1)
49 aspectd = 0; // 0:0 means unknown
50
56 default: inter = 'p'; break;
57 }
58
61 colorspace = " Cmono";
62 break;
64 colorspace = " Cmono16";
65 break;
67 colorspace = " C411 XYSCSS=411";
68 break;
73 default: colorspace = " C420jpeg XYSCSS=420JPEG"; break;
74 }
75 break;
77 colorspace = " C422 XYSCSS=422";
78 break;
80 colorspace = " C444 XYSCSS=444";
81 break;
83 colorspace = " C420p9 XYSCSS=420P9";
84 break;
86 colorspace = " C422p9 XYSCSS=422P9";
87 break;
89 colorspace = " C444p9 XYSCSS=444P9";
90 break;
92 colorspace = " C420p10 XYSCSS=420P10";
93 break;
95 colorspace = " C422p10 XYSCSS=422P10";
96 break;
98 colorspace = " C444p10 XYSCSS=444P10";
99 break;
101 colorspace = " C420p12 XYSCSS=420P12";
102 break;
104 colorspace = " C422p12 XYSCSS=422P12";
105 break;
107 colorspace = " C444p12 XYSCSS=444P12";
108 break;
110 colorspace = " C420p14 XYSCSS=420P14";
111 break;
113 colorspace = " C422p14 XYSCSS=422P14";
114 break;
116 colorspace = " C444p14 XYSCSS=444P14";
117 break;
119 colorspace = " C420p16 XYSCSS=420P16";
120 break;
122 colorspace = " C422p16 XYSCSS=422P16";
123 break;
125 colorspace = " C444p16 XYSCSS=444P16";
126 break;
127 }
128
129 /* construct stream header, if this is the first frame */
131 Y4M_MAGIC, width, height, raten, rated, inter,
132 aspectn, aspectd, colorspace);
133
135 }
136
138 {
144 int i;
146 char buf1[20];
148
150 picture = &picture_tmp;
151
152 /* for the first packet we have to output the header as well */
153 if (*first_pkt) {
154 *first_pkt = 0;
157 "Error. YUV4MPEG stream header write failed.\n");
159 } else {
161 }
162 }
163
164 /* construct frame header */
165
168
171
172 ptr = picture->
data[0];
173
180 break;
197 width *= 2;
198 break;
199 default:
203 }
204
205 for (i = 0; i <
height; i++) {
208 }
209
212 // Adjust for smaller Cb and Cr planes
214 &v_chroma_shift);
217
218 ptr1 = picture->
data[1];
219 ptr2 = picture->
data[2];
220 for (i = 0; i <
height; i++) {
/* Cb */
223 }
224 for (i = 0; i <
height; i++) {
/* Cr */
227 }
228 }
229
230 return 0;
231 }
232
234 {
236
239
243 }
244
248 "stream, some mjpegtools might not work.\n");
249 break;
255 break;
273 "Use '-strict -1' to encode to this pixel format.\n",
276 }
278 "Mjpegtools will not work.\n");
279 break;
280 default:
282 "yuv444p, yuv422p, yuv420p, yuv411p and gray8 pixel formats. "
283 "And using 'strict -1' also yuv444p9, yuv422p9, yuv420p9, "
284 "yuv444p10, yuv422p10, yuv420p10, "
285 "yuv444p12, yuv422p12, yuv420p12, "
286 "yuv444p14, yuv422p14, yuv420p14, "
287 "yuv444p16, yuv422p16, yuv420p16 "
288 "and gray16 pixel formats. "
289 "Use -pix_fmt to select one.\n");
291 }
292
293 *first_pkt = 1;
294 return 0;
295 }
296
298 .
name =
"yuv4mpegpipe",
300 .extensions = "y4m",
301 .priv_data_size = sizeof(int),
307 };