From patchwork Wed Jan 5 21:18:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33092 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1089539iog; Wed, 5 Jan 2022 13:18:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxn9xnC5csc7V+NXo/WRyY1cO5u5SXMFEizsqRo0pA3YLcCxUx5iFcdLgx/iTyJDwkJ26m X-Received: by 2002:a05:6402:40c3:: with SMTP id z3mr37747081edb.386.1641417510121; Wed, 05 Jan 2022 13:18:30 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i39si36899eda.211.2022.01.05.13.18.28; Wed, 05 Jan 2022 13:18:30 -0800 (PST) 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=GJa6wOJD; 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 1D18C689BFF; Wed, 5 Jan 2022 23:18:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2093.outbound.protection.outlook.com [40.92.91.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 878B0689BFF for ; Wed, 5 Jan 2022 23:18:22 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hYEvYglOcbupfMMPNGbbbZdfRJS1Rr5d23lzC656ujsJcx5kf7R3/Okg1MBQ2lgXaTAqlKpyToCRomQLVIL2TvPvSBMyLKGVUcISlFvSYPtC4QqjeP7q0gpvpZ3HzcpB/cuLKJ6mGNr0FLgFcwPDTG+ou3n9IyQc0luAL76NZD2exd/qiKqSFLhEr9bkhKEwC28yUQNloz2fT4L8ZWNwg/4QAvxykcUOgUemtMHCIc2nGkq0aIZ+WKd+lEu5+JjpL8DEvKfGH9hclgKdkR5/83ESAGPOgcGUL8wqcfLNAQKAidJ05k10JDpJVuQ2AtNg73p5U7RT+prWCRscLKO0Dw== 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=wwr+6EfTOtG5Z//Qdd4hvOt/zbCS6tk/PfwtQ+SdE94=; b=jWnwkZuLdedIwVxHnTWFmUhDoL9J7JV2JxrlTj+wGDVxAPJ4msuN18ynP3JECFQjcQk/v/XvCayaTuenDkh8hklDyBnnFL4U/e1IW3/GJfrHm4GmPuMaRx00JFR1ZhzoAfev0rsJXUSwnTMQOX6EtkTG//5EsqSg73neXtnMrn7ppS9D67GnYtsFpxVDQ1jqM0VG21LBX2OQIzvLEW1FhesCh++dS1MdMcqqs+QFE+nOZmjrM6u8DFJ03ITR8tWKKU4+HgF6tFRF8OVoDkVOLKEUqa+WuxbIA0CGi3aFVM3sTE0RrLOzIdhu0KuFPnAdsHl2Pxj7IqoAS28MpuWOZw== 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=wwr+6EfTOtG5Z//Qdd4hvOt/zbCS6tk/PfwtQ+SdE94=; b=GJa6wOJDLI7YVuObv8d60v2nB5qaPiPYZHR+JvMQW+AoyjPmblw5VXvNrEg5cOCuuYqw9NwVJzlKHX7oE918qOw5n6SEsAuC49SVxVcXE+fZDKfAhFgtxo2umDExpQ59ChC0zYMYFrJ4xYLXU0S1+WcxzwqJCyG5a7uNOIc0Xkyu1eBBLvil4Msl2jNrxZgj82XOrUS/ft/JWiLfB1q7Kib1oAJWskrZUV7KiuW5jCdliUFuVKziNcc13a+N+ePf1AqtMwjeB0lZQkmUpXqewHA+C9Bpc/F15P965BkMn/bZkRfzAYXJgaZk381465qnR9qODEWhPp8N0CGz61f1SQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB5379.eurprd03.prod.outlook.com (2603:10a6:20b:c1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.14; Wed, 5 Jan 2022 21:18:21 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 21:18:21 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 5 Jan 2022 22:18:11 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 X-TMN: [d87Y3V3OKUYBzoIpfjgveUQ1MRCH/ids] X-ClientProxiedBy: AM0PR07CA0017.eurprd07.prod.outlook.com (2603:10a6:208:ac::30) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220105211814.652006-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 47e0032c-f77e-4b12-240c-08d9d090e67b X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiR3EehW4kxQzdNcP2D/mG1JLW3JzCk1VgEeinm/sEhvzyILC0AUkzFzldIHtyq88Ec90rsCx9wvdsD1d5QB7TzXG7oD4Fmre4nO97sm+FBf77nCsu9F8JxOLQaAsg31WnWVMOglk6otzWXri01S6ybaVzVbZYwv+SQ5JlVyg6ooNBYeks1P29c3YAuMnZBT7ovAcliYaH0OZFlTFzMoHtWhSaBZ3A5YRwsVvZR1O8tlUjotNG17XvF1Aji3ss82asjix/dqB+e9mbgd9htZsuimX36pa/3Yj+UygIscaImVfWftBroj+c+B1PViF/aSrWKTw/+5voazxlHcC0KzKCT5X4m4tDYY2eGJ3e6NTzm6/DIIH0S0Hf28F2+taHnYJEyjasnrEeiupOWrJAH/v/cBP44JUXshXKxXmw2avap1AKNaSQIlOTaNMOnz9T1P0O2XdbvHkdhEAohBuWo/oGqoTVmlWVWOqzfdMuacr5fnqiShZOyQ0vbTMou23jQ0gwwe+0LsN2beILyQ/QpR+c2apwMA0/SwiFB0TTYlayQtARGqemiHSYG71iJePjY826M+YvWh99iHuwR9EJmbjSzkS0kbgHMiyhhfs7S/q3xMxkbMphL2mi2YjiVK8cLhmon2OQqq4G8n4aNj+6QUcy8N6Banm5Pr1avJFEE04Hu2qOEd69GiJFWpdn/5eBXgb0HO//7fbU6fg67Jq+tfTycZHdaeBFGgCP4ERyqbxMYmfZIAEb97Dvblxj95Q1PrQYw= X-MS-TrafficTypeDiagnostic: AM6PR03MB5379:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JifedZD0go64e7lyPvroXjWRhVT6V4rRBnILX8lC7cPVlakdaZcX3FjPv/QncAwtv+Xretnfuo1QDPWT8DwZHeFgoUbLlwXwIyN6jLM3+d39TCT0Xsm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m5Z6at/3sU4FcM6TbiT53cILpwzvA016K/D7M6lxVUHFScww7mG2omq97BfmRc2kPoehHo0uvRGmBP44/s7D7cwIwck5SVWxVT/udhxx07kEIXFJx6VZm+PJ/4FQyFWgr27Y1Ot6TvmqkLgghB7qh1t1uJ0ubW0j0ETo8h7loptRA6OnjULHim2dgyX8L3RHZRuL4tkeNbslo3M8NTRKbWUzQzyQcTxtPwyevTT76mnQxTsU7evSh0oUAoAnumWRVCkXZDq4uHkqKrwNPBSb3QTLwT4eGHmEH2BYMW1f4MS2Em3ZK7xWfwQ7+cCKd75d9xt37IKrMVmhophUSX4HRtij9AfV6J3VQ3TQ+RQPVFguG4AsQcSJC95ubCDRXcdNqpyAT9RthpzhK/wFeGeTQfSOaAvxFhw7m1dQBXl8j/WcH1Ocr1TF7b4XXO+w0Petg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47e0032c-f77e-4b12-240c-08d9d090e67b X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 21:18:21.2845 (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: AM6PR03MB5379 Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/hevcdec: Combine multiple allocations 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: wbD4BCyEyHZ0 Reduces the number of allocs and frees. Signed-off-by: Andreas Rheinhardt --- libavcodec/hevcdec.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 8d7a4f7147..568bdb5ab7 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2621,17 +2621,15 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) const uint8_t *data = nal->data; int length = nal->size; HEVCLocalContext *lc = s->HEVClc; - int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int)); - int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int)); + int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, 2 * sizeof(int)); + int *arg; int64_t offset; int64_t startheader, cmpt = 0; int i, j, res = 0; - if (!ret || !arg) { - av_free(ret); - av_free(arg); + if (!ret) return AVERROR(ENOMEM); - } + arg = ret + s->sh.num_entry_point_offsets + 1; if (s->sh.slice_ctb_addr_rs + s->sh.num_entry_point_offsets * s->ps.sps->ctb_width >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) { av_log(s->avctx, AV_LOG_ERROR, "WPP ctb addresses are wrong (%d %d %d %d)\n", @@ -2716,7 +2714,6 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) res += ret[i]; error: av_free(ret); - av_free(arg); return res; } From patchwork Wed Jan 5 21:19:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33093 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1089986iog; Wed, 5 Jan 2022 13:19:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIpWU3KJ0sPdjtglVDP2PKPnHrSYw7TkBrQ6mn+BCKVSHIXBkt9EHT8kDuhH40E0WDjpJG X-Received: by 2002:a05:6402:2686:: with SMTP id w6mr53789799edd.79.1641417564760; Wed, 05 Jan 2022 13:19:24 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gv57si4190ejc.437.2022.01.05.13.19.24; Wed, 05 Jan 2022 13:19:24 -0800 (PST) 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=DoYUWIIV; 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 573F768AD28; Wed, 5 Jan 2022 23:19:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2031.outbound.protection.outlook.com [40.92.90.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5798C689BFF for ; Wed, 5 Jan 2022 23:19:16 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kAZ59jJbyOay7HWU/qTzSsEvH4QTce4CYPRgWBmgmaRij2RsMe1oRC8t95xdW96GtVDLm6CjbuX6KRAnoUW9yFd0+oZlC/deIxJsbcOgIjrnBHdMWIhqfbDrypcnuq4WR7uwONOUp30V1q7f5SLuwg+P4oxFP/dPp/N/rhqf4h7ALSWmwxr5wB0ayzTo2yEjGVc5dSIrCVX1lITT2ii297L5a58UTT1M05JKJnPJKPsbdpDfZ15lbpttGOnxPcakSr+EYljab7zLjRMHU1AWzO90c6RRvO0/emRmU4GqTo8V1S7OElq1Vn5FRFJ5IBd6IIwEfl4sS9LryqEcBtNJSg== 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=IN7fY9RZHE/jfJBFJloQSNwLs3glmmdtA+YmlJQCWoU=; b=QDgUyRmjOaZFh45TnB4nNT6uRzLD98ST0VyrpO44MIWSdwslpbgk/xbMilR4VoFOd2n+tCx1RVPUUJ0rRnYeOxXkzX1y1rEVjYAhieEUqXexKYdBWgbtAOa9yg+b+NUBv3M4/1Lm82QMl1TkDSgTxKS311JQ7RCnO/iAq69b1y62t2BomsG8V0lh7xv1ihfYTEmy4SyO2WOLUWMh72r2Tey5veN5+XbQ8PjZILTAzrj3KobSTAOK3OL4dEoEQm9KA07X4VhtyjP/5dBlZLY7eUn1DamQgXzaSpPI4dFpfSYPWOycMrG+EbT9SqA/rn4Pp3Sk9NMshD4Fgko0nizqxA== 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=IN7fY9RZHE/jfJBFJloQSNwLs3glmmdtA+YmlJQCWoU=; b=DoYUWIIV0NhUijFuDj2aP4fTs0Y1UO0VTTIMKlzkFcSBNW+g/GdiOa1mosMmaccorQoaKnnPjljyrhJGTOblePRvKVZhif0s2oYhsIjSPhdBPi4HX/V8l1kW4lCrciMzT892eBbzH9T64v90J2E7/pg30+3Cv/fOphTFLQm5+aU2jrP1sB5e8QOYIcj88dSZRGoxYTlVT96DnsYeqqTfU93tdF4ZCMnd+Eo5xuZtDtiyHRLWnFylKPDN1Hyz5HxIOUD1+DGYJK2eFKG2RZM6CcFD7Np3/Mqjck6KrH2EGeFbUwG79AkzVuweyWUN7CuKVr3mq07SEEKtkAHQYBy+2Q== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR0302MB3398.eurprd03.prod.outlook.com (2603:10a6:209:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.16; Wed, 5 Jan 2022 21:19:15 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 21:19:14 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 5 Jan 2022 22:19:06 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [Y0IcisHucBRKBT3zDlIwZUr6iWpyLG7G] X-ClientProxiedBy: AM8P189CA0011.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::16) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220105211908.652136-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 654a8f0b-fa83-40ae-a9c6-08d9d091067f X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UJ+cHfC79vTguh6WqLpD1ahnLFjFfKB0KGp44r+vIU1UYr88LNRjCH8iEHCE5cFGZrzAUu2YNN/peYyI7E5LEnjLmfNw9IVfjZQ9fwVgRDzochr8rF2dg1pL/bcpUu+30kyLRGB13mMoxK4GxtVihiqvJPiOuTJCX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CFU6FPmmUogkcFuyMfNOPjqt0SXOPQxK9jSqZZRGQt/K6eLtjQzsl7C/eK6TRMacHaVBDmY2/HTXvecU1BvUdqUHXK931ck3ZOlSo/sgyA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 654a8f0b-fa83-40ae-a9c6-08d9d091067f X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 21:19:14.9375 (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: AM6PR0302MB3398 Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/hevcdec: Remove redundant frees 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: TzDetkiTEth7 These arrays have already been freed in pic_arrays_free(). Signed-off-by: Andreas Rheinhardt --- libavcodec/hevcdec.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 568bdb5ab7..85a1b9f47a 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -3595,10 +3595,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) ff_hevc_ps_uninit(&s->ps); - av_freep(&s->sh.entry_point_offset); - av_freep(&s->sh.offset); - av_freep(&s->sh.size); - if (s->HEVClcList && s->sList) { for (i = 1; i < s->threads_number; i++) { av_freep(&s->HEVClcList[i]); From patchwork Wed Jan 5 21:19:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33094 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1090051iog; Wed, 5 Jan 2022 13:19:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTO7L5j0FhB0/HVuE3deb33iwvGpL/uJL5u8yriS96P8JUdLACLoMU92Kox7saqqCPis/P X-Received: by 2002:a17:906:6a90:: with SMTP id p16mr275680ejr.115.1641417572985; Wed, 05 Jan 2022 13:19:32 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id qb4si13867ejc.57.2022.01.05.13.19.32; Wed, 05 Jan 2022 13:19:32 -0800 (PST) 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="Ov/9cW1d"; 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 7B25C68A867; Wed, 5 Jan 2022 23:19:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-oln040092072011.outbound.protection.outlook.com [40.92.72.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1CE7F68ADE6 for ; Wed, 5 Jan 2022 23:19:22 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mO2g95JQXaETyO6tBV4BpC93RDRqk/8l/OHk3+PoKIxSPm2qbprbwYg+T77ZILqEmNggDRb2MqZMeTO14IONXYVE9ItgLxDrcu/wSr725r2Xy3fdDJuSyh8lqshbKDQeYU3JjDBzBboHizpfLr6WSi+JihpJNJcz/RDRXgS9bVMHp/MvSMz69Pe0TzNLLWuIwyVtfVjT1DnjrlvjOlCLTpVNcBuAyWY0Qb1tFJXRuv4/k4g66zQg/BPID6f/QDrE9ePy+rCbVSbh94TGA25XsOShfKNiFwKyOXPj0YINxUFl0LJhlgNyt6kZ3MogTVWRWcoYhjq3eTsUa4+eGpwohQ== 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=l/50PhzHHlZNlmvTiQltFatTJAYYdAOHI8Uv1TnfJFE=; b=MTwrU3E/Od2AOpj3rO6mjQK4ywg7SPFOrFAsyeQWyUHO/BGcH1RZJeMJWWNNQVfNbNiMkSST407wqe1VsI2pRNb0xtdI5yzRFVScSD9HKZM0jmj2MvTa1ftI0i9635gbv+EYxz4z6xWQWgUcWVrXwbwTk7iDRVe9eM3X+51Q1AJoV4vLrrHz7qOFtHcksybT+j9h0w+mXEnACe4NZ6kfMRykb7NFqOoUSXzaEUy+bXlMehvSrPmhf2zovywQpYYNm3ZUNsbMcdat20MOcDu4mvhE1x9DhZmTtFz9H8Zqr3ZqZLjUPNI82B3RSf3Z5B7s8tDbArVgDpYLBz3StJ9fqA== 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=l/50PhzHHlZNlmvTiQltFatTJAYYdAOHI8Uv1TnfJFE=; b=Ov/9cW1dT5Sh/vzwpFiljs6HetjcuI2CKMQTsocAkdV81sXsg/uUsAgKOf5/eeWpuDwrCWrKR4TGxOBM6x7XrXtEnE9cq89IaP0DPIWF6oavAVwqOsZBPWFfILBVAH8bWpCPWW5yYhalDccXDxt/P73VH/AfWKJ8OxPzvukNn/UQaZ8SyJfh5SMjkNrcqMZAEYyhuM5MN04bqiWLdkkorXA1YryVzPRmvVGDzDFN87D24SYDGe8eBGv8a9MLMj+oSQgaXlROLY9oErBv5amsiRwWnzBYKM92bBNiX0q61Rm2eaOcMzawOQb6W3G7Hguwm+1Oapq6bVe2tKZYP71qcA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR0302MB3398.eurprd03.prod.outlook.com (2603:10a6:209:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.16; Wed, 5 Jan 2022 21:19:21 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 21:19:21 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 5 Jan 2022 22:19:07 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [7F3fdWx3YZpjAga+pkNq1QFMb3Ma3FZ0] X-ClientProxiedBy: AM8P189CA0011.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::16) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220105211908.652136-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6e3f4c5-1878-400b-2cbc-08d9d0910a4a X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiR3EehW4kxQzdNcP2D/mG1J9Co1q/+uUsydTM1ltaItHcCWJlr7E0xKLBhR1sgP1GzcPEQpG59zWJdEwCXV6IAzxZVywrCyQnsJNxoa/jhjTv6ciOteQqosc5Vzy1lvBGJKzxJkHEuqrdZhZRLKoKjG+dmkGdxD+3npL2gi5r/vHA475WJbislVnQykL9apj3/+Cm4Be34Br95kvmP9YmstlMlfg5PtrYOGsFKNiyB+924u5LgY0w5YVI/W/LGWdfcxd05zjyiFe8yYH0ECxsWPHQMavHN6bbRTL5Z+nWjUmCcLk5xFkr/D1R1iVmz4rkD4f9FpqrEKfiyuVbbELsh8H8Tr3Pgr+mhRO+0NIuwG9QUYgfdaxPLC73Ndzew5oMZ0pCpCXVux+C2X3fj4ehca41CUmaYB9QJ5sE0DQshTDSKwW5kA4ZYoZPgaMX2bU5wkSKaUq6dX8KqGylO9oV3Xw3Cf3KNg8UGY8Uc44xp0+QudFcbWEDCm074BWSerHyC7KCH1JvejsXNrh958ueiAveIYDBGpWpu+eGtCJz7Gp0BIr01QLInrJzHB84TUF7Raqy09nZSAGSzb30FjL3Yo+aevmZ/HyeHjSpCpK0gaASnKc2A8hkdtbKsXYjaUMJm+uesL8akAmLrOJDHiRdxkes4ReH+41afmgXFFbrVvT2K5Kt/gIR+ezrYDUEprmi5OGNgdWN0xeRQSHH8flAKqBaZQFKZdHzAsHJZhmx3AYdjQP9OymvjNVaqIbiavZWA= X-MS-TrafficTypeDiagnostic: AM6PR0302MB3398:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iMePPk1BSbeJWJEqn/geLGb9bo5Juo4rtvOnvCRNtOCVY41H/oWCRUY/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ZqJAVnnAqNKb566lOEAJMIZM/jbfGrVWrhh49q9ngn2+SOQse0TMXuMjI+qkurv7MRNR4SH3B8MYTmoqEDdADK4LzxrhvUoD8U/kMsgjmMribFWQoifh4Qq/nsZKgJSA/LAITxchDrmEKaTXMwJ2+B/BQ5eEzcDX9dEFW8AiH9GQQ7uk3JgBPXJijl2VfglHxfImf5F7RCLy6EcRVbuHM5gmYE3VHc0kQaeP0yBhqefubBa2G/cH/8aWc1jgfQcc43qqZ2MONuD1gpQuk1iuE7dicLQUDFGo4fFa2a0e4JCklUsEi5x5BYOMI1S/TXxXOFuBBreO9abdZx1aD8X3hVqBhn+FVBayVHTLl+Hnmp8E34O7urhFBdS1PQvtKCfwxvF5HtwAXik/3BVKfj2EaFpab/xLnVtLx4qZI08Q35xVZgbcJLduFjLhiv6cXa8x0CKjZRkVaybzYzpj9r1CyGcSTrYwmioVTmN4116kZKpEnC2uw6Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6e3f4c5-1878-400b-2cbc-08d9d0910a4a X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 21:19:21.3615 (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: AM6PR0302MB3398 Subject: [FFmpeg-devel] [PATCH 3/4] avcodec/hevcdec: Combine related data into structure 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: fgMkBzNZPLVs Signed-off-by: Andreas Rheinhardt --- libavcodec/hevcdec.c | 28 +++++++++++++--------------- libavcodec/hevcdec.h | 8 ++++++-- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 85a1b9f47a..fc0dc7a584 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -78,8 +78,7 @@ static void pic_arrays_free(HEVCContext *s) av_freep(&s->vertical_bs); av_freep(&s->sh.entry_point_offset); - av_freep(&s->sh.size); - av_freep(&s->sh.offset); + av_freep(&s->sh.entry_points); av_buffer_pool_uninit(&s->tab_mvf_pool); av_buffer_pool_uninit(&s->rpl_tab_pool); @@ -915,12 +914,10 @@ static int hls_slice_header(HEVCContext *s) } av_freep(&sh->entry_point_offset); - av_freep(&sh->offset); - av_freep(&sh->size); + av_freep(&sh->entry_points); sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(unsigned)); - sh->offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int)); - sh->size = av_malloc_array(sh->num_entry_point_offsets, sizeof(int)); - if (!sh->entry_point_offset || !sh->offset || !sh->size) { + FF_ALLOC_TYPED_ARRAY(sh->entry_points, sh->num_entry_point_offsets); + if (!sh->entry_point_offset || !sh->entry_points) { sh->num_entry_point_offsets = 0; av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n"); return AVERROR(ENOMEM); @@ -2552,10 +2549,11 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int lc = s->HEVClc; if(ctb_row) { - ret = init_get_bits8(&lc->gb, s->data + s->sh.offset[ctb_row - 1], s->sh.size[ctb_row - 1]); + const EntryPoint *const entry_point = &s->sh.entry_points[ctb_row - 1]; + ret = init_get_bits8(&lc->gb, s->data + entry_point->offset, entry_point->size); if (ret < 0) goto error; - ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[(ctb_row)-1], s->sh.size[ctb_row - 1]); + ff_init_cabac_decoder(&lc->cc, s->data + entry_point->offset, entry_point->size); } while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) { @@ -2675,9 +2673,10 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) cmpt++; } } - s->sh.size[i - 1] = s->sh.entry_point_offset[i] - cmpt; - s->sh.offset[i - 1] = offset; - + s->sh.entry_points[i - 1] = (EntryPoint){ + .size = s->sh.entry_point_offset[i] - cmpt, + .offset = offset + }; } if (s->sh.num_entry_point_offsets != 0) { offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt; @@ -2686,9 +2685,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) res = AVERROR_INVALIDDATA; goto error; } - s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset; - s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset; - + s->sh.entry_points[s->sh.num_entry_point_offsets - 1] = + (EntryPoint){ .size = length - offset, .offset = offset }; } s->data = data; diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 157bc6926f..76ad262558 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -246,6 +246,11 @@ typedef struct RefPicListTab { RefPicList refPicList[2]; } RefPicListTab; +typedef struct EntryPoint { + int offset; + int size; +} EntryPoint; + typedef struct SliceHeader { unsigned int pps_id; @@ -300,8 +305,7 @@ typedef struct SliceHeader { unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand unsigned *entry_point_offset; - int * offset; - int * size; + EntryPoint *entry_points; int num_entry_point_offsets; int8_t slice_qp; From patchwork Wed Jan 5 21:19:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33095 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1090144iog; Wed, 5 Jan 2022 13:19:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuNXWjgM+HfKhSezz7iM7zKFfsmb1yT12o1TDSpUXqtkaT8NF9F70uS8ENfCeLiIsCMR1t X-Received: by 2002:a05:6402:8:: with SMTP id d8mr54360201edu.61.1641417581844; Wed, 05 Jan 2022 13:19:41 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r20si5423ejr.392.2022.01.05.13.19.41; Wed, 05 Jan 2022 13:19:41 -0800 (PST) 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=MbGx+gBC; 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 9285F68AE3C; Wed, 5 Jan 2022 23:19:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2088.outbound.protection.outlook.com [40.92.90.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1D05868A8EE for ; Wed, 5 Jan 2022 23:19:29 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OJ8oBJeKyZmHhkErk9qzWFi3Z7tiiJqLCs3hCIlB2/f2tRkyRIngNqNDJbFEu72wbDQr4XgOU/CCVw59uCGa2dFTBk8T8E5YbG+Ruh8nKzQOg5PD/unoZsMNy/7MWWSogQeHNEr24LIRp6VWuL9mHGx+TBy0+PPoKKIiZendfA6vUMORMkVex+WKh5vQH3gPgCkFEyaQIIrljErqdAyhjA4KiR1/in8jd1n1SKKuZetGgqvf9ABsgFGZO2P5wS7syrCrUqICq29BCIDQezWXPcexqSL8SJR9cv6OF39Kpt0rT2FH3LYo1LTkAj1fwkg9boH5wLmB+t+U1op290irGQ== 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=mEpI4nBHDwcEKZeqbHbNygBPCfG5PnDgEXvc95rrOew=; b=k17tOqhDuT7olNlnLLhy6VjFT1uWWeKo1bIYVnRpBoecOlho5xROK5A/caWWyC8rwXwmjOWQEOXBKqMmr1uFgy99oYqKCl87rTEs981ouNv6RqvP8fUDKqwJ/bI/HFyka7yigqZ7bnJnqdwBop7Phjv0xqn6cM3wgUlQF6fHb19BWdzgy94YCD24rsx8UUuTf8Mc0FtDLMnU05x7dGmf2zm39FqnXtDOJ+ZpeGuXOwQvmWi+RRPFeZ7uK9+LCMSQdC47VyEpt2HfHhMfpVr3snB68pAlejUuJvhVByxdzEUWCEbfkxTbu6JSoDQSz1ZMupWr6LujR4X+4qzaIuOhNA== 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=mEpI4nBHDwcEKZeqbHbNygBPCfG5PnDgEXvc95rrOew=; b=MbGx+gBCi0XbBilYiHq5VCqqZtF1JJiFsp/xe4YhbuC85ZoA4Vp1haRFdZyDzaq3L26Fl8qsPvdg47+PzDdpz5SiCEj+Skmqb3hiubAq8RXyCsNqsmdT6v8wK0L+/CF2Edg+OsNGXHEKy+9m0jj8KfXM+cxwJ42fv7jZQF0FV1k7UXZzzSWuC+E3dYodf2K0I65uW5I220gxeV1Kp2eQzwkkeTixPajwFmJLmDJIh0mbOEBIFSGr2NXAKd00MTFz6Gv1NKSEU7OKF7uK9xHPZ3DoNxBQXB2+XyFbwnSD+RQPC9owDkoquAcjhrzT63C4vaVkOxRD/SaqqKPyy4sQJw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR0302MB3398.eurprd03.prod.outlook.com (2603:10a6:209:18::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.16; Wed, 5 Jan 2022 21:19:28 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 21:19:28 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 5 Jan 2022 22:19:08 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [PiY2E/uIU61tLVbCu1yrTLP39S9euoA/] X-ClientProxiedBy: AM8P189CA0011.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::16) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220105211908.652136-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ea35a0f-7fe0-4233-ac49-08d9d0910eb9 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNWm3GLoe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tTiIomf3ANmT0nyo6hrLQadnwQVd/5PnQMk+eHcBMoXwVUz2pJBOzd6wrrP3aG3bhms5evVANwB15SnUOdQ2FPmW70yw8VYhEH8znP1LqK3YOYCx71w+OZoCi2okcFgp40S7uKkfDh55xm18DEAoQ0uqdWzcgmHhAJByEOzNsv1t7ErjINKGPHvGhxrFSETOaGjj1mMjT/QtVkJL0KUCirIr8pQoyINoMLn9JtJz7+lrGF0OmZQmLjuIZuLUgcZLWNAkHYIskOQ2k1iaSCXkBkZrBVjCLD0JTUbndrEAA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ea35a0f-7fe0-4233-ac49-08d9d0910eb9 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 21:19:28.7239 (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: AM6PR0302MB3398 Subject: [FFmpeg-devel] [PATCH 4/4] avcodec/hevcdec: Avoid redundant entry_point_offsets array 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: eGo57S5drchq Instead modify the offsets in place. Signed-off-by: Andreas Rheinhardt --- libavcodec/hevcdec.c | 19 +++++++++---------- libavcodec/hevcdec.h | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index fc0dc7a584..6aa14455d0 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -77,7 +77,6 @@ static void pic_arrays_free(HEVCContext *s) av_freep(&s->horizontal_bs); av_freep(&s->vertical_bs); - av_freep(&s->sh.entry_point_offset); av_freep(&s->sh.entry_points); av_buffer_pool_uninit(&s->tab_mvf_pool); @@ -913,18 +912,16 @@ static int hls_slice_header(HEVCContext *s) return AVERROR_INVALIDDATA; } - av_freep(&sh->entry_point_offset); av_freep(&sh->entry_points); - sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(unsigned)); FF_ALLOC_TYPED_ARRAY(sh->entry_points, sh->num_entry_point_offsets); - if (!sh->entry_point_offset || !sh->entry_points) { + if (!sh->entry_points) { sh->num_entry_point_offsets = 0; av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n"); return AVERROR(ENOMEM); } for (i = 0; i < sh->num_entry_point_offsets; i++) { unsigned val = get_bits_long(gb, offset_len); - sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size + sh->entry_points[i].offset = val + 1; // +1; // +1 to get the size } if (s->threads_number > 1 && (s->ps.pps->num_tile_rows > 1 || s->ps.pps->num_tile_columns > 1)) { s->enable_parallel_tiles = 0; // TODO: you can enable tiles in parallel here @@ -2657,29 +2654,31 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) offset = (lc->gb.index >> 3); - for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) { + for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_points[0].offset; j < nal->skipped_bytes; j++) { if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { startheader--; cmpt++; } } + /* Convert the entry_points offsets from being pre-0x03-escaping + * to post-0x03-escaping and set sizes. */ for (i = 1; i < s->sh.num_entry_point_offsets; i++) { - offset += (s->sh.entry_point_offset[i - 1] - cmpt); + offset += (s->sh.entry_points[i - 1].offset - cmpt); for (j = 0, cmpt = 0, startheader = offset - + s->sh.entry_point_offset[i]; j < nal->skipped_bytes; j++) { + + s->sh.entry_points[i].offset; j < nal->skipped_bytes; j++) { if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) { startheader--; cmpt++; } } s->sh.entry_points[i - 1] = (EntryPoint){ - .size = s->sh.entry_point_offset[i] - cmpt, + .size = s->sh.entry_points[i].offset - cmpt, .offset = offset }; } if (s->sh.num_entry_point_offsets != 0) { - offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt; + offset += s->sh.entry_points[s->sh.num_entry_point_offsets - 1].offset - cmpt; if (length < offset) { av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n"); res = AVERROR_INVALIDDATA; diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 76ad262558..9ac04555f4 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -304,7 +304,6 @@ typedef struct SliceHeader { unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand - unsigned *entry_point_offset; EntryPoint *entry_points; int num_entry_point_offsets;