From patchwork Wed Dec 30 23:31:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24711 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id ED17D44B882 for ; Thu, 31 Dec 2020 01:35:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 17E5E68A92E; Thu, 31 Dec 2020 01:33:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D8AED68A912 for ; Thu, 31 Dec 2020 01:32:52 +0200 (EET) Received: by mail-ej1-f50.google.com with SMTP id d17so23634724ejy.9 for ; Wed, 30 Dec 2020 15:32:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=V+uNbwkjySmDzy206uGlUtz3QIMYS27EBEEtOjZVU68=; b=XEYpx3r4kBObU8cktYE4FlDqZDEzuWN8hB2U3fLTk3QMKTakTAWNqEyZu7WYRsZ/TW +CumzzOUACXJBHWoJfAjPJQyeQYIdQHjYphNp2ljAXcYpGgcScoL0Qp7rs2Kw4v6kcXC W/C1tX7VQezFXzUiYf4WQuwdo3BKMpn/JiacgmdVs/g6vi1ntjYuCImhyy4UL7wH1fV8 yqWhMHrvyT2bug/bgnrCAZF3eciqEpTTLKLbInWYWOdFKJo9zLPH8R7fHwMh46VsirNy mWLcyDKj1/1neB9pnqd0V/Qh55dXSOfXIGM+aSF3QZeT9Hkt5X72bQSLt7BOdzBLAuJC Rs7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=V+uNbwkjySmDzy206uGlUtz3QIMYS27EBEEtOjZVU68=; b=iG7m0wL788MpnNHhkm5oXGnjOxSvKyUi8gJBPAVBvjzGK2eMMLPifSYnckSSeKlCzC drPBCgqiwlwaARl1Rk6unc0PyHpMrXspgdS3Mwpg7W8n2k5oATjnhpZvn1UWSqJ4+Fwr cWfnkDQvf0p5q1taCz6Ak748piGGK1NKL3NM+Qn38QtJqAObHTVpSo88pb2FShcOguYH nPPlBSwIqWL0Il+OmYy/XVzkZuq3lPgrz0zgfow0rZ9knnMwKSzffPu5e58aJW97Sy34 AFVraF34CIMyla8yxpeVnn5nRzHWXYuB9WMA25XutodFCyNsmdpTZrwrY+c7/pno5ATC NgJQ== X-Gm-Message-State: AOAM533nmBKopR26MdNzzx4Ot2CUj6UL/xRyHqu3hDLo2tTPYJQ77Kad dV4oDBlGf8Js+fmydDS5QKZX89YJKm0= X-Google-Smtp-Source: ABdhPJxaxsp+PK0+/arYfXqWLXia24DcUq7HXLvkUbGDvQKduECoRBE7Y5MU+5h07wtPrbzUodYdDw== X-Received: by 2002:a17:906:c414:: with SMTP id u20mr50347048ejz.511.1609371172156; Wed, 30 Dec 2020 15:32:52 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id u19sm19630409ejg.16.2020.12.30.15.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Dec 2020 15:32:51 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 31 Dec 2020 00:31:46 +0100 Message-Id: <20201230233157.1055287-19-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201230233157.1055287-1-andreas.rheinhardt@gmail.com> References: <20201230233157.1055287-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/30] avcodec/opusdec: Cleanup generically in init failure X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavcodec/opusdec.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c index b09a542c86..24e90a3761 100644 --- a/libavcodec/opusdec.c +++ b/libavcodec/opusdec.c @@ -630,17 +630,14 @@ static av_cold int opus_decode_init(AVCodecContext *avctx) /* find out the channel configuration */ ret = ff_opus_parse_extradata(avctx, c); - if (ret < 0) { - av_freep(&c->fdsp); + if (ret < 0) return ret; - } /* allocate and init each independent decoder */ c->streams = av_mallocz_array(c->nb_streams, sizeof(*c->streams)); if (!c->streams) { c->nb_streams = 0; - ret = AVERROR(ENOMEM); - goto fail; + return AVERROR(ENOMEM); } for (i = 0; i < c->nb_streams; i++) { @@ -660,10 +657,8 @@ static av_cold int opus_decode_init(AVCodecContext *avctx) s->fdsp = c->fdsp; s->swr =swr_alloc(); - if (!s->swr) { - ret = AVERROR(ENOMEM); - goto fail; - } + if (!s->swr) + return AVERROR(ENOMEM); layout = (s->output_channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; av_opt_set_int(s->swr, "in_sample_fmt", avctx->sample_fmt, 0); @@ -675,31 +670,24 @@ static av_cold int opus_decode_init(AVCodecContext *avctx) ret = ff_silk_init(avctx, &s->silk, s->output_channels); if (ret < 0) - goto fail; + return ret; ret = ff_celt_init(avctx, &s->celt, s->output_channels, c->apply_phase_inv); if (ret < 0) - goto fail; + return ret; s->celt_delay = av_audio_fifo_alloc(avctx->sample_fmt, s->output_channels, 1024); - if (!s->celt_delay) { - ret = AVERROR(ENOMEM); - goto fail; - } + if (!s->celt_delay) + return AVERROR(ENOMEM); s->sync_buffer = av_audio_fifo_alloc(avctx->sample_fmt, s->output_channels, 32); - if (!s->sync_buffer) { - ret = AVERROR(ENOMEM); - goto fail; - } + if (!s->sync_buffer) + return AVERROR(ENOMEM); } return 0; -fail: - opus_decode_close(avctx); - return ret; } #define OFFSET(x) offsetof(OpusContext, x) @@ -728,4 +716,5 @@ AVCodec ff_opus_decoder = { .decode = opus_decode_packet, .flush = opus_decode_flush, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_CHANNEL_CONF, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, };