1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-08 13:22:53 +02:00

avfilter/vf_bilateral: add direct aka writable frame support

This commit is contained in:
Paul B Mahol 2021-10-22 09:34:51 +02:00
parent cf0881bcfc
commit 444cf3fca8

View File

@ -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);
}