mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
ac07e57c39
commit
af5419f91b
|
@ -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);
|
||||
}
|
||||
|
||||
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],
|
||||
|
|
Loading…
Reference in New Issue