diff options
Diffstat (limited to 'libavfilter/vf_hqdn3d.c')
-rw-r--r-- | libavfilter/vf_hqdn3d.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c index b9acf0b975..6961f713a1 100644 --- a/libavfilter/vf_hqdn3d.c +++ b/libavfilter/vf_hqdn3d.c @@ -3,20 +3,20 @@ * Copyright (c) 2010 Baptiste Coudurier * Copyright (c) 2012 Loren Merritt * - * This file is part of Libav, ported from MPlayer. + * This file is part of FFmpeg, ported from MPlayer. * - * Libav is free software; you can redistribute it and/or modify + * FFmpeg is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along - * with Libav; if not, write to the Free Software Foundation, Inc., + * with FFmpeg; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ @@ -276,12 +276,14 @@ static int config_input(AVFilterLink *inlink) static int filter_frame(AVFilterLink *inlink, AVFrame *in) { - HQDN3DContext *s = inlink->dst->priv; - AVFilterLink *outlink = inlink->dst->outputs[0]; + AVFilterContext *ctx = inlink->dst; + HQDN3DContext *s = ctx->priv; + AVFilterLink *outlink = ctx->outputs[0]; + AVFrame *out; int direct, c; - if (av_frame_is_writable(in)) { + if (av_frame_is_writable(in) && !ctx->is_disabled) { direct = 1; out = in; } else { @@ -293,17 +295,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } av_frame_copy_props(out, in); - out->width = outlink->w; - out->height = outlink->h; } for (c = 0; c < 3; c++) { denoise(s, in->data[c], out->data[c], s->line, &s->frame_prev[c], - in->width >> (!!c * s->hsub), - in->height >> (!!c * s->vsub), + FF_CEIL_RSHIFT(in->width, (!!c * s->hsub)), + FF_CEIL_RSHIFT(in->height, (!!c * s->vsub)), in->linesize[c], out->linesize[c], - s->coefs[c?2:0], s->coefs[c?3:1]); + s->coefs[c ? CHROMA_SPATIAL : LUMA_SPATIAL], + s->coefs[c ? CHROMA_TMP : LUMA_TMP]); + } + + if (ctx->is_disabled) { + av_frame_free(&out); + return ff_filter_frame(outlink, in); } if (!direct) @@ -313,8 +319,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } #define OFFSET(x) offsetof(HQDN3DContext, x) -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM -static const AVOption options[] = { +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM +static const AVOption hqdn3d_options[] = { { "luma_spatial", "spatial luma strength", OFFSET(strength[LUMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS }, { "chroma_spatial", "spatial chroma strength", OFFSET(strength[CHROMA_SPATIAL]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS }, { "luma_tmp", "temporal luma strength", OFFSET(strength[LUMA_TMP]), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0, DBL_MAX, FLAGS }, @@ -322,12 +328,7 @@ static const AVOption options[] = { { NULL }, }; -static const AVClass hqdn3d_class = { - .class_name = "hqdn3d", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; +AVFILTER_DEFINE_CLASS(hqdn3d); static const AVFilterPad avfilter_vf_hqdn3d_inputs[] = { { @@ -339,6 +340,7 @@ static const AVFilterPad avfilter_vf_hqdn3d_inputs[] = { { NULL } }; + static const AVFilterPad avfilter_vf_hqdn3d_outputs[] = { { .name = "default", @@ -358,6 +360,6 @@ AVFilter avfilter_vf_hqdn3d = { .query_formats = query_formats, .inputs = avfilter_vf_hqdn3d_inputs, - .outputs = avfilter_vf_hqdn3d_outputs, + .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL, }; |