From patchwork Wed May 11 16:17:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 35735 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp28685pzb; Wed, 11 May 2022 09:18:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK6ta9OK4OdQeQ3hkuS9tfwSQsgViAnawb5LH3zuQPQBlHDTVnys8QocRsd6y4VtFmdcex X-Received: by 2002:a17:906:4fd5:b0:6f8:5aa9:6f13 with SMTP id i21-20020a1709064fd500b006f85aa96f13mr21288860ejw.267.1652285922563; Wed, 11 May 2022 09:18:42 -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 ck26-20020a0564021c1a00b00423fc9d80ebsi2606243edb.338.2022.05.11.09.18.19; Wed, 11 May 2022 09:18:42 -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=a0tGvZxw; 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 D945368818E; Wed, 11 May 2022 19:17:53 +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-db8eur05olkn2027.outbound.protection.outlook.com [40.92.89.27]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 034DE68B2E6 for ; Wed, 11 May 2022 19:17:46 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cjOE7kYrf0WecssDqmxz3ofFIKB4UgdiEqF+fj/AeeePC1UhsbBAmzbYAurpUJSUyHw5+hgbg+u+5iaiRZ3G5jQKTUAA3rjqKYAhDNrxkWuvY6xKPvQ95Ft1aCiakjtpGZzrrqOFheG7GEKwlYbGQFmA3At8T8TiinwkYCuDv2ksKCbAX6sr58vEuRAg5RP9QnxHabJc5q8XhD8cLN47y4u0pBYLHfOpneV1+F8eQnN3iz6QNHQ7/kS+Xo66CepyMUpYZklngLXjvEe10LD5IE1GvH3DQPze8vrSo4kSVY0Nve5NUYFuRY7x2swsqNwnkY/JFWmgW/qkMO+2NVEJOA== 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=epGMkG0wnvB58+czMsOfMpums4u2zmhpAcNyXz/MF+k=; b=hQhyY2EbswNFXPQkiKP/fV9yvmQ6es4eOaD1VmheXvwzdoVyivY7ihbCUBNC3+J/O/nW8HNfsmsmmgrYK+7MlywkpxXGyWdLhY/ly9exMHfRjG0ajVZEPUkuTAMlrgVeB+a+hCGQyiV9hoDjMibSrJ3UqvSAVnzlGp0+uoaIFRYRr2qXuPGLdaemCkggCvh4IIgnUvxFakcedK+wSc+VUiATykIX5eWyZxzxCKrODeEzai9MXr2Uo+u6RdkzkzOmDAqA4A2YowMsLdE/tYDBnlA8Ifx1s5l/HU8Wpkd1ZKfVpiT5MVH0NSVpgQd9c8X0TTjl1fDTGw69UEVKfLqFIw== 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=epGMkG0wnvB58+czMsOfMpums4u2zmhpAcNyXz/MF+k=; b=a0tGvZxwxkIr5iEpkZ9UiVmtA8W9hTFGB5nwRh3GJ2jDne1HYKhXFVD9dNXDjuIebpaFMimaqNHVWDFqrXZy7K5hnEWMG59rKtJ5gM3oOJ9YDBXB/A5GMy/In0O3yuDdbdhQAz7jbfo7X1DXvaZMCf3xQKiMRsM6iBVJwE/mcPjdZMsa0B1YVJPSkO3gncJclLTwkB1V0FQQjXISrAwjOiPCXnNCx7OmR7xgJJJpCpyWar3U+Mc2cDEi5E/CnEYGj8qtRIstf/uXPbVXqzwSbAYK44L4luaCfoba0J9aheC1B7tVuXYnhk6tMXl322hHAr9Hbj6n8/3twDzOpVpnDQ== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by AM4PR0101MB2130.eurprd01.prod.exchangelabs.com (2603:10a6:200:54::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Wed, 11 May 2022 16:17:44 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%9]) with mapi id 15.20.5227.023; Wed, 11 May 2022 16:17:44 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 May 2022 18:17:36 +0200 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [iPYbqC8fWZ6JUhp+s8h4G12+lRM05HoR] X-ClientProxiedBy: ZR0P278CA0156.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::6) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220511161736.815366-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 57db3596-c916-4709-7d24-08da3369c77d X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEtOq11dBndvwNG52fGNPT+6yPSbbr4JCDJ1W3ShfqWNxo+73bR2U2dxFnSFZoqJp8r3qxVGFeXck+er+J9rPr4CxYZyhPT8OcEBHRZlDCXBY+LM+LTkDgaML//JUCQVMO6RaEjoVUbLqc28yU5q9b7PcUpzVLRUOFyO3EojoKztjGkSaMLUCqacuXtG4h07S1Rlza62EYYpTC0vGMJDHPscqL37Nnp4zoambwFKbiiQjSibircurn7vBCcch0xrMxVK5n4hC4Z3oTfD9eGTt5fprsRPh3EiWC3BSXh67LzwsU6wB4JTkOiG59qwIZnygbHZQDCCxKm75HcWH13BAdhQXer/i0dGaqkhCOW8I435On7BWLkzoG3ZniiMxdEcnOllu2sdRyi3hZx7SEmAbkIAg11I+vfNyhDV8mHqiZEBCLcFjsXxY7mzq2b4NYUgOqAB510JKssrcSOwZocRfFhoOPeorGqc0TKY9vrfXdhZ5C1IQy1WaznP+JYE98L4N/RMFsYxrK0tOmcJt4nHZ7rRLgnp4Fbe6WfLlfuKdLZ3O8PeboXo1qKWZLp3r1xCaUI5GkH5WO1gUNT9slYmJsyJArXARy9oHqQRVLTSYrHf15KHc7BkhxqT42OYTWFS+ujqIPwDQ0zP4i2sCQ/f/zJc2AXiv7axMx67/sYqZU322KunMlI+zqwEQn6QLqtNvkyw86viUQ1AP4GaMm2jj805rMIa0sLpi6ZJJIHeWetbktOlsonq4pTGSUjvdI2LTxI/oa15PL8QmRs58jwSqZJB X-MS-TrafficTypeDiagnostic: AM4PR0101MB2130:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SArxIjCOVjWHnCY4AZZUvez+Vvw8HQnrpJkuttB/ObIi0NBms6gsYcPhpTsobfuc5XfqDqLTNAN89HQ/7S4W2cEAHZPOLx5CSjqwi+adUe/Yij569dBoSXZT+9OyFRFRrJER6qUcuPexwsT9CRz6E8eMAwWfKflFvusmhYXYECj/F5Z0OwF1n5gsSx9c5rXayfjsawEUh2jbkioDPZRTIgcDvJE5Diij8Wj6uShs3dveEad4LAnr0v8S6masD5RAe4AgHIB9tVnWAm00emY43f9CItlKVcrSvAride501+fVjpLJyuTNsudzEe95Ahaa6a7PfqkuvML47bBx8YMcRPQxmxm26PP2o4/uphY3U+fXo1B5lxF4k7IuBYSvFzx5EDzV/3SWP5BiHRaO1rTkhZt5JP75e4NWiVK2nCPaeI3xYg1Zx61TAp7Z44xsFCf5Dq0SrvSTyzf82PayUVKzH4CxPi6EBe7ERYEkrNGVyTIoZjSdCcDbb1kf+SZ/vmdvfFetUxgtvtcI85nooWQWKfGLb5LRVRH8T+yUvfbczUsXyD0SE5QZ3BXXgZ9hffeviXW2EBJym7gdP344jRd2dT9sHHKan9Mibq808LVaWZt6t2WqqS7riqGufK+Dyn72G0HZvy1+y+uH1JbP3rJaLA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ePxfA6J0rJkwjwPQXwxJ2M3y23H4l//EiMmXEWs2YyquKSkCVYeudYbJMybbf6cikDAhMJxfwSV7XP1mMydvyXfmKGYNCdKnxFccEMIoxnBrm4TqkYbMcHKgK3jMuzQk/wzRElloJxWAYRQoegVXpGaTVqcUWk/zes69G9g7kNH9tl0uzWlYd0gGXP18bR895eTjUSDseaFN/6yaEWUfg5bMDigdTC42sLbLx/SntpjlfqbA2EJUCMy3NCycCM2qed8L8IH35zVLEpzqAlihQPSYuDnI9pc7WBAxkFKNqVOmviK2yIzLDdhBhdC+RWs8xUowsCnM92H0i15YxqU/SAvTGtjPcJ5p4vJzBI235+IFVqV6VeLtfJIh8y4TZEi3Q4buh5eiUGMjWPYNsbugO4kJqhPeJrgcjLOVuxjdAZ1BCBLPv5v0TVjShML8xEcCxT4UCySBAAvQdB/Yb1mjUNkzCNEvsLPf9KqwTeJTDtGgZ6UliDmKoI+A7ROIwjHi+fI/fk3JL+yHK8l2iQP97P7KZlCPNsThbW7JyQO6UZYR94yOxcmfcYNH/YGgkPS39H2Itsmo9pP9CweSZL5S7DAmZXkzpCclyKZTNvcHE8qf3zJkYojPCUaYIgXbn1SP3hOzlNqt7AI6wOdIe9E1igoEsv8cr3ONOP/sQek3311FLy2vrKF9FHPica8p2ny/SnmkIsfL4zMUEUxNKDlmfemtAIHkpl4mI/PD6snLBxx04w7qRgdwjcuxUuEo8BINOzdkWofuMsLogcmQOPNybheERChmSHCsbn4XffHBtlqy4J0Ke4mArttoSDFsXIc1gHv0K0iKeRL3aVe8f7BjpnMl3J8V9YbmISIjmLW4WTQkq3gZSRnJ+9wlkfvjorl/jKFEacodyyeSSSciZbQqSEamg5vKlraF5ATZmMoRO8iThf0S7RDdZW5q/fHDdsB/60SU/fwrPEFXfTDlWwCWSg9o5u84QwQx2gPwHPAPJUNnHGLnl0Gu9/dUXpfiAs7C9SRp30wM3+4+UGb4S4iaUPorLugA/sanpEz5XfhjwOAfoAirinuuAONhf36oY8L6cRCqSPjWMySXzaIybeHhamo6TZ17OZKzOQIz7WYFT0T5eZgEYhk0VkRsIL+YENRRM84aGPzIDoZ/jwSk4ui1HbHe8COeLD3XHZoh1OYVwrQ+8pN3roFSVe8wNcKv8nnPddYrOHySKeFhQW7cv2f55j8/JdTsMUHjBZWI+u5bG3upMcHXhJaZ+4LiUCPo2xVdNRbyj2BvQRtyLhoEWzsI3KGkrz3zt9xwqhRipoy+k0cKR1Wkxod/NCW8MtR7Ki3zztiJ/KxN5rH6EQTJ+7LVvgue3abFK7gIdFGsLydxoRKWaSsN6SX+jtpxNWJ8mN6Q5nZyjQMNkATGksVm6dz7gg2kjQoTplxHQI2QyTKJsJmmcRJ7alu0CprSZ6N1PenyDSWRA6afdDUOerXZ5SQmxg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57db3596-c916-4709-7d24-08da3369c77d X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 16:17:44.0943 (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: AM4PR0101MB2130 Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/decode: Don't allocate FrameDecodeData if it is unneeded 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: PdgtS8oYjrPU Currently, every call to ff_get_buffer() allocates FrameDecodeData, although only very few decoders (those that might use nvdec or videotoolbox hardware acceleration) actually need it. This commit addresses this by adding an internal codec cap to ensure that FrameDecodeData is only allocated for codecs that might need it (i.e. for which there is a hardware acceleration that might actually need it). Signed-off-by: Andreas Rheinhardt --- 1. It seems that this has even been allocated for some encoders before c954cf1e1b766a0d1992d5be0a8be0055a8e1a6a. 2. Given that the videotoolbox hwaccels call ff_attach_decode_data() themselves, they actually don't need the generic part of ff_get_buffer() to allocate it for them; in particular, one could avoid adding the flag to the prores decoder. I can modify the patch in this way if desired (it would also necessitate modifying the assert in decode_receive_frame_internal()). 3. Unfortunately, I don't have hardware to actually test nvdec or videotoolbox, so only the "it works if allocating it is certainly unnecessary" has been tested. It would be nice if someone could also test the other part. 4. One could of course set these flags only if the relevant hwaccels are enabled at compile-time. 5. Unfortunately, it seems to be too late to call ff_attach_decode_data() from ff_nvdec_start_frame(), as it is called after ff_thread_finish_setup() might have been called, so modifying the frame would be a race. 6. Maybe the following would also work: Add a caps_internal to AVHWAccel and only allocate FrameDecodeData if the hardware acceleration currently in use needs it (as given by this new cap). It should work (hopefully) and would be cleaner. libavcodec/av1dec.c | 3 ++- libavcodec/codec_internal.h | 5 +++++ libavcodec/decode.c | 16 +++++++++------- libavcodec/h263dec.c | 6 ++++-- libavcodec/h264dec.c | 3 ++- libavcodec/hevcdec.c | 3 ++- libavcodec/mjpegdec.c | 3 ++- libavcodec/mpeg12dec.c | 6 ++++-- libavcodec/mpeg4videodec.c | 3 ++- libavcodec/proresdec2.c | 3 ++- libavcodec/tests/avcodec.c | 15 ++++++++++++++- libavcodec/vc1dec.c | 6 ++++-- libavcodec/vp8.c | 3 ++- libavcodec/vp9.c | 3 ++- 14 files changed, 56 insertions(+), 22 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 1c09b1d6d6..291ba94a36 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -1250,7 +1250,8 @@ const FFCodec ff_av1_decoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_SETS_PKT_DTS, + FF_CODEC_CAP_SETS_PKT_DTS | + FF_CODEC_CAP_FRAME_DECODE_DATA, .flush = av1_decode_flush, .p.profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), .p.priv_class = &av1_class, diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 5df286ce52..cefe3fdd1a 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -73,6 +73,11 @@ * internal logic derive them from AVCodecInternal.last_pkt_props. */ #define FF_CODEC_CAP_SETS_FRAME_PROPS (1 << 8) +/** + * This decoder might use FrameDecodeData. In particular, ff_get_buffer() + * shall allocate it. + */ +#define FF_CODEC_CAP_FRAME_DECODE_DATA (1 << 9) /** * FFCodec.codec_tags termination value diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 264fc66a81..33c97c41a6 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -548,10 +548,10 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) frame->pts, frame->pkt_dts); - /* the only case where decode data is not set should be decoders - * that do not call ff_get_buffer() */ - av_assert0((frame->private_ref && frame->private_ref->size == sizeof(FrameDecodeData)) || - !(avctx->codec->capabilities & AV_CODEC_CAP_DR1)); + /* the only case where decode data may be set should be decoders + * with the FF_CODEC_CAP_FRAME_DECODE_DATA cap */ + av_assert0(!frame->private_ref || + codec->caps_internal & FF_CODEC_CAP_FRAME_DECODE_DATA); if (frame->private_ref) { FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data; @@ -1460,9 +1460,11 @@ FF_ENABLE_DEPRECATION_WARNINGS validate_avframe_allocation(avctx, frame); - ret = ff_attach_decode_data(frame); - if (ret < 0) - goto fail; + if (ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_FRAME_DECODE_DATA) { + ret = ff_attach_decode_data(frame); + if (ret < 0) + goto fail; + } end: if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions && diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 1f9f3e5e95..8160b394e2 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -769,7 +769,8 @@ const FFCodec ff_h263_decoder = { #endif AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | - FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | + FF_CODEC_CAP_FRAME_DECODE_DATA, .flush = ff_mpeg_flush, .p.max_lowres = 3, .p.pix_fmts = ff_h263_hwaccel_pixfmt_list_420, @@ -791,7 +792,8 @@ const FFCodec ff_h263p_decoder = { #endif AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | - FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | + FF_CODEC_CAP_FRAME_DECODE_DATA, .flush = ff_mpeg_flush, .p.max_lowres = 3, .p.pix_fmts = ff_h263_hwaccel_pixfmt_list_420, diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index d80bc6b17f..a7190dbfc5 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -1099,7 +1099,8 @@ const FFCodec ff_h264_decoder = { NULL }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING | - FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP, + FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_FRAME_DECODE_DATA, .flush = h264_decode_flush, .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context), .update_thread_context_for_user = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context_for_user), diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index f782ea6394..df5822f365 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -3890,7 +3890,8 @@ const FFCodec ff_hevc_decoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING | - FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP, + FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_FRAME_DECODE_DATA, .p.profiles = NULL_IF_CONFIG_SMALL(ff_hevc_profiles), .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_HEVC_DXVA2_HWACCEL diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 32874a5a19..aee4871346 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -3027,7 +3027,8 @@ const FFCodec ff_mjpeg_decoder = { .p.priv_class = &mjpegdec_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles), .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_SETS_PKT_DTS, + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_SETS_PKT_DTS | + FF_CODEC_CAP_FRAME_DECODE_DATA, .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_MJPEG_NVDEC_HWACCEL HWACCEL_NVDEC(mjpeg), diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index e9bde48f7a..53c14a7a04 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2877,7 +2877,8 @@ const FFCodec ff_mpeg1video_decoder = { #endif AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | - FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | + FF_CODEC_CAP_FRAME_DECODE_DATA, .flush = flush, .p.max_lowres = 3, .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context), @@ -2910,7 +2911,8 @@ const FFCodec ff_mpeg2video_decoder = { #endif AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | - FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | + FF_CODEC_CAP_FRAME_DECODE_DATA, .flush = flush, .p.max_lowres = 3, .p.profiles = NULL_IF_CONFIG_SMALL(ff_mpeg2_video_profiles), diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index e2bde73639..99d85495ea 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3678,7 +3678,8 @@ const FFCodec ff_mpeg4_decoder = { AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | - FF_CODEC_CAP_ALLOCATE_PROGRESS, + FF_CODEC_CAP_ALLOCATE_PROGRESS | + FF_CODEC_CAP_FRAME_DECODE_DATA, .flush = ff_mpeg_flush, .p.max_lowres = 3, .p.pix_fmts = ff_h263_hwaccel_pixfmt_list_420, diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index dba64a2489..64a38a2a14 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -882,7 +882,8 @@ const FFCodec ff_prores_decoder = { .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, .p.profiles = NULL_IF_CONFIG_SMALL(ff_prores_profiles), - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_FRAME_DECODE_DATA, .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_PRORES_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(prores), diff --git a/libavcodec/tests/avcodec.c b/libavcodec/tests/avcodec.c index 08b5fbede1..1ed7eb0a90 100644 --- a/libavcodec/tests/avcodec.c +++ b/libavcodec/tests/avcodec.c @@ -20,6 +20,7 @@ #include "libavcodec/codec.h" #include "libavcodec/codec_desc.h" #include "libavcodec/codec_internal.h" +#include "libavcodec/hwconfig.h" #include "libavcodec/internal.h" static const char *get_type_string(enum AVMediaType type) @@ -146,7 +147,8 @@ int main(void){ FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_EXPORTS_CROPPING | - FF_CODEC_CAP_SETS_FRAME_PROPS) || + FF_CODEC_CAP_SETS_FRAME_PROPS | + FF_CODEC_CAP_FRAME_DECODE_DATA) || codec->capabilities & (AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DRAW_HORIZ_BAND | @@ -170,6 +172,17 @@ int main(void){ !(codec->capabilities & AV_CODEC_CAP_FRAME_THREADS)) ERR("Decoder %s wants allocated progress without supporting" "frame threads\n"); + if (!(codec2->caps_internal & FF_CODEC_CAP_FRAME_DECODE_DATA) && + codec2->hw_configs) { + const AVCodecHWConfigInternal *const *hw_configs = codec2->hw_configs; + for (; *hw_configs; hw_configs++) { + if ((*hw_configs)->hwaccel && + (strstr((*hw_configs)->hwaccel->name, "nvdec") || + strstr((*hw_configs)->hwaccel->name, "videotoolbox"))) + ERR("Decoder %s has videotoolbox or nvdec HWAccel, " + "yet these need FrameDecodeData.\n"); + } + } } if (priv_data_size_wrong(codec2)) ERR_EXT("Private context of codec %s is impossibly-sized (size %d).", diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index a7d556c378..8ea9903350 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -1212,7 +1212,8 @@ const FFCodec ff_vc1_decoder = { FF_CODEC_DECODE_CB(vc1_decode_frame), .flush = ff_mpeg_flush, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_FRAME_DECODE_DATA, .p.pix_fmts = vc1_hwaccel_pixfmt_list_420, .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_VC1_DXVA2_HWACCEL @@ -1250,7 +1251,8 @@ const FFCodec ff_wmv3_decoder = { FF_CODEC_DECODE_CB(vc1_decode_frame), .flush = ff_mpeg_flush, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_FRAME_DECODE_DATA, .p.pix_fmts = vc1_hwaccel_pixfmt_list_420, .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_WMV3_DXVA2_HWACCEL diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index f521f2c9de..37fe4cb611 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -2967,7 +2967,8 @@ const FFCodec ff_vp8_decoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | - FF_CODEC_CAP_ALLOCATE_PROGRESS, + FF_CODEC_CAP_ALLOCATE_PROGRESS | + FF_CODEC_CAP_FRAME_DECODE_DATA, .flush = vp8_decode_flush, .update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_context), .hw_configs = (const AVCodecHWConfigInternal *const []) { diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index fee79fb45b..244dbe8aa6 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -1878,7 +1878,8 @@ const FFCodec ff_vp9_decoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_SLICE_THREAD_HAS_MF | - FF_CODEC_CAP_ALLOCATE_PROGRESS, + FF_CODEC_CAP_ALLOCATE_PROGRESS | + FF_CODEC_CAP_FRAME_DECODE_DATA, .flush = vp9_decode_flush, .update_thread_context = ONLY_IF_THREADS_ENABLED(vp9_decode_update_thread_context), .p.profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles),