diff options
author | Paul B Mahol <onemda@gmail.com> | 2023-02-06 14:57:50 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2023-02-12 13:32:00 +0100 |
commit | e506ea3ce1de0c782b2b833398240c8e19a02bb4 (patch) | |
tree | 09a019d09e096300024c435d15c3485d319bad04 /libavfilter | |
parent | 78f46065d861eb8487124e92ab46a459426eb89c (diff) | |
download | ffmpeg-e506ea3ce1de0c782b2b833398240c8e19a02bb4.tar.gz |
avfilter: use ff_inlink_make_frame_writable()
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/avf_abitscope.c | 11 | ||||
-rw-r--r-- | libavfilter/avf_ahistogram.c | 9 | ||||
-rw-r--r-- | libavfilter/avf_aphasemeter.c | 9 | ||||
-rw-r--r-- | libavfilter/avf_avectorscope.c | 7 | ||||
-rw-r--r-- | libavfilter/avf_showspectrum.c | 5 | ||||
-rw-r--r-- | libavfilter/avf_showvolume.c | 8 | ||||
-rw-r--r-- | libavfilter/f_ebur128.c | 12 | ||||
-rw-r--r-- | libavfilter/f_perms.c | 4 | ||||
-rw-r--r-- | libavfilter/framesync.c | 2 | ||||
-rw-r--r-- | libavfilter/vf_cover_rect.c | 9 | ||||
-rw-r--r-- | libavfilter/vf_dedot.c | 2 | ||||
-rw-r--r-- | libavfilter/vf_floodfill.c | 5 | ||||
-rw-r--r-- | libavfilter/vf_lensfun.c | 8 | ||||
-rw-r--r-- | libavfilter/vf_overlay_cuda.c | 3 | ||||
-rw-r--r-- | libavfilter/vf_paletteuse.c | 2 | ||||
-rw-r--r-- | libavfilter/vf_photosensitivity.c | 3 | ||||
-rw-r--r-- | libavfilter/vf_repeatfields.c | 49 | ||||
-rw-r--r-- | libavfilter/vf_signalstats.c | 27 | ||||
-rw-r--r-- | libavfilter/vf_telecine.c | 13 | ||||
-rw-r--r-- | libavfilter/vf_vidstabdetect.c | 12 |
20 files changed, 152 insertions, 48 deletions
diff --git a/libavfilter/avf_abitscope.c b/libavfilter/avf_abitscope.c index 4fc3c06ecb..782d57e03a 100644 --- a/libavfilter/avf_abitscope.c +++ b/libavfilter/avf_abitscope.c @@ -213,6 +213,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) AVFilterLink *outlink = ctx->outputs[0]; AudioBitScopeContext *s = ctx->priv; AVFrame *outpicref; + int ret; if (s->mode == 0 || !s->outpicref) { outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h); @@ -228,10 +229,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) } if (s->mode == 1) { - av_frame_make_writable(s->outpicref); + ret = ff_inlink_make_frame_writable(outlink, &s->outpicref); + if (ret < 0) { + av_frame_free(&insamples); + return ret; + } outpicref = av_frame_clone(s->outpicref); - if (!outpicref) + if (!outpicref) { + av_frame_free(&insamples); return AVERROR(ENOMEM); + } } outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base); diff --git a/libavfilter/avf_ahistogram.c b/libavfilter/avf_ahistogram.c index c45493730d..06490192a5 100644 --- a/libavfilter/avf_ahistogram.c +++ b/libavfilter/avf_ahistogram.c @@ -209,7 +209,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AudioHistogramContext *s = ctx->priv; const int H = s->histogram_h; const int w = s->w; - int c, y, n, p, bin; + int c, y, n, p, bin, ret; uint64_t acmax = 1; AVFrame *clone; @@ -229,7 +229,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } } - av_frame_make_writable(s->out); + ret = ff_inlink_make_frame_writable(outlink, &s->out); + if (ret < 0) { + av_frame_free(&in); + return ret; + } + if (s->dmode == SEPARATE) { for (y = 0; y < w; y++) { s->combine_buffer[3 * y ] = 0; diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c index 0f7692982c..bf9f922639 100644 --- a/libavfilter/avf_aphasemeter.c +++ b/libavfilter/avf_aphasemeter.c @@ -29,6 +29,7 @@ #include "libavutil/parseutils.h" #include "libavutil/timestamp.h" #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "audio.h" #include "video.h" @@ -246,7 +247,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) float fphase = 0; AVFrame *out; uint8_t *dst; - int i; + int i, ret; int mono_measurement; int out_phase_measurement; float tolerance = 1.0f - s->tolerance; @@ -265,8 +266,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) for (i = 0; i < outlink->h; i++) memset(out->data[0] + i * out->linesize[0], 0, outlink->w * 4); } else if (s->do_video) { + ret = ff_inlink_make_frame_writable(outlink, &s->out); + if (ret < 0) { + av_frame_free(&in); + return ret; + } out = s->out; - av_frame_make_writable(s->out); for (i = outlink->h - 1; i >= 10; i--) memmove(out->data[0] + (i ) * out->linesize[0], out->data[0] + (i-1) * out->linesize[0], diff --git a/libavfilter/avf_avectorscope.c b/libavfilter/avf_avectorscope.c index 3927d80b42..6e45fd9575 100644 --- a/libavfilter/avf_avectorscope.c +++ b/libavfilter/avf_avectorscope.c @@ -297,6 +297,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) unsigned x, y; unsigned prev_x = s->prev_x, prev_y = s->prev_y; double zoom = s->zoom; + int ret; if (!s->outpicref || s->outpicref->width != outlink->w || s->outpicref->height != outlink->h) { @@ -314,7 +315,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) s->outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base); s->outpicref->duration = 1; - av_frame_make_writable(s->outpicref); + ret = ff_inlink_make_frame_writable(outlink, &s->outpicref); + if (ret < 0) { + av_frame_free(&insamples); + return ret; + } ff_filter_execute(ctx, fade, NULL, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx))); if (zoom < 1) { diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 24a424a34a..4ce964706f 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -1441,7 +1441,10 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) } } - av_frame_make_writable(s->outpicref); + ret = ff_inlink_make_frame_writable(outlink, &s->outpicref); + if (ret < 0) + return ret; + outpicref = s->outpicref; /* copy to output */ if (s->orientation == VERTICAL) { if (s->sliding == SCROLL) { diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c index 24d42d030d..fa64d5237a 100644 --- a/libavfilter/avf_showvolume.c +++ b/libavfilter/avf_showvolume.c @@ -324,7 +324,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) AVFilterLink *outlink = ctx->outputs[0]; ShowVolumeContext *s = ctx->priv; const int step = s->step; - int c, j, k, max_draw; + int c, j, k, max_draw, ret; char channel_name[64]; AVFrame *out; @@ -434,7 +434,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) out = av_frame_clone(s->out); if (!out) return AVERROR(ENOMEM); - av_frame_make_writable(out); + ret = ff_inlink_make_frame_writable(outlink, &out); + if (ret < 0) { + av_frame_free(&out); + return ret; + } /* draw volume level */ for (c = 0; c < inlink->ch_layout.nb_channels && s->h >= 8 && s->draw_volume; c++) { diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index 8afab37fdb..38e7e0b295 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -618,13 +618,13 @@ static int gate_update(struct integrator *integ, double power, static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) { - int i, ch, idx_insample; + int i, ch, idx_insample, ret; AVFilterContext *ctx = inlink->dst; EBUR128Context *ebur128 = ctx->priv; const int nb_channels = ebur128->nb_channels; const int nb_samples = insamples->nb_samples; const double *samples = (double *)insamples->data[0]; - AVFrame *pic = ebur128->outpicref; + AVFrame *pic; #if CONFIG_SWRESAMPLE if (ebur128->peak_mode & PEAK_MODE_TRUE_PEAKS && ebur128->idx_insample == 0) { @@ -821,7 +821,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 - ebur128->target); y_loudness_lu_gauge = lu_to_y(ebur128, gauge_value); - av_frame_make_writable(pic); + ret = ff_inlink_make_frame_writable(outlink, &ebur128->outpicref); + if (ret < 0) { + av_frame_free(&insamples); + ebur128->insamples = NULL; + return ret; + } + pic = ebur128->outpicref; /* draw the graph using the short-term loudness */ p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + ebur128->graph.x*3; for (y = 0; y < ebur128->graph.h; y++) { diff --git a/libavfilter/f_perms.c b/libavfilter/f_perms.c index e26a15fd06..021652cfe8 100644 --- a/libavfilter/f_perms.c +++ b/libavfilter/f_perms.c @@ -24,6 +24,7 @@ #include "libavutil/opt.h" #include "libavutil/random_seed.h" #include "audio.h" +#include "filters.h" #include "video.h" enum mode { @@ -96,8 +97,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) in_perm == out_perm ? " (no-op)" : ""); if (in_perm == RO && out_perm == RW) { - if ((ret = av_frame_make_writable(frame)) < 0) + if ((ret = ff_inlink_make_frame_writable(inlink, &frame)) < 0) return ret; + out = frame; } else if (in_perm == RW && out_perm == RO) { out = av_frame_clone(frame); if (!out) diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c index ee91e4cf68..c748262ba6 100644 --- a/libavfilter/framesync.c +++ b/libavfilter/framesync.c @@ -288,7 +288,7 @@ int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, if (need_copy) { if (!(frame = av_frame_clone(frame))) return AVERROR(ENOMEM); - if ((ret = av_frame_make_writable(frame)) < 0) { + if ((ret = ff_inlink_make_frame_writable(fs->parent->inputs[in], &frame) < 0)) { av_frame_free(&frame); return ret; } diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c index 01c9f2abbb..642747a351 100644 --- a/libavfilter/vf_cover_rect.c +++ b/libavfilter/vf_cover_rect.c @@ -24,6 +24,7 @@ #include "libavutil/imgutils.h" #include "libavutil/opt.h" +#include "filters.h" #include "internal.h" #include "lavfutils.h" @@ -125,7 +126,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFilterContext *ctx = inlink->dst; CoverContext *cover = ctx->priv; AVDictionaryEntry *ex, *ey, *ew, *eh; - int x = -1, y = -1, w = -1, h = -1; + int ret, x = -1, y = -1, w = -1, h = -1; char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL; ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL, AV_DICT_MATCH_CASE); @@ -170,7 +171,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) x = av_clip(x, 0, in->width - w); y = av_clip(y, 0, in->height - h); - av_frame_make_writable(in); + ret = ff_inlink_make_frame_writable(inlink, &in); + if (ret < 0) { + av_frame_free(&in); + return ret; + } if (cover->mode == MODE_BLUR) { blur (cover, in, x, y); diff --git a/libavfilter/vf_dedot.c b/libavfilter/vf_dedot.c index a0638f45b4..6ca47c262a 100644 --- a/libavfilter/vf_dedot.c +++ b/libavfilter/vf_dedot.c @@ -289,7 +289,7 @@ static int activate(AVFilterContext *ctx) s->frames[4]) { out = av_frame_clone(s->frames[2]); if (out && !ctx->is_disabled) { - ret = av_frame_make_writable(out); + ret = ff_inlink_make_frame_writable(inlink, &out); if (ret >= 0) { if (s->m & 1) ff_filter_execute(ctx, s->dedotcrawl, out, NULL, diff --git a/libavfilter/vf_floodfill.c b/libavfilter/vf_floodfill.c index da747c9f9f..212255a784 100644 --- a/libavfilter/vf_floodfill.c +++ b/libavfilter/vf_floodfill.c @@ -22,6 +22,7 @@ #include "libavutil/imgutils.h" #include "libavutil/intreadwrite.h" #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "video.h" @@ -315,8 +316,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame) s->front++; } - if (ret = av_frame_make_writable(frame)) + if (ret = ff_inlink_make_frame_writable(link, &frame)) { + av_frame_free(&frame); return ret; + } while (s->front > s->back) { int x, y; diff --git a/libavfilter/vf_lensfun.c b/libavfilter/vf_lensfun.c index 35c522a723..f544af773e 100644 --- a/libavfilter/vf_lensfun.c +++ b/libavfilter/vf_lensfun.c @@ -32,6 +32,7 @@ #include "libavutil/opt.h" #include "libswscale/swscale.h" #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "video.h" @@ -443,9 +444,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFrame *out; VignettingThreadData vignetting_thread_data; DistortionCorrectionThreadData distortion_correction_thread_data; + int ret; if (lensfun->mode & VIGNETTING) { - av_frame_make_writable(in); + ret = ff_inlink_make_frame_writable(inlink, &in); + if (ret < 0) { + av_frame_free(&in); + return ret; + } vignetting_thread_data = (VignettingThreadData) { .width = inlink->w, diff --git a/libavfilter/vf_overlay_cuda.c b/libavfilter/vf_overlay_cuda.c index 68c00405fb..b2cbb9c625 100644 --- a/libavfilter/vf_overlay_cuda.c +++ b/libavfilter/vf_overlay_cuda.c @@ -32,6 +32,7 @@ #include "libavutil/eval.h" #include "avfilter.h" +#include "filters.h" #include "framesync.h" #include "internal.h" @@ -252,7 +253,7 @@ static int overlay_cuda_blend(FFFrameSync *fs) if (!input_overlay) return ff_filter_frame(outlink, input_main); - ret = av_frame_make_writable(input_main); + ret = ff_inlink_make_frame_writable(inlink, &input_main); if (ret < 0) { av_frame_free(&input_main); return ret; diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c index 944ff5c74d..5fa7a605ce 100644 --- a/libavfilter/vf_paletteuse.c +++ b/libavfilter/vf_paletteuse.c @@ -783,7 +783,7 @@ static int apply_palette(AVFilterLink *inlink, AVFrame *in, AVFrame **outf) av_frame_unref(s->last_out); if ((ret = av_frame_ref(s->last_in, in)) < 0 || (ret = av_frame_ref(s->last_out, out)) < 0 || - (ret = av_frame_make_writable(s->last_in)) < 0) { + (ret = ff_inlink_make_frame_writable(inlink, &s->last_in)) < 0) { av_frame_free(&out); *outf = NULL; return ret; diff --git a/libavfilter/vf_photosensitivity.c b/libavfilter/vf_photosensitivity.c index 1bb984cc93..e05d4d0262 100644 --- a/libavfilter/vf_photosensitivity.c +++ b/libavfilter/vf_photosensitivity.c @@ -25,6 +25,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "video.h" @@ -243,7 +244,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) /* just duplicate the frame */ s->history[s->history_pos] = 0; /* frame was duplicated, thus, delta is zero */ } else { - res = av_frame_make_writable(s->last_frame_av); + res = ff_inlink_make_frame_writable(inlink, &s->last_frame_av); if (res) { av_frame_free(&in); return res; diff --git a/libavfilter/vf_repeatfields.c b/libavfilter/vf_repeatfields.c index 9c02c61631..4d31f3b4f5 100644 --- a/libavfilter/vf_repeatfields.c +++ b/libavfilter/vf_repeatfields.c @@ -20,6 +20,7 @@ #include "libavutil/imgutils.h" #include "avfilter.h" +#include "filters.h" #include "internal.h" typedef struct RepeatFieldsContext { @@ -75,23 +76,23 @@ static void update_pts(AVFilterLink *link, AVFrame *f, int64_t pts, int fields) f->pts = AV_NOPTS_VALUE; } -static int filter_frame(AVFilterLink *inlink, AVFrame *in) { +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = inlink->dst->outputs[0]; RepeatFieldsContext *s = ctx->priv; - AVFrame *out; int ret, i; int state = s->state; if (!s->frame) { s->frame = av_frame_clone(in); - if (!s->frame) + if (!s->frame) { + av_frame_free(&in); return AVERROR(ENOMEM); + } s->frame->pts = AV_NOPTS_VALUE; } - out = s->frame; - if ((state == 0 && !in->top_field_first) || (state == 1 && in->top_field_first)) { av_log(ctx, AV_LOG_WARNING, "Unexpected field flags: " @@ -104,16 +105,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { AVFrame *new; new = av_frame_clone(in); - if (!new) + if (!new) { + av_frame_free(&in); return AVERROR(ENOMEM); + } ret = ff_filter_frame(outlink, new); if (in->repeat_pict) { - av_frame_make_writable(out); - update_pts(outlink, out, in->pts, 2); + ret = ff_inlink_make_frame_writable(inlink, &s->frame); + if (ret < 0) { + av_frame_free(&in); + return ret; + } + update_pts(outlink, s->frame, in->pts, 2); for (i = 0; i < s->nb_planes; i++) { - av_image_copy_plane(out->data[i], out->linesize[i] * 2, + av_image_copy_plane(s->frame->data[i], s->frame->linesize[i] * 2, in->data[i], in->linesize[i] * 2, s->linesize[i], s->planeheight[i] / 2); } @@ -121,28 +128,38 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { } } else { for (i = 0; i < s->nb_planes; i++) { - av_frame_make_writable(out); - av_image_copy_plane(out->data[i] + out->linesize[i], out->linesize[i] * 2, + ret = ff_inlink_make_frame_writable(inlink, &s->frame); + if (ret < 0) { + av_frame_free(&in); + return ret; + } + av_image_copy_plane(s->frame->data[i] + s->frame->linesize[i], s->frame->linesize[i] * 2, in->data[i] + in->linesize[i], in->linesize[i] * 2, s->linesize[i], s->planeheight[i] / 2); } - ret = ff_filter_frame(outlink, av_frame_clone(out)); + ret = ff_filter_frame(outlink, av_frame_clone(s->frame)); if (in->repeat_pict) { AVFrame *new; new = av_frame_clone(in); - if (!new) + if (!new) { + av_frame_free(&in); return AVERROR(ENOMEM); + } ret = ff_filter_frame(outlink, new); state = 0; } else { - av_frame_make_writable(out); - update_pts(outlink, out, in->pts, 1); + ret = ff_inlink_make_frame_writable(inlink, &s->frame); + if (ret < 0) { + av_frame_free(&in); + return ret; + } + update_pts(outlink, s->frame, in->pts, 1); for (i = 0; i < s->nb_planes; i++) { - av_image_copy_plane(out->data[i], out->linesize[i] * 2, + av_image_copy_plane(s->frame->data[i], s->frame->linesize[i] * 2, in->data[i], in->linesize[i] * 2, s->linesize[i], s->planeheight[i] / 2); } diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c index e6f84be9ba..b4d1029296 100644 --- a/libavfilter/vf_signalstats.c +++ b/libavfilter/vf_signalstats.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "filters.h" #include "internal.h" enum FilterMode { @@ -565,7 +566,7 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) int tothue = 0; int dify = 0, difu = 0, difv = 0; uint16_t masky = 0, masku = 0, maskv = 0; - + int ret; int filtot[FILT_NUMB] = {0}; AVFrame *prev; @@ -588,7 +589,16 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) if (s->outfilter != FILTER_NONE) { out = av_frame_clone(in); - av_frame_make_writable(out); + if (!out) { + av_frame_free(&in); + return AVERROR(ENOMEM); + } + ret = ff_inlink_make_frame_writable(link, &out); + if (ret < 0) { + av_frame_free(&out); + av_frame_free(&in); + return ret; + } } ff_filter_execute(ctx, compute_sat_hue_metrics8, &td_huesat, @@ -790,7 +800,7 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) int filtot[FILT_NUMB] = {0}; AVFrame *prev; - + int ret; AVFrame *sat = s->frame_sat; AVFrame *hue = s->frame_hue; const uint16_t *p_sat = (uint16_t *)sat->data[0]; @@ -810,7 +820,16 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) if (s->outfilter != FILTER_NONE) { out = av_frame_clone(in); - av_frame_make_writable(out); + if (!out) { + av_frame_free(&in); + return AVERROR(ENOMEM); + } + ret = ff_inlink_make_frame_writable(link, &out); + if (ret < 0) { + av_frame_free(&out); + av_frame_free(&in); + return ret; + } } ff_filter_execute(ctx, compute_sat_hue_metrics16, &td_huesat, diff --git a/libavfilter/vf_telecine.c b/libavfilter/vf_telecine.c index e8de63bbcf..227de6f733 100644 --- a/libavfilter/vf_telecine.c +++ b/libavfilter/vf_telecine.c @@ -29,6 +29,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "video.h" @@ -182,7 +183,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) } if (s->occupied) { - av_frame_make_writable(s->frame[nout]); + ret = ff_inlink_make_frame_writable(inlink, &s->frame[nout]); + if (ret < 0) { + av_frame_free(&inpicref); + return ret; + } for (i = 0; i < s->nb_planes; i++) { // fill in the EARLIER field from the buffered pic av_image_copy_plane(s->frame[nout]->data[i] + s->frame[nout]->linesize[i] * s->first_field, @@ -208,7 +213,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) while (len >= 2) { // output THIS image as-is - av_frame_make_writable(s->frame[nout]); + ret = ff_inlink_make_frame_writable(inlink, &s->frame[nout]); + if (ret < 0) { + av_frame_free(&inpicref); + return ret; + } for (i = 0; i < s->nb_planes; i++) av_image_copy_plane(s->frame[nout]->data[i], s->frame[nout]->linesize[i], inpicref->data[i], inpicref->linesize[i], diff --git a/libavfilter/vf_vidstabdetect.c b/libavfilter/vf_vidstabdetect.c index 62b998e171..b27b1e40a6 100644 --- a/libavfilter/vf_vidstabdetect.c +++ b/libavfilter/vf_vidstabdetect.c @@ -27,6 +27,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "filters.h" #include "internal.h" #include "vidstabutils.h" @@ -149,10 +150,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFilterLink *outlink = inlink->dst->outputs[0]; VSFrame frame; - int plane; + int plane, ret; - if (s->conf.show > 0 && !av_frame_is_writable(in)) - av_frame_make_writable(in); + if (s->conf.show > 0 && !av_frame_is_writable(in)) { + ret = ff_inlink_make_frame_writable(inlink, &in); + if (ret < 0) { + av_frame_free(&in); + return ret; + } + } for (plane = 0; plane < md->fi.planes; plane++) { frame.data[plane] = in->data[plane]; |