[FFmpeg-cvslog] libavfilter/vf_owdenoise.c: skip processing when strength is 0
Yuuki Galaxy
git at videolan.org
Tue Apr 12 22:59:52 CEST 2016
ffmpeg | branch: master | Yuuki Galaxy <galaxy001 at gmail.com> | Tue Apr 12 22:53:58 2016 +0800| [af5419f91b06cf85836ce9c8bc9efc965af79b48] | committer: Michael Niedermayer
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 at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=af5419f91b06cf85836ce9c8bc9efc965af79b48
---
libavfilter/vf_owdenoise.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/libavfilter/vf_owdenoise.c b/libavfilter/vf_owdenoise.c
index 3a77f89..6becccc 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],
More information about the ffmpeg-cvslog
mailing list