From patchwork Sat Jul 2 22:21:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 36605 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp1884032pzh; Sat, 2 Jul 2022 15:23:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tItbUiz0KryuoGkpKEHlpi0mMunBxYzbwMA+ywTSRkjC4F54MGbVSAWDiF7IUSQUg99u4A X-Received: by 2002:a05:6402:149:b0:431:7dde:9b59 with SMTP id s9-20020a056402014900b004317dde9b59mr27964579edu.339.1656800610387; Sat, 02 Jul 2022 15:23:30 -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 l2-20020a1709067d4200b0070f8f93e1f5si9230834ejp.306.2022.07.02.15.23.29; Sat, 02 Jul 2022 15:23:30 -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=QYKjpK8I; 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 A98B268B979; Sun, 3 Jul 2022 01:22:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073040.outbound.protection.outlook.com [40.92.73.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EE18E68B967 for ; Sun, 3 Jul 2022 01:22:37 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NxWaxz9HvMAWm6FYAIMaNJpHcQqv/2W3RWUpHslgCCQZQGX05BLLl+aDVnEdEx6uf4ULToyRKM+oPT/53Ha2MdaCqBmWdn7f08206frIL3z7W/s/KOl7fo5WEq3opwqOxQ6yEIQ7CXEP/heeUK3A7tEx/NZqKBU1/828s/zuzgKqlmWKH3hNwN+YHznr9V22zeltr/F95aF0BmFOWQFFRE2tYsA6emXhQFvdnnncKFfjyPO3daw3zN2eCQxeVa92V7hHzPt/tALeZvWzbeQK9xD5SNihWxV/NMr/VTQXY1u+UVtnEBZpnQp+pyIqnFA/WnMUakJHKTMNPsyEOvQ5nw== 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=7ZG0MzNvJSxXIFg4Ex6XKTwOfrW8xxtlzUuMmMV0KJg=; b=LOnys0xXGT4doZjZHoD5W9Au3JrDS241ay42Pd63MH8mPVV3p+eWP51R2FIpauws3rzTqCKR64PwGAQfqkXYz1H9Q9nTq9d03QZ7HbS1b+kVwYnzSpnncBCYzk5m96Z8n6G3U2f/sklJX318c0zHIDEkZynZUqzCxC75DfvGtJHSbP10RD0GCjdVGUiC+JHaxqJE7u/Wv/y7o1FIDOBJAUCgbjTu9WW9D6x41SvbsEMAZrupqEeiyMD5pPZS8U+gRLe/FN1njkumAH4PbJc8UviQkmkX3c4ClwRBuSGxRovl2PXJfDPZuwPA71b3EH8LzFkAJjgIE7ozFOh2aiyJZg== 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=7ZG0MzNvJSxXIFg4Ex6XKTwOfrW8xxtlzUuMmMV0KJg=; b=QYKjpK8ITaSC4S0zemuDSlD+K16cJ+AhRJsu3v9o/HQGpQ5lF98qW+k1J/by2zi5OADA4dAJJ0d8bwP9Cpqkw+32WqojMC6uqvigawzz7VCEKSppRVAeUBkoJDjoh4nv5HJpOvNsrwhPEobi7eArUh91CL2bXNVhYmhAreXvgL3HvpFQTNseyGAPGRtLbbZZdEKyDxEcHpmHCdR6NLjKI6HLySUBaS6Q5FGrdpgiPhhC9qe8X7kZboQAnhv/SS9oGGl1UZkPwe2/q2emTd7bmFtaaPbcSY9hmld8FEDuIfWJ6t3e83YGr03rbkkMhwpYSf+MuLrB7s6xX88TvUvUeA== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by VI1PR01MB4240.eurprd01.prod.exchangelabs.com (2603:10a6:803:6e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.14; Sat, 2 Jul 2022 22:22:30 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%10]) with mapi id 15.20.5395.018; Sat, 2 Jul 2022 22:22:30 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Jul 2022 00:21:50 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [vfBywwOTVCXg3c8r233b14f3ZINkJO77] X-ClientProxiedBy: FR3P281CA0089.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::18) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220702222200.169681-9-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 64666170-23e3-4bd8-ab80-08da5c795a06 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNXwBRntoGkOsgo00FNZK4OlFCetl+b8JgTRaeH+xKC9sZpy5ulDBA3dbjw01QdLT6bqa8OSuIUyRrm+SDq7/Uq+cyWf6Acpi3Yj4n82hXWbx97pPE5k9gCKzp36mSggui9Ykwnd/lFP+wro0boIs+2Yxabr3lhz2zd97f09LlFr+B9rFF5sRRGMzWhtmqMpswWfFiSL0KgtgZuoLLpxYZXtvsDb4euac407vnyFm+pKHMQN3D4IAo6zAIm4jWpeUu1DgqOepR8jjhtW3U2GP/7YNJq1mJxg0FfpG5/xtN3URMtHs6eaOOynjYPzS8ij1pCysIlZkWSsmVRl5FgS7iDvhHTL6+pUrv6z0Ylufki3HRG1d0DvEUselR4hLGLjTIEzSOAppC+0Qoh5rTMBfbIxkTEC3nmqQhgOq4r8glImUWZpRa0lx8X2KpQP9jfsge7Ybfq5M9AzUpN2dToGgdsDKH1Tl1bUx78yp2fGPAHJdPE6Jp01re8uEMemymXxASVdi2ba/SujS0EoREEY7yRMCVcGqp5F/g8Opu0+0GycEK8NtRtTZf2DvcBJl57Z7OQUfilFSa6FtEcqz2BmAc9CJTGx1pFIyyyoQRoquE55D/QVIdksh5Aloez5Z83cx9ObsRz70SjDCvlE4+Qz+BNsMFxiJi2aoL0FD6atzQIUdeGNuogPAi1ZoELm+tsPd3BdJi+qnxlRjdZC4BGPjaMPqqB3nEzLm8Q= X-MS-TrafficTypeDiagnostic: VI1PR01MB4240:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GnE0YwJwAYu9j9lDWmduoo6G5L5jc3guf3mRCxLu9V3khRiYl9Y2/ygwbXD3WXxZXJ5iqfyvsCBbrd2fMp5ezHRA9Y6pHJNIa/WJYfA9tkCWDY6Pyf2PeFgbk4hpgLo07OPcqbpufk2MiwYMO99tHv3YTK1+U/5fYj0yjeKueFD1MT59705izjtVLf9n1zJMTveL0G2wp4bnIkOk9gwBnSPs3fdj5Pqiads+4jvPpb28yKnZoXi4oweRQyt2I/ptkICbmSJcA81YvRHARI+xn95Y3Z+uqOLqVNWGOwW34S5/dK6+QZ+UV0qz3fEyulDaWqt9XHZwbq2qSouEZ7h3Qcc8SBnJ5UOCfCuaREKSJqZRIzy/NeDeuTb+6OXshqEhdsjo3afBUf1OhG7Hw9ud5sw8/OgCnf4HB2DZGdnaAhW03l81ItTy7mfQ3ZImHz5qHiJcJQtbzUUbPaXO+MxadVS0X/aRfCV3eu96gcf7wNRr+PO6gJJCMeQ2rDQ6r11tr06SoCodjTHeZvpt7fux5Yl12pqF/LUwUt1jP2hKp/aVb4rmdTVkrTJGBh3nJzKQ4Oo23WKtiriHLQl/wUiJGyTZ3NqTKM8pjGgyxPYbMXuw70VbkKnUbkoEOBJ6O1RHHHFLs313H2Wqx8Bjj+7iqg== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uXy4u6xFYydLr2EFHqz4pH+pk9iTGNU+L7EWu2esFztBrL0LyQmsXV3y4TOwLLv8HwZ8UsoUoV8QXY+82G0iErDTgN8j3po1FratUsJGAycF4TOX6WOZzDbYjJigfAilAPADzarb6u12TvE//pFXxfVqr+9ogSPoly+0x+t5juqaB/2nm/2tSpBB5WjXbQ0vonT2SQDSb5bppKsfB+ckqoO5ffsjxUIoqeJcQyq9ADjkknRZQ5uMlrjdhebLyu17CcGKM2m8SlwG6F0Y7iMqjWaCJMwpvkmgOBD3I3jqwDRabA37NORLqd6WNQcdNVl1l0sCKzmFYFhRTRwKzo1s2qevKQUaoypHNR5ZRvwe0jhAvRhnWsKk7736oyK6uD7rIWKzCGuVMyXEXTYE5FMFE4eHNVztXmJds80WbYqP/DHE7Cp7lDqpnm3DZ5RcqRGI/knAlqzoL8YicLeHgQjeVx5SXXZTIfuxTjw6l9NT51Aegj+CSOANvnEv/TlmUj/wHFe3oPlZCb3qATKlXqAt8SpcWT135+EwiJD91hKdP6NB/7N8zueSbUun23uQGYNhM7boIuXGTHtUcRflTvNK4SpoFn4m7pdy7JwzJttenjPt3jMA1bjLIky+kd1S1zT/qUV+keBG+KcBpvQMvTwO91lz2GJaRYtlTxuN74BWsVikwQ6ZBIAAoC57aQ/W67KPrb278cmlCIX4pOdXDjyf+AbKzCyr5lTzDmkHOB5PT7gN4H5eBpG1rdtuw2g/sEiJBa8YVQdxvgByE9jTFGTIdt9rdKqZxQsAZP/bb/0aJgo72aM7MI+HRaiROqPPve9uXdXXRgJNMH7BRo8nqIzhXMqU/TtpY43P4BUjC3t2CoieVNWFLNf0vkuVSke9zyrxP1YKdzFdPYzxeJsO6g/2wpfwhUNFPHVHi4Jo3vr2qFkX5RSa90YSjyWU6jontAHzwdQdvY8SR08LRil7TW8rzdFLCwAOPWOLXVBglmhb6gznMd3ZVJEvIqwATSeemL/yIzrHMLZkbl6Z2Nz8SjjKean0fuLeTJ/VtzTWQrZ1ie75658e6DDgxHXIPC/Rv78xP8j25DEesIMawf3Kyb64vHyXz6V/ku62teA5/i0a3orKDRPXC9ZDY+0e9tWVk6Y41SSC2y46KgC5WU64l65/puoHmULSSnqI4tuizzS2EmL2BL745EqBWPsoMlbszWf70sJXJn5lAacxXTuo7ZmzfIgUJGhCTr2AwwNlXK/iaYUV9Vk3rkIvxNOoutIm4PAlN/06Qh4tkesGtcR2kCCBk6o6Zp7S+Nt4x+POzhRNNTE= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64666170-23e3-4bd8-ab80-08da5c795a06 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2022 22:22:30.0210 (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: VI1PR01MB4240 Subject: [FFmpeg-devel] [PATCH 10/20] avcodec/h2645_sei: Factor out applying SEIs to frames 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: Z6q/sIdtg/0D Signed-off-by: Andreas Rheinhardt --- libavcodec/h2645_sei.c | 57 +++++++++++++++++++++++++++++++++++++++++ libavcodec/h2645_sei.h | 4 +++ libavcodec/h264_slice.c | 53 +++----------------------------------- libavcodec/hevcdec.c | 51 +++--------------------------------- 4 files changed, 68 insertions(+), 97 deletions(-) diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c index 6be3d97c92..6c7a6ea291 100644 --- a/libavcodec/h2645_sei.c +++ b/libavcodec/h2645_sei.c @@ -419,6 +419,63 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src) return 0; } +int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, + enum AVCodecID codec_id, + AVCodecContext *avctx) +{ + if (sei->display_orientation.present && + (sei->display_orientation.anticlockwise_rotation || + sei->display_orientation.hflip || + sei->display_orientation.vflip)) { + H2645SEIDisplayOrientation *o = &sei->display_orientation; + double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16); + AVFrameSideData *rotation = av_frame_new_side_data(frame, + AV_FRAME_DATA_DISPLAYMATRIX, + sizeof(int32_t) * 9); + if (!rotation) + return AVERROR(ENOMEM); + + /* av_display_rotation_set() expects the angle in the clockwise + * direction, hence the first minus. + * The below code applies the flips after the rotation, yet + * the H.2645 specs require flipping to be applied first. + * Because of R O(phi) = O(-phi) R (where R is flipping around + * an arbitatry axis and O(phi) is the proper rotation by phi) + * we can create display matrices as desired by negating + * the degree once for every flip applied. */ + angle = -angle * (1 - 2 * !!o->hflip) * (1 - 2 * !!o->vflip); + av_display_rotation_set((int32_t *)rotation->data, angle); + av_display_matrix_flip((int32_t *)rotation->data, + o->hflip, o->vflip); + } + + if (sei->a53_caption.buf_ref) { + H2645SEIA53Caption *a53 = &sei->a53_caption; + AVFrameSideData *sd = av_frame_new_side_data_from_buf(frame, AV_FRAME_DATA_A53_CC, a53->buf_ref); + if (!sd) + av_buffer_unref(&a53->buf_ref); + a53->buf_ref = NULL; + if (avctx) + avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; + } + + for (unsigned i = 0; i < sei->unregistered.nb_buf_ref; i++) { + H2645SEIUnregistered *unreg = &sei->unregistered; + + if (unreg->buf_ref[i]) { + AVFrameSideData *sd = av_frame_new_side_data_from_buf(frame, + AV_FRAME_DATA_SEI_UNREGISTERED, + unreg->buf_ref[i]); + if (!sd) + av_buffer_unref(&unreg->buf_ref[i]); + unreg->buf_ref[i] = NULL; + } + } + sei->unregistered.nb_buf_ref = 0; + + return 0; +} + void ff_h2645_sei_reset(H2645SEI *s) { av_buffer_unref(&s->a53_caption.buf_ref); diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h index 3e088f3307..4600caab29 100644 --- a/libavcodec/h2645_sei.h +++ b/libavcodec/h2645_sei.h @@ -134,4 +134,8 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src); void ff_h2645_sei_reset(H2645SEI *s); +int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, + enum AVCodecID codec_id, + AVCodecContext *avctx); + #endif /* AVCODEC_H2645_SEI_H */ diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index fb7aed998b..18b9ae5b09 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1144,6 +1144,7 @@ static int h264_export_frame_props(H264Context *h) const SPS *sps = h->ps.sps; H264Picture *cur = h->cur_pic_ptr; AVFrame *out = cur->f; + int ret; out->interlaced_frame = 0; out->repeat_pict = 0; @@ -1271,31 +1272,6 @@ static int h264_export_frame_props(H264Context *h) } } - if (h->sei.common.display_orientation.present && - (h->sei.common.display_orientation.anticlockwise_rotation || - h->sei.common.display_orientation.hflip || - h->sei.common.display_orientation.vflip)) { - H2645SEIDisplayOrientation *o = &h->sei.common.display_orientation; - double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16); - AVFrameSideData *rotation = av_frame_new_side_data(out, - AV_FRAME_DATA_DISPLAYMATRIX, - sizeof(int32_t) * 9); - if (rotation) { - /* av_display_rotation_set() expects the angle in the clockwise - * direction, hence the first minus. - * The below code applies the flips after the rotation, yet - * the H.2645 specs require flipping to be applied first. - * Because of R O(phi) = O(-phi) R (where R is flipping around - * an arbitatry axis and O(phi) is the proper rotation by phi) - * we can create display matrices as desired by negating - * the degree once for every flip applied. */ - angle = -angle * (1 - 2 * !!o->hflip) * (1 - 2 * !!o->vflip); - av_display_rotation_set((int32_t *)rotation->data, angle); - av_display_matrix_flip((int32_t *)rotation->data, - o->hflip, o->vflip); - } - } - if (h->sei.common.afd.present) { AVFrameSideData *sd = av_frame_new_side_data(out, AV_FRAME_DATA_AFD, sizeof(uint8_t)); @@ -1306,30 +1282,9 @@ static int h264_export_frame_props(H264Context *h) } } - if (h->sei.common.a53_caption.buf_ref) { - H2645SEIA53Caption *a53 = &h->sei.common.a53_caption; - - AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_A53_CC, a53->buf_ref); - if (!sd) - av_buffer_unref(&a53->buf_ref); - a53->buf_ref = NULL; - - h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; - } - - for (int i = 0; i < h->sei.common.unregistered.nb_buf_ref; i++) { - H2645SEIUnregistered *unreg = &h->sei.common.unregistered; - - if (unreg->buf_ref[i]) { - AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, - AV_FRAME_DATA_SEI_UNREGISTERED, - unreg->buf_ref[i]); - if (!sd) - av_buffer_unref(&unreg->buf_ref[i]); - unreg->buf_ref[i] = NULL; - } - } - h->sei.common.unregistered.nb_buf_ref = 0; + ret = ff_h2645_sei_to_frame(out, &h->sei.common, AV_CODEC_ID_H264, h->avctx); + if (ret < 0) + return ret; if (h->sei.common.film_grain_characteristics.present) { H2645SEIFilmGrainCharacteristics *fgc = &h->sei.common.film_grain_characteristics; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 698fb50a6c..465015069c 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2766,32 +2766,6 @@ static int set_side_data(HEVCContext *s) } } - if (s->sei.common.display_orientation.present && - (s->sei.common.display_orientation.anticlockwise_rotation || - s->sei.common.display_orientation.hflip || s->sei.common.display_orientation.vflip)) { - double angle = s->sei.common.display_orientation.anticlockwise_rotation * 360 / (double) (1 << 16); - AVFrameSideData *rotation = av_frame_new_side_data(out, - AV_FRAME_DATA_DISPLAYMATRIX, - sizeof(int32_t) * 9); - if (!rotation) - return AVERROR(ENOMEM); - - /* av_display_rotation_set() expects the angle in the clockwise - * direction, hence the first minus. - * The below code applies the flips after the rotation, yet - * the H.2645 specs require flipping to be applied first. - * Because of R O(phi) = O(-phi) R (where R is flipping around - * an arbitatry axis and O(phi) is the proper rotation by phi) - * we can create display matrices as desired by negating - * the degree once for every flip applied. */ - angle = -angle * (1 - 2 * !!s->sei.common.display_orientation.hflip) - * (1 - 2 * !!s->sei.common.display_orientation.vflip); - av_display_rotation_set((int32_t *)rotation->data, angle); - av_display_matrix_flip((int32_t *)rotation->data, - s->sei.common.display_orientation.hflip, - s->sei.common.display_orientation.vflip); - } - // Decrement the mastering display flag when IRAP frame has no_rasl_output_flag=1 // so the side data persists for the entire coded video sequence. if (s->sei.mastering_display.present > 0 && @@ -2861,28 +2835,9 @@ static int set_side_data(HEVCContext *s) metadata->MaxCLL, metadata->MaxFALL); } - if (s->sei.common.a53_caption.buf_ref) { - H2645SEIA53Caption *a53 = &s->sei.common.a53_caption; - - AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_A53_CC, a53->buf_ref); - if (!sd) - av_buffer_unref(&a53->buf_ref); - a53->buf_ref = NULL; - } - - for (int i = 0; i < s->sei.common.unregistered.nb_buf_ref; i++) { - H2645SEIUnregistered *unreg = &s->sei.common.unregistered; - - if (unreg->buf_ref[i]) { - AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, - AV_FRAME_DATA_SEI_UNREGISTERED, - unreg->buf_ref[i]); - if (!sd) - av_buffer_unref(&unreg->buf_ref[i]); - unreg->buf_ref[i] = NULL; - } - } - s->sei.common.unregistered.nb_buf_ref = 0; + ret = ff_h2645_sei_to_frame(out, &s->sei.common, AV_CODEC_ID_HEVC, NULL); + if (ret < 0) + return ret; if (s->sei.timecode.present) { uint32_t *tc_sd;