54 #define OFFSET(x) offsetof(DecimateContext, x)
55 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
58 {
"max",
"set the maximum number of consecutive dropped frames (positive), or the minimum interval between dropped frames (negative)",
80 int t = (w/16)*(h/16)*decimate->
frac;
83 for (y = 0; y < h-7; y += 4) {
84 for (x = 8; x < w-7; x += 4) {
85 d = decimate->
sad(cur + y*cur_linesize + x, cur_linesize,
86 ref + y*ref_linesize + x, ref_linesize);
87 if (d > decimate->
hi) {
91 if (d > decimate->
lo) {
128 int vsub = plane == 1 || plane == 2 ? decimate->
vsub : 0;
129 int hsub = plane == 1 || plane == 2 ? decimate->
hsub : 0;
216 "%s pts:%s pts_time:%s drop_count:%d\n",
235 }
while (decimate->
drop_count > 0 && ret >= 0);
260 .
name =
"mpdecimate",
265 .priv_class = &mpdecimate_class,
267 .
inputs = mpdecimate_inputs,
AVFrame * ref
reference picture
static const AVFilterPad mpdecimate_inputs[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static const AVFilterPad outputs[]
Main libavfilter public API header.
static int filter_frame(AVFilterLink *inlink, AVFrame *cur)
AVFILTER_DEFINE_CLASS(mpdecimate)
float frac
threshold of changed pixels over the total fraction
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
av_pixelutils_sad_fn sad
sum of absolute difference function
int max_drop_count
if positive: maximum number of sequential frames to drop if negative: minimum number of frames betwee...
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int hi
lower and higher threshold number of differences values for 8x8 blocks
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
timestamp utils, mostly useful for debugging/logging purposes
static const AVOption mpdecimate_options[]
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
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...
#define AV_LOG_VERBOSE
Detailed information.
static int 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...
A filter pad used for either input or output.
A link between two filters.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
int width
width and height of the video frame
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#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. ...
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
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])
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define FF_CEIL_RSHIFT(a, b)
AVFilterContext * src
source filter
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int format
agreed upon media format
static av_cold void uninit(AVFilterContext *ctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
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_...
Describe the class of an AVClass context structure.
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad inputs[]
int vsub
chroma subsampling values
static int request_frame(AVFilterLink *outlink)
const char * name
Filter name.
static const AVFilterPad mpdecimate_outputs[]
AVFilterLink ** outputs
array of pointers to output links
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.
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...
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static av_cold int init(AVFilterContext *ctx)
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)
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
AVFilterContext * dst
dest filter
AVFilter ff_vf_mpdecimate
static int config_input(AVFilterLink *inlink)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
AVPixelFormat
Pixel format.