27 #include "libavutil/opt.h"
28 #include "libavutil/pixdesc.h"
29 #include "libavutil/timestamp.h"
55 #define OFFSET(x) offsetof(DecimateContext, x)
56 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
59 {
"max",
"set the maximum number of consecutive dropped frames (positive), or the minimum interval between dropped frames (negative)",
81 int t = (w/16)*(h/16)*decimate->
frac;
85 for (y = 0; y < h-7; y += 4) {
86 for (x = 8; x < w-7; x += 4) {
89 ref+x+y*linesize, linesize);
93 if (d > decimate->
lo) {
120 for (plane = 0; ref->
data[plane] && ref->
linesize[plane]; plane++) {
121 int vsub = plane == 1 || plane == 2 ? decimate->
vsub : 0;
122 int hsub = plane == 1 || plane == 2 ? decimate->
hsub : 0;
141 if (!decimate->
avctx)
152 if (decimate->
avctx) {
204 "%s pts:%s pts_time:%s drop_count:%d\n",
223 }
while (decimate->
drop_count > 0 && ret >= 0);
248 .
name =
"mpdecimate",
253 .priv_class = &mpdecimate_class,
255 .
inputs = mpdecimate_inputs,
AVFrame * ref
reference picture
static const AVFilterPad mpdecimate_inputs[]
This structure describes decoded (raw) audio or video data.
const char * name
Filter name.
void * priv
private data for use by the filter
static const AVFilterPad outputs[]
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int(* sum_abs_dctelem)(int16_t *block)
static int filter_frame(AVFilterLink *inlink, AVFrame *cur)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
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.
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.
static const AVOption mpdecimate_options[]
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define FF_CEIL_RSHIFT(a, b)
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define AV_LOG_VERBOSE
Detailed information.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
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.
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
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.
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
AVFilterContext * src
source filter
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVPixelFormat
Pixel format.
AVFilter avfilter_vf_mpdecimate
int format
agreed upon media format
Main libavfilter public API header.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
AVFilterLink ** outputs
array of pointers to output links
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static av_cold void uninit(AVFilterContext *ctx)
AVCodecContext * avctx
codec context required for the DSPContext
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
void(* diff_pixels)(int16_t *block, const uint8_t *s1, const uint8_t *s2, int stride)
Describe the class of an AVClass context structure.
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad inputs[]
AVFilterLink ** inputs
array of pointers to input links
int vsub
chroma subsampling values
static int request_frame(AVFilterLink *outlink)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static const AVFilterPad mpdecimate_outputs[]
AVFilterContext * dst
dest filter
int drop_count
if positive: number of frames sequentially dropped if negative: number of sequential frames which wer...
AVFrame * av_frame_clone(AVFrame *src)
Create a new frame that references the same data as src.
static av_cold int init(AVFilterContext *ctx)
#define AVFILTER_DEFINE_CLASS(fname)
static int config_input(AVFilterLink *inlink)
DSPContext dspctx
context providing optimized diff routines
av_cold void avpriv_dsputil_init(DSPContext *c, AVCodecContext *avctx)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static int diff_planes(AVFilterContext *ctx, uint8_t *cur, uint8_t *ref, int linesize, int w, int h)
Return 1 if the two planes are different, 0 otherwise.