From patchwork Fri Oct 6 02:46:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 44172 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:7b1d:b0:15d:8365:d4b8 with SMTP id s29csp116910pzh; Thu, 5 Oct 2023 19:46:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFTBx8GfNscwgbnPEVxcMQ3M7MXxmrvsx+qQYadpBglTnSDM8NJxW4OQ+wmzXppwFqknow X-Received: by 2002:a05:6402:4314:b0:525:4d74:be8c with SMTP id m20-20020a056402431400b005254d74be8cmr2824712edc.14.1696560374511; Thu, 05 Oct 2023 19:46:14 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g19-20020a056402181300b00530893136fcsi1236037edy.18.2023.10.05.19.46.14; Thu, 05 Oct 2023 19:46:14 -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=@outlook.com header.s=selector1 header.b=lWPCy2D1; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0CF9B68CBE0; Fri, 6 Oct 2023 05:45:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01olkn2014.outbound.protection.outlook.com [40.92.65.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D962D68CAE0 for ; Fri, 6 Oct 2023 05:45:46 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N2o2VXHfRDHjjed5V2W6gjiZd9Bhe/t7bnu9ep/evAFrPq0xzJEkIrXqnMqZPeWOtLrU1LHvc4vcAypb5pxdGK1LRbZ/+Jk45xLIm3fAY/fTuGhJlObZCj4rryXziml2EoEGwQm8wvrch4YHZllu2XjlgT0+HwvooWXOYRJjHv4dIMIah9xVdCj7BFSN51XmXq9TmeIPeYInNRlY5MRhArpdYxmZfW4FQrnTu4BPgipz1mAS+n04OXs/+WaFdQ4jrCahK5BFwUiTg5pGEONw4SrF8mK1XWkiYSCdiNWG/MOF/MG2cBfcZzRjtVVvR9nr8lpXuivjPmzx82JaT4TDRw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TswwEcr481qwhQfrgJeA3dQjAiGu2ir+oL7zMBlQ8Bs=; b=IcO9baZ1po+QWuklcbaThtyfb1+bbHQQ2kZ7UQAvztVNJC8LBShyQRwHVBlxQ3XJKlzgWwXi0x31gbPeeVTp1MSSmPuea2PMiO17+jHldHtHxc3Hoaj7b+Bkvy+MqcduYBhzvobwtGEWEbCfl7tE0yMaJXRSTmFPvmi8n0sb5xIE7IJZmuz+ScaY5e/kGgKZNJNqmwQ/KRT2f0HZJb2mNOZWn5NLaCuCnNCiKEvC4kjQRnrPVgYolqbhvHZAtnVFhdN7tTIu9Ns8JUPB65NDnjztrBVV52ZiQUNsgUgW2xVKgcoVasTYSgCFI6RULaUHsjQXFzFLCEXiF5K3siFSAQ== 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=TswwEcr481qwhQfrgJeA3dQjAiGu2ir+oL7zMBlQ8Bs=; b=lWPCy2D1pV+pjHWBkLkjYgHatHGo23igtfSVXMnTjMN37BrrfisiAQyh0STU93SXufMafY+sTTXp3rW202/Ffe/3rVfB27iqkzvG5Y6B73vyd6uVJJJaP67az9Rl4+vR9x+K5XGr6IvlfBK5u6+HsxK76+C0iHZZ10dP9TqJ3IMgqEBjYdNW/VvmP5ofRNgYKOpVF3BH6fayvS5nPsTipcZePQBknsrfGg1VAB5dLcjENs4wmtBYDfGQURuJGR6X7kY3GhsTu1x6oGeNdqj5LjJ0ukuZTjutLycG0RIJyMVGZV4WmYNabdCWVx4SQn6tgogCfGF9biHYY8rJfQpurA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by DU2P250MB0148.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:275::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.37; Fri, 6 Oct 2023 02:45:45 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa%3]) with mapi id 15.20.6792.026; Fri, 6 Oct 2023 02:45:45 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Oct 2023 04:46:29 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [vxjxDF7Dt7rIANi9KcfJNMPY6ZkBU/4J] X-ClientProxiedBy: FR4P281CA0094.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:cb::11) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20231006024636.1005349-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|DU2P250MB0148:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e07b5ab-2816-4c17-6c7e-08dbc616569a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 80JT47tsx0AgasBxjq3rebqGBnaK5vCrcMPshfjzbEgGtBGiruMwUi8pKhXDnvtB8XabS6om3aueCypiHZb9x+LQNQtrbLKX1/cRh5kvX+lt7hIWSZHrF0PXux7905NdMZVmlwxGV3BHUETU1FRBzuVIZNOMmsWRO0+ItcUvMIMTROO3464ez5hUTLswrmTSSa0oSUsh5Y9zE3er7HyJ1t8pi1Q98A9rnd5kDfWNKqgtQo4ZPKffFU92k6+v8SvazHVZBvun27TcErU0HHqP1U+tEYB1A65tzIiicYIvf9VR+A7lInllY8PPzYKcjW+08n6BTWPHFWZ3/WPPZzWQ4ayKh2sl4UUnnsjNp85i/ABiwvHKD5KM1DlQftt3DI1iwt7hRlK0UGT3CG44bzeYnMvMmLLOgmVmsVhcf1vHUzLFWMO39FfZo0yf+hAWzevftgMuOSkZGqntsOb+zxasbCvdiVIxYgDP08+LSlCbEURnwT6GOCDr/+J9zjrpZX9Kd0li9A5XPYDuFbPqXbg3wzblmqd0lp4RTRDQGV3sRfQucc4sMX7AHjFLJqaXogwovqEx9OBFLOlfo8XsCFBXoJijy2vGW/VQ4zA5Wxt0KqYbSV9D77t3sa4iDxZJLnVF X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zKlD92DRwpEUkyNm4fnKuC4tccxlU9J+wtMaU233c/an2hSBtugvfP1SOzRz9DEQo+1qFsnU3JdwsG4Nek6D+yLc4zPVTUxzHyhnK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BD6psdMENC0dNegwgd18auDy10yzSEy8MRBrPIC+Qxbpk8qO/yJhVdECR0kd2uuLU2inI8YX2HZ3B6exTtROQA461 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e07b5ab-2816-4c17-6c7e-08dbc616569a X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2023 02:45:45.0390 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2P250MB0148 Subject: [FFmpeg-devel] [PATCH 06/13] avcodec/mpegvideo_enc: Don't overallocate arrays X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: rwUEAzaXDU0T Only entries 0..max_b_frames are ever used. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_enc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 1e0aed8db9..c06fdd08fe 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -819,8 +819,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) !FF_ALLOCZ_TYPED_ARRAY(s->q_intra_matrix16, 32) || !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) || !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16, 32) || - !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_PICTURE_COUNT) || - !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT)) + !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_B_FRAMES + 1) || + !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_B_FRAMES + 1)) return AVERROR(ENOMEM); /* Allocate MV tables; the MV and MB tables will be copied @@ -1231,7 +1231,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) } /* shift buffer entries */ - for (i = flush_offset; i < MAX_PICTURE_COUNT /*s->encoding_delay + 1*/; i++) + for (int i = flush_offset; i <= MAX_B_FRAMES; i++) s->input_picture[i - flush_offset] = s->input_picture[i]; s->input_picture[encoding_delay] = pic; @@ -1450,9 +1450,9 @@ static int select_input_picture(MpegEncContext *s) { int i, ret; - for (i = 1; i < MAX_PICTURE_COUNT; i++) + for (int i = 1; i <= MAX_B_FRAMES; i++) s->reordered_input_picture[i - 1] = s->reordered_input_picture[i]; - s->reordered_input_picture[MAX_PICTURE_COUNT - 1] = NULL; + s->reordered_input_picture[MAX_B_FRAMES] = NULL; /* set next picture type & ordering */ if (!s->reordered_input_picture[0] && s->input_picture[0]) {