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 },
80 mafd = (double)sad * 100.0 / (crnt->
width * crnt->
height) / (1 <<
s->bitdepth);
81 diff = fabs(mafd -
s->prev_mafd);
98 uint16_t src1_factor =
td->src1_factor;
99 uint16_t src2_factor =
td->src2_factor;
103 int cpy_line_width =
s->line_size[
plane];
105 int cpy_src1_line_size =
td->copy_src1->linesize[
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);
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;
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,
121 src1_factor, src2_factor,
s->blend_factor_max >> 1);
131 double interpolate_scene_score = 0;
135 interpolate_scene_score =
s->score;
138 ff_dlog(
ctx,
"blend_frames() interpolate scene score:%f\n", interpolate_scene_score);
141 if (interpolate_scene_score < s->scene_score) {
143 td.copy_src1 =
s->f0;
144 td.copy_src2 =
s->f1;
146 td.src1_factor =
s->blend_factor_max -
td.src2_factor;
155 ff_dlog(
ctx,
"blend_frames() INTERPOLATE to create work frame\n");
171 if (!
s->f0 && !
s->flush)
176 if (work_pts >=
s->pts1 && !
s->flush)
182 if (work_pts >=
s->pts1 +
s->delta &&
s->flush)
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) {
190 }
else if (
interpolate <= 0 || interpolate8 < s->interp_start) {
204 s->work->pts = work_pts;
251 src1 += src1_linesize;
252 src2 += src2_linesize;
260 uint16_t *dstw = (uint16_t *)dst;
261 uint16_t *src1w = (uint16_t *)
src1;
262 uint16_t *src2w = (uint16_t *)src2;
270 src1w += src1_linesize;
271 src2w += src2_linesize;
272 dstw += dst_linesize;
278 if (
s->bitdepth == 8) {
308 s->srce_time_base =
inlink->time_base;
350 if (
s->f1 &&
pts ==
s->pts1) {
362 s->delta =
s->pts1 -
s->pts0;
367 s->start_pts =
s->pts1;
373 s->start_pts =
s->pts1;
401 "config_output() input time base:%u/%u (%f)\n",
402 ctx->inputs[0]->time_base.num,
ctx->inputs[0]->time_base.den,
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);
413 "time base:%u/%u -> %u/%u exact:%d\n",
414 s->srce_time_base.num,
s->srce_time_base.den,
415 s->dest_time_base.num,
s->dest_time_base.den, exact);
424 "config_output() output time base:%u/%u (%f) w:%d h:%d\n",
427 outlink->
w, outlink->
h);
431 s->dest_frame_rate.num,
s->dest_frame_rate.den,
432 s->scene_score,
s->interp_start,
s->interp_end);
457 .description =
NULL_IF_CONFIG_SMALL(
"Upsamples or downsamples progressive source between specified frame rates."),
459 .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.
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
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
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.
static av_cold int end(AVCodecContext *avctx)
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)
static void blend_frames16_c(BLEND_FUNC_PARAMS)
const char * name
Filter name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
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
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 BLEND_FACTOR_DEPTH8
#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.
static const AVFilterPad outputs[]
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_YUV420P9
#define BLEND_FACTOR_DEPTH16
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)
@ 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)
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...
static int query_formats(AVFilterContext *ctx)
#define AV_PIX_FMT_YUV422P10
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
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
#define BLEND_FUNC_PARAMS
static av_cold int init(AVFilterContext *ctx)
#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
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 interlaced_frame
The content of the picture is interlaced.
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.
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_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_always_inline int diff(const uint32_t a, const uint32_t b)
static void blend_frames_c(BLEND_FUNC_PARAMS)
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)
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const AVOption framerate_options[]
static int config_output(AVFilterLink *outlink)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
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