26 #include "libavutil/imgutils.h"
28 #include "libavutil/opt.h"
75 total += src[0] + src[1] + src[2];
107 s->
x1 = inlink->
w - 1;
108 s->
y1 = inlink->
h - 1;
115 #define SET_META(key, value) \
116 snprintf(buf, sizeof(buf), "%d", value); \
117 av_dict_set(metadata, key, buf, 0)
124 int w, h, x,
y, shrink_by;
141 for (y = 0; y < s->
y1; y++) {
148 for (y = frame->
height - 1; y > s->
y2; y--) {
155 for (y = 0; y < s->
x1; y++) {
162 for (y = frame->
width - 1; y > s->
x2; y--) {
184 shrink_by = w % s->
round;
186 x += (shrink_by/2 + 1) & ~1;
188 shrink_by = h % s->
round;
190 y += (shrink_by/2 + 1) & ~1;
202 "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",
203 s->
x1, s->
x2, s->
y1, s->
y2, w, h, x, y, frame->
pts,
211 #define OFFSET(x) offsetof(CropDetectContext, x)
212 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
215 {
"limit",
"Threshold below which the pixel is considered black",
OFFSET(limit),
AV_OPT_TYPE_INT, { .i64 = 24 }, 0, 255,
FLAGS },
217 {
"reset",
"Recalculate the crop area after this many frames",
OFFSET(reset_count),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
FLAGS },
218 {
"reset_count",
"Recalculate the crop area after this many frames",
OFFSET(reset_count),
AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX,
FLAGS },
243 .
name =
"cropdetect",
246 .priv_class = &cropdetect_class,
249 .
inputs = avfilter_vf_cropdetect_inputs,
250 .
outputs = avfilter_vf_cropdetect_outputs,
This structure describes decoded (raw) audio or video data.
const char * name
Filter name.
void * priv
private data for use by the filter
AVFilter avfilter_vf_cropdetect
static const AVFilterPad outputs[]
int h
agreed upon image height
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
#define SET_META(key, value)
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...
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.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
as above, but U and V bytes are swapped
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static av_cold int init(AVFilterContext *ctx)
static double av_q2d(AVRational a)
Convert rational to double.
#define AV_LOG_VERBOSE
Detailed information.
A filter pad used for either input or output.
A link between two filters.
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
int width
width and height of the video frame
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. ...
#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...
static av_always_inline av_const double round(double x)
AVPixelFormat
Pixel format.
int w
agreed upon image width
common internal API header
static const AVOption cropdetect_options[]
int format
agreed upon media format
static int query_formats(AVFilterContext *ctx)
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)
static const AVFilterPad avfilter_vf_cropdetect_inputs[]
#define AV_LOG_INFO
Standard information.
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
AVDictionary ** avpriv_frame_get_metadatap(AVFrame *frame)
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.
AVFilterContext * dst
dest filter
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
static const AVFilterPad avfilter_vf_cropdetect_outputs[]
#define AVFILTER_DEFINE_CLASS(fname)
static int config_input(AVFilterLink *inlink)
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_NOPTS_VALUE
Undefined timestamp value.
static int checkline(void *ctx, const unsigned char *src, int stride, int len, int bpp)