Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -297,18 +297,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 296 unmodified lines | ||
| 297 | 297 | AVFilterLink *outlink = ctx->outputs[0]; |
| 298 | 298 | AVFrame *out; |
| 299 | 299 | |
| 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); | |
| 304 | 309 | } |
| 305 | − av_frame_copy_props(out, in); | |
| 306 | 310 | |
| 307 | 311 | for (int plane = 0; plane < s->nb_planes; plane++) { |
| 308 | 312 | 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]); | |
| 312 | 317 | continue; |
| 313 | 318 | } |
| 314 | 319 | |
| @@ -322,7 +327,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 7 unmodified lines | ||
| 322 | 327 | in->linesize[plane] / 2, out->linesize[plane] / 2); |
| 323 | 328 | } |
| 324 | 329 | |
| 325 | − av_frame_free(&in); | |
| 330 | + if (out != in) | |
| 331 | + av_frame_free(&in); | |
| 326 | 332 | return ff_filter_frame(outlink, out); |
| 327 | 333 | } |
| 328 | 334 | |