From patchwork Sun Jul 21 22:53:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 50671 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:a742:0:b0:482:c625:d099 with SMTP id f2csp1711721vqm; Sun, 21 Jul 2024 15:54:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUOjKGpntQVtlzDbejnX12M69x7VthnpO2CrnavugdkzZkuV9bE1KQAhPuwoudQ+YQ9wy89IBNPvPOmogayaFp9DVqIXGSrFd64Vg== X-Google-Smtp-Source: AGHT+IElg5uNu7Rh+ddoO9gkK/RFfGmROEyV+ZFkBo2sQEpAPSK4HYL+eto+8o88BBkkI9SjFZXg X-Received: by 2002:ac2:4bc2:0:b0:52c:e07d:229c with SMTP id 2adb3069b0e04-52efb6343fbmr3263734e87.22.1721602446701; Sun, 21 Jul 2024 15:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721602446; cv=none; d=google.com; s=arc-20160816; b=sROIlp+JcMw42IstrbNPNVaSYTuf0I/TCRzKu6j95oTDq5n5/9jM11dZ2/F7HiBSg1 RoE8rusTCjPIc8JelLgznLt/AJS/+ZI9M/IggigQqaM5UMYiLbdbfMPCjgBi9u5NXMO2 42SULrIg2zbWT3oKIyORthKQFDujwU/jw7L6jb9a6c5bMCxyW7W/vP5YzsJJpCl5WGne pAAATKQxGRNu3W9CaQiTKQ5mUrh1Pd0xAzB/vwZh/F8XXvLCNBdEAf4cxHNkT29WDeJy ydr+3x4TQ3XojcicP6B2dooGLvgPMc048gGZr9niAhxnMEO3TZVVjGS0DgWMIPFjv0K2 Ty5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=xpV6cztm7WyU0rDAlbAdIH6J/zMpVkQFBqD4qSX5LgA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=wQWuwajiB8msCBCdoOKV8ISu7NfquHh9i7IInSt3fNtbxcJdSB+bxt3FQNEbyT7tRG piByYpttogvGLha1EA3Wf8MFxgC4u9dIUj2dNBBMczAwhqATUYun668cZJLh3In4o4BV W5oFMTrpJvzwJ4VRJeO2AKmG1CMcB+QbJ6WIYu3TV0NZLIUCyYmX9Djk1C9u87sEp7Mo jMB/9sKWZbsRiqRpmsTwC5ygWhlcWOmUY7q1hmZimMQer1P5Q/2woTe3159de1Hdjdqc J/trOFWNdKPpd5e5DQ5CkcfiTo03KfA7GdzdM5vVuxHdvDqO71cHZspuvjf5C9yDauBa l2aQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=Thr4kcQX; 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=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a7a3c926eeasi316909766b.682.2024.07.21.15.54.06; Sun, 21 Jul 2024 15:54:06 -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=@gmail.com header.s=20230601 header.b=Thr4kcQX; 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=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7117868D75E; Mon, 22 Jul 2024 01:53:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A2C8368D49F for ; Mon, 22 Jul 2024 01:53:49 +0300 (EEST) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-65f9e25fffaso39563867b3.3 for ; Sun, 21 Jul 2024 15:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721602427; x=1722207227; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=bQAZY9rqqHgZatvQso+PteZU+7dfhLICax/qGZws1Qw=; b=Thr4kcQXr6dBb7x6SzDyepDlE9F/mI9WruiWasQoh2iXDXFecqE4rWRqq/r8KKGfKo xfweRU7E6615zNIA6Msr2nGB+6GQH4Pe0E2yUHrmPNU4uEnvkEYG0MODoqDB+sH9Q/en Y67GeV05+CuP8PKsFqPnqSib/id9UojxviOjNEBtlqixf72TDdlMCpyWmT0wDEMHkT4n 6E4SF28fVFQqJeJQmrdzzEQ6jU3kl+y76UK2EXjAkl/oRZnIy9EpVsdAAKpS4Uw21wIh QVYNw/xu2l2OTR0JNm8Rb2UjacIa4JsP2yrTq90oSumcczG8aZBqG56srGqJimvRta6s IdLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721602427; x=1722207227; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bQAZY9rqqHgZatvQso+PteZU+7dfhLICax/qGZws1Qw=; b=FwpAzkx7XVz1Xl6RbCA+uN9bv0tAoiSNA1Di56Xl6wImgd7ZhJ+xLI1ZmSmulgsijH Tnd4Ko63tgBenQOhKnKT1C0NsHYmvK8+f6Dhul8apzcilg43BTzKDlQLGVhMD79C2N3E XNgTplZiWEJp1+QJklyOTIjCgL+sY7e/3NcNIM4Etzo9kbBuctTocrDHqd8Y/HkiG5eX SyafW1mqU/GdarPrqzvFSGB3d+e1D1e+jFdEnIcP8+0p9qCEeyjIYlqGtLvT/JQtui5T HxOCODn6mnY9yXvd+HknweWMM6nOnjjK0X6u1uoq7bCEPdTxFCCZO1sbI+wmk3GJTJsg CGxw== X-Gm-Message-State: AOJu0YyMmV9Mgmh7Nt9yKB5wnAyQQzNH3MnIPWyBdJ/t1b5wL4zQTkhK 3yfVfNu7daRjcyeG2JpNTIeW+BHRWJnknUE2iy+lm6H15VthGh1DYV74gg== X-Received: by 2002:a81:69c5:0:b0:64b:44b4:e13 with SMTP id 00721157ae682-66ad8eb8906mr55697447b3.28.1721602427415; Sun, 21 Jul 2024 15:53:47 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70cff5538f6sm4223710b3a.100.2024.07.21.15.53.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 15:53:46 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Jul 2024 19:53:48 -0300 Message-ID: <20240721225350.298-2-jamrial@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240721225350.298-1-jamrial@gmail.com> References: <20240721225350.298-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4 v2] libavcodec/h2645_sei: export raw LCEVC metadata 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: yJniROr7xtuK Signed-off-by: James Almer --- libavcodec/h2645_sei.c | 37 +++++++++++++++++++++++++++++++++++++ libavcodec/h2645_sei.h | 5 +++++ libavcodec/itut35.h | 2 ++ 3 files changed, 44 insertions(+) diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c index 7c83747cd0..61d18e14b3 100644 --- a/libavcodec/h2645_sei.c +++ b/libavcodec/h2645_sei.c @@ -99,6 +99,20 @@ static int decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid } #endif +static int decode_registered_user_data_lcevc(HEVCSEILCEVC *s, + GetByteContext *gb) +{ + int size = bytestream2_get_bytes_left(gb); + + av_buffer_unref(&s->info); + s->info = av_buffer_alloc(size); + if (!s->info) + return AVERROR(ENOMEM); + + bytestream2_get_bufferu(gb, s->info->data, size); + return 0; +} + static int decode_registered_user_data_afd(H2645SEIAFD *h, GetByteContext *gb) { int flag; @@ -142,6 +156,7 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, } if (country_code != ITU_T_T35_COUNTRY_CODE_US && + country_code != ITU_T_T35_COUNTRY_CODE_UK && country_code != ITU_T_T35_COUNTRY_CODE_CN) { av_log(logctx, AV_LOG_VERBOSE, "Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d)\n", @@ -173,6 +188,13 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, } break; } + case ITU_T_T35_PROVIDER_CODE_LCEVC: { + if (bytestream2_get_bytes_left(gb) < 2) + return AVERROR_INVALIDDATA; + + bytestream2_skipu(gb, 1); // user_data_type_code + return decode_registered_user_data_lcevc(&h->lcevc, gb); + } #if CONFIG_HEVC_SEI case ITU_T_T35_PROVIDER_CODE_CUVA: { const uint16_t cuva_provider_oriented_code = 0x0005; @@ -501,6 +523,11 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src) av_buffer_unref(&dst->unregistered.buf_ref[i]); dst->unregistered.nb_buf_ref = 0; + ret = av_buffer_replace(&dst->lcevc.info, + src->lcevc.info); + if (ret < 0) + return ret; + if (src->unregistered.nb_buf_ref) { ret = av_reallocp_array(&dst->unregistered.buf_ref, src->unregistered.nb_buf_ref, @@ -666,6 +693,15 @@ static int h2645_sei_to_side_data(AVCodecContext *avctx, H2645SEI *sei, } } + if (sei->lcevc.info) { + HEVCSEILCEVC *lcevc = &sei->lcevc; + AVFrameSideData *entry = av_frame_side_data_add(sd, nb_sd, AV_FRAME_DATA_LCEVC, + &lcevc->info, 0); + if (!entry) + av_buffer_unref(&lcevc->info); + lcevc->info = NULL; + } + return 0; } @@ -875,6 +911,7 @@ void ff_h2645_sei_reset(H2645SEI *s) av_freep(&s->unregistered.buf_ref); av_buffer_unref(&s->dynamic_hdr_plus.info); av_buffer_unref(&s->dynamic_hdr_vivid.info); + av_buffer_unref(&s->lcevc.info); s->ambient_viewing_environment.present = 0; s->mastering_display.present = 0; diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h index 488dbcad7e..598f78b585 100644 --- a/libavcodec/h2645_sei.h +++ b/libavcodec/h2645_sei.h @@ -50,6 +50,10 @@ typedef struct HEVCSEIDynamicHDRVivid { AVBufferRef *info; } HEVCSEIDynamicHDRVivid; +typedef struct HEVCSEILCEVC { + AVBufferRef *info; +} HEVCSEILCEVC; + typedef struct H2645SEIUnregistered { AVBufferRef **buf_ref; unsigned nb_buf_ref; @@ -126,6 +130,7 @@ typedef struct H2645SEI { H2645SEIAFD afd; HEVCSEIDynamicHDRPlus dynamic_hdr_plus; //< HEVC only HEVCSEIDynamicHDRVivid dynamic_hdr_vivid; //< HEVC only + HEVCSEILCEVC lcevc; H2645SEIUnregistered unregistered; H2645SEIFramePacking frame_packing; H2645SEIDisplayOrientation display_orientation; diff --git a/libavcodec/itut35.h b/libavcodec/itut35.h index ffa7024981..a75ef37929 100644 --- a/libavcodec/itut35.h +++ b/libavcodec/itut35.h @@ -20,11 +20,13 @@ #define AVCODEC_ITUT35_H #define ITU_T_T35_COUNTRY_CODE_CN 0x26 +#define ITU_T_T35_COUNTRY_CODE_UK 0xB4 #define ITU_T_T35_COUNTRY_CODE_US 0xB5 #define ITU_T_T35_PROVIDER_CODE_ATSC 0x31 #define ITU_T_T35_PROVIDER_CODE_CUVA 0x04 #define ITU_T_T35_PROVIDER_CODE_DOLBY 0x3B +#define ITU_T_T35_PROVIDER_CODE_LCEVC 0x50 #define ITU_T_T35_PROVIDER_CODE_SMTPE 0x3C #endif /* AVCODEC_ITUT35_H */