FFmpeg
Loading...
Searching...
No Matches
vf_stereo3d.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Gordon Schmidt <gordon.schmidt <at> s2000.tu-chemnitz.de>
3 * Copyright (c) 2013-2015 Paul B Mahol
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 General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 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
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "libavutil/avassert.h"
23#include "libavutil/imgutils.h"
25#include "libavutil/opt.h"
27#include "libavutil/pixdesc.h"
28#include "avfilter.h"
29#include "drawutils.h"
30#include "filters.h"
31#include "formats.h"
32#include "video.h"
33#include "stereo3d.h"
34
36 ANAGLYPH_RC_GRAY, // anaglyph red/cyan gray
37 ANAGLYPH_RC_HALF, // anaglyph red/cyan half colored
38 ANAGLYPH_RC_COLOR, // anaglyph red/cyan colored
39 ANAGLYPH_RC_DUBOIS, // anaglyph red/cyan dubois
40 ANAGLYPH_GM_GRAY, // anaglyph green/magenta gray
41 ANAGLYPH_GM_HALF, // anaglyph green/magenta half colored
42 ANAGLYPH_GM_COLOR, // anaglyph green/magenta colored
43 ANAGLYPH_GM_DUBOIS, // anaglyph green/magenta dubois
44 ANAGLYPH_YB_GRAY, // anaglyph yellow/blue gray
45 ANAGLYPH_YB_HALF, // anaglyph yellow/blue half colored
46 ANAGLYPH_YB_COLOR, // anaglyph yellow/blue colored
47 ANAGLYPH_YB_DUBOIS, // anaglyph yellow/blue dubois
48 ANAGLYPH_RB_GRAY, // anaglyph red/blue gray
49 ANAGLYPH_RG_GRAY, // anaglyph red/green gray
50 MONO_L, // mono output for debugging (left eye only)
51 MONO_R, // mono output for debugging (right eye only)
52 INTERLEAVE_ROWS_LR, // row-interleave (left eye has top row)
53 INTERLEAVE_ROWS_RL, // row-interleave (right eye has top row)
54 SIDE_BY_SIDE_LR, // side by side parallel (left eye left, right eye right)
55 SIDE_BY_SIDE_RL, // side by side crosseye (right eye left, left eye right)
56 SIDE_BY_SIDE_2_LR, // side by side parallel with half width resolution
57 SIDE_BY_SIDE_2_RL, // side by side crosseye with half width resolution
58 ABOVE_BELOW_LR, // above-below (left eye above, right eye below)
59 ABOVE_BELOW_RL, // above-below (right eye above, left eye below)
60 ABOVE_BELOW_2_LR, // above-below with half height resolution
61 ABOVE_BELOW_2_RL, // above-below with half height resolution
62 ALTERNATING_LR, // alternating frames (left eye first, right eye second)
63 ALTERNATING_RL, // alternating frames (right eye first, left eye second)
64 CHECKERBOARD_LR, // checkerboard pattern (left eye first, right eye second)
65 CHECKERBOARD_RL, // checkerboard pattern (right eye first, left eye second)
66 INTERLEAVE_COLS_LR, // column-interleave (left eye first, right eye second)
67 INTERLEAVE_COLS_RL, // column-interleave (right eye first, left eye second)
68 HDMI, // HDMI frame pack (left eye first, right eye second)
69 STEREO_CODE_COUNT // TODO: needs autodetection
70};
71
80
81static const int ana_coeff[][3][6] = {
83 {{19595, 38470, 7471, 0, 0, 0},
84 { 0, 0, 0, 0, 0, 0},
85 { 0, 0, 0, 19595, 38470, 7471}},
87 {{19595, 38470, 7471, 0, 0, 0},
88 { 0, 0, 0, 19595, 38470, 7471},
89 { 0, 0, 0, 0, 0, 0}},
91 {{19595, 38470, 7471, 0, 0, 0},
92 { 0, 0, 0, 19595, 38470, 7471},
93 { 0, 0, 0, 19595, 38470, 7471}},
95 {{19595, 38470, 7471, 0, 0, 0},
96 { 0, 0, 0, 0, 65536, 0},
97 { 0, 0, 0, 0, 0, 65536}},
99 {{65536, 0, 0, 0, 0, 0},
100 { 0, 0, 0, 0, 65536, 0},
101 { 0, 0, 0, 0, 0, 65536}},
103 {{29884, 32768, 11534, -2818, -5767, -131},
104 {-2621, -2490, -1049, 24773, 48103, -1180},
105 { -983, -1376, -328, -4719, -7406, 80347}},
107 {{ 0, 0, 0, 19595, 38470, 7471},
108 {19595, 38470, 7471, 0, 0, 0},
109 { 0, 0, 0, 19595, 38470, 7471}},
111 {{ 0, 0, 0, 65536, 0, 0},
112 {19595, 38470, 7471, 0, 0, 0},
113 { 0, 0, 0, 0, 0, 65536}},
115 {{ 0, 0, 0, 65536, 0, 0},
116 { 0, 65536, 0, 0, 0, 0},
117 { 0, 0, 0, 0, 0, 65536}},
119 {{-4063,-10354, -2556, 34669, 46203, 1573},
120 {18612, 43778, 9372, -1049, -983, -4260},
121 { -983, -1769, 1376, 590, 4915, 61407}},
123 {{ 0, 0, 0, 19595, 38470, 7471},
124 { 0, 0, 0, 19595, 38470, 7471},
125 {19595, 38470, 7471, 0, 0, 0}},
127 {{ 0, 0, 0, 65536, 0, 0},
128 { 0, 0, 0, 0, 65536, 0},
129 {19595, 38470, 7471, 0, 0, 0}},
131 {{ 0, 0, 0, 65536, 0, 0},
132 { 0, 0, 0, 0, 65536, 0},
133 { 0, 0, 65536, 0, 0, 0}},
135 {{69599,-13435,19595, -1048, -8061, -1114},
136 {-1704, 59507, 4456, 393, 4063, -1114},
137 {-2490,-11338, 1442, 6160, 12124, 59703}},
138};
139
156
157#define OFFSET(x) offsetof(Stereo3DContext, x)
158#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
159
160static const AVOption stereo3d_options[] = {
161 { "in", "set input format", OFFSET(in.format), AV_OPT_TYPE_INT, {.i64=SIDE_BY_SIDE_LR}, INTERLEAVE_ROWS_LR, STEREO_CODE_COUNT-1, FLAGS, .unit = "in"},
162 { "ab2l", "above below half height left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_LR}, 0, 0, FLAGS, .unit = "in" },
163 { "tb2l", "above below half height left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_LR}, 0, 0, FLAGS, .unit = "in" },
164 { "ab2r", "above below half height right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_RL}, 0, 0, FLAGS, .unit = "in" },
165 { "tb2r", "above below half height right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_RL}, 0, 0, FLAGS, .unit = "in" },
166 { "abl", "above below left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_LR}, 0, 0, FLAGS, .unit = "in" },
167 { "tbl", "above below left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_LR}, 0, 0, FLAGS, .unit = "in" },
168 { "abr", "above below right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_RL}, 0, 0, FLAGS, .unit = "in" },
169 { "tbr", "above below right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_RL}, 0, 0, FLAGS, .unit = "in" },
170 { "al", "alternating frames left first", 0, AV_OPT_TYPE_CONST, {.i64=ALTERNATING_LR}, 0, 0, FLAGS, .unit = "in" },
171 { "ar", "alternating frames right first", 0, AV_OPT_TYPE_CONST, {.i64=ALTERNATING_RL}, 0, 0, FLAGS, .unit = "in" },
172 { "sbs2l", "side by side half width left first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_2_LR}, 0, 0, FLAGS, .unit = "in" },
173 { "sbs2r", "side by side half width right first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_2_RL}, 0, 0, FLAGS, .unit = "in" },
174 { "sbsl", "side by side left first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_LR}, 0, 0, FLAGS, .unit = "in" },
175 { "sbsr", "side by side right first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_RL}, 0, 0, FLAGS, .unit = "in" },
176 { "irl", "interleave rows left first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_ROWS_LR}, 0, 0, FLAGS, .unit = "in" },
177 { "irr", "interleave rows right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_ROWS_RL}, 0, 0, FLAGS, .unit = "in" },
178 { "icl", "interleave columns left first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_LR}, 0, 0, FLAGS, .unit = "in" },
179 { "icr", "interleave columns right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_RL}, 0, 0, FLAGS, .unit = "in" },
180 { "out", "set output format", OFFSET(out.format), AV_OPT_TYPE_INT, {.i64=ANAGLYPH_RC_DUBOIS}, 0, STEREO_CODE_COUNT-1, FLAGS, .unit = "out"},
181 { "ab2l", "above below half height left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_LR}, 0, 0, FLAGS, .unit = "out" },
182 { "tb2l", "above below half height left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_LR}, 0, 0, FLAGS, .unit = "out" },
183 { "ab2r", "above below half height right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_RL}, 0, 0, FLAGS, .unit = "out" },
184 { "tb2r", "above below half height right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_RL}, 0, 0, FLAGS, .unit = "out" },
185 { "abl", "above below left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_LR}, 0, 0, FLAGS, .unit = "out" },
186 { "tbl", "above below left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_LR}, 0, 0, FLAGS, .unit = "out" },
187 { "abr", "above below right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_RL}, 0, 0, FLAGS, .unit = "out" },
188 { "tbr", "above below right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_RL}, 0, 0, FLAGS, .unit = "out" },
189 { "agmc", "anaglyph green magenta color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_GM_COLOR}, 0, 0, FLAGS, .unit = "out" },
190 { "agmd", "anaglyph green magenta dubois", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_GM_DUBOIS}, 0, 0, FLAGS, .unit = "out" },
191 { "agmg", "anaglyph green magenta gray", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_GM_GRAY}, 0, 0, FLAGS, .unit = "out" },
192 { "agmh", "anaglyph green magenta half color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_GM_HALF}, 0, 0, FLAGS, .unit = "out" },
193 { "al", "alternating frames left first", 0, AV_OPT_TYPE_CONST, {.i64=ALTERNATING_LR}, 0, 0, FLAGS, .unit = "out" },
194 { "ar", "alternating frames right first", 0, AV_OPT_TYPE_CONST, {.i64=ALTERNATING_RL}, 0, 0, FLAGS, .unit = "out" },
195 { "arbg", "anaglyph red blue gray", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RB_GRAY}, 0, 0, FLAGS, .unit = "out" },
196 { "arcc", "anaglyph red cyan color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RC_COLOR}, 0, 0, FLAGS, .unit = "out" },
197 { "arcd", "anaglyph red cyan dubois", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RC_DUBOIS}, 0, 0, FLAGS, .unit = "out" },
198 { "arcg", "anaglyph red cyan gray", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RC_GRAY}, 0, 0, FLAGS, .unit = "out" },
199 { "arch", "anaglyph red cyan half color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RC_HALF}, 0, 0, FLAGS, .unit = "out" },
200 { "argg", "anaglyph red green gray", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RG_GRAY}, 0, 0, FLAGS, .unit = "out" },
201 { "aybc", "anaglyph yellow blue color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_YB_COLOR}, 0, 0, FLAGS, .unit = "out" },
202 { "aybd", "anaglyph yellow blue dubois", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_YB_DUBOIS}, 0, 0, FLAGS, .unit = "out" },
203 { "aybg", "anaglyph yellow blue gray", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_YB_GRAY}, 0, 0, FLAGS, .unit = "out" },
204 { "aybh", "anaglyph yellow blue half color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_YB_HALF}, 0, 0, FLAGS, .unit = "out" },
205 { "irl", "interleave rows left first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_ROWS_LR}, 0, 0, FLAGS, .unit = "out" },
206 { "irr", "interleave rows right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_ROWS_RL}, 0, 0, FLAGS, .unit = "out" },
207 { "ml", "mono left", 0, AV_OPT_TYPE_CONST, {.i64=MONO_L}, 0, 0, FLAGS, .unit = "out" },
208 { "mr", "mono right", 0, AV_OPT_TYPE_CONST, {.i64=MONO_R}, 0, 0, FLAGS, .unit = "out" },
209 { "sbs2l", "side by side half width left first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_2_LR}, 0, 0, FLAGS, .unit = "out" },
210 { "sbs2r", "side by side half width right first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_2_RL}, 0, 0, FLAGS, .unit = "out" },
211 { "sbsl", "side by side left first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_LR}, 0, 0, FLAGS, .unit = "out" },
212 { "sbsr", "side by side right first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_RL}, 0, 0, FLAGS, .unit = "out" },
213 { "chl", "checkerboard left first", 0, AV_OPT_TYPE_CONST, {.i64=CHECKERBOARD_LR}, 0, 0, FLAGS, .unit = "out" },
214 { "chr", "checkerboard right first", 0, AV_OPT_TYPE_CONST, {.i64=CHECKERBOARD_RL}, 0, 0, FLAGS, .unit = "out" },
215 { "icl", "interleave columns left first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_LR}, 0, 0, FLAGS, .unit = "out" },
216 { "icr", "interleave columns right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_RL}, 0, 0, FLAGS, .unit = "out" },
217 { "hdmi", "HDMI frame pack", 0, AV_OPT_TYPE_CONST, {.i64=HDMI}, 0, 0, FLAGS, .unit = "out" },
218 { NULL }
219};
220
222
227
228static const enum AVPixelFormat other_pix_fmts[] = {
280};
281
283 AVFilterFormatsConfig **cfg_in,
284 AVFilterFormatsConfig **cfg_out)
285{
286 const Stereo3DContext *s = ctx->priv;
287 const enum AVPixelFormat *pix_fmts;
288
289 switch (s->out.format) {
292 case ANAGLYPH_GM_GRAY:
293 case ANAGLYPH_GM_HALF:
294 case ANAGLYPH_RB_GRAY:
297 case ANAGLYPH_RC_GRAY:
298 case ANAGLYPH_RC_HALF:
299 case ANAGLYPH_RG_GRAY:
302 case ANAGLYPH_YB_GRAY:
303 case ANAGLYPH_YB_HALF:
305 break;
306 default:
308 }
309
310 return ff_set_pixel_formats_from_list2(ctx, cfg_in, cfg_out, pix_fmts);
311}
312
313static inline uint8_t ana_convert(const int *coeff, const uint8_t *left, const uint8_t *right)
314{
315 int sum;
316
317 sum = coeff[0] * left[0] + coeff[3] * right[0]; //red in
318 sum += coeff[1] * left[1] + coeff[4] * right[1]; //green in
319 sum += coeff[2] * left[2] + coeff[5] * right[2]; //blue in
320
321 return av_clip_uint8(sum >> 16);
322}
323
324static void anaglyph_ic(uint8_t *dst, uint8_t *lsrc, uint8_t *rsrc,
325 ptrdiff_t dst_linesize, ptrdiff_t l_linesize, ptrdiff_t r_linesize,
326 int width, int height,
327 const int *ana_matrix_r, const int *ana_matrix_g, const int *ana_matrix_b)
328{
329 int x, y, o;
330
331 for (y = 0; y < height; y++) {
332 for (o = 0, x = 0; x < width; x++, o+= 3) {
333 dst[o ] = ana_convert(ana_matrix_r, lsrc + o * 2, rsrc + o * 2);
334 dst[o + 1] = ana_convert(ana_matrix_g, lsrc + o * 2, rsrc + o * 2);
335 dst[o + 2] = ana_convert(ana_matrix_b, lsrc + o * 2, rsrc + o * 2);
336 }
337
338 dst += dst_linesize;
339 lsrc += l_linesize;
340 rsrc += r_linesize;
341 }
342}
343
344static void anaglyph(uint8_t *dst, uint8_t *lsrc, uint8_t *rsrc,
345 ptrdiff_t dst_linesize, ptrdiff_t l_linesize, ptrdiff_t r_linesize,
346 int width, int height,
347 const int *ana_matrix_r, const int *ana_matrix_g, const int *ana_matrix_b)
348{
349 int x, y, o;
350
351 for (y = 0; y < height; y++) {
352 for (o = 0, x = 0; x < width; x++, o+= 3) {
353 dst[o ] = ana_convert(ana_matrix_r, lsrc + o, rsrc + o);
354 dst[o + 1] = ana_convert(ana_matrix_g, lsrc + o, rsrc + o);
355 dst[o + 2] = ana_convert(ana_matrix_b, lsrc + o, rsrc + o);
356 }
357
358 dst += dst_linesize;
359 lsrc += l_linesize;
360 rsrc += r_linesize;
361 }
362}
363
364static int config_output(AVFilterLink *outlink)
365{
366 AVFilterContext *ctx = outlink->src;
367 AVFilterLink *inlink = ctx->inputs[0];
368 Stereo3DContext *s = ctx->priv;
369 FilterLink *il = ff_filter_link(inlink);
370 FilterLink *ol = ff_filter_link(outlink);
371 AVRational fps = il->frame_rate;
372 AVRational tb = inlink->time_base;
374 int ret;
375 s->aspect = inlink->sample_aspect_ratio;
376
377 switch (s->in.format) {
381 case SIDE_BY_SIDE_LR:
383 case SIDE_BY_SIDE_RL:
384 if (inlink->w & 1) {
385 av_log(ctx, AV_LOG_ERROR, "width must be even\n");
386 return AVERROR_INVALIDDATA;
387 }
388 break;
391 case ABOVE_BELOW_2_LR:
392 case ABOVE_BELOW_LR:
393 case ABOVE_BELOW_2_RL:
394 case ABOVE_BELOW_RL:
395 if (inlink->h & 1) {
396 av_log(ctx, AV_LOG_ERROR, "height must be even\n");
397 return AVERROR_INVALIDDATA;
398 }
399 if (AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h) & 1) {
400 av_log(ctx, AV_LOG_ERROR, "chroma height must be even\n");
401 return AVERROR_INVALIDDATA;
402 }
403 break;
404 }
405
406 s->in.width =
407 s->width = inlink->w;
408 s->in.height =
409 s->height = inlink->h;
410 s->in.off_lstep =
411 s->in.off_rstep =
412 s->in.off_left =
413 s->in.off_right =
414 s->in.row_left =
415 s->in.row_right = 0;
416 s->in.row_step = 1;
417
418 switch (s->in.format) {
420 s->aspect.num *= 2;
422 case SIDE_BY_SIDE_LR:
423 s->width = inlink->w / 2;
424 s->in.off_right = s->width;
425 break;
427 s->aspect.num *= 2;
429 case SIDE_BY_SIDE_RL:
430 s->width = inlink->w / 2;
431 s->in.off_left = s->width;
432 break;
433 case ABOVE_BELOW_2_LR:
434 s->aspect.den *= 2;
436 case ABOVE_BELOW_LR:
437 s->in.row_right =
438 s->height = inlink->h / 2;
439 break;
440 case ABOVE_BELOW_2_RL:
441 s->aspect.den *= 2;
443 case ABOVE_BELOW_RL:
444 s->in.row_left =
445 s->height = inlink->h / 2;
446 break;
447 case ALTERNATING_RL:
448 case ALTERNATING_LR:
449 fps.den *= 2;
450 tb.num *= 2;
451 break;
454 s->width = inlink->w / 2;
455 break;
458 s->in.row_step = 2;
459 if (s->in.format == INTERLEAVE_ROWS_RL)
460 s->in.off_lstep = 1;
461 else
462 s->in.off_rstep = 1;
463 if (s->out.format != CHECKERBOARD_LR &&
464 s->out.format != CHECKERBOARD_RL)
465 s->height = inlink->h / 2;
466 break;
467 default:
468 av_log(ctx, AV_LOG_ERROR, "input format %d is not supported\n", s->in.format);
469 return AVERROR(EINVAL);
470 }
471
472 s->out.width = s->width;
473 s->out.height = s->height;
474 s->out.off_lstep =
475 s->out.off_rstep =
476 s->out.off_left =
477 s->out.off_right =
478 s->out.row_left =
479 s->out.row_right = 0;
480 s->out.row_step = 1;
481
482 switch (s->out.format) {
483 case ANAGLYPH_RB_GRAY:
484 case ANAGLYPH_RG_GRAY:
485 case ANAGLYPH_RC_GRAY:
486 case ANAGLYPH_RC_HALF:
489 case ANAGLYPH_GM_GRAY:
490 case ANAGLYPH_GM_HALF:
493 case ANAGLYPH_YB_GRAY:
494 case ANAGLYPH_YB_HALF:
496 case ANAGLYPH_YB_DUBOIS: {
497 uint8_t rgba_map[4];
498
499 ff_fill_rgba_map(rgba_map, outlink->format);
500 s->ana_matrix[rgba_map[0]] = &ana_coeff[s->out.format][0][0];
501 s->ana_matrix[rgba_map[1]] = &ana_coeff[s->out.format][1][0];
502 s->ana_matrix[rgba_map[2]] = &ana_coeff[s->out.format][2][0];
503 break;
504 }
506 s->aspect.den *= 2;
508 case SIDE_BY_SIDE_LR:
509 s->out.width = s->width * 2;
510 s->out.off_right = s->width;
511 break;
513 s->aspect.den *= 2;
515 case SIDE_BY_SIDE_RL:
516 s->out.width = s->width * 2;
517 s->out.off_left = s->width;
518 break;
519 case ABOVE_BELOW_2_LR:
520 s->aspect.num *= 2;
522 case ABOVE_BELOW_LR:
523 s->out.height = s->height * 2;
524 s->out.row_right = s->height;
525 break;
526 case HDMI:
527 if (s->height != 720 && s->height != 1080) {
528 av_log(ctx, AV_LOG_ERROR, "Only 720 and 1080 height supported\n");
529 return AVERROR(EINVAL);
530 }
531
532 s->blanks = s->height / 24;
533 s->out.height = s->height * 2 + s->blanks;
534 s->out.row_right = s->height + s->blanks;
535 break;
536 case ABOVE_BELOW_2_RL:
537 s->aspect.num *= 2;
539 case ABOVE_BELOW_RL:
540 s->out.height = s->height * 2;
541 s->out.row_left = s->height;
542 break;
544 s->in.row_step = 1 + (s->in.format == INTERLEAVE_ROWS_RL);
545 s->out.row_step = 2;
546 s->out.height = s->height * 2;
547 s->out.off_rstep = 1;
548 break;
550 s->in.row_step = 1 + (s->in.format == INTERLEAVE_ROWS_LR);
551 s->out.row_step = 2;
552 s->out.height = s->height * 2;
553 s->out.off_lstep = 1;
554 break;
555 case MONO_R:
556 if (s->in.format != INTERLEAVE_COLS_LR) {
557 s->in.off_left = s->in.off_right;
558 s->in.row_left = s->in.row_right;
559 }
560 if (s->in.format == INTERLEAVE_ROWS_LR)
561 FFSWAP(int, s->in.off_lstep, s->in.off_rstep);
562 break;
563 case MONO_L:
564 if (s->in.format == INTERLEAVE_ROWS_RL)
565 FFSWAP(int, s->in.off_lstep, s->in.off_rstep);
566 break;
567 case ALTERNATING_RL:
568 case ALTERNATING_LR:
569 fps.num *= 2;
570 tb.den *= 2;
571 break;
572 case CHECKERBOARD_LR:
573 case CHECKERBOARD_RL:
576 s->out.width = s->width * 2;
577 break;
578 default:
579 av_log(ctx, AV_LOG_ERROR, "output format %d is not supported\n", s->out.format);
580 return AVERROR(EINVAL);
581 }
582
583 if (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL) {
584 if ((s->in.format & 1) != (s->out.format & 1)) {
585 FFSWAP(int, s->in.row_left, s->in.row_right);
586 FFSWAP(int, s->in.off_lstep, s->in.off_rstep);
587 FFSWAP(int, s->in.off_left, s->in.off_right);
588 FFSWAP(int, s->out.row_left, s->out.row_right);
589 FFSWAP(int, s->out.off_lstep, s->out.off_rstep);
590 FFSWAP(int, s->out.off_left, s->out.off_right);
591 }
592 }
593
594 outlink->w = s->out.width;
595 outlink->h = s->out.height;
596 ol->frame_rate = fps;
597 outlink->time_base = tb;
598 outlink->sample_aspect_ratio = s->aspect;
599
600 if ((ret = av_image_fill_linesizes(s->linesize, outlink->format, s->width)) < 0)
601 return ret;
602 s->nb_planes = av_pix_fmt_count_planes(outlink->format);
604 s->pheight[1] = s->pheight[2] = AV_CEIL_RSHIFT(s->height, desc->log2_chroma_h);
605 s->pheight[0] = s->pheight[3] = s->height;
606 s->hsub = desc->log2_chroma_w;
607 s->vsub = desc->log2_chroma_h;
608
609 s->dsp.anaglyph = anaglyph;
610#if ARCH_X86 && HAVE_X86ASM
611 ff_stereo3d_init_x86(&s->dsp);
612#endif
613
614 return 0;
615}
616
617typedef struct ThreadData {
619 AVFrame *out;
620} ThreadData;
621
622static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
623{
624 Stereo3DContext *s = ctx->priv;
625 ThreadData *td = arg;
626 AVFrame *ileft = td->ileft;
627 AVFrame *iright = td->iright;
628 AVFrame *out = td->out;
629 int height = s->out.height;
630 int start = ff_slice_pos(height, jobnr, nb_jobs);
631 int end = ff_slice_pos(height, jobnr + 1, nb_jobs);
632 const int **ana_matrix = s->ana_matrix;
633
634 s->dsp.anaglyph(out->data[0] + out->linesize[0] * start,
635 ileft ->data[0] + s->in_off_left [0] + ileft->linesize[0] * start * s->in.row_step,
636 iright->data[0] + s->in_off_right[0] + iright->linesize[0] * start * s->in.row_step,
637 out->linesize[0],
638 ileft->linesize[0] * s->in.row_step,
639 iright->linesize[0] * s->in.row_step,
640 s->out.width, end - start,
641 ana_matrix[0], ana_matrix[1], ana_matrix[2]);
642
643 return 0;
644}
645
646static void interleave_cols_to_any(Stereo3DContext *s, int *out_off, int p, AVFrame *in, AVFrame *out, int d)
647{
648 int y, x;
649
650 for (y = 0; y < s->pheight[p]; y++) {
651 const uint8_t *src = (const uint8_t*)in->data[p] + y * in->linesize[p] + d * s->pixstep[p];
652 uint8_t *dst = out->data[p] + out_off[p] + y * out->linesize[p] * s->out.row_step;
653
654 switch (s->pixstep[p]) {
655 case 1:
656 for (x = 0; x < s->linesize[p]; x++)
657 dst[x] = src[x * 2];
658 break;
659 case 2:
660 for (x = 0; x < s->linesize[p]; x+=2)
661 AV_WN16(&dst[x], AV_RN16(&src[x * 2]));
662 break;
663 case 3:
664 for (x = 0; x < s->linesize[p]; x+=3)
665 AV_WB24(&dst[x], AV_RB24(&src[x * 2]));
666 break;
667 case 4:
668 for (x = 0; x < s->linesize[p]; x+=4)
669 AV_WN32(&dst[x], AV_RN32(&src[x * 2]));
670 break;
671 case 6:
672 for (x = 0; x < s->linesize[p]; x+=6)
673 AV_WB48(&dst[x], AV_RB48(&src[x * 2]));
674 break;
675 case 8:
676 for (x = 0; x < s->linesize[p]; x+=8)
677 AV_WN64(&dst[x], AV_RN64(&src[x * 2]));
678 break;
679 }
680 }
681}
682
683static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
684{
685 AVFilterContext *ctx = inlink->dst;
686 Stereo3DContext *s = ctx->priv;
687 AVFilterLink *outlink = ctx->outputs[0];
688 AVFrame *out = NULL, *oleft, *oright, *ileft, *iright;
689 int out_off_left[4], out_off_right[4];
690 int i, ret;
691
692 if (s->in.format == s->out.format)
693 return ff_filter_frame(outlink, inpicref);
694
695 switch (s->out.format) {
696 case ALTERNATING_LR:
697 case ALTERNATING_RL:
698 if (!s->prev) {
699 s->prev = inpicref;
700 return 0;
701 }
702 break;
703 };
704
705 switch (s->in.format) {
706 case ALTERNATING_LR:
707 case ALTERNATING_RL:
708 if (!s->prev) {
709 s->prev = inpicref;
710 return 0;
711 }
712 ileft = s->prev;
713 iright = inpicref;
714 if (s->in.format == ALTERNATING_RL)
715 FFSWAP(AVFrame *, ileft, iright);
716 break;
717 default:
718 ileft = iright = inpicref;
719 };
720
721 if ((s->out.format == ALTERNATING_LR ||
722 s->out.format == ALTERNATING_RL) &&
723 (s->in.format == SIDE_BY_SIDE_LR ||
724 s->in.format == SIDE_BY_SIDE_RL ||
725 s->in.format == SIDE_BY_SIDE_2_LR ||
726 s->in.format == SIDE_BY_SIDE_2_RL ||
727 s->in.format == ABOVE_BELOW_LR ||
728 s->in.format == ABOVE_BELOW_RL ||
729 s->in.format == ABOVE_BELOW_2_LR ||
730 s->in.format == ABOVE_BELOW_2_RL ||
731 s->in.format == INTERLEAVE_ROWS_LR ||
732 s->in.format == INTERLEAVE_ROWS_RL)) {
733 oright = av_frame_clone(s->prev);
734 oleft = av_frame_clone(s->prev);
735 if (!oright || !oleft) {
736 av_frame_free(&oright);
737 av_frame_free(&oleft);
738 av_frame_free(&s->prev);
739 av_frame_free(&inpicref);
740 return AVERROR(ENOMEM);
741 }
742 } else if ((s->out.format == MONO_L ||
743 s->out.format == MONO_R) &&
744 (s->in.format == SIDE_BY_SIDE_LR ||
745 s->in.format == SIDE_BY_SIDE_RL ||
746 s->in.format == SIDE_BY_SIDE_2_LR ||
747 s->in.format == SIDE_BY_SIDE_2_RL ||
748 s->in.format == ABOVE_BELOW_LR ||
749 s->in.format == ABOVE_BELOW_RL ||
750 s->in.format == ABOVE_BELOW_2_LR ||
751 s->in.format == ABOVE_BELOW_2_RL ||
752 s->in.format == INTERLEAVE_ROWS_LR ||
753 s->in.format == INTERLEAVE_ROWS_RL)) {
754 out = oleft = oright = av_frame_clone(inpicref);
755 if (!out) {
756 av_frame_free(&s->prev);
757 av_frame_free(&inpicref);
758 return AVERROR(ENOMEM);
759 }
760 } else if ((s->out.format == MONO_L && s->in.format == ALTERNATING_LR) ||
761 (s->out.format == MONO_R && s->in.format == ALTERNATING_RL)) {
762 s->prev->pts /= 2;
763 ret = ff_filter_frame(outlink, s->prev);
764 av_frame_free(&inpicref);
765 s->prev = NULL;
766 return ret;
767 } else if ((s->out.format == MONO_L && s->in.format == ALTERNATING_RL) ||
768 (s->out.format == MONO_R && s->in.format == ALTERNATING_LR)) {
769 av_frame_free(&s->prev);
770 inpicref->pts /= 2;
771 return ff_filter_frame(outlink, inpicref);
772 } else if ((s->out.format == ALTERNATING_LR && s->in.format == ALTERNATING_RL) ||
773 (s->out.format == ALTERNATING_RL && s->in.format == ALTERNATING_LR)) {
774 FFSWAP(int64_t, s->prev->pts, inpicref->pts);
775 ff_filter_frame(outlink, inpicref);
776 ret = ff_filter_frame(outlink, s->prev);
777 s->prev = NULL;
778 return ret;
779 } else {
780 out = oleft = oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);
781 if (!out) {
782 av_frame_free(&s->prev);
783 av_frame_free(&inpicref);
784 return AVERROR(ENOMEM);
785 }
786 av_frame_copy_props(out, inpicref);
787
788 if (s->out.format == ALTERNATING_LR ||
789 s->out.format == ALTERNATING_RL) {
790 oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);
791 if (!oright) {
792 av_frame_free(&oleft);
793 av_frame_free(&s->prev);
794 av_frame_free(&inpicref);
795 return AVERROR(ENOMEM);
796 }
797 av_frame_copy_props(oright, s->prev);
798 }
799 }
800
801 for (i = 0; i < 4; i++) {
802 int hsub = i == 1 || i == 2 ? s->hsub : 0;
803 int vsub = i == 1 || i == 2 ? s->vsub : 0;
804 s->in_off_left[i] = (AV_CEIL_RSHIFT(s->in.row_left, vsub) + s->in.off_lstep) * ileft->linesize[i] + AV_CEIL_RSHIFT(s->in.off_left * s->pixstep[i], hsub);
805 s->in_off_right[i] = (AV_CEIL_RSHIFT(s->in.row_right, vsub) + s->in.off_rstep) * iright->linesize[i] + AV_CEIL_RSHIFT(s->in.off_right * s->pixstep[i], hsub);
806 out_off_left[i] = (AV_CEIL_RSHIFT(s->out.row_left, vsub) + s->out.off_lstep) * oleft->linesize[i] + AV_CEIL_RSHIFT(s->out.off_left * s->pixstep[i], hsub);
807 out_off_right[i] = (AV_CEIL_RSHIFT(s->out.row_right, vsub) + s->out.off_rstep) * oright->linesize[i] + AV_CEIL_RSHIFT(s->out.off_right * s->pixstep[i], hsub);
808 }
809
810 switch (s->out.format) {
811 case ALTERNATING_LR:
812 case ALTERNATING_RL:
813 switch (s->in.format) {
816 for (i = 0; i < s->nb_planes; i++) {
817 oleft->linesize[i] *= 2;
818 oright->linesize[i] *= 2;
819 }
821 case ABOVE_BELOW_LR:
822 case ABOVE_BELOW_RL:
823 case ABOVE_BELOW_2_LR:
824 case ABOVE_BELOW_2_RL:
825 case SIDE_BY_SIDE_LR:
826 case SIDE_BY_SIDE_RL:
829 oleft->width = outlink->w;
830 oright->width = outlink->w;
831 oleft->height = outlink->h;
832 oright->height = outlink->h;
833
834 for (i = 0; i < s->nb_planes; i++) {
835 oleft->data[i] += s->in_off_left[i];
836 oright->data[i] += s->in_off_right[i];
837 }
838 break;
839 default:
840 goto copy;
841 break;
842 }
843 break;
844 case HDMI:
845 for (i = 0; i < s->nb_planes; i++) {
846 int j, h = s->height >> ((i == 1 || i == 2) ? s->vsub : 0);
847 int b = (s->blanks) >> ((i == 1 || i == 2) ? s->vsub : 0);
848
849 for (j = h; j < h + b; j++)
850 memset(oleft->data[i] + j * s->linesize[i], 0, s->linesize[i]);
851 }
853 case SIDE_BY_SIDE_LR:
854 case SIDE_BY_SIDE_RL:
857 case ABOVE_BELOW_LR:
858 case ABOVE_BELOW_RL:
859 case ABOVE_BELOW_2_LR:
860 case ABOVE_BELOW_2_RL:
863copy:
864 if (s->in.format == INTERLEAVE_COLS_LR ||
865 s->in.format == INTERLEAVE_COLS_RL) {
866 for (i = 0; i < s->nb_planes; i++) {
867 int d = (s->in.format & 1) != (s->out.format & 1);
868
869 interleave_cols_to_any(s, out_off_left, i, ileft, oleft, d);
870 interleave_cols_to_any(s, out_off_right, i, iright, oright, !d);
871 }
872 } else {
873 for (i = 0; i < s->nb_planes; i++) {
874 av_image_copy_plane(oleft->data[i] + out_off_left[i],
875 oleft->linesize[i] * s->out.row_step,
876 ileft->data[i] + s->in_off_left[i],
877 ileft->linesize[i] * s->in.row_step,
878 s->linesize[i], s->pheight[i]);
879 av_image_copy_plane(oright->data[i] + out_off_right[i],
880 oright->linesize[i] * s->out.row_step,
881 iright->data[i] + s->in_off_right[i],
882 iright->linesize[i] * s->in.row_step,
883 s->linesize[i], s->pheight[i]);
884 }
885 }
886 break;
887 case MONO_L:
888 iright = ileft;
890 case MONO_R:
891 switch (s->in.format) {
894 for (i = 0; i < s->nb_planes; i++) {
895 out->linesize[i] *= 2;
896 }
898 case ABOVE_BELOW_LR:
899 case ABOVE_BELOW_RL:
900 case ABOVE_BELOW_2_LR:
901 case ABOVE_BELOW_2_RL:
902 case SIDE_BY_SIDE_LR:
903 case SIDE_BY_SIDE_RL:
906 out->width = outlink->w;
907 out->height = outlink->h;
908
909 for (i = 0; i < s->nb_planes; i++) {
910 out->data[i] += s->in_off_left[i];
911 }
912 break;
915 for (i = 0; i < s->nb_planes; i++) {
916 const int d = (s->in.format & 1) != (s->out.format & 1);
917
918 interleave_cols_to_any(s, out_off_right, i, iright, out, d);
919 }
920 break;
921 default:
922 for (i = 0; i < s->nb_planes; i++) {
923 av_image_copy_plane(out->data[i], out->linesize[i],
924 iright->data[i] + s->in_off_left[i],
925 iright->linesize[i] * s->in.row_step,
926 s->linesize[i], s->pheight[i]);
927 }
928 break;
929 }
930 break;
931 case ANAGLYPH_RB_GRAY:
932 case ANAGLYPH_RG_GRAY:
933 case ANAGLYPH_RC_GRAY:
934 case ANAGLYPH_RC_HALF:
937 case ANAGLYPH_GM_GRAY:
938 case ANAGLYPH_GM_HALF:
941 case ANAGLYPH_YB_GRAY:
942 case ANAGLYPH_YB_HALF:
944 case ANAGLYPH_YB_DUBOIS: {
945 if (s->in.format == INTERLEAVE_COLS_LR ||
946 s->in.format == INTERLEAVE_COLS_RL) {
947 const int d = (s->in.format & 1);
948
949 anaglyph_ic(out->data[0],
950 ileft ->data[0] + s->in_off_left [0] + d * 3,
951 iright->data[0] + s->in_off_right[0] + (!d) * 3,
952 out->linesize[0],
953 ileft->linesize[0] * s->in.row_step,
954 iright->linesize[0] * s->in.row_step,
955 s->out.width, s->out.height,
956 s->ana_matrix[0], s->ana_matrix[1], s->ana_matrix[2]);
957 } else {
958 ThreadData td;
959
960 td.ileft = ileft; td.iright = iright; td.out = out;
962 FFMIN(s->out.height, ff_filter_get_nb_threads(ctx)));
963 }
964 break;
965 }
966 case CHECKERBOARD_RL:
967 case CHECKERBOARD_LR:
968 for (i = 0; i < s->nb_planes; i++) {
969 int x, y;
970
971 for (y = 0; y < s->pheight[i]; y++) {
972 uint8_t *dst = out->data[i] + out->linesize[i] * y;
973 const int d1 = (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL) && (s->in.format & 1) != (s->out.format & 1);
974 const int d2 = (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL) ? !d1 : 0;
975 const int m = 1 + (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL);
976 const int in_y = y / s->in.row_step * s->in.row_step;
977 uint8_t *left = ileft->data[i] + ileft->linesize[i] * in_y + s->in_off_left[i] + d1 * s->pixstep[i];
978 uint8_t *right = iright->data[i] + iright->linesize[i] * in_y + s->in_off_right[i] + d2 * s->pixstep[i];
979 int p, b;
980
981 if (s->out.format == CHECKERBOARD_RL && s->in.format != INTERLEAVE_COLS_LR && s->in.format != INTERLEAVE_COLS_RL)
982 FFSWAP(uint8_t*, left, right);
983 switch (s->pixstep[i]) {
984 case 1:
985 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=2, p++, b+=2) {
986 dst[x ] = (b&1) == (y&1) ? left[p*m] : right[p*m];
987 dst[x+1] = (b&1) != (y&1) ? left[p*m] : right[p*m];
988 }
989 break;
990 case 2:
991 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=4, p+=2, b+=2) {
992 AV_WN16(&dst[x ], (b&1) == (y&1) ? AV_RN16(&left[p*m]) : AV_RN16(&right[p*m]));
993 AV_WN16(&dst[x+2], (b&1) != (y&1) ? AV_RN16(&left[p*m]) : AV_RN16(&right[p*m]));
994 }
995 break;
996 case 3:
997 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=6, p+=3, b+=2) {
998 AV_WB24(&dst[x ], (b&1) == (y&1) ? AV_RB24(&left[p*m]) : AV_RB24(&right[p*m]));
999 AV_WB24(&dst[x+3], (b&1) != (y&1) ? AV_RB24(&left[p*m]) : AV_RB24(&right[p*m]));
1000 }
1001 break;
1002 case 4:
1003 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=8, p+=4, b+=2) {
1004 AV_WN32(&dst[x ], (b&1) == (y&1) ? AV_RN32(&left[p*m]) : AV_RN32(&right[p*m]));
1005 AV_WN32(&dst[x+4], (b&1) != (y&1) ? AV_RN32(&left[p*m]) : AV_RN32(&right[p*m]));
1006 }
1007 break;
1008 case 6:
1009 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=12, p+=6, b+=2) {
1010 AV_WB48(&dst[x ], (b&1) == (y&1) ? AV_RB48(&left[p*m]) : AV_RB48(&right[p*m]));
1011 AV_WB48(&dst[x+6], (b&1) != (y&1) ? AV_RB48(&left[p*m]) : AV_RB48(&right[p*m]));
1012 }
1013 break;
1014 case 8:
1015 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=16, p+=8, b+=2) {
1016 AV_WN64(&dst[x ], (b&1) == (y&1) ? AV_RN64(&left[p*m]) : AV_RN64(&right[p*m]));
1017 AV_WN64(&dst[x+8], (b&1) != (y&1) ? AV_RN64(&left[p*m]) : AV_RN64(&right[p*m]));
1018 }
1019 break;
1020 }
1021 }
1022 }
1023 break;
1024 case INTERLEAVE_COLS_LR:
1025 case INTERLEAVE_COLS_RL:
1026 for (i = 0; i < s->nb_planes; i++) {
1027 const int d = (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL);
1028 const int m = 1 + d;
1029 int x, y;
1030
1031 for (y = 0; y < s->pheight[i]; y++) {
1032 uint8_t *dst = out->data[i] + out->linesize[i] * y;
1033 uint8_t *left = ileft->data[i] + ileft->linesize[i] * y * s->in.row_step + s->in_off_left[i] + d * s->pixstep[i];
1034 uint8_t *right = iright->data[i] + iright->linesize[i] * y * s->in.row_step + s->in_off_right[i];
1035 int p, b;
1036
1037 if (s->out.format == INTERLEAVE_COLS_LR)
1038 FFSWAP(uint8_t*, left, right);
1039
1040 switch (s->pixstep[i]) {
1041 case 1:
1042 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=2, p++, b+=2) {
1043 dst[x ] = b&1 ? left[p*m] : right[p*m];
1044 dst[x+1] = !(b&1) ? left[p*m] : right[p*m];
1045 }
1046 break;
1047 case 2:
1048 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=4, p+=2, b+=2) {
1049 AV_WN16(&dst[x ], b&1 ? AV_RN16(&left[p*m]) : AV_RN16(&right[p*m]));
1050 AV_WN16(&dst[x+2], !(b&1) ? AV_RN16(&left[p*m]) : AV_RN16(&right[p*m]));
1051 }
1052 break;
1053 case 3:
1054 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=6, p+=3, b+=2) {
1055 AV_WB24(&dst[x ], b&1 ? AV_RB24(&left[p*m]) : AV_RB24(&right[p*m]));
1056 AV_WB24(&dst[x+3], !(b&1) ? AV_RB24(&left[p*m]) : AV_RB24(&right[p*m]));
1057 }
1058 break;
1059 case 4:
1060 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=8, p+=4, b+=2) {
1061 AV_WN32(&dst[x ], b&1 ? AV_RN32(&left[p*m]) : AV_RN32(&right[p*m]));
1062 AV_WN32(&dst[x+4], !(b&1) ? AV_RN32(&left[p*m]) : AV_RN32(&right[p*m]));
1063 }
1064 break;
1065 case 6:
1066 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=12, p+=6, b+=2) {
1067 AV_WB48(&dst[x ], b&1 ? AV_RB48(&left[p*m]) : AV_RB48(&right[p*m]));
1068 AV_WB48(&dst[x+6], !(b&1) ? AV_RB48(&left[p*m]) : AV_RB48(&right[p*m]));
1069 }
1070 break;
1071 case 8:
1072 for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=16, p+=8, b+=2) {
1073 AV_WN64(&dst[x ], b&1 ? AV_RN64(&left[p*m]) : AV_RN64(&right[p*m]));
1074 AV_WN64(&dst[x+8], !(b&1) ? AV_RN64(&left[p*m]) : AV_RN64(&right[p*m]));
1075 }
1076 break;
1077 }
1078 }
1079 }
1080 break;
1081 default:
1082 av_assert0(0);
1083 }
1084
1085 if (oright != oleft) {
1086 if (s->out.format == ALTERNATING_LR)
1087 FFSWAP(AVFrame *, oleft, oright);
1088 oright->pts = s->prev->pts * 2;
1089 ff_filter_frame(outlink, oright);
1090 out = oleft;
1091 oleft->pts = s->prev->pts + inpicref->pts;
1092 av_frame_free(&s->prev);
1093 s->prev = inpicref;
1094 } else if (s->in.format == ALTERNATING_LR ||
1095 s->in.format == ALTERNATING_RL) {
1096 out->pts = s->prev->pts / 2;
1097 av_frame_free(&s->prev);
1098 av_frame_free(&inpicref);
1099 } else {
1100 av_frame_free(&s->prev);
1101 av_frame_free(&inpicref);
1102 }
1103 av_assert0(out);
1104 out->sample_aspect_ratio = s->aspect;
1105 return ff_filter_frame(outlink, out);
1106}
1107
1109{
1110 Stereo3DContext *s = ctx->priv;
1111
1112 av_frame_free(&s->prev);
1113}
1114
1116 {
1117 .name = "default",
1118 .type = AVMEDIA_TYPE_VIDEO,
1119 .filter_frame = filter_frame,
1120 },
1121};
1122
1124 {
1125 .name = "default",
1126 .type = AVMEDIA_TYPE_VIDEO,
1127 .config_props = config_output,
1128 },
1129};
1130
1132 .p.name = "stereo3d",
1133 .p.description = NULL_IF_CONFIG_SMALL("Convert video stereoscopic 3D view."),
1134 .p.priv_class = &stereo3d_class,
1135 .p.flags = AVFILTER_FLAG_SLICE_THREADS,
1136 .priv_size = sizeof(Stereo3DContext),
1137 .uninit = uninit,
1141};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:97
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
const FFFilter ff_vf_stereo3d
static FILE * out
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1112
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition avfilter.c:1754
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition avfilter.c:890
Main libavfilter public API header.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:596
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define av_clip_uint8
Definition common.h:106
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition drawutils.c:80
misc drawing utilities
int ret
Definition ffplay.c:391
int ff_set_pixel_formats_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const enum AVPixelFormat *fmts)
Definition formats.c:1225
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:172
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:65
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:602
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition frame.c:486
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition imgutils.c:374
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition imgutils.c:89
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
Definition imgutils.c:35
misc image utilities
#define b
Definition input.c:43
#define AV_WB24(p, d)
#define AV_WN32(p, v)
#define AV_RN64(p)
#define AV_RN32(p)
#define AV_WB48(p, darg)
#define AV_WN64(p, v)
#define AV_WN16(p, v)
#define AV_RN16(p)
#define AV_RB24(x)
#define AV_RB48(x)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
const char * arg
Definition jacosubdec.c:66
#define FILTER_INPUTS(array)
Definition filters.h:279
#define FILTER_OUTPUTS(array)
Definition filters.h:280
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition filters.h:813
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:493
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:256
void ff_stereo3d_init_x86(Stereo3DDSPContext *dsp)
#define av_fallthrough
Definition attributes.h:67
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
const char * desc
Definition libsvtav1.c:83
#define FFSWAP(type, a, b)
Definition macros.h:52
#define FFMIN(a, b)
Definition macros.h:49
AVOptions.
misc parsing utilities
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3524
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3484
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_YUV444P16BE
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition pixfmt.h:133
@ AV_PIX_FMT_YUV420P16BE
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition pixfmt.h:129
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_GBRP10BE
planar GBR 4:4:4 30bpp, big-endian
Definition pixfmt.h:169
@ AV_PIX_FMT_YUVA420P9BE
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
Definition pixfmt.h:175
@ AV_PIX_FMT_YUV420P14LE
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:270
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUVA444P9LE
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition pixfmt.h:180
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition pixfmt.h:265
@ AV_PIX_FMT_YUVA444P10LE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition pixfmt.h:186
@ AV_PIX_FMT_GBRP9LE
planar GBR 4:4:4 27bpp, little-endian
Definition pixfmt.h:168
@ AV_PIX_FMT_YUV444P14BE
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition pixfmt.h:277
@ AV_PIX_FMT_YUVA420P10BE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition pixfmt.h:181
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition pixfmt.h:99
@ AV_PIX_FMT_GBRP12BE
planar GBR 4:4:4 36bpp, big-endian
Definition pixfmt.h:279
@ AV_PIX_FMT_YUVA422P9LE
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
Definition pixfmt.h:178
@ AV_PIX_FMT_YUV420P9LE
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:154
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition pixfmt.h:102
@ AV_PIX_FMT_BGR48BE
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
Definition pixfmt.h:145
@ AV_PIX_FMT_YUVA420P10LE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition pixfmt.h:182
@ AV_PIX_FMT_RGB48BE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
Definition pixfmt.h:109
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition pixfmt.h:101
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition pixfmt.h:108
@ AV_PIX_FMT_YUV422P10BE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition pixfmt.h:157
@ AV_PIX_FMT_YUVA422P10LE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition pixfmt.h:184
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:156
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition pixfmt.h:107
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_RGBA64BE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
Definition pixfmt.h:202
@ AV_PIX_FMT_RGBA64LE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
Definition pixfmt.h:203
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition pixfmt.h:264
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV422P16LE
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition pixfmt.h:130
@ AV_PIX_FMT_YUV420P14BE
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition pixfmt.h:269
@ AV_PIX_FMT_YUV444P14LE
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition pixfmt.h:278
@ AV_PIX_FMT_YUVA444P9BE
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
Definition pixfmt.h:179
@ AV_PIX_FMT_YUV422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition pixfmt.h:272
@ AV_PIX_FMT_YUV444P10BE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition pixfmt.h:161
@ AV_PIX_FMT_YUVA420P9LE
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian
Definition pixfmt.h:176
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_YUV444P9LE
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition pixfmt.h:160
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition pixfmt.h:174
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition pixfmt.h:283
@ AV_PIX_FMT_GBRP12LE
planar GBR 4:4:4 36bpp, little-endian
Definition pixfmt.h:280
@ AV_PIX_FMT_YUVA444P16LE
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition pixfmt.h:192
@ AV_PIX_FMT_YUVA422P10BE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition pixfmt.h:183
@ AV_PIX_FMT_YUVA422P16BE
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition pixfmt.h:189
@ AV_PIX_FMT_BGRA64BE
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
Definition pixfmt.h:204
@ AV_PIX_FMT_GBRP16BE
planar GBR 4:4:4 48bpp, big-endian
Definition pixfmt.h:171
@ AV_PIX_FMT_GBRP9BE
planar GBR 4:4:4 27bpp, big-endian
Definition pixfmt.h:167
@ AV_PIX_FMT_YUVA420P16LE
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition pixfmt.h:188
@ AV_PIX_FMT_RGB48LE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
Definition pixfmt.h:110
@ AV_PIX_FMT_YUVA420P16BE
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition pixfmt.h:187
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:268
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition pixfmt.h:86
@ AV_PIX_FMT_YUV444P9BE
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition pixfmt.h:159
@ AV_PIX_FMT_YUV422P9LE
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition pixfmt.h:164
@ AV_PIX_FMT_YUV422P9BE
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition pixfmt.h:163
@ AV_PIX_FMT_BGR48LE
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
Definition pixfmt.h:146
@ AV_PIX_FMT_GBRP14LE
planar GBR 4:4:4 42bpp, little-endian
Definition pixfmt.h:282
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition pixfmt.h:263
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition pixfmt.h:158
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition pixfmt.h:173
@ AV_PIX_FMT_GBRP10LE
planar GBR 4:4:4 30bpp, little-endian
Definition pixfmt.h:170
@ AV_PIX_FMT_YUV420P12BE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition pixfmt.h:267
@ AV_PIX_FMT_BGRA64LE
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
Definition pixfmt.h:205
@ AV_PIX_FMT_YUV422P16BE
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition pixfmt.h:131
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition pixfmt.h:76
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
@ AV_PIX_FMT_YUV422P14LE
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition pixfmt.h:274
@ AV_PIX_FMT_YUV420P10BE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition pixfmt.h:155
@ AV_PIX_FMT_YUV420P9BE
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
Definition pixfmt.h:153
@ AV_PIX_FMT_YUVA444P10BE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition pixfmt.h:185
@ AV_PIX_FMT_YUV444P16LE
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition pixfmt.h:132
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition pixfmt.h:262
@ AV_PIX_FMT_GBRP14BE
planar GBR 4:4:4 42bpp, big-endian
Definition pixfmt.h:281
@ AV_PIX_FMT_YUV422P14BE
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition pixfmt.h:273
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition pixfmt.h:87
@ AV_PIX_FMT_YUV444P12BE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition pixfmt.h:275
@ AV_PIX_FMT_YUVA444P16BE
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition pixfmt.h:191
@ AV_PIX_FMT_YUVA422P16LE
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition pixfmt.h:190
@ AV_PIX_FMT_GBRP16LE
planar GBR 4:4:4 48bpp, little-endian
Definition pixfmt.h:172
@ AV_PIX_FMT_YUVA422P9BE
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
Definition pixfmt.h:177
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition pixfmt.h:162
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition pixfmt.h:85
@ AV_PIX_FMT_YUV422P12BE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition pixfmt.h:271
@ AV_PIX_FMT_YUV420P16LE
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:128
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition pixfmt.h:276
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:279
Lists of formats / etc.
Definition avfilter.h:120
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition frame.h:581
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:500
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition frame.h:524
AVOption.
Definition opt.h:428
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
StereoComponent in
const int * ana_matrix[3]
StereoComponent out
AVRational aspect
Stereo3DDSPContext dsp
int format
StereoCode.
Definition vf_stereo3d.c:73
Used for passing data between threads.
Definition v210dec.c:35
AVFrame * out
AVFrame * ileft
AVFrame * iright
#define av_log(a,...)
#define src
Definition vp8dsp.c:248
#define height
Definition dsp.h:99
#define width
Definition dsp.h:99
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static void hsub(htype *dst, const htype *src, int bins)
Definition vf_median.c:74
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static enum AVPixelFormat anaglyph_pix_fmts[]
static uint8_t ana_convert(const int *coeff, const uint8_t *left, const uint8_t *right)
static void interleave_cols_to_any(Stereo3DContext *s, int *out_off, int p, AVFrame *in, AVFrame *out, int d)
static void anaglyph_ic(uint8_t *dst, uint8_t *lsrc, uint8_t *rsrc, ptrdiff_t dst_linesize, ptrdiff_t l_linesize, ptrdiff_t r_linesize, int width, int height, const int *ana_matrix_r, const int *ana_matrix_g, const int *ana_matrix_b)
static void anaglyph(uint8_t *dst, uint8_t *lsrc, uint8_t *rsrc, ptrdiff_t dst_linesize, ptrdiff_t l_linesize, ptrdiff_t r_linesize, int width, int height, const int *ana_matrix_r, const int *ana_matrix_g, const int *ana_matrix_b)
static const int ana_coeff[][3][6]
Definition vf_stereo3d.c:81
StereoCode
Definition vf_stereo3d.c:35
@ ANAGLYPH_GM_GRAY
Definition vf_stereo3d.c:40
@ INTERLEAVE_ROWS_RL
Definition vf_stereo3d.c:53
@ INTERLEAVE_COLS_LR
Definition vf_stereo3d.c:66
@ SIDE_BY_SIDE_LR
Definition vf_stereo3d.c:54
@ ANAGLYPH_GM_HALF
Definition vf_stereo3d.c:41
@ ANAGLYPH_YB_DUBOIS
Definition vf_stereo3d.c:47
@ ANAGLYPH_GM_COLOR
Definition vf_stereo3d.c:42
@ ANAGLYPH_RG_GRAY
Definition vf_stereo3d.c:49
@ ANAGLYPH_RC_HALF
Definition vf_stereo3d.c:37
@ ANAGLYPH_RC_GRAY
Definition vf_stereo3d.c:36
@ INTERLEAVE_ROWS_LR
Definition vf_stereo3d.c:52
@ STEREO_CODE_COUNT
Definition vf_stereo3d.c:69
@ ANAGLYPH_YB_COLOR
Definition vf_stereo3d.c:46
@ ANAGLYPH_RB_GRAY
Definition vf_stereo3d.c:48
@ CHECKERBOARD_LR
Definition vf_stereo3d.c:64
@ HDMI
Definition vf_stereo3d.c:68
@ SIDE_BY_SIDE_2_LR
Definition vf_stereo3d.c:56
@ CHECKERBOARD_RL
Definition vf_stereo3d.c:65
@ SIDE_BY_SIDE_RL
Definition vf_stereo3d.c:55
@ INTERLEAVE_COLS_RL
Definition vf_stereo3d.c:67
@ ABOVE_BELOW_LR
Definition vf_stereo3d.c:58
@ ANAGLYPH_YB_GRAY
Definition vf_stereo3d.c:44
@ SIDE_BY_SIDE_2_RL
Definition vf_stereo3d.c:57
@ ANAGLYPH_RC_COLOR
Definition vf_stereo3d.c:38
@ ABOVE_BELOW_2_RL
Definition vf_stereo3d.c:61
@ MONO_L
Definition vf_stereo3d.c:50
@ ANAGLYPH_RC_DUBOIS
Definition vf_stereo3d.c:39
@ MONO_R
Definition vf_stereo3d.c:51
@ ABOVE_BELOW_2_LR
Definition vf_stereo3d.c:60
@ ANAGLYPH_YB_HALF
Definition vf_stereo3d.c:45
@ ALTERNATING_RL
Definition vf_stereo3d.c:63
@ ABOVE_BELOW_RL
Definition vf_stereo3d.c:59
@ ALTERNATING_LR
Definition vf_stereo3d.c:62
@ ANAGLYPH_GM_DUBOIS
Definition vf_stereo3d.c:43
static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
static const AVFilterPad stereo3d_inputs[]
static const AVOption stereo3d_options[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static av_cold void uninit(AVFilterContext *ctx)
#define OFFSET(x)
static int config_output(AVFilterLink *outlink)
static const AVFilterPad stereo3d_outputs[]
static enum AVPixelFormat other_pix_fmts[]
static void copy(const float *p1, float *p2, const int length)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:120