From patchwork Sun Sep 13 02:57:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22312 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 A4D1C449E91 for ; Sun, 13 Sep 2020 05:58:09 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 71D5A68BBA3; Sun, 13 Sep 2020 05:58:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78FDC68BB89 for ; Sun, 13 Sep 2020 05:58:02 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id z1so15070656wrt.3 for ; Sat, 12 Sep 2020 19:58:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WXUdTwYNAJg/bd8JHVRlMpiECtj6R+ld//4W7UKv0SM=; b=kK/Z45DfyyP6pAwMVjvYgfhcrZ7vywD2YO7RFcINF6mQzFouoI+mRUKFx0zkCvghtr ehbxd10hA3Cxr1r/H5Q5yXf0Y9SBcvHplH8nrL5RzPFeOmkLwsFva3M06GslRtXPCMf9 TZIMZJ+XgqzhBnWFiauo7BoQeEmMLSS0/xFGcVw2XSyXa+u4cvy2wZA9W4FbbFBoNdUa hcnuweHXcYI+zg3WbLE2UGdoZMKSAtdEtdZbyeUtnoTXm961peuIe+vWmUKqPqHilyyd hhHS+Knw3t9DgQOukuGQgehchdBvz/fNPyvhB7vO2tMiReJFB9CwKKLF+24YmsXVoLnb 9hDA== 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:mime-version :content-transfer-encoding; bh=WXUdTwYNAJg/bd8JHVRlMpiECtj6R+ld//4W7UKv0SM=; b=b7PGBXhvZgNqd35X3UhzpypN/UQzXGdADDsPyqa7EvXve2Teq2m/gpkAtW24DgSJsL igOwPTEc6x8+mpD8RUIKQyy0VlikpeQ3rrdkWtOE6EGR/yrH1sXfeTUZE6Wx+J/uaJoS qIbSQl3OeMUf1mT3hWPQH7m2AL1r5jTJkaWeMGJTgNEl9vz1Oe0Bc1iVxM1OdLa6L+AT z5J3/M3gAdRgVl/4H5JYGlMcdW/YiwhtccZve1IBqKjBtOmrhjOjX1IYPS7T6v46w9AC ZBvtv4jxidk7WdxA3XZqnis8E2G8vMF0MXmmlYtkvT5aJQB43gHg2KXxcR6CLcwWoprP ZKbQ== X-Gm-Message-State: AOAM530/S2S/8eZ61EYs3HPDjwZLQBNIaojhu781dyh4LhGbmYgFDCmR XabA4FPX7JMUCVr4yWXdm43CFoed3yk= X-Google-Smtp-Source: ABdhPJyA4birN0hVy4gYIRaIGIp1IWqDrzBoBWUj8/UVUcg3Fg6q9Sf/1CMGZ6VBkqDxauYZ1/VR9w== X-Received: by 2002:a5d:68d1:: with SMTP id p17mr8787084wrw.378.1599965881730; Sat, 12 Sep 2020 19:58:01 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:00 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:38 +0200 Message-Id: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/16] avcodec/snowdec: Use ff_snow_common_init() directly 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/snowdec.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 5e69f39022..68afe0df26 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -422,17 +422,6 @@ static int decode_header(SnowContext *s){ return 0; } -static av_cold int decode_init(AVCodecContext *avctx) -{ - int ret; - - if ((ret = ff_snow_common_init(avctx)) < 0) { - return ret; - } - - return 0; -} - static int decode_blocks(SnowContext *s){ int x, y; int w= s->b_width; @@ -665,7 +654,7 @@ AVCodec ff_snow_decoder = { .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_SNOW, .priv_data_size = sizeof(SnowContext), - .init = decode_init, + .init = ff_snow_common_init, .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/, From patchwork Sun Sep 13 02:57:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22313 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 10C86449E91 for ; Sun, 13 Sep 2020 05:58:28 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E165168BBB1; Sun, 13 Sep 2020 05:58:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CB09A68BBAE for ; Sun, 13 Sep 2020 05:58:21 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id c18so15044021wrm.9 for ; Sat, 12 Sep 2020 19:58:21 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=XMgWXlWMJ4Ri9BwlLJdoVTvQf6wLrjY+c/PXRd79uk4=; b=MuDGcPiCskQpdk08mkY08bzvpOBBTh27WbDTj3FESzOyjib1h3PCuazTg2HBxJiCbO BvUeKRg4lxtcYoe3Kp2CHxM8p8jGUgr79W1Rgc+8+YOc/25CNRPgMRjPjj/dsJxxSuda U4akECCKO8eyHktikVg2QBfYCPLIsmgZolfPI547TA4+2NTbAAOuylYU9E7z88yTzccU Jl+OlEX1NRvRipvMSDZeRgAPGgBsijfMrfj6bprcKeuYu9LOBMY/RlS3ZrSdyT0K22Ql sIauTEiGw+7CMTbIMdxw0AvqKcflrBaPIkNrPUt+OewZUXxytqjklqmcxMmM1760S7sx QyIw== 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:mime-version:content-transfer-encoding; bh=XMgWXlWMJ4Ri9BwlLJdoVTvQf6wLrjY+c/PXRd79uk4=; b=rbgHb9pPHdb74QyH/CicCUil7RjJXitqi/BchpPFc9RP/4Wfc9EYNEfbXXsil+HbiR MmmtGKEnXiPPMoewC+YSwsCmGLKz0W2mQl+iPLEWkzuM9o0KzI2lBbkcN4wKGj4XYMeQ T6cwQC6ZCJ2KyklqhwfArju7V7/cwInV4w9nZ8sMi2sfugtnQ1fKZbXX48ZAlyRqMk1g aOqEP3tLum3d1guXBqSrB1sFhL6y+Qux/LwkNP1WQJPJpvR8qRS4Ebf93hEloj9h6IHa SRlv9l/eaCSxDnG2IW6U2Ak5gm0zjJnNFsnGAkpbDTShMELCTMsn0XGeR/l4B7Kf7lvw pBWA== X-Gm-Message-State: AOAM530Obl969p29Xt88A5BKBZfMwcS7m/sjSrGAnKhepcqRvuvZsWfH 2UguyvcmmJCdxM5OWOQilXCeuNMWlAw= X-Google-Smtp-Source: ABdhPJzG3CCTWv0ehN1/erwtAK2tZ1mbFeOxi8hhmxDfCxxaNSYN3Twzio2DwKhPoQoMpERf7BGe6w== X-Received: by 2002:adf:ef45:: with SMTP id c5mr8833200wrp.37.1599965901052; Sat, 12 Sep 2020 19:58:21 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:20 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:39 +0200 Message-Id: <20200913025753.274772-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/16] avcodec/pcm-dvd: Avoid allocation of buffer 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" In this case, it also allows to remove the decoder's close function. Signed-off-by: Andreas Rheinhardt --- libavcodec/pcm-dvd.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c index 0a751a8191..725c2f5b29 100644 --- a/libavcodec/pcm-dvd.c +++ b/libavcodec/pcm-dvd.c @@ -34,8 +34,9 @@ typedef struct PCMDVDContext { int last_block_size; // Size of the last block of samples in bytes int samples_per_block; // Number of samples per channel per block int groups_per_block; // Number of 20/24-bit sample groups per block - uint8_t *extra_samples; // Pointer to leftover samples from a frame int extra_sample_count; // Number of leftover samples in the buffer + uint8_t extra_samples[8 * 3 * 4]; // Space for leftover samples from a frame + // (8 channels, 3B/sample, 4 samples/block) } PCMDVDContext; static av_cold int pcm_dvd_decode_init(AVCodecContext *avctx) @@ -44,18 +45,6 @@ static av_cold int pcm_dvd_decode_init(AVCodecContext *avctx) /* Invalid header to force parsing of the first header */ s->last_header = -1; - /* reserve space for 8 channels, 3 bytes/sample, 4 samples/block */ - if (!(s->extra_samples = av_malloc(8 * 3 * 4))) - return AVERROR(ENOMEM); - - return 0; -} - -static av_cold int pcm_dvd_decode_uninit(AVCodecContext *avctx) -{ - PCMDVDContext *s = avctx->priv_data; - - av_freep(&s->extra_samples); return 0; } @@ -310,7 +299,6 @@ AVCodec ff_pcm_dvd_decoder = { .priv_data_size = sizeof(PCMDVDContext), .init = pcm_dvd_decode_init, .decode = pcm_dvd_decode_frame, - .close = pcm_dvd_decode_uninit, .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE From patchwork Sun Sep 13 02:57:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22315 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 722BF449E91 for ; Sun, 13 Sep 2020 05:58:30 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5594068BBB9; Sun, 13 Sep 2020 05:58:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E36FC68BBB6 for ; Sun, 13 Sep 2020 05:58:22 +0300 (EEST) Received: by mail-wr1-f51.google.com with SMTP id z4so15089601wrr.4 for ; Sat, 12 Sep 2020 19:58:22 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=UYgqY52eODU7ZtiRBTY8T4VdizIQuMDNUXjdoZGjxY8=; b=vhbU+NS+92WUKe/H7dUU3+thl9khL/EptIn2qPAf3tLniXfl7T/Odt8LaL0P9lB8AL z90As1mp4l97h3ldRJFp8i5fqhRIM7J4nMbnx28U8kCt9SAJTnFsEI0CYAurMsn7MSyo rVY+sDTXTR9/WPsxDS9Weiv0hbGBNNryLQNnjFNmrrTnKjMNISHzj28eDVBFmwCkY77P QCcfjt6GPrMheWdbcJEToigXJdIL3W6r9Kd3/SsBXN61QfQ873D8zwsyz+gLUjo/Sm4i u03ytNgkCYe6emhcYkXWc932YrrHeR/hS9QZQQ7EA85tiShAchyO8uqJnkh6SsHCW5oZ yNkw== 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:mime-version:content-transfer-encoding; bh=UYgqY52eODU7ZtiRBTY8T4VdizIQuMDNUXjdoZGjxY8=; b=hpno5shOrhkI1CxoRwBqxUKNzd93+5G+EfkwDrwuG1hvmdXBc4vTmH7SZL5kRZceiS weLYLAddILpB3GzgVLCUgjHza9tIH/PVIdogwtp8TwH5tsM1B5nLh3e/DsDpUbslSK/v d2zlShbCN1MmGgurRElskPQ9CAYuey+bYOOLUx7LhnwUpsapEb5DpXYbV8878TyJMzm+ LZ+t6yppPomUyvGrlsjiuZEIF6uSqUoDqYNTwOeKAQNAh4GsuUoxE4EEGWpWG8wvJuJK VgHjRUFfogswpuyWeqt1OJBK9+G1tIiDp+ydSrzKJwzGWhiTReG56z5wESK6WJ02wNLA a/Ew== X-Gm-Message-State: AOAM53254w6zxlnJGIEkr4GKZj2jwOj4hC9oeZEJH8dClYqiHZ3b10JF t5y4rK9ZyEs1V9CHpGJNgV5n6flVhMk= X-Google-Smtp-Source: ABdhPJyG55n3iZn0lVlK7SPM4U0jIqMp7y6n43Y/FDn60JGo5HGC9kJijWMEwWq63eDcxWpevZgqyw== X-Received: by 2002:a5d:5602:: with SMTP id l2mr9695822wrv.410.1599965902044; Sat, 12 Sep 2020 19:58:22 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:21 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:40 +0200 Message-Id: <20200913025753.274772-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/16] avcodec/pcm-dvdenc: Remove empty function 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/pcm-dvdenc.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c index d26eaf071c..63f6e5d81b 100644 --- a/libavcodec/pcm-dvdenc.c +++ b/libavcodec/pcm-dvdenc.c @@ -170,11 +170,6 @@ static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, return 0; } -static av_cold int pcm_dvd_encode_close(AVCodecContext *avctx) -{ - return 0; -} - AVCodec ff_pcm_dvd_encoder = { .name = "pcm_dvd", .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for DVD media"), @@ -182,7 +177,6 @@ AVCodec ff_pcm_dvd_encoder = { .id = AV_CODEC_ID_PCM_DVD, .priv_data_size = sizeof(PCMDVDContext), .init = pcm_dvd_encode_init, - .close = pcm_dvd_encode_close, .encode2 = pcm_dvd_encode_frame, .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .supported_samplerates = (const int[]) { 48000, 96000, 0}, From patchwork Sun Sep 13 02:57:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22317 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 DC72D449E91 for ; Sun, 13 Sep 2020 05:58:32 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C506568BBD2; Sun, 13 Sep 2020 05:58:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B7A3468BBBB for ; Sun, 13 Sep 2020 05:58:23 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id z1so15070957wrt.3 for ; Sat, 12 Sep 2020 19:58:23 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=l++VrG4XnSHpy4Lrw5yMVQXiP4FE0Mabn04b1B75sh4=; b=EJzn4Fgs4QUAmbyko0q+VjzJslOpLv7VNihi2RjkWjZkZS1y8+trKRpbgsNAvacGQw Vi2zzbAXFEVwppE6oUbPjc1gEID0NPjdtryAZwwlePOIVoqYYFrJrXOOHEqu6V04XQMH CG/nPsx36ZekAVfC7wACl7UsaNYCV2WA8+lgUNI7DJwAN+vHLY+A1lBp0oWu4SMEAbR+ iMGmDm77Yr8w16X1loU1z7tlbbPLXjiFZ7eOa4mrXxfgVQYuPMUZDIQbkdk/MSxcqepH WCh+GcHL5EYRVCwt0za7NBXpHiieM1ud8Lpt86zu94CcnPamB3Po2vEgTuN/d8klhtoZ MGTQ== 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:mime-version:content-transfer-encoding; bh=l++VrG4XnSHpy4Lrw5yMVQXiP4FE0Mabn04b1B75sh4=; b=RFSwrIjwYnQTAdKAIq7VYVTOcwK0H1kdrxli4PlBut97a0GVhXPlE4iWmfUs/RrlaI JNdMFLV8I7ahCsYtB25dk2g0VqIvzJ0sRcrYa3DmhZ4IMMmvKrSgrbzyhsvRwpqGrZUV SaU72kwqgjz1ZG3O8n9hEE0Gku8f26d1o0E0fYjZBPi2z0ORiZ32QKpBUPuRmrc37CW2 42bDlJlTHsBS58M4urNI32Y3sdBFYRg5zgj26GzQx21k77hT1PFHjIG1Epmfq/ezQ0BW WVTUhiTzrNWo4+W47x0klIKBJe66I09w3saDtsbT15uJFKVoZ0IlwB+8SQPJcPlcb+CP IwjQ== X-Gm-Message-State: AOAM530egM7540twyV1qxFpvnukLxMRAZKlUH+XEGwNSWIm9tzjhsvBj sOUTbXotXxAuGnc9EMsBEPaSC4w1WGA= X-Google-Smtp-Source: ABdhPJx1pF19J6gHRZOyBxOt6ZRU4CXmmv2Ya1aUEJ5PJKj3cMP+4SS92+SeUxsQs9ofSOzwMWbhAg== X-Received: by 2002:adf:c44d:: with SMTP id a13mr8971762wrg.11.1599965902952; Sat, 12 Sep 2020 19:58:22 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:22 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:41 +0200 Message-Id: <20200913025753.274772-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/16] avcodec/qtrleenc: Fix memleak upon allocation 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" The qtrle encoder allocates several buffers and an AVFrame in its init function. If one of these allocations fails, but others succeed, the successfully allocated objects leak. This is fixed by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/qtrleenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 6669c1302f..8b0edf7b3d 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -413,4 +413,5 @@ AVCodec ff_qtrle_encoder = { .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB555BE, AV_PIX_FMT_ARGB, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Sun Sep 13 02:57:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22319 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 DAA57449E91 for ; Sun, 13 Sep 2020 05:58:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C34CD68BBDE; Sun, 13 Sep 2020 05:58:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 951A568BBCA for ; Sun, 13 Sep 2020 05:58:24 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id w5so15041757wrp.8 for ; Sat, 12 Sep 2020 19:58:24 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=GRyLUO4Q7jnyX/5fACKw9CpAvYX71nRpXyhfLqqPCwc=; b=lSfWRTJK9BiCYPAkgq4b+Xs7NfDeSI5QXn5xSm6HjBf5bLJXGwyF0BvgtJ0qFaL0IT CR1LZhhIb1ZOipCBamk0kfLGT2PQ89XeDaBXdd2Qk/r8P9E87WZkYwcBgrXsALvKdORZ 3ZWf7grT5czKMMqNo43G3SwUxnzvX3ZLTRbIfzJK2iepCMGjdPASFLr6quAlXpqXsOgy Y3j7O+QeSQV0RwBckiL0ld71mCfjsAPfPVQYnjh218rm8AZT83b8ykXHWHN36mEHYHCs /U5LCCJWmgVEohYuspPq+K/fh+KOVnrQKpOZVNsh/tl2PLwitS7HSvEpXyNF/cafT8ta xF4w== 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:mime-version:content-transfer-encoding; bh=GRyLUO4Q7jnyX/5fACKw9CpAvYX71nRpXyhfLqqPCwc=; b=iJhT6e3cC+Ad/JlvjuQiPwzIH6Q+5MaNlim30jZlbVpKMpqTfNSPSb6CPBENZtBF4D POaoN6ITVek+wHHgCoUfaU71Fjz5c6xH8pjyPaL9jNwMFpo6Q1lqlP4sxs0glzLYFDlU ls45qkkPH9uxcpi/DI/Im/kHTuZne3oCmNVxrsr0VyIU/V7YfdLXJcqBc4P571zTeavU F6kCIuaZi7O64/HYx/7P56DgwqbQtpQh6XHw5Ez4rr/icWk1Uzh90vvv9saDGMMa/PxH bKQw81Hpij0HtZIvZ004Bf1u70jIoXTu1OYCQqrF8Pd42mPvxv4qVS2lMayeBRYSU4Dq WGwg== X-Gm-Message-State: AOAM532CsrE8nWWs15u+Hll72y5XzqbRJk63Q+P0vwqRnhObryrF7cDk X2xOzMMryRI4hduT6aVc/uZiJxY4a1M= X-Google-Smtp-Source: ABdhPJwAK1WLizuc7cDvxEqH2wo16vqrXt0BrDZHEKV3PL5yABzg2HDWyiZCD5ksi80yb9ExdLrODQ== X-Received: by 2002:adf:f2d0:: with SMTP id d16mr8740902wrp.332.1599965903855; Sat, 12 Sep 2020 19:58:23 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:23 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:42 +0200 Message-Id: <20200913025753.274772-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/16] avcodec/ra144enc: Don't free unnecessarily 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" The init function of the real_144 encoder calls its own close function if a call to ff_lpc_init() fails; yet nothing has been allocated before that point and ff_lpc_init() can be expected to clean up after itself on error (the documentation does not say anything to the contrary and the current implementation can only fail if the only allocation fails, so there is nothing to clean up on error anyway), so this is unnecessary. Signed-off-by: Andreas Rheinhardt --- libavcodec/ra144enc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index 059f582334..c6965c5c47 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -65,14 +65,11 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx) ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER, FF_LPC_TYPE_LEVINSON); if (ret < 0) - goto error; + return ret; ff_af_queue_init(avctx, &ractx->afq); return 0; -error: - ra144_encode_close(avctx); - return ret; } From patchwork Sun Sep 13 02:57:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22321 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 166EB449E91 for ; Sun, 13 Sep 2020 05:58:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F09BC68BBE1; Sun, 13 Sep 2020 05:58:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AE8F168BBC2 for ; Sun, 13 Sep 2020 05:58:25 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id q9so7613682wmj.2 for ; Sat, 12 Sep 2020 19:58:25 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=abhWTntbAyPUfEy0/DU+dosEx9IZ2rOsEeKF01DApD0=; b=un8IIeSSAAJNjIX2d4B4s+2lzcEUEzwYxHQRBH2VvRiUoPQgEj1zJqCNH/FWNJotPa 9Krxd5f2mm1LWUAGeNJXwPUEY8in3KKKZwDSzkMcXYd2Ykp5M0WknEt2wB2mFKeQbNJm 2GUoJ1Munx+fWnsTCVUvl6nXu3aZLbZ7B1s40zqyly2WhPEkoObwH3gCrMV4URWeLyw9 Zj2NvNzBHy5kaCnYMa8egQfyL2aNHHpmpP4kEUpEtLIwUixQmar9+I+6qcv5IN6ugpma fUW3kv30pFzMTf52I3uA7Xku/A6McXSisw9Hrrt2biKvoHcTrT2Pnn/nvtPL2JsTClS2 rSBg== 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:mime-version:content-transfer-encoding; bh=abhWTntbAyPUfEy0/DU+dosEx9IZ2rOsEeKF01DApD0=; b=JESH1Kz6ZI2Oox0JPWa7DAIetl0MWZC9rFAhgschHvGkLhAax/h3oUZwKv+v8qugx7 4l9v9U2OIiJGUbD/D6PqidJsvpXETA/l6dlIHkC+AU6L0tDkS4ULq5pHF3VXKQuqr5LO H89kygIt8vuLhiOCp1tLOjyoPkTxzCks7fR/tYKPuFxK4G5X/FhZ7OPEr9mWxgaiLFkZ kX4L1t6cq/5y8PU95Isv3E4Pyj2H8zs4oAvMh/1K1FjFF0mxZTM5hJKWYu8XPs3T4GTA vKQHaBzWu9ENjzOalb10gWOmgL8io8d6kOOR8vKWavvTW3Ridm2TFXGjAZWg7c+9OJYJ Vqew== X-Gm-Message-State: AOAM532xRetrHr1ats9XeX3hJy5xoC3/goK1/F1WU+zcah+JmFg1XsUV IedTl+0cmEAL24LrH1++PiC5EFC2BtE= X-Google-Smtp-Source: ABdhPJyjq9uhvTQK0sPQ6qVuuy5ouqFu5Pbtgpm0zgurlAfHgvmSjqgSpYbi9wWvKqzyj9O0lFYWJA== X-Received: by 2002:a1c:bad5:: with SMTP id k204mr9303112wmf.111.1599965905009; Sat, 12 Sep 2020 19:58:25 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:24 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:43 +0200 Message-Id: <20200913025753.274772-6-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/16] avcodec/ra288: Avoid indirection when calling float dsp function 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" Do this by only keeping the only function pointer from the AVFloatDSPContext that is needed lateron. This also allows to remove the decoder's close function. Signed-off-by: Andreas Rheinhardt --- libavcodec/ra288.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c index aa4bd5d90f..8df17891b1 100644 --- a/libavcodec/ra288.c +++ b/libavcodec/ra288.c @@ -39,7 +39,8 @@ #define RA288_BLOCKS_PER_FRAME 32 typedef struct RA288Context { - AVFloatDSPContext *fdsp; + void (*vector_fmul)(float *dst, const float *src0, const float *src1, + int len); DECLARE_ALIGNED(32, float, sp_lpc)[FFALIGN(36, 16)]; ///< LPC coefficients for speech data (spec: A) DECLARE_ALIGNED(32, float, gain_lpc)[FFALIGN(10, 16)]; ///< LPC coefficients for gain (spec: GB) @@ -60,18 +61,10 @@ typedef struct RA288Context { float gain_rec[11]; } RA288Context; -static av_cold int ra288_decode_close(AVCodecContext *avctx) -{ - RA288Context *ractx = avctx->priv_data; - - av_freep(&ractx->fdsp); - - return 0; -} - static av_cold int ra288_decode_init(AVCodecContext *avctx) { RA288Context *ractx = avctx->priv_data; + AVFloatDSPContext *fdsp; avctx->channels = 1; avctx->channel_layout = AV_CH_LAYOUT_MONO; @@ -82,9 +75,11 @@ static av_cold int ra288_decode_init(AVCodecContext *avctx) return AVERROR_PATCHWELCOME; } - ractx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); - if (!ractx->fdsp) + fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); + if (!fdsp) return AVERROR(ENOMEM); + ractx->vector_fmul = fdsp->vector_fmul; + av_free(fdsp); return 0; } @@ -158,7 +153,7 @@ static void do_hybrid_window(RA288Context *ractx, av_assert2(order>=0); - ractx->fdsp->vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16)); + ractx->vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16)); convolve(buffer1, work + order , n , order); convolve(buffer2, work + order + n, non_rec, order); @@ -185,7 +180,7 @@ static void backward_filter(RA288Context *ractx, do_hybrid_window(ractx, order, n, non_rec, temp, hist, rec, window); if (!compute_lpc_coefs(temp, order, lpc, 0, 1, 1)) - ractx->fdsp->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16)); + ractx->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16)); memmove(hist, hist + n, move_size*sizeof(*hist)); } @@ -249,6 +244,5 @@ AVCodec ff_ra_288_decoder = { .priv_data_size = sizeof(RA288Context), .init = ra288_decode_init, .decode = ra288_decode_frame, - .close = ra288_decode_close, .capabilities = AV_CODEC_CAP_DR1, }; From patchwork Sun Sep 13 02:57:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22323 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 0C2A0449E91 for ; Sun, 13 Sep 2020 05:58:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E559B68BBFE; Sun, 13 Sep 2020 05:58:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 88AD468BBC7 for ; Sun, 13 Sep 2020 05:58:26 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id a17so15069633wrn.6 for ; Sat, 12 Sep 2020 19:58:26 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=bptT+kB88xyxhv0+TZVZo2IclLDw221GtWJOVtpaeOU=; b=dptM/2VKeWlQod9PIwwxDGrxFu7sKd2wKQft06yYwF0MwFr7xtNUjV46/cDD8jdtAj n4JgtaBXqCGCbgFMCPBzhxVYLwy26kOTBdxQeWVELnhwo77g4+4pJWw82T0qpm0McJGj KidhI3W4eNj5GEX1TBeXcmhPj6ngtA6TKZn3B02oJFMaJ06jTbdMNfFZ3arH8tDcNGth GKuqcr0c5aLMcxJHSpo4/TCn2Zz9SQUGjG0CtOVBkmfmXjcswEvzqDCsdIRfnBsgc2iZ Pmh4nW6J4awyHKCjQ/wcubWbRmNEqmmEz5XzLepBY7xxO0btrn9NqgVWBJcRga3GWTl1 GFbA== 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:mime-version:content-transfer-encoding; bh=bptT+kB88xyxhv0+TZVZo2IclLDw221GtWJOVtpaeOU=; b=XLmETZhqQDCAtuHZhk41yeYnbDiM/iUZRTD0oVSKn3NKalvibZyeqMKGQB6tzf8ohs Ty7CrOnZ/gTP2X12GySci8TtBZL7jNJl+8J3yQcDUD4rucjt9j3p2Zh0WZX5MbD8Hsyu fddh+Pi7mbCz1ssMou9kZpXmYc7aEUG+XkLkh8s40cVMOyZzaCvw5rC3Xj5LX7s81riu mFgrwwWixBSsX0Vdm4ndE1wNAzZDRaT2OIJ+Wy4Lzdcicxpy86LcHvbsWlVtRQCcNwMl DakAmBEfRL5Gd4nzgVeHJVDW1bkI+5dR85NKtyQyNRa/TVyXh4JZ92Zvfdc1yFnsbAMI iUNA== X-Gm-Message-State: AOAM533x2D9PfyeuMRAA5YAH90a40Cu+SawqXW82vTlcjLT+v6VLtZTJ VxS4OZRYslLjuSk+r6O/iwSxbqFYWTs= X-Google-Smtp-Source: ABdhPJxYm4F3YB4kIEmRpIIB7Esg9fL4ga4AAsmIJq0U6I8JW6fuxACRTrUCyEtnqLg/jo0Mf3dJ2A== X-Received: by 2002:adf:f0c3:: with SMTP id x3mr9026861wro.163.1599965905785; Sat, 12 Sep 2020 19:58:25 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:25 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:44 +0200 Message-Id: <20200913025753.274772-7-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/16] avcodec/pcm: Avoid indirection when calling float dsp function 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" Do this by only keeping the only function pointer from the AVFloatDSPContext that is needed lateron. This also allows to remove the decoders' close function. Signed-off-by: Andreas Rheinhardt --- libavcodec/pcm.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index 96a68f7fe8..12d1b3a2c3 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -235,13 +235,15 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, typedef struct PCMDecode { short table[256]; - AVFloatDSPContext *fdsp; + void (*vector_fmul_scalar)(float *dst, const float *src, float mul, + int len); float scale; } PCMDecode; static av_cold int pcm_decode_init(AVCodecContext *avctx) { PCMDecode *s = avctx->priv_data; + AVFloatDSPContext *fdsp; int i; if (avctx->channels <= 0) { @@ -268,9 +270,11 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; s->scale = 1. / (1 << (avctx->bits_per_coded_sample - 1)); - s->fdsp = avpriv_float_dsp_alloc(0); - if (!s->fdsp) + fdsp = avpriv_float_dsp_alloc(0); + if (!fdsp) return AVERROR(ENOMEM); + s->vector_fmul_scalar = fdsp->vector_fmul_scalar; + av_free(fdsp); break; default: break; @@ -284,15 +288,6 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx) return 0; } -static av_cold int pcm_decode_close(AVCodecContext *avctx) -{ - PCMDecode *s = avctx->priv_data; - - av_freep(&s->fdsp); - - return 0; -} - /** * Read PCM samples macro * @param size Data size of native machine format @@ -529,9 +524,9 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, if (avctx->codec_id == AV_CODEC_ID_PCM_F16LE || avctx->codec_id == AV_CODEC_ID_PCM_F24LE) { - s->fdsp->vector_fmul_scalar((float *)frame->extended_data[0], - (const float *)frame->extended_data[0], - s->scale, FFALIGN(frame->nb_samples * avctx->channels, 4)); + s->vector_fmul_scalar((float *)frame->extended_data[0], + (const float *)frame->extended_data[0], + s->scale, FFALIGN(frame->nb_samples * avctx->channels, 4)); emms_c(); } @@ -570,7 +565,6 @@ AVCodec ff_ ## name_ ## _decoder = { \ .id = AV_CODEC_ID_ ## id_, \ .priv_data_size = sizeof(PCMDecode), \ .init = pcm_decode_init, \ - .close = pcm_decode_close, \ .decode = pcm_decode_frame, \ .capabilities = AV_CODEC_CAP_DR1, \ .sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \ From patchwork Sun Sep 13 02:57:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22314 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 59B20449E91 for ; Sun, 13 Sep 2020 05:58:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3610C68BBC0; Sun, 13 Sep 2020 05:58:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6D6B168BBAC for ; Sun, 13 Sep 2020 05:58:27 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id j2so15063390wrx.7 for ; Sat, 12 Sep 2020 19:58:27 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=9T0xCG93nG+QLN73d0RNn38tWm9eRPrdUkWqMwpV9qw=; b=ZqDWMVdu9+crq61Coe+hJfl4mwt4mInGdQj6LJuI7FYKkVJTHOCXkCHAolXbndflRQ P/V2LsuwErbeQrCbbWrTIWHx8dVO0jcygF0VlIDnRoRF7sK70COaZ8RCgVAACpvDsVON J2eVsfOYzW70EpRQpT3I3DS+uyHl41J67Diw65ZHd83g4Uykcl98d5A249H8XQXUoDZN 2fo+RcxV6vXPAO7T+12k0DDzGISqvo+r/4wLhzqhilzWPI7o7L2X0vOK4VdQOb+QvsB4 g1STZh8CWTzxIo/RMQEX6HlfsS16a66F2qZoOsSBy6B0FW4HQw7vfwAlGHMAtcjkJRo6 QN5w== 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:mime-version:content-transfer-encoding; bh=9T0xCG93nG+QLN73d0RNn38tWm9eRPrdUkWqMwpV9qw=; b=EKHZrakk9AmNrz+9dl4uz1IdZWt5/fISAHf0kiBsdAgT7VgmGjNcwsLyf6Q/A2uJ3c 0RHjgwWu5B339EQDOLG4A8E1YIJLGPZtl6QlerrGSCi58qgR73WRUuJDEFLYi8J25plz tDRXGRCD54Ud+YAwp2dnzoJzCZofwiS0rel2vDRvk4wpNwoWuRQt6rLdddyIS5X+7ChR 51qiIdNQMCd/+NdwBwEDGc7n1hA39iZO1bj5DI66iBCBbEpTVObissgHQNhSINKxy+Hl Qud3xTz0/Fk+S1eoXxT/Sls0UobpIy+KQofFZAg8Aves9lhJrHhlW58Ib12sApDa4uM5 vmig== X-Gm-Message-State: AOAM533nqy3f9TZBx06qz12DHH4DPaAvGfpMuuMMz0fFWqgelxrp6OFu YZb0VMy1ZF0m4utkRh20aKW12bTOqBE= X-Google-Smtp-Source: ABdhPJwDduIedNjG6jmUHtOz2Uiz5nF9o2AV49TzDFLsYdJexCiC+5s5tWaE+bxV48le+AZdnEXWiw== X-Received: by 2002:adf:ec87:: with SMTP id z7mr9814444wrn.57.1599965906603; Sat, 12 Sep 2020 19:58:26 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:26 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:45 +0200 Message-Id: <20200913025753.274772-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/16] avcodec/roqaudioenc: Avoid redundant free of unallocated buffer 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" If allocating a buffer in RoQ DPCM encoder's init function failed, the close function would be called manually; all this function does is freeing said buffer, but given that it has not been allocated at all, this is unnecessary. Signed-off-by: Andreas Rheinhardt --- libavcodec/roqaudioenc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c index 5154604be8..c09212d3d1 100644 --- a/libavcodec/roqaudioenc.c +++ b/libavcodec/roqaudioenc.c @@ -53,7 +53,6 @@ static av_cold int roq_dpcm_encode_close(AVCodecContext *avctx) static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) { ROQDPCMContext *context = avctx->priv_data; - int ret; if (avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "Audio must be mono or stereo\n"); @@ -70,17 +69,12 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) context->frame_buffer = av_malloc(8 * ROQ_FRAME_SIZE * avctx->channels * sizeof(*context->frame_buffer)); - if (!context->frame_buffer) { - ret = AVERROR(ENOMEM); - goto error; - } + if (!context->frame_buffer) + return AVERROR(ENOMEM); context->lastSample[0] = context->lastSample[1] = 0; return 0; -error: - roq_dpcm_encode_close(avctx); - return ret; } static unsigned char dpcm_predict(short *previous, short current) From patchwork Sun Sep 13 02:57: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: 22316 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 82BF1449E91 for ; Sun, 13 Sep 2020 05:58:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6423168BBBF; Sun, 13 Sep 2020 05:58:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5390868BBB5 for ; Sun, 13 Sep 2020 05:58:28 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id e17so7622787wme.0 for ; Sat, 12 Sep 2020 19:58:28 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=+kP5fcg48ZlIh3GuMY6acGIAADxSQENuaviqky/pk3Q=; b=OMMN8SAkYcrcgzox4a1BBir62j4/aU+LNtgYLVojDulwOu2JmlXEsLF3z/HIl+VKmG 0TY2bc544XcHPlVDQp7vuowY0l6GgB45JwRkTmCyTVTfvwDtmI7izIcCw03dXTIpbKtY HdcKZvqKE31qVrb6NXhOvhAytP/SNLaxaw9ixlukyABjexRBNe/04zWaHXNt3S2ip2hz FzbJ8JkSSXqSqNJy/hZxFMLLrxYujFUGTEhaBX7wZ4hH2HEFe3gIkmakcqrQEXD3PHSW GiwnS4hrp+1ZGFuLg3lz4dQ+C5nzuKLNA0AuPmuvyD5N+WhYasfiRagaU1P+Fw7N+yMN rGCw== 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:mime-version:content-transfer-encoding; bh=+kP5fcg48ZlIh3GuMY6acGIAADxSQENuaviqky/pk3Q=; b=SV3P9wCnM0EMh50B+hPmNKT+0cKqOzZcO1/WakLx/WsJxMUvc3Ft7QygHiJuAHA22t ow1gEpTaXmhQqzW9C20dWMC6caQ+2CgL+QlUwM5W7VWVems2qmjfzwq/x6wAJaHRL5M5 8jpVetbbNUVlhOdHZhwm6e367GeC6HUXl50sOpxFuLWH7E1Dlxkxai4XFsVvn6GMtCmy b0uPMoIvwLTKlk3OZ4na83Tg1E5Q84QzZLqFR6x+Wj9cKGajCB4Yo9rEkb2zWmckCYjZ q5c816upC93ASxSvl0iQ86Dyrw54Bj4jYH3Zf0U7pdA3lApv/WiIpTC7DOk0mKKB8hpF TlOQ== X-Gm-Message-State: AOAM531xS+adgTKhh73uzvhW8ZwpaoRCTR15uGKt6MrsvLTv0QEGuN2u 7GiDTcFOtP1vvFQw9C1eORJ20V5q6oI= X-Google-Smtp-Source: ABdhPJw683tvQhmngM7Kjzs+XBi7M8ONn5VRtLMWxq93JU7m3ku8zKdEPAAE6EVGDScFilNsverCxA== X-Received: by 2002:a1c:6346:: with SMTP id x67mr8817319wmb.42.1599965907462; Sat, 12 Sep 2020 19:58:27 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:26 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:46 +0200 Message-Id: <20200913025753.274772-9-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/16] avcodec/sonic: Fix leaks upon allocation errors 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" The Sonic decoder and encoders allocate several buffers in their init function and return immediately if one of these allocations fails; this will lead to leaks if there was an earlier successfull allocation. Fix this by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/sonic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index ea6ef10c9e..fa4ecc3a7a 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -1095,6 +1095,7 @@ AVCodec ff_sonic_decoder = { .close = sonic_decode_close, .decode = sonic_decode_frame, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; #endif /* CONFIG_SONIC_DECODER */ @@ -1109,6 +1110,7 @@ AVCodec ff_sonic_encoder = { .encode2 = sonic_encode_frame, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .capabilities = AV_CODEC_CAP_EXPERIMENTAL, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .close = sonic_encode_close, }; #endif @@ -1124,6 +1126,7 @@ AVCodec ff_sonic_ls_encoder = { .encode2 = sonic_encode_frame, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .capabilities = AV_CODEC_CAP_EXPERIMENTAL, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .close = sonic_encode_close, }; #endif From patchwork Sun Sep 13 02:57:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22318 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 C4AF1449E91 for ; Sun, 13 Sep 2020 05:58:35 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AEC2968BBE5; Sun, 13 Sep 2020 05:58:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 21EE568BBBA for ; Sun, 13 Sep 2020 05:58:28 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id g4so15072205wrs.5 for ; Sat, 12 Sep 2020 19:58:28 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=bRBiQ76UI9vfxdsTPwHlamClIFRF7OH/vWRi8yiV7nE=; b=piYIJ0WHLOoAFenDlvOnYbkODB1yz+sNbRS57uH+KXRyEPyC3eFpalEPpWl7MxOEfR OwWbxbsHrTzMSxyDGWhqKKXjkXe876kwo5B5+xU4Qz+Wq55Mo3+wrknrDBEJaeZYskMy mJsYyZ9Jy41xPizktLflnP5GXYpOs+F4Jikf69798cfe5NTjQdbnP974dYYeOBVtqQhn bBIOVfy00rSHTkxnZralS83sgx7Gzi0jhR7U2zFVXRtyrodSuPqAepr7cxmBeIiYHT3L pJTp1k0H/T/HD2UQxYpzSX0E4Cnt/sWRYgHkGi+kCiG+lQ1eu6oU+hAgDPjNi2hEBxWv PR6Q== 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:mime-version:content-transfer-encoding; bh=bRBiQ76UI9vfxdsTPwHlamClIFRF7OH/vWRi8yiV7nE=; b=qxWeWhPlr2N+2eZd/gYwDS9Ngj6xO72VbtjcLCQksHxrT8WhAq4iaoN3zWiHLk04ZX mYbU1PfRyWdJ6lW7NGqg4ZKQT7mpZUfSliZG1pmSJtWYp2yB50sJobrVKP6oWrk61g/I l9GmYjQH88vjyzaA4sxEQVuaYXxFmTp4YhinrQhPs/2Ei4w1xg+zaq1yXM3TwfGUMt2j 6YSNAWGwftD1uYdEmewcxAj7ilE43wnVGlkUl0IUIGIwpNeaSaJjmkFR79vYHPNiF0Vf /z1x0sKhqGvRZkluzbREwjQPLODwgd5qHrwU9DxeIRMb98yluIdEa5NTCSbUs7a+NgpC eRuQ== X-Gm-Message-State: AOAM531S0FTx8JTCZLcXY5sNKHe4CoPCn6niXLcUQhxyGbrQw4Ux3tNk G9wmKzF+A09Qy+32Aq/R5ZyOmw87irs= X-Google-Smtp-Source: ABdhPJyhAxW3PIL4oNh6nYy6N04aiBQe0RGkW4zVbkQGHk1876UMF5b+xMfOVZSPe9BJ/E4PYr1+1w== X-Received: by 2002:a5d:4a0c:: with SMTP id m12mr9258961wrq.83.1599965908219; Sat, 12 Sep 2020 19:58:28 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:27 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:47 +0200 Message-Id: <20200913025753.274772-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/16] avcodec/svq3: Avoid allocations for SVQ3Frames 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" These frames can be made part of the SVQ3Context; notice that the pointers to the frames have been retained in order to allow to just swap them as the code already does. Signed-off-by: Andreas Rheinhardt --- libavcodec/svq3.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index c8db08a32f..8a67836827 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -147,6 +147,7 @@ typedef struct SVQ3Context { DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8]; uint32_t dequant4_coeff[QP_MAX_NUM + 1][16]; int block_offset[2 * (16 * 3)]; + SVQ3Frame frames[3]; } SVQ3Context; #define FULLPEL_MODE 1 @@ -1135,13 +1136,9 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) int marker_found = 0; int ret; - s->cur_pic = av_mallocz(sizeof(*s->cur_pic)); - s->last_pic = av_mallocz(sizeof(*s->last_pic)); - s->next_pic = av_mallocz(sizeof(*s->next_pic)); - if (!s->next_pic || !s->last_pic || !s->cur_pic) { - ret = AVERROR(ENOMEM); - goto fail; - } + s->cur_pic = &s->frames[0]; + s->last_pic = &s->frames[1]; + s->next_pic = &s->frames[2]; s->cur_pic->f = av_frame_alloc(); s->last_pic->f = av_frame_alloc(); @@ -1631,9 +1628,6 @@ static av_cold int svq3_decode_end(AVCodecContext *avctx) av_frame_free(&s->cur_pic->f); av_frame_free(&s->next_pic->f); av_frame_free(&s->last_pic->f); - av_freep(&s->cur_pic); - av_freep(&s->next_pic); - av_freep(&s->last_pic); av_freep(&s->slice_buf); av_freep(&s->intra4x4_pred_mode); av_freep(&s->edge_emu_buffer); From patchwork Sun Sep 13 02:57:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22320 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 0598C449E91 for ; Sun, 13 Sep 2020 05:58:38 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E0E4668BBEC; Sun, 13 Sep 2020 05:58:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 08D3D68BBCD for ; Sun, 13 Sep 2020 05:58:29 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id w2so7618414wmi.1 for ; Sat, 12 Sep 2020 19:58:29 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=Jyui1a6bIZ5dS/LrPvbDmNXVSQ8vptpr4e3/3gL9o5M=; b=vOJ03pfNq7zilbd9pEIyJpJ/KMb3RXKBo2tHpq7xrFBQLuypDQwW9YCmEdIdz27LER MCVrA6RCn9y1EPlEUr6psmX8EKp7TGdbaZ+KP5Y/PaSxz+qnC85HZssxeKU5yyKxSEyd Ia9umsVjSaaELCJouhQs7FUcj5trAi6c7xvxHCQDy9TdXEAHqt6/GYwVR0y+KOTu9qcL 64E0+YGyJqD5coWWOjQNkhkFS+cUcDeH2e95uS9ubcGog23F+Tv8SK9Dp74KKhIZ9FS7 L8wmqZha2KKWWnv8Bd99zACCRJRkWDma9FQjDlzKCMJ3FFqX6QeYOGkadJlVB6nCx9zl 0ZGA== 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:mime-version:content-transfer-encoding; bh=Jyui1a6bIZ5dS/LrPvbDmNXVSQ8vptpr4e3/3gL9o5M=; b=VGIiT6Z0G8RdPpIhF/osJ26E12D3hO7OMtbXwH6eP0DcozJDNVgTNgezIFCzYY69vz cWCHBr39ZJ+ltElqAutDxQOF8PnHAS3G4e8iiE61d0pW7NLZXnrM0MwNdotpLwQk9bIq a6Qy7zGR4Ng+/hV00NpxhWS+6jw5ZALP/IlnR9D3qzdp1QTIC8Qdq5gtD0UvqidothJt UgejSO9mdORxp9G2Cea9aiIuOzXxTEVPUoF7hxwCB2gmIk16uAtj0io/Yxqz6jHQz5CR heKQ+4jU5j+c+H5fdsMU0DPxKZSDjoOakN90siIFSDfzchs0irI9Hu3OAI1NPFbQ+3F8 Qbmg== X-Gm-Message-State: AOAM532Kse6N6/1fA21mdVHWG8kjEte/wy+yMekfNm4tFAK+0sauDbHI Z47+1iJbNdUjO+e3/hOwaErKYx2gvUU= X-Google-Smtp-Source: ABdhPJyGOP6P9XqVprl5YM4mDZPc/xDZDaR4NfEwJlCj0kCWSRUI5z0xhFKRwfNzvXVRIwQX+7aZjA== X-Received: by 2002:a1c:678a:: with SMTP id b132mr9422211wmc.10.1599965909122; Sat, 12 Sep 2020 19:58:29 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:28 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:48 +0200 Message-Id: <20200913025753.274772-11-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/16] avcodec/svq3: Fix memleaks upon allocation error 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" Commit b2361cfb94738298a6c4037cc348fe5015efb841e made all of the error paths in svq3_decode_init() call svq3_decode_end(); yet several new error paths that were added later (in merges from Libav) returned directly without cleaning up properly. This commit fixes the resulting potential memleaks by setting the FF_CODEC_CAP_INIT_CLEANUP flag. This also allows to simplify freeing by returning directly. Signed-off-by: Andreas Rheinhardt --- libavcodec/svq3.c | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 8a67836827..41a9bf2daa 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -222,8 +222,6 @@ static const uint32_t svq3_dequant_coeff[32] = { 61694, 68745, 77615, 89113, 100253, 109366, 126635, 141533 }; -static int svq3_decode_end(AVCodecContext *avctx); - static void svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp) { const unsigned qmul = svq3_dequant_coeff[qp]; @@ -1185,10 +1183,8 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) int w,h; size = AV_RB32(&extradata[4]); - if (size > extradata_end - extradata - 8) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (size > extradata_end - extradata - 8) + return AVERROR_INVALIDDATA; init_get_bits(&gb, extradata + 8, size * 8); /* 'frame size code' and optional 'width, height' */ @@ -1229,7 +1225,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) } ret = ff_set_dimensions(avctx, w, h); if (ret < 0) - goto fail; + return ret; s->halfpel_flag = get_bits1(&gb); s->thirdpel_flag = get_bits1(&gb); @@ -1248,10 +1244,8 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, "Unknown fields %d %d %d %d %d\n", unk0, unk1, unk2, unk3, unk4); - if (skip_1stop_8data_bits(&gb) < 0) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (skip_1stop_8data_bits(&gb) < 0) + return AVERROR_INVALIDDATA; s->has_watermark = get_bits1(&gb); avctx->has_b_frames = !s->low_delay; @@ -1269,16 +1263,13 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) uint8_t *buf; if (watermark_height <= 0 || - (uint64_t)watermark_width * 4 > UINT_MAX / watermark_height) { - ret = -1; - goto fail; - } + (uint64_t)watermark_width * 4 > UINT_MAX / watermark_height) + return AVERROR_INVALIDDATA; buf = av_malloc(buf_len); - if (!buf) { - ret = AVERROR(ENOMEM); - goto fail; - } + if (!buf) + return AVERROR(ENOMEM); + av_log(avctx, AV_LOG_DEBUG, "watermark size: %ux%u\n", watermark_width, watermark_height); av_log(avctx, AV_LOG_DEBUG, @@ -1289,8 +1280,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "could not uncompress watermark logo\n"); av_free(buf); - ret = -1; - goto fail; + return -1; } s->watermark_key = av_bswap16(av_crc(av_crc_get_table(AV_CRC_16_CCITT), 0, buf, buf_len)); @@ -1301,8 +1291,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) #else av_log(avctx, AV_LOG_ERROR, "this svq3 file contains watermark which need zlib support compiled in\n"); - ret = -1; - goto fail; + return AVERROR(ENOSYS); #endif } } @@ -1334,9 +1323,6 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) init_dequant4_coeff_table(s); return 0; -fail: - svq3_decode_end(avctx); - return ret; } static void free_picture(AVCodecContext *avctx, SVQ3Frame *pic) @@ -1654,4 +1640,5 @@ AVCodec ff_svq3_decoder = { AV_CODEC_CAP_DELAY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE}, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Sun Sep 13 02:57:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22322 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 1E820449E91 for ; Sun, 13 Sep 2020 05:58:40 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 039D068BBF1; Sun, 13 Sep 2020 05:58:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1447368BBC2 for ; Sun, 13 Sep 2020 05:58:31 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id k15so15044647wrn.10 for ; Sat, 12 Sep 2020 19:58:31 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=QCBDuCp40xgjhPLTA2JbIv5LWx0D+X/elreBRpsEbcA=; b=d0ZRZhlBBPxLCjEbh6MlX1f3PPHA10+lJPSrFfZHmUGPUnsDhPSy3rxRglweIETYEu gF26ya2t0xxV7lt0thAlw2Rm/1aKYYrWxhGzemwEAWlcXQAvBry1EWYugf3loU++yq2M saOZuoS0yNiT21PIk+dDWtZFo0ktpciCrf7qpS18chQjZw+US+SGJhbNxp7Tt1CyNmDI QwJMdZ0juvHzp7NPLYFI+i7O38Ik9UL+r1bLly7SeDmrJjnNjMZxSVPPxjbAlh1b8P8x 5VBBptPvmEXBuCbw08Cb/QQW4btrZUg658CH8+LxeVCrXj5sxXCQGajVdNkqNzT2qRsW Eacg== 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:mime-version:content-transfer-encoding; bh=QCBDuCp40xgjhPLTA2JbIv5LWx0D+X/elreBRpsEbcA=; b=ZAgYqOMDM05gEQQEGFL8s6mGEN7zgMj1taOWImloQWjEjm+a2IQgk5k2ANjhWfvpU7 2Y6H6UGNYM79hUfO4JVqlPPotgjPhqRVV+NP9vif7tCYKwVBFwO//E08bW1FpvajR5fJ ej2brR8V6vNIwb00eEK66d8vFhG/i2mO17Xlc6zrdKKKpwXpDu3lG2+imCcb2nkyCF41 WCR+8TVWdMzUmmYpMuXZTbq651JCGK10uafcKDf2hnihxIMO+lbUcpz5MeuIUo/y2dHh w+jZqp9s8ohoq0CsoofUg5VVBy9Xkl/0MFm1tV+ks2wAPTEIlQNdUdO9nwmzgDGsw+Lv uOzg== X-Gm-Message-State: AOAM53252JMVhkZ1IJpZ6KW0SCg5sPzf/tWzWI2RIki8eoBL2GQbxxhU W6gw9LbclKAVJ5WvpzHqjFFHiY7D1cQ= X-Google-Smtp-Source: ABdhPJyZ/5mBJgv3gOvFodIK2NOtR+i1SKeUBqeIOBj0tT8jlsS5sefCywverN+/V4UjXhpPDN7lwA== X-Received: by 2002:adf:f245:: with SMTP id b5mr9512662wrp.288.1599965910260; Sat, 12 Sep 2020 19:58:30 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:29 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:49 +0200 Message-Id: <20200913025753.274772-12-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/16] avcodec/svq3: Remove unused buffer 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/svq3.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 41a9bf2daa..0ac81364bd 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -75,10 +75,6 @@ typedef struct SVQ3Frame { AVBufferRef *mb_type_buf; uint32_t *mb_type; - - - AVBufferRef *ref_index_buf[2]; - int8_t *ref_index[2]; } SVQ3Frame; typedef struct SVQ3Context { @@ -1330,7 +1326,6 @@ static void free_picture(AVCodecContext *avctx, SVQ3Frame *pic) int i; for (i = 0; i < 2; i++) { av_buffer_unref(&pic->motion_val_buf[i]); - av_buffer_unref(&pic->ref_index_buf[i]); } av_buffer_unref(&pic->mb_type_buf); @@ -1341,7 +1336,6 @@ static int get_buffer(AVCodecContext *avctx, SVQ3Frame *pic) { SVQ3Context *s = avctx->priv_data; const int big_mb_num = s->mb_stride * (s->mb_height + 1) + 1; - const int mb_array_size = s->mb_stride * s->mb_height; const int b4_stride = s->mb_width * 4 + 1; const int b4_array_size = b4_stride * s->mb_height * 4; int ret; @@ -1356,14 +1350,12 @@ static int get_buffer(AVCodecContext *avctx, SVQ3Frame *pic) for (i = 0; i < 2; i++) { pic->motion_val_buf[i] = av_buffer_allocz(2 * (b4_array_size + 4) * sizeof(int16_t)); - pic->ref_index_buf[i] = av_buffer_allocz(4 * mb_array_size); - if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i]) { + if (!pic->motion_val_buf[i]) { ret = AVERROR(ENOMEM); goto fail; } pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4; - pic->ref_index[i] = pic->ref_index_buf[i]->data; } } From patchwork Sun Sep 13 02:57:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22324 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 6E862449E91 for ; Sun, 13 Sep 2020 05:58:42 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 53D2268BC02; Sun, 13 Sep 2020 05:58:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5E65368BBB2 for ; Sun, 13 Sep 2020 05:58:32 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id a9so8075320wmm.2 for ; Sat, 12 Sep 2020 19:58:32 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=ZuHS2BItckTa/pqSkCz7I3cy85O0CeekvwItpduyTyk=; b=T7F23W849tbgNh5QVKbrGiA/abaFhTOuEK4uowRNDGOYI7BIfjz95wnD0xtYPIB03w 9aN96Zn+bWTdsXKNVDwunv6wTH5kfMI8UaPTp5fTByiFMd4xI8PEbjKyR8Z32obiLuqR gx3DhdvVNWC0DdZTtHiRR2N5TsxL8zL7UwTEemcRt0T+RDbqzKsvlQKqYuAORAZX0CKl 52zx8LEI9bAUWmZy5LeMXfwV/OjoWKoOCu9SG7xuISn6TyYQfKZolwAPMnmfrywwOAX6 rTbX506VYdIIItAwuEwV/GsWR2DBw3V/RKc1hWukicEIgYyl5Fsrcqgmki0AjbOQmL3E l9XQ== 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:mime-version:content-transfer-encoding; bh=ZuHS2BItckTa/pqSkCz7I3cy85O0CeekvwItpduyTyk=; b=MVNcTzdK9yZosKBrbZQNNPXpJl7tvYDZl2gg9+jGEPMWHvosGEv4VDyJJu/O4aD16/ J8zCdgVK7fbIGf59ntIz2T3jeOXjcTLHVg8pBZ6p+3sA0MuNdIKy9OEbeUQrrGA34vKn IdewTdyY0XaV5qTvUcVcRQmzLpAfpOSCG3GdUw0Bub/FOtRP8XPbHZh6e/roCGyujDx1 csYyX+fCnXoLTFTLJ7RpjjOzYZzRnnBrmu2BSH5mTa5ViL/ODXeLiTZFqdniXJHjUva6 cfFgGhw4MSSzITvlV7sOMoxBMGlKngVRG0BhxlnbGRJ7fmZ7YjbgfbTcZd/USuu7yjJW G6wQ== X-Gm-Message-State: AOAM5306vgx/0wQhQfU7FTYarNBsN+5dI5LctjUkaaYDzD+KHC7mrpUj BLbtwR1IVgVYFllxFEtcaEI1Mon/7B0= X-Google-Smtp-Source: ABdhPJw+ZDpFKZbH/l++mgsvUnwku3HPGtGRQ78RSRTUmS0Bv7C3+xUw2BH87v5ZOjYvwyo58eRCyA== X-Received: by 2002:a1c:4b04:: with SMTP id y4mr8903183wma.111.1599965911394; Sat, 12 Sep 2020 19:58:31 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:30 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:50 +0200 Message-Id: <20200913025753.274772-13-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/16] avcodec/svq3: Avoid overhead of AVBuffer API 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" Up until now, the SVQ3 decoder allocated several refcounted buffers, despite no sharing/refcounting happening at all: Their refcount never exceeds one and they are treated like ordinary buffers (with the exception that the pointer used to access them is in the middle of the allocated buffer, but this does not warrant using the AVBuffer API at all). Given that using the AVBuffer API incurs overhead, it is no longer used at all. Signed-off-by: Andreas Rheinhardt --- libavcodec/svq3.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 0ac81364bd..fb7b992496 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -70,11 +70,10 @@ typedef struct SVQ3Frame { AVFrame *f; - AVBufferRef *motion_val_buf[2]; + int16_t (*motion_val_buf[2])[2]; int16_t (*motion_val[2])[2]; - AVBufferRef *mb_type_buf; - uint32_t *mb_type; + uint32_t *mb_type_buf, *mb_type; } SVQ3Frame; typedef struct SVQ3Context { @@ -1325,9 +1324,9 @@ static void free_picture(AVCodecContext *avctx, SVQ3Frame *pic) { int i; for (i = 0; i < 2; i++) { - av_buffer_unref(&pic->motion_val_buf[i]); + av_freep(&pic->motion_val_buf[i]); } - av_buffer_unref(&pic->mb_type_buf); + av_freep(&pic->mb_type_buf); av_frame_unref(pic->f); } @@ -1343,19 +1342,19 @@ static int get_buffer(AVCodecContext *avctx, SVQ3Frame *pic) if (!pic->motion_val_buf[0]) { int i; - pic->mb_type_buf = av_buffer_allocz((big_mb_num + s->mb_stride) * sizeof(uint32_t)); + pic->mb_type_buf = av_calloc(big_mb_num + s->mb_stride, sizeof(uint32_t)); if (!pic->mb_type_buf) return AVERROR(ENOMEM); - pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * s->mb_stride + 1; + pic->mb_type = pic->mb_type_buf + 2 * s->mb_stride + 1; for (i = 0; i < 2; i++) { - pic->motion_val_buf[i] = av_buffer_allocz(2 * (b4_array_size + 4) * sizeof(int16_t)); + pic->motion_val_buf[i] = av_calloc(b4_array_size + 4, 2 * sizeof(int16_t)); if (!pic->motion_val_buf[i]) { ret = AVERROR(ENOMEM); goto fail; } - pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4; + pic->motion_val[i] = pic->motion_val_buf[i] + 4; } } From patchwork Sun Sep 13 02:57:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22325 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 78AFE449E91 for ; Sun, 13 Sep 2020 05:58:43 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5CCB768BBD5; Sun, 13 Sep 2020 05:58:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F309568BBC4 for ; Sun, 13 Sep 2020 05:58:32 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id j2so15063450wrx.7 for ; Sat, 12 Sep 2020 19:58:32 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=JB2PVQPHi54rgR/B0bPpqxEy1zl6gt2hdQ8aCUPnXRU=; b=O8eW5dl9S2dQZczz/4lba/w43Sg2xc2F/T/EXO97Jk2UrF8OSBh8gWj+iUmx0UYg5f NTt5pZZLoT8KzRrENYwHRXxp6PT5p0ovbSK05YJyfRW7w/yYJvXZkKZWcyPvG6W3LSao IRtnTyLBQCVtZyZ81YnlLOy5k96nFT8Q42GmNRbRLPcLYoeFq8rGWPBWyon1REY5uEyX Q05w4CHUeRlR4WJqnuqmTnjiEAIrCIYUHeOMgIeITmvR9Ee6xKc7aZp87+r9tbPPVjWE TW+nwQTYrnNYAYwi5AYIMS/eT/Wd6cYueNSOZ5Ujaab4ge6vZnwRTrhs9+64Hk9Z+VAD jZ6w== 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:mime-version:content-transfer-encoding; bh=JB2PVQPHi54rgR/B0bPpqxEy1zl6gt2hdQ8aCUPnXRU=; b=cOps+BbdtajB7Bjju25sxEdGj3DXtF8xRnICkeqNAt7g1itbA0yYvfWKrgEaBUvRn6 K5waalaNZymX7qHrf+LAbg0C8OE6/xVl16lhbLNbNj0gbNuvYWpJk123XZeDfYacc13Q F9U5TNfK7cpiGyyRq9tXcYT/di9/Q49Szrsk3rPz7AHM85hy66uIoSsICwV11/dapnIe qSwmezS1fSR03mwVErwIrVkojAvxChGwYK3wS7obkoOENHIcSHVwRdsFI4pwaK2ykFvu upTKWFrdWG3s8FvI+uBnKlNq15Kn72GHJSL04vIcw2Trr5gg8++k4g9xi0v+wjwF2H0p hhsA== X-Gm-Message-State: AOAM533eBDhm+hXdNwn4j9GjMcOuoF0Rt0L6P7wlosHxMxWtOMr+3Xeo c8D5OZ6q1JMAhQegC9U3pxz8MIZmTR4= X-Google-Smtp-Source: ABdhPJywXGFc/B/Qr4uzSGH+g6inLHk0XCuTgETKoBKpCJTLrAwvOkuxjMf4jJlHRHWAi5kgcKvDVw== X-Received: by 2002:adf:ee8d:: with SMTP id b13mr9833308wro.249.1599965912174; Sat, 12 Sep 2020 19:58:32 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:31 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:51 +0200 Message-Id: <20200913025753.274772-14-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/16] avcodec/tscc2: Cleanup generically after 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" Do this by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/tscc2.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c index 65fbb010f6..6aadb51ad4 100644 --- a/libavcodec/tscc2.c +++ b/libavcodec/tscc2.c @@ -74,18 +74,14 @@ static av_cold int init_vlcs(TSCC2Context *c) tscc2_nc_vlc_bits[i], 1, 1, tscc2_nc_vlc_codes[i], 2, 2, tscc2_nc_vlc_syms, 1, 1, INIT_VLC_LE); - if (ret) { - free_vlcs(c); + if (ret) return ret; - } ret = ff_init_vlc_sparse(c->ac_vlc + i, 9, tscc2_ac_vlc_sizes[i], tscc2_ac_vlc_bits[i], 1, 1, tscc2_ac_vlc_codes[i], 2, 2, tscc2_ac_vlc_syms[i], 2, 2, INIT_VLC_LE); - if (ret) { - free_vlcs(c); + if (ret) return ret; - } } return 0; @@ -360,15 +356,12 @@ static av_cold int tscc2_decode_init(AVCodecContext *avctx) c->slice_quants = av_malloc(c->mb_width * c->mb_height); if (!c->slice_quants) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate slice information\n"); - free_vlcs(c); return AVERROR(ENOMEM); } c->pic = av_frame_alloc(); - if (!c->pic) { - tscc2_decode_end(avctx); + if (!c->pic) return AVERROR(ENOMEM); - } return 0; } @@ -383,4 +376,5 @@ AVCodec ff_tscc2_decoder = { .close = tscc2_decode_end, .decode = tscc2_decode_frame, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Sun Sep 13 02:57:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22326 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 80BBC449E91 for ; Sun, 13 Sep 2020 05:58:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 671A768BBDA; Sun, 13 Sep 2020 05:58:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ED1E668BBB6 for ; Sun, 13 Sep 2020 05:58:33 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id w5so15041868wrp.8 for ; Sat, 12 Sep 2020 19:58:33 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=FSkP1ejAn4CBe35nzokphEqOjHT11GUwvmThJCp1+ZI=; b=QakuFyOq0DJ7xr3Ufks3hm9pwd5oToJqCLf1uROpaAylK2Vld5QXT5k70jOMYUiMGn Wv/XlQU3xoChZ1/wVQ5RG0j++q97xlvF/vzd6fWXopFmZxbFLqAWPzoR+prh01FfEd4W 7cX9vcKHFhIAtWfCuUXSmcERbdpj9id+fdvtAhmAUuY+5EXdImgf2P3Du/I3V1kJCtDK tFaAk/qfdgSiBqqvyLixrIqHu8fIoXh6gCr1d8BlMeqoMxQowcNhyZeNMUgNm2eWCMn5 iXudXpQS+Nf+v5RXNvmpQRpbbvkn1j/3a7gCQprrBG9d8DRXAjpT+NzItmPnE4jEkwUL 96nQ== 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:mime-version:content-transfer-encoding; bh=FSkP1ejAn4CBe35nzokphEqOjHT11GUwvmThJCp1+ZI=; b=YevW9vdNIDm7eBU0SxpZiUiq/ZZu9Q26OTFFldIvIwIqjF+JCqE8UDOIjrNZx+giDL jyehiP9tmrfO7Y11Smkfg4iWjcCJtZy2lVlawoehw2mfyWII6rsz+bknapB1ey7uo2cX /t+i0HUqyyHdAU/K/1JF9UsbAX39ozPdNib5YrUfBP4UyUTfi8nLlhrrpJ3ntjBf3CDC WjVQR9qVt6H7Xr5TV+y/gVvvoFI6X9WAddIwWmpzwGPYy/ZZl2g+tJBjrzUipaN/KXY9 uIgyZQDtWba3h9fEW71fFNDfQkWWO7wdYikuS8Eh8OQPmjMUBeLh2FDGQ1148Aa+nqe1 UXkQ== X-Gm-Message-State: AOAM533HHfDUuhtse/GbE9W6VZYhtBw6ih0hP5IwNs6zdGggdElgs4h6 uzBKxnrnwc2YWYZcT91KnTtmgC7DUeE= X-Google-Smtp-Source: ABdhPJxlZquqaeuqYdocWZf9MPeZfpMZGPRO+eNTAzkG4TE/j3lrRqMgZAYGvBcISnIYMWnJ0EcSrw== X-Received: by 2002:adf:f44d:: with SMTP id f13mr9074252wrp.224.1599965913168; Sat, 12 Sep 2020 19:58:33 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:32 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:52 +0200 Message-Id: <20200913025753.274772-15-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/16] avcodec/vb: Cleanup generically after 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" In other words: Set the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/vb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/vb.c b/libavcodec/vb.c index d9c6b93a73..fe419c7663 100644 --- a/libavcodec/vb.c +++ b/libavcodec/vb.c @@ -262,11 +262,8 @@ static av_cold int decode_init(AVCodecContext *avctx) c->frame = av_mallocz(avctx->width * avctx->height); c->prev_frame = av_mallocz(avctx->width * avctx->height); - if (!c->frame || !c->prev_frame) { - av_freep(&c->frame); - av_freep(&c->prev_frame); + if (!c->frame || !c->prev_frame) return AVERROR(ENOMEM); - } return 0; } @@ -291,4 +288,5 @@ AVCodec ff_vb_decoder = { .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Sun Sep 13 02:57:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22327 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 575A5449E91 for ; Sun, 13 Sep 2020 05:58:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3B40A68BBF9; Sun, 13 Sep 2020 05:58:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5626168BBE9 for ; Sun, 13 Sep 2020 05:58:37 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id w5so15041919wrp.8 for ; Sat, 12 Sep 2020 19:58:37 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=liAYWGHrLLAxMClsQeq/oubxxvn21qy7t3k/REA8PX0=; b=JuT3HWA4R7Z7cVD9jBGQb3Am3bhlzjmSXHBQBesm1ZqeSO5NuOcutrCG3vsvRxAyll qmr+BvJ4OcXP+Q5mo4tniO8QUls8SPKLndHFum69j6HKuPSSSnnVICVQbJ+kpO3fEP/l kPCRYjFPY+3UAelOro7Od206POcEF/uACf32p9lQwCgq+R+6PTQhOgFIPV6ih/LfGFyw iL9suYSSb1gkeG4kfMoT3yE0snoYYfIfIUcCZFHHCUIX6oz8mSNKqri6NBI4XvqBYBfI Hf94UX3WPK7Xjex1jr/qKJKWZ1m5mx3jIXI+ac+OaoSh/cZJC4q/4VSsyql7MQcjuByE tbNg== 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:mime-version:content-transfer-encoding; bh=liAYWGHrLLAxMClsQeq/oubxxvn21qy7t3k/REA8PX0=; b=l50RlLkCWZf3N39LzzsKcU26611MUwkkcHPv0yZnnb4qb4GKpP7WbZbKNKEIBqVxBT UTnsQdMjDjsLOc7UOoB7DhkHefTDPGGn1mIa2Ydxwn/0EXHY3+mVDJU0fW8EkaFOSa7j PjBwttygzDECZmFPXeWxVnWrqiQ02Q/Bb4hY4j17buqVJFnsaKZ7uJuC+KO4jDyAhG/p PUIhZxwTUlGXp65U6Y9yjQiKe5JrrcqwXT34FHlKOIQEm7H64DMfbWfH2wVtp8/BR8Dd 9+bm6K5kABRhYv4zcDq7A1uCIoPyzuvwathd6eqMOYEyVPZrLNkOjPN/7sb5CuQfrlhK Rmmg== X-Gm-Message-State: AOAM5315UJME9GktSHm4EFDSxulaEwwwvtRYGxHLVh9i41H5aZdx1vrx wy7kgiFE2gRE51r7o9OyS9sy8ZhOiAQ= X-Google-Smtp-Source: ABdhPJwb3Dp2RzavMRvPlvkKHLdw/uhjqDmLZh6FKZfXDyJZNtO9xbX6mhYd5Pk7iJMxh+lh+RTnSA== X-Received: by 2002:a5d:6a45:: with SMTP id t5mr9843331wrw.58.1599965914134; Sat, 12 Sep 2020 19:58:34 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:33 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:53 +0200 Message-Id: <20200913025753.274772-16-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/16] avcodec/vble: Don't free buffer known to be NULL 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" Freeing a buffer allocated in the VBLE decoder's init function is the only thing the decoder's close function does and this implies that it is unnecessary to call it in case said allocation fails. Yet this is what has been done. Signed-off-by: Andreas Rheinhardt --- libavcodec/vble.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/vble.c b/libavcodec/vble.c index c48c13127a..2cddd550b1 100644 --- a/libavcodec/vble.c +++ b/libavcodec/vble.c @@ -197,7 +197,6 @@ static av_cold int vble_decode_init(AVCodecContext *avctx) if (!ctx->val) { av_log(avctx, AV_LOG_ERROR, "Could not allocate values buffer.\n"); - vble_decode_close(avctx); return AVERROR(ENOMEM); } From patchwork Mon Sep 14 05:27:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22348 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 A0A0244BE7C for ; Mon, 14 Sep 2020 08:28:03 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 757E068BB1F; Mon, 14 Sep 2020 08:28:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E7D7168BB1D for ; Mon, 14 Sep 2020 08:27:56 +0300 (EEST) Received: by mail-ej1-f49.google.com with SMTP id i22so21341441eja.5 for ; Sun, 13 Sep 2020 22:27:56 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=Lds2C0FrcZ6S/WnF8PLs1NFSpx5Veywnt5lGQU1W5N4=; b=Ql+kziqFkwKyFmL1qcli1Pad8IB6qiwrumZS3bTOdJzUmm9RwRz6rkPq4I86al2tSp wPb3UIVGJEXAqipqr/63jbIincSYPU2za9kjexN3fvheUGYr4VmW6BJ8fe9Gc3+MctGs b2mg+f4NzVQvYjjLhI+haI6EuWBoM/56rBcfgBXfYh9/sXGSxL8G+E7AjDgdAfo//Ch9 /gWZDSMxZIWpxJmhaj33Z05LOUcAIq3xcedlldKM546H9uVifOQgTXVpwlX5t5Np/WYc CgUrsNG2qIVZmddwUQRZW56dvTfTne9hocg0K4QVjLd2RL+eBplyRvOUXI2kebgSL2Cv XRMQ== 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:mime-version:content-transfer-encoding; bh=Lds2C0FrcZ6S/WnF8PLs1NFSpx5Veywnt5lGQU1W5N4=; b=SCfQZw5FBURxKCJqpSZufOH4pSEBF2UGWNMereRUcGsLqK3qmcXuW9C0kMKvGwuPWn BLrpmLM+TjsDXq8JcMDo3uhKVbRmcKEvc3LUngWTeJ0cbDru3038BtC1hfmzXhdgn1U2 +A16hd8OwKdp3jN+LzcD7BBy2pRJpg0eJfT3/0+mdEwuBMQwB/1A+UesTCeR6wdP56Y0 78bQ/DDOSBVEApc4KxME62+grawrIitpWu7hbUXdENpcCmm9dM4KaQ7/PgtVJTOyY0cR B9hEk4jLcgIPZSIoOHv34PZyxEYz9sRMUNP4v2GNfAQqLIeqQSd0XAt8ENDedsRHk56H Ka5Q== X-Gm-Message-State: AOAM533wYCmojWLX6nKgbLE/uCr6COjHbctFhsBkOMNVvnco8yl8e0Uq rG4tMcNbeMIU6tvFbKnHmaQECwEmdLw= X-Google-Smtp-Source: ABdhPJwqN7nxyluP4625xzMsKyNqrExm6q3C+TrbDk1HTsE5c8i4Ros/7iBkAQmD2GxckQhKxx6Dww== X-Received: by 2002:a17:906:7f15:: with SMTP id d21mr13254276ejr.470.1600061276071; Sun, 13 Sep 2020 22:27:56 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:27:55 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:24 +0200 Message-Id: <20200914052747.124118-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/40] avcodec/alacenc: Remove redundant code to free extradata 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" It is already freed generically for encoders. Signed-off-by: Andreas Rheinhardt --- libavcodec/alacenc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 804cc7b17b..fc5fa270e6 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -498,8 +498,6 @@ static av_cold int alac_encode_close(AVCodecContext *avctx) { AlacEncodeContext *s = avctx->priv_data; ff_lpc_end(&s->lpc_ctx); - av_freep(&avctx->extradata); - avctx->extradata_size = 0; return 0; } From patchwork Mon Sep 14 05:27:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22368 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 C3DA244A762 for ; Mon, 14 Sep 2020 08:36:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AE56868BC64; Mon, 14 Sep 2020 08:36:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CDD3868BA38 for ; Mon, 14 Sep 2020 08:36:24 +0300 (EEST) Received: by mail-lf1-f68.google.com with SMTP id x69so12016186lff.3 for ; Sun, 13 Sep 2020 22:36:24 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=191hsLZQzMyrLAChgXYD8eP0jITwaEPjHi//EHy1IGw=; b=uLw43A6SSOpL7/YALxVejuR46nN+j1M2MQRpsLRi2lx/A7Hzbjviv6qa8aqv9iD1Un mLkkPre9BULIxqKj6Q5INKmsXdY4MWAA1mV+wA/O9lEREPfnULQe0YYT5b94iKIRq8PI zk5Rtmec5XqeIC6Z1IJFUSX5lAQNQuyntENPpZF6N81TtOaCNG21NlIaerj92bifyeIo CuCbLeUIxa9EyyhAAUWYUJoxtIdo7zK1BZcIHQ/UYOkF2Xq8N4KLoXcVHa3KvGOj1jMp yG6m+++zf7rV3qXUdsk+WV2OE8VQbpHYGJYLHFnvX9gaZzcSge9cVIGDkjsl2JyKeKQN jBBA== 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:mime-version:content-transfer-encoding; bh=191hsLZQzMyrLAChgXYD8eP0jITwaEPjHi//EHy1IGw=; b=XiSx0LGpWbQRanrx1NQ5WV9zr2IGPqKw9bOdWO2fQy+q6sVwD8E+v0GMVSXPIJwYwI qV/JFKXANzgY7SkRjy1I68+5LdSmaZZwBNljVxtjFT1ubzEBeot3LSIWDHK8fcUa1o8T kN0B4vS9mOTBnhVZFh94ZRlO3rRNL1lHv4pF7Alr2j9dn9uKXFXXwWpVYRTECls8a6/g xw0fSmxMX8t99itKDubRcl0wWYYjlcq9dNx7KUlOxY6B7aOZ7KpwKbKd4UXshcn5SXEs 2s6A1S5DEb/N6xlIq1/IKejVk9VPl5EaBvg/LBPrFF22kovnfHeEpoHx9sWjxkVKB5yP h1MQ== X-Gm-Message-State: AOAM533Vqt2wcf0JqVGysLhDYCo40FlP2c/AKghLnNYYB5ENHO71/x8d ibAYiADm6PRlK4K45tXWzJZpbXuOU/w= X-Google-Smtp-Source: ABdhPJyjpB1c3BoBCV/IdwGELvX8Fz/aS+G0AKCLAnEJrtAuLA3KcnYBrKrlvx2LAcxJJrBEE+ADyA== X-Received: by 2002:a17:906:454a:: with SMTP id s10mr12807441ejq.138.1600061296871; Sun, 13 Sep 2020 22:28:16 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:16 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:25 +0200 Message-Id: <20200914052747.124118-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/40] avcodec/alacenc: Don't free unnecessarily 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" The init function of the ALAC encoder calls its own close function if a call to ff_lpc_init() fails; yet nothing has been allocated before that point (except extradata which is freed generically) and ff_lpc_init() can be expected to clean up after itself on error (the documentation does not say anything to the contrary and the current implementation can only fail if the only allocation fails, so there is nothing to clean up on error anyway), so this is unnecessary. Signed-off-by: Andreas Rheinhardt --- libavcodec/alacenc.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index fc5fa270e6..9d135d1350 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -535,10 +535,8 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) avctx->bits_per_raw_sample); avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); - if (!avctx->extradata) { - ret = AVERROR(ENOMEM); - goto error; - } + if (!avctx->extradata) + return AVERROR(ENOMEM); avctx->extradata_size = ALAC_EXTRADATA_SIZE; alac_extradata = avctx->extradata; @@ -566,8 +564,7 @@ FF_DISABLE_DEPRECATION_WARNINGS avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) { av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", avctx->min_prediction_order); - ret = AVERROR(EINVAL); - goto error; + return AVERROR(EINVAL); } s->min_prediction_order = avctx->min_prediction_order; @@ -578,8 +575,7 @@ FF_DISABLE_DEPRECATION_WARNINGS avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) { av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", avctx->max_prediction_order); - ret = AVERROR(EINVAL); - goto error; + return AVERROR(EINVAL); } s->max_prediction_order = avctx->max_prediction_order; @@ -591,8 +587,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n", s->min_prediction_order, s->max_prediction_order); - ret = AVERROR(EINVAL); - goto error; + return AVERROR(EINVAL); } s->avctx = avctx; @@ -600,13 +595,10 @@ FF_ENABLE_DEPRECATION_WARNINGS if ((ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->max_prediction_order, FF_LPC_TYPE_LEVINSON)) < 0) { - goto error; + return ret; } return 0; -error: - alac_encode_close(avctx); - return ret; } static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, From patchwork Mon Sep 14 05:27:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22362 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 0D7BB4480DE for ; Mon, 14 Sep 2020 08:34:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E84A568BC35; Mon, 14 Sep 2020 08:34:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5913A68BBA9 for ; Mon, 14 Sep 2020 08:34:32 +0300 (EEST) Received: by mail-ej1-f66.google.com with SMTP id i26so21333560ejb.12 for ; Sun, 13 Sep 2020 22:34:32 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=0RxT3lXPCmOj3ZPBLs3oE9Sd+hOidPoBLW80g/6/aO8=; b=RF3IyvjvxIbN1IJvgQeS5+ROAzcIna2+RerbtulqF3IiA8tMaMO0YW62bpNlllq/oQ qaTG3hGdTdTxsFjm7UKLCZJNPfSc5/5d4fBr9WBcXd/kqbR1Y550fAYGHHhxlId4SYy7 X6USy9NAnSZtjbjp8XBQjS5ZWJf9kALUIzIbRmpVNujll1js3x36bkmVrnywYTBtYn42 tj7w4pACati/8ZHfUWJwQYdnQdRCpWAdep5RgYdmQZ+823r8FjLSyuqrVYGMnx+THbF7 z7lvOtDqLa4YrU10Mk7lTTTVVM0TIajR3jqyTRJhjEG3FNIyC/eF0m/JzqQoIM1ItJ5g +KZg== 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:mime-version:content-transfer-encoding; bh=0RxT3lXPCmOj3ZPBLs3oE9Sd+hOidPoBLW80g/6/aO8=; b=odxb7kz0WqBlfUGJiKgzOMdEkqyvt+SUdGX0jBsEesTdjNPTlA9fZ9LzegZKttAAtm r5+P8w4aQw+V41M4Wb//iSU6mWOBwtnTxNYcsXt070PCxnHr+aj214pO3v2S7cp5ZvP0 enmnzSjXAH84C9iax7CZh026JYk95D0NpfGFbcJFCG0gEJZJGfT3QA946UDlpDaJnqve FeRdIk8kYEhziGjTaIeZ13Rdmfokqgd6yAbve2v74lc4KDAaU3cYIDfSokC7QZNsCmnj Rcgs2398xj4nM1PX9+I2Hmfk9D4On9KKe31hHEGdslqgwkN5SeiGYJYu7aZR3fRTJYZS CV5Q== X-Gm-Message-State: AOAM530Fa0woO6kB5ImT/jx1s584bPX2OkCk7IJ5atdRqVmO7T+CGvcz ldIUWm/jdK5WkQJ/IMvnJPotJ9N1qgc= X-Google-Smtp-Source: ABdhPJz3690ejy5im4i+Fl57S0G3jgY6g3PeCQVNEHT+vXK4EfqP6cFIJVCCr+TiqxfY0juUGiamaw== X-Received: by 2002:a50:f687:: with SMTP id d7mr16020445edn.353.1600061297757; Sun, 13 Sep 2020 22:28:17 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:17 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:26 +0200 Message-Id: <20200914052747.124118-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/40] avcodec/atrac1: Check allocation of AVFloatDSPContext 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/atrac1.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c index a8c8c91bcc..9ecd49273d 100644 --- a/libavcodec/atrac1.c +++ b/libavcodec/atrac1.c @@ -362,6 +362,10 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx) ff_atrac_generate_tables(); q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); + if (!q->fdsp) { + atrac1_decode_end(avctx); + return AVERROR(ENOMEM); + } q->bands[0] = q->low; q->bands[1] = q->mid; From patchwork Mon Sep 14 05:27:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22361 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 F0D444480DE for ; Mon, 14 Sep 2020 08:34:28 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D1ABC68BC30; Mon, 14 Sep 2020 08:34:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B8F868BC2E for ; Mon, 14 Sep 2020 08:34:27 +0300 (EEST) Received: by mail-lf1-f66.google.com with SMTP id z19so12013402lfr.4 for ; Sun, 13 Sep 2020 22:34:27 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=T0CyGAdglA9BoAmRC33IMsKitGAuFDq7yQBYvErf/qc=; b=OQslUylr+WoY3IlSRKgxTgcQM7+UQHV+HeUQ5sRPyeyCZfYTxrLcAmz4fCaxjhkjOQ 47aVBonRk3iyUewuSjyhBSzdoJnfy3U/MbWrAgNhumj1c0lC1D+oLU7X9KQpGePaS09m ROt7FP9VS/79z68tplyNHooq0tqt6QS9zJancxv6QJtWoc6FUsOqKv7VqlUnIoWPSfbJ IEVTS912TWzVZGs8Kgsp8d0v2HHFrpX6Js0SsyJBFLZ8FopNzkHRZR8mwra1AkQrOmJE 8vRXepieOQoMN9DQWXlGy79kIQ1pTf4ml5sRI0LRCOaArREbWwgpCq4vr1dChbLwZfpM ho5g== 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:mime-version:content-transfer-encoding; bh=T0CyGAdglA9BoAmRC33IMsKitGAuFDq7yQBYvErf/qc=; b=ljT7F9wFIEFx42Dv7kJkjTs4RF22Bfd2/O+D5meuvJkTZY1qNjtQNGOhvKp0m7+llN NLSq4HbMpmdISIb06S/W60OyDU2wYXjaKl2pNGhezDyLHTydSOOVKsuNKeIi8mUDISwh q6R8dDbXjGsOd59ezYT24YPe2L9414ufgcJoNjlpCAcMyRSgy9F7QGCz7LjYEv96yrhW A2G1O5HQuGlu4j2KkGHl+QXLlTwIj+pwEK1dhhKB4P2ebn7PTwrbn6kTQ+Mp64OiKGqQ RnhR9OlaawrinmrMy2iBiw1yCN2AljJ+p+fW8Y7EULIMwFzKsRMuJwApXwkKvXnLoitS /DUw== X-Gm-Message-State: AOAM533pWxLF1zu1gw4ib+5sT9LLsuQKeRFH+6yKsj4LUl7RE+fV2uAb Jmkd66SfuEtZ8uS5Km64hwv30Cx7OV8= X-Google-Smtp-Source: ABdhPJxBFDuww5LNP5mBZki/343tHcyp7rR/UF7aEj5Sh1wYtzCFnB/746yECnyfXMWPSSwFy3tJkA== X-Received: by 2002:aa7:c053:: with SMTP id k19mr15240495edo.326.1600061298729; Sun, 13 Sep 2020 22:28:18 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:18 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:27 +0200 Message-Id: <20200914052747.124118-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/40] avcodec/atrac1: Cleanup generically after 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/atrac1.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c index 9ecd49273d..4cfb1061c5 100644 --- a/libavcodec/atrac1.c +++ b/libavcodec/atrac1.c @@ -353,7 +353,6 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx) (ret = ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15))) || (ret = ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15)))) { av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n"); - atrac1_decode_end(avctx); return ret; } @@ -363,7 +362,6 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx) q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!q->fdsp) { - atrac1_decode_end(avctx); return AVERROR(ENOMEM); } @@ -393,4 +391,5 @@ AVCodec ff_atrac1_decoder = { .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Mon Sep 14 05:27:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22370 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 7E9E744BBDB for ; Mon, 14 Sep 2020 08:49:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 596C168BBD5; Mon, 14 Sep 2020 08:49:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D6F0D68B8E3 for ; Mon, 14 Sep 2020 08:49:37 +0300 (EEST) Received: by mail-ej1-f68.google.com with SMTP id nw23so21394118ejb.4 for ; Sun, 13 Sep 2020 22:49:37 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=uvMt9vckLgeDY4kXfgmvobJ+qRzpnBv3bdYG+DBRACc=; b=kOKGx988FTgSoeI1OyUZJJmE5yDlgQQLVoKwmdTt/ZAABcZD2KGo1CgRz3KhjaSkrB tHNw69z6AHVsQpbXYPBTdUV7ksaQ7vJLAseI20xmFpOrrMviIGt8Ob/+ekhb8E3oBlLb 9IkRbzpZltDiX9oYWclymnKLcwDLHxAQG55eHfTlcvyZt3FmpmfLzoN78oFfbTXHggxZ EMZrbV+2BlBcBgpQUsUEtXLToRNRDQVRPBrqlugt626H2rEx/maMHPpUezdNdJpClI4u NrkQCfUswcYanNUxsDU9aDS23uGIhajC3nQ23s3NT224RTvp7iYDNl4uKCNyOMmSuZy0 EAIg== 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:mime-version:content-transfer-encoding; bh=uvMt9vckLgeDY4kXfgmvobJ+qRzpnBv3bdYG+DBRACc=; b=iXjNnEzUFwl2Dv+X1FQ3l6nskgWav2hTKmdF616D53+QJnFUWgZYsDC5Y4Mi6S62x6 iZ9yKnk43ib4ZE1IQ6LljSTEQ9VfnVNcUgZ/TTWagi/rQjZ8gloclOz98iD4tTpuo/Q1 AEs1Jys5kml+jNG+8Nqh4BSTl6CPhzJ823NAsH2bypquFX5KqP7OvADPh1aKW1Ktjy14 FHPWc93sNa9CuEbouK9PLoX/IoVYLXGwyHX+rLup0pTxscT4zruBNsSFSiBmNohMkST+ vPc3WZEguRoF3SiECLzM4vpPuAHJxnxdbsnHj0uVlOn1rYWGyoU/qv0fUKbAM/ImQn85 aDRQ== X-Gm-Message-State: AOAM531fhhB5i2HW0KMn3BdRfHRPlgX8qMJMeVjVO4PD4d+OBpt+EA6p tp/swXTpfMmr1mr0H/KhZZbBmPfZ7/w= X-Google-Smtp-Source: ABdhPJy3W3iA1ZLMi2VaGxs03qHHmEbnUJcI9E/bd8OaiNmLlJTkGlCqCAYxK+OblQhE/8VnF/oUVQ== X-Received: by 2002:aa7:c1c3:: with SMTP id d3mr15666475edp.228.1600061299718; Sun, 13 Sep 2020 22:28:19 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:19 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:28 +0200 Message-Id: <20200914052747.124118-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/40] avcodec/atrac1: Avoid indirection when calling float dsp function 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" Do this by only keeping the only function pointer from the AVFloatDSPContext that is needed lateron. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac1.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c index 4cfb1061c5..b2a2d5e6a1 100644 --- a/libavcodec/atrac1.c +++ b/libavcodec/atrac1.c @@ -80,7 +80,8 @@ typedef struct AT1Ctx { DECLARE_ALIGNED(32, float, high)[512]; float* bands[3]; FFTContext mdct_ctx[3]; - AVFloatDSPContext *fdsp; + void (*vector_fmul_window)(float *dst, const float *src0, + const float *src1, const float *win, int len); } AT1Ctx; /** size of the transform in samples in the long mode for each QMF band */ @@ -140,8 +141,8 @@ static int at1_imdct_block(AT1SUCtx* su, AT1Ctx *q) at1_imdct(q, &q->spec[pos], &su->spectrum[0][ref_pos + start_pos], nbits, band_num); /* overlap and window */ - q->fdsp->vector_fmul_window(&q->bands[band_num][start_pos], prev_buf, - &su->spectrum[0][ref_pos + start_pos], ff_sine_32, 16); + q->vector_fmul_window(&q->bands[band_num][start_pos], prev_buf, + &su->spectrum[0][ref_pos + start_pos], ff_sine_32, 16); prev_buf = &su->spectrum[0][ref_pos+start_pos + 16]; start_pos += block_size; @@ -324,8 +325,6 @@ static av_cold int atrac1_decode_end(AVCodecContext * avctx) ff_mdct_end(&q->mdct_ctx[1]); ff_mdct_end(&q->mdct_ctx[2]); - av_freep(&q->fdsp); - return 0; } @@ -333,6 +332,7 @@ static av_cold int atrac1_decode_end(AVCodecContext * avctx) static av_cold int atrac1_decode_init(AVCodecContext *avctx) { AT1Ctx *q = avctx->priv_data; + AVFloatDSPContext *fdsp; int ret; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; @@ -360,10 +360,11 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx) ff_atrac_generate_tables(); - q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); - if (!q->fdsp) { + fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); + if (!fdsp) return AVERROR(ENOMEM); - } + q->vector_fmul_window = fdsp->vector_fmul_window; + av_free(fdsp); q->bands[0] = q->low; q->bands[1] = q->mid; From patchwork Mon Sep 14 05:27:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22358 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 41AA3448021 for ; Mon, 14 Sep 2020 08:34:00 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2075068BBA5; Mon, 14 Sep 2020 08:34:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7EFC468BADC for ; Mon, 14 Sep 2020 08:33:53 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id m6so17233599wrn.0 for ; Sun, 13 Sep 2020 22:33:53 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=V4UyhUpoZeeBms2C/pp3Iz4tYiGg5sG7S+BJhBXhDWs=; b=c8PKUrsGwSAJsxrMGYL3c0wxA0AnF2i8rbTRCeZarYTZufPbirZtEqt5LCodn3J5jh PMDJ3tDhw9hLR7yla7BYQl5VBhXubu/s550VxYTNwEo1ZRSP8ycAnsHGttkVpSQx6J9Z QLPIywGfaEP7o3TWORdspfZNyfMW0GsP6u0QlOT3Ymuq3bj5R0KjRGMxeGf7jQaYSTwA wqMK0Ct5nl18mbMzQihcncPKtG4KbTO6MIF0wDD9oMo14JPWh3POSxaAjxeR1283DhVn 8laHFPUqIUZFLtaChYsiu5bWCmLQzvLDd34OC6i1kX4aWKTP2uF1o/MadGMFV978SogY HABA== 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:mime-version:content-transfer-encoding; bh=V4UyhUpoZeeBms2C/pp3Iz4tYiGg5sG7S+BJhBXhDWs=; b=WSJtR5o8vBqw7auj67de3bwXYyWdP5eOGsQ4gv05TkXZqJW9tlPgKhmql5+SpH7tBU 8I4DuggqufeFqXK2pjxszcGe6yRFq7ogtafxU6maejPUDTBQawGQZy2W+eOn0ngXdY/B V8dDrK0YKhgRqDulguHc1VgoBXS2UuK3+LDDXF63sHLUwycMH5ak0Iz3slTxmHttw2hL fT6s2J3jmE3xlgWWI4GYHhrh7fSFBEuMvJLF3lfLAD1YTorKTkF1NisBG95c9w/mFn4+ VPym+q/d0oVop+V7Ouw+H18frRC6pWBy5xaRTXkOVJdyiSqjaWzHVNjGOgNR4YlAc/do jWHg== X-Gm-Message-State: AOAM530w46HKxmb+SvMVYDCC5FY3kxZ/9v7s0Osvbd7cWcwaTTS7Z7dE c14sGNAm27K5HXjA1VErnomPXRI/jMU= X-Google-Smtp-Source: ABdhPJx5k09KaIAXq6ZDHuXHDUS+Kx05aYjT1gjRR4fRssU03VP2JcdZNTVNNY27vWsnxS+IU16Y0g== X-Received: by 2002:aa7:db02:: with SMTP id t2mr15348422eds.95.1600061300672; Sun, 13 Sep 2020 22:28:20 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:20 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:29 +0200 Message-Id: <20200914052747.124118-6-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 22/40] avcodec/atrac3: Cleanup generically after 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/atrac3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 067aa23f1f..ef2f8428dc 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -977,7 +977,6 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) /* initialize the MDCT transform */ if ((ret = ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768)) < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n"); - av_freep(&q->decoded_bytes_buffer); return ret; } @@ -1002,7 +1001,6 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) q->units = av_mallocz_array(avctx->channels, sizeof(*q->units)); if (!q->units || !q->fdsp) { - atrac3_decode_close(avctx); return AVERROR(ENOMEM); } @@ -1021,6 +1019,7 @@ AVCodec ff_atrac3_decoder = { .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; AVCodec ff_atrac3al_decoder = { @@ -1035,4 +1034,5 @@ AVCodec ff_atrac3al_decoder = { .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Mon Sep 14 05:27:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22365 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 5D332448249 for ; Mon, 14 Sep 2020 08:35:12 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4593B68BC31; Mon, 14 Sep 2020 08:35:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1CD6E68BC3A for ; Mon, 14 Sep 2020 08:35:10 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id s12so17180455wrw.11 for ; Sun, 13 Sep 2020 22:35:10 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=UyNmZ4sX3qb4APnTgX9TkYV6m7mwNGZGI1D/CxlkluI=; b=u1yw1Yfhjl/fkKmWBd+IanWxBgd5YDfN7Q0tHfXP95iDSxY494R44ZMBYBEPHY8wE/ SY3XgD7G+WCmYklEl19Ak8ywHms6AJf1qThhNMxZJOE9xDSk208oKuYDkK7Py4JDS3Ct oZXoz4ZylNfX/9isaYtNou16ShvNWA6NUMfLSaghvY3KdsDY/PHMk1NTUMZRxiNGqVFX GhH94Xhqid5kWuNQVhbXoC7dHFN9accr8TSCzZlBtN8uHq8grwIZ0cw2Ph4t685bj8xQ q21s3+u4lu/kMA6ZHMKmSVhFpI1Fy3o+x2EL/LRjndb6QfWFr3aHjbcgmQgN6iyx2vNi URgQ== 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:mime-version:content-transfer-encoding; bh=UyNmZ4sX3qb4APnTgX9TkYV6m7mwNGZGI1D/CxlkluI=; b=dquPH1rsqzSeazJhzY4o1jgqxeRWyVbXMUiU5EBzw3JngTI99vw0qld4PsnI9LLPzv P97MatJ82rniwXY4GbJwEaya6bRbKI8LCmKFSyb855ild8aruQIaVDtNKiAlTYq7sh40 H/XS0BcBvK/JQvBHEQ4ZC+bSabkp1PQVcfmthMNMNRMKDsFinLD8YYwG43LFMbU/T8Qm AHITz/pgx7s8Rc/djE3+8ow56nkKsAXxJGYjDNnqQG6SchSptx8IvHNx9wg5e3ieV87I p9VqTwTfAXlPQxUpMDhL/ut8bQTdeB5mOvoxehLZtXmec5GPzUSes8M/xLo1emjvYSCl W1bQ== X-Gm-Message-State: AOAM5315vaMo6xhU23MHJLYdxpdS3IJ3fMkNL5fRJfsmAmm510N7J332 KF6CItrcMXeBx4MpPefZ9YejzwL9eZc= X-Google-Smtp-Source: ABdhPJy05Ca5bTiuoGlMrBck59FzryFul7CbyoUTbsD62LjMVz3FLURUbE0RDlmhzFBUatVOvtVotw== X-Received: by 2002:a05:6402:12d1:: with SMTP id k17mr15083754edx.323.1600061301700; Sun, 13 Sep 2020 22:28:21 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:21 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:30 +0200 Message-Id: <20200914052747.124118-7-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 23/40] avcodec/atrac3: Avoid indirection when calling float dsp function 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" Do this by only keeping the only function pointer from the AVFloatDSPContext that is needed lateron. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac3.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index ef2f8428dc..dc68e507aa 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -111,7 +111,8 @@ typedef struct ATRAC3Context { AtracGCContext gainc_ctx; FFTContext mdct_ctx; - AVFloatDSPContext *fdsp; + void (*vector_fmul)(float *dst, const float *src0, const float *src1, + int len); } ATRAC3Context; static DECLARE_ALIGNED(32, float, mdct_window)[MDCT_SIZE]; @@ -144,7 +145,7 @@ static void imlt(ATRAC3Context *q, float *input, float *output, int odd_band) q->mdct_ctx.imdct_calc(&q->mdct_ctx, output, input); /* Perform windowing on the output. */ - q->fdsp->vector_fmul(output, output, mdct_window, MDCT_SIZE); + q->vector_fmul(output, output, mdct_window, MDCT_SIZE); } /* @@ -194,7 +195,6 @@ static av_cold int atrac3_decode_close(AVCodecContext *avctx) av_freep(&q->units); av_freep(&q->decoded_bytes_buffer); - av_freep(&q->fdsp); ff_mdct_end(&q->mdct_ctx); @@ -874,6 +874,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) int version, delay, samples_per_frame, frame_factor; const uint8_t *edata_ptr = avctx->extradata; ATRAC3Context *q = avctx->priv_data; + AVFloatDSPContext *fdsp; if (avctx->channels < MIN_CHANNELS || avctx->channels > MAX_CHANNELS) { av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n"); @@ -997,12 +998,15 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) } ff_atrac_init_gain_compensation(&q->gainc_ctx, 4, 3); - q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); + fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); + if (!fdsp) + return AVERROR(ENOMEM); + q->vector_fmul = fdsp->vector_fmul; + av_free(fdsp); q->units = av_mallocz_array(avctx->channels, sizeof(*q->units)); - if (!q->units || !q->fdsp) { + if (!q->units) return AVERROR(ENOMEM); - } return 0; } From patchwork Mon Sep 14 05:27:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22369 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 9F7E044A762 for ; Mon, 14 Sep 2020 08:36:40 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 910E068BC72; Mon, 14 Sep 2020 08:36:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6E38E68BC67 for ; Mon, 14 Sep 2020 08:36:39 +0300 (EEST) Received: by mail-lf1-f67.google.com with SMTP id z17so11972410lfi.12 for ; Sun, 13 Sep 2020 22:36:39 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=CLhABYhhOqdbbXlxofDfpmXpB7Lt7i0x8DI7tq8+8is=; b=LDHxJNI7dgUUTeVFGKwfl6J4OAuDLUCjPlk2EjLMHKBS5mib1Eu909eJiw2EoN0sh0 FqiXC5Ly+vp5JcHD/LUeXRNvFHKKT5iVyfNI/qehZM8iy9dh/eHxW58yJ3oOBh3B5jGm nlpDrg33c0H0rz1yZQDGaaHa8UgWbEObPqD1ipdLKQqjfRa/Q7zrP4jIQ45X+7F73fiE seIo/PsjAW1LM3aNs3+eVKTLVMIH8ejedRfp48DHbEC5+sEcZALMAWQdVQLBFb2fcANp 5RJkYl+HoETxqs9nOswypvkinPIAQKp+C+wamJHuNyhJt6S/A62dOttRQ3Re9pWmlctN Bn3A== 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:mime-version:content-transfer-encoding; bh=CLhABYhhOqdbbXlxofDfpmXpB7Lt7i0x8DI7tq8+8is=; b=LHrnSUGweBKR+WVevPSXWRvtDtA2NYtcjqirtlLNLBXbCS7jENeWcj/PmQvfU/3e9+ /JKhZm7fkQvp2M1NrE8H/X0qgghuBxjLM9YftMR6auBFuOM3i0tkkuUSmVAPIZD7s7vi rYlN14mDZNAckVy3fp+QYsNA8o/jMntWTNphJSqfGCv8TWc+2iuCLN1v5gOcMUfghsPg Pinkc6SioAW/x/hIDg8gRrh7GKQGHhBDdr8rZLeo0weYqxbqxiAXAxHnu4IRLX1a3aQF brJ3nL1ZYXEpCO/GmkSb4BfgmOwGv8FiAHtqAy7mgxASPScLCR6U1jJqmFEBIruJ+Yh7 Oghw== X-Gm-Message-State: AOAM532SFZQoGLMhLSDGOL41L9H6CXvmg6y+oAwL/QfoLq3B9ROORluA 9/ZT6LEuaa50Z/0evvyzozq73GCfHZs= X-Google-Smtp-Source: ABdhPJwvC0Oas8aBxth7Gl7vA6ZjNHR7dgB3ZZI8OIbBBOzYdOFERg284S1bzOYUMLAHGzfIMkhTJg== X-Received: by 2002:a05:6402:10c6:: with SMTP id p6mr15567138edu.76.1600061302578; Sun, 13 Sep 2020 22:28:22 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:22 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:31 +0200 Message-Id: <20200914052747.124118-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 24/40] avcodec/av1dec: Fix segfault upon allocation error 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" The decoder's close function simply presumed that some AVFrames have been successfully allocated although this can of course fail. Signed-off-by: Andreas Rheinhardt --- Once could btw return immediately as soon as one encounters an AVFrame that is NULL, because these frames are the first things to be allocated in init (and in the same order as they are freed); yet I wanted to avoid this additional dependency. libavcodec/av1dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index bd8acdaafe..4b89bd83a0 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -388,11 +388,11 @@ static av_cold int av1_decode_free(AVCodecContext *avctx) AV1DecContext *s = avctx->priv_data; for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) { - if (s->ref[i].tf.f->buf[0]) + if (s->ref[i].tf.f && s->ref[i].tf.f->buf[0]) av1_frame_unref(avctx, &s->ref[i]); av_frame_free(&s->ref[i].tf.f); } - if (s->cur_frame.tf.f->buf[0]) + if (s->cur_frame.tf.f && s->cur_frame.tf.f->buf[0]) av1_frame_unref(avctx, &s->cur_frame); av_frame_free(&s->cur_frame.tf.f); From patchwork Mon Sep 14 05:27:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22357 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 1A5F8448021 for ; Mon, 14 Sep 2020 08:33:51 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EF45868BBA9; Mon, 14 Sep 2020 08:33:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C135268BA7E for ; Mon, 14 Sep 2020 08:33:44 +0300 (EEST) Received: by mail-lf1-f66.google.com with SMTP id u8so12011754lff.1 for ; Sun, 13 Sep 2020 22:33:44 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=RfEtpQCgTcHAujhavNnAOthO3DZ/jAUPS5uFVimZFUQ=; b=T1KCRFDesVtMJ+f+iUzW5I600dqiczISfQpMCGMP7H820lDUMCowdvXq2jX4B4I+eW bcI1KOshQ+lqVRS6+W4E86/mBEz6exLUiA971Ae5XowUoygPln5DaJdy7WYdUtbz486K Iq5l87bbJWUzQJFVqjPVn037xnY6winrNPl6Tz7cj3Xq0zBInSzRj6vQuG4j5VjMyGra zq9M+WRV9dI4oW7EclI2rCgU/0nxNPenKFgvNOQY7JtcvLiPKxdeBAYotAHIoY0KS+Sq HnwWX02LP+1YwISYwCOaOcqyRCiuy3dvKoA1mGxZCu2v5MXoMHsJaCNe/vfRRxDQ7pLm qJ1g== 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:mime-version:content-transfer-encoding; bh=RfEtpQCgTcHAujhavNnAOthO3DZ/jAUPS5uFVimZFUQ=; b=laoh2t111/eCZUwf/x0m2vfsrBuD4CaowzgKUFQAVSPJWJXQlBg5HZ/oBZY8WyulC5 K0ZBgT6G8Od5n1SozQhrKxT689EeLlGCcTgLh4B/KvYXWTbfCM+WYzV7mS84fNkrReyo GrJ9ShLw0dYNL5VCys/JWU7YtG0c9+5UQhsuwwDEa6ufG0MDTcs0LtwVHUfT/qmjjNM4 c/ES37xX7VAyYKidQJs/b6LuxSGG/l3wpE3jmYsSpqvZ8sf22kYcWJlfhw+5py1zx0WL Ga1EyYFwuOyqvpmDQlM5sIvb1Rf2eU+kBJp5+1pESTs0KtvT3mbSz3XAKxJxdclepK5s FMIg== X-Gm-Message-State: AOAM530zY6tRKROlDJ2TcyAFstDrQS8IHHpxs9FHoRNYaieGgc8emyA5 rXrJLYdQataREC1lwTg7S38Z8DsRZeY= X-Google-Smtp-Source: ABdhPJx77TVwzM3kFgufYWUqET9nIMZdCXkzGS2L6PRDXiUcFWGS5HbKxJQ+UJFF2f5Lqn7eebFYWg== X-Received: by 2002:a17:906:2a1a:: with SMTP id j26mr12828837eje.456.1600061303452; Sun, 13 Sep 2020 22:28:23 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:22 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:32 +0200 Message-Id: <20200914052747.124118-9-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 25/40] avcodec/av1dec: Remove redundant second free 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" The AV1 decoder has the FF_CODEC_CAP_INIT_CLEANUP flag set and yet the decoder's close function is called manually on some error paths. This is unnecessary and has been removed in this commit. Signed-off-by: Andreas Rheinhardt --- libavcodec/av1dec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 4b89bd83a0..1a9764db55 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -482,7 +482,6 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) { s->ref[i].tf.f = av_frame_alloc(); if (!s->ref[i].tf.f) { - av1_decode_free(avctx); av_log(avctx, AV_LOG_ERROR, "Failed to allocate reference frame buffer %d.\n", i); return AVERROR(ENOMEM); @@ -491,7 +490,6 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) s->cur_frame.tf.f = av_frame_alloc(); if (!s->cur_frame.tf.f) { - av1_decode_free(avctx); av_log(avctx, AV_LOG_ERROR, "Failed to allocate current frame buffer.\n"); return AVERROR(ENOMEM); @@ -506,7 +504,7 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) avctx->extradata_size); if (ret < 0) { av_log(avctx, AV_LOG_WARNING, "Failed to read extradata.\n"); - goto end; + return ret; } seq = ((CodedBitstreamAV1Context *)(s->cbc->priv_data))->sequence_header; From patchwork Mon Sep 14 05:27:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22366 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 69B58448249 for ; Mon, 14 Sep 2020 08:35:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 526FF68BC4B; Mon, 14 Sep 2020 08:35:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5B90C68BC4A for ; Mon, 14 Sep 2020 08:35:34 +0300 (EEST) Received: by mail-lf1-f67.google.com with SMTP id y2so11987150lfy.10 for ; Sun, 13 Sep 2020 22:35:34 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=UBXaU73x6tPT1LIxJEtCgwspESBGuCTSNdgVOwurPCQ=; b=amTWRNyabIT0fb3rhDibUScPEPNw3Nsvl+klqt4dTiviEADz/Y80id7ntbiOWS5e+l YOI1Z54ld3YPwN4DHmZesom1QDj7etuB5/uf+KabnlKUcF5Mmu2ZRau1G7qq/WjbRM1H +62Gm4LzwKX4bq/sLXGjHjsa2EIZ/zwvd7xuVs+mc6nVwl7rqzCgfONfVa84TXSY+bvS WOCWjLHc7edE5ivHqzR1kTQAhxNw3+1FN8MCZ6a9hUiwRc0prhvW6sK42+Z5pO9BcfYN /0fT8YseQl0Ra3nzt3WiTEr/ViL1TPy9F2ZaPbr2gc3kSaNhiYfq+YEGOBhvtuWoL9Ie 6S6g== 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:mime-version:content-transfer-encoding; bh=UBXaU73x6tPT1LIxJEtCgwspESBGuCTSNdgVOwurPCQ=; b=elky6wKQjf0wMGwnGWKEQ8zUf0HKRBxTliN6Xh+nm9W8SF0dQMw2ETNGIsyQGtfg85 zpKlxIq0sWfNQ13d37CQ3DgahXyrqAd7mEHTUWLFfNCshyX6wKY5JVJ/eb9t1hpuNiuV ZQ4Oqa4SQA7pkkXsYwXIhcItY6b7G79oBpox5fyuSRO6xT4s+p/SAWj4xS5dKp0aCWzT XDobRyoV++LFCffuxlCs1TefZ19OLCwqhFkoYa8wWXP5BLIVNXhO87LcqeHpY9/B4son eAatLNV7nJT7vR+uPlsk4Xva8yryONLy+WLwNEW6+VZiIGm5n+rTgEa1MXTIuNK0V6h4 AVkQ== X-Gm-Message-State: AOAM532ODkXEHger8KQxJuqqxGlQChCVLvdDA3YIrgEk1MhIZSJ8vjwi 7QTjWTzL3mt2yV+L0YQNo9kcnGQ/F+U= X-Google-Smtp-Source: ABdhPJwC2uurktT85faR/Cg6X+b70e4A9c+vsy+z4+/JlA0hEmxWbYuD91lCQf23sGkPIncvt7JiOg== X-Received: by 2002:a50:fc83:: with SMTP id f3mr15941315edq.102.1600061304516; Sun, 13 Sep 2020 22:28:24 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:24 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:33 +0200 Message-Id: <20200914052747.124118-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 26/40] avcodec/avrndec: Check allocation for success 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/avrndec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c index f4ec490de5..a4b6fadfc8 100644 --- a/libavcodec/avrndec.c +++ b/libavcodec/avrndec.c @@ -54,6 +54,8 @@ static av_cold int init(AVCodecContext *avctx) } a->mjpeg_avctx = avcodec_alloc_context3(codec); + if (!a->mjpeg_avctx) + return AVERROR(ENOMEM); av_dict_set(&thread_opt, "threads", "1", 0); // Is this needed ? a->mjpeg_avctx->refcounted_frames = 1; From patchwork Mon Sep 14 05:27:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22377 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:c650:0:0:0:0:0 with SMTP id k77csp893790ybf; Sun, 13 Sep 2020 22:36:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA8TbJRu6pvxv4Odh3Y/jK0zyLaDiik6z3et6xp519LBnNm6a2jf51ILB1WU6dunJ/PQC1 X-Received: by 2002:a5d:4d48:: with SMTP id a8mr13723019wru.318.1600061778953; Sun, 13 Sep 2020 22:36:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600061778; cv=none; d=google.com; s=arc-20160816; b=aEJB8dXLPG8GBond5s6CBYOxYqKj0/WfDJx+7eTFbPZD/dGEkxvILP6thDdT6i9ki0 e0cLiPcEfzordPWm7dBfHSQ/X0SN68e1nMgKdPFM1zZPK6jmd/kW6KOZCfzmKTZrLMgM yva8YVQCVFZ2w42o2fE6W1O4sHpSFe1+mlatSU8SOeZrjRPnG1BhaJ5e7xw5ChxlDvTt oS9Qe2r0YuV9PL1rxQRoT8Cx9kRURrml6DxjT4ch9/OmKOvJLwPUCDYcpg8dECiIB6Bb CdOp418wXTjTYvLyOmXHV6yu4emSmGTKrHBbyvYE6A39WCJt9dZC5lZVBex6ZhJcrdRT pQAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=RsOQ+x7hburvYyyRYZS/0dHioGFiUvaVO70QH5l/vEE=; b=gWaviAdnygbv0Ve3xccGL/McpqEeP5fASKYORQw97xIx+u72+aA9ilg21uwJfipAf6 KCXXSGY9Q2WEwHJmjZUru6YfgwhX/AFpvZ7MuRxo7WnkObwhLjSr8NULHOWbwXLJdSbA klnYjAM2WzM8B8IwiG8QfweIB7wO4e1Guiq/RB6ud0NqBHP/YIEXfoC5iWQHgrkuN2+l RwfUp9b4KPyxBUTeUw9bRSrLM/KkHrcE2hDgtiICc0WlXmKmW9nspFPkrRWR9xsNetTG vXAOMXirZL6vMFRiYjNV4vvr6E8nIKDS6Fg50Awl4LEqmEy+c6Z2ibJdh6OOYEXFnj7C Uleg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=QJ6wp9r1; 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 g67si9137491wma.107.2020.09.13.22.36.18; Sun, 13 Sep 2020 22:36:18 -0700 (PDT) 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=20161025 header.b=QJ6wp9r1; 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 21E0868BC3E; Mon, 14 Sep 2020 08:36:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EA9CB68BC55 for ; Mon, 14 Sep 2020 08:36:01 +0300 (EEST) Received: by mail-ed1-f65.google.com with SMTP id e22so5747204edq.6 for ; Sun, 13 Sep 2020 22:36:01 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=eM4k9NrJKaSaU4F2oVU6KerpWXvC+swmb0YG6+Hr+Zw=; b=QJ6wp9r1s5ylZb4vqTM60UzXLEXN28WYzRWqmX4+Wlsm4L+4zk6ghgkgkUBmNGHY3l uInWsyDCkLXwMDc7eZga/LFgafvgFZfZECe8GzwiYsbIRoQc+naqAH0i/3rp5tmSnqq5 SW2OCBRil5CnWGGZTR5seWt/PsC577SwK/ohbw8u75o+D7KvRv28pCmfVd4eRwAFL1j6 iTyI1Fyrpsu7Kw6os2BosDsPWd9UXGvO3y7ROgthmPBKbXR+4QQxo43uVk+qmJ27KYZ/ dfOLn84smMYE+n7PaD1VxH28xm1hnmcU14Adce0NRny/r2GBiHVUcyCZ15UTcEjXKfdr U7ew== 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:mime-version:content-transfer-encoding; bh=eM4k9NrJKaSaU4F2oVU6KerpWXvC+swmb0YG6+Hr+Zw=; b=gX/t8zUXQSal/n/Z4stjscN2KgQtNajf/jXbD2xk86TLIln3L9PJ+bsmOoedfFVxrm /px0T9LxsTI3wEe1xjHKcQAh4qPqdCpT9Es+7WjsMZhtHOTwWxPB7b82bgPQbINEXyD/ Z4nD1RMDNPJ34wiCAwEH5ZssQpk0/EEnX/npaZfy4hUb9sOQ8mYPgDLRUWlhKPswRQ7k xOJhCtIE88OoYLIaupalOZXvSxv1uzQIJTn1bLJOtLTywAI6w0EoAMUJVpNO0jF/Ipwe jBl6+PMHK2Y9HmSxO3kWl88eKqdBM25Dxs9JoZeZ+qGkg38mt2/7HlnXnotGc6QUdsD/ dr+Q== X-Gm-Message-State: AOAM532r5SrShaqpyA6M9qiKNuc2hKFmK5D+EUhp9yQw9gnlkPuXRK40 9SCxbzxXMzqWsdRioKCVimUvk2hmvp0= X-Received: by 2002:a50:a418:: with SMTP id u24mr15080322edb.193.1600061305616; Sun, 13 Sep 2020 22:28:25 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:25 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:34 +0200 Message-Id: <20200914052747.124118-11-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 27/40] avcodec/avrndec: Fix memleak on error 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" X-TUID: U26xNq5TrjWM Content-Length: 1314 If ff_codec_open2_recursive() fails, the already allocated AVCodecContext leaks. Fix this by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/avrndec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c index a4b6fadfc8..c5a60acd4f 100644 --- a/libavcodec/avrndec.c +++ b/libavcodec/avrndec.c @@ -170,5 +170,5 @@ AVCodec ff_avrn_decoder = { .close = end, .decode = decode_frame, .max_lowres = 3, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Mon Sep 14 05:27:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22363 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 35A91448249 for ; Mon, 14 Sep 2020 08:35:08 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1DCC868BC3E; Mon, 14 Sep 2020 08:35:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 722F468BC23 for ; Mon, 14 Sep 2020 08:35:01 +0300 (EEST) Received: by mail-ed1-f66.google.com with SMTP id i1so16292177edv.2 for ; Sun, 13 Sep 2020 22:35:01 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=ZB6SmfBsGkDLLp58P+RzegZTFNzuJQQ8MliObjoDmqg=; b=gCEyvdexyMER1DIHMQY3uzNlOLNLbl3oxv/Q1EaTXzZ7thhN3+qiNxRXjPlMoUMu8D H8ZxrQFyEhbwIjqee6dq7EhO2gaypTMTWD6QnXHEc/wF7hwAzpHkiNbIX67VSFKL9ZNM 9u08sC+5VFlpyqhCSpRhmRcEyqGjQ4W9XmrIBB11+l8Gf2StUmQhcox1Lz27AAA6pc4w jSFEXA1eiBEqlJO3m3XbpyeUt/+TCjkHfLG+RtT3i+AMoSTfmXmBUu+oEPR+F+mHrhVL Oz+D173l0GANAPT3eFnOrDJzos9uS5ml//jmsjX6DPcWTJvVsx1kvGluHO+BZ6+IVuL2 fP5g== 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:mime-version:content-transfer-encoding; bh=ZB6SmfBsGkDLLp58P+RzegZTFNzuJQQ8MliObjoDmqg=; b=l6+1v5Xhx0hADwzLoYoWdUidlRpzzKfpH23g7YbOPWs84EN/bZlUOMdsa1SNNoYdF6 IvSwjd5LcoQq02izFf5Pl7ajfan30cOXlE15EDtJCh5DTTkoyfyXtQYvb8EF6mq7EiBI aqBeqNs/jtFWlNr4VezhdWKKImIEz+Wp55XD1Md9hgTgPdShDi/e7zXbZ/FecUDyawWY 7z67odpIXfw5Az33pin+S3CtEEDRHRxcTAsOl39TzHVQn3QV/AeZRZHPqE5evYOo1LmK lEbaoprcDnJmTLhnXXybaXdU9stzJ3wfZ6WzjjMo/EGEODOt52XrygNozWJaHR0QVCR4 TZzg== X-Gm-Message-State: AOAM531gbRq04KHwRso0Yfr3a1Sjf5JVo88R8ANFLGFbNXF+Vizve6o8 lwb+sYfFYnemVHbtiMgkAPah/klBoxU= X-Google-Smtp-Source: ABdhPJxFvuf4ZKvNgoIenkgQ6+3jKGkLvo7bgHdHO2o/1h83ZoPIBX/tV9L/kP6dwRN5P4bwWNYxkQ== X-Received: by 2002:a50:b046:: with SMTP id i64mr16150306edd.9.1600061306652; Sun, 13 Sep 2020 22:28:26 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:26 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:35 +0200 Message-Id: <20200914052747.124118-12-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 28/40] avcodec/c93: Cleanup generically after 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/c93.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/c93.c b/libavcodec/c93.c index e1808150b8..7e3bfdbc72 100644 --- a/libavcodec/c93.c +++ b/libavcodec/c93.c @@ -63,10 +63,8 @@ static av_cold int decode_init(AVCodecContext *avctx) s->pictures[0] = av_frame_alloc(); s->pictures[1] = av_frame_alloc(); - if (!s->pictures[0] || !s->pictures[1]) { - decode_end(avctx); + if (!s->pictures[0] || !s->pictures[1]) return AVERROR(ENOMEM); - } return 0; } @@ -269,5 +267,5 @@ AVCodec ff_c93_decoder = { .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Mon Sep 14 05:27:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22359 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 917A64480DE for ; Mon, 14 Sep 2020 08:34:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7613C68BC23; Mon, 14 Sep 2020 08:34:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3820768BBE2 for ; Mon, 14 Sep 2020 08:34:14 +0300 (EEST) Received: by mail-ed1-f68.google.com with SMTP id l17so16228226edq.12 for ; Sun, 13 Sep 2020 22:34:14 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=G8Om6i1X+A8kH6AKlsAIveWTTVBv2lRzPls451rBBU0=; b=fuHwuUNJYzzDO36ham4HB+xWawdZbJsiWsoT8k97bnfVFgKavHwU0g/WBqgSA1aGch +MrHS2WwkxJ/CaNw/5oZ+IT9jmMwZEooFIyJH8TrDsqsRkGpFUev7t+2OhKDF/2GaJAF GdAU9GUD+XusTgfs3V9d73729RdSvObK7unx1rr1cDWhoigsMqwCAMnO6si6+Dc0AvKs obPqyFGpmYKq5e/G2cZ3X26Q6bEiCWAvvIlQMHRQdkVRHmosEgwapSf3RmKVF0LHdjCJ lLUW+lHeTYkGP1zs57fRjMfaR19jcY/DaV2JjZ4TFTr5nqRwjsp5KlqWB12Oj1lm1fAV OMVQ== 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:mime-version:content-transfer-encoding; bh=G8Om6i1X+A8kH6AKlsAIveWTTVBv2lRzPls451rBBU0=; b=hhQhNOHNHLlkxIFZiijRCOpG553Le5lPfFoQ07O7JBemCGp2ItzxSsKh5tqs5gMgzj H9NYIdr+0s1B0qXjzecveDK3doVscpiUTP0EWDY+v3SqVNob5z1cYGR6RwIZj0GFrq60 i+tfqfwhrPVzeUt4TtxzFymsavLRlm1APGqNhVQamE78k5BZhSbu/4cBSyE9Wy0uyUFc tXYSHTn99OP+A8IneIXDGlUHlArmJf+7Qf42Fr1E4sFdbdMjnL5eMVxDBLY0cFt10ztK cBQi6UtV9fnV++JU0XCsXuXJwTeaksdXuL/5TM4hRHlo1GVlbOydnUPS62mec6MjE8Es KVqg== X-Gm-Message-State: AOAM532NtnUlIRzOS38jGr79r1xQZNiaRt43V6UGNZnQN3F9kP8SIOQf v4vxgdgcczFLH/1ntScW/+lksDMBxFU= X-Google-Smtp-Source: ABdhPJwvGagORW2DdRqwx8ATxHdWV6z0fKd6+xYVu/yYBQqmta31XtzNqwdNPTkboAJDmhFWTPHduA== X-Received: by 2002:a17:906:f6c6:: with SMTP id jo6mr12828238ejb.251.1600061307617; Sun, 13 Sep 2020 22:28:27 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:27 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:36 +0200 Message-Id: <20200914052747.124118-13-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 29/40] avcodec/cfhdenc: Fix leaks on allocation errors 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" The CineForm HD encoder attempts to allocate several buffers in its init function; yet if only some of these allocations succeed, the successfully allocated buffers leak. This is fixed by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/cfhdenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c index 776b6da235..5554baefa3 100644 --- a/libavcodec/cfhdenc.c +++ b/libavcodec/cfhdenc.c @@ -919,4 +919,5 @@ AVCodec ff_cfhd_encoder = { AV_PIX_FMT_GBRAP12, AV_PIX_FMT_NONE }, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Mon Sep 14 05:27:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22360 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 E46494480DE for ; Mon, 14 Sep 2020 08:34:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CB70968BC2A; Mon, 14 Sep 2020 08:34:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DEABC68BBA1 for ; Mon, 14 Sep 2020 08:34:24 +0300 (EEST) Received: by mail-lf1-f65.google.com with SMTP id z19so12013326lfr.4 for ; Sun, 13 Sep 2020 22:34:24 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=MjGHfXYiPPHfxBUwQEWGgidokQv8dXr6Lqixc7cWHAY=; b=sHEN8gdgU2GdWNB7FGy9yFQ0Il8B/0Kbs6q3NlEkt4xF34XMUarbLny6YYEKrXn07H UU3h7CL1DbGDc8MYUSSCDsl51nfucyTBe+5naRj0CYhWmW52tn5HVYNwQUAqLZYAboh9 5YdGSRxyyatNfY01TeXN3IEJItUXY9ZxX/civFcONcjk+7xaH65ksCINbud3pXa8Pfal 224hj9KIPszil7/LhLl8B5/dovFtLhdU7tqccg/GYMV0JcM+i4FdZb3PCbwF5cwcuIzX x5arXc5nT04rMUNyfyn3/cx4b1+VN8XKQacN8aTOsUXt70MMbMkaMvEyr2AVMB4UQHi3 HVkg== 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:mime-version:content-transfer-encoding; bh=MjGHfXYiPPHfxBUwQEWGgidokQv8dXr6Lqixc7cWHAY=; b=GoMvYyxo4jlZwLD6sZGDJXYGVTforCw1LjN1aumJGmkTz1ms6HZLGAsCjUT9FcYg8w QUx1C2JvjrvcfZUidZytmaEfaxmhGLyv91RfobpNafsdHzPwv7xUBmK2COSSITY1ZwaU NYOj7jLTOlhWaEQmzY0YtVEP+hbYQ/Zevnzsct5gJqOINUg413E1lVSbwnP2igYKl+oY +CdyZgVaja9V4CpR30lGmkPb4fIqX3L6V6N1D/mY2lM63qnluYDNJtoumsCLSNYnOiAp l/TdFTAw9gTBtA0lAR8dAvmzK6onzuO1kwZw5XSCnYYC3G8ltpQxaeTVa2yrazvvV90w KX2Q== X-Gm-Message-State: AOAM531UE3K+j1y0WBYo+nbXoZKXtp+IM1QUpihGkaFTsSu1B8mWkwif fhO+x0lqNMeIheCgB7QW7nvWXfXCCvA= X-Google-Smtp-Source: ABdhPJzMXF89AXFejYGo7tTt6nXSqG/cRzJmMbtrs2IW2Od7b19u5GpPsDcrpG0Cu5AR3aubQ5pdiw== X-Received: by 2002:a17:906:b74a:: with SMTP id fx10mr12707431ejb.232.1600061308619; Sun, 13 Sep 2020 22:28:28 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:28 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:37 +0200 Message-Id: <20200914052747.124118-14-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 30/40] avcodec/cngenc: Replace av_free() by av_freep() in close function 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" This avoids leaving pointers to already freed memory in memory. Signed-off-by: Andreas Rheinhardt --- libavcodec/cngenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c index e185c4a40a..8f23b7555a 100644 --- a/libavcodec/cngenc.c +++ b/libavcodec/cngenc.c @@ -37,8 +37,8 @@ static av_cold int cng_encode_close(AVCodecContext *avctx) { CNGContext *p = avctx->priv_data; ff_lpc_end(&p->lpc); - av_free(p->samples32); - av_free(p->ref_coef); + av_freep(&p->samples32); + av_freep(&p->ref_coef); return 0; } From patchwork Mon Sep 14 05:27:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22367 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 7F348448249 for ; Mon, 14 Sep 2020 08:36:00 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6C8526880F3; Mon, 14 Sep 2020 08:36:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A520468BC3E for ; Mon, 14 Sep 2020 08:35:58 +0300 (EEST) Received: by mail-lj1-f194.google.com with SMTP id y4so17468514ljk.8 for ; Sun, 13 Sep 2020 22:35:58 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=RWV+vA1uEM3C3zSgga3nFLvw11soWnJ3UWjcKEuz0pQ=; b=pZsJvIlRqayeOkyhwhmk8KKcDDlNrP4+IdAFZex5fxvnOzA+nIZ7hXBlMrV1xNm0yk pxbT0kd6llzEe9/dAT4oFaax+ehomBASOQ6epCwtZAoU9TaN3mSzGNbQzNAm3P79UfQn MkUwvLVf9Eju2hqD59qd0wvcCkPoeMS7kU1AuUxPs7wFJz/ic/NsplfJKl+yVNCmN0yG LqjIAdV7taoRJPDd6DJAmYfgWBfsLqJqZwjRDZjLiFADwHl0CksHGiPvTZ1OhT2dk5jH ICSylOos7FxV07KzyIBuNLAlWEVbtfs43TxTrUVyzrnkFszOC6f20jJg1NiW+svAe5nE w8SQ== 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:mime-version:content-transfer-encoding; bh=RWV+vA1uEM3C3zSgga3nFLvw11soWnJ3UWjcKEuz0pQ=; b=HFvY5Lz1vLxslQuCrDyapaMumc7hQ/3+pphos2DWz1YOl2clqkQXOTy/z0/JIwD5av aTSCdQyXheNI37rdYhHq6oeMxS1HekZKP9dbrKNPDfsUzyK3T3Ehmyy2wCswq1eRcNUi tP9yuMtu1ApemkvnQpuxsbXNdrFIwuBNSPn6/Cg5x9N9Vn8SkbAX5ZnNARoQb4qiULTl 97yjPMzOzOoE50eyO10qEfdhw1pJmg+4zlSIo9c0z4Y/Djy4NsbEV5tvXqySAIpRHaKF bslGoXwQBwOggJ3x7Mti0o50pbsBNvzmd3KD//alGJgp3U3mLAQ8xIxpwG1L3diyjqT9 eqIw== X-Gm-Message-State: AOAM5336hMr0cM6ygFcT/EOfFedo5O7fi7wTYKKWZHHrFClFs1sUIjjz t7lhd23KMXIEzs29PHpas/RWwjPx/jA= X-Google-Smtp-Source: ABdhPJzGbWO+79Xkln4SWmdcuSoaEEQ5kxZ5e7SB/b/9ltIUlzfz6DxgTpAPhnMYGCmO1Y0UDBj3XQ== X-Received: by 2002:a05:6402:176c:: with SMTP id da12mr15795793edb.386.1600061309550; Sun, 13 Sep 2020 22:28:29 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:29 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:38 +0200 Message-Id: <20200914052747.124118-15-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 31/40] avcodec/cngenc: Cleanup generically after 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/cngenc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c index 8f23b7555a..b622d7bbda 100644 --- a/libavcodec/cngenc.c +++ b/libavcodec/cngenc.c @@ -58,10 +58,8 @@ static av_cold int cng_encode_init(AVCodecContext *avctx) return ret; p->samples32 = av_malloc_array(avctx->frame_size, sizeof(*p->samples32)); p->ref_coef = av_malloc_array(p->order, sizeof(*p->ref_coef)); - if (!p->samples32 || !p->ref_coef) { - cng_encode_close(avctx); + if (!p->samples32 || !p->ref_coef) return AVERROR(ENOMEM); - } return 0; } @@ -113,4 +111,5 @@ AVCodec ff_comfortnoise_encoder = { .close = cng_encode_close, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Mon Sep 14 05:27:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22349 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 EB0D544A49B for ; Mon, 14 Sep 2020 08:28:32 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D1C2368BB38; Mon, 14 Sep 2020 08:28:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 802BC68B86B for ; Mon, 14 Sep 2020 08:28:31 +0300 (EEST) Received: by mail-ed1-f53.google.com with SMTP id l17so16218569edq.12 for ; Sun, 13 Sep 2020 22:28:31 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=mMRElwryGgfGut3MHcGtEYxHzkgKCod+vrmXT76f1t4=; b=sj5G1z1smJRvEgzUGguMgk3FB0bUSXXMtDucHPHM7LFk9mVDpSClABMCszM0/vWNMv 2/oiurF9GkpEJg4RzeRCb34N0ZZObFLIwX9g8PHGl0rKmXdvGPQbo0TlAKdHtIeLgdpw mAJULN1lV4m8zeFBJZCtiKrcBRKsqlNR4tnFMK1VP5z7E1/nvslO8svii/3fvo7+lM1G 420F1CnDxNucRUmndb+LN5OCRtlkac5KDximwcWw16XsOctkuO0d1dJJX6muCqQIBEkw tvoGPzq6XSv/elN3U426MQJtjxzdiT3gVFVgKYzpNza7uIDPWTrzYDOhaN7K3tnf5pat eFnw== 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:mime-version:content-transfer-encoding; bh=mMRElwryGgfGut3MHcGtEYxHzkgKCod+vrmXT76f1t4=; b=Z+c6ekBNN/vs2BFhcHHwY3BLubozgVoiC1+gI1u1ME1w0Wz7GgkKZZlecRxG6uyBLn x/GpFYk6TCyZVoCtrMRq05svDCDoeMSy4MZfHLnW4TZvlnsER6SmKKrY3JobGryn1I+W xMREJdVOvaEJJbAlS8YnPCVtn+ftZYTKPGV59rTrh1z08Z6Ir3KwARYUaeCkl9XCVVRn eeNG7E/0ZiHJk46ehawTwj1pnfOJjjY63dblN/Scrr2v6nvxLs8PtLJO8V/MlZWYw3Yr WxzvDJlZPevD+WYHZkJsOiCamW4XPIEmve4X7zZO6N0poKJJibDzx8avJ2iHKMZbezU0 G03A== X-Gm-Message-State: AOAM532kyTtduKkBbKnjFqVSnpk7lv65FgPwHDrIpjlLYn/4Ktj+fKnU hA0YwvyKx6QpUN+Xevw5uzIIgSxf1QE= X-Google-Smtp-Source: ABdhPJxLf8p07XV3g708RNWcIdowqlwwHwykI2u8J69+iWcYhXKABZopFoD0w3sj5aRjpJgjooRKoQ== X-Received: by 2002:a50:c182:: with SMTP id m2mr15108382edf.70.1600061310479; Sun, 13 Sep 2020 22:28:30 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:30 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:39 +0200 Message-Id: <20200914052747.124118-16-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 32/40] avcodec/dsicinvideo: Remove redundant code for freeing 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" The dsicinvideo decoder already has the FF_CODEC_CAP_INIT_CLEANUP flag set, so it is unnecessary to directly clean up some already allocated buffers in case another one could not be allocated in the init function, as all buffers will be freed anyway later in the decoder's close function. Signed-off-by: Andreas Rheinhardt --- libavcodec/dsicinvideo.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/dsicinvideo.c b/libavcodec/dsicinvideo.c index 7f74808e6d..52f660fb51 100644 --- a/libavcodec/dsicinvideo.c +++ b/libavcodec/dsicinvideo.c @@ -58,7 +58,6 @@ static av_cold int allocate_buffers(CinVideoContext *cin) cin->bitmap_table[i] = av_mallocz(cin->bitmap_size); if (!cin->bitmap_table[i]) { av_log(cin->avctx, AV_LOG_ERROR, "Can't allocate bitmap buffers.\n"); - destroy_buffers(cin); return AVERROR(ENOMEM); } } From patchwork Mon Sep 14 05:27:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22364 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 41425448249 for ; Mon, 14 Sep 2020 08:35:10 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 24FF168BC41; Mon, 14 Sep 2020 08:35:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4E97268BC40 for ; Mon, 14 Sep 2020 08:35:03 +0300 (EEST) Received: by mail-lf1-f65.google.com with SMTP id z17so11969513lfi.12 for ; Sun, 13 Sep 2020 22:35:03 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=TZ+nImZuWX5ZzkK5rY3Q+TyykOO3dUZe3Q4gXO/g8oc=; b=B5oGUKl4XBAnaiCKG4U2kVviD5bLmsiYWejXxN3N0ZWrNIA0dIpXpBwbBVVgdeU7R7 SvzAapjN1H/8kNMtWx2MvE3qXPjDOOVFRAITwKCrRWHIZ5Wd1OsVdoC+P0z1Vuo1LYht GiX6dk5MOAKeY7NQ75EtTTgvHLzkdUKfUTqY68MnO+3yle0xG8oTmTf744N9A9AZfghQ Y7zmzMm7LOv/tjYvIv2N3f2CAHTAuxtrEpSDpSbaH0pvFQtiaNjkovYy3QJlREGMjTqA kDiIZvT7nOHXQdRMNEj6lLNh6cYgULNC/2VpLvSVt4oKh10g5OACU42plcrc/K7l42nh 4c6w== 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:mime-version:content-transfer-encoding; bh=TZ+nImZuWX5ZzkK5rY3Q+TyykOO3dUZe3Q4gXO/g8oc=; b=uA2D/+cA7/eEXGGg99jwEXZFiQf5kP5BXaAMCLh0s94vb3P54ikkNAgj3LU5W/ZVFn ClLa3YXkcOFuWQvexQo7NDgW6eEp2LMpMsB0HAcmsUwg071ycUl9pEDfD3qzh0Txkt4V X8UDbIhdq2cxiHjt8B+NUfAbaGPoGbdxZ1/gHsPfPDYyQ9e88DskDn49TyB4sbtSOT2m tRMWJtklNU7Pxy/9T8/HGjbdl6RLt2dIxoGRKcwsUrorItDUh2PYIEb7cKiC5D3ufxsB IqVFzIlDaM7E9zoI5mDXjzsfAGQ6V18/IDDz/MWELE7pU8xGfujdAjSeO8zoURUjpCx0 xwAA== X-Gm-Message-State: AOAM532Osdg4J4WQc3nlulSHNzyiepPrMn4AwQStFKJnPNXuwvk6SveF ++fCK7ImZyJSOLj6fY6aGvRAigZvsTk= X-Google-Smtp-Source: ABdhPJyEnkuW4f+VAnvCxJZe6qbW8bddafSTBVquJuHZGtJViwC9dcIynj9F6aGjzPmdiZflHvZZSg== X-Received: by 2002:aa7:dcd9:: with SMTP id w25mr14768676edu.280.1600061311436; Sun, 13 Sep 2020 22:28:31 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:30 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:40 +0200 Message-Id: <20200914052747.124118-17-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 33/40] avcodec/dxa: Cleanup generically after 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/dxa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dxa.c b/libavcodec/dxa.c index f6edc03e1a..3f62eac252 100644 --- a/libavcodec/dxa.c +++ b/libavcodec/dxa.c @@ -343,7 +343,6 @@ static av_cold int decode_init(AVCodecContext *avctx) c->dsize = avctx->width * avctx->height * 2; c->decomp_buf = av_malloc(c->dsize + DECOMP_BUF_PADDING); if (!c->decomp_buf) { - av_frame_free(&c->prev); av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); return AVERROR(ENOMEM); } @@ -371,4 +370,5 @@ AVCodec ff_dxa_decoder = { .close = decode_end, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Mon Sep 14 05:27:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22350 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 EA5B544A49B for ; Mon, 14 Sep 2020 08:28:34 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CCC4468BB44; Mon, 14 Sep 2020 08:28:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 05F4368BB3C for ; Mon, 14 Sep 2020 08:28:33 +0300 (EEST) Received: by mail-ej1-f65.google.com with SMTP id r7so21299247ejs.11 for ; Sun, 13 Sep 2020 22:28:33 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=uDDqtU6/fp1VlPqN/iXmZplB5Q5heO6Tpx5WNkDvs2o=; b=AGMPsIf1egRFa++lJj0gfjPgGKSmu1n73m41KRNAL4O4kJO7eDcGPglmcW1cpSSCvo y+SlbQfYuIH2WE03NzaZg8ZOQFoguf8H3fJYO8Fadabd445eVFp3UU+MdZq4Pz2xTldD uJHKXGKkx6utYjbbTRqSibIVZc5DTqZcGrmb4GCbfcyiXy67fby8miEuBxR1HeW9wQF2 DCbM6xw4SohK1GzAJ17UddjZxmUglqeW1UcM3dLNyhW4cq27Zx/HFMZarj5A7Uh9qAIr l0Iz5sfELf9JE7zsjhlgRJ7pqR61RtWii5asTMlYtE/UkxtwuW+hEJwEQQ5JSDx3dTE1 8o6g== 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:mime-version:content-transfer-encoding; bh=uDDqtU6/fp1VlPqN/iXmZplB5Q5heO6Tpx5WNkDvs2o=; b=Rfp3qpHyEiFYRItT3NH/vwPCHc7PisV3aG7dChV0Dx5Y3ZuXM8xc7dMD2GhDIHUMjC /35Q/CnqDpq916Egl8DVlhn5uGf3QQci7dbKbaAFv6Bxxhl64YkG0JtwdSF9APosFQrB fMIKOi6dzkdOF4idZFLKT2EvrrqlrCD+97h2Qnyk0rOJa4rWlWVxWeD+P6LeuoHUWHm+ tn3xmlOFnZa9LtjRR8228N0mSl0gY4g2J2JaLXWJ28Al0bVmtGu58ZR5EJ6buibAJPhj wFAYDYh0rha5rVfTlfbuepwdrtn0rYIZrQQEEEbdPIkGMQtbW8otMMBb/PD/flKUb3qD J7vw== X-Gm-Message-State: AOAM530Tqs9jssDdaCkKMNScg3mvM1JVvZ8FcUopohfQUK+ZaHit+fMT 5YE4ugtnb9uAcXj4avDpd83UmPFSzGo= X-Google-Smtp-Source: ABdhPJxttpeECiZfAk9qO7DJPOyfbOSvIbfcgmalwxYvk3nzl+laFpM4xOCCCVFlL4GCQ5IlpxWPfQ== X-Received: by 2002:a17:906:4d4d:: with SMTP id b13mr12541621ejv.221.1600061312423; Sun, 13 Sep 2020 22:28:32 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:31 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:41 +0200 Message-Id: <20200914052747.124118-18-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 34/40] avcodec/ac3enc_template: Don't free uninitialized pointers on error 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" The ac3 encoders (fixed- and floating-point AC-3 as well as the EAC-3 encoder) all allocate an array whose elements are pointers to other buffers. The array is not zeroed initially so that if an allocation of one of the subbuffers fails, the other pointers are uninitialized. This causes problems when cleaning, so zero the array initially. (Only the fixed-point AC-3 encoder was affected by this, because the other two don't clean up at all in case of errors during init.) Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index 985b35e5b6..b85fe51ef5 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -42,7 +42,7 @@ int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s) int ch; if (!FF_ALLOC_TYPED_ARRAY(s->windowed_samples, AC3_WINDOW_SIZE) || - !FF_ALLOC_TYPED_ARRAY(s->planar_samples, s->channels)) + !FF_ALLOCZ_TYPED_ARRAY(s->planar_samples, s->channels)) return AVERROR(ENOMEM); for (ch = 0; ch < s->channels; ch++) { From patchwork Mon Sep 14 05:27:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22351 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 EFD0644A49B for ; Mon, 14 Sep 2020 08:28:35 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DC8DC68BB86; Mon, 14 Sep 2020 08:28:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4467168BB3C for ; Mon, 14 Sep 2020 08:28:34 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id nw23so21342953ejb.4 for ; Sun, 13 Sep 2020 22:28:34 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=aIllyBENsrhJshvS8U58hxXArL4ic58OHkSmTC8dgO4=; b=SyaW32/xxX+HsHT8LEkBa0Ql4vP0BkN1S74fKraKaLMe0S6qB9mjtlmtkrNdnl2YOG /4uoeqwD64Xb0pNEsnt2tNx8UstT27fmxsduBcY+0Qm/IEuVuxIEQT/cyKRlO7vLAuRZ eOgEG4R0xZZxyk8ZHeShi8dGZ0mhjNcZ2kCxsn76dopsI91QyZy1GUqz2KjSKOu07Slg nGckV++KWx4oQvCJCE5964cZaff+ZcSSOMIbqDq1rUurYiTPIb/QX/8lzkn9muZss4g9 9lgACQr3+2af+HLKoVEWy78/mXbTjpOEFRVZ6AhdB3YQob3b4Gk+shVJZmz+gC7rM7B5 D+2Q== 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:mime-version:content-transfer-encoding; bh=aIllyBENsrhJshvS8U58hxXArL4ic58OHkSmTC8dgO4=; b=MU5v4DbJApv+k9Sqps2bWUCrBdf6TE6zcFqKgCRopsuB9WlgFGt1j4r3Lrf//sVFIQ 874+Ho8oLK02oasnSh3lfEW+bT/IZq1FkW4yBr9nHR780xRSKj7VKhWkXl0TJtKx3+my oabE4snjcLrVa73CcT/hhlob2GPsc8ruSHWTmclPwkDYS/hZIOc6mOUj1kLsx/6wuc4D ImD3+PGCArUrY3DXCJrQehro02MZ89ZFyJNAi8aaYaH2Wegq4vSl4VOkyGyh8zG+MQn/ C+5geDcMrPX1akADESDFaE+wsv3jOZQsJAaGvwSuILC7oT8/i2XLrRTN2eFFF2119v+e qDVA== X-Gm-Message-State: AOAM530ivB9IVKchk9eRa4rqeb0GrO2QtxKM/K9lM50V4yya3Wy8SXVs GtTLEq19CSrPLJVTm2yka9FFWZ88pjg= X-Google-Smtp-Source: ABdhPJyUqBEkvUZQ/MwNWkvG1Ss8ij1b7qF3V1j1JAyryjqDBPT3nnPj4dpDypTeLG8hmqnbCuejmg== X-Received: by 2002:a17:906:4c89:: with SMTP id q9mr13526447eju.290.1600061313488; Sun, 13 Sep 2020 22:28:33 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:32 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:42 +0200 Message-Id: <20200914052747.124118-19-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 35/40] avcodec/ac3enc_float, eac3enc: Fix leaks on init error 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" The AC-3 encoders (both floating- as well as fixed-point) as well as the EAC-3 encoder share code: All use ff_ac3_encode_init() as well as ff_ac3_encode_close(). Until ee726e777b851cdd4e28cdab36b38f0c39e35ea9 ff_ac3_encode_init() called ff_ac3_encode_close() to clean up on error. Said commit removed this and instead set the FF_CODEC_CAP_INIT_CLEANUP flag; but it did the latter only for the fixed-point AC-3 encoder and not for the other two users of ff_ac3_encode_init(). This caused any already allocated buffer to leak upon a subsequent error for the two other encoders. This commit fixes this by adding the FF_CODEC_CAP_INIT_CLEANUP flag to the other two encoders using ff_ac3_encode_init(). Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc_float.c | 1 + libavcodec/eac3enc.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 1f3111af0e..99863a9722 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -153,4 +153,5 @@ AVCodec ff_ac3_encoder = { .supported_samplerates = ff_ac3_sample_rate_tab, .channel_layouts = ff_ac3_channel_layouts, .defaults = ac3_defaults, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 6a90571e56..8e1032f268 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -266,4 +266,5 @@ AVCodec ff_eac3_encoder = { .supported_samplerates = ff_ac3_sample_rate_tab, .channel_layouts = ff_ac3_channel_layouts, .defaults = ac3_defaults, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Mon Sep 14 05:27:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22352 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 048AA44A49B for ; Mon, 14 Sep 2020 08:28:38 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DEA9768BB39; Mon, 14 Sep 2020 08:28:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6158168BB3D for ; Mon, 14 Sep 2020 08:28:35 +0300 (EEST) Received: by mail-ej1-f68.google.com with SMTP id z22so21322693ejl.7 for ; Sun, 13 Sep 2020 22:28:35 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=fOQA8dYGFzWNSbeU/ZKnLzZA3t5DaEY7PF07zCH7DO0=; b=Wuv9QV41042ERbgNJ06PRVHZOWPfLwF5wRRNw39CRy5M28peypzSwaH+4T5JSrjOUA V8fXcr0dDiu8ZEZ7iEnPkdCMYVTGpTlMbklZK3hsazlpK7LbCEhWrGEn69oDf503BPbk rJPh+TNI0oUm4k64WMV74LuvmjyAZl9RFkrClK28dvrVXyMSPhIzUHiu/ppD/itZCYS+ XNJWLTHa070Osn5XhA53hTg1zrjpML4xckssf1QSs9dPT8r/n/c83wjKWIABB1rYLU8J zRvPWgDKOutMw38Bp483pQBm1RWca9PeXhlgPsBugb5eqs9eEciJ9SylrgAGMNPJC17H oNFQ== 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:mime-version:content-transfer-encoding; bh=fOQA8dYGFzWNSbeU/ZKnLzZA3t5DaEY7PF07zCH7DO0=; b=o8RoOcdc4khu6rS+iIjPRyZgW9mESQmAgda1EhzjfBmxBNcBs3rtpvAPYrhimtKwFX b9Mdfej55aAucIqkSWwvGhi8xyBnVMU9LrssoYv/BBcMaPbv/QE5i9AWxd1B4eKmNNiI /wH3sjwUin+3Fw3eGqMlH9Od/vUgY5louN9+kgyBvgpLi8hffazndNBAviT2gfFiI/ZT OdLJY/TVYo5CCVb+GlyXNFFgdiJHiO3lNdjwgMMkawu/ltRmXKiqDRckYzidKRypsb4R /JuvnpUoFlfae2mqNhvEUyXFfZTBtJDSx+CegfAAvzYoS2AZKGUFhjXolrcw1cxL1LLz lCrQ== X-Gm-Message-State: AOAM533fOcu1veGlc9aAduqhFN7ASCH8IoDxcwF+HUeYs+5Tk4ZsmE6q rua85UgaPClz4VwPfrA772cQ+QYOTKQ= X-Google-Smtp-Source: ABdhPJzbTgYskuBpVs+fCBXWMQrAU7YPtLz+26oy2XxEyf4ywGA3/qBnB/lHEBVWZIBE7HBpKW89Jg== X-Received: by 2002:a17:906:a00c:: with SMTP id p12mr12632864ejy.10.1600061314452; Sun, 13 Sep 2020 22:28:34 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:34 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:43 +0200 Message-Id: <20200914052747.124118-20-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 36/40] avcodec/escape130: Cleanup generically on 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/escape130.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/escape130.c b/libavcodec/escape130.c index 1dd7eedd74..a6fda901de 100644 --- a/libavcodec/escape130.c +++ b/libavcodec/escape130.c @@ -128,9 +128,6 @@ static av_cold int escape130_decode_init(AVCodecContext *avctx) s->buf1 = av_malloc(avctx->width * avctx->height * 3 / 2); s->buf2 = av_malloc(avctx->width * avctx->height * 3 / 2); if (!s->old_y_avg || !s->buf1 || !s->buf2) { - av_freep(&s->old_y_avg); - av_freep(&s->buf1); - av_freep(&s->buf2); av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n"); return AVERROR(ENOMEM); } @@ -358,4 +355,5 @@ AVCodec ff_escape130_decoder = { .close = escape130_decode_close, .decode = escape130_decode_frame, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Mon Sep 14 05:27:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22353 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 C8BE844A49B for ; Mon, 14 Sep 2020 08:28:38 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B2C6568BBA5; Mon, 14 Sep 2020 08:28:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4429968BB5C for ; Mon, 14 Sep 2020 08:28:36 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id u21so21353445eja.2 for ; Sun, 13 Sep 2020 22:28:36 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=S49wdk4xDHZDrQDCFDSxNVKbun9RXf0ASgKW6zdiRYU=; b=VA8p4/IkNVFdLWtRdHxMy+ncr7ewSwAgb+UOKefaYrryPuXrJp5znK81uEipMUFsGn OxG9bzECFwULK8iSEoojGoGSynye8/jTrKGxzTH7UrWs2zYDUBgIgQgf71oE56fgGtct 8B5z3US1tR6L8ojnZNLXhq0ZJwbX2YskkO0Mexp52ccVL3F4NRBtyYFfaebu522wZ2uQ GJWBkCSucRephqTXl/q9ShcoRPBX9IBRIKkxDueLIVFcpgyF0ZiK95gNoQt2ArSAoiGX czsPPquB0aWBF79/bOXN6PTv7tJpBOkbT1558Oe6RfHfvMHL2e7VpByn1FvfEoku1R7A KzFw== 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:mime-version:content-transfer-encoding; bh=S49wdk4xDHZDrQDCFDSxNVKbun9RXf0ASgKW6zdiRYU=; b=kGnyDO33IqfPGShydyRgiDsSJt08k7S0EgLgmaD1O9jHqKdXDjCdocUXTlGgWNhrwc pXqPxiPEfHe90emve5DfUWPnaJgJ1u4LS49aUWAmvHYLrhN7RPZ/KznqAerE+Bnu3RsC dhK81o7ae8I03SRWaotlop3jMHMojrkvcXnwIZWAEOvNoSfbQQwCSZ6i/BFrJM1gs8FZ aM2f64mStXqFawFzvPx4706Lyk6F18YVIys5xV7k+Sms7sTQsFWK1ACvTxYhy+vF6F+4 ML63vsF9Y96E6cYozsFDKDCZiNDiMWageqFfOYIu0IvybqFX8z9/7aLbwPnV6g48OOTE DC2A== X-Gm-Message-State: AOAM533NMCu5pj8SvhvsTslDfF03oBro7V4uj0k1voxfcagt4ExGRIik hjhNzinxqbdUkxyGUPnVJkshvq7Ebe8= X-Google-Smtp-Source: ABdhPJxivaGa4HEuy3DPzzqJJloyJrQIgLxuCaWUOrQcjacdxTAe1O0gFm110i0rznLIOkF4wIp3Ag== X-Received: by 2002:a17:906:48d6:: with SMTP id d22mr13147077ejt.462.1600061315407; Sun, 13 Sep 2020 22:28:35 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:34 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:44 +0200 Message-Id: <20200914052747.124118-21-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 37/40] avcodec/ffv1: Fix segfaults on allocation error 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" When allocating FFV1 slice contexts fails, ff_ffv1_init_slice_contexts() frees everything that it has allocated, yet it does not reset the counter for the number of allocated slice contexts. This inconsistent state leads to segfaults lateron in ff_ffv1_close(), because said function presumes that the slice contexts have been allocated. Fix this by making sure that the number of slice contexts on error is consistent (namely zero). (This issue only affected the FFV1 decoder, because the encoder does not clean up after itself on init failure.) Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 93cec14244..5b52849400 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -115,12 +115,11 @@ av_cold int ff_ffv1_init_slices_state(FFV1Context *f) av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) { - int i; + int i, max_slice_count = f->num_h_slices * f->num_v_slices; - f->max_slice_count = f->num_h_slices * f->num_v_slices; - av_assert0(f->max_slice_count > 0); + av_assert0(max_slice_count > 0); - for (i = 0; i < f->max_slice_count; i++) { + for (i = 0; i < max_slice_count; i++) { int sx = i % f->num_h_slices; int sy = i / f->num_h_slices; int sxs = f->avctx->width * sx / f->num_h_slices; @@ -152,6 +151,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) goto memfail; } } + f->max_slice_count = max_slice_count; return 0; memfail: From patchwork Mon Sep 14 05:27:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22354 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 A398044A49B for ; Mon, 14 Sep 2020 08:28:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8A60968BBC2; Mon, 14 Sep 2020 08:28:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 03B5868B86B for ; Mon, 14 Sep 2020 08:28:36 +0300 (EEST) Received: by mail-ej1-f65.google.com with SMTP id q13so21314510ejo.9 for ; Sun, 13 Sep 2020 22:28:36 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=IRS5iIGeyRsc/iGJQ+LSDEKApOnxe9oJYFrJl+aVICw=; b=JuNCnJgSiXqcegqnbFfTkFBEAWnd+flBGDcjqgiT345mD896vDb5KpMdD5jRY3zA27 401e2O9zZoHusXfPKVf7IYOyeUaJlc4xCDpb8HzUidbFyfBF/q3+6h9f9wGOrqW6HJ5W cF3f/OO9j2+R3yrY7PDE1TzaafuiKwldJH8lSoV/j4WJsma1TpMhsKHasFzDfaGrv0k+ ATWSH6zJEed2Mt99bMpxhr/SXevJywWavgMfHjxmmRCfy52+EuIh8mJrDc4MSbpLdQQd QrMpTppLHZXq3r2c6vQ/UYJp1GhHOHAVt3DSn3gL2B3jePK61PyZH5SH8vqXEng/xmwL Isbg== 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:mime-version:content-transfer-encoding; bh=IRS5iIGeyRsc/iGJQ+LSDEKApOnxe9oJYFrJl+aVICw=; b=E1omOLa/P/oTjmNB7t+vni2gOvRADe3E3PDy1CcdyF02dkrLBImS/fAmIoagwYbx+o in+Joenl0a30yXJmdjvZtwFIW74kD3aW5ytTP/PeQIknKrpyARWvwAmH2VHODAKuHpqo zHaL5V1G1nSVzIFfnPXLa9VpRsr2w8I0NdqBEVjT85nDLTmNBeir9pRKutQZyv+rc1vU vK/VqlellVVYPhVoW3XNmqpcU0KZ4xAq7+b/QItdNobA1FmBzdtKgWaar2BYtncsnK29 Tylk3iS0D+2VZtngBXnyN+VnvuC9Zr4Lfp5v223C2lBp9D1tXBMaojo1VEKCfGRlE/pg u4HQ== X-Gm-Message-State: AOAM530qRIa3/zAIIRR8+VkmbbuzXVMIJK60mJ9h7ymr/IZfp+QTg84Y E93vbPT3eVFyv2Ryq2otIU3TAeAUA/I= X-Google-Smtp-Source: ABdhPJyBTug7VsdCUfRL5VCVevJYQ2pU0X3dhHbIS6IQ7JIszNLPt8jQKfSr9hUUANZ67UuoYwtnNA== X-Received: by 2002:a17:906:a4b:: with SMTP id x11mr13725654ejf.368.1600061316177; Sun, 13 Sep 2020 22:28:36 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:35 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:45 +0200 Message-Id: <20200914052747.124118-22-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 38/40] avcodec/ffv1enc: Fix memleaks on 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" The FFV1 encoder has so far not cleaned up after itself in this case; but it can be done easily by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1enc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 97dc15eac9..611b250e96 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1354,4 +1354,5 @@ AVCodec ff_ffv1_encoder = { .defaults = ffv1_defaults, #endif .priv_class = &ffv1_class, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; From patchwork Mon Sep 14 05:27: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: 22355 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 BEA3F44A49B for ; Mon, 14 Sep 2020 08:28:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A706768BBD6; Mon, 14 Sep 2020 08:28:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7A82968BBAA for ; Mon, 14 Sep 2020 08:28:38 +0300 (EEST) Received: by mail-ed1-f67.google.com with SMTP id b12so16218350edz.11 for ; Sun, 13 Sep 2020 22:28:38 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=gknPRTCP5iUhIGmTLne9pMH7Q5fP0juZ/fXjiEG+JWQ=; b=SPIwKhIRor6+qWq4GPGGUWU3fNtVdXwV+iUi+v94QyjABkRWy7zAG0A64SMUY0X+Jm eAewCHW8/xZOxMLwIvcBz2TgCPR7Tg/bWaFg0/hdkqAuH1PgQZwye9xQ7EVPNojvqGJR OWoumuMeTTwpXl1B+0r8Fwgu3JXoy5TWUhtqp0hRGRLA3aSLvqFy+3nWTFE4NodMNwju AspeqjIZfIwpmiTxc5MCSLU9oE2U0DO+rfsKfkLz+L++ielqu4bQ6cAfxe4K3QFactGL VwuSJ6Tpdd1PBo2HK6TxXF8AjUoXjKqXotuM00eKyxkRp49H3gS0k6+tORt2WXnxQa5y Ca4w== 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:mime-version:content-transfer-encoding; bh=gknPRTCP5iUhIGmTLne9pMH7Q5fP0juZ/fXjiEG+JWQ=; b=Cu9Lc+8H9dRoq/Leb1rZNtwstkvmuBKTNbQI1pyOaXEPmjpEBNJKGVQYRHcu7MQ3gk BlpuJxnqKv2IvNtlZovV+0CWn0eYhvA9XqUCQzBqcDkVW2LXBE7f5jxyRfBbgkfOReFw TWgSEX2jL1oCarhDK8acg6PFspb+MrZd1O0v5z4Y50cWIyh4vXu9cGYiH5HcIIiQ00gF f7Obz6S9tFGFFvE3lGZdAxgs/2Brh0MVJ2c/+aZCeUcgwOL6vrdlj9XpgMtw6GOVrHX+ iFaWsrrMiZ1HJNgforQZLSvZiar/8etCNgLirnJF2I/mtBHKwnPrImEC7RbZI9qyT0mQ Tntg== X-Gm-Message-State: AOAM531daNqI5HbGffREZJfcCxoL3VJw8MJtrYbVciRoWzTiNlsqyyjR aZEftrxlfoy65dW5ZYISDN/7X7Q5gjI= X-Google-Smtp-Source: ABdhPJylJBU0ZfF7xqNUoxV3AabM2kPq4WDVqO2Pfb8bLDYdjW3kEfm8yWze264BABUtmmFf9aEgBQ== X-Received: by 2002:aa7:cb05:: with SMTP id s5mr15264835edt.212.1600061317681; Sun, 13 Sep 2020 22:28:37 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:36 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:46 +0200 Message-Id: <20200914052747.124118-23-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 39/40] avcodec/ffv1: Simplify cleanup after allocation 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" Now that ff_ffv1_close() for both the FFV1 encoder and decoder, the code contained therein can be used to free the partially allocated slice contexts if allocating the slice contexts failed. One just has to set the correct number of slice contexts on error. This allows to remove the code for freeing partially allocated slice contexts in ff_ffv1_init_slice_contexts(). Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 5b52849400..1c580c3b49 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -119,7 +119,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) av_assert0(max_slice_count > 0); - for (i = 0; i < max_slice_count; i++) { + for (i = 0; i < max_slice_count;) { int sx = i % f->num_h_slices; int sy = i / f->num_h_slices; int sxs = f->avctx->width * sx / f->num_h_slices; @@ -131,7 +131,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) if (!fs) goto memfail; - f->slice_context[i] = fs; + f->slice_context[i++] = fs; memcpy(fs, f, sizeof(*fs)); memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2)); @@ -144,22 +144,14 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) sizeof(*fs->sample_buffer)); fs->sample_buffer32 = av_malloc_array((fs->width + 6), 3 * MAX_PLANES * sizeof(*fs->sample_buffer32)); - if (!fs->sample_buffer || !fs->sample_buffer32) { - av_freep(&fs->sample_buffer); - av_freep(&fs->sample_buffer32); - av_freep(&f->slice_context[i]); + if (!fs->sample_buffer || !fs->sample_buffer32) goto memfail; - } } f->max_slice_count = max_slice_count; return 0; memfail: - while(--i >= 0) { - av_freep(&f->slice_context[i]->sample_buffer); - av_freep(&f->slice_context[i]->sample_buffer32); - av_freep(&f->slice_context[i]); - } + f->max_slice_count = i; return AVERROR(ENOMEM); } From patchwork Mon Sep 14 05:27:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22356 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 9322B44A49B for ; Mon, 14 Sep 2020 08:28:42 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7E30568BBE2; Mon, 14 Sep 2020 08:28:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6F6A968BBA9 for ; Mon, 14 Sep 2020 08:28:39 +0300 (EEST) Received: by mail-ed1-f68.google.com with SMTP id l17so16218792edq.12 for ; Sun, 13 Sep 2020 22:28:39 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=+J7CQ2Z8dkrsnPdv1V/d0PhJbFGwc0k3Sn6PSOdKhaM=; b=FwCoXGVEPv1v5o7KuxQUm63UAMzZ3savkGcu67i0T/+vGBIVa2YNtovQt4S7ivLZJM U+N9pb39KS5ilmRdkS2aCy3sZRhHiOqM9dgwLCZETJq9SOuYHaV55sXSK6LvH7m5xCmk n8Sv3xjHpjXuVlsUC2/tTPMZ4HZqLbAjMjloz8GgRaqkUI0elhOizc1bUUL6FbzSbG4v ww0BVJKwNCXJ9JJaw6CtLpZs2ZOFHh8i5wg7SuXgGnfBrW2B4TvSr02NS2JjMML5MTiI InJ9GbJ+s05IPBBAJ4ugyM4+x37vVtENdJYex64d03zcBzOLMMq0ovl9z8GGD4CKoqRd WjaA== 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:mime-version:content-transfer-encoding; bh=+J7CQ2Z8dkrsnPdv1V/d0PhJbFGwc0k3Sn6PSOdKhaM=; b=Xxorrnr59JZqAEylOU09HpDfDypAi9PeEwyUydZ54RdXF3tFYIAdv/Dt0tkaoJR6Te tTU79NDc61cBkhockA37lFCVFSWwH7e/+yk4vaLbaA26cegOMmVEodcnk681U2OQI/FW RLsO4Q5bnrKofURbUNEptT06THzSGQnclOPYJHAYlCwHvNtClPcLMGCJfvF466k0qYX6 G0c/ws7Nyq+oDF1Spf9YN3tmr3Kc1t3uV6FyIvc/IVBT9Yogpquxb5wHGgktxlNN1Aj/ fmjKEvszuJYE28excOVQkiIC7vXRzYI6LHyRkiWj9z2ZZnoWC6WyQzbN/b97+RdRWHwe 9hKw== X-Gm-Message-State: AOAM5331MPCt7bENgMZ44eP5a8GzhJuUf4SyP8893iaCaIYbiPuAVpKz 3jCSxRYuOSDne8GY1vHWzujtL8j3kQQ= X-Google-Smtp-Source: ABdhPJw++deT8IboePUB4a2BTfJThpHzuTIoepOyb7r9PV30D7+ap5cHyD4NVn7dG+6itAhOHmVXsQ== X-Received: by 2002:a05:6402:3075:: with SMTP id bs21mr15669745edb.236.1600061318552; Sun, 13 Sep 2020 22:28:38 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:38 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:47 +0200 Message-Id: <20200914052747.124118-24-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 40/40] avcodec/ffwavesynth: Cleanup generically after 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/ffwavesynth.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c index d92bb38c45..c99bac90ea 100644 --- a/libavcodec/ffwavesynth.c +++ b/libavcodec/ffwavesynth.c @@ -323,13 +323,11 @@ static av_cold int wavesynth_init(AVCodecContext *avc) r = wavesynth_parse_extradata(avc); if (r < 0) { av_log(avc, AV_LOG_ERROR, "Invalid intervals definitions.\n"); - goto fail; + return r; } ws->sin = av_malloc(sizeof(*ws->sin) << SIN_BITS); - if (!ws->sin) { - r = AVERROR(ENOMEM); - goto fail; - } + if (!ws->sin) + return AVERROR(ENOMEM); for (i = 0; i < 1 << SIN_BITS; i++) ws->sin[i] = floor(32767 * sin(2 * M_PI * i / (1 << SIN_BITS))); ws->dither_state = MKTAG('D','I','T','H'); @@ -340,11 +338,6 @@ static av_cold int wavesynth_init(AVCodecContext *avc) wavesynth_seek(ws, 0); avc->sample_fmt = AV_SAMPLE_FMT_S16; return 0; - -fail: - av_freep(&ws->inter); - av_freep(&ws->sin); - return r; } static void wavesynth_synth_sample(struct wavesynth_context *ws, int64_t ts, @@ -476,4 +469,5 @@ AVCodec ff_ffwavesynth_decoder = { .close = wavesynth_close, .decode = wavesynth_decode, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, };