[FFmpeg-cvslog] avfilter/vf_bilateral: add direct aka writable frame support
Paul B Mahol
git at videolan.org
Fri Oct 22 10:37:21 EEST 2021
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Oct 22 09:34:51 2021 +0200| [444cf3fca8dab2da9b95cc36920667f76d0f796c] | committer: Paul B Mahol
avfilter/vf_bilateral: add direct aka writable frame support
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=444cf3fca8dab2da9b95cc36920667f76d0f796c
---
libavfilter/vf_bilateral.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c
index 8fe341f70d..b236efe6c3 100644
--- a/libavfilter/vf_bilateral.c
+++ b/libavfilter/vf_bilateral.c
@@ -297,18 +297,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
AVFilterLink *outlink = ctx->outputs[0];
AVFrame *out;
- out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
- if (!out) {
- av_frame_free(&in);
- return AVERROR(ENOMEM);
+ if (av_frame_is_writable(in)) {
+ out = in;
+ } else {
+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+ if (!out) {
+ av_frame_free(&in);
+ return AVERROR(ENOMEM);
+ }
+ av_frame_copy_props(out, in);
}
- av_frame_copy_props(out, in);
for (int plane = 0; plane < s->nb_planes; plane++) {
if (!(s->planes & (1 << plane))) {
- av_image_copy_plane(out->data[plane], out->linesize[plane],
- in->data[plane], in->linesize[plane],
- s->planewidth[plane] * ((s->depth + 7) / 8), s->planeheight[plane]);
+ if (out != in)
+ av_image_copy_plane(out->data[plane], out->linesize[plane],
+ in->data[plane], in->linesize[plane],
+ s->planewidth[plane] * ((s->depth + 7) / 8), s->planeheight[plane]);
continue;
}
@@ -322,7 +327,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
in->linesize[plane] / 2, out->linesize[plane] / 2);
}
- av_frame_free(&in);
+ if (out != in)
+ av_frame_free(&in);
return ff_filter_frame(outlink, out);
}
More information about the ffmpeg-cvslog
mailing list