From patchwork Sat Jul 13 14:58:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 50523 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2298:b0:482:c625:d099 with SMTP id fp24csp1415327vqb; Sat, 13 Jul 2024 08:16:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVud+Z/p2EcWSCKSOhTNnyF/X9G8kT4GcUPD8hNSLZypgInurYW8dYK8umjfLwKgppr6xkTG5gxmQ6CTmx03AUJeeXcoGYzZL8pxA== X-Google-Smtp-Source: AGHT+IF7hQJCyBhsn04hKjlizG9Cr49dGG7BkW58TSpkb8g9fhC/aKfbHZ8tUvsgDzONCD3Jen/n X-Received: by 2002:a17:906:730a:b0:a6f:2835:be95 with SMTP id a640c23a62f3a-a799d3a55b7mr379907966b.37.1720883806490; Sat, 13 Jul 2024 08:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720883806; cv=none; d=google.com; s=arc-20160816; b=P6b9g5GHqCoLXPffOTdeXwsaxpBHlbVlO2auT0Ls0K8qGL/bqe3lXDI67KAZliRpJ+ n9F6gEx1qHTEb35aujfWLHh7cav6ajn+p0eT8SNlv1ESUQl3hAoOwu+6VnlsslF15X1B y+tIq3OyTGofjjurq0j4QHNxcLZK9x+1lRZR/yEuQfHPyORXZTpECLAs87SFIwpDSuaL KUpVR+5PbZDUIwX13X/3FiQwpIue+XfVZOtOTNNwieA24ltYOBAra//vTCmvkhGZ+C0a I7GWmMT5SqctFAsiTdEWbOtkhE6S2Mikfb3PEJ0vNafvJNcfUmf3b3IpxQz6U8KbOfG1 9T1g== 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=4+j5vlgE1lTnWXdtK1/+WykZ3DzjEMfa8kGEzROcn4A=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=U1Hp1iLiwRsqJu5MBPUHlSBzUsuFFH+NaaoEfflRhsMXvVhUEDQzNa25cGJzQ0Tsqm YCK1/Dt0bsFVQMuFmt98astXFbFeSVHBqyt4wpj+ZFbgoJZvf574AAX9Jeor9XnU1Rym uyU/9O88NjBU4YCIwhoFl2qG5TPL5RF0suz7sTgaSN0K4OV/crz9x/0T7wAud4wHgBDW aCQJIMoMjvtlTHz/Ew6C5+WBmPca/xP7TUzewPNIA0wMR9b7T1nir8XtUctR2gIOdXaM /cAPB8ybV7fNUYodBO54WVF0jQBgQmnih4rx1js3RC0/BfUjOt8ySs1ufXLjTUDDX6JW SSGQ==; 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=Iy43aG7j; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a79bc5a8cb1si72247966b.238.2024.07.13.08.16.46; Sat, 13 Jul 2024 08:16: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=@gmail.com header.s=20230601 header.b=Iy43aG7j; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D957168DC33; Sat, 13 Jul 2024 17:59:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5058968DC01 for ; Sat, 13 Jul 2024 17:59:09 +0300 (EEST) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1fafc9e07f8so21529015ad.0 for ; Sat, 13 Jul 2024 07:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720882747; x=1721487547; 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=K8mrs7PrRVB7Og7yS37Y8mtOrgZZyglGY8Cq+imMgSE=; b=Iy43aG7j2vDAAtocYnlA4RPYg/A6V+yM8YFsprJw9gvbTkXZBPfsUdidQ5cmVoV7gs iPj+ncf56aojAQ2OjiymXaHOOwTbC9bR0e01sJ4dI3kVXzNcOZmcmW3csCHJpys+oRGb T6NPkVluudOdi7lGcrO6PA0X93v7i3k2UoxT3h5BNDh++clcLU744beG/kDWYFAPP+n9 K6XvpnpiHfd8l+DrV/V5GlBRvBznBgi92AeY1JcQ5Vj62rv7FEmNXrb0EPObsKMQPuC4 YsZfMWQ0A+8XQLhOWUNofQxJq8wv/Rxf07oYCmXaPodpv2GbZoXCrqJzNutkuKO4MXkf yZuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720882747; x=1721487547; 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=K8mrs7PrRVB7Og7yS37Y8mtOrgZZyglGY8Cq+imMgSE=; b=RzsquJExsPQb3aQDktbKJvvPCfy/2anNpJKAK/bXiJclGPgJb7eYXD6XOMjLaI1+VO 52cbRENwJnRxmuvMVqy8+f/dPkP6NnEkTR4w9/6LIRjDc8T7f02r+Q6qvublTAURVL7h Da/5iFosHRJl62uMID3UTj1V98RN3ilZ10Yf97i5c/6ibMuZl0rgBIP0ASONfDgdXVv4 gNe3zhBUrTyo691zMexcDR5oYO3ue9+3goKSGOYRLaSPsTyYMoESIm/MLBwekCDz0XYw aMiYrWbovN3zzM9WrhCpZ6wp6R8czBX7dBWUw3r/ZLZ86pEcFp5nvIvywAC4+Ka59kKt RSZg== X-Gm-Message-State: AOJu0YwK4ndDsWKheHwd7RW3ZxM1qmaRRBrbgmxbuyhFrI17YRpo+V5h PnUSAyuWIIftMe11wffXe7o3TC96VKRbLJtSiO+mAacaP9EnE0aIH8K/Dg== X-Received: by 2002:a17:902:db02:b0:1fa:643:f42f with SMTP id d9443c01a7336-1fbb6ef8fa3mr144493975ad.62.1720882747086; Sat, 13 Jul 2024 07:59:07 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fc0eea3cfbsm9800275ad.115.2024.07.13.07.59.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jul 2024 07:59:06 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 13 Jul 2024 11:58:46 -0300 Message-ID: <20240713145846.1331-4-jamrial@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240713145846.1331-1-jamrial@gmail.com> References: <20240713145846.1331-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avcodec/cbs_h265: add support for 3D Reference Displays Information SEI 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: CbediSYmLThN Signed-off-by: James Almer --- libavcodec/cbs_h2645.c | 6 ++++ libavcodec/cbs_h265.h | 16 ++++++++++ libavcodec/cbs_h265_syntax_template.c | 42 +++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 828e56b8c0..d73d77a985 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -2275,6 +2275,12 @@ static const SEIMessageTypeDescriptor cbs_sei_h265_types[] = { sizeof(H265RawSEIAlphaChannelInfo), SEI_MESSAGE_RW(h265, sei_alpha_channel_info), }, + { + SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO, + 1, 0, + sizeof(H265RawSEI3DReferenceDisplaysInfo), + SEI_MESSAGE_RW(h265, sei_3d_reference_displays_info), + }, SEI_MESSAGE_TYPE_END }; diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h index afb942ced5..52631f9bfb 100644 --- a/libavcodec/cbs_h265.h +++ b/libavcodec/cbs_h265.h @@ -715,6 +715,22 @@ typedef struct H265RawSEIAlphaChannelInfo { uint8_t alpha_channel_clip_type_flag; } H265RawSEIAlphaChannelInfo; +typedef struct H265RawSEI3DReferenceDisplaysInfo { + uint8_t prec_ref_display_width; + uint8_t ref_viewing_distance_flag; + uint8_t prec_ref_viewing_dist; + uint8_t num_ref_displays_minus1; + uint8_t left_view_id[31]; + uint8_t right_view_id[31]; + uint8_t exponent_ref_display_width[31]; + uint8_t mantissa_ref_display_width[31]; + uint8_t exponent_ref_viewing_distance[31]; + uint8_t mantissa_ref_viewing_distance[31]; + uint8_t additional_shift_present_flag[31]; + uint16_t num_sample_shift_plus512[31]; + uint8_t three_dimensional_reference_displays_extension_flag; +} H265RawSEI3DReferenceDisplaysInfo; + typedef struct H265RawSEI { H265RawNALUnitHeader nal_unit_header; SEIRawMessageList message_list; diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 1826950e8e..ee01b5e0d0 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -2189,6 +2189,48 @@ SEI_FUNC(sei_alpha_channel_info, (CodedBitstreamContext *ctx, RWContext *rw, return 0; } +SEI_FUNC(sei_3d_reference_displays_info, (CodedBitstreamContext *ctx, RWContext *rw, + H265RawSEI3DReferenceDisplaysInfo *current, + SEIMessageState *sei)) +{ + int length; + int err, i; + + HEADER("Three Dimensional Reference Displays Information"); + + ue(prec_ref_display_width, 0, 31); + flag(ref_viewing_distance_flag); + if (current->ref_viewing_distance_flag) + ue(prec_ref_viewing_dist, 0, 31); + ue(num_ref_displays_minus1, 0, 31); + for (i = 0; i <= current->num_ref_displays_minus1; i++) { + ues(left_view_id[i], 0, UINT8_MAX, 1, i); + ues(right_view_id[i], 0, UINT8_MAX, 1, i); + us(6, exponent_ref_display_width[i], 0, 62, 1, i); + if (!current->exponent_ref_display_width[i]) + length = FFMAX(0, (int)current->prec_ref_display_width - 30); + else + length = FFMAX(0, (int)current->exponent_ref_display_width[i] + + (int)current->prec_ref_display_width - 31); + ubs(length, mantissa_ref_display_width[i], 1, i); + if (current->ref_viewing_distance_flag) { + us(6, exponent_ref_viewing_distance[i], 0, 62, 1, i); + if (!current->exponent_ref_viewing_distance[i]) + length = FFMAX(0, (int)current->prec_ref_viewing_dist - 30); + else + length = FFMAX(0, (int)current->exponent_ref_viewing_distance[i] + + (int)current->prec_ref_viewing_dist - 31); + ubs(length, mantissa_ref_viewing_distance[i], 1, i); + } + flags(additional_shift_present_flag[i], 1, i); + if (current->additional_shift_present_flag[i]) + us(10, num_sample_shift_plus512[i], 0, 1023, 1, i); + } + flag(three_dimensional_reference_displays_extension_flag); + + return 0; +} + static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw, H265RawSEI *current, int prefix) {