History

avfilter/vf_bilateral: add direct aka writable frame support

Paul B Mahol committed 5 years ago

Commit 444cf3f1 parent cf0881b1 file · +15 −9Browse files

Unified · Split

libavfilter/vf_bilateral.c+15−9
@@ -297,18 +297,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 296 unmodified lines
297297 AVFilterLink *outlink = ctx->outputs[0];
298298 AVFrame *out;
299299
300− out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
301− if (!out) {
302− av_frame_free(&in);
303− return AVERROR(ENOMEM);
300+ if (av_frame_is_writable(in)) {
301+ out = in;
302+ } else {
303+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
304+ if (!out) {
305+ av_frame_free(&in);
306+ return AVERROR(ENOMEM);
307+ }
308+ av_frame_copy_props(out, in);
304309 }
305− av_frame_copy_props(out, in);
306310
307311 for (int plane = 0; plane < s->nb_planes; plane++) {
308312 if (!(s->planes & (1 << plane))) {
309− av_image_copy_plane(out->data[plane], out->linesize[plane],
310− in->data[plane], in->linesize[plane],
311− s->planewidth[plane] * ((s->depth + 7) / 8), s->planeheight[plane]);
313+ if (out != in)
314+ av_image_copy_plane(out->data[plane], out->linesize[plane],
315+ in->data[plane], in->linesize[plane],
316+ s->planewidth[plane] * ((s->depth + 7) / 8), s->planeheight[plane]);
312317 continue;
313318 }
314319
@@ -322,7 +327,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 7 unmodified lines
322327 in->linesize[plane] / 2, out->linesize[plane] / 2);
323328 }
324329
325− av_frame_free(&in);
330+ if (out != in)
331+ av_frame_free(&in);
326332 return ff_filter_frame(outlink, out);
327333 }
328334

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t