FFmpeg
vf_framerate.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Mark Himsley
3  *
4  * get_scene_score() Copyright (c) 2011 Stefano Sabatini
5  * taken from libavfilter/vf_select.c
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 /**
25  * @file
26  * filter for upsampling or downsampling a progressive source
27  */
28 
29 #define DEBUG
30 
31 #include "libavutil/avassert.h"
32 #include "libavutil/imgutils.h"
33 #include "libavutil/internal.h"
34 #include "libavutil/opt.h"
35 #include "libavutil/pixdesc.h"
36 
37 #include "avfilter.h"
38 #include "internal.h"
39 #include "video.h"
40 #include "filters.h"
41 #include "framerate.h"
42 #include "scene_sad.h"
43 
44 #define OFFSET(x) offsetof(FrameRateContext, x)
45 #define V AV_OPT_FLAG_VIDEO_PARAM
46 #define F AV_OPT_FLAG_FILTERING_PARAM
47 #define FRAMERATE_FLAG_SCD 01
48 
49 static const AVOption framerate_options[] = {
50  {"fps", "required output frames per second rate", OFFSET(dest_frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="50"}, 0, INT_MAX, V|F },
51 
52  {"interp_start", "point to start linear interpolation", OFFSET(interp_start), AV_OPT_TYPE_INT, {.i64=15}, 0, 255, V|F },
53  {"interp_end", "point to end linear interpolation", OFFSET(interp_end), AV_OPT_TYPE_INT, {.i64=240}, 0, 255, V|F },
54  {"scene", "scene change level", OFFSET(scene_score), AV_OPT_TYPE_DOUBLE, {.dbl=8.2}, 0, INT_MAX, V|F },
55 
56  {"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=1}, 0, INT_MAX, V|F, "flags" },
57  {"scene_change_detect", "enable scene change detection", 0, AV_OPT_TYPE_CONST, {.i64=FRAMERATE_FLAG_SCD}, INT_MIN, INT_MAX, V|F, "flags" },
58  {"scd", "enable scene change detection", 0, AV_OPT_TYPE_CONST, {.i64=FRAMERATE_FLAG_SCD}, INT_MIN, INT_MAX, V|F, "flags" },
59 
60  {NULL}
61 };
62 
64 
65 static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next)
66 {
67  FrameRateContext *s = ctx->priv;
68  double ret = 0;
69 
70  ff_dlog(ctx, "get_scene_score()\n");
71 
72  if (crnt->height == next->height &&
73  crnt->width == next->width) {
74  uint64_t sad;
75  double mafd, diff;
76 
77  ff_dlog(ctx, "get_scene_score() process\n");
78  s->sad(crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->width, crnt->height, &sad);
79  emms_c();
80  mafd = (double)sad * 100.0 / (crnt->width * crnt->height) / (1 << s->bitdepth);
81  diff = fabs(mafd - s->prev_mafd);
82  ret = av_clipf(FFMIN(mafd, diff), 0, 100.0);
83  s->prev_mafd = mafd;
84  }
85  ff_dlog(ctx, "get_scene_score() result is:%f\n", ret);
86  return ret;
87 }
88 
89 typedef struct ThreadData {
92 } ThreadData;
93 
94 static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
95 {
96  FrameRateContext *s = ctx->priv;
97  ThreadData *td = arg;
98  uint16_t src1_factor = td->src1_factor;
99  uint16_t src2_factor = td->src2_factor;
100  int plane;
101 
102  for (plane = 0; plane < 4 && td->copy_src1->data[plane] && td->copy_src2->data[plane]; plane++) {
103  int cpy_line_width = s->line_size[plane];
104  uint8_t *cpy_src1_data = td->copy_src1->data[plane];
105  int cpy_src1_line_size = td->copy_src1->linesize[plane];
106  uint8_t *cpy_src2_data = td->copy_src2->data[plane];
107  int cpy_src2_line_size = td->copy_src2->linesize[plane];
108  int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);
109  uint8_t *cpy_dst_data = s->work->data[plane];
110  int cpy_dst_line_size = s->work->linesize[plane];
111  const int start = (cpy_src_h * job ) / nb_jobs;
112  const int end = (cpy_src_h * (job+1)) / nb_jobs;
113  cpy_src1_data += start * cpy_src1_line_size;
114  cpy_src2_data += start * cpy_src2_line_size;
115  cpy_dst_data += start * cpy_dst_line_size;
116 
117  s->blend(cpy_src1_data, cpy_src1_line_size,
118  cpy_src2_data, cpy_src2_line_size,
119  cpy_dst_data, cpy_dst_line_size,
120  cpy_line_width, end - start,
121  src1_factor, src2_factor, s->blend_factor_max >> 1);
122  }
123 
124  return 0;
125 }
126 
128 {
129  FrameRateContext *s = ctx->priv;
130  AVFilterLink *outlink = ctx->outputs[0];
131  double interpolate_scene_score = 0;
132 
133  if ((s->flags & FRAMERATE_FLAG_SCD)) {
134  if (s->score >= 0.0)
135  interpolate_scene_score = s->score;
136  else
137  interpolate_scene_score = s->score = get_scene_score(ctx, s->f0, s->f1);
138  ff_dlog(ctx, "blend_frames() interpolate scene score:%f\n", interpolate_scene_score);
139  }
140  // decide if the shot-change detection allows us to blend two frames
141  if (interpolate_scene_score < s->scene_score) {
142  ThreadData td;
143  td.copy_src1 = s->f0;
144  td.copy_src2 = s->f1;
147 
148  // get work-space for output frame
149  s->work = ff_get_video_buffer(outlink, outlink->w, outlink->h);
150  if (!s->work)
151  return AVERROR(ENOMEM);
152 
153  av_frame_copy_props(s->work, s->f0);
154 
155  ff_dlog(ctx, "blend_frames() INTERPOLATE to create work frame\n");
156  ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(FFMAX(1, outlink->h >> 2), ff_filter_get_nb_threads(ctx)));
157  return 1;
158  }
159  return 0;
160 }
161 
163 {
164  FrameRateContext *s = ctx->priv;
165  int64_t work_pts;
166  int64_t interpolate, interpolate8;
167  int ret;
168 
169  if (!s->f1)
170  return 0;
171  if (!s->f0 && !s->flush)
172  return 0;
173 
174  work_pts = s->start_pts + av_rescale_q(s->n, av_inv_q(s->dest_frame_rate), s->dest_time_base);
175 
176  if (work_pts >= s->pts1 && !s->flush)
177  return 0;
178 
179  if (!s->f0) {
180  s->work = av_frame_clone(s->f1);
181  } else {
182  if (work_pts >= s->pts1 + s->delta && s->flush)
183  return 0;
184 
185  interpolate = av_rescale(work_pts - s->pts0, s->blend_factor_max, s->delta);
186  interpolate8 = av_rescale(work_pts - s->pts0, 256, s->delta);
187  ff_dlog(ctx, "process_work_frame() interpolate: %"PRId64"/256\n", interpolate8);
188  if (interpolate >= s->blend_factor_max || interpolate8 > s->interp_end) {
189  s->work = av_frame_clone(s->f1);
190  } else if (interpolate <= 0 || interpolate8 < s->interp_start) {
191  s->work = av_frame_clone(s->f0);
192  } else {
193  ret = blend_frames(ctx, interpolate);
194  if (ret < 0)
195  return ret;
196  if (ret == 0)
197  s->work = av_frame_clone(interpolate > (s->blend_factor_max >> 1) ? s->f1 : s->f0);
198  }
199  }
200 
201  if (!s->work)
202  return AVERROR(ENOMEM);
203 
204  s->work->pts = work_pts;
205  s->n++;
206 
207  return 1;
208 }
209 
211 {
212  FrameRateContext *s = ctx->priv;
214  return 0;
215 }
216 
218 {
219  FrameRateContext *s = ctx->priv;
220  av_frame_free(&s->f0);
221  av_frame_free(&s->f1);
222 }
223 
225 {
226  static const enum AVPixelFormat pix_fmts[] = {
237  };
238 
239  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
240  if (!fmts_list)
241  return AVERROR(ENOMEM);
242  return ff_set_common_formats(ctx, fmts_list);
243 }
244 
246 {
247  int line, pixel;
248  for (line = 0; line < height; line++) {
249  for (pixel = 0; pixel < width; pixel++)
250  dst[pixel] = ((src1[pixel] * factor1) + (src2[pixel] * factor2) + half) >> BLEND_FACTOR_DEPTH8;
251  src1 += src1_linesize;
252  src2 += src2_linesize;
253  dst += dst_linesize;
254  }
255 }
256 
258 {
259  int line, pixel;
260  uint16_t *dstw = (uint16_t *)dst;
261  uint16_t *src1w = (uint16_t *)src1;
262  uint16_t *src2w = (uint16_t *)src2;
263  width /= 2;
264  src1_linesize /= 2;
265  src2_linesize /= 2;
266  dst_linesize /= 2;
267  for (line = 0; line < height; line++) {
268  for (pixel = 0; pixel < width; pixel++)
269  dstw[pixel] = ((src1w[pixel] * factor1) + (src2w[pixel] * factor2) + half) >> BLEND_FACTOR_DEPTH16;
270  src1w += src1_linesize;
271  src2w += src2_linesize;
272  dstw += dst_linesize;
273  }
274 }
275 
277 {
278  if (s->bitdepth == 8) {
280  s->blend = blend_frames_c;
281  } else {
283  s->blend = blend_frames16_c;
284  }
285  if (ARCH_X86)
287 }
288 
290 {
291  AVFilterContext *ctx = inlink->dst;
292  FrameRateContext *s = ctx->priv;
293  const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
294  int plane;
295 
296  for (plane = 0; plane < 4; plane++) {
297  s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w,
298  plane);
299  }
300 
301  s->bitdepth = pix_desc->comp[0].depth;
302  s->vsub = pix_desc->log2_chroma_h;
303 
304  s->sad = ff_scene_sad_get_fn(s->bitdepth == 8 ? 8 : 16);
305  if (!s->sad)
306  return AVERROR(EINVAL);
307 
308  s->srce_time_base = inlink->time_base;
309 
311 
312  return 0;
313 }
314 
316 {
317  int ret, status;
318  AVFilterLink *inlink = ctx->inputs[0];
319  AVFilterLink *outlink = ctx->outputs[0];
320  FrameRateContext *s = ctx->priv;
321  AVFrame *inpicref;
322  int64_t pts;
323 
324  FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
325 
326 retry:
327  ret = process_work_frame(ctx);
328  if (ret < 0)
329  return ret;
330  else if (ret == 1)
331  return ff_filter_frame(outlink, s->work);
332 
333  ret = ff_inlink_consume_frame(inlink, &inpicref);
334  if (ret < 0)
335  return ret;
336 
337  if (inpicref) {
338  if (inpicref->interlaced_frame)
339  av_log(ctx, AV_LOG_WARNING, "Interlaced frame found - the output will not be correct.\n");
340 
341  if (inpicref->pts == AV_NOPTS_VALUE) {
342  av_log(ctx, AV_LOG_WARNING, "Ignoring frame without PTS.\n");
343  av_frame_free(&inpicref);
344  }
345  }
346 
347  if (inpicref) {
348  pts = av_rescale_q(inpicref->pts, s->srce_time_base, s->dest_time_base);
349 
350  if (s->f1 && pts == s->pts1) {
351  av_log(ctx, AV_LOG_WARNING, "Ignoring frame with same PTS.\n");
352  av_frame_free(&inpicref);
353  }
354  }
355 
356  if (inpicref) {
357  av_frame_free(&s->f0);
358  s->f0 = s->f1;
359  s->pts0 = s->pts1;
360  s->f1 = inpicref;
361  s->pts1 = pts;
362  s->delta = s->pts1 - s->pts0;
363  s->score = -1.0;
364 
365  if (s->delta < 0) {
366  av_log(ctx, AV_LOG_WARNING, "PTS discontinuity.\n");
367  s->start_pts = s->pts1;
368  s->n = 0;
369  av_frame_free(&s->f0);
370  }
371 
372  if (s->start_pts == AV_NOPTS_VALUE)
373  s->start_pts = s->pts1;
374 
375  goto retry;
376  }
377 
378  if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
379  if (!s->flush) {
380  s->flush = 1;
381  goto retry;
382  }
383  ff_outlink_set_status(outlink, status, pts);
384  return 0;
385  }
386 
387  FF_FILTER_FORWARD_WANTED(outlink, inlink);
388 
389  return FFERROR_NOT_READY;
390 }
391 
392 static int config_output(AVFilterLink *outlink)
393 {
394  AVFilterContext *ctx = outlink->src;
395  FrameRateContext *s = ctx->priv;
396  int exact;
397 
398  ff_dlog(ctx, "config_output()\n");
399 
400  ff_dlog(ctx,
401  "config_output() input time base:%u/%u (%f)\n",
402  ctx->inputs[0]->time_base.num,ctx->inputs[0]->time_base.den,
403  av_q2d(ctx->inputs[0]->time_base));
404 
405  // make sure timebase is small enough to hold the framerate
406 
407  exact = av_reduce(&s->dest_time_base.num, &s->dest_time_base.den,
408  av_gcd((int64_t)s->srce_time_base.num * s->dest_frame_rate.num,
409  (int64_t)s->srce_time_base.den * s->dest_frame_rate.den ),
410  (int64_t)s->srce_time_base.den * s->dest_frame_rate.num, INT_MAX);
411 
412  av_log(ctx, AV_LOG_INFO,
413  "time base:%u/%u -> %u/%u exact:%d\n",
415  s->dest_time_base.num, s->dest_time_base.den, exact);
416  if (!exact) {
417  av_log(ctx, AV_LOG_WARNING, "Timebase conversion is not exact\n");
418  }
419 
420  outlink->frame_rate = s->dest_frame_rate;
421  outlink->time_base = s->dest_time_base;
422 
423  ff_dlog(ctx,
424  "config_output() output time base:%u/%u (%f) w:%d h:%d\n",
425  outlink->time_base.num, outlink->time_base.den,
426  av_q2d(outlink->time_base),
427  outlink->w, outlink->h);
428 
429 
430  av_log(ctx, AV_LOG_INFO, "fps -> fps:%u/%u scene score:%f interpolate start:%d end:%d\n",
432  s->scene_score, s->interp_start, s->interp_end);
433 
434  return 0;
435 }
436 
437 static const AVFilterPad framerate_inputs[] = {
438  {
439  .name = "default",
440  .type = AVMEDIA_TYPE_VIDEO,
441  .config_props = config_input,
442  },
443  { NULL }
444 };
445 
446 static const AVFilterPad framerate_outputs[] = {
447  {
448  .name = "default",
449  .type = AVMEDIA_TYPE_VIDEO,
450  .config_props = config_output,
451  },
452  { NULL }
453 };
454 
456  .name = "framerate",
457  .description = NULL_IF_CONFIG_SMALL("Upsamples or downsamples progressive source between specified frame rates."),
458  .priv_size = sizeof(FrameRateContext),
459  .priv_class = &framerate_class,
460  .init = init,
461  .uninit = uninit,
463  .inputs = framerate_inputs,
464  .outputs = framerate_outputs,
466  .activate = activate,
467 };
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link&#39;s FIFO and update the link&#39;s stats.
Definition: avfilter.c:1481
#define NULL
Definition: coverity.c:32
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane...
Definition: imgutils.c:76
static void blend_frames16_c(BLEND_FUNC_PARAMS)
Definition: vf_framerate.c:257
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2522
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
static int process_work_frame(AVFilterContext *ctx)
Definition: vf_framerate.c:162
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_framerate.c:217
AVOption.
Definition: opt.h:246
double scene_score
score that denotes a scene change has happened
Definition: framerate.h:41
double score
scene change score (f0 to f1)
Definition: framerate.h:63
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
misc image utilities
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
Main libavfilter public API header.
ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
Definition: scene_sad.c:59
int64_t pts0
last frame pts in dest_time_base
Definition: framerate.h:60
static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next)
Definition: vf_framerate.c:65
int num
Numerator.
Definition: rational.h:59
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:391
return FFERROR_NOT_READY
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:99
AVFILTER_DEFINE_CLASS(framerate)
int64_t pts1
current frame pts in dest_time_base
Definition: framerate.h:61
int framerate
Definition: h264_levels.c:65
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:189
int interp_end
end of range to apply linear interpolation
Definition: framerate.h:43
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
blend_func blend
Definition: framerate.h:68
const char * name
Pad name.
Definition: internal.h:60
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
#define av_cold
Definition: attributes.h:82
AVOptions.
#define BLEND_FACTOR_DEPTH16
Definition: framerate.h:32
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
AVRational dest_frame_rate
output frames per second
Definition: framerate.h:39
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:388
int height
Definition: vf_avgblur.c:61
static void interpolate(float *out, float v1, float v2, int size)
Definition: twinvq.c:84
AVFrame * dst
Definition: vf_blend.c:55
int plane
Definition: vf_blend.c:57
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:100
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
#define ff_dlog(a,...)
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:442
int flags
flags affecting frame rate conversion algorithm
Definition: framerate.h:40
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:392
#define BLEND_FACTOR_DEPTH8
Definition: framerate.h:31
#define av_log(a,...)
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:199
int line_size[4]
bytes of pixel data per line for each plane
Definition: framerate.h:45
A filter pad used for either input or output.
Definition: internal.h:54
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
Scene SAD functions.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1436
int width
Definition: frame.h:353
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
int64_t n
output frame counter
Definition: framerate.h:66
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
uint16_t src1_factor
Definition: vf_framerate.c:91
int interp_start
start of range to apply linear interpolation
Definition: framerate.h:42
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
void * priv
private data for use by the filter
Definition: avfilter.h:353
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
const char * arg
Definition: jacosubdec.c:66
simple assert() macros that are a bit more flexible than ISO C assert().
#define FRAMERATE_FLAG_SCD
Definition: vf_framerate.c:47
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
Definition: mathematics.c:37
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:390
#define FFMAX(a, b)
Definition: common.h:94
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
common internal API header
static int blend_frames(AVFilterContext *ctx, int interpolate)
Definition: vf_framerate.c:127
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:385
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
#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:78
AVFormatContext * ctx
Definition: movenc.c:48
double prev_mafd
previous MAFD (scene detect only)
Definition: framerate.h:52
AVFrame * copy_src1
Definition: vf_framerate.c:90
#define s(width, name)
Definition: cbs_vp9.c:257
AVFilter ff_vf_framerate
Definition: vf_framerate.c:455
AVRational srce_time_base
timebase of source
Definition: framerate.h:48
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:386
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:540
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
void ff_framerate_init_x86(FrameRateContext *s)
#define src1
Definition: h264pred.c:139
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
static const AVFilterPad framerate_outputs[]
Definition: vf_framerate.c:446
static int query_formats(AVFilterContext *ctx)
Definition: vf_framerate.c:224
static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
Definition: vf_framerate.c:94
Used for passing data between threads.
Definition: af_adeclick.c:487
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:326
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
int blend_factor_max
Definition: framerate.h:54
AVFrame * work
Definition: framerate.h:56
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:387
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
Filter definition.
Definition: avfilter.h:144
AVRational dest_time_base
timebase of destination
Definition: framerate.h:49
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
offset must point to AVRational
Definition: opt.h:236
const char * name
Filter name.
Definition: avfilter.h:148
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:384
static av_cold int init(AVFilterContext *ctx)
Definition: vf_framerate.c:210
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
uint8_t pixel
Definition: tiny_ssim.c:42
void ff_framerate_init(FrameRateContext *s)
Definition: vf_framerate.c:276
static int64_t pts
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:378
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:388
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:394
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:309
#define BLEND_FUNC_PARAMS
Definition: framerate.h:25
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
#define F
Definition: vf_framerate.c:46
uint16_t src2_factor
Definition: vf_framerate.c:91
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line
Definition: swscale.txt:33
AVFrame * f0
last frame
Definition: framerate.h:58
static void blend_frames_c(BLEND_FUNC_PARAMS)
Definition: vf_framerate.c:245
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
int den
Denominator.
Definition: rational.h:60
avfilter_execute_func * execute
Definition: internal.h:155
FF_FILTER_FORWARD_WANTED(outlink, inlink)
AVFrame * copy_src2
Definition: vf_framerate.c:90
#define V
Definition: vf_framerate.c:45
static av_always_inline int diff(const uint32_t a, const uint32_t b)
ff_scene_sad_fn sad
Sum of the absolute difference function (scene detect only)
Definition: framerate.h:51
static const AVOption framerate_options[]
Definition: vf_framerate.c:49
static int config_input(AVFilterLink *inlink)
Definition: vf_framerate.c:289
A list of supported formats for one end of a filter link.
Definition: formats.h:64
#define OFFSET(x)
Definition: vf_framerate.c:44
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:258
static const AVFilterPad framerate_inputs[]
Definition: vf_framerate.c:437
An instance of a filter.
Definition: avfilter.h:338
int height
Definition: frame.h:353
int64_t start_pts
pts of the first output frame
Definition: framerate.h:65
int flush
1 if the filter is being flushed
Definition: framerate.h:64
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
void INT64 start
Definition: avisynth_c.h:766
AVFrame * f1
current frame
Definition: framerate.h:59
static int config_output(AVFilterLink *outlink)
Definition: vf_framerate.c:392
AVFilterLink * inlink
Definition: vf_blend.c:56
internal API functions
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
int depth
Number of bits in the component.
Definition: pixdesc.h:58
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
int64_t delta
pts1 to pts0 delta
Definition: framerate.h:62
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:654
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
static int activate(AVFilterContext *ctx)
Definition: vf_framerate.c:315