On 1/30/16, Andy Furniss <adf.li...@gmail.com> wrote: > Paul B Mahol wrote: >> Hi, >> >> 3rd version attached! > > It seems that now bff/tff flags on input are correctly followed and > output is good, but it can't be overridden by field=bf or field=tf both > give correct output. > > For raw video though, they are honored and are still the wrong way round.
Could you test attached patch? Apply on top of last one.
From 11d9bc4f3aef810b6955ebc752b44d738594be1d Mon Sep 17 00:00:00 2001 From: Paul B Mahol <one...@gmail.com> Date: Sat, 30 Jan 2016 09:21:56 +0100 Subject: [PATCH] fix Signed-off-by: Paul B Mahol <one...@gmail.com> --- doc/filters.texi | 4 ++++ libavfilter/vf_nnedi.c | 32 ++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 98f3129..7907993 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8511,6 +8511,10 @@ Set mode of operation. Can be one of the following: @table @samp +@item af +Use frame flags, both fields. +@item a +Use frame flags, single field. @item t Use top field only. @item b diff --git a/libavfilter/vf_nnedi.c b/libavfilter/vf_nnedi.c index d77d065..27bb1c7 100644 --- a/libavfilter/vf_nnedi.c +++ b/libavfilter/vf_nnedi.c @@ -68,7 +68,7 @@ typedef struct NNEDIContext { int xdia; int ydia; - // Parameters. + // Parameters int deint; int field; int process_plane; @@ -107,9 +107,11 @@ static const AVOption nnedi_options[] = { {"deint", "set which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "deint" }, {"all", "deinterlace all frames", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "deint" }, {"interlaced", "only deinterlace frames marked as interlaced", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "deint" }, - {"field", "set mode of operation", OFFSET(field), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS, "field" }, - {"t", "use top field only", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "field" }, - {"b", "use bottom field only", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "field" }, + {"field", "set mode of operation", OFFSET(field), AV_OPT_TYPE_INT, {.i64=-1}, -2, 3, FLAGS, "field" }, + {"af", "use frame flags, both fields", 0, AV_OPT_TYPE_CONST, {.i64=-2}, 0, 0, FLAGS, "field" }, + {"a", "use frame flags, single field", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, FLAGS, "field" }, + {"t", "use top field only", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "field" }, + {"b", "use bottom field only", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "field" }, {"tf", "use both fields, top first", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "field" }, {"bf", "use both fields, bottom first", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "field" }, {"planes", "set which planes to process", OFFSET(process_plane), AV_OPT_TYPE_INT, {.i64=7}, 0, 7, FLAGS }, @@ -170,7 +172,7 @@ static int config_output(AVFilterLink *outlink) outlink->w = ctx->inputs[0]->w; outlink->h = ctx->inputs[0]->h; - if (s->field > 1) + if (s->field > 1 || s->field == -2) outlink->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate, (AVRational){2, 1}); @@ -696,13 +698,17 @@ static int get_frame(AVFilterContext *ctx, int is_second) if (effective_field > 1) effective_field -= 2; + else if (effective_field < 0) + effective_field += 2; - if (src->interlaced_frame && src->top_field_first == 0) + if (s->field < 0 && src->interlaced_frame && src->top_field_first == 0) effective_field = 0; - else if (src->interlaced_frame && src->top_field_first == 1) + else if (s->field < 0 && src->interlaced_frame && src->top_field_first == 1) effective_field = 1; + else + effective_field = !effective_field; - if (s->field > 1) { + if (s->field > 1 || s->field == -2) { if (is_second) { field_n = (effective_field == 0); } else { @@ -791,9 +797,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *src) NNEDIContext *s = ctx->priv; int ret; - if (s->field > 1 && !s->second) { + if ((s->field > 1 || + s->field == -2) && !s->second) { goto second; - } else if (s->field > 1) { + } else if (s->field > 1 || + s->field == -2) { AVFrame *dst; s->src = s->second; @@ -831,7 +839,7 @@ second: return AVERROR(ENOMEM); } - if (s->field > 1) { + if (s->field > 1 || s->field == -2) { av_frame_free(&s->second); if ((s->deint && src->interlaced_frame) || (!s->deint)) @@ -855,7 +863,7 @@ second: if (src->pts != AV_NOPTS_VALUE) s->dst->pts = src->pts * 2; - if (s->field <= 1) { + if (s->field <= 1 && s->field > -2) { av_frame_free(&src); s->src = NULL; } -- 1.9.1
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel