1 /*
2 * Copyright (c) 2013 Vittorio Giovara
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * Generate a frame packed video, by combining two views in a single surface.
24 */
25
26 #include <string.h>
27
33
38
41
44
46
48
50
53
59 };
60
62 {
63 // this will ensure that formats are the same on all pads
65 return 0;
66 }
67
69 {
71
72 // clean any leftover frame
75 }
76
78 {
81
86
87 // check size and fps match on the other input
91 "Left and right sizes differ (%dx%d vs %dx%d).\n",
92 width, height,
97 "Left and right time bases differ (%d/%d vs %d/%d).\n",
98 time_base.
num, time_base.
den,
104 "Left and right framerates differ (%d/%d vs %d/%d).\n",
105 frame_rate.
num, frame_rate.
den,
109 }
110
114
115 // modify output properties as needed
120
122 break;
125 width *= 2;
126 break;
129 height *= 2;
130 break;
131 default:
134 }
135
140
141 return 0;
142 }
143
146 int interleaved)
147 {
148 int plane, i;
151
156
157 if (plane == 1 || plane == 2) {
160 }
161
162 if (interleaved) {
163 for (i = 0; i < lines; i++) {
164 int j;
165 int k = 0;
166
167 for (j = 0; j <
length; j++) {
168 dstp[k++] = leftp[j];
169 dstp[k++] = rightp[j];
170 }
171
175 }
176 } else {
179 length, lines);
182 length, lines);
183 }
184 }
185 }
186
189 int interleaved)
190 {
193 int lines = dst->
height / 2;
194
196 if (plane == 1 || plane == 2) {
199 }
200
202
204 dst->
linesize[plane] << interleaved,
207 length, lines);
209 dst->
linesize[plane] << interleaved,
212 length, lines);
213 }
214 }
215
217 {
221 break;
224 break;
227 break;
230 break;
231 }
232 }
233
235 {
238 return 0;
239 }
240
242 {
245 return 0;
246 }
247
249 {
254
255 /* get a frame on the either input, stop as soon as a video ends */
256 for (i = 0; i < 2; i++) {
259 if (ret < 0)
261 }
262 }
263
267
268 for (i = 0; i < 2; i++) {
269 // set correct timestamps
271
272 // set stereo3d side data
274 if (!stereo)
277
278 // filter the frame and immediately relinquish its pointer
281 if (ret < 0)
283 }
285 } else {
287 if (!dst)
289
291
292 // get any property from the original frame
294 if (ret < 0) {
297 }
298
299 for (i = 0; i < 2; i++)
301
302 // set stereo3d side data
304 if (!stereo) {
307 }
309
311 }
312 }
313
314 #define OFFSET(x) offsetof(FramepackContext, x)
315 #define V AV_OPT_FLAG_VIDEO_PARAM
330 };
331
337 };
338
340 {
344 .needs_fifo = 1,
345 },
346 {
347 .name = "right",
350 .needs_fifo = 1,
351 },
353 };
354
356 {
361 },
363 };
364
369 .priv_class = &framepack_class,
371 .
inputs = framepack_inputs,
374 };