1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-02-04 06:08:26 +02:00

lavfi/yadif: add support to named options and options introspection

Also rename the "enable_auto" field to "deint", to match the name of the
option.
This commit is contained in:
Stefano Sabatini 2013-01-02 11:40:02 +01:00
parent 8674597fe5
commit f7dc6aa6b1
4 changed files with 47 additions and 19 deletions

View File

@ -4290,10 +4290,17 @@ ffmpeg -i in.avi -vf "vflip" out.avi
Deinterlace the input video ("yadif" means "yet another deinterlacing Deinterlace the input video ("yadif" means "yet another deinterlacing
filter"). filter").
It accepts the optional parameters: @var{mode}:@var{parity}:@var{auto}. The filter accepts parameters as a list of @var{key}=@var{value}
pairs, separated by ":". If the key of the first options is omitted,
the arguments are interpreted according to syntax
@var{mode}:@var{parity}:@var{deint}.
@var{mode} specifies the interlacing mode to adopt, accepts one of the The description of the accepted parameters follows.
following values:
@table @option
@item mode
Specify the interlacing mode to adopt. Accept one of the following
values:
@table @option @table @option
@item 0 @item 0
@ -4308,8 +4315,9 @@ like 1 but skips spatial interlacing check
Default value is 0. Default value is 0.
@var{parity} specifies the picture field parity assumed for the input @item parity
interlaced video, accepts one of the following values: Specify the picture field parity assumed for the input interlaced
video. Accept one of the following values:
@table @option @table @option
@item 0 @item 0
@ -4324,8 +4332,9 @@ Default value is -1.
If interlacing is unknown or decoder does not export this information, If interlacing is unknown or decoder does not export this information,
top field first will be assumed. top field first will be assumed.
@var{auto} specifies if deinterlacer should trust the interlaced flag @item deint
and only deinterlace frames marked as interlaced Specify which frames to deinterlace. Accept one of the following
values:
@table @option @table @option
@item 0 @item 0
@ -4335,6 +4344,7 @@ only deinterlace frames marked as interlaced
@end table @end table
Default value is 0. Default value is 0.
@end table
@c man end VIDEO FILTERS @c man end VIDEO FILTERS

View File

@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 3 #define LIBAVFILTER_VERSION_MAJOR 3
#define LIBAVFILTER_VERSION_MINOR 30 #define LIBAVFILTER_VERSION_MINOR 30
#define LIBAVFILTER_VERSION_MICRO 102 #define LIBAVFILTER_VERSION_MICRO 103
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \ LIBAVFILTER_VERSION_MINOR, \

View File

@ -20,6 +20,7 @@
#include "libavutil/avassert.h" #include "libavutil/avassert.h"
#include "libavutil/cpu.h" #include "libavutil/cpu.h"
#include "libavutil/common.h" #include "libavutil/common.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h" #include "libavutil/pixdesc.h"
#include "avfilter.h" #include "avfilter.h"
#include "formats.h" #include "formats.h"
@ -231,7 +232,7 @@ static int filter_frame(AVFilterLink *link, AVFilterBufferRef *picref)
if (!yadif->cur) if (!yadif->cur)
return 0; return 0;
if (yadif->auto_enable && !yadif->cur->video->interlaced) { if (yadif->deint && !yadif->cur->video->interlaced) {
yadif->out = avfilter_ref_buffer(yadif->cur, ~AV_PERM_WRITE); yadif->out = avfilter_ref_buffer(yadif->cur, ~AV_PERM_WRITE);
if (!yadif->out) if (!yadif->out)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
@ -296,6 +297,18 @@ static int request_frame(AVFilterLink *link)
return 0; return 0;
} }
#define OFFSET(x) offsetof(YADIFContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static const AVOption yadif_options[] = {
{ "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS },
{ "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS },
{ "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS },
{NULL},
};
AVFILTER_DEFINE_CLASS(yadif);
static av_cold void uninit(AVFilterContext *ctx) static av_cold void uninit(AVFilterContext *ctx)
{ {
YADIFContext *yadif = ctx->priv; YADIFContext *yadif = ctx->priv;
@ -304,6 +317,7 @@ static av_cold void uninit(AVFilterContext *ctx)
avfilter_unref_bufferp(&yadif->cur ); avfilter_unref_bufferp(&yadif->cur );
avfilter_unref_bufferp(&yadif->next); avfilter_unref_bufferp(&yadif->next);
av_freep(&yadif->temp_line); yadif->temp_line_size = 0; av_freep(&yadif->temp_line); yadif->temp_line_size = 0;
av_opt_free(yadif);
} }
static int query_formats(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx)
@ -341,23 +355,24 @@ static int query_formats(AVFilterContext *ctx)
static av_cold int init(AVFilterContext *ctx, const char *args) static av_cold int init(AVFilterContext *ctx, const char *args)
{ {
YADIFContext *yadif = ctx->priv; YADIFContext *yadif = ctx->priv;
static const char *shorthand[] = { "mode", "parity", "enable", NULL };
int ret;
yadif->mode = 0;
yadif->parity = -1;
yadif->auto_enable = 0;
yadif->csp = NULL; yadif->csp = NULL;
if (args) yadif->class = &yadif_class;
sscanf(args, "%d:%d:%d", av_opt_set_defaults(yadif);
&yadif->mode, &yadif->parity, &yadif->auto_enable);
if ((ret = av_opt_set_from_string(yadif, args, shorthand, "=", ":")) < 0)
return ret;
yadif->filter_line = filter_line_c; yadif->filter_line = filter_line_c;
if (ARCH_X86) if (ARCH_X86)
ff_yadif_init_x86(yadif); ff_yadif_init_x86(yadif);
av_log(ctx, AV_LOG_VERBOSE, "mode:%d parity:%d auto_enable:%d\n", av_log(ctx, AV_LOG_VERBOSE, "mode:%d parity:%d deint:%d\n",
yadif->mode, yadif->parity, yadif->auto_enable); yadif->mode, yadif->parity, yadif->deint);
return 0; return 0;
} }
@ -413,6 +428,7 @@ AVFilter avfilter_vf_yadif = {
.query_formats = query_formats, .query_formats = query_formats,
.inputs = avfilter_vf_yadif_inputs, .inputs = avfilter_vf_yadif_inputs,
.outputs = avfilter_vf_yadif_outputs, .outputs = avfilter_vf_yadif_outputs,
.priv_class = &yadif_class,
}; };

View File

@ -23,6 +23,8 @@
#include "avfilter.h" #include "avfilter.h"
typedef struct YADIFContext { typedef struct YADIFContext {
const AVClass *class;
/** /**
* 0: send 1 frame for each frame * 0: send 1 frame for each frame
* 1: send 1 frame for each field * 1: send 1 frame for each field
@ -44,7 +46,7 @@ typedef struct YADIFContext {
* 0: deinterlace all frames * 0: deinterlace all frames
* 1: only deinterlace frames marked as interlaced * 1: only deinterlace frames marked as interlaced
*/ */
int auto_enable; int deint;
AVFilterBufferRef *cur; AVFilterBufferRef *cur;
AVFilterBufferRef *next; AVFilterBufferRef *next;