From patchwork Sat Aug 31 16:31:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51263 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:4027:b0:48e:c0f8:d0de with SMTP id ky39csp1031736vqb; Sat, 31 Aug 2024 10:10:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUFdACfhH/oh4J3OMu1ISxBA9qa1huhUJONiMYvtIN9TNLK3550iRinmaOrvic9C7m8A+RDSG6oy3lMjJnLSoWl@gmail.com X-Google-Smtp-Source: AGHT+IFpLl+xUaseZ/IZYPcGnv1ei8fTZ3PpZ5LAbN52qvrEjF+eDbsL7Zs6aTwImPaD4Uwf/ezy X-Received: by 2002:a05:6402:5c9:b0:5a2:68a2:ae57 with SMTP id 4fb4d7f45d1cf-5c243781be8mr1789225a12.31.1725124219676; Sat, 31 Aug 2024 10:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725124219; cv=none; d=google.com; s=arc-20240605; b=jlgpYZ4lm9s+rs7jBOdUIbpOp+beuVrcnnCaHq55iqTFK6gKFvhIy8uJ70irTNXx5J UwELd+Xwv9zC8CCLWdB4fIaf0KSjhnbqw+iZRxeoFMTgeLqy7Pv344S4nSsjy/Wt2JJk vTgLPojF3dxi6RS2EdxX0d/urbOUpEImBimZUEM5zSiUVAx2sVGBOOpsHpqZsapJYcDC bM0rcvJsINFudrdhFDnzUQCL8DUGL5rkvsHboTNlugnmJarxy+DbJcoTM2XWqiQ+Cv4T EyP6X5fxWinar4ozOY4bpuZKs8LWh1qVRyCHCDmlUgbkq/vzHTRPXG03n98GCsh+OOcK Lh7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=9Art5aUa8PW6KcXiFJbHF7WTICdAaMLWKZ+MsHGQyA8=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Xw+xOcKg6Q9H3o+lvFjvSeXjpDkrZQEvIIAO6wGX3/7lhbsaxARMlCDZkwlqs4SXSs i4QLDm88vCaj4p4LtdsWKYnYXOxtR3Xt061yPaLzrz0YzXCWhuXWWj44x+kMDx4ffCzX r8wE0U5VR1OXjzAuYzow6oZG5mqrjvN7vwZ0OBbtgQeGiQH/vWiesgcceJ8icybpnRK3 kMSKWfsPamcsas66nsNZI/Ucmiweotw6KTWV7hDIVlQPhPX9g9UuUzdhCuw/wE66NdOp Wrfo1Cfz3ws1Duga9JdzVLb15yiAZCqrluUf4ZhtErzrNjqH8qLYD1x4vDZolBE/CbaP YMVg==; 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=P2dKjCTS; 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 4fb4d7f45d1cf-5c240f4c622si1768233a12.591.2024.08.31.10.10.19; Sat, 31 Aug 2024 10:10:19 -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=P2dKjCTS; 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 EC98568DDE4; Sat, 31 Aug 2024 19:31:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B6ACD68DD93 for ; Sat, 31 Aug 2024 19:30:54 +0300 (EEST) Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2d889ba25f7so771256a91.0 for ; Sat, 31 Aug 2024 09:30:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725121852; x=1725726652; 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=nvvIhLCt5HrPhKWu/R2Ozd1vUWAE7PV94Rk9nWw8tzI=; b=P2dKjCTSkBTLkmWh0oEiZHOmHeXUi3n1AjQywJg1a0dFA1/Yb/lkUqKKBOq/FOnvhw 4Tnt7KMNRi+TkGxdmGRl/qrU/3cp5MJ3W8dDv57kwD++FQtxc2s/e6nB6bXYtTxxZJQN ou8SNKe8a4sAIaxtLyJ2MbRW6U4CSr2vofxn0V2cBlrVpDr5E8QPWYktplg7pJ475RQp Sq1rE8eKTDLXieQi/ZtAPMjI5C8bKVQ/0qQCFD0ICCoZTwJLTJAv3szAyOaY6S245KCb F7dRIMInecP+JBRlkKTPtvn+O47gKLKjOCFkslxCnZ59yrLAoQZEORZJEKOhDMRHxaw5 jl0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725121852; x=1725726652; 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=nvvIhLCt5HrPhKWu/R2Ozd1vUWAE7PV94Rk9nWw8tzI=; b=KZNK5+sIzgq0Pjn9RB9L7s96BeztWmVMWn0uVH0JzVigpMTfliWy9esdZIm3ihcNAU Db/XhdGP7Cg/JnjmCdheWpabK7iu3UvQUMMPgclFYol8KTXZkiLxPRfCAladG7ZUTCvH SKKF6rDgg0rfQD+me/rh5p5PXF597WzvZtvE9dDwft0GPe4oDGJM52N6sx70ayeCUJv2 kT6jJ0Nsgs0WkocGIUAOlxQzn52wLvCideaLuq/DbtpNj45P6mQ3tujOjnO4fvimVqlO Z0IreyQ67rj/hjys3OuxDvwPTw8m7SHBVcTCH0i+MLjypxqLSeFbOMA4ojG73t+qGAhM wYQA== X-Gm-Message-State: AOJu0YzlBYgCe2GYwpeiUdY8WsNA7tl42j18MKvXVQVX7VWXMH88L3T4 vxoxm7sGC6flSlDUldKKKCZkGl0MZ4+Si04WQ/YXsUvg6/xYKvRvF25xIg== X-Received: by 2002:a17:90b:358c:b0:2d8:79bf:3873 with SMTP id 98e67ed59e1d1-2d8973a5a01mr1766170a91.29.1725121852255; Sat, 31 Aug 2024 09:30:52 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d85b3b9522sm5935328a91.50.2024.08.31.09.30.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Aug 2024 09:30:51 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 31 Aug 2024 13:31:06 -0300 Message-ID: <20240831163114.4197-5-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240831163114.4197-1-jamrial@gmail.com> References: <20240831163114.4197-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/13 v3] avcodec/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: udleXvMuDBgI Signed-off-by: James Almer --- libavcodec/h2645_sei.c | 34 ++++++++++++++++++++++++++++++++++ libavcodec/h2645_sei.h | 5 +++++ libavcodec/itut35.h | 2 ++ 3 files changed, 41 insertions(+) diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c index 7c83747cd0..c46a563308 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,10 @@ 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, @@ -778,6 +804,13 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, } } + if (sei->lcevc.info) { + HEVCSEILCEVC *lcevc = &sei->lcevc; + ret = ff_frame_new_side_data_from_buf(avctx, frame, AV_FRAME_DATA_LCEVC, &lcevc->info); + if (ret < 0) + return ret; + } + if (sei->film_grain_characteristics.present) { H2645SEIFilmGrainCharacteristics *fgc = &sei->film_grain_characteristics; AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(frame); @@ -875,6 +908,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 */