FFmpeg
vf_framepack.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Vittorio Giovara
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * Generate a frame packed video, by combining two views in a single surface.
24  */
25 
26 #include <string.h>
27 
28 #include "libavutil/common.h"
29 #include "libavutil/imgutils.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/pixdesc.h"
32 #include "libavutil/rational.h"
33 #include "libavutil/stereo3d.h"
34 
35 #include "avfilter.h"
36 #include "filters.h"
37 #include "video.h"
38 
39 #define LEFT 0
40 #define RIGHT 1
41 
42 typedef struct FramepackContext {
43  const AVClass *class;
44 
45  int depth;
46  const AVPixFmtDescriptor *pix_desc; ///< agreed pixel format
47 
48  enum AVStereo3DType format; ///< frame pack type output
49 
50  AVFrame *input_views[2]; ///< input frames
52 
53 static const enum AVPixelFormat formats_supported[] = {
78 };
79 
81 {
82  FramepackContext *s = ctx->priv;
83 
84  // clean any leftover frame
85  av_frame_free(&s->input_views[LEFT]);
86  av_frame_free(&s->input_views[RIGHT]);
87 }
88 
89 static int config_output(AVFilterLink *outlink)
90 {
91  AVFilterContext *ctx = outlink->src;
92  FramepackContext *s = outlink->src->priv;
93  FilterLink *leftl = ff_filter_link(ctx->inputs[LEFT]);
94  FilterLink *rightl = ff_filter_link(ctx->inputs[RIGHT]);
95  FilterLink *ol = ff_filter_link(outlink);
96 
97  int width = ctx->inputs[LEFT]->w;
98  int height = ctx->inputs[LEFT]->h;
99  AVRational time_base = ctx->inputs[LEFT]->time_base;
100  AVRational frame_rate = leftl->frame_rate;
101 
102  // check size and fps match on the other input
103  if (width != ctx->inputs[RIGHT]->w ||
104  height != ctx->inputs[RIGHT]->h) {
106  "Left and right sizes differ (%dx%d vs %dx%d).\n",
107  width, height,
108  ctx->inputs[RIGHT]->w, ctx->inputs[RIGHT]->h);
109  return AVERROR_INVALIDDATA;
110  } else if (av_cmp_q(time_base, ctx->inputs[RIGHT]->time_base) != 0) {
112  "Left and right time bases differ (%d/%d vs %d/%d).\n",
113  time_base.num, time_base.den,
114  ctx->inputs[RIGHT]->time_base.num,
115  ctx->inputs[RIGHT]->time_base.den);
116  return AVERROR_INVALIDDATA;
117  } else if (av_cmp_q(frame_rate, rightl->frame_rate) != 0) {
119  "Left and right framerates differ (%d/%d vs %d/%d).\n",
120  frame_rate.num, frame_rate.den,
121  rightl->frame_rate.num,
122  rightl->frame_rate.den);
123  return AVERROR_INVALIDDATA;
124  }
125 
126  s->pix_desc = av_pix_fmt_desc_get(outlink->format);
127  if (!s->pix_desc)
128  return AVERROR_BUG;
129  s->depth = s->pix_desc->comp[0].depth;
130 
131  // modify output properties as needed
132  switch (s->format) {
134  time_base.den *= 2;
135  frame_rate.num *= 2;
136  break;
137  case AV_STEREO3D_COLUMNS:
139  width *= 2;
140  break;
141  case AV_STEREO3D_LINES:
143  height *= 2;
144  break;
145  default:
146  av_log(ctx, AV_LOG_ERROR, "Unknown packing mode.\n");
147  return AVERROR_INVALIDDATA;
148  }
149 
150  outlink->w = width;
151  outlink->h = height;
152  outlink->time_base = time_base;
153  ol->frame_rate = frame_rate;
154 
155  return 0;
156 }
157 
158 static void horizontal_frame_pack(AVFilterLink *outlink,
159  AVFrame *out,
160  int interleaved)
161 {
162  AVFilterContext *ctx = outlink->src;
163  FramepackContext *s = ctx->priv;
164  int i, plane;
165 
166  if (interleaved && s->depth <= 8) {
167  const uint8_t *leftp = s->input_views[LEFT]->data[0];
168  const uint8_t *rightp = s->input_views[RIGHT]->data[0];
169  uint8_t *dstp = out->data[0];
170  int length = out->width / 2;
171  int lines = out->height;
172 
173  for (plane = 0; plane < s->pix_desc->nb_components; plane++) {
174  if (plane == 1 || plane == 2) {
175  length = AV_CEIL_RSHIFT(out->width / 2, s->pix_desc->log2_chroma_w);
176  lines = AV_CEIL_RSHIFT(out->height, s->pix_desc->log2_chroma_h);
177  }
178  for (i = 0; i < lines; i++) {
179  int j;
180  leftp = s->input_views[LEFT]->data[plane] +
181  s->input_views[LEFT]->linesize[plane] * i;
182  rightp = s->input_views[RIGHT]->data[plane] +
183  s->input_views[RIGHT]->linesize[plane] * i;
184  dstp = out->data[plane] + out->linesize[plane] * i;
185  for (j = 0; j < length; j++) {
186  // interpolate chroma as necessary
187  if ((s->pix_desc->log2_chroma_w ||
188  s->pix_desc->log2_chroma_h) &&
189  (plane == 1 || plane == 2)) {
190  *dstp++ = (*leftp + *rightp) / 2;
191  *dstp++ = (*leftp + *rightp) / 2;
192  } else {
193  *dstp++ = *leftp;
194  *dstp++ = *rightp;
195  }
196  leftp += 1;
197  rightp += 1;
198  }
199  }
200  }
201  } else if (interleaved && s->depth > 8) {
202  const uint16_t *leftp = (const uint16_t *)s->input_views[LEFT]->data[0];
203  const uint16_t *rightp = (const uint16_t *)s->input_views[RIGHT]->data[0];
204  uint16_t *dstp = (uint16_t *)out->data[0];
205  int length = out->width / 2;
206  int lines = out->height;
207 
208  for (plane = 0; plane < s->pix_desc->nb_components; plane++) {
209  if (plane == 1 || plane == 2) {
210  length = AV_CEIL_RSHIFT(out->width / 2, s->pix_desc->log2_chroma_w);
211  lines = AV_CEIL_RSHIFT(out->height, s->pix_desc->log2_chroma_h);
212  }
213  for (i = 0; i < lines; i++) {
214  int j;
215  leftp = (const uint16_t *)s->input_views[LEFT]->data[plane] +
216  s->input_views[LEFT]->linesize[plane] * i / 2;
217  rightp = (const uint16_t *)s->input_views[RIGHT]->data[plane] +
218  s->input_views[RIGHT]->linesize[plane] * i / 2;
219  dstp = (uint16_t *)out->data[plane] + out->linesize[plane] * i / 2;
220  for (j = 0; j < length; j++) {
221  // interpolate chroma as necessary
222  if ((s->pix_desc->log2_chroma_w ||
223  s->pix_desc->log2_chroma_h) &&
224  (plane == 1 || plane == 2)) {
225  *dstp++ = (*leftp + *rightp) / 2;
226  *dstp++ = (*leftp + *rightp) / 2;
227  } else {
228  *dstp++ = *leftp;
229  *dstp++ = *rightp;
230  }
231  leftp += 1;
232  rightp += 1;
233  }
234  }
235  }
236  } else {
237  for (i = 0; i < 2; i++) {
238  const AVFrame *const input_view = s->input_views[i];
239  const int psize = 1 + (s->depth > 8);
240  uint8_t *dst[4];
241  int sub_w = psize * input_view->width >> s->pix_desc->log2_chroma_w;
242 
243  dst[0] = out->data[0] + i * input_view->width * psize;
244  dst[1] = out->data[1] + i * sub_w;
245  dst[2] = out->data[2] + i * sub_w;
246 
247  av_image_copy2(dst, out->linesize,
248  input_view->data, input_view->linesize,
249  input_view->format,
250  input_view->width,
251  input_view->height);
252  }
253  }
254 }
255 
256 static void vertical_frame_pack(AVFilterLink *outlink,
257  AVFrame *out,
258  int interleaved)
259 {
260  AVFilterContext *ctx = outlink->src;
261  FramepackContext *s = ctx->priv;
262  int i;
263 
264  for (i = 0; i < 2; i++) {
265  const AVFrame *const input_view = s->input_views[i];
266  uint8_t *dst[4];
267  int linesizes[4];
268  int sub_h = input_view->height >> s->pix_desc->log2_chroma_h;
269 
270  dst[0] = out->data[0] + i * out->linesize[0] *
271  (interleaved + input_view->height * (1 - interleaved));
272  dst[1] = out->data[1] + i * out->linesize[1] *
273  (interleaved + sub_h * (1 - interleaved));
274  dst[2] = out->data[2] + i * out->linesize[2] *
275  (interleaved + sub_h * (1 - interleaved));
276 
277  linesizes[0] = out->linesize[0] +
278  interleaved * out->linesize[0];
279  linesizes[1] = out->linesize[1] +
280  interleaved * out->linesize[1];
281  linesizes[2] = out->linesize[2] +
282  interleaved * out->linesize[2];
283 
284  av_image_copy2(dst, linesizes,
285  input_view->data, input_view->linesize,
286  input_view->format,
287  input_view->width,
288  input_view->height);
289  }
290 }
291 
293  AVFrame *dst)
294 {
295  AVFilterContext *ctx = outlink->src;
296  FramepackContext *s = ctx->priv;
297  switch (s->format) {
299  horizontal_frame_pack(outlink, dst, 0);
300  break;
301  case AV_STEREO3D_COLUMNS:
302  horizontal_frame_pack(outlink, dst, 1);
303  break;
305  vertical_frame_pack(outlink, dst, 0);
306  break;
307  case AV_STEREO3D_LINES:
308  vertical_frame_pack(outlink, dst, 1);
309  break;
310  }
311 }
312 
314 {
315  FramepackContext *s = ctx->priv;
316  AVFilterLink *outlink = ctx->outputs[0];
317  FilterLink *l = ff_filter_link(outlink);
318  AVStereo3D *stereo;
319  int ret, i;
320 
321  if (!(s->input_views[0] && s->input_views[1]))
322  return 0;
323  if (s->format == AV_STEREO3D_FRAMESEQUENCE) {
324  int64_t pts = s->input_views[0]->pts;
325 
326  for (i = 0; i < 2; i++) {
327  // set correct timestamps
328  if (pts != AV_NOPTS_VALUE) {
329  s->input_views[i]->pts = i == 0 ? pts * 2 : pts * 2 + av_rescale_q(1, av_inv_q(l->frame_rate), outlink->time_base);
330  s->input_views[i]->duration = av_rescale_q(1, av_inv_q(l->frame_rate), outlink->time_base);
331  }
332 
333  // set stereo3d side data
334  stereo = av_stereo3d_create_side_data(s->input_views[i]);
335  if (!stereo)
336  return AVERROR(ENOMEM);
337  stereo->type = s->format;
338  stereo->view = i == LEFT ? AV_STEREO3D_VIEW_LEFT
340 
341  // filter the frame and immediately relinquish its pointer
342  ret = ff_filter_frame(outlink, s->input_views[i]);
343  s->input_views[i] = NULL;
344  if (ret < 0)
345  return ret;
346  }
347  return ret;
348  } else {
349  AVFrame *dst = ff_get_video_buffer(outlink, outlink->w, outlink->h);
350  if (!dst)
351  return AVERROR(ENOMEM);
352 
353  spatial_frame_pack(outlink, dst);
354 
355  // get any property from the original frame
356  ret = av_frame_copy_props(dst, s->input_views[LEFT]);
357  if (ret < 0) {
358  av_frame_free(&dst);
359  return ret;
360  }
361 
362  for (i = 0; i < 2; i++)
363  av_frame_free(&s->input_views[i]);
364 
365  // set stereo3d side data
367  if (!stereo) {
368  av_frame_free(&dst);
369  return AVERROR(ENOMEM);
370  }
371  stereo->type = s->format;
372 
373  return ff_filter_frame(outlink, dst);
374  }
375 }
376 
378 {
379  AVFilterLink *outlink = ctx->outputs[0];
380  FramepackContext *s = ctx->priv;
381  int ret;
382 
384 
385  if (!s->input_views[0]) {
386  ret = ff_inlink_consume_frame(ctx->inputs[0], &s->input_views[0]);
387  if (ret < 0)
388  return ret;
389  }
390 
391  if (!s->input_views[1]) {
392  ret = ff_inlink_consume_frame(ctx->inputs[1], &s->input_views[1]);
393  if (ret < 0)
394  return ret;
395  }
396 
397  if (s->input_views[0] && s->input_views[1])
398  return try_push_frame(ctx);
399 
400  FF_FILTER_FORWARD_STATUS(ctx->inputs[0], outlink);
401  FF_FILTER_FORWARD_STATUS(ctx->inputs[1], outlink);
402 
403  if (ff_outlink_frame_wanted(ctx->outputs[0]) &&
404  !s->input_views[0]) {
405  ff_inlink_request_frame(ctx->inputs[0]);
406  return 0;
407  }
408 
409  if (ff_outlink_frame_wanted(ctx->outputs[0]) &&
410  !s->input_views[1]) {
411  ff_inlink_request_frame(ctx->inputs[1]);
412  return 0;
413  }
414 
415  return FFERROR_NOT_READY;
416 }
417 
418 #define OFFSET(x) offsetof(FramepackContext, x)
419 #define VF AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
420 static const AVOption framepack_options[] = {
421  { "format", "Frame pack output format", OFFSET(format), AV_OPT_TYPE_INT,
422  { .i64 = AV_STEREO3D_SIDEBYSIDE }, 0, INT_MAX, .flags = VF, .unit = "format" },
423  { "sbs", "Views are packed next to each other", 0, AV_OPT_TYPE_CONST,
424  { .i64 = AV_STEREO3D_SIDEBYSIDE }, INT_MIN, INT_MAX, .flags = VF, .unit = "format" },
425  { "tab", "Views are packed on top of each other", 0, AV_OPT_TYPE_CONST,
426  { .i64 = AV_STEREO3D_TOPBOTTOM }, INT_MIN, INT_MAX, .flags = VF, .unit = "format" },
427  { "frameseq", "Views are one after the other", 0, AV_OPT_TYPE_CONST,
428  { .i64 = AV_STEREO3D_FRAMESEQUENCE }, INT_MIN, INT_MAX, .flags = VF, .unit = "format" },
429  { "lines", "Views are interleaved by lines", 0, AV_OPT_TYPE_CONST,
430  { .i64 = AV_STEREO3D_LINES }, INT_MIN, INT_MAX, .flags = VF, .unit = "format" },
431  { "columns", "Views are interleaved by columns", 0, AV_OPT_TYPE_CONST,
432  { .i64 = AV_STEREO3D_COLUMNS }, INT_MIN, INT_MAX, .flags = VF, .unit = "format" },
433  { NULL },
434 };
435 
436 AVFILTER_DEFINE_CLASS(framepack);
437 
438 static const AVFilterPad framepack_inputs[] = {
439  {
440  .name = "left",
441  .type = AVMEDIA_TYPE_VIDEO,
442  },
443  {
444  .name = "right",
445  .type = AVMEDIA_TYPE_VIDEO,
446  },
447 };
448 
449 static const AVFilterPad framepack_outputs[] = {
450  {
451  .name = "packed",
452  .type = AVMEDIA_TYPE_VIDEO,
453  .config_props = config_output,
454  },
455 };
456 
458  .name = "framepack",
459  .description = NULL_IF_CONFIG_SMALL("Generate a frame packed stereoscopic video."),
460  .priv_size = sizeof(FramepackContext),
461  .priv_class = &framepack_class,
465  .activate = activate,
466  .uninit = framepack_uninit,
467 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:116
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:546
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:525
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
AV_STEREO3D_VIEW_LEFT
@ AV_STEREO3D_VIEW_LEFT
Frame contains only the left view.
Definition: stereo3d.h:158
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
out
FILE * out
Definition: movenc.c:55
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1062
spatial_frame_pack
static av_always_inline void spatial_frame_pack(AVFilterLink *outlink, AVFrame *dst)
Definition: vf_framepack.c:292
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3170
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
rational.h
int64_t
long long int64_t
Definition: coverity.c:34
framepack_outputs
static const AVFilterPad framepack_outputs[]
Definition: vf_framepack.c:449
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:162
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:538
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
pixdesc.h
AVFrame::width
int width
Definition: frame.h:461
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:545
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:540
AVOption
AVOption.
Definition: opt.h:429
RIGHT
#define RIGHT
Definition: vf_framepack.c:40
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:502
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
try_push_frame
static int try_push_frame(AVFilterContext *ctx)
Definition: vf_framepack.c:313
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
video.h
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:541
AV_STEREO3D_VIEW_RIGHT
@ AV_STEREO3D_VIEW_RIGHT
Frame contains only the right view.
Definition: stereo3d.h:163
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:482
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:410
AV_STEREO3D_SIDEBYSIDE
@ AV_STEREO3D_SIDEBYSIDE
Views are next to each other.
Definition: stereo3d.h:64
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1491
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:537
FramepackContext
Definition: vf_framepack.c:42
FF_FILTER_FORWARD_STATUS_BACK_ALL
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
Definition: filters.h:447
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:520
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:472
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:518
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:547
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:500
OFFSET
#define OFFSET(x)
Definition: vf_framepack.c:418
pts
static int64_t pts
Definition: transcode_aac.c:644
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:486
FramepackContext::depth
int depth
Definition: vf_framepack.c:45
AVRational::num
int num
Numerator.
Definition: rational.h:59
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:505
AV_PIX_FMT_YUVJ411P
@ 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_STEREO3D_FRAMESEQUENCE
@ AV_STEREO3D_FRAMESEQUENCE
Views are alternated temporally.
Definition: stereo3d.h:89
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
vertical_frame_pack
static void vertical_frame_pack(AVFilterLink *outlink, AVFrame *out, int interleaved)
Definition: vf_framepack.c:256
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:514
AV_PIX_FMT_YUVJ422P
@ 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_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:522
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1594
AV_STEREO3D_LINES
@ AV_STEREO3D_LINES
Views are packed per line, as if interlaced.
Definition: stereo3d.h:126
stereo3d.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:523
AV_PIX_FMT_YUVA420P
@ 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_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:515
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
filters.h
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:544
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:499
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:513
ctx
AVFormatContext * ctx
Definition: movenc.c:49
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(framepack)
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:485
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
AV_PIX_FMT_YUVJ444P
@ 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_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:483
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:521
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:713
FramepackContext::input_views
AVFrame * input_views[2]
input frames
Definition: vf_framepack.c:50
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
horizontal_frame_pack
static void horizontal_frame_pack(AVFilterLink *outlink, AVFrame *out, int interleaved)
Definition: vf_framepack.c:158
AV_PIX_FMT_YUVJ420P
@ 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_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:504
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:503
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:517
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:197
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
height
#define height
Definition: dsp.h:85
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
ff_vf_framepack
const AVFilter ff_vf_framepack
Definition: vf_framepack.c:457
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:507
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
FramepackContext::format
enum AVStereo3DType format
frame pack type output
Definition: vf_framepack.c:48
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:509
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:476
activate
static int activate(AVFilterContext *ctx)
Definition: vf_framepack.c:377
LEFT
#define LEFT
Definition: vf_framepack.c:39
AV_PIX_FMT_YUVA444P
@ 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_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:542
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_framepack.c:89
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:519
AV_STEREO3D_TOPBOTTOM
@ AV_STEREO3D_TOPBOTTOM
Views are on top of each other.
Definition: stereo3d.h:76
common.h
av_always_inline
#define av_always_inline
Definition: attributes.h:49
AV_PIX_FMT_YUVJ440P
@ 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_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
framepack_uninit
static av_cold void framepack_uninit(AVFilterContext *ctx)
Definition: vf_framepack.c:80
VF
#define VF
Definition: vf_framepack.c:419
framepack_options
static const AVOption framepack_options[]
Definition: vf_framepack.c:420
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:501
av_cmp_q
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
AVFilter
Filter definition.
Definition: avfilter.h:201
ret
ret
Definition: filter_design.txt:187
AV_STEREO3D_COLUMNS
@ AV_STEREO3D_COLUMNS
Views are packed per column.
Definition: stereo3d.h:138
AVStereo3D::type
enum AVStereo3DType type
How views are packed within the video.
Definition: stereo3d.h:207
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:539
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:506
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:511
AVFrame::height
int height
Definition: frame.h:461
FramepackContext::pix_desc
const AVPixFmtDescriptor * pix_desc
agreed pixel format
Definition: vf_framepack.c:46
av_image_copy2
static void av_image_copy2(uint8_t *const dst_data[4], const int dst_linesizes[4], uint8_t *const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Wrapper around av_image_copy() to workaround the limitation that the conversion from uint8_t * const ...
Definition: imgutils.h:184
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:543
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
av_stereo3d_create_side_data
AVStereo3D * av_stereo3d_create_side_data(AVFrame *frame)
Allocate a complete AVFrameSideData and add it to the frame.
Definition: stereo3d.c:54
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
AVStereo3D::view
enum AVStereo3DView view
Determines which views are packed.
Definition: stereo3d.h:217
FF_FILTER_FORWARD_STATUS
FF_FILTER_FORWARD_STATUS(inlink, outlink)
framepack_inputs
static const AVFilterPad framepack_inputs[]
Definition: vf_framepack.c:438
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
imgutils.h
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
AVFrame::linesize
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:434
AVStereo3DType
AVStereo3DType
List of possible 3D Types.
Definition: stereo3d.h:48
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:508
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:512
AVStereo3D
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
Definition: stereo3d.h:203
width
#define width
Definition: dsp.h:85
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:484
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
AV_PIX_FMT_YUVA422P
@ 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_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:510
formats_supported
static enum AVPixelFormat formats_supported[]
Definition: vf_framepack.c:53