From patchwork Mon Feb 6 14:12:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 40303 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp3394072pzk; Mon, 6 Feb 2023 06:12:25 -0800 (PST) X-Google-Smtp-Source: AK7set8oyg4SFhcDH2ia6uBeu2TVDM48wJVaLv53OtP64asQ1yPJ+4mVDrfdEZJ67bpsy8G3sLOV X-Received: by 2002:a17:907:3e07:b0:88f:8c13:52d1 with SMTP id hp7-20020a1709073e0700b0088f8c1352d1mr16965666ejc.48.1675692744733; Mon, 06 Feb 2023 06:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675692744; cv=none; d=google.com; s=arc-20160816; b=llbmwv23bViVhCmQ+ggT1+GJT3o7Vyrm5lksa04H7xO9SonYyoIJ/RBZZgI1KawRW4 QSJWshCi38KE6k2dWJH0pr1kHymPWKABBUKep4fRvHQSjs5Jm73NUBY93Wt0JBMIczoT Pi6Ug/W6gqx287F7aXWiAEnioA9JELTJgLmo0lpEPqUCPRucD0VUCtTn0ZIKsQRc1dr8 ODX+EE6gVZyJ0Xo+cmrj8StoXBp8p+ENfE7DOWZQkq+mPbJhXX/DuTK6XwoLzjRQJW2y SYwUhG7YtUFdddRUY+MQUyu+5WfWno6mWrDKRG30+t1b8fRLKLoOeTOxDXpubjIHlepb rRxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to; bh=xnrnoRehCKSJaMdiwAhG7wWqyCyZ3Px2Ry59qUaV0C0=; b=yOHRpjWMqC+vOJia/9+5JLi0eCftTqNb39ntg/PQTfy5zJjQvcvTprCHOjUHqiTalj nxp4gXIundgKKFlmS+AsReG7+IMfeafLmmHsesMgyt7BuTqdPKi0Q1IRFdL/hk85CQQA PlVXk7FISbJF3SnJwYPB+ZT+YNvWJFtXEYlHkoY3dNylSr2ipFRSn/9c93Yu9vIPbk3x /2fPmR14jOtm/Pg88gc5zEGu4RvJp29u/B7CQ1l0jicqanpVO5WUKzjij2eQWFykkyeq T0D9nAyM3fxOQhWkjcUZMAFP9oc48hzy8Hv00GxOBVnCaPs4/Ee+M7VOdUpgSxPCdI/r Jg/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="GMCR/CdW"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ex2-20020a170907954200b0086cb918f2b2si7465537ejc.581.2023.02.06.06.12.24; Mon, 06 Feb 2023 06:12:24 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="GMCR/CdW"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D09FE68BE46; Mon, 6 Feb 2023 16:12:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vs1-f54.google.com (mail-vs1-f54.google.com [209.85.217.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E201268B9DB for ; Mon, 6 Feb 2023 16:12:13 +0200 (EET) Received: by mail-vs1-f54.google.com with SMTP id p10so12778008vsu.5 for ; Mon, 06 Feb 2023 06:12:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=gJmp+lwRz/F/V3j6qWa+Ea3aoiScFvM/NJd2oUYzUSA=; b=GMCR/CdWghrONBNtVzF4T2ttM6ASzrHKV3LljzLjSZpBI6tpfZVqx9KV2KVK29HHSk mYbcJGJoV+m5BILfitJMhZk23NVJwX076XSWVjoPu7Ost1PrDBB83kf21hGdtWfg5nir kU0fC7hkh7E22bufDJPkhxOVAJM08lzbT8NGFG5R0q85QpUu7HuNbU9r06psG5PGFtn2 FntULcgdpkzwgkjj6Qu0eAEDOe5VvbPoInO2NTuuPsrUPCHDmHTbvDl1ucjYEotJRPwy O8vEdyiwx+FbL7vMLqYRYK7EJUEE/oCS/jqEtaMtzeFOK1UL4wKX/Q9bzN9M6McccITy MV4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=gJmp+lwRz/F/V3j6qWa+Ea3aoiScFvM/NJd2oUYzUSA=; b=JG+yTR1eB16nMLjaDvUegsi/pKTmrVvsWmRZkkk01ao9NQaiWl7dgPnmYV2yJRyfrK ssDmttwvfoxQri2WBMojyhioZISVd2otBSn72RB8xosAK7/yKTRy/d1K2Eq/8xGEz55c kJ0ELcth4SeBmG671vu4MtackJehqojUvJmfUA7fmAVudlgh6/ITpyELc8A9kziGG+CN k0/rfkvIBPpDhCHFwn7kZ+KXuIE2aWXboLv+bH/ARN4ZYrpGSCVL+z5wMos5TFIML/6O s+SUxngMcQRNFUip+hor0/mJ8IY+ekqb9w4lrSgPIn3ARfoukDOffxJ3/wxmZXFQW3pZ oz/w== X-Gm-Message-State: AO0yUKVFB3YHMUljuM8BopYfC6LSSXJw6xk+om42WH39XRfQ73r5d+v5 QF5WVzWLHEcDOiPLqN6kHUpB9etNbsbbTmB6OnbmXp8/ X-Received: by 2002:a05:6102:441f:b0:403:7f25:badc with SMTP id df31-20020a056102441f00b004037f25badcmr2066935vsb.36.1675692732384; Mon, 06 Feb 2023 06:12:12 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:612c:2428:b0:32a:5eaa:92e4 with HTTP; Mon, 6 Feb 2023 06:12:11 -0800 (PST) From: Paul B Mahol Date: Mon, 6 Feb 2023 15:12:11 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avfilter: use ff_inlink_make_frame_writable() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Qg3ZtGVIEqp+ Patch attached. From 8d2d4d35a54d0a3ddf300ef7196489898c3efc4e Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 6 Feb 2023 14:57:50 +0100 Subject: [PATCH] avfilter: use ff_inlink_make_frame_writable() Signed-off-by: Paul B Mahol --- libavfilter/avf_abitscope.c | 11 +++++++++-- libavfilter/avf_ahistogram.c | 9 +++++++-- libavfilter/avf_aphasemeter.c | 9 +++++++-- libavfilter/avf_avectorscope.c | 7 ++++++- libavfilter/avf_showspectrum.c | 5 ++++- libavfilter/avf_showvolume.c | 6 ++++-- libavfilter/f_ebur128.c | 10 ++++++++-- libavfilter/f_perms.c | 3 ++- libavfilter/framesync.c | 2 +- libavfilter/vf_cover_rect.c | 7 +++++-- libavfilter/vf_dedot.c | 2 +- libavfilter/vf_floodfill.c | 3 ++- libavfilter/vf_lensfun.c | 6 +++++- libavfilter/vf_overlay_cuda.c | 3 ++- libavfilter/vf_paletteuse.c | 2 +- libavfilter/vf_photosensitivity.c | 3 ++- libavfilter/vf_repeatfields.c | 13 ++++++++++--- libavfilter/vf_signalstats.c | 13 +++++++++---- libavfilter/vf_telecine.c | 13 +++++++++++-- libavfilter/vf_vidstabdetect.c | 10 +++++++--- 20 files changed, 103 insertions(+), 34 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..645fc68cb0 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,9 @@ 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) + 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..ef0fb4a52a 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -618,7 +618,7 @@ 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; @@ -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..95fb97f201 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,7 +97,7 @@ 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; } else if (in_perm == RW && out_perm == RO) { out = av_frame_clone(frame); diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c index ee91e4cf68..422f4f7ad1 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[0], &frame) < 0)) { av_frame_free(&frame); return ret; } diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c index 01c9f2abbb..2fc5fc9693 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,9 @@ 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) + 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..952f1d15f1 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,7 +316,7 @@ 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)) return ret; while (s->front > s->back) { diff --git a/libavfilter/vf_lensfun.c b/libavfilter/vf_lensfun.c index 35c522a723..52652e0c9b 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,12 @@ 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) + 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..4ace5a18f7 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 { @@ -110,7 +111,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { ret = ff_filter_frame(outlink, new); if (in->repeat_pict) { - av_frame_make_writable(out); + ret = ff_inlink_make_frame_writable(inlink, &out); + if (ret < 0) + return ret; update_pts(outlink, out, in->pts, 2); for (i = 0; i < s->nb_planes; i++) { av_image_copy_plane(out->data[i], out->linesize[i] * 2, @@ -121,7 +124,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { } } else { for (i = 0; i < s->nb_planes; i++) { - av_frame_make_writable(out); + ret = ff_inlink_make_frame_writable(inlink, &out); + if (ret < 0) + return ret; av_image_copy_plane(out->data[i] + out->linesize[i], out->linesize[i] * 2, in->data[i] + in->linesize[i], in->linesize[i] * 2, s->linesize[i], s->planeheight[i] / 2); @@ -139,7 +144,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { ret = ff_filter_frame(outlink, new); state = 0; } else { - av_frame_make_writable(out); + ret = ff_inlink_make_frame_writable(inlink, &out); + if (ret < 0) + return ret; update_pts(outlink, out, in->pts, 1); for (i = 0; i < s->nb_planes; i++) { av_image_copy_plane(out->data[i], out->linesize[i] * 2, diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c index e6f84be9ba..93ff378b31 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,9 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in) if (s->outfilter != FILTER_NONE) { out = av_frame_clone(in); - av_frame_make_writable(out); + ret = ff_inlink_make_frame_writable(link, &out); + if (ret < 0) + return ret; } ff_filter_execute(ctx, compute_sat_hue_metrics8, &td_huesat, @@ -790,7 +793,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 +813,9 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) if (s->outfilter != FILTER_NONE) { out = av_frame_clone(in); - av_frame_make_writable(out); + ret = ff_inlink_make_frame_writable(link, &out); + if (ret < 0) + 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..3eb1abab46 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,13 @@ 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) + return ret; + } for (plane = 0; plane < md->fi.planes; plane++) { frame.data[plane] = in->data[plane]; -- 2.39.1