From patchwork Sun Feb 25 01:55:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46509 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51b:b0:19e:cdac:8cce with SMTP id gm27csp690993pzb; Sat, 24 Feb 2024 17:53:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWdjVRJ9zcvxKSicFvxVmol5OrzJGvlFdnuTII6NtbCkBtQWSVfX91pD2k7+Un++0nVx1C/v4Z2qgILWPlUEfidweuAbQn5CxK3WA== X-Google-Smtp-Source: AGHT+IF7Cv0uevddBfcHE0cqoS+dpEWTs82shkhPy6LgPTOzeljpU97rvYb7gwlHpDy4+NqDQbR2 X-Received: by 2002:a17:906:5391:b0:a3f:850e:acba with SMTP id g17-20020a170906539100b00a3f850eacbamr2536690ejo.3.1708826018468; Sat, 24 Feb 2024 17:53:38 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id rv4-20020a17090710c400b00a3fc641ace9si934626ejb.556.2024.02.24.17.53.38; Sat, 24 Feb 2024 17:53:38 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=gvPAy8x5; 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 7221868C0A0; Sun, 25 Feb 2024 03:53:34 +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-vi1eur02olkn2087.outbound.protection.outlook.com [40.92.48.87]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFD5868C27C for ; Sun, 25 Feb 2024 03:53:27 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L/EFO/O1ws/58zYnPeIGN4bpqQ7ArnLjszh/yp9lnRPpdEmDahCJ8+SuHVmTjlS26oD6r2EUmEo/agYPH+pd2aaM+zNCsZpuoA5i/ILVL+tuLMcNoBNEgdT8wP+Wt6ig4NbVI4qdTXX9YW8j50piCFlqX/3xNpbxx9RO4vQBzKuWG81sKSrm9YGOUNs+T01uwWgGJKDJUBHO0U8nvXhoXAs+UCjoOOOB8t6SXDbVqXbhqinmhPudy2voyam75PJ5FEkDucJw56zjOpFw6fMBqDECrud6DAU9TjjG2en42+Ltpf1C4I4Hmd1ylxW4oqurHrqg3oHQAQWwxLUldv3h1w== 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=1s6+H1zuEpGf34WXXvajvT8BV3ZoYK028FLQ4N85kF0=; b=ZA3ilW1lmYCpyWu0EJCdx3INvVD8A76YLjbqns6X7nhCpQUY8dDft8cB5Z/2FSmw06Hq1948WkKrz9RMZzHSrdbiL8YLpJrirmUlGLIsnPp2u0IGHkrLNKGFFc+Sdas4WIYRSiIxO8v3eSXzLbKjLo/VhcdKyJY82qNo4oyqOcEPUwdtb86VRyUff5KZGRZG6QolK/AEQwQQ5Tk0Qdipw74OgWfHJYKc3gTV18354NMZY8TWDj3hYeVBI6hx8POtpUcrV/M9jcW5LbKwlyd38EeN0MQOmrFxlf8R20t7Hwy0KQ69Yd7bi5YllNHpebxRRNELWNIn3JidNF3iEd5ORA== 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=1s6+H1zuEpGf34WXXvajvT8BV3ZoYK028FLQ4N85kF0=; b=gvPAy8x5gkTLkC9vJEETzMVEGSzpvKZt7BdzvTKQKv2jSlyfWDejED4sV3b0GQHaT/QpAdmzVzCTdSuSidAAl78GS2J6CTmdPDrEwYje0XknFKxtHM7srzNT84VICZn6LCzhkM2m5obAuSZn/RLgXIBxVCTyvCEVC+2LF9dIZlTyoLp9O8XDLuJop5UadV/iq8HPjIWoXO5HCP8EOp1f5D/XdQJ5hDTpWtse6KwnDUrjpHhgnEAYJecTglGd3ZEHlcqjged1owktpNFMeKaBz1ZlSOOBCH3Btv905NjcdoOzRTj/rYjVwSe8aRmcOCTP7241Wx7rylkZ03Mf/AfVvA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by DU2P250MB0190.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:276::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.31; Sun, 25 Feb 2024 01:53:26 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 25 Feb 2024 01:53:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 25 Feb 2024 02:55:18 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 X-TMN: [Vc2j82KEkN7yGymE0xHtxdaJRSvuyAoSZqEK99q0QTY=] X-ClientProxiedBy: ZR0P278CA0048.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::17) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240225015518.3474603-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|DU2P250MB0190:EE_ X-MS-Office365-Filtering-Correlation-Id: 3899a69b-0352-4870-c250-08dc35a48e51 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SO+to0J0ql0sVMx03jAVoy/Ps8oxcchX3ZfmXkacczjSh7itwvEEnSWm8mMa72Lux7sdjzQSjwA9Kp1A/gmjt/X5lW5RnKVuC/ii6gLNLPSEYW6WDqGLmEDEy3O8fx0fshsvL9uhUXkcYfUtl1ZEVN0TdA26Inm0SLFVYBSe4xVH8uYdQOtFPkS2mX93nLkWzgCgWTUOhccWnR+DnocH2Q/2skNmAHF4X47Erq9LFzCrNJhGaUOdmfXmrVANJ084M4oncAuhn/tFlnGZQ9MKIw82/QB8TXi49t4HNgLVKp9Y83kKse60JaDIt7+7WW22X/jN0s1FZX7CUvU+OyQUmz/uue5Qwf/cSzyPSVXuS4SNkwJDM3gNo7J+jfHyclJUM5vWc0EsTqkOKhqr38OhQcI2VGvkho0GIMl5+r5n4adn0SSYg6/iTsVUdvmrF7Y3jsTeio6CIaGXCvzSa8T+aedhjxXFj2kmE8kiyzrtT9RVS2zWTprKW7Ew3LilWo7mpwdGG0wsiztz6DPLID0peNLRmzYgO9VlhHdbmEo1rSiz9f5yxItMjbzAthZwhxBVHB6nLXAXc51GPTWIrci4w9P1+0DBpGO1KdlKordaoAFryKjKSdl96ObEPjZQAgXY X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ilEDnwmFvg3f1W7jaOAeUJPFkbdwAGQCSMLtfxS26QDjrADeG+Z4oBEvs8Ar+o3RnFMDDdbBCmqQbbOS1lBEe/NpjYJWSgCDVtphm0+hdISBCY0iXnQOFfKjAmrmi+eEMtRsd/ca8aWm52SEkvLN+7zLMmfkCUpWB36iB0O6dXPBmv5RawSynnajoBBPoycDoU1u+Zd38PwSkQvziIJwGBzO9W6ifEA6lE8DuKmWlOAoEd4WdWJ/sIleyBhit96hgomsoMoUHH6RxByY2NwW1gHiAMh4Oyu0hBE4dwLmO87CPmD9AebuIKFjekwgwVupRsEWMsdWZRn3mhioLYcmUbIApPAdAL73zSI6Yr4S+X9QOI7mc9qBCpidWSNm983WnUoZ7lkGdKg3Tqq7iXSL7emHlryCV71Fz/hnAAwtK46FPjUFKT2Tjl97xOGP+hMLf/s4/mutUOgxFvP1BpZfGRGe7oJvwGkzb9QLWjGyieEH47/iofqCtyhqmEF1Jm7Kc6bJhxsMA2IIBZzJcuWfO94XV+nBrsmw7zc2ahM4e7UExxU8F0zn4iOOODoOa+zPIqUab/UVGZLB5t8BTlr5yitTS643QYrjHUAdrV0FQOVYVoYJJdJ5tjtp2XoV5juoQyRGwHrLkpvQtHz0dgfCunw4b4R0PFNddqppzVcxwl9i1IqG/Y5Mb5ab6sq1Bv3tPqtJMHitRnFHAFF20Jnspmty3THAfba2CI3+Y7rILDNEwMBBfcK4TGz97M8V/DFUi0IDSvq8H5RINHLeh9wwaF4k1ZXmZfYu/X8612C2HUMCbaMrJWlcpbmRmfMUNnkoR8Eu5rg8GnlzAo+3jobqQUBV51oKon1fHwqoto8KpwgWS861zOelOrHnBhezVRKoRek71XuxtlvEWsEotq2EVnwPJXDaLBgud0Y2Ip11B5Y0N2bVCVtSGIPmkWPk5qK9hiq2Q31wInDUO7SkJF2aJ6FIEbcGTUvrMI6Un0QhAR8vqyL/oo5IV5JFnrTiLXk/Y9u75m9YFImBfgFl/sx2QEoKDxCA9Bhlnt8QELfg1ZaEdOF5PmfUyOjgCBy9LN41kxPDQpXEzX/EoGA9n58tDqoeRop4LYDMXtBdU+KcqahcuIavc13npPq0ZgV133VHFCKSNUTSmS+RNWuiIWkcyUtrXaqlYVJ9AGtE1bmhBWhrF8hNzMc3Qryhj4MmQPYbl5XSf3E3sewpqpkxMmfH2JgNqSvN9Xd1QSlbZ8IqMNFt28dq9/no20Bklb7GvftD/DSNl2wGjc7jQFJbbiCLow== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3899a69b-0352-4870-c250-08dc35a48e51 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Feb 2024 01:53:26.0477 (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: DU2P250MB0190 Subject: [FFmpeg-devel] [PATCH] avcodec/cbs_h2645: Avoid function pointer casts, fix UB 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: k0cpkxOnsQ/U The SEI message read/write functions are called via function pointers where the SEI message-specific context is passed as void*. But the actual function definitions use a pointer to their proper context in place of void*, making the calls undefined behaviour. Clang UBSan 17 warns about this. This commit fixes this by adding wrapper functions (created via macros) that have the right type that call the actual functions. This reduced the number of failing FATE tests with UBSan from 164 to 85 here. Signed-off-by: Andreas Rheinhardt --- libavcodec/cbs_h2645.c | 15 +++++++ libavcodec/cbs_h264_syntax_template.c | 35 ++++++++-------- libavcodec/cbs_h265_syntax_template.c | 58 +++++++++++++-------------- libavcodec/cbs_h266_syntax_template.c | 8 ++-- libavcodec/cbs_sei.h | 7 ---- libavcodec/cbs_sei_syntax_template.c | 47 +++++++++++----------- 6 files changed, 88 insertions(+), 82 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 2fb249bcd3..8e4af7b2cc 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -235,6 +235,16 @@ static int cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t paylo #define FUNC_H266(name) FUNC_NAME1(READWRITE, h266, name) #define FUNC_SEI(name) FUNC_NAME1(READWRITE, sei, name) +#define SEI_FUNC(name, args) \ +static int FUNC(name) args; \ +static int FUNC(name ## _internal)(CodedBitstreamContext *ctx, \ + RWContext *rw, void *cur, \ + SEIMessageState *state) \ +{ \ + return FUNC(name)(ctx, rw, cur, state); \ +} \ +static int FUNC(name) args + #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL) #define u(width, name, range_min, range_max) \ @@ -2070,6 +2080,11 @@ const CodedBitstreamType ff_cbs_type_h266 = { .close = &cbs_h266_close, }; +// Macro for the read/write pair. +#define SEI_MESSAGE_RW(codec, name) \ + .read = cbs_ ## codec ## _read_ ## name ## _internal, \ + .write = cbs_ ## codec ## _write_ ## name ## _internal + static const SEIMessageTypeDescriptor cbs_sei_common_types[] = { { SEI_TYPE_FILLER_PAYLOAD, diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 0f8bba4a0d..4d2d303722 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -510,9 +510,9 @@ static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } -static int FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw, - H264RawSEIBufferingPeriod *current, - SEIMessageState *sei) +SEI_FUNC(sei_buffering_period, (CodedBitstreamContext *ctx, RWContext *rw, + H264RawSEIBufferingPeriod *current, + SEIMessageState *sei)) { CodedBitstreamH264Context *h264 = ctx->priv_data; const H264RawSPS *sps; @@ -604,9 +604,8 @@ static int FUNC(sei_pic_timestamp)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } -static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, RWContext *rw, - H264RawSEIPicTiming *current, - SEIMessageState *sei) +SEI_FUNC(sei_pic_timing, (CodedBitstreamContext *ctx, RWContext *rw, + H264RawSEIPicTiming *current, SEIMessageState *sei)) { CodedBitstreamH264Context *h264 = ctx->priv_data; const H264RawSPS *sps; @@ -676,9 +675,9 @@ static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } -static int FUNC(sei_pan_scan_rect)(CodedBitstreamContext *ctx, RWContext *rw, - H264RawSEIPanScanRect *current, - SEIMessageState *sei) +SEI_FUNC(sei_pan_scan_rect, (CodedBitstreamContext *ctx, RWContext *rw, + H264RawSEIPanScanRect *current, + SEIMessageState *sei)) { int err, i; @@ -703,9 +702,9 @@ static int FUNC(sei_pan_scan_rect)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } -static int FUNC(sei_recovery_point)(CodedBitstreamContext *ctx, RWContext *rw, - H264RawSEIRecoveryPoint *current, - SEIMessageState *sei) +SEI_FUNC(sei_recovery_point, (CodedBitstreamContext *ctx, RWContext *rw, + H264RawSEIRecoveryPoint *current, + SEIMessageState *sei)) { int err; @@ -719,9 +718,9 @@ static int FUNC(sei_recovery_point)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } -static int FUNC(film_grain_characteristics)(CodedBitstreamContext *ctx, RWContext *rw, - H264RawFilmGrainCharacteristics *current, - SEIMessageState *state) +SEI_FUNC(film_grain_characteristics, (CodedBitstreamContext *ctx, RWContext *rw, + H264RawFilmGrainCharacteristics *current, + SEIMessageState *state)) { CodedBitstreamH264Context *h264 = ctx->priv_data; const H264RawSPS *sps; @@ -802,9 +801,9 @@ static int FUNC(film_grain_characteristics)(CodedBitstreamContext *ctx, RWContex return 0; } -static int FUNC(sei_display_orientation)(CodedBitstreamContext *ctx, RWContext *rw, - H264RawSEIDisplayOrientation *current, - SEIMessageState *sei) +SEI_FUNC(sei_display_orientation, (CodedBitstreamContext *ctx, RWContext *rw, + H264RawSEIDisplayOrientation *current, + SEIMessageState *sei)) { int err; diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 2d4b954718..86ca00a0c9 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -1618,9 +1618,9 @@ static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } -static int FUNC(sei_buffering_period) - (CodedBitstreamContext *ctx, RWContext *rw, - H265RawSEIBufferingPeriod *current, SEIMessageState *sei) +SEI_FUNC(sei_buffering_period, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawSEIBufferingPeriod *current, + SEIMessageState *sei)) { CodedBitstreamH265Context *h265 = ctx->priv_data; const H265RawSPS *sps; @@ -1728,9 +1728,8 @@ static int FUNC(sei_buffering_period) return 0; } -static int FUNC(sei_pic_timing) - (CodedBitstreamContext *ctx, RWContext *rw, - H265RawSEIPicTiming *current, SEIMessageState *sei) +SEI_FUNC(sei_pic_timing, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawSEIPicTiming *current, SEIMessageState *sei)) { CodedBitstreamH265Context *h265 = ctx->priv_data; const H265RawSPS *sps; @@ -1804,9 +1803,9 @@ static int FUNC(sei_pic_timing) return 0; } -static int FUNC(sei_pan_scan_rect) - (CodedBitstreamContext *ctx, RWContext *rw, - H265RawSEIPanScanRect *current, SEIMessageState *sei) +SEI_FUNC(sei_pan_scan_rect, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawSEIPanScanRect *current, + SEIMessageState *sei)) { int err, i; @@ -1831,9 +1830,9 @@ static int FUNC(sei_pan_scan_rect) return 0; } -static int FUNC(sei_recovery_point) - (CodedBitstreamContext *ctx, RWContext *rw, - H265RawSEIRecoveryPoint *current, SEIMessageState *sei) +SEI_FUNC(sei_recovery_point, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawSEIRecoveryPoint *current, + SEIMessageState *sei)) { int err; @@ -1847,9 +1846,9 @@ static int FUNC(sei_recovery_point) return 0; } -static int FUNC(film_grain_characteristics)(CodedBitstreamContext *ctx, RWContext *rw, - H265RawFilmGrainCharacteristics *current, - SEIMessageState *state) +SEI_FUNC(film_grain_characteristics, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawFilmGrainCharacteristics *current, + SEIMessageState *state)) { CodedBitstreamH265Context *h265 = ctx->priv_data; const H265RawSPS *sps = h265->active_sps; @@ -1912,9 +1911,9 @@ static int FUNC(film_grain_characteristics)(CodedBitstreamContext *ctx, RWContex return 0; } -static int FUNC(sei_display_orientation) - (CodedBitstreamContext *ctx, RWContext *rw, - H265RawSEIDisplayOrientation *current, SEIMessageState *sei) +SEI_FUNC(sei_display_orientation, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawSEIDisplayOrientation *current, + SEIMessageState *sei)) { int err; @@ -1931,9 +1930,9 @@ static int FUNC(sei_display_orientation) return 0; } -static int FUNC(sei_active_parameter_sets) - (CodedBitstreamContext *ctx, RWContext *rw, - H265RawSEIActiveParameterSets *current, SEIMessageState *sei) +SEI_FUNC(sei_active_parameter_sets, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawSEIActiveParameterSets *current, + SEIMessageState *sei)) { CodedBitstreamH265Context *h265 = ctx->priv_data; const H265RawVPS *vps; @@ -1968,9 +1967,9 @@ static int FUNC(sei_active_parameter_sets) return 0; } -static int FUNC(sei_decoded_picture_hash) - (CodedBitstreamContext *ctx, RWContext *rw, - H265RawSEIDecodedPictureHash *current, SEIMessageState *sei) +SEI_FUNC(sei_decoded_picture_hash, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawSEIDecodedPictureHash *current, + SEIMessageState *sei)) { CodedBitstreamH265Context *h265 = ctx->priv_data; const H265RawSPS *sps = h265->active_sps; @@ -2000,9 +1999,8 @@ static int FUNC(sei_decoded_picture_hash) return 0; } -static int FUNC(sei_time_code) - (CodedBitstreamContext *ctx, RWContext *rw, - H265RawSEITimeCode *current, SEIMessageState *sei) +SEI_FUNC(sei_time_code, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawSEITimeCode *current, SEIMessageState *sei)) { int err, i; @@ -2051,9 +2049,9 @@ static int FUNC(sei_time_code) return 0; } -static int FUNC(sei_alpha_channel_info) - (CodedBitstreamContext *ctx, RWContext *rw, - H265RawSEIAlphaChannelInfo *current, SEIMessageState *sei) +SEI_FUNC(sei_alpha_channel_info, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawSEIAlphaChannelInfo *current, + SEIMessageState *sei)) { int err, length; diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c index e75f2f6971..29d9670521 100644 --- a/libavcodec/cbs_h266_syntax_template.c +++ b/libavcodec/cbs_h266_syntax_template.c @@ -3427,10 +3427,10 @@ static int FUNC(slice_header) (CodedBitstreamContext *ctx, RWContext *rw, return 0; } -static int FUNC(sei_decoded_picture_hash) (CodedBitstreamContext *ctx, - RWContext *rw, - H266RawSEIDecodedPictureHash * - current, SEIMessageState *unused) +SEI_FUNC(sei_decoded_picture_hash, (CodedBitstreamContext *ctx, + RWContext *rw, + H266RawSEIDecodedPictureHash *current, + SEIMessageState *unused)) { int err, c_idx, i; diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h index 4511c506cc..ec7cdb62f0 100644 --- a/libavcodec/cbs_sei.h +++ b/libavcodec/cbs_sei.h @@ -126,13 +126,6 @@ typedef struct SEIMessageTypeDescriptor { SEIMessageWriteFunction write; } SEIMessageTypeDescriptor; -// Macro for the read/write pair. The clumsy cast is needed because the -// current pointer is typed in all of the read/write functions but has to -// be void here to fit all cases. -#define SEI_MESSAGE_RW(codec, name) \ - .read = (SEIMessageReadFunction) cbs_ ## codec ## _read_ ## name, \ - .write = (SEIMessageWriteFunction)cbs_ ## codec ## _write_ ## name - // End-of-list sentinel element. #define SEI_MESSAGE_TYPE_END { .type = -1 } diff --git a/libavcodec/cbs_sei_syntax_template.c b/libavcodec/cbs_sei_syntax_template.c index 62dd1dabaa..81448ef3f2 100644 --- a/libavcodec/cbs_sei_syntax_template.c +++ b/libavcodec/cbs_sei_syntax_template.c @@ -16,9 +16,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -static int FUNC(filler_payload) - (CodedBitstreamContext *ctx, RWContext *rw, - SEIRawFillerPayload *current, SEIMessageState *state) +SEI_FUNC(filler_payload, (CodedBitstreamContext *ctx, RWContext *rw, + SEIRawFillerPayload *current, + SEIMessageState *state)) { int err, i; @@ -34,9 +34,9 @@ static int FUNC(filler_payload) return 0; } -static int FUNC(user_data_registered) - (CodedBitstreamContext *ctx, RWContext *rw, - SEIRawUserDataRegistered *current, SEIMessageState *state) +SEI_FUNC(user_data_registered, (CodedBitstreamContext *ctx, RWContext *rw, + SEIRawUserDataRegistered *current, + SEIMessageState *state)) { int err, i, j; @@ -66,9 +66,9 @@ static int FUNC(user_data_registered) return 0; } -static int FUNC(user_data_unregistered) - (CodedBitstreamContext *ctx, RWContext *rw, - SEIRawUserDataUnregistered *current, SEIMessageState *state) +SEI_FUNC(user_data_unregistered, (CodedBitstreamContext *ctx, RWContext *rw, + SEIRawUserDataUnregistered *current, + SEIMessageState *state)) { int err, i; @@ -94,9 +94,10 @@ static int FUNC(user_data_unregistered) return 0; } -static int FUNC(mastering_display_colour_volume) - (CodedBitstreamContext *ctx, RWContext *rw, - SEIRawMasteringDisplayColourVolume *current, SEIMessageState *state) +SEI_FUNC(mastering_display_colour_volume, + (CodedBitstreamContext *ctx, RWContext *rw, + SEIRawMasteringDisplayColourVolume *current, + SEIMessageState *state)) { int err, c; @@ -116,9 +117,9 @@ static int FUNC(mastering_display_colour_volume) return 0; } -static int FUNC(content_light_level_info) - (CodedBitstreamContext *ctx, RWContext *rw, - SEIRawContentLightLevelInfo *current, SEIMessageState *state) +SEI_FUNC(content_light_level_info, (CodedBitstreamContext *ctx, RWContext *rw, + SEIRawContentLightLevelInfo *current, + SEIMessageState *state)) { int err; @@ -130,10 +131,10 @@ static int FUNC(content_light_level_info) return 0; } -static int FUNC(alternative_transfer_characteristics) - (CodedBitstreamContext *ctx, RWContext *rw, - SEIRawAlternativeTransferCharacteristics *current, - SEIMessageState *state) +SEI_FUNC(alternative_transfer_characteristics, + (CodedBitstreamContext *ctx, RWContext *rw, + SEIRawAlternativeTransferCharacteristics *current, + SEIMessageState *state)) { int err; @@ -144,10 +145,10 @@ static int FUNC(alternative_transfer_characteristics) return 0; } -static int FUNC(ambient_viewing_environment) - (CodedBitstreamContext *ctx, RWContext *rw, - SEIRawAmbientViewingEnvironment *current, - SEIMessageState *state) +SEI_FUNC(ambient_viewing_environment, + (CodedBitstreamContext *ctx, RWContext *rw, + SEIRawAmbientViewingEnvironment *current, + SEIMessageState *state)) { static const uint16_t max_ambient_light_value = 50000; int err;