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 "framerate.h"
42 
43 #define OFFSET(x) offsetof(FrameRateContext, x)
44 #define V AV_OPT_FLAG_VIDEO_PARAM
45 #define F AV_OPT_FLAG_FILTERING_PARAM
46 #define FRAMERATE_FLAG_SCD 01
47 
48 static const AVOption framerate_options[] = {
49  {"fps", "required output frames per second rate", OFFSET(dest_frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="50"}, 0, INT_MAX, V|F },
50 
51  {"interp_start", "point to start linear interpolation", OFFSET(interp_start), AV_OPT_TYPE_INT, {.i64=15}, 0, 255, V|F },
52  {"interp_end", "point to end linear interpolation", OFFSET(interp_end), AV_OPT_TYPE_INT, {.i64=240}, 0, 255, V|F },
53  {"scene", "scene change level", OFFSET(scene_score), AV_OPT_TYPE_DOUBLE, {.dbl=8.2}, 0, INT_MAX, V|F },
54 
55  {"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=1}, 0, INT_MAX, V|F, "flags" },
56  {"scene_change_detect", "enable scene change detection", 0, AV_OPT_TYPE_CONST, {.i64=FRAMERATE_FLAG_SCD}, INT_MIN, INT_MAX, V|F, "flags" },
57  {"scd", "enable scene change detection", 0, AV_OPT_TYPE_CONST, {.i64=FRAMERATE_FLAG_SCD}, INT_MIN, INT_MAX, V|F, "flags" },
58 
59  {NULL}
60 };
61 
62 AVFILTER_DEFINE_CLASS(framerate);
63 
64 static av_always_inline int64_t sad_8x8_16(const uint16_t *src1, ptrdiff_t stride1,
65  const uint16_t *src2, ptrdiff_t stride2)
66 {
67  int sum = 0;
68  int x, y;
69 
70  for (y = 0; y < 8; y++) {
71  for (x = 0; x < 8; x++)
72  sum += FFABS(src1[x] - src2[x]);
73  src1 += stride1;
74  src2 += stride2;
75  }
76  return sum;
77 }
78 
79 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)
80 {
81  int64_t sad;
82  int x, y;
83  for (sad = y = 0; y < height - 7; y += 8) {
84  for (x = 0; x < width - 7; x += 8) {
85  sad += sad_8x8_16(p1 + y * p1_linesize + x,
86  p1_linesize,
87  p2 + y * p2_linesize + x,
88  p2_linesize);
89  }
90  }
91  return sad;
92 }
93 
94 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)
95 {
96  int64_t sad;
97  int x, y;
98  for (sad = y = 0; y < height - 7; y += 8) {
99  for (x = 0; x < width - 7; x += 8) {
100  sad += s->sad(p1 + y * p1_linesize + x,
101  p1_linesize,
102  p2 + y * p2_linesize + x,
103  p2_linesize);
104  }
105  }
106  emms_c();
107  return sad;
108 }
109 
110 static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next)
111 {
112  FrameRateContext *s = ctx->priv;
113  double ret = 0;
114 
115  ff_dlog(ctx, "get_scene_score()\n");
116 
117  if (crnt->height == next->height &&
118  crnt->width == next->width) {
119  int64_t sad;
120  double mafd, diff;
121 
122  ff_dlog(ctx, "get_scene_score() process\n");
123  if (s->bitdepth == 8)
124  sad = scene_sad8(s, crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->width, crnt->height);
125  else
126  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);
127 
128  mafd = (double)sad * 100.0 / FFMAX(1, (crnt->height & ~7) * (crnt->width & ~7)) / (1 << s->bitdepth);
129  diff = fabs(mafd - s->prev_mafd);
130  ret = av_clipf(FFMIN(mafd, diff), 0, 100.0);
131  s->prev_mafd = mafd;
132  }
133  ff_dlog(ctx, "get_scene_score() result is:%f\n", ret);
134  return ret;
135 }
136 
137 typedef struct ThreadData {
140 } ThreadData;
141 
142 static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
143 {
144  FrameRateContext *s = ctx->priv;
145  ThreadData *td = arg;
146  uint16_t src1_factor = td->src1_factor;
147  uint16_t src2_factor = td->src2_factor;
148  int plane;
149 
150  for (plane = 0; plane < 4 && td->copy_src1->data[plane] && td->copy_src2->data[plane]; plane++) {
151  int cpy_line_width = s->line_size[plane];
152  uint8_t *cpy_src1_data = td->copy_src1->data[plane];
153  int cpy_src1_line_size = td->copy_src1->linesize[plane];
154  uint8_t *cpy_src2_data = td->copy_src2->data[plane];
155  int cpy_src2_line_size = td->copy_src2->linesize[plane];
156  int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> s->vsub) : (td->copy_src1->height);
157  uint8_t *cpy_dst_data = s->work->data[plane];
158  int cpy_dst_line_size = s->work->linesize[plane];
159  const int start = (cpy_src_h * job ) / nb_jobs;
160  const int end = (cpy_src_h * (job+1)) / nb_jobs;
161  cpy_src1_data += start * cpy_src1_line_size;
162  cpy_src2_data += start * cpy_src2_line_size;
163  cpy_dst_data += start * cpy_dst_line_size;
164 
165  s->blend(cpy_src1_data, cpy_src1_line_size,
166  cpy_src2_data, cpy_src2_line_size,
167  cpy_dst_data, cpy_dst_line_size,
168  cpy_line_width, end - start,
169  src1_factor, src2_factor, s->blend_factor_max >> 1);
170  }
171 
172  return 0;
173 }
174 
176 {
177  FrameRateContext *s = ctx->priv;
178  AVFilterLink *outlink = ctx->outputs[0];
179  double interpolate_scene_score = 0;
180 
181  if ((s->flags & FRAMERATE_FLAG_SCD)) {
182  if (s->score >= 0.0)
183  interpolate_scene_score = s->score;
184  else
185  interpolate_scene_score = s->score = get_scene_score(ctx, s->f0, s->f1);
186  ff_dlog(ctx, "blend_frames() interpolate scene score:%f\n", interpolate_scene_score);
187  }
188  // decide if the shot-change detection allows us to blend two frames
189  if (interpolate_scene_score < s->scene_score) {
190  ThreadData td;
191  td.copy_src1 = s->f0;
192  td.copy_src2 = s->f1;
195 
196  // get work-space for output frame
197  s->work = ff_get_video_buffer(outlink, outlink->w, outlink->h);
198  if (!s->work)
199  return AVERROR(ENOMEM);
200 
201  av_frame_copy_props(s->work, s->f0);
202 
203  ff_dlog(ctx, "blend_frames() INTERPOLATE to create work frame\n");
204  ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(FFMAX(1, outlink->h >> 2), ff_filter_get_nb_threads(ctx)));
205  return 1;
206  }
207  return 0;
208 }
209 
211 {
212  FrameRateContext *s = ctx->priv;
213  int64_t work_pts;
214  int64_t interpolate, interpolate8;
215  int ret;
216 
217  if (!s->f1)
218  return 0;
219  if (!s->f0 && !s->flush)
220  return 0;
221 
222  work_pts = s->start_pts + av_rescale_q(s->n, av_inv_q(s->dest_frame_rate), s->dest_time_base);
223 
224  if (work_pts >= s->pts1 && !s->flush)
225  return 0;
226 
227  if (!s->f0) {
228  s->work = av_frame_clone(s->f1);
229  } else {
230  if (work_pts >= s->pts1 + s->delta && s->flush)
231  return 0;
232 
233  interpolate = av_rescale(work_pts - s->pts0, s->blend_factor_max, s->delta);
234  interpolate8 = av_rescale(work_pts - s->pts0, 256, s->delta);
235  ff_dlog(ctx, "process_work_frame() interpolate: %"PRId64"/256\n", interpolate8);
236  if (interpolate >= s->blend_factor_max || interpolate8 > s->interp_end) {
237  s->work = av_frame_clone(s->f1);
238  } else if (interpolate <= 0 || interpolate8 < s->interp_start) {
239  s->work = av_frame_clone(s->f0);
240  } else {
241  ret = blend_frames(ctx, interpolate);
242  if (ret < 0)
243  return ret;
244  if (ret == 0)
245  s->work = av_frame_clone(interpolate > (s->blend_factor_max >> 1) ? s->f1 : s->f0);
246  }
247  }
248 
249  if (!s->work)
250  return AVERROR(ENOMEM);
251 
252  s->work->pts = work_pts;
253  s->n++;
254 
255  return 1;
256 }
257 
259 {
260  FrameRateContext *s = ctx->priv;
262  return 0;
263 }
264 
266 {
267  FrameRateContext *s = ctx->priv;
268  av_frame_free(&s->f0);
269  av_frame_free(&s->f1);
270 }
271 
273 {
274  static const enum AVPixelFormat pix_fmts[] = {
285  };
286 
287  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
288  if (!fmts_list)
289  return AVERROR(ENOMEM);
290  return ff_set_common_formats(ctx, fmts_list);
291 }
292 
294 {
295  int line, pixel;
296  for (line = 0; line < height; line++) {
297  for (pixel = 0; pixel < width; pixel++)
298  dst[pixel] = ((src1[pixel] * factor1) + (src2[pixel] * factor2) + half) >> BLEND_FACTOR_DEPTH8;
299  src1 += src1_linesize;
300  src2 += src2_linesize;
301  dst += dst_linesize;
302  }
303 }
304 
306 {
307  int line, pixel;
308  uint16_t *dstw = (uint16_t *)dst;
309  uint16_t *src1w = (uint16_t *)src1;
310  uint16_t *src2w = (uint16_t *)src2;
311  width /= 2;
312  src1_linesize /= 2;
313  src2_linesize /= 2;
314  dst_linesize /= 2;
315  for (line = 0; line < height; line++) {
316  for (pixel = 0; pixel < width; pixel++)
317  dstw[pixel] = ((src1w[pixel] * factor1) + (src2w[pixel] * factor2) + half) >> BLEND_FACTOR_DEPTH16;
318  src1w += src1_linesize;
319  src2w += src2_linesize;
320  dstw += dst_linesize;
321  }
322 }
323 
325 {
326  if (s->bitdepth == 8) {
328  s->blend = blend_frames_c;
329  } else {
331  s->blend = blend_frames16_c;
332  }
333  if (ARCH_X86)
335 }
336 
337 static int config_input(AVFilterLink *inlink)
338 {
339  AVFilterContext *ctx = inlink->dst;
340  FrameRateContext *s = ctx->priv;
341  const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
342  int plane;
343 
344  for (plane = 0; plane < 4; plane++) {
345  s->line_size[plane] = av_image_get_linesize(inlink->format, inlink->w,
346  plane);
347  }
348 
349  s->bitdepth = pix_desc->comp[0].depth;
350  s->vsub = pix_desc->log2_chroma_h;
351 
352  s->sad = av_pixelutils_get_sad_fn(3, 3, 2, s); // 8x8 both sources aligned
353  if (!s->sad)
354  return AVERROR(EINVAL);
355 
356  s->srce_time_base = inlink->time_base;
357 
359 
360  return 0;
361 }
362 
363 static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
364 {
365  int ret;
366  AVFilterContext *ctx = inlink->dst;
367  FrameRateContext *s = ctx->priv;
368  int64_t pts;
369 
370  if (inpicref->interlaced_frame)
371  av_log(ctx, AV_LOG_WARNING, "Interlaced frame found - the output will not be correct.\n");
372 
373  if (inpicref->pts == AV_NOPTS_VALUE) {
374  av_log(ctx, AV_LOG_WARNING, "Ignoring frame without PTS.\n");
375  return 0;
376  }
377 
378  pts = av_rescale_q(inpicref->pts, s->srce_time_base, s->dest_time_base);
379  if (s->f1 && pts == s->pts1) {
380  av_log(ctx, AV_LOG_WARNING, "Ignoring frame with same PTS.\n");
381  return 0;
382  }
383 
384  av_frame_free(&s->f0);
385  s->f0 = s->f1;
386  s->pts0 = s->pts1;
387  s->f1 = inpicref;
388  s->pts1 = pts;
389  s->delta = s->pts1 - s->pts0;
390  s->score = -1.0;
391 
392  if (s->delta < 0) {
393  av_log(ctx, AV_LOG_WARNING, "PTS discontinuity.\n");
394  s->start_pts = s->pts1;
395  s->n = 0;
396  av_frame_free(&s->f0);
397  }
398 
399  if (s->start_pts == AV_NOPTS_VALUE)
400  s->start_pts = s->pts1;
401 
402  do {
403  ret = process_work_frame(ctx);
404  if (ret <= 0)
405  return ret;
406  ret = ff_filter_frame(ctx->outputs[0], s->work);
407  } while (ret >= 0);
408 
409  return ret;
410 }
411 
412 static int config_output(AVFilterLink *outlink)
413 {
414  AVFilterContext *ctx = outlink->src;
415  FrameRateContext *s = ctx->priv;
416  int exact;
417 
418  ff_dlog(ctx, "config_output()\n");
419 
420  ff_dlog(ctx,
421  "config_output() input time base:%u/%u (%f)\n",
422  ctx->inputs[0]->time_base.num,ctx->inputs[0]->time_base.den,
423  av_q2d(ctx->inputs[0]->time_base));
424 
425  // make sure timebase is small enough to hold the framerate
426 
427  exact = av_reduce(&s->dest_time_base.num, &s->dest_time_base.den,
428  av_gcd((int64_t)s->srce_time_base.num * s->dest_frame_rate.num,
429  (int64_t)s->srce_time_base.den * s->dest_frame_rate.den ),
430  (int64_t)s->srce_time_base.den * s->dest_frame_rate.num, INT_MAX);
431 
432  av_log(ctx, AV_LOG_INFO,
433  "time base:%u/%u -> %u/%u exact:%d\n",
435  s->dest_time_base.num, s->dest_time_base.den, exact);
436  if (!exact) {
437  av_log(ctx, AV_LOG_WARNING, "Timebase conversion is not exact\n");
438  }
439 
440  outlink->frame_rate = s->dest_frame_rate;
441  outlink->time_base = s->dest_time_base;
442 
443  ff_dlog(ctx,
444  "config_output() output time base:%u/%u (%f) w:%d h:%d\n",
445  outlink->time_base.num, outlink->time_base.den,
446  av_q2d(outlink->time_base),
447  outlink->w, outlink->h);
448 
449 
450  av_log(ctx, AV_LOG_INFO, "fps -> fps:%u/%u scene score:%f interpolate start:%d end:%d\n",
452  s->scene_score, s->interp_start, s->interp_end);
453 
454  return 0;
455 }
456 
457 static int request_frame(AVFilterLink *outlink)
458 {
459  AVFilterContext *ctx = outlink->src;
460  FrameRateContext *s = ctx->priv;
461  int ret;
462 
463  ff_dlog(ctx, "request_frame()\n");
464 
465  ret = ff_request_frame(ctx->inputs[0]);
466  if (ret == AVERROR_EOF && s->f1 && !s->flush) {
467  s->flush = 1;
468  ret = process_work_frame(ctx);
469  if (ret < 0)
470  return ret;
471  ret = ret ? ff_filter_frame(ctx->outputs[0], s->work) : AVERROR_EOF;
472  }
473 
474  ff_dlog(ctx, "request_frame() source's request_frame() returned:%d\n", ret);
475  return ret;
476 }
477 
478 static const AVFilterPad framerate_inputs[] = {
479  {
480  .name = "default",
481  .type = AVMEDIA_TYPE_VIDEO,
482  .config_props = config_input,
483  .filter_frame = filter_frame,
484  },
485  { NULL }
486 };
487 
488 static const AVFilterPad framerate_outputs[] = {
489  {
490  .name = "default",
491  .type = AVMEDIA_TYPE_VIDEO,
492  .request_frame = request_frame,
493  .config_props = config_output,
494  },
495  { NULL }
496 };
497 
499  .name = "framerate",
500  .description = NULL_IF_CONFIG_SMALL("Upsamples or downsamples progressive source between specified frame rates."),
501  .priv_size = sizeof(FrameRateContext),
502  .priv_class = &framerate_class,
503  .init = init,
504  .uninit = uninit,
506  .inputs = framerate_inputs,
507  .outputs = framerate_outputs,
509 };
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:79
int plane
Definition: avisynth_c.h:422
#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
const char * s
Definition: avisynth_c.h:768
static void blend_frames16_c(BLEND_FUNC_PARAMS)
Definition: vf_framerate.c:305
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2363
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
static int process_work_frame(AVFilterContext *ctx)
Definition: vf_framerate.c:210
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_framerate.c:265
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:94
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
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:110
int num
Numerator.
Definition: rational.h:59
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:372
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 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:311
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:96
static int flags
Definition: log.c:55
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:75
static int request_frame(AVFilterLink *outlink)
Definition: vf_framerate.c:457
#define ff_dlog(a,...)
#define AVERROR_EOF
End of file.
Definition: error.h:55
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:365
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:373
#define BLEND_FACTOR_DEPTH8
Definition: framerate.h:31
#define av_log(a,...)
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 width
Definition: frame.h:276
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:139
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
uint16_t width
Definition: gdv.c:47
simple assert() macros that are a bit more flexible than ISO C assert().
#define FRAMERATE_FLAG_SCD
Definition: vf_framerate.c:46
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:371
#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:66
common internal API header
static int blend_frames(AVFilterContext *ctx, int interpolate)
Definition: vf_framerate.c:175
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:366
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:74
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:138
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
AVFilter ff_vf_framerate
Definition: vf_framerate.c:498
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:64
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:367
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:538
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:488
static int query_formats(AVFilterContext *ctx)
Definition: vf_framerate.c:272
static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
Definition: vf_framerate.c:142
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:249
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:368
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
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:64
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:365
static av_cold int init(AVFilterContext *ctx)
Definition: vf_framerate.c:258
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:324
static int64_t pts
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:378
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:369
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:375
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:232
#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:45
uint16_t src2_factor
Definition: vf_framerate.c:139
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
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:293
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:155
AVFrame * copy_src2
Definition: vf_framerate.c:138
static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
Definition: vf_framerate.c:363
#define V
Definition: vf_framerate.c:44
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static const AVOption framerate_options[]
Definition: vf_framerate.c:48
static int config_input(AVFilterLink *inlink)
Definition: vf_framerate.c:337
A list of supported formats for one end of a filter link.
Definition: formats.h:64
#define OFFSET(x)
Definition: vf_framerate.c:43
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:254
static const AVFilterPad framerate_inputs[]
Definition: vf_framerate.c:478
An instance of a filter.
Definition: avfilter.h:338
int height
Definition: frame.h:276
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:95
void INT64 start
Definition: avisynth_c.h:690
#define av_always_inline
Definition: attributes.h:39
AVFrame * f1
current frame
Definition: framerate.h:59
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:407
static int config_output(AVFilterLink *outlink)
Definition: vf_framerate.c:412
internal API functions
int depth
Number of bits in the component.
Definition: pixdesc.h:58
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
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:652
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248