[FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: adjust Default threshold based on bit depth
Michael Niedermayer
michaelni at gmx.at
Tue Dec 30 21:12:13 CET 2014
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libavfilter/vf_cropdetect.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c
index dd237ef..d49101c 100644
--- a/libavfilter/vf_cropdetect.c
+++ b/libavfilter/vf_cropdetect.c
@@ -137,9 +137,12 @@ static int config_input(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
CropDetectContext *s = ctx->priv;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
- av_image_fill_max_pixsteps(s->max_pixsteps, NULL,
- av_pix_fmt_desc_get(inlink->format));
+ av_image_fill_max_pixsteps(s->max_pixsteps, NULL, desc);
+
+ if (s->limit < 0)
+ s->limit = 24 << (desc->comp[0].depth_minus1 - 7);
s->x1 = inlink->w - 1;
s->y1 = inlink->h - 1;
@@ -238,7 +241,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static const AVOption cropdetect_options[] = {
- { "limit", "Threshold below which the pixel is considered black", OFFSET(limit), AV_OPT_TYPE_INT, { .i64 = 24 }, 0, 65535, FLAGS },
+ { "limit", "Threshold below which the pixel is considered black", OFFSET(limit), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 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 },
--
1.7.9.5
More information about the ffmpeg-devel
mailing list