From patchwork Sat May 11 20:50:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48753 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1706:b0:1af:cdee:28c5 with SMTP id nv6csp298742pzb; Sat, 11 May 2024 13:55:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUINNFxlL1DBjEvjPpCyaDv1YtdWQY7pi8snse58q+TkHXUijw7xnRPsyoSNn5yRXD0ZffTmqmgrK4mIbeUcv/ANmOEoHZcju6o/Q== X-Google-Smtp-Source: AGHT+IGHtCFBNXFJSfrrxrLn5alSqYL6YS6TCp3+iJf3edb8xhG7TIg1YvyOsG+lJfn5ey6tuerY X-Received: by 2002:a17:906:f6da:b0:a5a:1ba1:1e7b with SMTP id a640c23a62f3a-a5a2d584119mr374494866b.19.1715460939871; Sat, 11 May 2024 13:55:39 -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 a640c23a62f3a-a5a17ba6afcsi326321566b.686.2024.05.11.13.55.39; Sat, 11 May 2024 13:55:39 -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=V3XinbFq; 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 0471868D698; Sat, 11 May 2024 23:53:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2086.outbound.protection.outlook.com [40.92.91.86]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0A8C68D5E3 for ; Sat, 11 May 2024 23:53:19 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C8n79ZBuuBY6QlcBvOFJWfIWLOW0wulJkXl5wvMYKu924EcfA512Ih0eSZU+3gHOinw3bV+5iexSZvZkA+I8w+SgBqYiva6NYozRFc5uReHMDr0mCAihTqbT/RRjVtW6EcaGI5G3H/yF61NXNcvK0dwiBoq5iQmFBe6hPIMA87zjiJP3h/htbUpAP+/5QANrixHqb0HzwSoaDfG2nPRKqjL4hv6zz5eX3FvzIdf6EAV8E+s5vnVOjSJRNMTa2vCI3mahCCSI/Uh+k4T62OWBnLPsUyITpm14NPKqAP9X+NDKht2I5N6s/LBpWAT3enKVllloAKnc0qyxmZqjWusnxg== 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=X0XwgT065/dczRgJqxzoroTVOq3YtYkaepJrDmD3Pj8=; b=GDnJDcTkagrh56G5t0EPoCjzsoyPQibf6w3gJGDRqXgxqyF6Eidouugf4muaoqLVQMiZUhk8TJBthQ+lydv+V7bJ7QVLYXfRd/6KGHoCiv2CGfAH9jKKjuABWbiZGDOkuFN/ukIk9h9qKXRsXlSHjBmHKmFJwq8TiNeEYsysjM8IN5ZzwOa3+/tRQw87w3VvO/bczxhIR2FJBptUQbrLFSWaeAuyH45nWLHjA72GxFFSx4xfGaAmjyLdl5IWfdH3ratndWogRLkXaudL87V9f9GIVCd6Wbm2ORl47lHu3wAtPSzRy2imuWS5vvxw5YoD/atIoObCZ5wMez/1ePljEg== 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=X0XwgT065/dczRgJqxzoroTVOq3YtYkaepJrDmD3Pj8=; b=V3XinbFqlIUOE4ZzI1DUKaTx2ZVMcGyX0+97kLygZfAvXrTgIZQszEUK/U3mqFpb8/464zQzGg3E7db0085VirB2yWPlmnMlVbMvFEJgacMEp6ynbXrWG8i/+ekhBgxcrgp6NuWOS9Ind5DTIqzHdxdcDp0T7mczWW8IHNX5B8MQsl+VY6jmzvYAWuRdiRC31VrDvnGG0wQ69jTKUJUkCXp7XYVK/KTFFk4T8mdxY5W9OkNW/EfFn63yJZHuEWae9t8a8smLlRIDYOqS1IhtcXbG67wV2l7Fh0bCy/y5ldbKND0ffJVREX8Zn3RnYMowo9CWzyqf7fR542oIt4jdFQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PR3P250MB0370.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Sat, 11 May 2024 20:53:18 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::d6a1:e3af:a5f1:b614]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::d6a1:e3af:a5f1:b614%7]) with mapi id 15.20.7544.052; Sat, 11 May 2024 20:53:18 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 11 May 2024 22:50:51 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [p1PfpA0bmN+hoxph7Id8Kz08MsoQ9ljTHHFviqej3ks=] X-ClientProxiedBy: ZR0P278CA0172.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:45::6) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240511205135.2411886-26-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PR3P250MB0370:EE_ X-MS-Office365-Filtering-Correlation-Id: 79af0eaa-348b-4e27-aae4-08dc71fc62c0 X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|3412199016|440099019|1710799017; X-Microsoft-Antispam-Message-Info: cshSAr+mH679flugZMDezB7s+Tdf6T/VBZLxc4l7dpNKssCHaq8fxPpmXTfIjWPxmobx4c/bVYXncjafFtWULlPLwU8nVflboQK8kUs9B8IZ/UE6nRInL1AZHKHIm9Wo61ciHZc60CUbuY2gLxp4JhqU8x9IkC3Lwl8Xe+Lrf2HSplJG+ZMyh2ZDeWdSw5RK7RkIzO7gOnRXlcLcDdeZ5i/6+h4gcrWJ9aCR1PepJhUiNFgF4h2zZK8hId9Duua5Tn9bEwqf2KmKJ9F+BKcf4RqzVBcyOIAtWrKyLKs2hmodQ940Nur0As+L7K7OsFe0NsrLHTfUYx9wg/6B69MhORsjsGmC2quzAK8Xpc3N3alQxdWstnFsol1uqyBNKFiGWCwCJIfc22S2XEv+m69ArBVkPJpCRFbqlIH3sx5SwdgVo1Z6bczd881AXxY4mbKFuF572AzCsax3a0xDz/D/Nyn5NNaMrNsPdnkCREDipeqzLbKZdJfEWDwElF4Eg/pvZ7uf4DZ5F1LsCP8elTM4X6utNX+w4RdFHnOd1t/Wswx5xPHm4LbJ602N9k/ryQd5usumICeqRBW3Iq/kqWVp8sEreAJNvCYn76U4V98xRnqdD8BRgfMjc5uj8aJQ8Dog X-MS-Exchange-AntiSpam-MessageData-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A0XxgEF85mZNR6jqmfVArdwg+dGTCXdWh6TEYOJg82682esYCrQurodNaTjfLoyuAc3ovmEyRZzh29cLwIz4mRMnUnPTvD3TEnWb+VRL39XceNS4vz1LdMGMd8zCdCXMLR44464uyxtyTGKV4hU5KhEortS8wkC7sUj0/FVcevWLt3qecFSavYsqLAQPC+BkQP4ZGSm9hl96dcE388vKgHri2RlBrFzmKj3aZE00CQoFY9+8UCGYNDw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79af0eaa-348b-4e27-aae4-08dc71fc62c0 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2024 20:53:18.4709 (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: PR3P250MB0370 Subject: [FFmpeg-devel] [PATCH v2 27/71] avcodec/h263, mpeg(picture|video): Only allocate mbskip_table for MPEG-4 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: IeUv7hz6Gcdu It is the only user of said table and doing so is especially important given that this buffer is zeroed every time. Signed-off-by: Andreas Rheinhardt --- libavcodec/h263.c | 3 ++- libavcodec/mpegpicture.c | 3 ++- libavcodec/mpegvideo.c | 19 +++++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/libavcodec/h263.c b/libavcodec/h263.c index 3edf810bcc..b4cf5ee0de 100644 --- a/libavcodec/h263.c +++ b/libavcodec/h263.c @@ -56,7 +56,8 @@ void ff_h263_update_motion_val(MpegEncContext * s){ const int wrap = s->b8_stride; const int xy = s->block_index[0]; - s->current_picture.mbskip_table[mb_xy] = s->mb_skipped; + if (s->current_picture.mbskip_table) + s->current_picture.mbskip_table[mb_xy] = s->mb_skipped; if(s->mv_type != MV_TYPE_8X8){ int motion_x, motion_y; diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index ad6157f0c1..ca265da9fc 100644 --- a/libavcodec/mpegpicture.c +++ b/libavcodec/mpegpicture.c @@ -138,10 +138,11 @@ static int alloc_picture_tables(BufferPoolContext *pools, Picture *pic, if (!pic->name ## buf_suffix idx_suffix) \ return AVERROR(ENOMEM); \ } while (0) - GET_BUFFER(mbskip_table,,); GET_BUFFER(qscale_table, _base,); GET_BUFFER(mb_type, _base,); if (pools->motion_val_pool) { + if (pools->mbskip_table_pool) + GET_BUFFER(mbskip_table,,); for (int i = 0; i < 2; i++) { GET_BUFFER(ref_index,, [i]); GET_BUFFER(motion_val, _base, [i]); diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index eab4451e1e..5c6ec7db55 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -594,6 +594,12 @@ int ff_mpv_init_context_frame(MpegEncContext *s) s->mb_index2xy[s->mb_height * s->mb_width] = (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed? +#define ALLOC_POOL(name, size, flags) do { \ + pools->name ##_pool = ff_refstruct_pool_alloc((size), (flags)); \ + if (!pools->name ##_pool) \ + return AVERROR(ENOMEM); \ +} while (0) + if (s->codec_id == AV_CODEC_ID_MPEG4 || (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME)) { /* interlaced direct mode decoding tables */ @@ -608,12 +614,16 @@ int ff_mpv_init_context_frame(MpegEncContext *s) tmp += mv_table_size; } } - if (s->codec_id == AV_CODEC_ID_MPEG4 && !s->encoding) { + if (s->codec_id == AV_CODEC_ID_MPEG4) { + ALLOC_POOL(mbskip_table, mb_array_size + 2, + FF_REFSTRUCT_POOL_FLAG_ZERO_EVERY_TIME); + if (!s->encoding) { /* cbp, pred_dir */ if (!(s->cbp_table = av_mallocz(mb_array_size)) || !(s->pred_dir_table = av_mallocz(mb_array_size))) return AVERROR(ENOMEM); } + } } if (s->msmpeg4_version >= 3) { @@ -642,13 +652,6 @@ int ff_mpv_init_context_frame(MpegEncContext *s) return AVERROR(ENOMEM); memset(s->mbintra_table, 1, mb_array_size); -#define ALLOC_POOL(name, size, flags) do { \ - pools->name ##_pool = ff_refstruct_pool_alloc((size), (flags)); \ - if (!pools->name ##_pool) \ - return AVERROR(ENOMEM); \ -} while (0) - - ALLOC_POOL(mbskip_table, mb_array_size + 2, FF_REFSTRUCT_POOL_FLAG_ZERO_EVERY_TIME); ALLOC_POOL(qscale_table, mv_table_size, 0); ALLOC_POOL(mb_type, mv_table_size * sizeof(uint32_t), 0);