Go to the documentation of this file.
68 const uint16_t *src16 = (
const uint16_t *)
src;
123 s->frame_nb = -1 *
s->skip;
126 s->limit,
s->round,
s->skip,
s->reset_count);
140 s->limit *= (1 <<
desc->comp[0].depth) - 1;
150 #define SET_META(key, value) \
151 av_dict_set_int(metadata, key, value, 0)
157 int bpp =
s->max_pixsteps[0];
158 int w,
h, x, y, shrink_by;
160 int outliers, last_y;
164 if (++
s->frame_nb > 0) {
165 metadata = &
frame->metadata;
168 if (
s->reset_count > 0 &&
s->frame_nb >
s->reset_count) {
170 s->y1 =
frame->height - 1;
176 #define FIND(DST, FROM, NOEND, INC, STEP0, STEP1, LEN) \
178 for (last_y = y = FROM; NOEND; y = y INC) {\
179 if (checkline(ctx, frame->data[0] + STEP0 * y, STEP1, LEN, bpp) > limit) {\
180 if (++outliers > s->max_outliers) { \
209 shrink_by =
w %
s->round;
211 x += (shrink_by/2 + 1) & ~1;
213 shrink_by =
h %
s->round;
215 y += (shrink_by/2 + 1) & ~1;
227 "x1:%d x2:%d y1:%d y2:%d w:%d h:%d x:%d y:%d pts:%"PRId64
" t:%f crop=%d:%d:%d:%d\n",
228 s->x1,
s->x2,
s->y1,
s->y2,
w,
h, x, y,
frame->pts,
236 #define OFFSET(x) offsetof(CropDetectContext, x)
237 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
242 {
"reset",
"Recalculate the crop area after this many frames",
OFFSET(reset_count),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
FLAGS },
244 {
"reset_count",
"Recalculate the crop area after this many frames",
OFFSET(reset_count),
AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX,
FLAGS },
268 .
name =
"cropdetect",
271 .priv_class = &cropdetect_class,
AVPixelFormat
Pixel format.
static av_cold int init(AVFilterContext *ctx)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define FILTER_PIXFMTS_ARRAY(array)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
#define SET_META(key, value)
This structure describes decoded (raw) audio or video data.
#define AV_PIX_FMT_YUV420P10
#define AV_LOG_VERBOSE
Detailed information.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
A link between two filters.
static int checkline(void *ctx, const unsigned char *src, int stride, int len, int bpp)
#define AV_PIX_FMT_YUV422P9
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV422P16
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AV_PIX_FMT_YUV444P16
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AV_PIX_FMT_YUV420P9
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_PIX_FMT_YUV420P16
AVFILTER_DEFINE_CLASS(cropdetect)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(array)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Describe the class of an AVClass context structure.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static const AVOption cropdetect_options[]
#define AV_PIX_FMT_YUV422P10
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
#define FIND(DST, FROM, NOEND, INC, STEP0, STEP1, LEN)
#define AV_PIX_FMT_YUV422P12
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_PIX_FMT_YUV444P12
static int config_input(AVFilterLink *inlink)
#define AV_LOG_INFO
Standard information.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
static av_always_inline av_const double round(double x)
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
const char * name
Pad name.
#define AV_PIX_FMT_YUV444P9
static double limit(double x)
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
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 AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static const AVFilterPad avfilter_vf_cropdetect_inputs[]
static const AVFilterPad avfilter_vf_cropdetect_outputs[]
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV420P14
const AVFilter ff_vf_cropdetect