1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit '95f1f56a21bc2f824af6fb97ca7ab35cdd0c401e'

* commit '95f1f56a21bc2f824af6fb97ca7ab35cdd0c401e':
  vf_select: switch to an AVOptions-based system.

Conflicts:
	doc/filters.texi
	libavfilter/f_select.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-04-10 23:18:18 +02:00
commit b3fb2d8cec
3 changed files with 29 additions and 20 deletions

View File

@ -6421,14 +6421,16 @@ It accepts the following values:
@section aselect, select @section aselect, select
Select frames to pass in output. Select frames to pass in output.
These filters accept a single option @option{expr} or @option{e} This filter accepts the following options:
specifying the select expression, which can be specified either by
specyfing @code{expr=VALUE} or specifying the expression
alone.
The select expression is evaluated for each input frame. If the @table @option
evaluation result is a non-zero value, the frame is selected and
passed to the output, otherwise it is discarded. @item expr
An expression, which is evaluated for each input frame. If the expression is
evaluated to a non-zero value, the frame is selected and passed to the output,
otherwise it is discarded.
@end table
The expression can contain the following constants: The expression can contain the following constants:

View File

@ -682,6 +682,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
!strcmp(filter->filter->name, "noformat") || !strcmp(filter->filter->name, "noformat") ||
!strcmp(filter->filter->name, "resample") || !strcmp(filter->filter->name, "resample") ||
// !strcmp(filter->filter->name, "scale" ) || // !strcmp(filter->filter->name, "scale" ) ||
!strcmp(filter->filter->name, "select") ||
0 0
; ;

View File

@ -125,8 +125,8 @@ enum var_name {
typedef struct { typedef struct {
const AVClass *class; const AVClass *class;
AVExpr *expr;
char *expr_str; char *expr_str;
AVExpr *expr;
double var_values[VAR_VARS_NB]; double var_values[VAR_VARS_NB];
int do_scene_detect; ///< 1 if the expression requires scene detection variables, 0 otherwise int do_scene_detect; ///< 1 if the expression requires scene detection variables, 0 otherwise
#if CONFIG_AVCODEC #if CONFIG_AVCODEC
@ -138,13 +138,6 @@ typedef struct {
double select; double select;
} SelectContext; } SelectContext;
#define OFFSET(x) offsetof(SelectContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
static const AVOption options[] = {
{ "expr", "set selection expression", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = "1"}, 0, 0, FLAGS },
{ "e", "set selection expression", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = "1"}, 0, 0, FLAGS },
{NULL},
};
static av_cold int init(AVFilterContext *ctx, const char *args, const AVClass *class) static av_cold int init(AVFilterContext *ctx, const char *args, const AVClass *class)
{ {
@ -153,7 +146,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, const AVClass *c
if ((ret = av_expr_parse(&select->expr, select->expr_str, if ((ret = av_expr_parse(&select->expr, select->expr_str,
var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) { var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", select->expr_str); av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n",
select->expr_str);
return ret; return ret;
} }
select->do_scene_detect = !!strstr(select->expr_str, "scene"); select->do_scene_detect = !!strstr(select->expr_str, "scene");
@ -398,7 +392,13 @@ static const char *const shorthand[] = { "expr", NULL };
#if CONFIG_ASELECT_FILTER #if CONFIG_ASELECT_FILTER
#define aselect_options options #define OFFSET(x) offsetof(SelectContext, x)
#define AFLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
static const AVOption aselect_options[] = {
{ "expr", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = AFLAGS },
{ "e", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = AFLAGS },
{ NULL },
};
AVFILTER_DEFINE_CLASS(aselect); AVFILTER_DEFINE_CLASS(aselect);
static av_cold int aselect_init(AVFilterContext *ctx, const char *args) static av_cold int aselect_init(AVFilterContext *ctx, const char *args)
@ -451,7 +451,14 @@ AVFilter avfilter_af_aselect = {
#if CONFIG_SELECT_FILTER #if CONFIG_SELECT_FILTER
#define select_options options #define OFFSET(x) offsetof(SelectContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
static const AVOption select_options[] = {
{ "expr", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS },
{ "e", "An expression to use for selecting frames", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS },
{ NULL },
};
AVFILTER_DEFINE_CLASS(select); AVFILTER_DEFINE_CLASS(select);
static av_cold int select_init(AVFilterContext *ctx, const char *args) static av_cold int select_init(AVFilterContext *ctx, const char *args)
@ -498,10 +505,9 @@ AVFilter avfilter_vf_select = {
.query_formats = query_formats, .query_formats = query_formats,
.priv_size = sizeof(SelectContext), .priv_size = sizeof(SelectContext),
.priv_class = &select_class,
.inputs = avfilter_vf_select_inputs, .inputs = avfilter_vf_select_inputs,
.outputs = avfilter_vf_select_outputs, .outputs = avfilter_vf_select_outputs,
.priv_class = &select_class,
.shorthand = shorthand,
}; };
#endif /* CONFIG_SELECT_FILTER */ #endif /* CONFIG_SELECT_FILTER */