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);
85 ff_dlog(
ctx,
"get_scene_score() result is:%f\n", ret);
101 uint16_t src1_factor =
td->src1_factor;
102 uint16_t src2_factor =
td->src2_factor;
105 for (plane = 0; plane < 4 &&
src1->data[plane] && src2->
data[plane]; plane++) {
106 const int start = (
s->height[plane] * job ) / nb_jobs;
107 const int end = (
s->height[plane] * (job+1)) / nb_jobs;
108 uint8_t *src1_data =
src1->data[plane] + start *
src1->linesize[plane];
112 s->blend(src1_data,
src1->linesize[plane], src2_data, src2->
linesize[plane],
113 dst_data, work->
linesize[plane],
s->line_size[plane], end - start,
114 src1_factor, src2_factor,
s->blend_factor_max >> 1);
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) {
136 td.copy_src1 =
s->f0;
137 td.copy_src2 =
s->f1;
139 td.src1_factor =
s->blend_factor_max -
td.src2_factor;
148 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;
240 #define BLEND_FRAME_FUNC(nbits) \
241 static void blend_frames##nbits##_c(BLEND_FUNC_PARAMS) \
244 uint##nbits##_t *dstw = (uint##nbits##_t *)dst; \
245 uint##nbits##_t *src1w = (uint##nbits##_t *)src1; \
246 uint##nbits##_t *src2w = (uint##nbits##_t *)src2; \
247 int bytes = nbits / 8; \
249 src1_linesize /= bytes; \
250 src2_linesize /= bytes; \
251 dst_linesize /= bytes; \
252 for (line = 0; line < height; line++) { \
253 for (pixel = 0; pixel < width; pixel++) \
254 dstw[pixel] = ((src1w[pixel] * factor1) + \
255 (src2w[pixel] * factor2) + half) \
256 >> BLEND_FACTOR_DEPTH(nbits); \
257 src1w += src1_linesize; \
258 src2w += src2_linesize; \
259 dstw += dst_linesize; \
267 if (
s->bitdepth == 8) {
269 s->blend = blend_frames8_c;
272 s->blend = blend_frames16_c;
286 for (plane = 0; plane < 4; plane++) {
288 s->height[plane] = inlink->
h >> ((plane == 1 || plane == 2) ?
s->vsub : 0);
339 if (
s->f1 &&
pts ==
s->pts1) {
351 s->delta =
s->pts1 -
s->pts0;
356 s->start_pts =
s->pts1;
362 s->start_pts =
s->pts1;
390 "config_output() input time base:%u/%u (%f)\n",
391 ctx->inputs[0]->time_base.num,
ctx->inputs[0]->time_base.den,
396 exact =
av_reduce(&
s->dest_time_base.num, &
s->dest_time_base.den,
398 (
int64_t)
s->srce_time_base.den *
s->dest_frame_rate.den ),
399 (
int64_t)
s->srce_time_base.den *
s->dest_frame_rate.num, INT_MAX);
402 "time base:%u/%u -> %u/%u exact:%d\n",
403 s->srce_time_base.num,
s->srce_time_base.den,
404 s->dest_time_base.num,
s->dest_time_base.den, exact);
413 "config_output() output time base:%u/%u (%f) w:%d h:%d\n",
416 outlink->
w, outlink->
h);
420 s->dest_frame_rate.num,
s->dest_frame_rate.den,
421 s->scene_score,
s->interp_start,
s->interp_end);
446 .description =
NULL_IF_CONFIG_SMALL(
"Upsamples or downsamples progressive source between specified frame rates."),
448 .priv_class = &framerate_class,
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Main libavfilter public API header.
#define flags(name, subs,...)
static __device__ float fabs(float a)
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
void ff_framerate_init_x86(FrameRateContext *s)
#define BLEND_FACTOR_DEPTH(n)
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
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.
#define AV_NOPTS_VALUE
Undefined timestamp value.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV420P9
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ 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...
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define AV_PIX_FMT_YUV444P10
ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
int depth
Number of bits in the component.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
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).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int interlaced_frame
The content of the picture is interlaced.
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...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Used for passing data between threads.
static void interpolate(float *out, float v1, float v2, int size)
static int blend_frames(AVFilterContext *ctx, int interpolate)
#define FRAMERATE_FLAG_SCD
static int process_work_frame(AVFilterContext *ctx)
static const AVOption framerate_options[]
static int query_formats(AVFilterContext *ctx)
static int config_input(AVFilterLink *inlink)
AVFILTER_DEFINE_CLASS(framerate)
void ff_framerate_init(FrameRateContext *s)
static const AVFilterPad framerate_outputs[]
static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next)
static int activate(AVFilterContext *ctx)
static av_cold int init(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static const AVFilterPad framerate_inputs[]
static int config_output(AVFilterLink *outlink)
#define BLEND_FRAME_FUNC(nbits)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.