diff options
author | Yuuki Galaxy <galaxy001@gmail.com> | 2016-04-12 22:53:58 +0800 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-04-12 22:57:32 +0200 |
commit | af5419f91b06cf85836ce9c8bc9efc965af79b48 (patch) | |
tree | cd2f141e020fb260fd57aa6fcc19e8ba5e04224a | |
parent | ac07e57c39de856cb88ee6ff0669da3ced2fc694 (diff) | |
download | ffmpeg-af5419f91b06cf85836ce9c8bc9efc965af79b48.tar.gz |
libavfilter/vf_owdenoise.c: skip processing when strength is 0
It is practical to de-noise only on luma while keeping chroma unchanged.
However, libavfilter/vf_owdenoise.c always do the Wavelet transform/retransform on all 3 channels without check whether chroma_strength is 0.
Thus I make this patch. De-noise on Y only for yuv420 is now 1.5 times faster.
Signed-off-by: Yuuki Galaxy <galaxy001@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavfilter/vf_owdenoise.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/libavfilter/vf_owdenoise.c b/libavfilter/vf_owdenoise.c index 3a77f8967e..6becccccf5 100644 --- a/libavfilter/vf_owdenoise.c +++ b/libavfilter/vf_owdenoise.c @@ -222,7 +222,6 @@ static void filter(OWDenoiseContext *s, static int filter_frame(AVFilterLink *inlink, AVFrame *in) { - int direct = 0; AVFilterContext *ctx = inlink->dst; OWDenoiseContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; @@ -231,8 +230,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) const int ch = AV_CEIL_RSHIFT(inlink->h, s->vsub); if (av_frame_is_writable(in)) { - direct = 1; out = in; + + if (s->luma_strength > 0) + filter(s, out->data[0], out->linesize[0], in->data[0], in->linesize[0], inlink->w, inlink->h, s->luma_strength); + if (s->chroma_strength > 0) { + filter(s, out->data[1], out->linesize[1], in->data[1], in->linesize[1], cw, ch, s->chroma_strength); + filter(s, out->data[2], out->linesize[2], in->data[2], in->linesize[2], cw, ch, s->chroma_strength); + } } else { out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) { @@ -240,13 +245,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) return AVERROR(ENOMEM); } av_frame_copy_props(out, in); - } - filter(s, out->data[0], out->linesize[0], in->data[0], in->linesize[0], inlink->w, inlink->h, s->luma_strength); - filter(s, out->data[1], out->linesize[1], in->data[1], in->linesize[1], cw, ch, s->chroma_strength); - filter(s, out->data[2], out->linesize[2], in->data[2], in->linesize[2], cw, ch, s->chroma_strength); + if (s->luma_strength > 0) { + filter(s, out->data[0], out->linesize[0], in->data[0], in->linesize[0], inlink->w, inlink->h, s->luma_strength); + } else { + av_image_copy_plane(out->data[0], out->linesize[0], in ->data[0], in ->linesize[0], inlink->w, inlink->h); + } + if (s->chroma_strength > 0) { + filter(s, out->data[1], out->linesize[1], in->data[1], in->linesize[1], cw, ch, s->chroma_strength); + filter(s, out->data[2], out->linesize[2], in->data[2], in->linesize[2], cw, ch, s->chroma_strength); + } else { + av_image_copy_plane(out->data[1], out->linesize[1], in ->data[1], in ->linesize[1], inlink->w, inlink->h); + av_image_copy_plane(out->data[2], out->linesize[2], in ->data[2], in ->linesize[2], inlink->w, inlink->h); + } - if (!direct) { if (in->data[3]) av_image_copy_plane(out->data[3], out->linesize[3], in ->data[3], in ->linesize[3], |