FFmpeg
Data Structures | Macros | Functions | Variables
vf_cropdetect.c File Reference

border detection filter Ported from MPlayer libmpcodecs/vf_cropdetect.c. More...

#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  CropDetectContext
 

Macros

#define SET_META(key, value)   av_dict_set_int(metadata, key, value, 0)
 
#define FIND(DST, FROM, NOEND, INC, STEP0, STEP1, LEN)
 
#define OFFSET(x)   offsetof(CropDetectContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

static int query_formats (AVFilterContext *ctx)
 
static int checkline (void *ctx, const unsigned char *src, int stride, int len, int bpp)
 
static av_cold int init (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
 AVFILTER_DEFINE_CLASS (cropdetect)
 

Variables

static const AVOption cropdetect_options []
 
static const AVFilterPad avfilter_vf_cropdetect_inputs []
 
static const AVFilterPad avfilter_vf_cropdetect_outputs []
 
AVFilter ff_vf_cropdetect
 

Detailed Description

border detection filter Ported from MPlayer libmpcodecs/vf_cropdetect.c.

Definition in file vf_cropdetect.c.

Macro Definition Documentation

#define SET_META (   key,
  value 
)    av_dict_set_int(metadata, key, value, 0)

Definition at line 157 of file vf_cropdetect.c.

Referenced by filter_frame().

#define FIND (   DST,
  FROM,
  NOEND,
  INC,
  STEP0,
  STEP1,
  LEN 
)
Value:
outliers = 0;\
for (last_y = y = FROM; NOEND; y = y INC) {\
if (checkline(ctx, frame->data[0] + STEP0 * y, STEP1, LEN, bpp) > limit) {\
if (++outliers > s->max_outliers) { \
DST = last_y;\
break;\
}\
} else\
last_y = y INC;\
}
AVFormatContext * ctx
Definition: movenc.c:48
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define s(width, name)
Definition: cbs_vp9.c:257
if(ret)
#define LEN
#define DST(x, y)
for(j=16;j >0;--j)
static int checkline(void *ctx, const unsigned char *src, int stride, int len, int bpp)
Definition: vf_cropdetect.c:71

Referenced by filter_frame().

#define OFFSET (   x)    offsetof(CropDetectContext, x)

Definition at line 243 of file vf_cropdetect.c.

Definition at line 244 of file vf_cropdetect.c.

Function Documentation

static int query_formats ( AVFilterContext ctx)
static

Definition at line 46 of file vf_cropdetect.c.

static int checkline ( void ctx,
const unsigned char *  src,
int  stride,
int  len,
int  bpp 
)
static

Definition at line 71 of file vf_cropdetect.c.

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 126 of file vf_cropdetect.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 138 of file vf_cropdetect.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 160 of file vf_cropdetect.c.

AVFILTER_DEFINE_CLASS ( cropdetect  )

Variable Documentation

const AVOption cropdetect_options[]
static
Initial value:
= {
{ "limit", "Threshold below which the pixel is considered black", OFFSET(limit), AV_OPT_TYPE_FLOAT, { .dbl = 24.0/255 }, 0, 65535, FLAGS },
{ "round", "Value by which the width/height should be divisible", OFFSET(round), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, INT_MAX, FLAGS },
{ "reset", "Recalculate the crop area after this many frames", OFFSET(reset_count), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
{ "reset_count", "Recalculate the crop area after this many frames",OFFSET(reset_count),AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX, FLAGS },
{ "max_outliers", "Threshold count of outliers", OFFSET(max_outliers),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
{ NULL }
}
#define NULL
Definition: coverity.c:32
static av_always_inline av_const double round(double x)
Definition: libm.h:444
#define FLAGS
#define OFFSET(x)

Definition at line 246 of file vf_cropdetect.c.

const AVFilterPad avfilter_vf_cropdetect_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static int config_input(AVFilterLink *inlink)

Definition at line 257 of file vf_cropdetect.c.

const AVFilterPad avfilter_vf_cropdetect_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 267 of file vf_cropdetect.c.

AVFilter ff_vf_cropdetect
Initial value:
= {
.name = "cropdetect",
.description = NULL_IF_CONFIG_SMALL("Auto-detect crop size."),
.priv_size = sizeof(CropDetectContext),
.priv_class = &cropdetect_class,
.init = init,
}
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:125
static av_cold int init(AVFilterContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static int query_formats(AVFilterContext *ctx)
Definition: vf_cropdetect.c:46
static const AVFilterPad avfilter_vf_cropdetect_inputs[]
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
#define flags(name, subs,...)
Definition: cbs_av1.c:561
static const AVFilterPad avfilter_vf_cropdetect_outputs[]

Definition at line 275 of file vf_cropdetect.c.