From patchwork Fri Apr 19 15:58:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48169 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c906:b0:1a9:af23:56c1 with SMTP id gx6csp719962pzb; Fri, 19 Apr 2024 08:58:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVk7961m6mrSncAgw8ZAFRDqT/sB+fQbPsQPeYSddqqIBmZE66Cz4rdVPzSLEVCxaGH+BWslgMoY2msARTBqt24KVeCKu74JPSlFw== X-Google-Smtp-Source: AGHT+IFb46alRz0eVBhz4/82I4RBoL38dsJsr97WmTjBPFVf6WJ24lMy9RqBbQ9og/RMXKG6aVSu X-Received: by 2002:a05:6402:2695:b0:571:e17e:3208 with SMTP id w21-20020a056402269500b00571e17e3208mr648728edd.3.1713542313834; Fri, 19 Apr 2024 08:58:33 -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 t9-20020a50ab49000000b0056e71418614si2208650edc.505.2024.04.19.08.58.33; Fri, 19 Apr 2024 08:58:33 -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=uUCh4CEl; 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 6EC6768D3CC; Fri, 19 Apr 2024 18:58:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2020.outbound.protection.outlook.com [40.92.89.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0A98468D33C for ; Fri, 19 Apr 2024 18:58:24 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P8SMOmxgJoaJZG36SgtXbpUU9sCByYHg4yjbzZakb6/H7brROLvC9fwht2FzoQ+AolXtIB4gnKpOqYm/lmhBP8H3l0+3zUvafNQBbipsr1PrvROil3Xc4nbYoPhrAQpQfTavRALHE/SHtoyOtHxBpqbwGKxN6pFTSVkYLg4J67SbDe4+TXViaeUHXYNMfXqj5CO1tcqJw0EDOxAdE4SBS/oR4HAzNeiOTFlsk7zD6MQrpUmbVwbOTGkvozXPHDsEhVQ65KWyuiLEsKRWWf9NZLLj/5Y3OierXM4V1Z588Cj7njnwnbbfb77qmhKx/d7IOIwP8+NqO5LXkClEUaHEBg== 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=1bNEwAwsljnh7JR+C6BMD4BDQcYyPH1/2VLpkN+3a6M=; b=J/Kj7zfRAkBhn6xLQKz//Sy04IQxYLq9M1JXNztNbLrMxu8e39gYprbaSUfT9migOf9MWIp3Y9QQ+m/HcbjkJPLz1KYu/LJYDXhYabt8Uwwy+gT5gkWtAuz1PwpTOe/z7gPuyURreoUjV6U19FciydgMmmGpZGf2zHV0aBHImm5/iuc3YVuZ41pGAC/ZEFx1pQvlbcmgs9jA1z6rsOrzlh3t0uMm15WTJxEih2laoEGF1aEHNcP9hemZcRJSKIvd9ZGyDjHrPQvHoAb589/ENXdoMdDMv8TaqiWmnxcncRfVEopZZnYdHrnmZ/fZNdqFrL6o0Pl9jxzOBYJp65isOA== 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=1bNEwAwsljnh7JR+C6BMD4BDQcYyPH1/2VLpkN+3a6M=; b=uUCh4CElhj01G4qYHTzMtr4ZVBYxLKlE8U9yOoyaMsxPihCXW1nirhbD/iBSFhU1xhkX1Yp8BohEs4SLQo+IqEFMGy7qsgNDuDk8zNm1r3q75U0o1U8hSUA4+cVdXDpCGORFE3x8gX9rLHmjZSU8MDEOJn7DwG4fVSrOY6VycneDdEKbazqyVABwBw0mFBWOWBX9NJcxhe/3tWR8duABDkAd9yKKG4J5Iw4BLsB7ua2G4MISx/c54fnGO9scHVW4FyWgSd4VMrF90WKIO+yYNpSc4tVMIL7KTQ2Likyb+TPQmdD7ubrk2pvoj4JJ1ZQUJRT2pZEoy9+jSgTXvP0BIw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0098.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:171::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.39; Fri, 19 Apr 2024 15:58:22 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb%3]) with mapi id 15.20.7409.042; Fri, 19 Apr 2024 15:58:22 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Apr 2024 17:58:10 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 X-TMN: [QGBnJhxorLYtCws2F8fVKe8TSzkMx/ucuX5Mh96Txjs=] X-ClientProxiedBy: ZR2P278CA0088.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:65::19) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240419155814.1104217-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0098:EE_ X-MS-Office365-Filtering-Correlation-Id: 2db4c8ab-b33d-4883-5cc2-08dc608989f3 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cXUIrAkULVkKxWHZGk5ft0QNRI01kp+WK59s6u2I0ZPAjCS0JUsfraSfrxwI9/1Jal0Zh31qdIAR8F/+jaCmEcoAt2QlAJnRc4hmp0X6/ujjb70xlECTwU1pjQg/K3WW08ydZS8TdclrwtsG7YWy4utEoTerdted3rKTr9UvqYiH83lFbJ6frS7GfrF0UtlHboe7Yi9Q475uFTghLZL7vzpAOk7Wvw9NYhdCJqLyk6CvpwByreQpPxp7S0J6xSgu2HoGLNB1EXrWYp/HigorZz/Y5akvLFSAsLsh8X389OqXf4xdLYc0Nqtem5q21aso3lNbYdfJMdQDI7g4EibJTvW9fKJ9lDBeS6uoV2dXZDO+sbD7bjZtb/2UObulxiUcZgu62WZ18CHCRXGFY6AgiU+jp6dIj+BBCEycMuCrSqbZPg72jHkfT7RAKOpV4dNdALEkUUTGqkQyp9Ol53GHhALiqmOcne0scTJxreu5PX09E0V+XxMWdbUdBgrredB/urxs46IzeIXGCPJm08heNColAOP4QZ9Tu0vYaIKUA3AfCu6rJVVmJoUHFWvWrztuOBF/jYQBXpjEEDn1XERRtjsgRN9VJDpgQece1hAyRpCti+vdYrKwDRDny7ZbU9vD X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-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KBe8yQFXcaQ7+O7zWKwI6Eou+w6lSS6rDnzba3iuxo9L9JaflnP05J7q8cDnrw+NycSRODwFT6wb2DtRFhmWwKMbj7BV40KDImW3/+o5mAZX7+2Hjk6dKRM32QzyhsEivNaoaUdVkuKnqHGY4vfAOyDyLTmceHiAH3fzX085/3POVs+gFw32OhjKQF7uvcL6Fr+FoCX7zjsBG8xkK453UCdVTBP2MxASnpyaFMJjQHGAYYTQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2db4c8ab-b33d-4883-5cc2-08dc608989f3 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 15:58:22.3173 (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: PR3P250MB0098 Subject: [FFmpeg-devel] [PATCH 1/5] avcodec/progressframe: Explain how unnamed union can simplify accesses 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: JlWt0cJ6hrLs This relies on the common initial seqence guarantee (and on C11 support for unnamed members). Signed-off-by: Andreas Rheinhardt --- Alternatively, we could rely on type punning via unions and even use union { AVFrame *const f; ProgressFrame pf; }; libavcodec/progressframe.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavcodec/progressframe.h b/libavcodec/progressframe.h index dc841f30d2..428a461659 100644 --- a/libavcodec/progressframe.h +++ b/libavcodec/progressframe.h @@ -58,6 +58,18 @@ struct AVCodecContext; +/** + * The ProgressFrame structure. + * Hint: It is guaranteed that the AVFrame pointer is at the start + * of ProgressFrame. This allows to use an unnamed + * union { + * struct { + * AVFrame *f; + * }; + * ProgressFrame pf; + * }; + * to simplify accessing the embedded AVFrame. + */ typedef struct ProgressFrame { struct AVFrame *f; struct ProgressInternal *progress; From patchwork Fri Apr 19 16:07:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48170 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c906:b0:1a9:af23:56c1 with SMTP id gx6csp727855pzb; Fri, 19 Apr 2024 09:08:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUAH9fDXOx5oJ/KxyudcYxA+BFDZ8Rl8G0UKMVBuKQb79wgoyQl5scIIRF0QV7xSv3pTKIhkYSmrcPrT/lrr2eZuzxpEdVKzXyr/g== X-Google-Smtp-Source: AGHT+IHAvV5N0Uk1C2VrBPV6VSbkgSD/1rOmsRrGDQ+lO+5NSloFprN0D1a3omZyzK9kQc5xdyt6 X-Received: by 2002:a17:906:6d05:b0:a55:6ad1:9a52 with SMTP id m5-20020a1709066d0500b00a556ad19a52mr1941566ejr.2.1713542882095; Fri, 19 Apr 2024 09:08:02 -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 v6-20020a170906488600b00a555bbe951bsi2362388ejq.867.2024.04.19.09.07.54; Fri, 19 Apr 2024 09:08:02 -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=Q+7HkdWg; 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 468E868D3C9; Fri, 19 Apr 2024 19:07:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02olkn2075.outbound.protection.outlook.com [40.92.48.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B65BB68D308 for ; Fri, 19 Apr 2024 19:07:44 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gfbTnfqppmQagK0K3sZ3OIJceJbLc2oSR6QHyyrfD56JgjSXww9d8EWxL+22LAC4eb6rtEfQH4Iw3UPNQBUPTgDEnj0qKvN5JWRMRdGOQtphQEQRA6RccCVuoIPW7tjgrJfSKS0g+vXTB2n7gEhsOJmRg7eYfGJKdPGSihl6DaKORem5RwQYN/UDV3x4FchRQlIG4wMTTUVyaSUefL/JCb9rTlksRwEccQrMBskHjB2jLpZHJJuUao7wccGlfc+Nm56R7Z7O4xc1xRSJKXN1sN0dhfDn0AMu5RsynNrhW1MwL9wLBUlUbjjbN1xgq/hmkiGwuWEv/LUCG1Fp4iTi1g== 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=dEZkyYT38dHp/Q2hh5q3eyaycgUdCV6K+QxBMXl/e48=; b=FbACK3lYqqYmhlEQdwABW2/qHVlhL1QWcBJtsRd2Bkuzp6eqs9ajxTJ9fWdpvV1PA9bWYUI7TLrkjymBEc/HZ6PWUsafRumThkVBDrkBAJ6tYA8VDpxNWzcCV+cnClsxXTc+mduuHvxfaxhgDwbeFrHV+sL83xUp/XiZBZSbF4mgzhrsUTDg81pA8A5YM2xAL8hLAyeB6D+8k1+3oThgCYPXvwBdob8s4+eb17xlB0yY1oOUTeaZbCigT7USalR9yAXF0jqOAFdPugNlZJa1uGCtuqrBLsFPa5tvYghpKQwRDOK4o9jfEstwxW7fBd3IfXyh47b6bmYx1dHeWR2ZkQ== 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=dEZkyYT38dHp/Q2hh5q3eyaycgUdCV6K+QxBMXl/e48=; b=Q+7HkdWgKvW9SfPAMeYCLtEqSVojmGnEFxF8CUjG6E846h2juTuF4V9y67x+pLhFby4ZyrljgOckk4E9ClOr38U9ZYdyumyXuJg5b+c4Q7KZk8J0ng4cDXjE4FGe6Z/KiPeY/NBZBCBbnn7oFpnwJAZBissC44wEP05zOB6sHLRxlkYoCGh2hl/QremWTZIoh/4EkNDhNTTg5GHKYaI8Z0+r6jSO5c7q28m+4w+Vq0CoGrv9LuU2RtmHFuEROTNStMxFVUIlluPu9ugC0M7TKBPEOM6R0uCtiAB4x3D3A//M5KeCJt0iqfLMRzxm//zMB2gHRmV6pkGQABKThjRKSg== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AM8P250MB0138.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:321::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.41; Fri, 19 Apr 2024 16:07:43 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb%3]) with mapi id 15.20.7409.042; Fri, 19 Apr 2024 16:07:41 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Apr 2024 18:07:31 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [dRYHdqvGL2EA8MUZ1kBQ+HBXlqJigSrle+E16WYCt+M=] X-ClientProxiedBy: ZR2P278CA0006.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:50::12) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240419160734.1104837-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AM8P250MB0138:EE_ X-MS-Office365-Filtering-Correlation-Id: 85c3a81e-7419-43bc-91eb-08dc608ad76f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wt8cYyexq/divEM5BjZZMB5ni0tJwBbVqttSj4RpyumbYSK6eyCAFN77zKqnhGUHYCsfBZEHkNd0KVrJKms48joVRoimPEYjH8XGJNg78bu5zM/pLmsKQkJKJ/Wha3EvIG+E44ojPGrc582KhtY3e4Fu0GFXDEgb5guvfddv+OgioLmUbrBdd9A205WoJiXSiyPjXJXGQd3Pmrn09IGhwptrJNm5/nTmWb8ZroH6gPrcsuoniLZ7OnzxWAVBNfsGkp27PWljXdHExCgDzi/w1qbvtYJKt62OtAr66ixJh8C8bKriPmJ/FsO09wdeddksiC82V8JhKVIx9dcUzPn15dB5rTAe+nDTGzD+IWqj36RIcQg/3w+MDFwBFnAeiZAK16/txn5VfjXq9Qe6lD51CxtTMW/3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yvoVQdyHHet+KrtnBdTsP3AdOwLePVG7upbnfZcEh0FJ+bBY+NxsvXZmmxD5oyUS4ZrSoDgUgYB+clCFALmF9rr6UmDhbuWTCfJrOE2mrOJeHDm2OuipXbChv4lGn8bt1Tqu811ww9t4yqyPRGk17UoW6BpmfnFoegJoHCFqKACfcYZjosx9JZSXcf0a2QRw1ZPDJakLhh/tlKnONRB/JsssUoPiusHsWDFDSS+E9a6MSks+WARUEy38qsUlbebqz3qj+edr9nOWfakDD5+aYOelcw/d+aCJ4kJ01z7NmR8T2Ft8Mrbwc4OorWX+M/fvhoZy2XVEcGF1EivrcdZ0Z0lJGV9FCCzAGNEVUEkqbJ7G+tXeBCYFqgW6FEcVDsIYBDpRAFr6VIv+TagMPEbJKx6TPF11jAbpZEs5zOMqt+3W30pfyTD4lWGGBb47Ovw+p7BHZfk7jqr+8AAc8BGx2RI+OMMNoZGIICdTx6jT6A/3g82Fg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85c3a81e-7419-43bc-91eb-08dc608ad76f X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 16:07:41.8235 (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: AM8P250MB0138 Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/hevcdec: Use union for AVFrame* and ProgressFrame 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: doYgweDvdqBu It avoids having to sync ProgressFrame.f and the pointer typically used to access the AVFrame. Signed-off-by: Andreas Rheinhardt --- libavcodec/hevc_refs.c | 2 -- libavcodec/hevcdec.c | 1 - libavcodec/hevcdec.h | 8 ++++++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index 192d311696..8da9ec982a 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -34,7 +34,6 @@ void ff_hevc_unref_frame(HEVCFrame *frame, int flags) frame->flags &= ~flags; if (!frame->flags) { ff_progress_frame_unref(&frame->tf); - frame->frame = NULL; av_frame_unref(frame->frame_grain); frame->needs_fg = 0; @@ -87,7 +86,6 @@ static HEVCFrame *alloc_frame(HEVCContext *s) AV_GET_BUFFER_FLAG_REF); if (ret < 0) return NULL; - frame->frame = frame->tf.f; frame->rpl = ff_refstruct_allocz(s->pkt.nb_nals * sizeof(*frame->rpl)); if (!frame->rpl) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 1974bf9cb3..50433957f7 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -3418,7 +3418,6 @@ static int hevc_ref_frame(HEVCFrame *dst, HEVCFrame *src) int ret; ff_progress_frame_ref(&dst->tf, &src->tf); - dst->frame = dst->tf.f; if (src->needs_fg) { ret = av_frame_ref(dst->frame_grain, src->frame_grain); diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 24fcbf440a..e82daf6679 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -352,9 +352,13 @@ typedef struct DBParams { #define HEVC_SEQUENCE_COUNTER_INVALID (HEVC_SEQUENCE_COUNTER_MASK + 1) typedef struct HEVCFrame { - AVFrame *frame; + union { + struct { + AVFrame *frame; + }; + ProgressFrame tf; + }; AVFrame *frame_grain; - ProgressFrame tf; int needs_fg; /* 1 if grain needs to be applied by the decoder */ MvField *tab_mvf; ///< RefStruct reference RefPicList *refPicList; From patchwork Fri Apr 19 16:07:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48171 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c906:b0:1a9:af23:56c1 with SMTP id gx6csp728086pzb; Fri, 19 Apr 2024 09:08:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXxvjt7ECKobeYGcSMpD6blpaIqbYWTG73ABTZhLAAW76r1O9r730Sm8b9wQUrhWsWFGVFbhXwYK+PygRoO0K1nm78FUHaDBKQ3LA== X-Google-Smtp-Source: AGHT+IHh/j+BRdC0mK5xC1Cegl0UUMe6kuMz3B23wb4SphA7PvIQYuWB97jlshfXDfIM6QvTujVO X-Received: by 2002:a17:906:1f48:b0:a51:cc51:7931 with SMTP id d8-20020a1709061f4800b00a51cc517931mr1609866ejk.5.1713542899860; Fri, 19 Apr 2024 09:08:19 -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 bm12-20020a170906c04c00b00a521c17dc47si2246637ejb.179.2024.04.19.09.08.04; Fri, 19 Apr 2024 09:08:19 -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="VsSB7/SJ"; 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 5AC4968D3E6; Fri, 19 Apr 2024 19:07:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02olkn2075.outbound.protection.outlook.com [40.92.48.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CD3FF68D3B4 for ; Fri, 19 Apr 2024 19:07:49 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jjffNKj7HXBOorfjk4cHKy25beKrZNDS8mA9HnlnhYL81DnpkCGt+jRxEJu3rte/sg9xHNAYmHougNem7InDC8mqvbeKLr/DyeD7oCcXZB+3TYqmoshQE/xFXZyAVxOiD/E9eCc3osR+GGZEBsPSDpsLZotoEHs5oNzFol3f4cKYRw7AgAYcDTH+SbLm4k7cEP+s9jPlcZ8u1fIzGU2Zz9PrnUAn7ebF94PdNrKETyPYelTGAsXiXAWaIgHklP1OP9ZVxZv6JxiCPK+DwY9ZlDGQBePTNT6AzzVivf9KDI4adDMm/NVdpmipyrIIkFoZMeSUdzb/bOoFrWLLH6pB+g== 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=q/lqxLOGwPP5H7c/F2A5noxra1PNe485mW7kbjxNZeQ=; b=EsFeufp8+0QZP3POlAeTMMNBfZPTemquWWMDAINqUCwtmD8as5hfo6T54jZ8ncYsAZEWg2P1uDtn3qj41E8r8eNnng8x7lvej8ohVq176oMXPGRENeg3S+nTc1B8pdllj0HiYHtzv9jd+MKirhJ36z5kxyBVu3iPUBTMs7z6hKqFfeYmBqlLWYy6CLqbPkfhAyszZHEj84KgjKucZb1wxBlagrnbDzlojSTbmUxq0ToRBs5CF0XQ48G75yrSYBOtVVXmlFU23AzLf/SffcwnWBADnxHi6dCUK2dHJyWzrTxic/9MRfRriW4QKZKtA85Cav2FhIjEDXnZlJAo43L54g== 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=q/lqxLOGwPP5H7c/F2A5noxra1PNe485mW7kbjxNZeQ=; b=VsSB7/SJZ4X8oV0Ylf73fMbIOc2mlmKiP/qPqCQGTCyPKaM4ScrNWkYneDzKW44/UIr4Qo/T4QFwcpJkY2+2vSuxLi73ZO/WBeAr0pY4K39GPr+gwbRA0TBopkmO5satlrod2aXyHk9n89luvZW5YHMxs2aRu9RWYRaxt4kXxgAtclXcCXTUi85lrzQ3YDA0UI2QJWNWRhZBLMupJ7fFd6RN0Uz+sxB8d3+/1hXRLTDJSd0YHfq/kKIKLnG7299DhrTXSm6q+cINuUa8kSsCXfmCuFfrEJaNpScrWnnPLvlIJDIghJGmxxu0X0UOHHcsq6DIeTIdR2PUf1h8q/nhJQ== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AM8P250MB0138.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:321::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.41; Fri, 19 Apr 2024 16:07:48 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb%3]) with mapi id 15.20.7409.042; Fri, 19 Apr 2024 16:07:48 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Apr 2024 18:07:32 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [Ei/z1OrlZde1rR9WrwB+3KnLhfoNFxyqUelu6RngypI=] X-ClientProxiedBy: ZR2P278CA0006.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:50::12) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240419160734.1104837-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AM8P250MB0138:EE_ X-MS-Office365-Filtering-Correlation-Id: f4bed31b-bbcd-43c1-099f-08dc608adb5c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mTbNXnF33qFVI6KWT5Z+8Qo/P0IST3lD8zmR1y4QYLOuUDgnz9rCW65YF8/K8x30G5Rzpc2ZWWKo0QBqJ9qYfou8dP6EzzNGLSHwuMFBfCkL8/IB5wkw2Krt+wduTndDagKeUSk32sFCajt3YLjTDqGv3O9h/dx7sTQnCG2/LIXzXZOzCed68IiTdqHnv0ZW0dNtv1Kn/Qh8wApc6LzoFH2m14lmVdjevItHrFoJQ3sv0MKwnzuetLHaUrslMW9g6XAILuVvlITeyT95wGeQew54Q36501mTdskZeYx/uusEIs3vALzbf+tSqXroHdDz51l+aH+O+PXqP3b1lOvF8h3R22+mNwUBCeRzaMTHfjrqiP53T/16W6o+6lJBmb6k8Z3l9iobI02VqbuK+iXrK/Z6+jW6B4TM0NJqMDZ/lPN7wzLys4bgvPwaYRixL41KJKAkiXmMt5Jsz5+XXncL/gzJyyjOBHtwQimrmUgHSEJQjsQkIvyqnwkLui5WssIAzlRqtnFKXWJS9VTpBB5lRDKRiwF/jCSyCiML3OfQIBvf/Fs/MQ1ouHTaqdXn0shHw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2N7RzjGTOqrDAHlAlVhMkEa5XBmM/uzcnMLE+3XX+X/LszSCc2jKKOfCBw+qxLI6OZ1Wp7ZGKPr+1xmfVPobkyBCEsiX1/46sxgVBvEYb+Hhhh6xzWfHokPNK9DX71l2U/RlSvxeO+HysHyfThxoQgvpi/hnFxni00gBOpTrjEE2+Ux2Rbsan2g79KdIAsnKBOHCFzCUQ7U98ltZ375g66nMMKUPLRHjNycqNw4ILbJY0uek7JOx/VlLVFHwgcJ3jN5/s73UnvrgviJr+Y9oSi2PQWrn07rW+wlVmrUobFY1b6hsTzXF9+qzI6+337T5eNtK8FK/a2YPXIQPBKpES7L6w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4bed31b-bbcd-43c1-099f-08dc608adb5c X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 16:07:48.3795 (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: AM8P250MB0138 Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/av1dec: Use ProgressFrames 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: zBp2DfpaQ+Pe AV1 can put a frame into multiple reference slots; up until now, this involved creating a new reference to the underlying AVFrame; therefore av1_frame_ref() could fail. This commit changes this by using the ProgressFrame API to share the underlying AVFrames. (Hint: vaapi_av1_surface_id() checked whether the AV1Frames contained in the AV1DecContext were NULL or not (of course they were not); this has been changed to actually check for whether said AV1Frame is blank or not.) Signed-off-by: Andreas Rheinhardt --- 1. The AV1 patches are basically untested (apart from FATE and compilation). Could someone please test them? 2. An alternative is to use an array of AV1Frames and an array of pointers to AV1Frames. The former have refcounts where each pointer to an AV1Frame is considered to own a reference. av1_frame_ref() would boil down to incrementing a refcount and setting a pointer. 3. Is there a specific reason that vulkan checked pict_type instead of setting whether e.g. buf[0] or data[0] was set (as is customarily done)? libavcodec/av1dec.c | 92 +++++++++++------------------------------ libavcodec/av1dec.h | 8 +++- libavcodec/dxva2_av1.c | 8 ++-- libavcodec/nvdec_av1.c | 4 +- libavcodec/vaapi_av1.c | 6 +-- libavcodec/vdpau_av1.c | 7 ++-- libavcodec/vulkan_av1.c | 4 +- 7 files changed, 47 insertions(+), 82 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index b4b741054a..2a1a249bc4 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -38,8 +38,8 @@ #include "itut35.h" #include "hwconfig.h" #include "profiles.h" +#include "progressframe.h" #include "refstruct.h" -#include "thread.h" /**< same with Div_Lut defined in spec 7.11.3.7 */ static const uint16_t div_lut[AV1_DIV_LUT_NUM] = { @@ -672,7 +672,7 @@ static int get_pixel_format(AVCodecContext *avctx) static void av1_frame_unref(AV1Frame *f) { - av_frame_unref(f->f); + ff_progress_frame_unref(&f->pf); ff_refstruct_unref(&f->hwaccel_picture_private); ff_refstruct_unref(&f->header_ref); f->raw_frame_header = NULL; @@ -683,20 +683,16 @@ static void av1_frame_unref(AV1Frame *f) f->coded_lossless = 0; } -static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src) +static void av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src) { - int ret; - ff_refstruct_replace(&dst->header_ref, src->header_ref); dst->raw_frame_header = src->raw_frame_header; - if (!src->f->buf[0]) - return 0; + if (!src->f) + return; - ret = av_frame_ref(dst->f, src->f); - if (ret < 0) - goto fail; + ff_progress_frame_ref(&dst->pf, &src->pf); ff_refstruct_replace(&dst->hwaccel_picture_private, src->hwaccel_picture_private); @@ -725,12 +721,6 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s sizeof(dst->ref_frame_sign_bias)); memcpy(dst->order_hints, src->order_hints, sizeof(dst->order_hints)); - - return 0; - -fail: - av1_frame_unref(dst); - return AVERROR(ENOMEM); } static av_cold int av1_decode_free(AVCodecContext *avctx) @@ -738,16 +728,9 @@ static av_cold int av1_decode_free(AVCodecContext *avctx) AV1DecContext *s = avctx->priv_data; AV1RawMetadataITUTT35 itut_t35; - for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) { - if (s->ref[i].f) { - av1_frame_unref(&s->ref[i]); - av_frame_free(&s->ref[i].f); - } - } - if (s->cur_frame.f) { - av1_frame_unref(&s->cur_frame); - av_frame_free(&s->cur_frame.f); - } + for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) + av1_frame_unref(&s->ref[i]); + av1_frame_unref(&s->cur_frame); av_buffer_unref(&s->seq_data_ref); ff_refstruct_unref(&s->seq_ref); ff_refstruct_unref(&s->header_ref); @@ -863,16 +846,6 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) s->pkt = avctx->internal->in_pkt; s->pix_fmt = AV_PIX_FMT_NONE; - for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) { - s->ref[i].f = av_frame_alloc(); - if (!s->ref[i].f) - return AVERROR(ENOMEM); - } - - s->cur_frame.f = av_frame_alloc(); - if (!s->cur_frame.f) - return AVERROR(ENOMEM); - ret = ff_cbs_init(&s->cbc, AV_CODEC_ID_AV1, avctx); if (ret < 0) return ret; @@ -934,7 +907,8 @@ static int av1_frame_alloc(AVCodecContext *avctx, AV1Frame *f) return ret; } - if ((ret = ff_thread_get_buffer(avctx, f->f, AV_GET_BUFFER_FLAG_REF)) < 0) + ret = ff_progress_frame_get_buffer(avctx, &f->pf, AV_GET_BUFFER_FLAG_REF); + if (ret < 0) goto fail; frame = f->f; @@ -1211,23 +1185,17 @@ FF_ENABLE_DEPRECATION_WARNINGS return 0; } -static int update_reference_list(AVCodecContext *avctx) +static void update_reference_list(AVCodecContext *avctx) { AV1DecContext *s = avctx->priv_data; const AV1RawFrameHeader *header = s->raw_frame_header; - int ret; for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) { if (header->refresh_frame_flags & (1 << i)) { av1_frame_unref(&s->ref[i]); - if ((ret = av1_frame_ref(avctx, &s->ref[i], &s->cur_frame)) < 0) { - av_log(avctx, AV_LOG_ERROR, - "Failed to update frame %d in reference list\n", i); - return ret; - } + av1_frame_ref(avctx, &s->ref[i], &s->cur_frame); } } - return 0; } static int get_current_frame(AVCodecContext *avctx) @@ -1358,20 +1326,12 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) if (s->raw_frame_header->show_existing_frame) { av1_frame_unref(&s->cur_frame); - ret = av1_frame_ref(avctx, &s->cur_frame, - &s->ref[s->raw_frame_header->frame_to_show_map_idx]); - if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Failed to get reference frame.\n"); - goto end; - } + av1_frame_ref(avctx, &s->cur_frame, + &s->ref[s->raw_frame_header->frame_to_show_map_idx]); - ret = update_reference_list(avctx); - if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Failed to update reference list.\n"); - goto end; - } + update_reference_list(avctx); - if (s->cur_frame.f->buf[0]) { + if (s->cur_frame.f) { ret = set_output_frame(avctx, frame); if (ret < 0) av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n"); @@ -1392,7 +1352,7 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) s->cur_frame.spatial_id = header->spatial_id; s->cur_frame.temporal_id = header->temporal_id; - if (avctx->hwaccel && s->cur_frame.f->buf[0]) { + if (avctx->hwaccel && s->cur_frame.f) { ret = FF_HW_CALL(avctx, start_frame, unit->data, unit->data_size); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "HW accel start frame fail.\n"); @@ -1418,7 +1378,7 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) if (ret < 0) goto end; - if (avctx->hwaccel && s->cur_frame.f->buf[0]) { + if (avctx->hwaccel && s->cur_frame.f) { ret = FF_HW_CALL(avctx, decode_slice, raw_tile_group->tile_data.data, raw_tile_group->tile_data.data_size); if (ret < 0) { @@ -1469,7 +1429,7 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) if (raw_tile_group && (s->tile_num == raw_tile_group->tg_end + 1)) { int show_frame = s->raw_frame_header->show_frame; - if (avctx->hwaccel && s->cur_frame.f->buf[0]) { + if (avctx->hwaccel && s->cur_frame.f) { ret = FF_HW_SIMPLE_CALL(avctx, end_frame); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "HW accel end frame fail.\n"); @@ -1477,13 +1437,9 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) } } - ret = update_reference_list(avctx); - if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Failed to update reference list.\n"); - goto end; - } + update_reference_list(avctx); - if (s->raw_frame_header->show_frame && s->cur_frame.f->buf[0]) { + if (s->raw_frame_header->show_frame && s->cur_frame.f) { ret = set_output_frame(avctx, frame); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Set output frame error\n"); @@ -1597,7 +1553,9 @@ const FFCodec ff_av1_decoder = { .close = av1_decode_free, FF_CODEC_RECEIVE_FRAME_CB(av1_receive_frame), .p.capabilities = AV_CODEC_CAP_DR1, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | + FF_CODEC_CAP_USES_PROGRESSFRAMES, .flush = av1_decode_flush, .p.profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), .p.priv_class = &av1_class, diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h index 79a0be510b..66a732d781 100644 --- a/libavcodec/av1dec.h +++ b/libavcodec/av1dec.h @@ -32,9 +32,15 @@ #include "cbs.h" #include "cbs_av1.h" #include "dovi_rpu.h" +#include "progressframe.h" typedef struct AV1Frame { - AVFrame *f; + union { + struct { + struct AVFrame *f; + }; + ProgressFrame pf; + }; void *hwaccel_picture_private; ///< RefStruct reference diff --git a/libavcodec/dxva2_av1.c b/libavcodec/dxva2_av1.c index 184a922fd8..5b95f99c9b 100644 --- a/libavcodec/dxva2_av1.c +++ b/libavcodec/dxva2_av1.c @@ -138,9 +138,9 @@ int ff_dxva2_av1_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACont int8_t ref_idx = frame_header->ref_frame_idx[i]; AVFrame *ref_frame = h->ref[ref_idx].f; - pp->frame_refs[i].width = ref_frame->width; - pp->frame_refs[i].height = ref_frame->height; - pp->frame_refs[i].Index = ref_frame->buf[0] ? ref_idx : 0xFF; + pp->frame_refs[i].width = ref_frame ? ref_frame->width : 0; + pp->frame_refs[i].height = ref_frame ? ref_frame->height : 0; + pp->frame_refs[i].Index = ref_frame ? ref_idx : 0xFF; /* Global Motion */ pp->frame_refs[i].wminvalid = h->cur_frame.gm_invalid[AV1_REF_FRAME_LAST + i]; @@ -151,7 +151,7 @@ int ff_dxva2_av1_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACont } for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { AVFrame *ref_frame = h->ref[i].f; - if (ref_frame->buf[0]) + if (ref_frame) pp->RefFrameMapTextureIndex[i] = ff_dxva2_get_surface_index(avctx, ctx, ref_frame, 0); } diff --git a/libavcodec/nvdec_av1.c b/libavcodec/nvdec_av1.c index b0b013846e..4efa420e66 100644 --- a/libavcodec/nvdec_av1.c +++ b/libavcodec/nvdec_av1.c @@ -251,8 +251,8 @@ static int nvdec_av1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u AVFrame *ref_frame = s->ref[ref_idx].f; ppc->ref_frame[i].index = ppc->ref_frame_map[ref_idx]; - ppc->ref_frame[i].width = ref_frame->width; - ppc->ref_frame[i].height = ref_frame->height; + ppc->ref_frame[i].width = ref_frame ? ref_frame->width : 0; + ppc->ref_frame[i].height = ref_frame ? ref_frame->height : 0; /* Global Motion */ ppc->global_motion[i].invalid = !frame_header->is_global[AV1_REF_FRAME_LAST + i]; diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c index 1f9a6071ba..1f563483b9 100644 --- a/libavcodec/vaapi_av1.c +++ b/libavcodec/vaapi_av1.c @@ -46,7 +46,7 @@ typedef struct VAAPIAV1DecContext { static VASurfaceID vaapi_av1_surface_id(AV1Frame *vf) { - if (vf) + if (vf->f) return ff_vaapi_get_surface_id(vf->f); else return VA_INVALID_SURFACE; @@ -132,7 +132,7 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, goto fail; pic->output_surface = ff_vaapi_get_surface_id(ctx->tmp_frame); } else { - pic->output_surface = vaapi_av1_surface_id(&s->cur_frame); + pic->output_surface = ff_vaapi_get_surface_id(s->cur_frame.f); } memset(&pic_param, 0, sizeof(VADecPictureParameterBufferAV1)); @@ -142,7 +142,7 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, .bit_depth_idx = bit_depth_idx, .matrix_coefficients = seq->color_config.matrix_coefficients, .current_frame = pic->output_surface, - .current_display_picture = vaapi_av1_surface_id(&s->cur_frame), + .current_display_picture = ff_vaapi_get_surface_id(s->cur_frame.f), .frame_width_minus1 = frame_header->frame_width_minus_1, .frame_height_minus1 = frame_header->frame_height_minus_1, .primary_ref_frame = frame_header->primary_ref_frame, diff --git a/libavcodec/vdpau_av1.c b/libavcodec/vdpau_av1.c index 80923092b9..b74ea6aa0c 100644 --- a/libavcodec/vdpau_av1.c +++ b/libavcodec/vdpau_av1.c @@ -219,7 +219,8 @@ static int vdpau_av1_start_frame(AVCodecContext *avctx, info->loop_filter_ref_deltas[i] = frame_header->loop_filter_ref_deltas[i]; /* Reference Frames */ - info->ref_frame_map[i] = ff_vdpau_get_surface_id(s->ref[i].f) ? ff_vdpau_get_surface_id(s->ref[i].f) : VDP_INVALID_HANDLE; + info->ref_frame_map[i] = s->ref[i].f && ff_vdpau_get_surface_id(s->ref[i].f) ? + ff_vdpau_get_surface_id(s->ref[i].f) : VDP_INVALID_HANDLE; } if (frame_header->primary_ref_frame == AV1_PRIMARY_REF_NONE) { @@ -235,8 +236,8 @@ static int vdpau_av1_start_frame(AVCodecContext *avctx, AVFrame *ref_frame = s->ref[ref_idx].f; info->ref_frame[i].index = info->ref_frame_map[ref_idx]; - info->ref_frame[i].width = ref_frame->width; - info->ref_frame[i].height = ref_frame->height; + info->ref_frame[i].width = ref_frame ? ref_frame->width : 0; + info->ref_frame[i].height = ref_frame ? ref_frame->height : 0; /* Global Motion */ info->global_motion[i].invalid = !frame_header->is_global[AV1_REF_FRAME_LAST + i]; diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index 49cd69d051..25ab4ecc70 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -284,7 +284,7 @@ static int vk_av1_start_frame(AVCodecContext *avctx, AV1VulkanDecodePicture *hp = ref_frame->hwaccel_picture_private; int found = 0; - if (ref_frame->f->pict_type == AV_PICTURE_TYPE_NONE) + if (!ref_frame->f) continue; for (int j = 0; j < ref_count; j++) { @@ -326,7 +326,7 @@ static int vk_av1_start_frame(AVCodecContext *avctx, const AV1Frame *ref_frame = &s->ref[idx]; AV1VulkanDecodePicture *hp = ref_frame->hwaccel_picture_private; - if (ref_frame->f->pict_type == AV_PICTURE_TYPE_NONE) + if (!ref_frame->f) ap->av1_pic_info.referenceNameSlotIndices[i] = AV1_REF_FRAME_NONE; else ap->av1_pic_info.referenceNameSlotIndices[i] = hp->frame_id; From patchwork Fri Apr 19 16:07:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48172 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c906:b0:1a9:af23:56c1 with SMTP id gx6csp728178pzb; Fri, 19 Apr 2024 09:08:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW+FmORV9VpIibuXLGu3rdbidM0814praiv9KL2SOvny+Axv6OKgRYbTOpWLllCHiXBzJKgOe+PXpAWPoiYynfIAadcu1pBH9HJ9g== X-Google-Smtp-Source: AGHT+IEnubDcU2GJTIvAraxRSIpQdmyKG5zCKo9ogeMp9gb0rRNblQL20M8AcGQdnAq8ayfFJ87C X-Received: by 2002:a50:aad4:0:b0:56d:fca8:d209 with SMTP id r20-20020a50aad4000000b0056dfca8d209mr1903993edc.10.1713542905733; Fri, 19 Apr 2024 09:08:25 -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 z13-20020a509e0d000000b005705bcdca17si2194838ede.444.2024.04.19.09.08.14; Fri, 19 Apr 2024 09:08:25 -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=ibaxc3gA; 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 7FC6868D404; Fri, 19 Apr 2024 19:08:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02olkn2075.outbound.protection.outlook.com [40.92.48.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E7AA568D3CD for ; Fri, 19 Apr 2024 19:07:54 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a4x4mIz7kUb7B3F/usVc98Uo3JrVA1UuL2QTNV4MIyt7lRhfj8Sgfc8a9ai+MQvkXrbnSmDVPRjX0rnbRw73JUDpUiz2U1impHeGnlXG2+/vxraQfRYVcfDg3gWoC824vZ7jWl+fw1ZUezOgvOU9DvoRi3hulmDUvzVl+0xaxJNHIXvCA38+Y4JVI5Y71JxjUkJIylYHvbPJKF2LJXXdSalgOvc98/uRJrtwYNJxtSFIlOi/yR3i/OzYRtRzzawvPB6YmiWEkY909B0gkOKtq6HOtUxAcxmvzAh4js/eRMLbj71qNooiSZ9VtGmNZA1F35hNKJCl0HJPdu49Ph8B+g== 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=+3AdSTByyAQIE47tacmmsatyDfmeuogLUitLOv9qVSM=; b=aRRzvuR1ujH7GrXV1l+JAaJnaTwhd20gZ2oSsijfv15d1K9dCBBC5Q0g1mUGiZGjof2AdD6m1CEScmEfy8atXEhB23NW6mJMZ3tr0YegV79KovOR7MkghTp57CKDhWwqv2gXKpMOyFfKd7EqdlRICIwUznOvoabavxyKGCN7f5+/5+nL/2m2tvxo0b7RsWIj/kWzmXvfgf4jrjeuijfp6XDQoRe5FxZTEbCr5KzXyPwXGbp4LkSbpURNOudk1ibpjLW2vihEtXX68mL3wayLD1MM6d0d2aWo10jgrI8czn7U5vRr/vkwEfqxUx9aasAYy9rMTY/FGRmiHDH8TROrIg== 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=+3AdSTByyAQIE47tacmmsatyDfmeuogLUitLOv9qVSM=; b=ibaxc3gA5P+8SjPiI7fadtofHXn/DSvFNz5CslLO1HBeFhZKqdbHGXR79haDSUrOpBBCZORuGsMoC6PWmLjI26z2OLlg5yWXQ5TS3D+lFc+oOanv1cXYepJSbtgKjWOs7DZQVLh8DXMq/CPO6TdeHOr3ypP7AdIFxukKf7VJ6JpKymVRiOLWznK9Y2Bk72wmy5mlZkQwtd9Tm+gJNFkmhPsIjYWySnC2EILzPTvr74De33UFe+FFy+mH8SiZhyDMjdH6rQ2oPijtzaR6iG6CD36+t9J/0V0oC4DYJQcDDfEzUK6zROlk5RQ9jrpTJehw9FFk8Xhxjp0GNQWyTvz5eg== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AM8P250MB0138.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:321::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.41; Fri, 19 Apr 2024 16:07:49 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb%3]) with mapi id 15.20.7409.042; Fri, 19 Apr 2024 16:07:49 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Apr 2024 18:07:33 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [lGflkRYoSJjrDyAsK7W7HC1CqJ1IosuIoMJlES2ejO8=] X-ClientProxiedBy: ZR2P278CA0006.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:50::12) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240419160734.1104837-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AM8P250MB0138:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f3b4f1f-c7fd-4801-d9d0-08dc608adc02 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2PqPlv0DwKpkkX9Vi6bt2aHIApUZQH4au4O8FXHRIpbfCJVrXQSd1y7bi940WKXivW3PeBI2F1q0JeiPea+i5sWlnQ+SfWgZ+TGDnkL5YFGoLvfw8FhCq2WCiZQMGcXz7eVItuewGe7PZkjlcXmIbdM235xOyZFlVwxTkO49A7gPu7NMO5Kmjvx0Ayp5ctH691wQda6BbMRQqnWQXQIFWbvmjubZdL4h/V7c3DjFY/yy+v6IIhs90Lcb8jxQNh4FE8DZvaZPPNjC74iAv62f3TzNMkqxu8ts6I9Sq1x9QUI+cZRWTmB4rKWjZQuRZK5+qhASomCJFJlHRzg3vj1uc61zGeTqKYSwm/a/NjA/5CmDKyaq/JVDFF9nFkxB41+AH3QHyCnPCj0K229eL8sR7aCtCuc/SWEevgwdcG6DrtplsnCRzIEgh2eFjQkzqOhCqUYtONDULVHle8EwlZ8nYzMKewYlARAjDgwl4f5jEoEPM3SmbZ6WTr4W5dWlWrGg094UjDT+JOYv+6A4dpVEM6dlX/vGuRtfvNk39d+PkWvqVpBsyB/dQkdi+ACautkAxzvszOLEQ7cqZ5zChpSHeZbUuUxkVdSoi/7TJOzljI/4HnUlbiWZEF3JtJjsCyJx X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam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qs+/7h3IbkKaEujgAztgnFHLVNrlnqwjGKDTJv9kJMqRetjmgcM+1Fs1BU6O36wyt3zQUBdDDOs+q57k4+zAceWNR1x7E5rwoZ8wwDBPtmbwrbzgQNhMxQt1NN4pNjMBDZlf2wE/N3HkytqW1OIQjeSFtgK5XtV0spLcZHlRpAvU1bdL4i+n3cNACT2vzcb6IDsfSNrko7Slql0FF5G2oaGsTzp0UQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f3b4f1f-c7fd-4801-d9d0-08dc608adc02 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 16:07:49.4377 (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: AM8P250MB0138 Subject: [FFmpeg-devel] [PATCH 4/5] avcodec/av1dec: Make av1_frame_replace() out of av1_frame_ref() 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: tBRxw8f/GvQ6 Signed-off-by: Andreas Rheinhardt --- libavcodec/av1dec.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 2a1a249bc4..21ba9d475d 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -683,16 +683,15 @@ static void av1_frame_unref(AV1Frame *f) f->coded_lossless = 0; } -static void av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src) +static void av1_frame_replace(AV1Frame *dst, const AV1Frame *src) { + av_assert1(dst != src); + ff_refstruct_replace(&dst->header_ref, src->header_ref); dst->raw_frame_header = src->raw_frame_header; - if (!src->f) - return; - - ff_progress_frame_ref(&dst->pf, &src->pf); + ff_progress_frame_replace(&dst->pf, &src->pf); ff_refstruct_replace(&dst->hwaccel_picture_private, src->hwaccel_picture_private); @@ -1191,10 +1190,8 @@ static void update_reference_list(AVCodecContext *avctx) const AV1RawFrameHeader *header = s->raw_frame_header; for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) { - if (header->refresh_frame_flags & (1 << i)) { - av1_frame_unref(&s->ref[i]); - av1_frame_ref(avctx, &s->ref[i], &s->cur_frame); - } + if (header->refresh_frame_flags & (1 << i)) + av1_frame_replace(&s->ref[i], &s->cur_frame); } } @@ -1324,10 +1321,8 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) s->raw_frame_header = &obu->obu.frame_header; if (s->raw_frame_header->show_existing_frame) { - av1_frame_unref(&s->cur_frame); - - av1_frame_ref(avctx, &s->cur_frame, - &s->ref[s->raw_frame_header->frame_to_show_map_idx]); + av1_frame_replace(&s->cur_frame, + &s->ref[s->raw_frame_header->frame_to_show_map_idx]); update_reference_list(avctx); From patchwork Fri Apr 19 16:07:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48173 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c906:b0:1a9:af23:56c1 with SMTP id gx6csp728312pzb; Fri, 19 Apr 2024 09:08:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVgRtL7929v/+iBTZx8FheAT0xhYT0CbeVHjALDgTNzU/lPC48jUeUbF4gmy986ap5rsQudIrwwADn5xtyYhxTggpr5meo3DHa8Sg== X-Google-Smtp-Source: AGHT+IHJ7pNjlapR/FkodaZbSnYPc1q/Wy2KqqZgoLhJw/ftjAHSLmNYj1DILdQJFSllwl/Q7ycS X-Received: by 2002:ac2:5f81:0:b0:518:956d:82cf with SMTP id r1-20020ac25f81000000b00518956d82cfmr1661642lfe.4.1713542914543; Fri, 19 Apr 2024 09:08:34 -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 bl20-20020a056402211400b00571d7acd844si613293edb.609.2024.04.19.09.08.23; Fri, 19 Apr 2024 09:08:34 -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=eD4d0DVu; 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 9F14768D40A; Fri, 19 Apr 2024 19:08:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02olkn2075.outbound.protection.outlook.com [40.92.48.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 094C468D3AE for ; Fri, 19 Apr 2024 19:08:00 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iYkvWMnUknhSUA6jn/7vFDn+IoVwOzqK0WUsDTgMYQnbExDA8yytA+jkuS6a28ldI/jXUeQdJjP8lj+PYFRqtkGc5Yr9eajqoXS57istulWAFVl5TIXz9rmt9FbxRRomp+d4nkgQeDrA5Xwj896RWLnhcgXArdhyQvmTtwUzEG9GN3yKtwd8X45fJwg1OLx/a51fGrqfty6+bAUMihrwxjhawKb0+/ZhTIVDMltiltYsoxeEggSNkeRXCjnivxku62J9jo4hsR2dokDV3Tjul4zusvgNSItatoD1oIXMlFxPhYCL2A4yj46QFU1pSrZo2e/valWAY1TwRb2MkZCnMA== 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=pHHUtAiCa5JOiGV7EXV23/h27n0Pk62g2dj60faThDw=; b=QPAEkCrP2eItsDoWYJmVpYxFKY0BmX3Ktgd1TAsN/qAZgR7oX/JylW1ONQ/pz3jJ2YSXtyfzXx+sRgs5vXg5zAkSBxfpbkod/zWNN3mg955YugDKKpyQ27bKFYdGKM0/BHW/33jdFIYoCy0pwcxkJOd1UaqUs8HUhxlBfqZvjpqAHsYrx+7MUpmzxEXKURQmKqcmicWAHNUbiBKq6dsyD0M0y651vtokk1/7c0PJf0NZPtTw+7ikHA1lfHYXQe/0GlLmuhlcAIOGTzqBRvBg+1WKJkTPRAJAav6pKzHVrLcx1v6X4NvsiHyVwNObzm/+wlCL7fTWS1yWgJvUZqirkw== 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=pHHUtAiCa5JOiGV7EXV23/h27n0Pk62g2dj60faThDw=; b=eD4d0DVuNuTbPNGNasLXvVfQ3JQoRN18QRzNeLN8QJHMfnyqntMXpzcLDK5TGvIiv/JDyZ2uNGU8a//jVEByeYrlEJYFfOF36RUdaBi7x+GDTSl2YtQ9OTKy19XaLe64CRFAVANFXVfvg1xX77Pkxbqg9FV/7WUP0JXXaV41jyCsdWwY7XiDtv8Q1lvYlHUBYOOWynKSkGwNAEJQFpI3jZ1wWcEnjdMGMA/HylTi8SsyMwFVhZ5wNowHWLSHN1+bBktwvVS+wBjHp0JfdS9dX9/08i6FtQpNDqbLaXZ9PIlZ4aO8jpI1D7YrbMmfaxqGGofxh4MGGICKndeHYYxZPw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AM8P250MB0138.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:321::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.41; Fri, 19 Apr 2024 16:07:50 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb%3]) with mapi id 15.20.7409.042; Fri, 19 Apr 2024 16:07:50 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Apr 2024 18:07:34 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [MGip+pNaOtuo931ERWRJ1jJvcoi52YW2kbTZUuiL5Bo=] X-ClientProxiedBy: ZR2P278CA0006.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:50::12) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240419160734.1104837-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AM8P250MB0138:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bbc0556-bd5f-4afb-edf0-08dc608adc9c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dFY3K6ZDWcpfO78zZECiy+R/pDDuqLj21jwCEiMiL8dq7eM2KHPonS6RoS7iLIqO9YurFYf/qQpUFq4JfthcdNYe6v9DNeolkVTiXJkQQdU7fgiGcusjl8lh3+xOuaSI9JSZB1ruUlA0FHLgbOVGXChnb6ALuj69a2yKiVDsDvHIqVvGMQ9rgzyG1UeY0bseyOyJbC+Qteqb6ZCK1TJq3GK8pdQonQ25nfZOABTwAF7MzYBkYQiA3MZsUu6v9la1yP7Ou8V7OlT4NmA3CD1nGq/Sj/sP4JtkfvD75DJtm3+72ERDW28UMVUVWejphtbYA+SXq2YWq4vOiuy8phyNTdY6hDSiw772V5E+8MwpdRU4ayhI3mqRZPheJMuzN03/8b2JtRXDbPtk5oFVEAIwCkXLrWxt9H1cB0a6v2mLa0qPCE1AZGX8q0Md2WZ7oiE6W+idmk8ILKCr1VUrWmA2wd1GRCpzmSVxWBSCz1b+26xL4TF8jcxaGR1v+Tz/xnNdSZZNABROIVEnYJd2IeDB53V7pt8ApkwMSiq9Q/QN2BOeCDFff7LUzAIjaDbi3QNmXjy0emp30+BUTQF/EPbDHWEpchBf7CSY2x6Oa35J6VyV9QlGMn6Aze5P4w7igoJE X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F+DBwHnPQpHMggzY93A3MQz9AdDbxyr5RBhdIPFkc6UbuZEnMMKKBHPC6ifOEE1vLZV57tmu7NihYp+EbthzdkB3Sw3n1PPM2nw3u9vuP3TWWMYMk2uMr5iKqEjrSYDO2EXbiY0bWJVYuF5QXpMy5COik6wb2wa6yPdjDXWPEgZkevl4gbcVzG88wSjZShQdylXLoVACuwMTK3E2otyiI/9isvHHyECeJEsDwzaSHQEJCPlj8CLfWOrSbmTd2E07NDT4mGiIHvwUas2sI178vGoU6GI94OoYuJ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608adc9c X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 16:07:50.4528 (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: AM8P250MB0138 Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/vaapi_av1: Use ProgressFrames 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: aFMQ/v1xkoQf The rationale here is exactly the same as for using them for AV1: It avoids av_frame_ref() when putting the same frame into multiple reference slots. (In case av_frame_ref() failed, the context would be left in an inconsistent state that claimed that an AVFrame was valid (i.e. not blank), when in fact it was not valid.) Signed-off-by: Andreas Rheinhardt --- libavcodec/vaapi_av1.c | 61 +++++++++++------------------------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c index 1f563483b9..20651a0ac2 100644 --- a/libavcodec/vaapi_av1.c +++ b/libavcodec/vaapi_av1.c @@ -18,17 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/frame.h" #include "hwaccel_internal.h" #include "vaapi_decode.h" #include "internal.h" #include "av1dec.h" -#include "thread.h" - -typedef struct VAAPIAV1FrameRef { - AVFrame *frame; - int valid; -} VAAPIAV1FrameRef; +#include "progressframe.h" typedef struct VAAPIAV1DecContext { VAAPIDecodeContext base; @@ -40,8 +34,8 @@ typedef struct VAAPIAV1DecContext { * applying film grain here. And current_display_picture will be * used to apply film grain and push to downstream. */ - VAAPIAV1FrameRef ref_tab[AV1_NUM_REF_FRAMES]; - AVFrame *tmp_frame; + ProgressFrame ref_tab[AV1_NUM_REF_FRAMES]; + ProgressFrame tmp_frame; } VAAPIAV1DecContext; static VASurfaceID vaapi_av1_surface_id(AV1Frame *vf) @@ -70,32 +64,14 @@ static int8_t vaapi_av1_get_bit_depth_idx(AVCodecContext *avctx) return bit_depth == 8 ? 0 : bit_depth == 10 ? 1 : 2; } -static int vaapi_av1_decode_init(AVCodecContext *avctx) -{ - VAAPIAV1DecContext *ctx = avctx->internal->hwaccel_priv_data; - - ctx->tmp_frame = av_frame_alloc(); - if (!ctx->tmp_frame) - return AVERROR(ENOMEM); - - for (int i = 0; i < FF_ARRAY_ELEMS(ctx->ref_tab); i++) { - ctx->ref_tab[i].frame = av_frame_alloc(); - if (!ctx->ref_tab[i].frame) - return AVERROR(ENOMEM); - ctx->ref_tab[i].valid = 0; - } - - return ff_vaapi_decode_init(avctx); -} - static int vaapi_av1_decode_uninit(AVCodecContext *avctx) { VAAPIAV1DecContext *ctx = avctx->internal->hwaccel_priv_data; - av_frame_free(&ctx->tmp_frame); + ff_progress_frame_unref(&ctx->tmp_frame); for (int i = 0; i < FF_ARRAY_ELEMS(ctx->ref_tab); i++) - av_frame_free(&ctx->ref_tab[i].frame); + ff_progress_frame_unref(&ctx->ref_tab[i]); return ff_vaapi_decode_uninit(avctx); } @@ -125,12 +101,12 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, goto fail; if (apply_grain) { - if (ctx->tmp_frame->buf[0]) - av_frame_unref(ctx->tmp_frame); - err = ff_thread_get_buffer(avctx, ctx->tmp_frame, AV_GET_BUFFER_FLAG_REF); + ff_progress_frame_unref(&ctx->tmp_frame); + err = ff_progress_frame_get_buffer(avctx, &ctx->tmp_frame, + AV_GET_BUFFER_FLAG_REF); if (err < 0) goto fail; - pic->output_surface = ff_vaapi_get_surface_id(ctx->tmp_frame); + pic->output_surface = ff_vaapi_get_surface_id(ctx->tmp_frame.f); } else { pic->output_surface = ff_vaapi_get_surface_id(s->cur_frame.f); } @@ -265,8 +241,8 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, if (pic_param.pic_info_fields.bits.frame_type == AV1_FRAME_KEY && frame_header->show_frame) pic_param.ref_frame_map[i] = VA_INVALID_ID; else - pic_param.ref_frame_map[i] = ctx->ref_tab[i].valid ? - ff_vaapi_get_surface_id(ctx->ref_tab[i].frame) : + pic_param.ref_frame_map[i] = ctx->ref_tab[i].f ? + ff_vaapi_get_surface_id(ctx->ref_tab[i].f) : vaapi_av1_surface_id(&s->ref[i]); } for (int i = 0; i < AV1_REFS_PER_FRAME; i++) { @@ -370,17 +346,10 @@ static int vaapi_av1_end_frame(AVCodecContext *avctx) for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) { if (header->refresh_frame_flags & (1 << i)) { - if (ctx->ref_tab[i].frame->buf[0]) - av_frame_unref(ctx->ref_tab[i].frame); + ff_progress_frame_unref(&ctx->ref_tab[i]); - if (apply_grain) { - ret = av_frame_ref(ctx->ref_tab[i].frame, ctx->tmp_frame); - if (ret < 0) - return ret; - ctx->ref_tab[i].valid = 1; - } else { - ctx->ref_tab[i].valid = 0; - } + if (apply_grain) + ff_progress_frame_ref(&ctx->ref_tab[i], &ctx->tmp_frame); } } @@ -431,7 +400,7 @@ const FFHWAccel ff_av1_vaapi_hwaccel = { .end_frame = vaapi_av1_end_frame, .decode_slice = vaapi_av1_decode_slice, .frame_priv_data_size = sizeof(VAAPIDecodePicture), - .init = vaapi_av1_decode_init, + .init = ff_vaapi_decode_init, .uninit = vaapi_av1_decode_uninit, .frame_params = ff_vaapi_common_frame_params, .priv_data_size = sizeof(VAAPIAV1DecContext),