FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 #include "libavutil/pixelutils.h"
37 
38 #include "avfilter.h"
39 #include "internal.h"
40 #include "video.h"
41 #include "filters.h"
42 #include "framerate.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 
63 AVFILTER_DEFINE_CLASS(framerate);
64 
65 static av_always_inline int64_t sad_8x8_16(const uint16_t *src1, ptrdiff_t stride1,
66  const uint16_t *src2, ptrdiff_t stride2)
67 {
68  int sum = 0;
69  int x, y;
70 
71  for (y = 0; y < 8; y++) {
72  for (x = 0; x < 8; x++)
73  sum += FFABS(src1[x] - src2[x]);
74  src1 += stride1;
75  src2 += stride2;
76  }
77  return sum;
78 }
79 
80 static int64_t scene_sad16(FrameRateContext *s, const uint16_t *p1, int p1_linesize, const uint16_t* p2, int p2_linesize, const int width, const int height)
81 {
82  int64_t sad;
83  int x, y;
84  for (sad = y = 0; y < height - 7; y += 8) {
85  for (x = 0; x < width - 7; x += 8) {
86  sad += sad_8x8_16(p1 + y * p1_linesize + x,
87  p1_linesize,
88  p2 + y * p2_linesize + x,
89  p2_linesize);
90  }
91  }
92  return sad;
93 }
94 
95 static int64_t scene_sad8(FrameRateContext *s, uint8_t *p1, int p1_linesize, uint8_t* p2, int p2_linesize, const int width, const int height)
96 {
97  int64_t sad;
98  int x, y;
99  for (sad = y = 0; y < height - 7; y += 8) {
100  for (x = 0; x < width - 7; x += 8) {
101  sad += s->sad(p1 + y * p1_linesize + x,
102  p1_linesize,
103  p2 + y * p2_linesize + x,
104  p2_linesize);
105  }
106  }
107  emms_c();
108  return sad;
109 }
110 
111 static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next)
112 {
113  FrameRateContext *s = ctx->priv;
114  double ret = 0;
115 
116  ff_dlog(ctx, "get_scene_score()\n");
117 
118  if (crnt->height == next->height &&
119  crnt->width == next->width) {
120  int64_t sad;
121  double mafd, diff;
122 
123  ff_dlog(ctx, "get_scene_score() process\n");
124  if (s->bitdepth == 8)
125  sad = scene_sad8(s, crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->width, crnt->height);
126  else
127  sad = scene_sad16(s, (const uint16_t*)crnt->data[0], crnt->linesize[0] / 2, (const uint16_t*)next->data[0], next->linesize[0] / 2, crnt->width, crnt->height);
128 
129  mafd = (double)sad * 100.0 / FFMAX(1, (crnt->height & ~7) * (crnt->width & ~7)) / (1 << s->bitdepth);
130  diff = fabs(mafd - s->prev_mafd);
131  ret = av_clipf(FFMIN(mafd, diff), 0, 100.0);
132  s->prev_mafd = mafd;
133  }
134  ff_dlog(ctx, "get_scene_score() result is:%f\n", ret);
135  return ret;
136 }
137 
138 typedef struct ThreadData {
141 } ThreadData;
142 
143 static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
144 {
145  FrameRateContext *s = ctx->priv;
146  ThreadData *td = arg;
147  uint16_t src1_factor = td->src1_factor;
148  uint16_t src2_factor = td->src2_factor;
149  int plane;
150 
151  for (plane = 0; plane < 4 && td->copy_src1->data[plane] && td->copy_src2->data[plane]; plane++) {
152  int cpy_line_width = s->line_size[plane];
153  uint8_t *cpy_src1_data = td->copy_src1->data[plane];
154  int cpy_src1_line_size = td->copy_src1->linesize[plane];
155  uint8_t *cpy_src2_data = td->copy_src2->data[plane];
156  int cpy_src2_line_size = td->copy_src2->linesize[plane];
157  int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);
158  uint8_t *cpy_dst_data = s->work->data[plane];
159  int cpy_dst_line_size = s->work->linesize[plane];
160  const int start = (cpy_src_h * job ) / nb_jobs;
161  const int end = (cpy_src_h * (job+1)) / nb_jobs;
162  cpy_src1_data += start * cpy_src1_line_size;
163  cpy_src2_data += start * cpy_src2_line_size;
164  cpy_dst_data += start * cpy_dst_line_size;
165 
166  s->blend(cpy_src1_data, cpy_src1_line_size,
167  cpy_src2_data, cpy_src2_line_size,
168  cpy_dst_data, cpy_dst_line_size,
169  cpy_line_width, end - start,
170  src1_factor, src2_factor, s->blend_factor_max >> 1);
171  }
172 
173  return 0;
174 }
175 
177 {
178  FrameRateContext *s = ctx->priv;
179  AVFilterLink *outlink = ctx->outputs[0];
180  double interpolate_scene_score = 0;
181 
182  if ((s->flags & FRAMERATE_FLAG_SCD)) {
183  if (s->score >= 0.0)
184  interpolate_scene_score = s->score;
185  else
186  interpolate_scene_score = s->score = get_scene_score(ctx, s->f0, s->f1);
187  ff_dlog(ctx, "blend_frames() interpolate scene score:%f\n", interpolate_scene_score);
188  }
189  // decide if the shot-change detection allows us to blend two frames
190  if (interpolate_scene_score < s->scene_score) {
191  ThreadData td;
192  td.copy_src1 = s->f0;
193  td.copy_src2 = s->f1;
196 
197  // get work-space for output frame
198  s->work = ff_get_video_buffer(outlink, outlink->w, outlink->h);
199  if (!s->work)
200  return AVERROR(ENOMEM);
201 
202  av_frame_copy_props(s->work, s->f0);
203 
204  ff_dlog(ctx, "blend_frames() INTERPOLATE to create work frame\n");
205  ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(FFMAX(1, outlink->h >> 2), ff_filter_get_nb_threads(ctx)));
206  return 1;
207  }
208  return 0;
209 }
210 
212 {
213  FrameRateContext *s = ctx->priv;
214  int64_t work_pts;
215  int64_t interpolate, interpolate8;
216  int ret;
217 
218  if (!s->f1)
219  return 0;
220  if (!s->f0 && !s->flush)
221  return 0;
222 
223  work_pts = s->start_pts + av_rescale_q(s->n, av_inv_q(s->dest_frame_rate), s->dest_time_base);
224 
225  if (work_pts >= s->pts1 && !s->flush)
226  return 0;
227 
228  if (!s->f0) {
229  s->work = av_frame_clone(s->f1);
230  } else {
231  if (work_pts >= s->pts1 + s->delta && s->flush)
232  return 0;
233 
234  interpolate = av_rescale(work_pts - s->pts0, s->blend_factor_max, s->delta);
235  interpolate8 = av_rescale(work_pts - s->pts0, 256, s->delta);
236  ff_dlog(ctx, "process_work_frame() interpolate: %"PRId64"/256\n", interpolate8);
237  if (interpolate >= s->blend_factor_max || interpolate8 > s->interp_end) {
238  s->work = av_frame_clone(s->f1);
239  } else if (interpolate <= 0 || interpolate8 < s->interp_start) {
240  s->work = av_frame_clone(s->f0);
241  } else {
242  ret = blend_frames(ctx, interpolate);
243  if (ret < 0)
244  return ret;
245  if (ret == 0)
246  s->work = av_frame_clone(interpolate > (s->blend_factor_max >> 1) ? s->f1 : s->f0);
247  }
248  }
249 
250  if (!s->work)
251  return AVERROR(ENOMEM);
252 
253  s->work->pts = work_pts;
254  s->n++;
255 
256  return 1;
257 }
258 
260 {
261  FrameRateContext *s = ctx->priv;
263  return 0;
264 }
265 
267 {
268  FrameRateContext *s = ctx->priv;
269  av_frame_free(&s->f0);
270  av_frame_free(&s->f1);
271 }
272 
274 {
275  static const enum AVPixelFormat pix_fmts[] = {
286  };
287 
288  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
289  if (!fmts_list)
290  return AVERROR(ENOMEM);
291  return ff_set_common_formats(ctx, fmts_list);
292 }
293 
295 {
296  int line, pixel;
297  for (line = 0; line < height; line++) {
298  for (pixel = 0; pixel < width; pixel++)
299  dst[pixel] = ((src1[pixel] * factor1) + (src2[pixel] * factor2) + half) >> BLEND_FACTOR_DEPTH8;
300  src1 += src1_linesize;
301  src2 += src2_linesize;
302  dst += dst_linesize;
303  }
304 }
305 
307 {
308  int line, pixel;
309  uint16_t *dstw = (uint16_t *)dst;
310  uint16_t *src1w = (uint16_t *)src1;
311  uint16_t *src2w = (uint16_t *)src2;
312  width /= 2;
313  src1_linesize /= 2;
314  src2_linesize /= 2;
315  dst_linesize /= 2;
316  for (line = 0; line < height; line++) {
317  for (pixel = 0; pixel < width; pixel++)
318  dstw[pixel] = ((src1w[pixel] * factor1) + (src2w[pixel] * factor2) + half) >> BLEND_FACTOR_DEPTH16;
319  src1w += src1_linesize;
320  src2w += src2_linesize;
321  dstw += dst_linesize;
322  }
323 }
324 
326 {
327  if (s->bitdepth == 8) {
329  s->blend = blend_frames_c;
330  } else {
332  s->blend = blend_frames16_c;
333  }
334  if (ARCH_X86)
336 }
337 
338 static int config_input(AVFilterLink *inlink)
339 {
340  AVFilterContext *ctx = inlink->dst;
341  FrameRateContext *s = ctx->priv;
342  const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
343  int plane;
344 
345  for (plane = 0; plane < 4; plane++) {
346  s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w,
347  plane);
348  }
349 
350  s->bitdepth = pix_desc->comp[0].depth;
351  s->vsub = pix_desc->log2_chroma_h;
352 
353  s->sad = av_pixelutils_get_sad_fn(3, 3, 2, s); // 8x8 both sources aligned
354  if (!s->sad)
355  return AVERROR(EINVAL);
356 
357  s->srce_time_base = inlink->time_base;
358 
360 
361  return 0;
362 }
363 
365 {
366  int ret, status;
367  AVFilterLink *inlink = ctx->inputs[0];
368  AVFilterLink *outlink = ctx->outputs[0];
369  FrameRateContext *s = ctx->priv;
370  AVFrame *inpicref;
371  int64_t pts;
372 
373  FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
374 
375 retry:
376  ret = process_work_frame(ctx);
377  if (ret < 0)
378  return ret;
379  else if (ret == 1)
380  return ff_filter_frame(outlink, s->work);
381 
382  ret = ff_inlink_consume_frame(inlink, &inpicref);
383  if (ret < 0)
384  return ret;
385 
386  if (inpicref) {
387  if (inpicref->interlaced_frame)
388  av_log(ctx, AV_LOG_WARNING, "Interlaced frame found - the output will not be correct.\n");
389 
390  if (inpicref->pts == AV_NOPTS_VALUE) {
391  av_log(ctx, AV_LOG_WARNING, "Ignoring frame without PTS.\n");
392  av_frame_free(&inpicref);
393  }
394  }
395 
396  if (inpicref) {
397  pts = av_rescale_q(inpicref->pts, s->srce_time_base, s->dest_time_base);
398 
399  if (s->f1 && pts == s->pts1) {
400  av_log(ctx, AV_LOG_WARNING, "Ignoring frame with same PTS.\n");
401  av_frame_free(&inpicref);
402  }
403  }
404 
405  if (inpicref) {
406  av_frame_free(&s->f0);
407  s->f0 = s->f1;
408  s->pts0 = s->pts1;
409  s->f1 = inpicref;
410  s->pts1 = pts;
411  s->delta = s->pts1 - s->pts0;
412  s->score = -1.0;
413 
414  if (s->delta < 0) {
415  av_log(ctx, AV_LOG_WARNING, "PTS discontinuity.\n");
416  s->start_pts = s->pts1;
417  s->n = 0;
418  av_frame_free(&s->f0);
419  }
420 
421  if (s->start_pts == AV_NOPTS_VALUE)
422  s->start_pts = s->pts1;
423 
424  goto retry;
425  }
426 
427  if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
428  if (!s->flush) {
429  s->flush = 1;
430  goto retry;
431  }
432  ff_outlink_set_status(outlink, status, pts);
433  return 0;
434  }
435 
436  FF_FILTER_FORWARD_WANTED(outlink, inlink);
437 
438  return FFERROR_NOT_READY;
439 }
440 
441 static int config_output(AVFilterLink *outlink)
442 {
443  AVFilterContext *ctx = outlink->src;
444  FrameRateContext *s = ctx->priv;
445  int exact;
446 
447  ff_dlog(ctx, "config_output()\n");
448 
449  ff_dlog(ctx,
450  "config_output() input time base:%u/%u (%f)\n",
451  ctx->inputs[0]->time_base.num,ctx->inputs[0]->time_base.den,
452  av_q2d(ctx->inputs[0]->time_base));
453 
454  // make sure timebase is small enough to hold the framerate
455 
456  exact = av_reduce(&s->dest_time_base.num, &s->dest_time_base.den,
457  av_gcd((int64_t)s->srce_time_base.num * s->dest_frame_rate.num,
458  (int64_t)s->srce_time_base.den * s->dest_frame_rate.den ),
459  (int64_t)s->srce_time_base.den * s->dest_frame_rate.num, INT_MAX);
460 
461  av_log(ctx, AV_LOG_INFO,
462  "time base:%u/%u -> %u/%u exact:%d\n",
464  s->dest_time_base.num, s->dest_time_base.den, exact);
465  if (!exact) {
466  av_log(ctx, AV_LOG_WARNING, "Timebase conversion is not exact\n");
467  }
468 
469  outlink->frame_rate = s->dest_frame_rate;
470  outlink->time_base = s->dest_time_base;
471 
472  ff_dlog(ctx,
473  "config_output() output time base:%u/%u (%f) w:%d h:%d\n",
474  outlink->time_base.num, outlink->time_base.den,
475  av_q2d(outlink->time_base),
476  outlink->w, outlink->h);
477 
478 
479  av_log(ctx, AV_LOG_INFO, "fps -> fps:%u/%u scene score:%f interpolate start:%d end:%d\n",
481  s->scene_score, s->interp_start, s->interp_end);
482 
483  return 0;
484 }
485 
486 static const AVFilterPad framerate_inputs[] = {
487  {
488  .name = "default",
489  .type = AVMEDIA_TYPE_VIDEO,
490  .config_props = config_input,
491  },
492  { NULL }
493 };
494 
495 static const AVFilterPad framerate_outputs[] = {
496  {
497  .name = "default",
498  .type = AVMEDIA_TYPE_VIDEO,
499  .config_props = config_output,
500  },
501  { NULL }
502 };
503 
505  .name = "framerate",
506  .description = NULL_IF_CONFIG_SMALL("Upsamples or downsamples progressive source between specified frame rates."),
507  .priv_size = sizeof(FrameRateContext),
508  .priv_class = &framerate_class,
509  .init = init,
510  .uninit = uninit,
512  .inputs = framerate_inputs,
513  .outputs = framerate_outputs,
515  .activate = activate,
516 };
static int64_t scene_sad16(FrameRateContext *s, const uint16_t *p1, int p1_linesize, const uint16_t *p2, int p2_linesize, const int width, const int height)
Definition: vf_framerate.c:80
int plane
Definition: avisynth_c.h:422
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: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:306
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2446
This structure describes decoded (raw) audio or video data.
Definition: frame.h:226
static int process_work_frame(AVFilterContext *ctx)
Definition: vf_framerate.c:211
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_framerate.c:266
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
static int64_t scene_sad8(FrameRateContext *s, uint8_t *p1, int p1_linesize, uint8_t *p2, int p2_linesize, const int width, const int height)
Definition: vf_framerate.c:95
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.
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:111
int num
Numerator.
Definition: rational.h:59
#define FFERROR_NOT_READY
Filters implementation helper functions.
Definition: filters.h:34
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:383
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
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:319
static void interpolate(float *out, float v1, float v2, int size)
Definition: twinvq.c:84
#define height
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:373
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:384
#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
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:284
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:140
int interp_start
start of range to apply linear interpolation
Definition: framerate.h:42
#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: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
Definition: graph2dot.c:48
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:382
#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:176
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:377
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
Definition: filters.h:254
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
#define width
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:139
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
#define s(width, name)
Definition: cbs_vp9.c:257
AVFilter ff_vf_framerate
Definition: vf_framerate.c:504
AVRational srce_time_base
timebase of source
Definition: framerate.h:48
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static av_always_inline int64_t sad_8x8_16(const uint16_t *src1, ptrdiff_t stride1, const uint16_t *src2, ptrdiff_t stride2)
Definition: vf_framerate.c:65
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:378
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:495
static int query_formats(AVFilterContext *ctx)
Definition: vf_framerate.c:273
static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
Definition: vf_framerate.c:143
Used for passing data between threads.
Definition: af_adeclick.c:484
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:257
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
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:379
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
av_pixelutils_sad_fn av_pixelutils_get_sad_fn(int w_bits, int h_bits, int aligned, void *log_ctx)
Get a potentially optimized pointer to a Sum-of-absolute-differences function (see the av_pixelutils_...
Definition: pixelutils.c:66
Filter definition.
Definition: avfilter.h:144
AVRational dest_time_base
timebase of destination
Definition: framerate.h:49
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:376
static av_cold int init(AVFilterContext *ctx)
Definition: vf_framerate.c:259
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
uint8_t pixel
Definition: tiny_ssim.c:42
void ff_framerate_init(FrameRateContext *s)
Definition: vf_framerate.c:325
static int64_t pts
#define flags(name, subs,...)
Definition: cbs_av1.c:596
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:378
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:380
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:386
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:240
#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:140
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
AVFrame * f0
last frame
Definition: framerate.h:58
av_pixelutils_sad_fn sad
Sum of the absolute difference function (scene detect only)
Definition: framerate.h:51
static void blend_frames_c(BLEND_FUNC_PARAMS)
Definition: vf_framerate.c:294
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
AVFrame * copy_src2
Definition: vf_framerate.c:139
#define V
Definition: vf_framerate.c:45
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static const AVOption framerate_options[]
Definition: vf_framerate.c:49
static int config_input(AVFilterLink *inlink)
Definition: vf_framerate.c:338
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:486
An instance of a filter.
Definition: avfilter.h:338
int height
Definition: frame.h:284
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:690
#define av_always_inline
Definition: attributes.h:39
AVFrame * f1
current frame
Definition: framerate.h:59
static int config_output(AVFilterLink *outlink)
Definition: vf_framerate.c:441
internal API functions
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:364