diff options
-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], |