Commit 1c3cdf53 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '460e7b4f'

* commit '460e7b4f':
  vf_cropdetect: switch to an AVOptions-based system.

Conflicts:
	doc/filters.texi
	libavfilter/vf_cropdetect.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 200e04c7 460e7b4f
...@@ -660,6 +660,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque ...@@ -660,6 +660,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
!strcmp(filter->filter->name, "blackframe") || !strcmp(filter->filter->name, "blackframe") ||
!strcmp(filter->filter->name, "boxblur" ) || !strcmp(filter->filter->name, "boxblur" ) ||
!strcmp(filter->filter->name, "crop" ) || !strcmp(filter->filter->name, "crop" ) ||
!strcmp(filter->filter->name, "cropdetect") ||
!strcmp(filter->filter->name, "format") || !strcmp(filter->filter->name, "format") ||
!strcmp(filter->filter->name, "noformat") || !strcmp(filter->filter->name, "noformat") ||
!strcmp(filter->filter->name, "resample") !strcmp(filter->filter->name, "resample")
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/internal.h" #include "libavutil/internal.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "avfilter.h" #include "avfilter.h"
#include "formats.h" #include "formats.h"
#include "internal.h" #include "internal.h"
...@@ -41,18 +42,6 @@ typedef struct { ...@@ -41,18 +42,6 @@ typedef struct {
int max_pixsteps[4]; int max_pixsteps[4];
} CropDetectContext; } 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 int query_formats(AVFilterContext *ctx)
{ {
static const enum AVPixelFormat pix_fmts[] = { static const enum AVPixelFormat pix_fmts[] = {
...@@ -100,6 +89,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) ...@@ -100,6 +89,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
CropDetectContext *cd = ctx->priv; CropDetectContext *cd = ctx->priv;
cd->frame_nb = -2; cd->frame_nb = -2;
av_log(ctx, AV_LOG_VERBOSE, "limit:%d round:%d reset_count:%d\n", av_log(ctx, AV_LOG_VERBOSE, "limit:%d round:%d reset_count:%d\n",
cd->limit, cd->round, cd->reset_count); cd->limit, cd->round, cd->reset_count);
...@@ -201,6 +191,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) ...@@ -201,6 +191,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
return ff_filter_frame(inlink->dst->outputs[0], 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[] = { static const AVFilterPad avfilter_vf_cropdetect_inputs[] = {
{ {
.name = "default", .name = "default",
...@@ -220,17 +223,14 @@ static const AVFilterPad avfilter_vf_cropdetect_outputs[] = { ...@@ -220,17 +223,14 @@ static const AVFilterPad avfilter_vf_cropdetect_outputs[] = {
{ NULL } { NULL }
}; };
static const char *const shorthand[] = { "limit", "round", "reset_count", NULL };
AVFilter avfilter_vf_cropdetect = { AVFilter avfilter_vf_cropdetect = {
.name = "cropdetect", .name = "cropdetect",
.description = NULL_IF_CONFIG_SMALL("Auto-detect crop size."), .description = NULL_IF_CONFIG_SMALL("Auto-detect crop size."),
.priv_size = sizeof(CropDetectContext), .priv_size = sizeof(CropDetectContext),
.priv_class = &cropdetect_class,
.init = init, .init = init,
.query_formats = query_formats, .query_formats = query_formats,
.inputs = avfilter_vf_cropdetect_inputs, .inputs = avfilter_vf_cropdetect_inputs,
.outputs = avfilter_vf_cropdetect_outputs, .outputs = avfilter_vf_cropdetect_outputs,
.priv_class = &cropdetect_class,
.shorthand = shorthand,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment