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 },
70 ff_dlog(ctx,
"get_scene_score()\n");
77 ff_dlog(ctx,
"get_scene_score() process\n");
82 ret = av_clipf(
FFMIN(mafd, diff), 0, 100.0);
85 ff_dlog(ctx,
"get_scene_score() result is:%f\n", ret);
124 double interpolate_scene_score = 0;
128 interpolate_scene_score = s->
score;
131 ff_dlog(ctx,
"blend_frames() interpolate scene score:%f\n", interpolate_scene_score);
134 if (interpolate_scene_score < s->scene_score) {
148 ff_dlog(ctx,
"blend_frames() INTERPOLATE to create work frame\n");
180 ff_dlog(ctx,
"process_work_frame() interpolate: %"PRId64
"/256\n", interpolate8);
183 }
else if (interpolate <= 0 || interpolate8 < s->interp_start) {
238 #define BLEND_FRAME_FUNC(nbits) \ 239 static void blend_frames##nbits##_c(BLEND_FUNC_PARAMS) \ 242 uint##nbits##_t *dstw = (uint##nbits##_t *)dst; \ 243 uint##nbits##_t *src1w = (uint##nbits##_t *)src1; \ 244 uint##nbits##_t *src2w = (uint##nbits##_t *)src2; \ 245 int bytes = nbits / 8; \ 247 src1_linesize /= bytes; \ 248 src2_linesize /= bytes; \ 249 dst_linesize /= bytes; \ 250 for (line = 0; line < height; line++) { \ 251 for (pixel = 0; pixel < width; pixel++) \ 252 dstw[pixel] = ((src1w[pixel] * factor1) + \ 253 (src2w[pixel] * factor2) + half) \ 254 >> BLEND_FACTOR_DEPTH(nbits); \ 255 src1w += src1_linesize; \ 256 src2w += src2_linesize; \ 257 dstw += dst_linesize; \ 265 if (s->bitdepth == 8) {
267 s->blend = blend_frames8_c;
270 s->blend = blend_frames16_c;
284 for (plane = 0; plane < 4; plane++) {
337 if (s->
f1 && pts == s->
pts1) {
385 ff_dlog(ctx,
"config_output()\n");
388 "config_output() input time base:%u/%u (%f)\n",
400 "time base:%u/%u -> %u/%u exact:%d\n",
411 "config_output() output time base:%u/%u (%f) w:%d h:%d\n",
414 outlink->
w, outlink->
h);
417 av_log(ctx,
AV_LOG_INFO,
"fps -> fps:%u/%u scene score:%f interpolate start:%d end:%d\n",
444 .description =
NULL_IF_CONFIG_SMALL(
"Upsamples or downsamples progressive source between specified frame rates."),
446 .priv_class = &framerate_class,
450 .
inputs = framerate_inputs,
int height[4]
height of each plane
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
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...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
static int process_work_frame(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
double scene_score
score that denotes a scene change has happened
double score
scene change score (f0 to f1)
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
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
int64_t pts0
last frame pts in dest_time_base
int h
agreed upon image height
static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next)
#define AV_PIX_FMT_YUV420P12
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVFILTER_DEFINE_CLASS(framerate)
int64_t pts1
current frame pts in dest_time_base
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
int interp_end
end of range to apply linear interpolation
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
static av_cold int end(AVCodecContext *avctx)
AVRational dest_frame_rate
output frames per second
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static void interpolate(float *out, float v1, float v2, int size)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
int interlaced_frame
The content of the picture is interlaced.
int flags
flags affecting frame rate conversion algorithm
#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.
#define AV_PIX_FMT_YUV422P12
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
int line_size[4]
bytes of pixel data per line for each plane
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int64_t n
output frame counter
#define BLEND_FRAME_FUNC(nbits)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
int interp_start
start of range to apply linear interpolation
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
#define FRAMERATE_FLAG_SCD
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
#define AV_PIX_FMT_YUV444P10
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
common internal API header
static int blend_frames(AVFilterContext *ctx, int interpolate)
#define AV_PIX_FMT_YUV422P9
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
double prev_mafd
previous MAFD (scene detect only)
AVFilterContext * src
source filter
AVRational srce_time_base
timebase of source
#define AV_PIX_FMT_YUV444P9
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
static const AVFilterPad outputs[]
int format
agreed upon media format
void ff_framerate_init_x86(FrameRateContext *s)
#define AV_LOG_INFO
Standard information.
static const AVFilterPad framerate_outputs[]
static int query_formats(AVFilterContext *ctx)
static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
Used for passing data between threads.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
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
#define AV_PIX_FMT_YUV420P10
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
AVRational dest_time_base
timebase of destination
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
offset must point to AVRational
const char * name
Filter name.
#define AV_PIX_FMT_YUV420P9
static av_cold int init(AVFilterContext *ctx)
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
void ff_framerate_init(FrameRateContext *s)
#define flags(name, subs,...)
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
avfilter_execute_func * execute
FF_FILTER_FORWARD_WANTED(outlink, inlink)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
ff_scene_sad_fn sad
Sum of the absolute difference function (scene detect only)
static const AVOption framerate_options[]
AVFilterContext * dst
dest filter
static int config_input(AVFilterLink *inlink)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
static const AVFilterPad framerate_inputs[]
int64_t start_pts
pts of the first output frame
int flush
1 if the filter is being flushed
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
AVFrame * f1
current frame
static int config_output(AVFilterLink *outlink)
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 depth
Number of bits in the component.
AVPixelFormat
Pixel format.
int64_t delta
pts1 to pts0 delta
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int activate(AVFilterContext *ctx)