Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavfilter/avfilter.c1
-rw-r--r--libavfilter/vf_cropdetect.c32
2 files changed, 17 insertions, 16 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 8f1322c523..81b2f47eed 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -660,6 +660,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
!strcmp(filter->filter->name, "blackframe") ||
!strcmp(filter->filter->name, "boxblur" ) ||
!strcmp(filter->filter->name, "crop" ) ||
+ !strcmp(filter->filter->name, "cropdetect") ||
!strcmp(filter->filter->name, "format") ||
!strcmp(filter->filter->name, "noformat") ||
!strcmp(filter->filter->name, "resample")
diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c
index 7c0af7323e..b721f70df5 100644
--- a/libavfilter/vf_cropdetect.c
+++ b/libavfilter/vf_cropdetect.c
@@ -26,6 +26,7 @@
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
+
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
@@ -41,18 +42,6 @@ typedef struct {
int max_pixsteps[4];
} CropDetectContext;
-#define OFFSET(x) offsetof(CropDetectContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
-
-static const AVOption cropdetect_options[] = {
- { "limit", "set black threshold", OFFSET(limit), AV_OPT_TYPE_INT, {.i64=24}, 0, 255, FLAGS },
- { "round", "set width/height round value", OFFSET(round), AV_OPT_TYPE_INT, {.i64=16}, 0, INT_MAX, FLAGS },
- { "reset_count", "set after how many frames to reset detected info", OFFSET(reset_count), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
- { NULL }
-};
-
-AVFILTER_DEFINE_CLASS(cropdetect);
-
static int query_formats(AVFilterContext *ctx)
{
static const enum AVPixelFormat pix_fmts[] = {
@@ -100,6 +89,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
CropDetectContext *cd = ctx->priv;
cd->frame_nb = -2;
+
av_log(ctx, AV_LOG_VERBOSE, "limit:%d round:%d reset_count:%d\n",
cd->limit, cd->round, cd->reset_count);
@@ -201,6 +191,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
return ff_filter_frame(inlink->dst->outputs[0], frame);
}
+#define OFFSET(x) offsetof(CropDetectContext, x)
+#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, 255, 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 },
+ { NULL },
+};
+
+AVFILTER_DEFINE_CLASS(cropdetect);
+
static const AVFilterPad avfilter_vf_cropdetect_inputs[] = {
{
.name = "default",
@@ -220,17 +223,14 @@ static const AVFilterPad avfilter_vf_cropdetect_outputs[] = {
{ NULL }
};
-static const char *const shorthand[] = { "limit", "round", "reset_count", NULL };
-
AVFilter avfilter_vf_cropdetect = {
.name = "cropdetect",
.description = NULL_IF_CONFIG_SMALL("Auto-detect crop size."),
.priv_size = sizeof(CropDetectContext),
+ .priv_class = &cropdetect_class,
.init = init,
.query_formats = query_formats,
.inputs = avfilter_vf_cropdetect_inputs,
.outputs = avfilter_vf_cropdetect_outputs,
- .priv_class = &cropdetect_class,
- .shorthand = shorthand,
};