From patchwork Mon Mar 29 17:08:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26640 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 4C91F449256 for ; Mon, 29 Mar 2021 20:08:53 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1CB02689BDC; Mon, 29 Mar 2021 20:08:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-oln040092067016.outbound.protection.outlook.com [40.92.67.16]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 06A4C687F27 for ; Mon, 29 Mar 2021 20:08:47 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dcE7yoWNyfaSKcI007rKxQnXzvekqjiHwcWgdtXyjvxMuFUN6MUNjF1UChme3yl8nvZelUVbwrQKik2WzFDqdPofdc1b6HNIX1+DTUvOD763CUGL9zJpbbhF5VsMhX6AY2WN1MmpcMmU6N+J17dzGiBkR+2eAk8YWP4rkslLTGoPiBhceuyiDe0GI6jjnmZAxYKu/ja8E56xqei9az6WEAk+PnpC0v/NsxzIG6JtuMaiR/Fw6Bgz7bmCCNYmQMfSoQVm86YjpA04RjyskyuSpwqCH/S0fLm6dvqt+YO9f1+1ZObmcpGx+XCuSScEvVbsALDn8Y6K6C6nAlX8HvvAng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q5f3GgxkbTfclwAEM2zcFfXDKzi867smw1gy6QNHRpQ=; b=IjJvcOSs1eDSR5bV9ujnZLVxcaOXqXxmQP62elttqgVGVtXR5VGjsL6WhrZxFcOlSwAQ8c4eLh65DrmCTw2gjwINhj0v7vtOw26hgohSlkxFS/LgqPJumU/dZUoDx3b49fAjUckYa3GZ9dHdtcncNfFxWcykevpGPCTh4+pBN3d3PMpkNa9/ayc+Cmw9VNNvBBWFT3Y5b0HGAGfYkF0NPndQSq7ZMu6FKvXiCc9YJ2qBa8RVg5+Vc0AvtBxphQHfBz2w6Kq0R+fichUw0D4sK6xUbiaEUY0VrUTJzlwiiNJu/53ydtUbNMN31R7D0WhDe98CGNjqCvTYg/gDAflOoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q5f3GgxkbTfclwAEM2zcFfXDKzi867smw1gy6QNHRpQ=; b=fbIcdGgL29zJFG2kgKxmD3d0+CeusMIW8dIjEQnk2GLb3ypPnanQjBL+HHD0Sm8AJlbMpxZLjOTyc4LBB8kAdxhRDJSA2fUi2YjRRdsQMp1v8C271sLbyCOHjqS2xqwrwlTW9nOWGpIIWhqS0DWBgTP6mUs26YpUHa7IXv4iI/5OL6VpyEKhNBLqhhScnKnWknHJP96eh/2Z9PyPw1tnO4TqMoRNNndvjcBh1rs1maRKIjNMHISTRX/CzaFbZeh0450/dcMpGXpcaIdtmFchMF4NbTOSXzCS1a2IgBNaSrS+KS5FGTH6GJdektdqJENaFFvqDBXmqFJiT5UB/HuIzw== Received: from VE1EUR02FT052.eop-EUR02.prod.protection.outlook.com (2a01:111:e400:7e1e::4d) by VE1EUR02HT014.eop-EUR02.prod.protection.outlook.com (2a01:111:e400:7e1e::144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29; Mon, 29 Mar 2021 17:08:45 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e1e::53) by VE1EUR02FT052.mail.protection.outlook.com (2a01:111:e400:7e1e::402) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Mon, 29 Mar 2021 17:08:45 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4C12805ADDF1B5B1B2D35BA15C4AC4DC898CDDB926E97A061EFA95268D1DEBF6; UpperCasedChecksum:3B26BBEC2B4C4934553E0FD10F34352FEBF022A7CEE34A4F0094B6B08899A30F; SizeAsReceived:7403; Count:46 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::8128:5de5:4e94:9a21]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::8128:5de5:4e94:9a21%3]) with mapi id 15.20.3977.033; Mon, 29 Mar 2021 17:08:45 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 29 Mar 2021 19:08:32 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 X-TMN: [3tIKaHOtthHqINVELZamOW6h9hdBEXon] X-ClientProxiedBy: ZR0P278CA0068.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::19) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210329170833.718310-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.137.96) by ZR0P278CA0068.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Mon, 29 Mar 2021 17:08:44 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 23e5f66a-50f7-43c4-1d35-08d8f2d54f82 X-MS-Exchange-SLBlob-MailProps: mBRmoEB1kyJI6Ri+2w4enWz2jr7dr09BOl/V/EYvrtPhKI5Axp1qOz13jCJxXeNVcIdsJKb5pro3mr8EXWNxP6GBD+fmcO70THMEUZMjByXyOjSSsH09V1iqg6H0otB7wz/Woo//gGGdUTdpzSAJIDFu8ITlZcrledNe58/cM3M1o0QK6umvW7C4A3ofnVFeu1vXQFCdAIuv2YlF/oKYT2wM9kq/nChb7gLfBIMHC9c+OIjWT5tjVJPB9oWu/aGKRVwK0hMxvDtvnbGs+g+lArwwuW+cOL/hO5ow7MwO3BXGPhHKqCBWs+IUhyvSooANs4KKTNADN/Fp3RIUb3ECDWfhiy1Hcabvu3DJHmSFsAAzk1cK61NqLJkHijlK9bhyYjZ+KHwcorYY+g8dEYK3tctIyqKUN7ze+If42jv2WA+g2rZEyEm3281nYARxVrI46FC4PIphKQvPs/GT4Gy81EnLbAul6hIKdsVQZQso3+vP0TkSfozI0hSW4M1t9BG9MKKlOL6hn3zxCY8LLU62lpIm7ENkBdluH8Qreyhk46IeGP6ac+8aIVyA2lI+JkurTYtXCsKSqda7SNdAlHkfTTY15yt/Uui6DlNNRxILu9iiTJPZX79Ool0q5lhnY55/vZ9PmSddQfMf7An0DMQabA/wuSL5UdZmmL9sLLb17duUGmhN5JbzkWcsUT952xu2l5NYnvAb0wAffgwMrx8nQLaS+ShMIOFtT4gjO2odWc8whI//PSWiKkBXPpyFm6zzOSkZ/1bRAdM= X-MS-TrafficTypeDiagnostic: VE1EUR02HT014: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wbY4YKLbD9jQUxPPCOg2TSkBBijnAAFR2Ay83qVHD2lF9ZkPyx3tQSfrbfFF0eJJh87C0lLUlGaZdlRJHDOgkk6a4FFByBWlh+ET2uKt758N/XzNQoR285bRCfWw5ZrmkUxw0U4uXsrTlJL38l0aqYRUqGoDxgiv+gtASXpL2cy3TRi9J6IGVch3WjH1yJ8c6SsB+710tBHSd0KBDxjI9seh2ZezmPGyZWAyNjb/X4iOdULy6Fb5/WCmffzFASzNn4cRN8Xk5PRF4ggx2VMvBht6DdXu0U+pl73PC3Y1l/l5pEDRJJaW39yNLZDT8TlBb7eGLX5rMHIGmUHfjyDmVM+X5i1nqsvA2Gj03Mh5LkrASfyQ1hHA8/2rVtxxYJeuYdndqNNEwvaNMuyouRyDaw== X-MS-Exchange-AntiSpam-MessageData: 7khZi3yX2swGAv61OFuMGiUTKY9OS4B68exrmWa+1CDa0y9irn6EIK7ZQsumdsqUfcjOiYrJ/OUCOsuLPzgbCH4yFrwmw77D1dzInWLhBOjXLYho39MgFLbdUYOZi30Ca1QgDyBDoAC1wLLYB4HWHA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23e5f66a-50f7-43c4-1d35-08d8f2d54f82 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2021 17:08:45.2466 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT052.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR02HT014 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/ac3enc: Use actual size of buffer in init_put_bits() 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" Since the very beginning (since de6d9b6404bfd1c589799142da5a95428f146edd) the AC-3 encoder used AC3_MAX_CODED_FRAME_SIZE (namely 3840) for the size of the output buffer (without any check at all). This causes problems when encoding EAC-3 for which the maximum is too small, smaller than the actual size of the buffer: One can run into asserts used by the PutBits API. Ticket #8513 is about such a case and this commit fixes it by using the real size of the buffer. Signed-off-by: Andreas Rheinhardt --- Not checking the size of the output buffer seems to have been wrong when it was added; yet commit 0ecca7a49f8e254c12a3a1de048d738bfbb614c6 added a FF_MIN_BUFFER_SIZE of 16384, thereby legitimizing this behaviour. This number (renamed to AV_INPUT_BUFFER_MIN_SIZE) still exists and it is used by a few encoders, yet not by any allocation function at all. It seems to me that there is no reason why this constant should be public (if it should exist at all). libavcodec/ac3.h | 1 - libavcodec/ac3enc.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h index f8f6a81f45..e358f8d9e3 100644 --- a/libavcodec/ac3.h +++ b/libavcodec/ac3.h @@ -27,7 +27,6 @@ #ifndef AVCODEC_AC3_H #define AVCODEC_AC3_H -#define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */ #define EAC3_MAX_CHANNELS 16 /**< maximum number of channels in EAC3 */ #define AC3_MAX_CHANNELS 7 /**< maximum number of channels, including coupling channel */ #define CPL_CH 0 /**< coupling channel index */ diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 8044e6dcd0..4cfd0afe12 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1729,7 +1729,7 @@ static void ac3_output_frame(AC3EncodeContext *s, unsigned char *frame) { int blk; - init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE); + init_put_bits(&s->pb, frame, s->frame_size); s->output_frame_header(s);