From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 5C5464BE2E for ; Mon, 3 Feb 2025 22:36:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2047268B3F2; Tue, 4 Feb 2025 00:36:46 +0200 (EET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1CB0068A67E for ; Tue, 4 Feb 2025 00:36:39 +0200 (EET) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2164b662090so97099135ad.1 for ; Mon, 03 Feb 2025 14:36:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738622197; x=1739226997; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=MFuYJvq7l4WnWYI3uYwZpciZhSHUz71pcdxOCEHtBtI=; b=mOpIL112C2K68yY6GUylj1gqiDajwihDPLAWM4PRqrT6kp6IJrxabIkUIJKXe91p/M V1kdp285YDA+Jsjwv24F5ERFwRQV5dTTRtQjjMMZaRXN2JxNgTzGxoxyOFm8wmyh3iZJ WZWSowRyeOzT/LEx5QAuAEphzDeGcrv+RJTRZ8Bfy+5HzWGWBl65HHbRYQ7IZ+b5DM4i IxlVrpLwygDnfle5OQhMtBC9HsBGQfn2+yDGD3piW6SSxZmYkm35bLHG5bmm5pMZQm0I YZz9SSZ9BRFcxZ0c7j7/MtHzk+Y3NTAAP5zf/M1ai7M67lsfLqk1Z/1VcMDm/XjREHDs DGZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738622197; x=1739226997; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MFuYJvq7l4WnWYI3uYwZpciZhSHUz71pcdxOCEHtBtI=; b=XrggfLqtfw8oyb2SlkVAe2k1SLIearNxBIgkkhcZ+BihNDLYX/ZS2PXA5PT8R4FEXg UiEMAAjwNhyK0xucKzq0EDFoXmF+rzp4vjbVBMg2kTddAVGeFHY4rVD4m0xYdTZCNtdz lGqzk8B9WtG5K42q+fBPRv+oimQk24Dt//ptSx+OIuxnEQpsrq6JCmhMOg2V1LnJQ/oL 9i3HUdxD0m32yRv9eifzDmhRnxhyaV1E8TDWaj1Gj58OJANfkwhrDe2zhitMDGED+Krt wgxnUXQrxoYxF170EUE4tZ+QTXt4s6ZqJIcKAmQ6m7Q5CkjFbteJfhuaNeiy4dqRMCq1 uTBA== X-Gm-Message-State: AOJu0YzogP6tgVfWFJcn6jDaEqVfRWACakLygTWLNkU413P9VDmZ2uy5 GC10ZHSE9RMz8TTPidFsyPoRYHbZV/JzazhqznygeEfHln1XLTzKWut3LaDo X-Gm-Gg: ASbGncs3s2c+uLvN2GM87aQZliuMgNNdCds3WDzHJj3VUsw+Ti2F6MZLhe1EAzx/ScZ Rl+7WUhmuWFORgPLAmdI8zmaWSaGbFGAqtaZzw4tF+muJuQZ7aSDAvqT+NlEfCR4tENgosAfskn 3Im28H6/xPU/L0wQMCRNjZuG1n0iHt1tijTz8aoOeKtMkKdySwMWq5s+1O9CcWqq86sgjUS+gmL 9mILsUvmnugVean6hDuUGLcN4Ujr6AqohHqv4qrzPTi8AqNeWKn3YETlClTNdR12cJfuuOhrGqq /TBIsakfBo4nscAdKQGN/lVh2KtD9x0= X-Google-Smtp-Source: AGHT+IHnqHiCso5iyKTo5sw2xsLPtI23qDjG+tTx1Gz0HoS2bBO02rRXic/M2SHNGQLIdMusaICHYQ== X-Received: by 2002:a05:6a20:72a0:b0:1e5:a0d8:5a33 with SMTP id adf61e73a8af0-1ed7a62498amr41820447637.18.1738622196328; Mon, 03 Feb 2025 14:36:36 -0800 (PST) Received: from localhost.localdomain ([2800:2121:b040:c:7d9c:3d76:2afc:cc38]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ad11841ec59sm5154543a12.57.2025.02.03.14.36.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 14:36:35 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Feb 2025 19:35:41 -0300 Message-ID: <20250203223546.12224-1-jamrial@gmail.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/6] avutil: add an API to handle Three Dimensional Reference Displays Information 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: As defined in section G.14.3.2.3 of ITU-T H.265, it's required for proper signaling of MV-HEVC. Signed-off-by: James Almer --- Better namespace, and now only allocating the required display reference entries. libavutil/Makefile | 2 + libavutil/ref_displays_info.c | 53 +++++++++++ libavutil/ref_displays_info.h | 169 ++++++++++++++++++++++++++++++++++ 3 files changed, 224 insertions(+) create mode 100644 libavutil/ref_displays_info.c create mode 100644 libavutil/ref_displays_info.h diff --git a/libavutil/Makefile b/libavutil/Makefile index f8031815bd..67e942243e 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -76,6 +76,7 @@ HEADERS = adler32.h \ random_seed.h \ rc4.h \ rational.h \ + ref_displays_info.h \ refstruct.h \ replaygain.h \ ripemd.h \ @@ -166,6 +167,7 @@ OBJS = adler32.o \ pixelutils.o \ random_seed.o \ rational.o \ + ref_displays_info.o \ refstruct.o \ reverse.o \ rc4.o \ diff --git a/libavutil/ref_displays_info.c b/libavutil/ref_displays_info.c new file mode 100644 index 0000000000..a51aa42b54 --- /dev/null +++ b/libavutil/ref_displays_info.c @@ -0,0 +1,53 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#include "avassert.h" +#include "mem.h" +#include "ref_displays_info.h" + +AV3DReferenceDisplaysInfo *av_ref_displays_info_alloc(unsigned int num_ref_displays, + size_t *out_size) +{ + struct CombinedStruct { + AV3DReferenceDisplaysInfo i; + AV3DReferenceDisplay r; + }; + const size_t ref_offset = offsetof(struct CombinedStruct, r); + size_t size = ref_offset; + AV3DReferenceDisplaysInfo *rdi; + + if (num_ref_displays > (SIZE_MAX - size) / sizeof(AV3DReferenceDisplay)) + return NULL; + size += sizeof(AV3DReferenceDisplay) * num_ref_displays; + + rdi = av_mallocz(size); + if (!rdi) + return NULL; + + rdi->num_ref_displays = num_ref_displays; + rdi->ref_size = sizeof(AV3DReferenceDisplay); + rdi->ref_offset = ref_offset; + + if (out_size) + *out_size = size; + + return rdi; +} diff --git a/libavutil/ref_displays_info.h b/libavutil/ref_displays_info.h new file mode 100644 index 0000000000..02ff4fcd98 --- /dev/null +++ b/libavutil/ref_displays_info.h @@ -0,0 +1,169 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @ingroup lavu_video_3d_reference_displays_info + * 3D Reference Displays Information + */ + +#ifndef AVUTIL_REF_DISPLAYS_INFO_H +#define AVUTIL_REF_DISPLAYS_INFO_H + +#include +#include + +#include "libavutil/avassert.h" + +/** + * @defgroup lavu_video_3d_reference_displays_info 3D Reference Displays Information + * @ingroup lavu_video + * + * The 3D Reference Displays Information describes information about the reference display + * width(s) and reference viewing distance(s) as well as information about the corresponding + * reference stereo pair(s). + * @{ + */ + +/** + * This structure describes information about the reference display width(s) and reference + * viewing distance(s) as well as information about the corresponding reference stereo pair(s). + * See section G.14.3.2.3 of ITU-T H.265 for more information. + * + * @note The struct must be allocated with av_ref_displays_info_alloc() and its size is not a + * part of the public ABI. + */ +typedef struct AV3DReferenceDisplaysInfo { + /** + * The number of reference displays that are signalled in this struct. + * Allowed range is 1 to 32, inclusive. + */ + unsigned int num_ref_displays; + + /** + * Offset in bytes from the beginning of this structure at which the array + * of reference displays starts. + */ + size_t ref_offset; + + /** + * Size of each reference display entry in bytes. May not match sizeof(AV3DReferenceDisplay). + */ + size_t ref_size; + + /** + * The exponent of the maximum allowable truncation error for + * {exponent,mantissa}_ref_display_width as given by 2(-prec_ref_display_width). + */ + uint8_t prec_ref_display_width; + + /** + * A flag to indicate the presence of reference viewing distance. + * If false, the values of prec_ref_viewing_dist, exponent_ref_viewing_distance, + * and mantissa_ref_viewing_distance are undefined. + */ + uint8_t ref_viewing_distance_flag; + + /** + * The exponent of the maximum allowable truncation error for + * {exponent,mantissa}_ref_viewing_distance as given by 2^(-prec_ref_viewing_dist). + * The value of prec_ref_viewing_dist shall be in the range of 0 to 31, inclusive. + */ + uint8_t prec_ref_viewing_dist; +} AV3DReferenceDisplaysInfo; + +/** + * Data structure for storing a reference display information. + * It is allocated as a part of AV3DReferenceDisplaysInfo and should be retrieved with + * av_ref_displays_info_display(). + * + * sizeof(AV3DReferenceDisplay) is not a part of the ABI and new fields may be + * added to it. + */ +typedef struct AV3DReferenceDisplay { + /** + * The ViewId of the left view of a stereo pair corresponding to the n-th reference display. + */ + uint16_t left_view_id; + + /** + * The ViewId of the left view of a stereo pair corresponding to the n-th reference display. + */ + uint16_t right_view_id; + + /** + * The exponent part of the reference display width of the n-th reference display. + */ + uint8_t exponent_ref_display_width; + + /** + * The mantissa part of the reference display width of the n-th reference display. + */ + uint8_t mantissa_ref_display_width; + + /** + * Tthe exponent part of the reference viewing distance of the n-th reference display. + */ + uint8_t exponent_ref_viewing_distance; + + /** + * The mantissa part of the reference viewing distance of the n-th reference display. + */ + uint8_t mantissa_ref_viewing_distance; + + /** + * An array of flags to indicates that the information about additional horizontal shift of + * the left and right views for the n-th reference display is present. + */ + uint8_t additional_shift_present_flag; + + /** + * The recommended additional horizontal shift for a stereo pair corresponding to the n-th + * reference baseline and the n-th reference display. + */ + int16_t num_sample_shift; +} AV3DReferenceDisplay; + +/** + * Get the reference display at the specified {@code idx}. + * Must be between 0 and num_ref_displays - 1. + */ +static av_always_inline AV3DReferenceDisplay* +av_ref_displays_info_display(AV3DReferenceDisplaysInfo *rdi, unsigned int idx) +{ + av_assert0(idx < rdi->num_ref_displays); + return (AV3DReferenceDisplay *)((uint8_t *)rdi + rdi->ref_offset + + idx * rdi->ref_size); +} + +/** + * Allocates memory for AV3DReferenceDisplaysInfo, plus an array of + * {@code num_ref_displays} AV3DReferenceDisplay and initializes the variables. + * Can be freed with a normal av_free() call. + * + * @param num_ref_displays the number of reference displays. + * @return the newly allocated struct or NULL on failure + */ +AV3DReferenceDisplaysInfo *av_ref_displays_info_alloc(unsigned int num_ref_displays, + size_t *out_size); + +/** + * @} + */ + +#endif /* AVUTIL_REF_DISPLAYS_INFO_H */ -- 2.48.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".