Go to the documentation of this file.
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
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 },
100 uint16_t src1_factor =
td->src1_factor;
101 uint16_t src2_factor =
td->src2_factor;
104 for (plane = 0; plane < 4 &&
src1->data[plane] &&
src2->data[plane]; plane++) {
105 const int start = (
s->height[plane] * job ) / nb_jobs;
106 const int end = (
s->height[plane] * (job+1)) / nb_jobs;
107 uint8_t *src1_data =
src1->data[plane] + start *
src1->linesize[plane];
108 uint8_t *src2_data =
src2->data[plane] + start *
src2->linesize[plane];
109 uint8_t *dst_data =
work->data[plane] + start *
work->linesize[plane];
111 s->blend(src1_data,
src1->linesize[plane], src2_data,
src2->linesize[plane],
112 dst_data,
work->linesize[plane],
s->line_size[plane], end - start,
113 src1_factor, src2_factor,
s->blend_factor_max >> 1);
123 double interpolate_scene_score = 0;
127 interpolate_scene_score =
s->score;
130 ff_dlog(
ctx,
"blend_frames() interpolate scene score:%f\n", interpolate_scene_score);
133 if (interpolate_scene_score < s->scene_score) {
135 td.copy_src1 =
s->f0;
136 td.copy_src2 =
s->f1;
138 td.src1_factor =
s->blend_factor_max -
td.src2_factor;
147 ff_dlog(
ctx,
"blend_frames() INTERPOLATE to create work frame\n");
164 if (!
s->f0 && !
s->flush)
169 if (work_pts >=
s->pts1 && !
s->flush)
177 if (work_pts >=
s->pts1 +
s->delta &&
s->flush)
181 interpolate8 =
av_rescale(work_pts -
s->pts0, 256,
s->delta);
182 ff_dlog(
ctx,
"process_work_frame() interpolate: %"PRId64
"/256\n", interpolate8);
183 if (
interpolate >=
s->blend_factor_max || interpolate8 >
s->interp_end) {
185 }
else if (
interpolate <= 0 || interpolate8 < s->interp_start) {
199 s->work->pts = work_pts;
232 #define BLEND_FRAME_FUNC(nbits) \
233 static void blend_frames##nbits##_c(BLEND_FUNC_PARAMS) \
236 uint##nbits##_t *dstw = (uint##nbits##_t *)dst; \
237 uint##nbits##_t *src1w = (uint##nbits##_t *)src1; \
238 uint##nbits##_t *src2w = (uint##nbits##_t *)src2; \
239 int bytes = nbits / 8; \
241 src1_linesize /= bytes; \
242 src2_linesize /= bytes; \
243 dst_linesize /= bytes; \
244 for (line = 0; line < height; line++) { \
245 for (pixel = 0; pixel < width; pixel++) \
246 dstw[pixel] = ((src1w[pixel] * factor1) + \
247 (src2w[pixel] * factor2) + half) \
248 >> BLEND_FACTOR_DEPTH(nbits); \
249 src1w += src1_linesize; \
250 src2w += src2_linesize; \
251 dstw += dst_linesize; \
259 if (
s->bitdepth == 8) {
261 s->blend = blend_frames8_c;
264 s->blend = blend_frames16_c;
279 for (plane = 0; plane < 4; plane++) {
281 s->height[plane] =
inlink->h >> ((plane == 1 || plane == 2) ?
s->vsub : 0);
290 s->srce_time_base =
inlink->time_base;
332 if (
s->f1 &&
pts ==
s->pts1) {
344 s->delta =
s->pts1 -
s->pts0;
349 s->start_pts =
s->pts1;
355 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
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
offset must point to AVRational
#define FILTER_PIXFMTS_ARRAY(array)
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.
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.
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.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
#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_INPUTS(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 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
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)
#define FILTER_OUTPUTS(array)
@ 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)
#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[]
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static int config_output(AVFilterLink *outlink)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.