From patchwork Fri Mar 22 13:32:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47311 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1743:b0:1a3:ac71:9534 with SMTP id nw3csp136822pzb; Fri, 22 Mar 2024 06:33:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwIoSlRoQrCCojX0Q2i57ITajNTiwMy/ZDT4jDlH77R+Ng7vmLkdtalQ/ctvs7yvfORwtqJjNJToD7z3UwS6rWi3wpYOAr+ELidw== X-Google-Smtp-Source: AGHT+IGts6hWS2jaYFim2JvdHVLwAhdb6gXGS4yk5lY5kAuD39/lNtqVB3Tl8Ox4jUzO6h3ef2Nv X-Received: by 2002:a17:906:f756:b0:a47:3651:a302 with SMTP id jp22-20020a170906f75600b00a473651a302mr809061ejb.42.1711114391528; Fri, 22 Mar 2024 06:33:11 -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 lz10-20020a170906fb0a00b00a46fe9df976si929211ejb.671.2024.03.22.06.33.10; Fri, 22 Mar 2024 06:33:11 -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=G7dC81Ld; 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 7EBFC68D598; Fri, 22 Mar 2024 15:33:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01olkn2036.outbound.protection.outlook.com [40.92.66.36]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 02FD068D484 for ; Fri, 22 Mar 2024 15:33:00 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cs6KE7uDynSL9+AXF39MKqqxwcW3rpMT0se/pIFVH4FD7YrzyWt4mYcBJJro8oMe6GHa88Yri0f/lZzfiRk4mXZpdbC2yMCwqTq9R1Uj82CATf/aKYSTsm1ceBx/zmvU0oudPC9PV7eGnxrWsuXt7hn0yMP8WPgPOOLMKq8X8VQHIRUddVfVGIaobitxK3qjqaD199i/iG6KmMoWz+l1h6UoGWqxaMExJMGMRI1ZhlZ/aj9k8HnvJkPaRYqz59Cw4TlwgK6qyChuc8ZP8TKlts1/x4Y5txFRyWTCIvROqkEcA2iCtf/+gb9P53xGYitF0dI50bhUJyA8lhLepgNNBw== 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=clqSNRiUhFHVJOD/0kI+2vD37hlb0u3XZrAzzZdHpOY=; b=blePI300Auu4tTiLfX5Bod9vJ1MuhAwAc8mPy4onAoar8JnkukEolOQ2baTZBs6V/fVEBY+QRzwV3yGZ9S+HmjqeKVsf8/1cfxg1EGBiJRS0eP8Fa8dbVozNYl8HCQ6aduetspcKDjp1pm8NzwER4ea+7T6YVJobSMtWCV4gKpt4kQQW04qmxTrRvAU1/EegGp77rZQEvjylG3lQQzsG7CfhGx3n8VfKpqxWmL03XIOJ48x/jfJ2otz9EZbNZC7d2mfPr9ld/11aWnqt8LqOtmWTgg7WgF52rRVjcVYdXImWbpVA566x7znMwytyk13/H8ga4/WsE18XlQ7xixMq+A== 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=clqSNRiUhFHVJOD/0kI+2vD37hlb0u3XZrAzzZdHpOY=; b=G7dC81LdPIJ73whZDDO92f6QLT2RN7T/0cSExSBlzoU0tDBIK1xid3+EZ712tWzOTOcAy3PkpI4C6NT9ZY0xxICiOEqr649g5ctz8JWXgQwF1NvMIrY0PmRdLClrRFovruIf8tD7vd2LZv24/MtBUQfyMAGw206GZ1v4fcL/gw2ruW9C2+vjM+0S9DKPFVJ9AigL/ITf/CBIGG+UCqdEqNN1L/W0Z77qHWItvqe4E6ERgr/dBT+W3YnU8zwLrzXTb1c9G3ihj6K2h9nNA18m6Nr0KeLqHzJc8dREs+ATLUAM1prfnxRmn2c5vQyWMTSXpoFd2doprWJj2/X50sGd7g== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS8P250MB0165.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:374::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.15; Fri, 22 Mar 2024 13:32:59 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7386.025; Fri, 22 Mar 2024 13:32:59 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Mar 2024 14:32:50 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 X-TMN: [OyTuxqHhI5Vf3Tl6ObJz6bNvRUQAxenDMTONngCfoPE=] X-ClientProxiedBy: FR3P281CA0162.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::14) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240322133251.191407-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS8P250MB0165:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bc8652c-3034-49b4-0ca5-08dc4a749729 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zeVTgUFPorSHiIV9ygqBJ8PoIUD9hDUTjn5gz9pjR+Dgc9GB+sSMKm8cSO1RtJsH92OAWVvVGxtj0s6VqgN9027r1618oyo1Lj6AoNDQF6IlL3VPb3mmGBk/OvpsbMxW/8VkNyiarFBcWIMCjqmK+Wzh57s2tOofXcETeuNSjFbKoW175R2BVKqfFhtWY6loMrn/Ym59tS1P8C/1Be4k4FiEXYjxa4v7AsvplBfEqlCwyLVm0YZ+Nw6Sdtz2c3v9PjtB3iqty6DCXzX1WQfUQ4wSYcQQxKFG7v/Bnw/CP4agFBO4w8UrHDDc1jl2JdxmANQ5CxAdQAFZhcWhjG/bjoKH7w8Kbd4WUz1UwNnqIjQhRu2P+vMZaevTKBh2VPZbwylWEtmYdudDUVpmgLvC2ETMAjL8+X/7dyL0pfsxAaWuT0noGW6JTxrFiIXVPOncB02UNju0EM5QErk1ued7IDQnq9IKqkgeLChUw3YNHtKw0s5eDb0kDaiOSM7usB24tUeSVlbCtkbUOuOD4hTWM4g4YM5VEuckLswbmuj32lr7bp5Rd7qOwClZbH6vlAxxanr+X1UjPtRyI2Olmuomj3wtSpnQtxW0LaAoLaHjMC+tE2w2uI0epMbAo5OHKENBhXTezjLhVIEX/XG0XOHsM953t6zbnc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LtX+5N7NGMW6jNRoycEVc9ZjkXZJttEz7jgA1zH7GhAWE2d1O84ujNwkDorVHd2hC6OPa8YpiwdDX31qt+HBo1F0PzCamFRC2v/gyQ8guajyBdArVCBbrH44HCHRL7JElIWAlpkF4q1+B7gDHs6Toc+iJBTB8DIOl3W6gQ5oqAI2GK1FYp+eCfzZf+81jo/LbIJ2jPah3sALrhupwP4f6RdK6Q59NulsgYEKwUZkdY1MJYohk5e7RwtRqXY9NUzZxWCAyGoaf08g95mGh18jYC/oYzfxJeRs9Q2re+pWKF+wSzctnqkLQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bc8652c-3034-49b4-0ca5-08dc4a749729 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2024 13:32:59.4545 (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: AS8P250MB0165 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/libx265: Don't use AVBPrint unnecessarily 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: T/H6jaUrhRiC This code uses the AVBPrint API for exactly one av_bprintf() in a scenario in which a good upper bound for the needed size of the buffer is available (with said upper bound being much smaller than sizeof(AVBPrint)). So one can simply use snprintf() instead. This also avoids the (always-false due to the current size of the internal AVBPrint buffer) check for whether the AVBPrint is complete. Furthermore, the old code used AV_BPRINT_SIZE_AUTOMATIC which implies that the AVBPrint buffer will never be (re)allocated and yet it used av_bprint_finalize(). This has of course also been removed. Signed-off-by: Andreas Rheinhardt --- This has actually been mentioned in my review of v3 of this patchset: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20230817214858.184010-13-jeebjp@gmail.com/ libavcodec/libx265.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 70ec6d3539..d7620878b8 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -28,17 +28,14 @@ #include #include "libavutil/avassert.h" -#include "libavutil/bprint.h" #include "libavutil/buffer.h" #include "libavutil/internal.h" -#include "libavutil/common.h" #include "libavutil/mastering_display_metadata.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avcodec.h" #include "codec_internal.h" #include "encode.h" -#include "internal.h" #include "packet_internal.h" #include "atsc_a53.h" #include "sei.h" @@ -182,13 +179,10 @@ static int handle_mdcv(const AVClass **avcl, const x265_api *api, x265_param *params, const AVMasteringDisplayMetadata *mdcv) { - int ret = AVERROR_BUG; - AVBPrint buf; - av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC); + char buf[10 /* # of PRId64s */ * 20 /* max strlen for %PRId64 */ + sizeof("G(,)B(,)R(,)WP(,)L(,)")]; // G(%hu,%hu)B(%hu,%hu)R(%hu,%hu)WP(%hu,%hu)L(%u,%u) - av_bprintf( - &buf, + snprintf(buf, sizeof(buf), "G(%"PRId64",%"PRId64")B(%"PRId64",%"PRId64")R(%"PRId64",%"PRId64")" "WP(%"PRId64",%"PRId64")L(%"PRId64",%"PRId64")", av_rescale_q(1, mdcv->display_primaries[1][0], (AVRational){ 1, 50000 }), @@ -202,28 +196,15 @@ static int handle_mdcv(const AVClass **avcl, const x265_api *api, av_rescale_q(1, mdcv->max_luminance, (AVRational){ 1, 10000 }), av_rescale_q(1, mdcv->min_luminance, (AVRational){ 1, 10000 })); - if (!av_bprint_is_complete(&buf)) { - av_log(avcl, AV_LOG_ERROR, - "MDCV string too long for its available space!\n"); - ret = AVERROR(ENOMEM); - goto end; - } - - if (api->param_parse(params, "master-display", buf.str) == + if (api->param_parse(params, "master-display", buf) == X265_PARAM_BAD_VALUE) { av_log(avcl, AV_LOG_ERROR, "Invalid value \"%s\" for param \"master-display\".\n", - buf.str); - ret = AVERROR(EINVAL); - goto end; + buf); + return AVERROR(EINVAL); } - ret = 0; - -end: - av_bprint_finalize(&buf, NULL); - - return ret; + return 0; } static int handle_side_data(AVCodecContext *avctx, const x265_api *api, From patchwork Fri Mar 22 13:33: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: 47312 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1743:b0:1a3:ac71:9534 with SMTP id nw3csp137277pzb; Fri, 22 Mar 2024 06:33:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW2wrkyAnvBaTtKuLIDpBaK7WN0m1AHyjnBr25W/89HHrSbAD+WfpSK9co+ew91ckzDZvJ7dX5dkJ7yleW4Ab0G5i54KCPJScobdA== X-Google-Smtp-Source: AGHT+IFAefYNqIJlrxEgE1jP8Y+PkbnQJ586zu4lOtFmZaRiew9jlWJqKZiAFaWOeNAxzifVExVv X-Received: by 2002:a50:9ec2:0:b0:568:c6a2:f427 with SMTP id a60-20020a509ec2000000b00568c6a2f427mr1540030edf.27.1711114433448; Fri, 22 Mar 2024 06:33:53 -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 c20-20020a50d654000000b0056bacaac784si900697edj.602.2024.03.22.06.33.51; Fri, 22 Mar 2024 06:33:53 -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=vIsI6CLV; 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 DB2A868D5A0; Fri, 22 Mar 2024 15:33:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02olkn2035.outbound.protection.outlook.com [40.92.48.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7F03668D50D for ; Fri, 22 Mar 2024 15:33:42 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bHOFpgLiviGi769CKoKlq/WM/FXAsaOk6ECDVKbYQkKFUUzv4k1TAqrBWStvuwBT2ADjdjNzk2PXDc9CSvGJdcJMs05bp7p4w0+bTsAeSHo+IaJ2stOW8fohCKUSrba54DHMdgQVFqvlKrJWAE47yL+Rj7IWXA0ha682MkufD4s5pQ1RfLZbdaZ+bcHICHldRD3HCTx/8KSeWUqZlvwCDSA5XyLQEdtz3YN05QmJ1zy3gLe6yc7xr+07WNLAbu59RnrCV+bwt4xUlwXIjn3DTn9ml+6N5KcAslW0RFPsDU+1wp8uhLGrq0iPacqXZdrtVEgvt9ECOqVmu87nb5Z8qw== 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=ArpVP1aBK67Yo1fV4xRWZrnk5F+oaJJUclP50zq/nkE=; b=I8It57PDqk+z0aJi7ofbdjeCKAMIV9I2QgXVHghABByJ3px8nKWYzUgTSmQ1DM9B/KG/uf3w3MDGCdGm5YmF/ihoujpCgoIPbxe32WD0z8ZWGa6L6G0j+zOS6rPWa4+7jxsH3EOzi4mD1VlBO6hZ10+XI4hv4/fGaWRkcO9t3yRlR1m+Xrv/rPsJHRW2LcM3UuhMVVRjDzIGpuJ/oXDVio2Uv21lnPd98hu1JSftJrqz20MU+skrkGxBiR4C3YXOcnHIbErsrlDPIOr501PZI/jdgOv0eBTEiO5MkA0+WwoI9/IrYAQA/6Pe/a0DFNkSOr6lgICXyUQnQcgRBr6i5w== 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=ArpVP1aBK67Yo1fV4xRWZrnk5F+oaJJUclP50zq/nkE=; b=vIsI6CLV2PoheUknP05owi9syPG7SK3lx87pp3N5J4RvRzld+xZy+NCLYyssOh1Vd0G9UlPd9qgz4I7rJ7oZvQg9YwkRKNqbZVAhsQU39JQrzIFaSf6Rc1FDNKcFiJ0uOe9YQHYsEKaYKzm4Hov+TfcloRia54iEkbtAPBGMCBZ2yVEbiD9482i9tNBFGbR11oZvKPzXlPy602dcadN73UjFxH1tk5r9Xhu8ObnjlsGbF5SIy0dwHh1rFxRfK86R2k9/bOZEWxxZhrH4mlWKx4H65mqTaB/9W3KxBX6o63ENhXr6tWgzWQKTHDM/Vk22WIRC3Irj/XGH1v+D4HQymg== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS8P250MB0165.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:374::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.15; Fri, 22 Mar 2024 13:33:41 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7386.025; Fri, 22 Mar 2024 13:33:41 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Mar 2024 14:33:34 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [MVYOuOjk9He/gzCB5/teml0mwDGY9dsu+cOEiu4A0KY=] X-ClientProxiedBy: FR2P281CA0175.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::12) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240322133334.191451-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS8P250MB0165:EE_ X-MS-Office365-Filtering-Correlation-Id: fb01fb2e-1f1f-4461-7db4-08dc4a74aff2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EBcFFrY87oaVsQFQNaBfbCCqVr7nRnR6LYfiYNvxTG9UVhBPnb7AvvyoglMclw3g5zCwtR+bKTejoFUCQKulYSCK2R+3xRFLsDARtoIoli7kc9M3IZCoffMCoIdFEzEuLz+KaDon6oRcTqBjEF+lukW0J/vAsX/RdvvnZBlTHgE6qBxNJqYrTGqpPhInrWf2O4LVy+fpO8t+XcnNA/AP67uaPo3OTY7tLiR7NwwbwlSi8vG9AE+1lo1ipnYrpSgLyrwW2kVSFiUwfEp/Ne9qF9gaZTRnZJ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SdmnxUePmnM4zBNjZ9B6MtyV30lhvGSw6ZECgDt7hLzdXYcplcF2efffNz97xoqU7cCFG3FBz38KIkisibvVqxiWhurYNd8f4imlxEsKFVQie4WIyB0S66DvWsBdqsDjuh1yVqud/1VErunT4VFoGpV7gWT2MMdg7LcBBsCoHhcaq0MhvTFipYXv80HAstxTru1zTdrmMALxsGTA0zTkMNz72b9XuWVhoiJ93h9TxhicwOMK4KCll6f4DOb85wXwJ7X8OeqyIjcNRMSEKXgsqNMXfld3Lv7CFAFz1XMmBZCXVpyYzUD4knULSQEPfqDd/LPSyJmCAsVkiXSJ1kH9GRTC3LXInMCQYJQdNXB6ZeZPxjwN4b4C2n0E2e5Fo/xgPI92Nx3lspKtltghfLRL9CYuHTXv+fHiaslpqrU5Mupp7sa2nuUAIqgOrFh9SzEVezopXB77AR0FekrUeCBWh43g01inCymDIDzkdJCArT2c7rnyi7iSrjqIpxlG6IMWQWBOR9QQX5akM3+Wah8Chd7HOHSoQieS9EUCAU2qtMfWXBi2Q+aTxiwUc1/inDIEBMnM6RrbCd193itW6KJrZ3Km16DE6fiLTU1FlubaWp49HXc/kFwauu+b3Jtw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb01fb2e-1f1f-4461-7db4-08dc4a74aff2 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2024 13:33:41.0413 (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: AS8P250MB0165 Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/libx265: Pass logctx as void*, not AVClass** 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: 3mipUkUb82Aj The latter need not be save, because av_log() expects to get a pointer to an AVClass-enabled structure and not only a fake object. If this function were actually be called in the following way: const AVClass *avcl = avctx->av_class; handle_mdcv(&avcl, ); the AVClass's item_name would expect to point to an actual AVCodecContext, potentially leading to a segfault. Signed-off-by: Andreas Rheinhardt --- libavcodec/libx265.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index d7620878b8..45349a85b9 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -175,7 +175,7 @@ static av_cold int libx265_param_parse_int(AVCodecContext *avctx, return 0; } -static int handle_mdcv(const AVClass **avcl, const x265_api *api, +static int handle_mdcv(void *logctx, const x265_api *api, x265_param *params, const AVMasteringDisplayMetadata *mdcv) { @@ -198,7 +198,7 @@ static int handle_mdcv(const AVClass **avcl, const x265_api *api, if (api->param_parse(params, "master-display", buf) == X265_PARAM_BAD_VALUE) { - av_log(avcl, AV_LOG_ERROR, + av_log(logctx, AV_LOG_ERROR, "Invalid value \"%s\" for param \"master-display\".\n", buf); return AVERROR(EINVAL); @@ -230,7 +230,7 @@ static int handle_side_data(AVCodecContext *avctx, const x265_api *api, if (mdcv_sd) { int ret = handle_mdcv( - &avctx->av_class, api, params, + avctx, api, params, (AVMasteringDisplayMetadata *)mdcv_sd->data); if (ret < 0) return ret; From patchwork Fri Mar 22 13:57:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47313 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1743:b0:1a3:ac71:9534 with SMTP id nw3csp151099pzb; Fri, 22 Mar 2024 06:57:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVPRd4ZrUM62kuL5GVw/6rUrAYZHOSWTkhG7zhtX/D8Yfrynuec2PFAEc/Adl2aQ//2gQeRTVQsGjVB7J2kLAFF1bAshBSwhsCpnQ== X-Google-Smtp-Source: AGHT+IH8Mk7pTSUxgWDXcT/kRtYvYGDC8D9D153ZvIiHqKu9ao08ylPTST7dh0xgQCzAme8msL+I X-Received: by 2002:a50:8d56:0:b0:56b:7e43:a3f6 with SMTP id t22-20020a508d56000000b0056b7e43a3f6mr1343527edt.40.1711115866924; Fri, 22 Mar 2024 06:57:46 -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 c18-20020a05640227d200b0056bdda17589si866874ede.345.2024.03.22.06.57.46; Fri, 22 Mar 2024 06:57:46 -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=e18mfous; 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 DAB9468D597; Fri, 22 Mar 2024 15:57:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02olkn2079.outbound.protection.outlook.com [40.92.49.79]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 986C768D4A6 for ; Fri, 22 Mar 2024 15:57:36 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c4+LFkIrrthOg3u2mh/+225NJOobkPpVoe5rMoiTDAeysse1/Q8R/z1kdz3y7KsbL6B5RmU2vNhFdwj2lTnXKjwdumITjLAE34qxhXIZ5lbPSbwejP04ao51robWMKLu8AoG1d2q8PxMfwKsd29bYI7lH3gVHiZLVij8n/kgI52PmYkZSeta5UQJf6vyT2ptdIDAxj/kJOAG8XgzUHa9NFPfEFiUDPLUh9hjavDCP9EbsipleRmrEEsW0NKX3WvGKlaAOKHBSEl8CUstCNoxKX6z1wF7+qF5NwIWvXgh5SLgXowPjwga7X3XFlYenJnCIf4lYb/0159cPDQxEABCbw== 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=8Jexa1Fijv59QPD3fCcT0yB47sCQEDhZ2lwWkT7OO7w=; b=eTLfSINGC1Ay0L2i22fI/90kb9Ei7hdzo1Fr2fXDA/yIjdvs/YW2RYdL0WD+6S86/2Ro0aiZv0WSh3KMTcKokS3z7rwgqWZW/d3M88k+UKJXpqTSKvEuDzZLPHndBIfv6rrVYGHoOVzBfsSp+HIIqv7wda/laUee6sQYirgnYcJxJa9f9klRqDlsPckBzzC0h8Vb9RXGBmrQyuLfKfPgBw+NJ7y01WW7q+cYtyPgKOk2N3CuZNoUXr3UAZod96O1XH8QBt4yhbOuHmUVwvEH1GcYwVTj8tvk2j3scGPdnEFGEm78SD2vRTFDdVBMCA6oEdZSgYRoAsJRs1fiJKs+0g== 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=8Jexa1Fijv59QPD3fCcT0yB47sCQEDhZ2lwWkT7OO7w=; b=e18mfousr09bNptA1nzoEJQ+JBm4fLkD166zBtywip2L4/ds0SUw+JBfwN7GKmD3Rib4BeqIlcsRPRK1Mc0VW1IaJ7/ropO0ug7u8IDNzZZfY8E9t6ZgzaLlir/uRmukDi/NfLekMguei6PYLXyfu/xd4tfGCFrjV8mS6W9lDijqYkU1PTJE1Doku0S/2JB/veFJqhLSyUPwzP6cWHO/qY8bB0HZs+ggZxdMUPVkF39MHh2iin1GKCkCoazFOZiTJTmddmH9CMVu5s+fqpkHoiHGWMT2MAYtL2TNkhYX0yprJLP0ISU2FUa3NNdmd8NWdaiTYn9HFO1l4WJha66NXg== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS8P250MB0069.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:377::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.24; Fri, 22 Mar 2024 13:57:34 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7386.025; Fri, 22 Mar 2024 13:57:34 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Mar 2024 14:57:23 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [bXlFZWHUPsSv4H7saM8K6XWyF6Wgktl2] X-ClientProxiedBy: ZR0P278CA0172.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:45::6) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240322135724.193748-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS8P250MB0069:EE_ X-MS-Office365-Filtering-Correlation-Id: c9860539-9606-42ce-f69d-08dc4a78064a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mQzQoT1q0kvHdoczalv+EY2nGvL4Z9k6M9e1LBqjBId4tygulBoVpQGn/a0jYgpat2M6ig1DW7qKTxIfz7uwIR8/4IaRatoUwzmlOppPD3gMyss31yJMm8s5QZdO7WjE8IMSggOegBpsnRM/mUxoqk8//CHLSpODZMgDnSlfnMVvMtHvg4CTWbJjQFCkzGWJFxOOgC0FwVXRpG4N43/n9lYIXgBhkPg3JgstTou5zqKojlSJOYY/1Z1jywyyL5A7k7Di5toHOy7gq+kzmNoI4LOf/7ysdKk7uCcgGIvGG0Xi725c8nM0PW5+HCyx4ZsgLMlZmhjiXuMEGTqxvF89C2O5/NdCYGcHX0AtCSgNzmKwFZNq3BaUpiVr8NIKQq2MVA7x2Lad6n2eZCWWIpmO/482DXBiVZmQ1XZrsxbVHk/YAe+2ZoR8Q7FGuhEBCR64BifroO/LeK8g/nDacyOa3MPcwfabkE+iHpHCPblgZERfepnw57Fx4UG2RbeZukn4uKNm93Jb1LIMXvfHkJ5HUinJc2B7R4owbxy+RWxGY2Z2kEzca67M9YdqYx9FaBWZ6JJuQO46MEJKvS8Nxm27UxiG+TkKUKOHESlYqJW8ySqTuL0pBbdNg02wnx6nTV8e X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b0EHzePHxd7alnxnrxSFYHxsA+FWbsvwHJZ97tFpqhFmqKlmTxYHNJs+JXRAi6Ap3B890vZLS6LZ0HQIo+izPUEISspKgKnfj3Tarp3Sqx+V1beAL+MzlVIFUpxkWAJ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bbVqeoVqk8bzf7RU4kwXcJxRbLsaQ7z/Hid5Cv35lBQzGljQtYScjMcaaYwbU7yGFSflttLxBAb+xgdUUbQyifyro8lJLZw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9860539-9606-42ce-f69d-08dc4a78064a X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2024 13:57:34.4308 (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: AS8P250MB0069 Subject: [FFmpeg-devel] [PATCH 3/4] avutil/frame: Constify av_frame_side_data_get() 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: KXY5IcWNFzBb Signed-off-by: Andreas Rheinhardt --- Will bump minor and add an APIChanges entry for patches 3+4 on push. libavutil/frame.c | 2 +- libavutil/frame.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 89db687d9c..8598aa98a2 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -813,7 +813,7 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, return 0; } -const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData * const *sd, const int nb_sd, enum AVFrameSideDataType type) { diff --git a/libavutil/frame.h b/libavutil/frame.h index a7fc909ad8..cf9ffe1ba9 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1051,7 +1051,7 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, * @return a pointer to the side data of a given type on success, NULL if there * is no side data with such type in this set. */ -const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData * const *sd, const int nb_sd, enum AVFrameSideDataType type); From patchwork Fri Mar 22 13:58:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47314 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1743:b0:1a3:ac71:9534 with SMTP id nw3csp151505pzb; Fri, 22 Mar 2024 06:58:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV6q6jKD/abqEE+Qxexw/o2QBTFWGSGq/qzZgp2XqlnO85RZ76Q7+YGemZUSLwLbRv7qu1NwA38M8yzNDFkM0FkSo1UhaRuOdn5FA== X-Google-Smtp-Source: AGHT+IHXeE3d6tmzF4NjmzpmikZrUNDXTRLvFIhgKUyNSHQVNmo9+/Lxwr44ZpKFdrDHTJL99hS2 X-Received: by 2002:a17:907:2d8f:b0:a47:355b:a024 with SMTP id gt15-20020a1709072d8f00b00a47355ba024mr1123595ejc.8.1711115916581; Fri, 22 Mar 2024 06:58:36 -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 h15-20020a1709067ccf00b00a46bf3dfba3si932708ejp.1041.2024.03.22.06.58.36; Fri, 22 Mar 2024 06:58:36 -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=JP0Pm+XN; 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 03F2768D598; Fri, 22 Mar 2024 15:58:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02olkn2068.outbound.protection.outlook.com [40.92.49.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 204F768D4DF for ; Fri, 22 Mar 2024 15:58:27 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nh+XIv3vK4TqbkYVgwK+1Lc5Ip9eajnsAYNroIi8OtCjR3leXMQLXAg3zHkT9aKGpIP6FizlKcJUyQdYFWN3ZBh9K7mvZtD/Hd2Dwex5a2zJOB5Hr7xq8mhqtftTG97xFX8mAycXK5jVryR4Q+ZK/bngGIYGNlP1Bi0HGgcA1R0Mtpu8+J9DKasbYaMaMNBnQgHX2eJwz83qqYxizeILMFUabL91Sap761HvPNQ8vMYqG+tBK4Fh+lXP5ZVpih6lqFOfgV/v97CU0tT63jzlnyaC9oCsxhdGtYXii+fbH7Qr9gyQv5z/n9LwhCtNVtLvOm9bzKOwd5Q3vvDE61bSYA== 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=kk1+BXe8XLexp3UPXr2Vf6rPF+YZHBbnuMXWoY0MZnA=; b=l07Ai7xjiHP09XfWKsU2+nrOEG4zBx7tATIK4Z/5vNndBVsWRTee9EoHVIterqs9NZ2BPxrvCg+w9YAl1Y7haoqywo3OcJ5cmLtKerbdcVp4xI34WTnwO5jNvYG41n4b+rstiV6Nlacxb0+eP/vzu47PLxcl3go+PZmlkpCYg/wSWONXkILwBhAteFbLrvxeMe0Ih3p327MwzCLTabpKWvytk2W8s0DquaPP36ZgnFYECfgkdRZNMFb+78T83cdH97c1RGPoTtHKBkZLbYmIS1Ox88FxV73xGyAq0Q65B/X/NDSB83z4h1LB/LLI5JagcNsw2moyiUZrdn+rhlXITg== 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=kk1+BXe8XLexp3UPXr2Vf6rPF+YZHBbnuMXWoY0MZnA=; b=JP0Pm+XNjs7fVEseH1w0FRUPuJQtI5BzqKpDHpqMdldjuqOc97uAaR/YQD41ptQuiqCLNhSxMJu7NibRuOkDuFVji5w1W+fVa0fpnsr6ltLPteRnEXWJZ4zop3Z3H4i+2JUJJumZEq9zS0+uVypzu1+gnefpSvAeqhmVGtCGTZ0xNPBkgdHVMk2xZZG5D6H8J9wMppBiwsmx/UYW8WUzTaW77IQRqAssC4M7eXKa6uLyIDAudLg5CtetjBr4TH7Uh+8X08KUIHGp4JGyLEtfMI7dwEXcMU5RtkfiJ9Ha2rrHHSamHvJ6FhAQhm/cnmpNTKFjsVyJqbrNnOpwWnBDhA== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS8P250MB0069.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:377::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.24; Fri, 22 Mar 2024 13:58:24 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7386.025; Fri, 22 Mar 2024 13:58:24 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Mar 2024 14:58:16 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [6m8XZ/6S7J04daK8hk33LdJb1PaqljfErTSwxYY+DMY=] X-ClientProxiedBy: ZR0P278CA0213.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:6a::19) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240322135816.198916-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS8P250MB0069:EE_ X-MS-Office365-Filtering-Correlation-Id: 60fd4aa4-f09e-4fdf-2ee1-08dc4a782415 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5l7NOPMIoBVqHehkhBnfw6/Jca7OURi9uZvAC+QJEZBVt8YAU6JPCmhBqzdRX2alWclgGaG2Adm0TNwZXQqvoq/t1Mh00To9fPgytWvsyCOG6dy1DEvpD7BWRGPH2mufZdTUpXjf+giAdmyV7VQ0UOYgEtclts+WTkP/LCDIOwEZs1HOn5QoOif3wV4i+v+AxO7wneiBG96E7AVC3WFIy+XBICKa5uKDgjDtPdfi+xPQ1JuVZ0ZBTULef+i/37M+wuclEkobAg4qU9MU1H5SFmJ4UqRN12yTYiA7f7K47YwexsaczhU5DhNEsRzXB553vNsL+txHbXJvb7JywJXW1CCV1+uXp62VovccjjIdFncy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XBG0oBMayHbGVxRqK610pFxvw3Bjyc/tlkU1cJL2JHqDeLYnokfSuQBMZFvMAEc45gVXq9lRDbMZOFxjg35x+VZdVfdTILV9iyCNG/JkYGJy2E+BeqXDJmhPqU7xCjCtrGkaMEMNPBih31HoPYRs+6HADnZllb9jkwu6KxsOhJhBCe3ruoirJAHy3bS67VoqvL7h94zg3cUOjqwSNlPFC/ABvTtQkE9vELNO6CiRKuX595JQXpplyGN0+vYKIPurwvzpj7QfQ3chtiyS8OmvF/kK/LiROzIVv0bXesY52Y5y2E1RBrVEKXWfYWOdwh0aStQ2m0WRdL2E00WDtWdw70P7Y6kxwpYH3tGaxYHr7S8n/81OBYFT2BcMbN62t/gXYllOtJ6ewGFcrkwKarUcgVw1II/NkYTRtA0FIMkE9VFBcLGZDRg509lKjD27fRKqHpwSSH/Ugz8xmJBxIjxB7AQVSZhtphn6FqyCBellSL2rxkTtuW1IHU01OA7e4js2S4proJh8aL4IahoZRbCpeqI3xoz9z3x0csqnxA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60fd4aa4-f09e-4fdf-2ee1-08dc4a782415 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2024 13:58:24.3962 (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: AS8P250MB0069 Subject: [FFmpeg-devel] [PATCH 4/4] avutil/frame: Rename av_frame_side_data_get and add wrapper for it 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: MjPf61EmXNHb av_frame_side_data_get() has a const AVFrameSideData * const *sd parameter; so calling it with an AVFramesSideData **sd like AVCodecContext.decoded_side_data (or with a AVFramesSideData * const *sd) is safe, but the conversion is not performed automatically in C. All users of this function therefore resort to a cast. This commit changes this: av_frame_side_data_get() is renamed to av_frame_side_data_get_c(); furthermore, a static inline wrapper for it name av_frame_side_data_get() is added that accepts an AVFramesSideData * const * and converts this to const AVFramesSideData * const * in a Wcast-qual safe way. This also allows to remove the casts from the current users. Signed-off-by: Andreas Rheinhardt --- libavcodec/libsvtav1.c | 6 ++---- libavcodec/libx264.c | 6 ++---- libavcodec/libx265.c | 6 ++---- libavutil/frame.c | 8 ++++---- libavutil/frame.h | 19 +++++++++++++++++-- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 6400a6507a..8fa42d590b 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -180,12 +180,10 @@ static void handle_side_data(AVCodecContext *avctx, EbSvtAv1EncConfiguration *param) { const AVFrameSideData *cll_sd = - av_frame_side_data_get( - (const AVFrameSideData **)avctx->decoded_side_data, + av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); const AVFrameSideData *mdcv_sd = - av_frame_side_data_get( - (const AVFrameSideData **)avctx->decoded_side_data, + av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 3d195fa6b6..eadb20d2b3 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -1044,12 +1044,10 @@ static void handle_side_data(AVCodecContext *avctx, x264_param_t *params) { #if CONFIG_LIBX264_HDR10 const AVFrameSideData *cll_sd = - av_frame_side_data_get( - (const AVFrameSideData **)avctx->decoded_side_data, + av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); const AVFrameSideData *mdcv_sd = - av_frame_side_data_get( - (const AVFrameSideData **)avctx->decoded_side_data, + av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 45349a85b9..d3e74eaacf 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -211,12 +211,10 @@ static int handle_side_data(AVCodecContext *avctx, const x265_api *api, x265_param *params) { const AVFrameSideData *cll_sd = - av_frame_side_data_get( - (const AVFrameSideData **)avctx->decoded_side_data, + av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); const AVFrameSideData *mdcv_sd = - av_frame_side_data_get( - (const AVFrameSideData **)avctx->decoded_side_data, + av_frame_side_data_get(avctx->decoded_side_data, avctx->nb_decoded_side_data, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); diff --git a/libavutil/frame.c b/libavutil/frame.c index 8598aa98a2..7dd37e5490 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -813,9 +813,9 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, return 0; } -const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData * const *sd, - const int nb_sd, - enum AVFrameSideDataType type) +const AVFrameSideData *av_frame_side_data_get_c(const AVFrameSideData * const *sd, + const int nb_sd, + enum AVFrameSideDataType type) { for (int i = 0; i < nb_sd; i++) { if (sd[i]->type == type) @@ -828,7 +828,7 @@ AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type) { return (AVFrameSideData *)av_frame_side_data_get( - (const AVFrameSideData **)frame->side_data, frame->nb_side_data, + frame->side_data, frame->nb_side_data, type ); } diff --git a/libavutil/frame.h b/libavutil/frame.h index cf9ffe1ba9..373866c600 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1051,9 +1051,24 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, * @return a pointer to the side data of a given type on success, NULL if there * is no side data with such type in this set. */ -const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData * const *sd, +const AVFrameSideData *av_frame_side_data_get_c(const AVFrameSideData * const *sd, + const int nb_sd, + enum AVFrameSideDataType type); + +/** + * Wrapper around av_frame_side_data_get_c() to workaround the limitation + * that for any type T the conversion from T * const * to const T * const * + * is not performed automatically in C. + * @see av_frame_side_data_get_c() + */ +static inline +const AVFrameSideData *av_frame_side_data_get(AVFrameSideData * const *sd, const int nb_sd, - enum AVFrameSideDataType type); + enum AVFrameSideDataType type) +{ + return av_frame_side_data_get_c((const AVFrameSideData * const *)sd, + nb_sd, type); +} /** * @} From patchwork Fri Mar 22 14:41:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47315 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1743:b0:1a3:ac71:9534 with SMTP id nw3csp181772pzb; Fri, 22 Mar 2024 07:41:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVNrl1cSzicqDaB5jlt2oQHMh7OFJaKRdVLeP3znZHI1xKKVORYzFXJcG1VcNTF4StPJ7OI7qIl6Tgb6XST631CsFRV0lL7cZ9goA== X-Google-Smtp-Source: AGHT+IGfT0pmrPyY8cxwGJVpP2eQxfSQrBhOD/IIcnZJeWUv1g2CcLel/sPP7CY/ytDb7SJv94e6 X-Received: by 2002:a17:906:1453:b0:a46:ed72:6bb4 with SMTP id q19-20020a170906145300b00a46ed726bb4mr1787010ejc.72.1711118518967; Fri, 22 Mar 2024 07:41:58 -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 p16-20020a1709060e9000b00a3e64ce97fbsi939479ejf.468.2024.03.22.07.41.58; Fri, 22 Mar 2024 07:41:58 -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=Ar4ZyKVS; 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 8AE5968D5AA; Fri, 22 Mar 2024 16:41:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2085.outbound.protection.outlook.com [40.92.74.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D4C8268CF01 for ; Fri, 22 Mar 2024 16:41:47 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hauxEWwmkIz2a9Am9acLjDguFNuS76TxtDBuNnE4VzQL6L3JNj5btdEL5BJ5JjaPaLefMJbUlNBYmEaBrX1sBZYow83m0gLkjGS6K/APvbR7Xj/eBzsz8hB4qiuk/1Eq55VWcy4mp4muOyYIw7ucYiK2et8ECF5JOfvex7rL1KDWEFhH63CbFKTkoCyE5hb8bbtdwtgpT+jYHG3IUlLSz3cPrOJ+j5QTIIRaKEcyuqXFjQpHM6JtiSIpNjLTVil5YZBat8C4UQsZYR8f6ZyR8PKSpLJLxN0gHeZ0AzetYkuiSVNJ7m118gCiXTk/7mLcZq1FvRCTlNAYkqlfFFLd3Q== 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=e1Ewv4kDgkJnqnEflbybnSf1Tx4/6PTpZNYsH65RkKE=; b=S8UjHnQh0aHpJljvU7XoLZWtEoMImjB6tNTfMkKFg7Kxv8pf3KUZxi8oHpyfQYz5jMIv7t2If3tc9Shaaec6ftxqG01jXsartGc7VJ1MPf7jFjv8TuTviSn2pBblJbeL7GcPzwBl5/kfXruoyJ0RmQEFLIdK3zlbbrdfeOZ3UY8dr2P4eHXIiaA+35sOTJaJh6xyWp1SSUMYNadyKHE4LxMQF6GmRMUc+vIXd7KDl3Uypa90oBFONPHAqhCxUNqjG0FqtfuuTnLaVXUSpVu/8tGLOGculKrGa+jnPWAn+VKwE83vw1dP9kE/wDbcAnDoB0sVMTtHoxh2XAnViqoc4w== 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=e1Ewv4kDgkJnqnEflbybnSf1Tx4/6PTpZNYsH65RkKE=; b=Ar4ZyKVS5wB03O6gJyo6b79n72wUD5oXAYAJsXku45zgzg2IhtJxlzfUiu1EJyn85IxtuQz69GJ1SAM7kMDIg/uhRJD1mv56+G0MULFuxHIQqnU3dP9AjObXZI5CL5mTEkY2B5EUSINJFYtx9rjrQ/wKhZd1UXZqB7QHtHM6W/ujk77Z1NQguPwIACOYrB2XWa7hZfHgu06ydkRYVwzh45SpSzifcgDadYFZ5ZKSngj1iswqht5SKnup82BFGzXyNhCAprggA3HW80U2d4JytBsBDkdeuJxIZ+bB0WvHDiX0fgkcZwvWPDIoTnyin5asV+VwGgV9VPhpi9mljDcOLw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0238.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:277::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.24; Fri, 22 Mar 2024 14:41:46 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7386.025; Fri, 22 Mar 2024 14:41:46 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Mar 2024 15:41:38 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [RwuyQ1FjITs2nXhsWWmzvvVuznZocP8ExMj0FE+rLBs=] X-ClientProxiedBy: ZR2P278CA0053.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:53::11) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240322144138.199549-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0238:EE_ X-MS-Office365-Filtering-Correlation-Id: 17645a24-bed8-4212-59fb-08dc4a7e32eb X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqkjmXb1vlddM5aSa/Epk3AZFAtg5rGR2rBalRY+BGc745mgduPNssppdh5Yfqx9Vd+euVu0+3t0ljWOVrJ3qfCHAwRIAcN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BMZCRgWOKqBKn5zIMRhFcSFKpG5GFMYMRBy+wH2frbyM661bZtKTgKd/Z0AmrSVpRdjQ3y3/xSxP7KLFjHF9rvxQVoHYDsLIHfglXQ9jtnYMELUeYyZg1uuJZ0GYTYt4tIefor4ER6KCmFOPC6Tf1Nn9KFx8Ky5c7fiaijit6wvRh6mP0GCFY61GXF3iEZ2231htkNiNyvGo1YwRNkVOzxckX8lhpsIKRtnQUljnVRWeV0dtBg+atQ0r0NswxMSP6LzPe4XW1CAHHbPORQ9il7X7geFf6qOvBeOU8n3f94AcCq3Zo+0alq4zDxP7rm+bsMqV4Dz/TyiKTSIIeIufGWsI7LiE3y6yIAZNU6JuAT4k0XoCVqKH2YJ2l9zAe50JkPdNN1q/ZEl5Gdzf2BqNSC23rO2uouixqwVv25itl4Pc4rj7pMuJN+yjjWSyHOembuvcCjsVJQA7aJJ0ZtEbBXR035nkuu3GjpaMVZySAFBQ1BPa+t7jdC4Foai2QzeTxZpZNGljYNjDBAQmF5t9NzO1V6Impc0Hob7EArMTlIINYjcvg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17645a24-bed8-4212-59fb-08dc4a7e32eb X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2024 14:41:46.2989 (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: DU2P250MB0238 Subject: [FFmpeg-devel] [PATCH 5/5] avutil/frame: Use av_realloc_array(), improve overflow check 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: GE76dfQjXU0o Also use sizeof of the proper type, namely sizeof(**sd) and not sizeof(*sd). Signed-off-by: Andreas Rheinhardt --- libavutil/frame.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 7dd37e5490..d7a32cdc92 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -721,10 +721,11 @@ static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, if (!buf) return NULL; - if (*nb_sd > INT_MAX / sizeof(*sd) - 1) + // *nb_sd + 1 needs to fit into an int and a size_t. + if ((unsigned)*nb_sd >= FFMIN(INT_MAX, SIZE_MAX)) return NULL; - tmp = av_realloc(*sd, (*nb_sd + 1) * sizeof(*sd)); + tmp = av_realloc_array(*sd, sizeof(**sd), *nb_sd + 1); if (!tmp) return NULL; *sd = tmp;