FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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"
24 #include "libavutil/intreadwrite.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/parseutils.h"
27 #include "libavutil/pixdesc.h"
28 #include "avfilter.h"
29 #include "drawutils.h"
30 #include "formats.h"
31 #include "internal.h"
32 #include "video.h"
33 #include "stereo3d.h"
34 
35 enum StereoCode {
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 
72 typedef struct StereoComponent {
73  int format; ///< StereoCode
74  int width, height;
78  int row_step;
80 
81 static 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  {{29891, 32800, 11559, -2849, -5763, -102},
104  {-2627, -2479, -1033, 24804, 48080, -1209},
105  { -997, -1350, -358, -4729, -7403, 80373}},
106  [ANAGLYPH_GM_GRAY] =
107  {{ 0, 0, 0, 19595, 38470, 7471},
108  {19595, 38470, 7471, 0, 0, 0},
109  { 0, 0, 0, 19595, 38470, 7471}},
110  [ANAGLYPH_GM_HALF] =
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}},
122  [ANAGLYPH_YB_GRAY] =
123  {{ 0, 0, 0, 19595, 38470, 7471},
124  { 0, 0, 0, 19595, 38470, 7471},
125  {19595, 38470, 7471, 0, 0, 0}},
126  [ANAGLYPH_YB_HALF] =
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  {{65535,-12650,18451, -987, -7590, -1049},
136  {-1604, 56032, 4196, 370, 3826, -1049},
137  {-2345,-10676, 1358, 5801, 11416, 56217}},
138 };
139 
140 typedef struct Stereo3DContext {
141  const AVClass *class;
143  int width, height;
144  const int *ana_matrix[3];
146  int linesize[4];
147  int pheight[4];
148  int hsub, vsub;
149  int pixstep[4];
151  int blanks;
155 
156 #define OFFSET(x) offsetof(Stereo3DContext, x)
157 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
158 
159 static const AVOption stereo3d_options[] = {
160  { "in", "set input format", OFFSET(in.format), AV_OPT_TYPE_INT, {.i64=SIDE_BY_SIDE_LR}, INTERLEAVE_ROWS_LR, STEREO_CODE_COUNT-1, FLAGS, "in"},
161  { "ab2l", "above below half height left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_LR}, 0, 0, FLAGS, "in" },
162  { "ab2r", "above below half height right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_RL}, 0, 0, FLAGS, "in" },
163  { "abl", "above below left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_LR}, 0, 0, FLAGS, "in" },
164  { "abr", "above below right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_RL}, 0, 0, FLAGS, "in" },
165  { "al", "alternating frames left first", 0, AV_OPT_TYPE_CONST, {.i64=ALTERNATING_LR}, 0, 0, FLAGS, "in" },
166  { "ar", "alternating frames right first", 0, AV_OPT_TYPE_CONST, {.i64=ALTERNATING_RL}, 0, 0, FLAGS, "in" },
167  { "sbs2l", "side by side half width left first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_2_LR}, 0, 0, FLAGS, "in" },
168  { "sbs2r", "side by side half width right first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_2_RL}, 0, 0, FLAGS, "in" },
169  { "sbsl", "side by side left first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_LR}, 0, 0, FLAGS, "in" },
170  { "sbsr", "side by side right first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_RL}, 0, 0, FLAGS, "in" },
171  { "irl", "interleave rows left first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_ROWS_LR}, 0, 0, FLAGS, "in" },
172  { "irr", "interleave rows right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_ROWS_RL}, 0, 0, FLAGS, "in" },
173  { "icl", "interleave columns left first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_LR}, 0, 0, FLAGS, "in" },
174  { "icr", "interleave columns right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_RL}, 0, 0, FLAGS, "in" },
175  { "out", "set output format", OFFSET(out.format), AV_OPT_TYPE_INT, {.i64=ANAGLYPH_RC_DUBOIS}, 0, STEREO_CODE_COUNT-1, FLAGS, "out"},
176  { "ab2l", "above below half height left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_LR}, 0, 0, FLAGS, "out" },
177  { "ab2r", "above below half height right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_RL}, 0, 0, FLAGS, "out" },
178  { "abl", "above below left first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_LR}, 0, 0, FLAGS, "out" },
179  { "abr", "above below right first", 0, AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_RL}, 0, 0, FLAGS, "out" },
180  { "agmc", "anaglyph green magenta color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_GM_COLOR}, 0, 0, FLAGS, "out" },
181  { "agmd", "anaglyph green magenta dubois", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_GM_DUBOIS}, 0, 0, FLAGS, "out" },
182  { "agmg", "anaglyph green magenta gray", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_GM_GRAY}, 0, 0, FLAGS, "out" },
183  { "agmh", "anaglyph green magenta half color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_GM_HALF}, 0, 0, FLAGS, "out" },
184  { "al", "alternating frames left first", 0, AV_OPT_TYPE_CONST, {.i64=ALTERNATING_LR}, 0, 0, FLAGS, "out" },
185  { "ar", "alternating frames right first", 0, AV_OPT_TYPE_CONST, {.i64=ALTERNATING_RL}, 0, 0, FLAGS, "out" },
186  { "arbg", "anaglyph red blue gray", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RB_GRAY}, 0, 0, FLAGS, "out" },
187  { "arcc", "anaglyph red cyan color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RC_COLOR}, 0, 0, FLAGS, "out" },
188  { "arcd", "anaglyph red cyan dubois", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RC_DUBOIS}, 0, 0, FLAGS, "out" },
189  { "arcg", "anaglyph red cyan gray", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RC_GRAY}, 0, 0, FLAGS, "out" },
190  { "arch", "anaglyph red cyan half color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RC_HALF}, 0, 0, FLAGS, "out" },
191  { "argg", "anaglyph red green gray", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_RG_GRAY}, 0, 0, FLAGS, "out" },
192  { "aybc", "anaglyph yellow blue color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_YB_COLOR}, 0, 0, FLAGS, "out" },
193  { "aybd", "anaglyph yellow blue dubois", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_YB_DUBOIS}, 0, 0, FLAGS, "out" },
194  { "aybg", "anaglyph yellow blue gray", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_YB_GRAY}, 0, 0, FLAGS, "out" },
195  { "aybh", "anaglyph yellow blue half color", 0, AV_OPT_TYPE_CONST, {.i64=ANAGLYPH_YB_HALF}, 0, 0, FLAGS, "out" },
196  { "irl", "interleave rows left first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_ROWS_LR}, 0, 0, FLAGS, "out" },
197  { "irr", "interleave rows right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_ROWS_RL}, 0, 0, FLAGS, "out" },
198  { "ml", "mono left", 0, AV_OPT_TYPE_CONST, {.i64=MONO_L}, 0, 0, FLAGS, "out" },
199  { "mr", "mono right", 0, AV_OPT_TYPE_CONST, {.i64=MONO_R}, 0, 0, FLAGS, "out" },
200  { "sbs2l", "side by side half width left first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_2_LR}, 0, 0, FLAGS, "out" },
201  { "sbs2r", "side by side half width right first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_2_RL}, 0, 0, FLAGS, "out" },
202  { "sbsl", "side by side left first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_LR}, 0, 0, FLAGS, "out" },
203  { "sbsr", "side by side right first", 0, AV_OPT_TYPE_CONST, {.i64=SIDE_BY_SIDE_RL}, 0, 0, FLAGS, "out" },
204  { "chl", "checkerboard left first", 0, AV_OPT_TYPE_CONST, {.i64=CHECKERBOARD_LR}, 0, 0, FLAGS, "out" },
205  { "chr", "checkerboard right first", 0, AV_OPT_TYPE_CONST, {.i64=CHECKERBOARD_RL}, 0, 0, FLAGS, "out" },
206  { "icl", "interleave columns left first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_LR}, 0, 0, FLAGS, "out" },
207  { "icr", "interleave columns right first", 0, AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_RL}, 0, 0, FLAGS, "out" },
208  { "hdmi", "HDMI frame pack", 0, AV_OPT_TYPE_CONST, {.i64=HDMI}, 0, 0, FLAGS, "out" },
209  { NULL }
210 };
211 
212 AVFILTER_DEFINE_CLASS(stereo3d);
213 
214 static const enum AVPixelFormat anaglyph_pix_fmts[] = {
217 };
218 
219 static const enum AVPixelFormat other_pix_fmts[] = {
271 };
272 
274 {
275  Stereo3DContext *s = ctx->priv;
276  const enum AVPixelFormat *pix_fmts;
277  AVFilterFormats *fmts_list;
278 
279  switch (s->out.format) {
280  case ANAGLYPH_GM_COLOR:
281  case ANAGLYPH_GM_DUBOIS:
282  case ANAGLYPH_GM_GRAY:
283  case ANAGLYPH_GM_HALF:
284  case ANAGLYPH_RB_GRAY:
285  case ANAGLYPH_RC_COLOR:
286  case ANAGLYPH_RC_DUBOIS:
287  case ANAGLYPH_RC_GRAY:
288  case ANAGLYPH_RC_HALF:
289  case ANAGLYPH_RG_GRAY:
290  case ANAGLYPH_YB_COLOR:
291  case ANAGLYPH_YB_DUBOIS:
292  case ANAGLYPH_YB_GRAY:
293  case ANAGLYPH_YB_HALF:
294  pix_fmts = anaglyph_pix_fmts;
295  break;
296  default:
297  pix_fmts = other_pix_fmts;
298  }
299 
300  fmts_list = ff_make_format_list(pix_fmts);
301  if (!fmts_list)
302  return AVERROR(ENOMEM);
303  return ff_set_common_formats(ctx, fmts_list);
304 }
305 
306 static inline uint8_t ana_convert(const int *coeff, const uint8_t *left, const uint8_t *right)
307 {
308  int sum;
309 
310  sum = coeff[0] * left[0] + coeff[3] * right[0]; //red in
311  sum += coeff[1] * left[1] + coeff[4] * right[1]; //green in
312  sum += coeff[2] * left[2] + coeff[5] * right[2]; //blue in
313 
314  return av_clip_uint8(sum >> 16);
315 }
316 
317 static void anaglyph_ic(uint8_t *dst, uint8_t *lsrc, uint8_t *rsrc,
318  ptrdiff_t dst_linesize, ptrdiff_t l_linesize, ptrdiff_t r_linesize,
319  int width, int height,
320  const int *ana_matrix_r, const int *ana_matrix_g, const int *ana_matrix_b)
321 {
322  int x, y, o;
323 
324  for (y = 0; y < height; y++) {
325  for (o = 0, x = 0; x < width; x++, o+= 3) {
326  dst[o ] = ana_convert(ana_matrix_r, lsrc + o * 2, rsrc + o * 2);
327  dst[o + 1] = ana_convert(ana_matrix_g, lsrc + o * 2, rsrc + o * 2);
328  dst[o + 2] = ana_convert(ana_matrix_b, lsrc + o * 2, rsrc + o * 2);
329  }
330 
331  dst += dst_linesize;
332  lsrc += l_linesize;
333  rsrc += r_linesize;
334  }
335 }
336 
337 static void anaglyph(uint8_t *dst, uint8_t *lsrc, uint8_t *rsrc,
338  ptrdiff_t dst_linesize, ptrdiff_t l_linesize, ptrdiff_t r_linesize,
339  int width, int height,
340  const int *ana_matrix_r, const int *ana_matrix_g, const int *ana_matrix_b)
341 {
342  int x, y, o;
343 
344  for (y = 0; y < height; y++) {
345  for (o = 0, x = 0; x < width; x++, o+= 3) {
346  dst[o ] = ana_convert(ana_matrix_r, lsrc + o, rsrc + o);
347  dst[o + 1] = ana_convert(ana_matrix_g, lsrc + o, rsrc + o);
348  dst[o + 2] = ana_convert(ana_matrix_b, lsrc + o, rsrc + o);
349  }
350 
351  dst += dst_linesize;
352  lsrc += l_linesize;
353  rsrc += r_linesize;
354  }
355 }
356 
357 static int config_output(AVFilterLink *outlink)
358 {
359  AVFilterContext *ctx = outlink->src;
360  AVFilterLink *inlink = ctx->inputs[0];
361  Stereo3DContext *s = ctx->priv;
362  AVRational aspect = inlink->sample_aspect_ratio;
363  AVRational fps = inlink->frame_rate;
364  AVRational tb = inlink->time_base;
366  int ret;
367 
368  switch (s->in.format) {
369  case INTERLEAVE_COLS_LR:
370  case INTERLEAVE_COLS_RL:
371  case SIDE_BY_SIDE_2_LR:
372  case SIDE_BY_SIDE_LR:
373  case SIDE_BY_SIDE_2_RL:
374  case SIDE_BY_SIDE_RL:
375  if (inlink->w & 1) {
376  av_log(ctx, AV_LOG_ERROR, "width must be even\n");
377  return AVERROR_INVALIDDATA;
378  }
379  break;
380  case INTERLEAVE_ROWS_LR:
381  case INTERLEAVE_ROWS_RL:
382  case ABOVE_BELOW_2_LR:
383  case ABOVE_BELOW_LR:
384  case ABOVE_BELOW_2_RL:
385  case ABOVE_BELOW_RL:
386  if (inlink->h & 1) {
387  av_log(ctx, AV_LOG_ERROR, "height must be even\n");
388  return AVERROR_INVALIDDATA;
389  }
390  break;
391  }
392 
393  s->in.width =
394  s->width = inlink->w;
395  s->in.height =
396  s->height = inlink->h;
397  s->in.off_lstep =
398  s->in.off_rstep =
399  s->in.off_left =
400  s->in.off_right =
401  s->in.row_left =
402  s->in.row_right = 0;
403  s->in.row_step = 1;
404 
405  switch (s->in.format) {
406  case SIDE_BY_SIDE_2_LR:
407  aspect.num *= 2;
408  case SIDE_BY_SIDE_LR:
409  s->width = inlink->w / 2;
410  s->in.off_right = s->width;
411  break;
412  case SIDE_BY_SIDE_2_RL:
413  aspect.num *= 2;
414  case SIDE_BY_SIDE_RL:
415  s->width = inlink->w / 2;
416  s->in.off_left = s->width;
417  break;
418  case ABOVE_BELOW_2_LR:
419  aspect.den *= 2;
420  case ABOVE_BELOW_LR:
421  s->in.row_right =
422  s->height = inlink->h / 2;
423  break;
424  case ABOVE_BELOW_2_RL:
425  aspect.den *= 2;
426  case ABOVE_BELOW_RL:
427  s->in.row_left =
428  s->height = inlink->h / 2;
429  break;
430  case ALTERNATING_RL:
431  case ALTERNATING_LR:
432  fps.den *= 2;
433  tb.num *= 2;
434  break;
435  case INTERLEAVE_COLS_RL:
436  case INTERLEAVE_COLS_LR:
437  s->width = inlink->w / 2;
438  break;
439  case INTERLEAVE_ROWS_LR:
440  case INTERLEAVE_ROWS_RL:
441  s->in.row_step = 2;
442  if (s->in.format == INTERLEAVE_ROWS_RL)
443  s->in.off_lstep = 1;
444  else
445  s->in.off_rstep = 1;
446  if (s->out.format != CHECKERBOARD_LR &&
447  s->out.format != CHECKERBOARD_RL)
448  s->height = inlink->h / 2;
449  break;
450  default:
451  av_log(ctx, AV_LOG_ERROR, "input format %d is not supported\n", s->in.format);
452  return AVERROR(EINVAL);
453  }
454 
455  s->out.width = s->width;
456  s->out.height = s->height;
457  s->out.off_lstep =
458  s->out.off_rstep =
459  s->out.off_left =
460  s->out.off_right =
461  s->out.row_left =
462  s->out.row_right = 0;
463  s->out.row_step = 1;
464 
465  switch (s->out.format) {
466  case ANAGLYPH_RB_GRAY:
467  case ANAGLYPH_RG_GRAY:
468  case ANAGLYPH_RC_GRAY:
469  case ANAGLYPH_RC_HALF:
470  case ANAGLYPH_RC_COLOR:
471  case ANAGLYPH_RC_DUBOIS:
472  case ANAGLYPH_GM_GRAY:
473  case ANAGLYPH_GM_HALF:
474  case ANAGLYPH_GM_COLOR:
475  case ANAGLYPH_GM_DUBOIS:
476  case ANAGLYPH_YB_GRAY:
477  case ANAGLYPH_YB_HALF:
478  case ANAGLYPH_YB_COLOR:
479  case ANAGLYPH_YB_DUBOIS: {
480  uint8_t rgba_map[4];
481 
482  ff_fill_rgba_map(rgba_map, outlink->format);
483  s->ana_matrix[rgba_map[0]] = &ana_coeff[s->out.format][0][0];
484  s->ana_matrix[rgba_map[1]] = &ana_coeff[s->out.format][1][0];
485  s->ana_matrix[rgba_map[2]] = &ana_coeff[s->out.format][2][0];
486  break;
487  }
488  case SIDE_BY_SIDE_2_LR:
489  aspect.den *= 2;
490  case SIDE_BY_SIDE_LR:
491  s->out.width = s->width * 2;
492  s->out.off_right = s->width;
493  break;
494  case SIDE_BY_SIDE_2_RL:
495  aspect.den *= 2;
496  case SIDE_BY_SIDE_RL:
497  s->out.width = s->width * 2;
498  s->out.off_left = s->width;
499  break;
500  case ABOVE_BELOW_2_LR:
501  aspect.num *= 2;
502  case ABOVE_BELOW_LR:
503  s->out.height = s->height * 2;
504  s->out.row_right = s->height;
505  break;
506  case HDMI:
507  if (s->height != 720 && s->height != 1080) {
508  av_log(ctx, AV_LOG_ERROR, "Only 720 and 1080 height supported\n");
509  return AVERROR(EINVAL);
510  }
511 
512  s->blanks = s->height / 24;
513  s->out.height = s->height * 2 + s->blanks;
514  s->out.row_right = s->height + s->blanks;
515  break;
516  case ABOVE_BELOW_2_RL:
517  aspect.num *= 2;
518  case ABOVE_BELOW_RL:
519  s->out.height = s->height * 2;
520  s->out.row_left = s->height;
521  break;
522  case INTERLEAVE_ROWS_LR:
523  s->in.row_step = 1 + (s->in.format == INTERLEAVE_ROWS_RL);
524  s->out.row_step = 2;
525  s->out.height = s->height * 2;
526  s->out.off_rstep = 1;
527  break;
528  case INTERLEAVE_ROWS_RL:
529  s->in.row_step = 1 + (s->in.format == INTERLEAVE_ROWS_LR);
530  s->out.row_step = 2;
531  s->out.height = s->height * 2;
532  s->out.off_lstep = 1;
533  break;
534  case MONO_R:
535  if (s->in.format != INTERLEAVE_COLS_LR) {
536  s->in.off_left = s->in.off_right;
537  s->in.row_left = s->in.row_right;
538  }
539  if (s->in.format == INTERLEAVE_ROWS_LR)
540  FFSWAP(int, s->in.off_lstep, s->in.off_rstep);
541  break;
542  case MONO_L:
543  if (s->in.format == INTERLEAVE_ROWS_RL)
544  FFSWAP(int, s->in.off_lstep, s->in.off_rstep);
545  break;
546  case ALTERNATING_RL:
547  case ALTERNATING_LR:
548  fps.num *= 2;
549  tb.den *= 2;
550  break;
551  case CHECKERBOARD_LR:
552  case CHECKERBOARD_RL:
553  s->out.width = s->width * 2;
554  break;
555  case INTERLEAVE_COLS_LR:
556  case INTERLEAVE_COLS_RL:
557  s->out.width = s->width * 2;
558  break;
559  default:
560  av_log(ctx, AV_LOG_ERROR, "output format %d is not supported\n", s->out.format);
561  return AVERROR(EINVAL);
562  }
563 
565  if ((s->in.format & 1) != (s->out.format & 1)) {
566  FFSWAP(int, s->in.row_left, s->in.row_right);
567  FFSWAP(int, s->in.off_lstep, s->in.off_rstep);
568  FFSWAP(int, s->in.off_left, s->in.off_right);
569  FFSWAP(int, s->out.row_left, s->out.row_right);
570  FFSWAP(int, s->out.off_lstep, s->out.off_rstep);
571  FFSWAP(int, s->out.off_left, s->out.off_right);
572  }
573  }
574 
575  outlink->w = s->out.width;
576  outlink->h = s->out.height;
577  outlink->frame_rate = fps;
578  outlink->time_base = tb;
579  outlink->sample_aspect_ratio = aspect;
580 
581  if ((ret = av_image_fill_linesizes(s->linesize, outlink->format, s->width)) < 0)
582  return ret;
585  s->pheight[1] = s->pheight[2] = AV_CEIL_RSHIFT(s->height, desc->log2_chroma_h);
586  s->pheight[0] = s->pheight[3] = s->height;
587  s->hsub = desc->log2_chroma_w;
588  s->vsub = desc->log2_chroma_h;
589 
590  s->dsp.anaglyph = anaglyph;
591  if (ARCH_X86)
593 
594  return 0;
595 }
596 
597 typedef struct ThreadData {
599  AVFrame *out;
600 } ThreadData;
601 
602 static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
603 {
604  Stereo3DContext *s = ctx->priv;
605  ThreadData *td = arg;
606  AVFrame *ileft = td->ileft;
607  AVFrame *iright = td->iright;
608  AVFrame *out = td->out;
609  int height = s->out.height;
610  int start = (height * jobnr ) / nb_jobs;
611  int end = (height * (jobnr+1)) / nb_jobs;
612  const int **ana_matrix = s->ana_matrix;
613 
614  s->dsp.anaglyph(out->data[0] + out->linesize[0] * start,
615  ileft ->data[0] + s->in_off_left [0] + ileft->linesize[0] * start * s->in.row_step,
616  iright->data[0] + s->in_off_right[0] + iright->linesize[0] * start * s->in.row_step,
617  out->linesize[0],
618  ileft->linesize[0] * s->in.row_step,
619  iright->linesize[0] * s->in.row_step,
620  s->out.width, end - start,
621  ana_matrix[0], ana_matrix[1], ana_matrix[2]);
622 
623  return 0;
624 }
625 
626 static void interleave_cols_to_any(Stereo3DContext *s, int *out_off, int p, AVFrame *in, AVFrame *out, int d)
627 {
628  int y, x;
629 
630  for (y = 0; y < s->pheight[p]; y++) {
631  const uint8_t *src = (const uint8_t*)in->data[p] + y * in->linesize[p] + d * s->pixstep[p];
632  uint8_t *dst = out->data[p] + out_off[p] + y * out->linesize[p] * s->out.row_step;
633 
634  switch (s->pixstep[p]) {
635  case 1:
636  for (x = 0; x < s->linesize[p]; x++)
637  dst[x] = src[x * 2];
638  break;
639  case 2:
640  for (x = 0; x < s->linesize[p]; x+=2)
641  AV_WN16(&dst[x], AV_RN16(&src[x * 2]));
642  break;
643  case 3:
644  for (x = 0; x < s->linesize[p]; x+=3)
645  AV_WB24(&dst[x], AV_RB24(&src[x * 2]));
646  break;
647  case 4:
648  for (x = 0; x < s->linesize[p]; x+=4)
649  AV_WN32(&dst[x], AV_RN32(&src[x * 2]));
650  break;
651  case 6:
652  for (x = 0; x < s->linesize[p]; x+=6)
653  AV_WB48(&dst[x], AV_RB48(&src[x * 2]));
654  break;
655  case 8:
656  for (x = 0; x < s->linesize[p]; x+=8)
657  AV_WN64(&dst[x], AV_RN64(&src[x * 2]));
658  break;
659  }
660  }
661 }
662 
663 static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
664 {
665  AVFilterContext *ctx = inlink->dst;
666  Stereo3DContext *s = ctx->priv;
667  AVFilterLink *outlink = ctx->outputs[0];
668  AVFrame *out, *oleft, *oright, *ileft, *iright;
669  int out_off_left[4], out_off_right[4];
670  int i, ret;
671 
672  if (s->in.format == s->out.format)
673  return ff_filter_frame(outlink, inpicref);
674 
675  switch (s->out.format) {
676  case ALTERNATING_LR:
677  case ALTERNATING_RL:
678  if (!s->prev) {
679  s->prev = inpicref;
680  return 0;
681  }
682  break;
683  };
684 
685  switch (s->in.format) {
686  case ALTERNATING_LR:
687  case ALTERNATING_RL:
688  if (!s->prev) {
689  s->prev = inpicref;
690  return 0;
691  }
692  ileft = s->prev;
693  iright = inpicref;
694  if (s->in.format == ALTERNATING_RL)
695  FFSWAP(AVFrame *, ileft, iright);
696  break;
697  default:
698  ileft = iright = inpicref;
699  };
700 
701  if ((s->out.format == ALTERNATING_LR ||
702  s->out.format == ALTERNATING_RL) &&
703  (s->in.format == SIDE_BY_SIDE_LR ||
704  s->in.format == SIDE_BY_SIDE_RL ||
705  s->in.format == SIDE_BY_SIDE_2_LR ||
706  s->in.format == SIDE_BY_SIDE_2_RL ||
707  s->in.format == ABOVE_BELOW_LR ||
708  s->in.format == ABOVE_BELOW_RL ||
709  s->in.format == ABOVE_BELOW_2_LR ||
710  s->in.format == ABOVE_BELOW_2_RL ||
711  s->in.format == INTERLEAVE_ROWS_LR ||
712  s->in.format == INTERLEAVE_ROWS_RL)) {
713  oright = av_frame_clone(s->prev);
714  oleft = av_frame_clone(s->prev);
715  if (!oright || !oleft) {
716  av_frame_free(&oright);
717  av_frame_free(&oleft);
718  av_frame_free(&s->prev);
719  av_frame_free(&inpicref);
720  return AVERROR(ENOMEM);
721  }
722  } else if ((s->out.format == MONO_L ||
723  s->out.format == MONO_R) &&
724  (s->in.format == SIDE_BY_SIDE_LR ||
725  s->in.format == SIDE_BY_SIDE_RL ||
726  s->in.format == SIDE_BY_SIDE_2_LR ||
727  s->in.format == SIDE_BY_SIDE_2_RL ||
728  s->in.format == ABOVE_BELOW_LR ||
729  s->in.format == ABOVE_BELOW_RL ||
730  s->in.format == ABOVE_BELOW_2_LR ||
731  s->in.format == ABOVE_BELOW_2_RL ||
732  s->in.format == INTERLEAVE_ROWS_LR ||
733  s->in.format == INTERLEAVE_ROWS_RL)) {
734  out = oleft = oright = av_frame_clone(inpicref);
735  if (!out) {
736  av_frame_free(&s->prev);
737  av_frame_free(&inpicref);
738  return AVERROR(ENOMEM);
739  }
740  } else if ((s->out.format == MONO_L && s->in.format == ALTERNATING_LR) ||
741  (s->out.format == MONO_R && s->in.format == ALTERNATING_RL)) {
742  s->prev->pts /= 2;
743  ret = ff_filter_frame(outlink, s->prev);
744  av_frame_free(&inpicref);
745  s->prev = NULL;
746  return ret;
747  } else if ((s->out.format == MONO_L && s->in.format == ALTERNATING_RL) ||
748  (s->out.format == MONO_R && s->in.format == ALTERNATING_LR)) {
749  av_frame_free(&s->prev);
750  inpicref->pts /= 2;
751  return ff_filter_frame(outlink, inpicref);
752  } else if ((s->out.format == ALTERNATING_LR && s->in.format == ALTERNATING_RL) ||
753  (s->out.format == ALTERNATING_RL && s->in.format == ALTERNATING_LR)) {
754  FFSWAP(int64_t, s->prev->pts, inpicref->pts);
755  ff_filter_frame(outlink, inpicref);
756  ret = ff_filter_frame(outlink, s->prev);
757  s->prev = NULL;
758  return ret;
759  } else {
760  out = oleft = oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);
761  if (!out) {
762  av_frame_free(&s->prev);
763  av_frame_free(&inpicref);
764  return AVERROR(ENOMEM);
765  }
766  av_frame_copy_props(out, inpicref);
767 
768  if (s->out.format == ALTERNATING_LR ||
769  s->out.format == ALTERNATING_RL) {
770  oright = ff_get_video_buffer(outlink, outlink->w, outlink->h);
771  if (!oright) {
772  av_frame_free(&oleft);
773  av_frame_free(&s->prev);
774  av_frame_free(&inpicref);
775  return AVERROR(ENOMEM);
776  }
777  av_frame_copy_props(oright, s->prev);
778  }
779  }
780 
781  for (i = 0; i < 4; i++) {
782  int hsub = i == 1 || i == 2 ? s->hsub : 0;
783  int vsub = i == 1 || i == 2 ? s->vsub : 0;
784  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);
785  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);
786  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);
787  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);
788  }
789 
790  switch (s->out.format) {
791  case ALTERNATING_LR:
792  case ALTERNATING_RL:
793  switch (s->in.format) {
794  case INTERLEAVE_ROWS_LR:
795  case INTERLEAVE_ROWS_RL:
796  for (i = 0; i < s->nb_planes; i++) {
797  oleft->linesize[i] *= 2;
798  oright->linesize[i] *= 2;
799  }
800  case ABOVE_BELOW_LR:
801  case ABOVE_BELOW_RL:
802  case ABOVE_BELOW_2_LR:
803  case ABOVE_BELOW_2_RL:
804  case SIDE_BY_SIDE_LR:
805  case SIDE_BY_SIDE_RL:
806  case SIDE_BY_SIDE_2_LR:
807  case SIDE_BY_SIDE_2_RL:
808  oleft->width = outlink->w;
809  oright->width = outlink->w;
810  oleft->height = outlink->h;
811  oright->height = outlink->h;
812 
813  for (i = 0; i < s->nb_planes; i++) {
814  oleft->data[i] += s->in_off_left[i];
815  oright->data[i] += s->in_off_right[i];
816  }
817  break;
818  default:
819  goto copy;
820  break;
821  }
822  break;
823  case HDMI:
824  for (i = 0; i < s->nb_planes; i++) {
825  int j, h = s->height >> ((i == 1 || i == 2) ? s->vsub : 0);
826  int b = (s->blanks) >> ((i == 1 || i == 2) ? s->vsub : 0);
827 
828  for (j = h; j < h + b; j++)
829  memset(oleft->data[i] + j * s->linesize[i], 0, s->linesize[i]);
830  }
831  case SIDE_BY_SIDE_LR:
832  case SIDE_BY_SIDE_RL:
833  case SIDE_BY_SIDE_2_LR:
834  case SIDE_BY_SIDE_2_RL:
835  case ABOVE_BELOW_LR:
836  case ABOVE_BELOW_RL:
837  case ABOVE_BELOW_2_LR:
838  case ABOVE_BELOW_2_RL:
839  case INTERLEAVE_ROWS_LR:
840  case INTERLEAVE_ROWS_RL:
841 copy:
842  if (s->in.format == INTERLEAVE_COLS_LR ||
843  s->in.format == INTERLEAVE_COLS_RL) {
844  for (i = 0; i < s->nb_planes; i++) {
845  int d = (s->in.format & 1) != (s->out.format & 1);
846 
847  interleave_cols_to_any(s, out_off_left, i, ileft, oleft, d);
848  interleave_cols_to_any(s, out_off_right, i, iright, oright, !d);
849  }
850  } else {
851  for (i = 0; i < s->nb_planes; i++) {
852  av_image_copy_plane(oleft->data[i] + out_off_left[i],
853  oleft->linesize[i] * s->out.row_step,
854  ileft->data[i] + s->in_off_left[i],
855  ileft->linesize[i] * s->in.row_step,
856  s->linesize[i], s->pheight[i]);
857  av_image_copy_plane(oright->data[i] + out_off_right[i],
858  oright->linesize[i] * s->out.row_step,
859  iright->data[i] + s->in_off_right[i],
860  iright->linesize[i] * s->in.row_step,
861  s->linesize[i], s->pheight[i]);
862  }
863  }
864  break;
865  case MONO_L:
866  iright = ileft;
867  case MONO_R:
868  switch (s->in.format) {
869  case INTERLEAVE_ROWS_LR:
870  case INTERLEAVE_ROWS_RL:
871  for (i = 0; i < s->nb_planes; i++) {
872  out->linesize[i] *= 2;
873  }
874  case ABOVE_BELOW_LR:
875  case ABOVE_BELOW_RL:
876  case ABOVE_BELOW_2_LR:
877  case ABOVE_BELOW_2_RL:
878  case SIDE_BY_SIDE_LR:
879  case SIDE_BY_SIDE_RL:
880  case SIDE_BY_SIDE_2_LR:
881  case SIDE_BY_SIDE_2_RL:
882  out->width = outlink->w;
883  out->height = outlink->h;
884 
885  for (i = 0; i < s->nb_planes; i++) {
886  out->data[i] += s->in_off_left[i];
887  }
888  break;
889  case INTERLEAVE_COLS_LR:
890  case INTERLEAVE_COLS_RL:
891  for (i = 0; i < s->nb_planes; i++) {
892  const int d = (s->in.format & 1) != (s->out.format & 1);
893 
894  interleave_cols_to_any(s, out_off_right, i, iright, out, d);
895  }
896  break;
897  default:
898  for (i = 0; i < s->nb_planes; i++) {
899  av_image_copy_plane(out->data[i], out->linesize[i],
900  iright->data[i] + s->in_off_left[i],
901  iright->linesize[i] * s->in.row_step,
902  s->linesize[i], s->pheight[i]);
903  }
904  break;
905  }
906  break;
907  case ANAGLYPH_RB_GRAY:
908  case ANAGLYPH_RG_GRAY:
909  case ANAGLYPH_RC_GRAY:
910  case ANAGLYPH_RC_HALF:
911  case ANAGLYPH_RC_COLOR:
912  case ANAGLYPH_RC_DUBOIS:
913  case ANAGLYPH_GM_GRAY:
914  case ANAGLYPH_GM_HALF:
915  case ANAGLYPH_GM_COLOR:
916  case ANAGLYPH_GM_DUBOIS:
917  case ANAGLYPH_YB_GRAY:
918  case ANAGLYPH_YB_HALF:
919  case ANAGLYPH_YB_COLOR:
920  case ANAGLYPH_YB_DUBOIS: {
921  if (s->in.format == INTERLEAVE_COLS_LR ||
922  s->in.format == INTERLEAVE_COLS_RL) {
923  const int d = (s->in.format & 1);
924 
925  anaglyph_ic(out->data[0],
926  ileft ->data[0] + s->in_off_left [0] + d * 3,
927  iright->data[0] + s->in_off_right[0] + (!d) * 3,
928  out->linesize[0],
929  ileft->linesize[0] * s->in.row_step,
930  iright->linesize[0] * s->in.row_step,
931  s->out.width, s->out.height,
932  s->ana_matrix[0], s->ana_matrix[1], s->ana_matrix[2]);
933  } else {
934  ThreadData td;
935 
936  td.ileft = ileft; td.iright = iright; td.out = out;
937  ctx->internal->execute(ctx, filter_slice, &td, NULL,
939  }
940  break;
941  }
942  case CHECKERBOARD_RL:
943  case CHECKERBOARD_LR:
944  for (i = 0; i < s->nb_planes; i++) {
945  int x, y;
946 
947  for (y = 0; y < s->pheight[i]; y++) {
948  uint8_t *dst = out->data[i] + out->linesize[i] * y;
949  const int d1 = (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL) && (s->in.format & 1) != (s->out.format & 1);
950  const int d2 = (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL) ? !d1 : 0;
951  const int m = 1 + (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL);
952  uint8_t *left = ileft->data[i] + ileft->linesize[i] * y + s->in_off_left[i] + d1 * s->pixstep[i];
953  uint8_t *right = iright->data[i] + iright->linesize[i] * y + s->in_off_right[i] + d2 * s->pixstep[i];
954  int p, b;
955 
957  FFSWAP(uint8_t*, left, right);
958  switch (s->pixstep[i]) {
959  case 1:
960  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=2, p++, b+=2) {
961  dst[x ] = (b&1) == (y&1) ? left[p*m] : right[p*m];
962  dst[x+1] = (b&1) != (y&1) ? left[p*m] : right[p*m];
963  }
964  break;
965  case 2:
966  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=4, p+=2, b+=2) {
967  AV_WN16(&dst[x ], (b&1) == (y&1) ? AV_RN16(&left[p*m]) : AV_RN16(&right[p*m]));
968  AV_WN16(&dst[x+2], (b&1) != (y&1) ? AV_RN16(&left[p*m]) : AV_RN16(&right[p*m]));
969  }
970  break;
971  case 3:
972  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=6, p+=3, b+=2) {
973  AV_WB24(&dst[x ], (b&1) == (y&1) ? AV_RB24(&left[p*m]) : AV_RB24(&right[p*m]));
974  AV_WB24(&dst[x+3], (b&1) != (y&1) ? AV_RB24(&left[p*m]) : AV_RB24(&right[p*m]));
975  }
976  break;
977  case 4:
978  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=8, p+=4, b+=2) {
979  AV_WN32(&dst[x ], (b&1) == (y&1) ? AV_RN32(&left[p*m]) : AV_RN32(&right[p*m]));
980  AV_WN32(&dst[x+4], (b&1) != (y&1) ? AV_RN32(&left[p*m]) : AV_RN32(&right[p*m]));
981  }
982  break;
983  case 6:
984  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=12, p+=6, b+=2) {
985  AV_WB48(&dst[x ], (b&1) == (y&1) ? AV_RB48(&left[p*m]) : AV_RB48(&right[p*m]));
986  AV_WB48(&dst[x+6], (b&1) != (y&1) ? AV_RB48(&left[p*m]) : AV_RB48(&right[p*m]));
987  }
988  break;
989  case 8:
990  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=16, p+=8, b+=2) {
991  AV_WN64(&dst[x ], (b&1) == (y&1) ? AV_RN64(&left[p*m]) : AV_RN64(&right[p*m]));
992  AV_WN64(&dst[x+8], (b&1) != (y&1) ? AV_RN64(&left[p*m]) : AV_RN64(&right[p*m]));
993  }
994  break;
995  }
996  }
997  }
998  break;
999  case INTERLEAVE_COLS_LR:
1000  case INTERLEAVE_COLS_RL:
1001  for (i = 0; i < s->nb_planes; i++) {
1002  const int d = (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL);
1003  const int m = 1 + d;
1004  int x, y;
1005 
1006  for (y = 0; y < s->pheight[i]; y++) {
1007  uint8_t *dst = out->data[i] + out->linesize[i] * y;
1008  uint8_t *left = ileft->data[i] + ileft->linesize[i] * y * s->in.row_step + s->in_off_left[i] + d * s->pixstep[i];
1009  uint8_t *right = iright->data[i] + iright->linesize[i] * y * s->in.row_step + s->in_off_right[i];
1010  int p, b;
1011 
1012  if (s->out.format == INTERLEAVE_COLS_LR)
1013  FFSWAP(uint8_t*, left, right);
1014 
1015  switch (s->pixstep[i]) {
1016  case 1:
1017  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=2, p++, b+=2) {
1018  dst[x ] = b&1 ? left[p*m] : right[p*m];
1019  dst[x+1] = !(b&1) ? left[p*m] : right[p*m];
1020  }
1021  break;
1022  case 2:
1023  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=4, p+=2, b+=2) {
1024  AV_WN16(&dst[x ], b&1 ? AV_RN16(&left[p*m]) : AV_RN16(&right[p*m]));
1025  AV_WN16(&dst[x+2], !(b&1) ? AV_RN16(&left[p*m]) : AV_RN16(&right[p*m]));
1026  }
1027  break;
1028  case 3:
1029  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=6, p+=3, b+=2) {
1030  AV_WB24(&dst[x ], b&1 ? AV_RB24(&left[p*m]) : AV_RB24(&right[p*m]));
1031  AV_WB24(&dst[x+3], !(b&1) ? AV_RB24(&left[p*m]) : AV_RB24(&right[p*m]));
1032  }
1033  break;
1034  case 4:
1035  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=8, p+=4, b+=2) {
1036  AV_WN32(&dst[x ], b&1 ? AV_RN32(&left[p*m]) : AV_RN32(&right[p*m]));
1037  AV_WN32(&dst[x+4], !(b&1) ? AV_RN32(&left[p*m]) : AV_RN32(&right[p*m]));
1038  }
1039  break;
1040  case 6:
1041  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=12, p+=6, b+=2) {
1042  AV_WB48(&dst[x ], b&1 ? AV_RB48(&left[p*m]) : AV_RB48(&right[p*m]));
1043  AV_WB48(&dst[x+6], !(b&1) ? AV_RB48(&left[p*m]) : AV_RB48(&right[p*m]));
1044  }
1045  break;
1046  case 8:
1047  for (x = 0, b = 0, p = 0; x < s->linesize[i] * 2; x+=16, p+=8, b+=2) {
1048  AV_WN64(&dst[x ], b&1 ? AV_RN64(&left[p*m]) : AV_RN64(&right[p*m]));
1049  AV_WN64(&dst[x+8], !(b&1) ? AV_RN64(&left[p*m]) : AV_RN64(&right[p*m]));
1050  }
1051  break;
1052  }
1053  }
1054  }
1055  break;
1056  default:
1057  av_assert0(0);
1058  }
1059 
1060  if (oright != oleft) {
1061  if (s->out.format == ALTERNATING_LR)
1062  FFSWAP(AVFrame *, oleft, oright);
1063  oright->pts = s->prev->pts * 2;
1064  ff_filter_frame(outlink, oright);
1065  out = oleft;
1066  oleft->pts = s->prev->pts + inpicref->pts;
1067  av_frame_free(&s->prev);
1068  s->prev = inpicref;
1069  } else if (s->in.format == ALTERNATING_LR ||
1070  s->in.format == ALTERNATING_RL) {
1071  out->pts = s->prev->pts / 2;
1072  av_frame_free(&s->prev);
1073  av_frame_free(&inpicref);
1074  } else {
1075  av_frame_free(&s->prev);
1076  av_frame_free(&inpicref);
1077  }
1078  return ff_filter_frame(outlink, out);
1079 }
1080 
1082 {
1083  Stereo3DContext *s = ctx->priv;
1084 
1085  av_frame_free(&s->prev);
1086 }
1087 
1088 static const AVFilterPad stereo3d_inputs[] = {
1089  {
1090  .name = "default",
1091  .type = AVMEDIA_TYPE_VIDEO,
1092  .filter_frame = filter_frame,
1093  },
1094  { NULL }
1095 };
1096 
1097 static const AVFilterPad stereo3d_outputs[] = {
1098  {
1099  .name = "default",
1100  .type = AVMEDIA_TYPE_VIDEO,
1101  .config_props = config_output,
1102  },
1103  { NULL }
1104 };
1105 
1107  .name = "stereo3d",
1108  .description = NULL_IF_CONFIG_SMALL("Convert video stereoscopic 3D view."),
1109  .priv_size = sizeof(Stereo3DContext),
1110  .uninit = uninit,
1112  .inputs = stereo3d_inputs,
1113  .outputs = stereo3d_outputs,
1114  .priv_class = &stereo3d_class,
1116 };
#define NULL
Definition: coverity.c:32
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:177
#define AV_RB48(x)
Definition: intreadwrite.h:472
const char * s
Definition: avisynth_c.h:768
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:266
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AVFrame * out
Definition: af_sofalizer.c:585
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:259
static void copy(const float *p1, float *p2, const int length)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2266
This structure describes decoded (raw) audio or video data.
Definition: frame.h:184
StereoComponent in
Definition: vf_stereo3d.c:142
AVOption.
Definition: opt.h:245
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:263
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:170
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:220
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
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)
Definition: vf_stereo3d.c:337
misc image utilities
static void interleave_cols_to_any(Stereo3DContext *s, int *out_off, int p, AVFrame *in, AVFrame *out, int d)
Definition: vf_stereo3d.c:626
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2306
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:64
int format
StereoCode.
Definition: vf_stereo3d.c:73
const char * desc
Definition: nvenc.c:101
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:173
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:264
int in_off_right[4]
Definition: vf_stereo3d.c:152
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:180
int num
Numerator.
Definition: rational.h:59
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:219
const char * b
Definition: vf_curves.c:113
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:201
planar GBR 4:4:4 36bpp, little-endian
Definition: pixfmt.h:269
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
Definition: pixfmt.h:167
AVFILTER_DEFINE_CLASS(stereo3d)
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:253
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:76
planar GBR 4:4:4 36bpp, big-endian
Definition: pixfmt.h:268
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:139
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
static uint8_t ana_convert(const int *coeff, const uint8_t *left, const uint8_t *right)
Definition: vf_stereo3d.c:306
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
AVFilter ff_vf_stereo3d
Definition: vf_stereo3d.c:1106
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:34
const char * name
Pad name.
Definition: internal.h:59
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
Definition: pixfmt.h:191
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:315
AVFrame * iright
Definition: vf_stereo3d.c:598
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:202
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1189
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:102
StereoComponent out
Definition: vf_stereo3d.c:142
uint8_t
#define av_cold
Definition: attributes.h:82
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:252
AVOptions.
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:111
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
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:217
#define AV_WB48(p, darg)
Definition: intreadwrite.h:481
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:265
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:268
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:95
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:203
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)
Definition: vf_stereo3d.c:317
AVFrame * ileft
Definition: vf_stereo3d.c:598
static const AVFilterPad stereo3d_outputs[]
Definition: vf_stereo3d.c:1097
#define height
planar GBR 4:4:4 48bpp, big-endian
Definition: pixfmt.h:186
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:101
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:75
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:206
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:53
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:168
planar GBR 4:4:4 27bpp, big-endian
Definition: pixfmt.h:182
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:176
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_stereo3d.c:1081
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:188
int width
width and height of the video frame
Definition: frame.h:236
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:568
#define td
Definition: regdef.h:70
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:144
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:158
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:96
void * priv
private data for use by the filter
Definition: avfilter.h:322
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
Definition: pixfmt.h:194
const char * arg
Definition: jacosubdec.c:66
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:172
simple assert() macros that are a bit more flexible than ISO C assert().
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:262
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:142
AVFrame * prev
Definition: vf_stereo3d.c:150
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition: pixfmt.h:195
#define FLAGS
Definition: vf_stereo3d.c:157
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:93
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:160
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:94
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:196
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
#define OFFSET(x)
Definition: vf_stereo3d.c:156
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:786
#define FFMIN(a, b)
Definition: common.h:96
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:74
#define width
static const AVFilterPad stereo3d_inputs[]
Definition: vf_stereo3d.c:1088
AVFormatContext * ctx
Definition: movenc.c:48
#define AV_WB24(p, d)
Definition: intreadwrite.h:450
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:200
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
Definition: pixfmt.h:192
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_stereo3d.c:602
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:65
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:257
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:169
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
#define src
Definition: vp9dsp.c:530
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:178
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:159
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:480
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
static enum AVPixelFormat other_pix_fmts[]
Definition: vf_stereo3d.c:219
void ff_stereo3d_init_x86(Stereo3DDSPContext *dsp)
static const AVOption stereo3d_options[]
Definition: vf_stereo3d.c:159
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:140
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
misc drawing utilities
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
Definition: bytestream.h:87
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:215
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:189
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
#define AV_RN16(p)
Definition: intreadwrite.h:360
planar GBR 4:4:4 30bpp, big-endian
Definition: pixfmt.h:184
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:204
static enum AVPixelFormat anaglyph_pix_fmts[]
Definition: vf_stereo3d.c:214
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
planar GBR 4:4:4 42bpp, little-endian
Definition: pixfmt.h:271
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:205
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
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:88
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:207
Rational number (pair of numerator and denominator).
Definition: rational.h:58
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:258
static int config_output(AVFilterLink *outlink)
Definition: vf_stereo3d.c:357
const int * ana_matrix[3]
Definition: vf_stereo3d.c:144
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:254
const char * name
Filter name.
Definition: avfilter.h:148
planar GBR 4:4:4 42bpp, big-endian
Definition: pixfmt.h:270
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
Definition: pixfmt.h:190
#define AV_RN32(p)
Definition: intreadwrite.h:364
misc parsing utilities
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:319
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
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)
Definition: stereo3d.h:28
static int query_formats(AVFilterContext *ctx)
Definition: vf_stereo3d.c:273
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:199
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:347
static int flags
Definition: cpu.c:47
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:198
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:174
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:143
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:261
#define AV_WN32(p, v)
Definition: intreadwrite.h:376
planar GBR 4:4:4 27bpp, little-endian
Definition: pixfmt.h:183
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:110
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:141
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:76
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
int den
Denominator.
Definition: rational.h:60
avfilter_execute_func * execute
Definition: internal.h:153
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:197
static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
Definition: vf_stereo3d.c:663
static const int ana_coeff[][3][6]
Definition: vf_stereo3d.c:81
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:267
A list of supported formats for one end of a filter link.
Definition: formats.h:64
#define AV_RN64(p)
Definition: intreadwrite.h:368
static const double coeff[2][5]
Definition: vf_owdenoise.c:72
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:272
An instance of a filter.
Definition: avfilter.h:307
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:198
int in_off_left[4]
Definition: vf_stereo3d.c:152
int height
Definition: frame.h:236
FILE * out
Definition: movenc.c:54
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:100
void INT64 start
Definition: avisynth_c.h:690
#define AV_WN16(p, v)
Definition: intreadwrite.h:372
planar GBR 4:4:4 48bpp, little-endian
Definition: pixfmt.h:187
#define FFSWAP(type, a, b)
Definition: common.h:99
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:287
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
Definition: pixfmt.h:193
internal API functions
Stereo3DDSPContext dsp
Definition: vf_stereo3d.c:153
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:251
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
StereoCode
Definition: vf_stereo3d.c:35
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:256
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:175
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:260
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:589
planar GBR 4:4:4 30bpp, little-endian
Definition: pixfmt.h:185
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:218
#define tb
Definition: regdef.h:68
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
#define AV_WN64(p, v)
Definition: intreadwrite.h:380
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:171