Go to the documentation of this file.
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
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 },
103 for (plane = 0; plane < 4 &&
src1->data[plane] &&
src2->data[plane]; plane++) {
104 const int start = (
s->height[plane] * job ) / nb_jobs;
105 const int end = (
s->height[plane] * (job+1)) / nb_jobs;
106 uint8_t *src1_data =
src1->data[plane] + start *
src1->linesize[plane];
107 uint8_t *src2_data =
src2->data[plane] + start *
src2->linesize[plane];
108 uint8_t *dst_data =
work->data[plane] + start *
work->linesize[plane];
110 s->blend(src1_data,
src1->linesize[plane], src2_data,
src2->linesize[plane],
111 dst_data,
work->linesize[plane],
s->line_size[plane], end - start,
112 src1_factor, src2_factor,
s->blend_factor_max >> 1);
122 double interpolate_scene_score = 0;
126 interpolate_scene_score =
s->score;
129 ff_dlog(
ctx,
"blend_frames() interpolate scene score:%f\n", interpolate_scene_score);
132 if (interpolate_scene_score < s->scene_score) {
146 ff_dlog(
ctx,
"blend_frames() INTERPOLATE to create work frame\n");
163 if (!
s->f0 && !
s->flush)
168 if (work_pts >=
s->pts1 && !
s->flush)
176 if (work_pts >=
s->pts1 +
s->delta &&
s->flush)
180 interpolate8 =
av_rescale(work_pts -
s->pts0, 256,
s->delta);
181 ff_dlog(
ctx,
"process_work_frame() interpolate: %"PRId64
"/256\n", interpolate8);
182 if (
interpolate >=
s->blend_factor_max || interpolate8 >
s->interp_end) {
184 }
else if (
interpolate <= 0 || interpolate8 < s->interp_start) {
198 s->work->pts = work_pts;
231 #define BLEND_FRAME_FUNC(nbits) \
232 static void blend_frames##nbits##_c(BLEND_FUNC_PARAMS) \
235 uint##nbits##_t *dstw = (uint##nbits##_t *)dst; \
236 uint##nbits##_t *src1w = (uint##nbits##_t *)src1; \
237 uint##nbits##_t *src2w = (uint##nbits##_t *)src2; \
238 int bytes = nbits / 8; \
240 src1_linesize /= bytes; \
241 src2_linesize /= bytes; \
242 dst_linesize /= bytes; \
243 for (line = 0; line < height; line++) { \
244 for (pixel = 0; pixel < width; pixel++) \
245 dstw[pixel] = ((src1w[pixel] * factor1) + \
246 (src2w[pixel] * factor2) + half) \
247 >> BLEND_FACTOR_DEPTH(nbits); \
248 src1w += src1_linesize; \
249 src2w += src2_linesize; \
250 dstw += dst_linesize; \
258 if (
s->bitdepth == 8) {
260 s->blend = blend_frames8_c;
263 s->blend = blend_frames16_c;
278 for (plane = 0; plane < 4; plane++) {
280 s->height[plane] =
inlink->h >> ((plane == 1 || plane == 2) ?
s->vsub : 0);
289 s->srce_time_base =
inlink->time_base;
331 if (
s->f1 &&
pts ==
s->pts1) {
343 s->delta =
s->pts1 -
s->pts0;
348 s->start_pts =
s->pts1;
354 s->start_pts =
s->pts1;
383 "config_output() input time base:%u/%u (%f)\n",
384 ctx->inputs[0]->time_base.num,
ctx->inputs[0]->time_base.den,
389 exact =
av_reduce(&
s->dest_time_base.num, &
s->dest_time_base.den,
391 (
int64_t)
s->srce_time_base.den *
s->dest_frame_rate.den ),
392 (
int64_t)
s->srce_time_base.den *
s->dest_frame_rate.num, INT_MAX);
395 "time base:%u/%u -> %u/%u exact:%d\n",
396 s->srce_time_base.num,
s->srce_time_base.den,
397 s->dest_time_base.num,
s->dest_time_base.den, exact);
406 "config_output() output time base:%u/%u (%f) w:%d h:%d\n",
409 outlink->
w, outlink->
h);
413 s->dest_frame_rate.num,
s->dest_frame_rate.den,
414 s->scene_score,
s->interp_start,
s->interp_end);
437 .description =
NULL_IF_CONFIG_SMALL(
"Upsamples or downsamples progressive source between specified frame rates."),
439 .priv_class = &framerate_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next)
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
#define FILTER_PIXFMTS_ARRAY(array)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
static int process_work_frame(AVFilterContext *ctx)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int depth
Number of bits in the component.
#define AV_PIX_FMT_YUV420P10
static int activate(AVFilterContext *ctx)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
const char * name
Filter name.
A link between two filters.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
AVFILTER_DEFINE_CLASS(framerate)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Link properties exposed to filter code, but not external callers.
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
#define FRAMERATE_FLAG_SCD
#define AV_PIX_FMT_YUV422P9
#define BLEND_FACTOR_DEPTH(n)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
static int blend_frames(AVFilterContext *ctx, int interpolate)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AV_PIX_FMT_YUV420P9
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
static __device__ float fabs(float a)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
must be printed separately If there s no standard function for printing the type you the WRITE_1D_FUNC_ARGV macro is a very quick way to create one See libavcodec dv_tablegen c for an example The h file This file should the initialization functions should not do and instead of the variable declarations the generated *_tables h file should be included Since that will be generated in the build the path must be i e not Makefile changes To make the automatic table creation work
const AVFilter ff_vf_framerate
#define AV_PIX_FMT_YUV422P10
#define BLEND_FRAME_FUNC(nbits)
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
static FilterLink * ff_filter_link(AVFilterLink *link)
static av_cold int init(AVFilterContext *ctx)
static enum AVPixelFormat pix_fmts[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_YUV422P12
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_PIX_FMT_YUV444P12
static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
AVFilterContext * src
source filter
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
FF_FILTER_FORWARD_WANTED(outlink, inlink)
static void interpolate(float *out, float v1, float v2, int size)
#define AV_LOG_INFO
Standard information.
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.
int w
agreed upon image width
static const AVFilterPad framerate_outputs[]
void ff_framerate_init(FrameRateContext *s)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Used for passing data between threads.
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
const char * name
Pad name.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_PIX_FMT_YUV444P9
static int config_input(AVFilterLink *inlink)
#define AV_PIX_FMT_YUV420P12
int h
agreed upon image height
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
@ AV_OPT_TYPE_INT
Underlying C type is int.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static const AVFilterPad framerate_inputs[]
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static av_cold void uninit(AVFilterContext *ctx)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
void ff_framerate_init_x86(FrameRateContext *s)
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const AVOption framerate_options[]
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
static int config_output(AVFilterLink *outlink)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.