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,
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_mpdecimate
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_VERBOSE
Detailed information.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS_ARRAY(array)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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 enum AVPixelFormat pix_fmts[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
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])
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_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A 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_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ 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_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ 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...
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
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 linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
float frac
threshold of changed pixels over the total fraction
AVFrame * ref
reference picture
int max_drop_count
for mode 0: if positive: maximum number of sequential frames to drop for mode 0: if negative: minimum...
int dup_count
for mode 1: number of duplicated frames
int min_dup_count
for mode 1: minimum number of previous frames that need to be duplicated to keep frame
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
av_pixelutils_sad_fn sad
sum of absolute difference function
int max_keep_count
for mode 0: number of similar frames to ignore before to start dropping them
int hi
lower and higher threshold number of differences values for 8x8 blocks
int keep_count
for mode 0: number of similar frames already ignored
int vsub
chroma subsampling values
static int ref[MAX_W *MAX_W]
static AVFormatContext * ctx
timestamp utils, mostly useful for debugging/logging purposes
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static const AVOption mpdecimate_options[]
@ DECIMATE_KEEP_NO_UPDATE
keep frame without updating reference (similar frame under keep threshold, or forced keep due to max_...
@ DECIMATE_KEEP_UPDATE
keep frame and update reference (frame is different, or first frame)
@ DECIMATE_DROP
similar frame, past keep threshold — drop it
static int filter_frame(AVFilterLink *inlink, AVFrame *cur)
static int config_input(AVFilterLink *inlink)
static int filter_frame_mode_1(AVFilterLink *inlink, AVFrame *cur)
static const AVFilterPad mpdecimate_inputs[]
static int filter_frame_mode_0(AVFilterLink *inlink, AVFrame *cur)
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.
static av_cold void uninit(AVFilterContext *ctx)
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...
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.