Go to the documentation of this file.
67 #define OFFSET(x) offsetof(DecimateContext, x)
68 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
71 {
"max",
"for mode 0: set the maximum number of consecutive dropped frames (positive), or the minimum interval between dropped frames (negative)",
73 {
"keep",
"for mode 0: set the number of similar consecutive frames to be kept before starting to drop similar frames",
79 {
"min",
"for mode 1: set minimum number of previous frames that need to be duplicated to keep current frame",
90 uint8_t *cur,
int cur_linesize,
91 uint8_t *
ref,
int ref_linesize,
98 int t = (
w/16)*(
h/16)*decimate->
frac;
101 for (y = 0; y <
h-7; y += 4) {
102 for (x = 8; x <
w-7; x += 4) {
103 d = decimate->
sad(cur + y*cur_linesize + x, cur_linesize,
104 ref + y*ref_linesize + x, ref_linesize);
105 if (d > decimate->
hi) {
109 if (d > decimate->
lo) {
132 for (plane = 0;
ref->data[plane] &&
ref->linesize[plane]; plane++) {
138 int vsub = plane == 1 || plane == 2 ? decimate->
vsub : 0;
139 int hsub = plane == 1 || plane == 2 ? decimate->
hsub : 0;
142 ref->data[plane],
ref->linesize[plane],
188 if (decimate->
mode == 1) {
263 "%s pts:%s pts_time:%s drop_count:%d keep_count:%d\n",
302 "%s pts:%s pts_time:%s dup_count:%d\n",
341 .
p.
name =
"mpdecimate",
343 .p.priv_class = &mpdecimate_class,
AVPixelFormat
Pixel format.
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)
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.
int(* av_pixelutils_sad_fn)(const uint8_t *src1, ptrdiff_t stride1, const uint8_t *src2, ptrdiff_t stride2)
Sum of abs(src1[x] - src2[x])
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).
static int filter_frame_mode_0(AVFilterLink *inlink, AVFrame *cur)
#define AV_LOG_VERBOSE
Detailed information.
int vsub
chroma subsampling values
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int drop_count
if positive: number of frames sequentially dropped if negative: number of sequential frames which wer...
int mode
0: drop similar frames, 1: drop similar and unique frames
static int config_input(AVFilterLink *inlink)
#define FILTER_PIXFMTS_ARRAY(array)
int keep_count
for mode 0: number of similar frames already ignored
A filter pad used for either input or output.
av_pixelutils_sad_fn av_pixelutils_get_sad_fn(int w_bits, int h_bits, int aligned, void *log_ctx)
Get a potentially optimized pointer to a Sum-of-absolute-differences function (see the av_pixelutils_...
static int is_frame_different(AVFilterContext *ctx, AVFrame *cur, AVFrame *ref)
Tell if the frame is different with respect to the reference frame ref.
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
static int filter_frame(AVFilterLink *inlink, AVFrame *cur)
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame_mode_1(AVFilterLink *inlink, AVFrame *cur)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static AVFormatContext * ctx
static enum AVPixelFormat pix_fmts[]
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static DecimateResult decimate_frame(AVFilterContext *ctx, AVFrame *cur, AVFrame *ref)
Tell if the frame should be decimated, for example if it is no much different with respect to the ref...
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Describe the class of an AVClass context structure.
and forward the result(frame or status change) to the corresponding input. If nothing is possible
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
int min_dup_count
for mode 1: minimum number of previous frames that need to be duplicated to keep frame
AVFrame * ref
reference picture
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const AVOption mpdecimate_options[]
static av_cold int init(AVFilterContext *ctx)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
av_pixelutils_sad_fn sad
sum of absolute difference function
int max_drop_count
for mode 0: if positive: maximum number of sequential frames to drop for mode 0: if negative: minimum...
@ DECIMATE_KEEP_NO_UPDATE
keep frame without updating reference (similar frame under keep threshold, or forced keep due to max_...
float frac
threshold of changed pixels over the total fraction
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
const char * name
Pad name.
int hi
lower and higher threshold number of differences values for 8x8 blocks
const FFFilter ff_vf_mpdecimate
AVFILTER_DEFINE_CLASS(mpdecimate)
#define FILTER_INPUTS(array)
int max_keep_count
for mode 0: number of similar frames to ignore before to start dropping them
@ AV_OPT_TYPE_INT
Underlying C type is int.
static int ref[MAX_W *MAX_W]
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
AVFilter p
The public AVFilter.
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int dup_count
for mode 1: number of duplicated frames
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
@ DECIMATE_KEEP_UPDATE
keep frame and update reference (frame is different, or first frame)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static const AVFilterPad mpdecimate_inputs[]
static av_cold void uninit(AVFilterContext *ctx)
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)
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
@ DECIMATE_DROP
similar frame, past keep threshold — drop it
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
static int diff_planes(AVFilterContext *ctx, uint8_t *cur, int cur_linesize, uint8_t *ref, int ref_linesize, int w, int h)
Return 1 if the two planes are different, 0 otherwise.