FFmpeg
Loading...
Searching...
No Matches
vf_mpdecimate.c File Reference
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixelutils.h"
#include "libavutil/timestamp.h"
#include "avfilter.h"
#include "filters.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  DecimateContext
 

Macros

#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Enumerations

enum  DecimateResult { DECIMATE_DROP , DECIMATE_KEEP_UPDATE , DECIMATE_KEEP_NO_UPDATE }
 

Functions

 AVFILTER_DEFINE_CLASS (mpdecimate)
 
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 int is_frame_different (AVFilterContext *ctx, AVFrame *cur, AVFrame *ref)
 Tell if the frame is different with respect to the reference frame ref.
 
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 reference frame ref.
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame_mode_0 (AVFilterLink *inlink, AVFrame *cur)
 
static int filter_frame_mode_1 (AVFilterLink *inlink, AVFrame *cur)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *cur)
 

Variables

static const AVOption mpdecimate_options []
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad mpdecimate_inputs []
 
const FFFilter ff_vf_mpdecimate
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 67 of file vf_mpdecimate.c.

◆ FLAGS

Definition at line 68 of file vf_mpdecimate.c.

Enumeration Type Documentation

◆ DecimateResult

Enumerator
DECIMATE_DROP 

similar frame, past keep threshold — drop it

DECIMATE_KEEP_UPDATE 

keep frame and update reference (frame is different, or first frame)

DECIMATE_KEEP_NO_UPDATE 

keep frame without updating reference (similar frame under keep threshold, or forced keep due to max_drop_count)

Definition at line 36 of file vf_mpdecimate.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( mpdecimate )

◆ diff_planes()

static int diff_planes ( AVFilterContext * ctx,
uint8_t * cur,
int cur_linesize,
uint8_t * ref,
int ref_linesize,
int w,
int h )
static

Return 1 if the two planes are different, 0 otherwise.

Definition at line 89 of file vf_mpdecimate.c.

Referenced by is_frame_different().

◆ is_frame_different()

static int is_frame_different ( AVFilterContext * ctx,
AVFrame * cur,
AVFrame * ref )
static

Tell if the frame is different with respect to the reference frame ref.

Definition at line 126 of file vf_mpdecimate.c.

Referenced by decimate_frame(), and filter_frame_mode_1().

◆ decimate_frame()

static DecimateResult decimate_frame ( AVFilterContext * ctx,
AVFrame * cur,
AVFrame * ref )
static

Tell if the frame should be decimated, for example if it is no much different with respect to the reference frame ref.

Definition at line 155 of file vf_mpdecimate.c.

Referenced by filter_frame_mode_0().

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 180 of file vf_mpdecimate.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 199 of file vf_mpdecimate.c.

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 221 of file vf_mpdecimate.c.

◆ filter_frame_mode_0()

static int filter_frame_mode_0 ( AVFilterLink * inlink,
AVFrame * cur )
static

Definition at line 232 of file vf_mpdecimate.c.

Referenced by filter_frame().

◆ filter_frame_mode_1()

static int filter_frame_mode_1 ( AVFilterLink * inlink,
AVFrame * cur )
static

Definition at line 281 of file vf_mpdecimate.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * cur )
static

Definition at line 325 of file vf_mpdecimate.c.

Variable Documentation

◆ mpdecimate_options

const AVOption mpdecimate_options[]
static
Initial value:
= {
{ "max", "for mode 0: set the maximum number of consecutive dropped frames (positive), or the minimum interval between dropped frames (negative)",
OFFSET(max_drop_count), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGS },
{ "keep", "for mode 0: set the number of similar consecutive frames to be kept before starting to drop similar frames",
OFFSET(max_keep_count), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
{ "hi", "set high dropping threshold", OFFSET(hi), AV_OPT_TYPE_INT, {.i64=64*12}, INT_MIN, INT_MAX, FLAGS },
{ "lo", "set low dropping threshold", OFFSET(lo), AV_OPT_TYPE_INT, {.i64=64*5}, INT_MIN, INT_MAX, FLAGS },
{ "frac", "set fraction dropping threshold", OFFSET(frac), AV_OPT_TYPE_FLOAT, {.dbl=0.33}, 0, 1, FLAGS },
{ "mode", "0: drop similar frames, 1: drop similar and unique frames", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS },
{ "min", "for mode 1: set minimum number of previous frames that need to be duplicated to keep current frame",
OFFSET(min_dup_count), AV_OPT_TYPE_INT, {.i64=1}, 1, INT_MAX, FLAGS },
{ NULL }
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
mode
Use these values in ebur128_init (or'ed).
Definition ebur128.h:83
#define OFFSET(x)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270

Definition at line 70 of file vf_mpdecimate.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition pixfmt.h:108
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition pixfmt.h:107
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition pixfmt.h:174
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition pixfmt.h:86
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition pixfmt.h:173
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition pixfmt.h:87
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition pixfmt.h:85

Definition at line 205 of file vf_mpdecimate.c.

◆ mpdecimate_inputs

const AVFilterPad mpdecimate_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
}
static int config_input(AVFilterLink *inlink)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 331 of file vf_mpdecimate.c.

◆ ff_vf_mpdecimate

const FFFilter ff_vf_mpdecimate
Initial value:
= {
.p.name = "mpdecimate",
.p.description = NULL_IF_CONFIG_SMALL("Remove near-duplicate frames."),
.p.priv_class = &mpdecimate_class,
.init = init,
.uninit = uninit,
.priv_size = sizeof(DecimateContext),
}
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
static const AVFilterPad mpdecimate_inputs[]
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition video.c:37

Definition at line 340 of file vf_mpdecimate.c.