* [FFmpeg-devel] [PATCH 1/6] avutil: add an API to handle 3D Reference Displays Information
@ 2025-01-31 14:00 James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 2/6] avutil/frame: add a 3D Reference Displays Information side data type James Almer
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: James Almer @ 2025-01-31 14:00 UTC (permalink / raw)
To: ffmpeg-devel
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 <jamrial@gmail.com>
---
libavutil/Makefile | 2 +
libavutil/tdrdi.c | 35 ++++++++++++
libavutil/tdrdi.h | 129 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 166 insertions(+)
create mode 100644 libavutil/tdrdi.c
create mode 100644 libavutil/tdrdi.h
diff --git a/libavutil/Makefile b/libavutil/Makefile
index f8031815bd..a9a98d18a5 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -84,6 +84,7 @@ HEADERS = adler32.h \
sha512.h \
spherical.h \
stereo3d.h \
+ tdrdi.h \
threadmessage.h \
time.h \
timecode.h \
@@ -176,6 +177,7 @@ OBJS = adler32.o \
slicethread.o \
spherical.o \
stereo3d.o \
+ tdrdi.o \
threadmessage.o \
time.o \
timecode.o \
diff --git a/libavutil/tdrdi.c b/libavutil/tdrdi.c
new file mode 100644
index 0000000000..144f31db05
--- /dev/null
+++ b/libavutil/tdrdi.c
@@ -0,0 +1,35 @@
+/*
+ * 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 <stddef.h>
+#include <stdint.h>
+
+#include "mem.h"
+#include "tdrdi.h"
+
+AV3DReferenceDisplaysInfo *av_tdrdi_alloc(size_t *size)
+{
+ AV3DReferenceDisplaysInfo *tdrdi = av_mallocz(sizeof(AV3DReferenceDisplaysInfo));
+ if (!tdrdi)
+ return NULL;
+
+ if (size)
+ *size = sizeof(*tdrdi);
+
+ return tdrdi;
+}
diff --git a/libavutil/tdrdi.h b/libavutil/tdrdi.h
new file mode 100644
index 0000000000..896873374c
--- /dev/null
+++ b/libavutil/tdrdi.h
@@ -0,0 +1,129 @@
+/*
+ * 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_spherical
+ * Spherical video
+ */
+
+#ifndef AVUTIL_TDRDI_H
+#define AVUTIL_TDRDI_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+/**
+ * @defgroup lavu_video_reference_displays_info 3D Reference Displays Information
+ * @ingroup lavu_video
+ *
+ * @{
+ */
+
+#define AV_TDRDI_MAX_NUM_REF_DISPLAY 32
+/**
+ * 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_tdrdi_alloc() and
+ * its size is not a part of the public ABI.
+ */
+typedef struct AV3DReferenceDisplaysInfo {
+ /**
+ * 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;
+
+ /**
+ * The number of reference displays that are signalled in this struct.
+ * Allowed range is 1 to 32, inclusive.
+ */
+ uint8_t num_ref_displays;
+
+ /**
+ * The ViewId of the left view of a stereo pair corresponding to the n-th reference display.
+ */
+ uint16_t left_view_id[AV_TDRDI_MAX_NUM_REF_DISPLAY];
+
+ /**
+ * The ViewId of the left view of a stereo pair corresponding to the n-th reference display.
+ */
+ uint16_t right_view_id[AV_TDRDI_MAX_NUM_REF_DISPLAY];
+
+ /**
+ * The exponent part of the reference display width of the n-th reference display.
+ */
+ uint8_t exponent_ref_display_width[AV_TDRDI_MAX_NUM_REF_DISPLAY];
+
+ /**
+ * The mantissa part of the reference display width of the n-th reference display.
+ */
+ uint8_t mantissa_ref_display_width[AV_TDRDI_MAX_NUM_REF_DISPLAY];
+
+ /**
+ * Tthe exponent part of the reference viewing distance of the n-th reference display.
+ */
+ uint8_t exponent_ref_viewing_distance[AV_TDRDI_MAX_NUM_REF_DISPLAY];
+
+ /**
+ * The mantissa part of the reference viewing distance of the n-th reference display.
+ */
+ uint8_t mantissa_ref_viewing_distance[AV_TDRDI_MAX_NUM_REF_DISPLAY];
+
+ /**
+ * 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[AV_TDRDI_MAX_NUM_REF_DISPLAY];
+
+ /**
+ * 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[AV_TDRDI_MAX_NUM_REF_DISPLAY];
+} AV3DReferenceDisplaysInfo;
+
+/**
+ * Allocate a AV3DReferenceDisplaysInfo structure and initialize its fields to default
+ * values.
+ *
+ * @return the newly allocated struct or NULL on failure
+ */
+AV3DReferenceDisplaysInfo *av_tdrdi_alloc(size_t *size);
+
+/**
+ * @}
+ */
+
+#endif /* AVUTIL_TDRDI_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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* [FFmpeg-devel] [PATCH 2/6] avutil/frame: add a 3D Reference Displays Information side data type
2025-01-31 14:00 [FFmpeg-devel] [PATCH 1/6] avutil: add an API to handle 3D Reference Displays Information James Almer
@ 2025-01-31 14:00 ` James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 3/6] avcodec/packet: " James Almer
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: James Almer @ 2025-01-31 14:00 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavutil/frame.c | 1 +
libavutil/frame.h | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 992115e04f..d1566298ae 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -59,6 +59,7 @@ static const AVSideDataDescriptor sd_props[] = {
[AV_FRAME_DATA_ICC_PROFILE] = { "ICC profile", AV_SIDE_DATA_PROP_GLOBAL | AV_SIDE_DATA_PROP_COLOR_DEPENDENT },
[AV_FRAME_DATA_SEI_UNREGISTERED] = { "H.26[45] User Data Unregistered SEI message", AV_SIDE_DATA_PROP_MULTI },
[AV_FRAME_DATA_VIDEO_HINT] = { "Encoding video hint", AV_SIDE_DATA_PROP_SIZE_DEPENDENT },
+ [AV_FRAME_DATA_3D_REFERENCE_DISPLAYS] = { "3D Reference Displays Information", AV_SIDE_DATA_PROP_GLOBAL },
};
static void get_frame_defaults(AVFrame *frame)
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 49260ae2dd..f0de1921f4 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -243,6 +243,17 @@ enum AVFrameSideDataType {
* The data is an int storing the view ID.
*/
AV_FRAME_DATA_VIEW_ID,
+
+ /**
+ * This side data contains information about the reference display width(s)
+ * and reference viewing distance(s) as well as information about the
+ * corresponding reference stereo pair(s), i.e., the pair(s) of views to be
+ * displayed for the viewer's left and right eyes on the reference display
+ * at the reference viewing distance.
+ * The payload is the AV3DReferenceDisplaysInfo struct defined in
+ * libavutil/tdrdi.h.
+ */
+ AV_FRAME_DATA_3D_REFERENCE_DISPLAYS,
};
enum AVActiveFormatDescription {
--
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* [FFmpeg-devel] [PATCH 3/6] avcodec/packet: add a 3D Reference Displays Information side data type
2025-01-31 14:00 [FFmpeg-devel] [PATCH 1/6] avutil: add an API to handle 3D Reference Displays Information James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 2/6] avutil/frame: add a 3D Reference Displays Information side data type James Almer
@ 2025-01-31 14:00 ` James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 4/6] avformat/dump: add support for 3D Reference Displays Information side data James Almer
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: James Almer @ 2025-01-31 14:00 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/avcodec.c | 1 +
libavcodec/packet.c | 1 +
libavcodec/packet.h | 11 +++++++++++
3 files changed, 13 insertions(+)
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index e7e2c09222..fe19d99a84 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -65,6 +65,7 @@ const SideDataMap ff_sd_global_map[] = {
{ AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
{ AV_PKT_DATA_ICC_PROFILE, AV_FRAME_DATA_ICC_PROFILE },
{ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT },
+ { AV_PKT_DATA_3D_REFERENCE_DISPLAYS, AV_FRAME_DATA_3D_REFERENCE_DISPLAYS },
{ AV_PKT_DATA_NB },
};
diff --git a/libavcodec/packet.c b/libavcodec/packet.c
index 5104eb98b1..4003b56223 100644
--- a/libavcodec/packet.c
+++ b/libavcodec/packet.c
@@ -308,6 +308,7 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type)
case AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM: return "IAMF Recon Gain Info Parameter Data";
case AV_PKT_DATA_FRAME_CROPPING: return "Frame Cropping";
case AV_PKT_DATA_LCEVC: return "LCEVC NAL data";
+ case AV_PKT_DATA_3D_REFERENCE_DISPLAYS: return "3D Reference Displays Info";
}
return NULL;
}
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index c1f1ad7b43..fd013cec62 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -345,6 +345,17 @@ enum AVPacketSideDataType {
*/
AV_PKT_DATA_LCEVC,
+ /**
+ * This side data contains information about the reference display width(s)
+ * and reference viewing distance(s) as well as information about the
+ * corresponding reference stereo pair(s), i.e., the pair(s) of views to be
+ * displayed for the viewer's left and right eyes on the reference display
+ * at the reference viewing distance.
+ * The payload is the AV3DReferenceDisplaysInfo struct defined in
+ * libavutil/tdrdi.h.
+ */
+ AV_PKT_DATA_3D_REFERENCE_DISPLAYS,
+
/**
* The number of side data types.
* This is not part of the public API/ABI in the sense that it may
--
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* [FFmpeg-devel] [PATCH 4/6] avformat/dump: add support for 3D Reference Displays Information side data
2025-01-31 14:00 [FFmpeg-devel] [PATCH 1/6] avutil: add an API to handle 3D Reference Displays Information James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 2/6] avutil/frame: add a 3D Reference Displays Information side data type James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 3/6] avcodec/packet: " James Almer
@ 2025-01-31 14:00 ` James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 5/6] avfilter/vf_showinfo: " James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays " James Almer
4 siblings, 0 replies; 11+ messages in thread
From: James Almer @ 2025-01-31 14:00 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavformat/dump.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 3d37623a41..f19ee584b1 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -37,6 +37,7 @@
#include "libavutil/replaygain.h"
#include "libavutil/spherical.h"
#include "libavutil/stereo3d.h"
+#include "libavutil/tdrdi.h"
#include "libavutil/timecode.h"
#include "libavcodec/avcodec.h"
@@ -461,6 +462,14 @@ static void dump_cropping(void *ctx, const AVPacketSideData *sd)
av_log(ctx, AV_LOG_INFO, "%d/%d/%d/%d", left, right, top, bottom);
}
+static void dump_tdrdi(void *ctx, const AVPacketSideData *sd)
+{
+ const AV3DReferenceDisplaysInfo *tdrdi =
+ (const AV3DReferenceDisplaysInfo *)sd->data;
+
+ av_log(ctx, AV_LOG_INFO, "number of reference displays: %u", tdrdi->num_ref_displays);
+}
+
static void dump_sidedata(void *ctx, const AVPacketSideData *side_data, int nb_side_data,
int w, int h, AVRational avg_frame_rate,
const char *indent, int log_level)
@@ -540,6 +549,10 @@ static void dump_sidedata(void *ctx, const AVPacketSideData *side_data, int nb_s
av_log(ctx, AV_LOG_INFO, "Frame cropping: ");
dump_cropping(ctx, sd);
break;
+ case AV_PKT_DATA_3D_REFERENCE_DISPLAYS:
+ av_log(ctx, log_level, "3D Reference Displays Information: ");
+ dump_tdrdi(ctx, sd);
+ break;
default:
av_log(ctx, log_level, "unknown side data type %d "
"(%"SIZE_SPECIFIER" bytes)", sd->type, sd->size);
--
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* [FFmpeg-devel] [PATCH 5/6] avfilter/vf_showinfo: add support for 3D Reference Displays Information side data
2025-01-31 14:00 [FFmpeg-devel] [PATCH 1/6] avutil: add an API to handle 3D Reference Displays Information James Almer
` (2 preceding siblings ...)
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 4/6] avformat/dump: add support for 3D Reference Displays Information side data James Almer
@ 2025-01-31 14:00 ` James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays " James Almer
4 siblings, 0 replies; 11+ messages in thread
From: James Almer @ 2025-01-31 14:00 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavfilter/vf_showinfo.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 8109ca7fce..c706d00c96 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -38,6 +38,7 @@
#include "libavutil/pixdesc.h"
#include "libavutil/spherical.h"
#include "libavutil/stereo3d.h"
+#include "libavutil/tdrdi.h"
#include "libavutil/timestamp.h"
#include "libavutil/timecode.h"
#include "libavutil/mastering_display_metadata.h"
@@ -152,6 +153,14 @@ static void dump_roi(AVFilterContext *ctx, const AVFrameSideData *sd)
}
}
+static void dump_tdrdi(AVFilterContext *ctx, const AVFrameSideData *sd)
+{
+ const AV3DReferenceDisplaysInfo *tdrdi = (const AV3DReferenceDisplaysInfo *)sd->data;
+
+
+ av_log(ctx, AV_LOG_INFO, "number of reference displays: %u", tdrdi->num_ref_displays);
+}
+
static void dump_detection_bbox(AVFilterContext *ctx, const AVFrameSideData *sd)
{
int nb_bboxes;
@@ -860,6 +869,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
case AV_FRAME_DATA_VIEW_ID:
av_log(ctx, AV_LOG_INFO, "view id: %d\n", *(int*)sd->data);
break;
+ case AV_FRAME_DATA_3D_REFERENCE_DISPLAYS:
+ dump_tdrdi(ctx, sd);
+ break;
default:
if (name)
av_log(ctx, AV_LOG_INFO,
--
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* [FFmpeg-devel] [PATCH 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays side data
2025-01-31 14:00 [FFmpeg-devel] [PATCH 1/6] avutil: add an API to handle 3D Reference Displays Information James Almer
` (3 preceding siblings ...)
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 5/6] avfilter/vf_showinfo: " James Almer
@ 2025-01-31 14:00 ` James Almer
2025-01-31 20:58 ` [FFmpeg-devel] [PATCH v2 " James Almer
4 siblings, 1 reply; 11+ messages in thread
From: James Almer @ 2025-01-31 14:00 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/hevc/hevcdec.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 7d3e844945..91119fbc58 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -36,6 +36,7 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/stereo3d.h"
+#include "libavutil/tdrdi.h"
#include "libavutil/timecode.h"
#include "aom_film_grain.h"
@@ -416,6 +417,42 @@ FF_ENABLE_DEPRECATION_WARNINGS
avctx->color_trc = s->sei.common.alternative_transfer.preferred_transfer_characteristics;
}
+ if (s->sei.tdrdi.num_ref_displays) {
+ const HEVCSEITDRDI *sei = &s->sei.tdrdi;
+ size_t size;
+ AV3DReferenceDisplaysInfo *tdrdi = av_tdrdi_alloc(&size);
+
+ if (!tdrdi)
+ return AVERROR(ENOMEM);
+
+ tdrdi->prec_ref_display_width = sei->prec_ref_display_width;
+ tdrdi->ref_viewing_distance_flag = sei->ref_viewing_distance_flag;
+ tdrdi->prec_ref_viewing_dist = sei->prec_ref_viewing_dist;
+ tdrdi->num_ref_displays = sei->num_ref_displays;
+ memcpy(tdrdi->left_view_id,
+ sei->left_view_id, sizeof(tdrdi->left_view_id));
+ memcpy(tdrdi->right_view_id,
+ sei->right_view_id, sizeof(tdrdi->right_view_id));
+ memcpy(tdrdi->exponent_ref_display_width,
+ sei->exponent_ref_display_width, sizeof(tdrdi->exponent_ref_display_width));
+ memcpy(tdrdi->mantissa_ref_display_width,
+ sei->mantissa_ref_display_width, sizeof(tdrdi->mantissa_ref_display_width));
+ memcpy(tdrdi->exponent_ref_viewing_distance,
+ sei->exponent_ref_viewing_distance, sizeof(tdrdi->exponent_ref_viewing_distance));
+ memcpy(tdrdi->mantissa_ref_viewing_distance,
+ sei->mantissa_ref_viewing_distance, sizeof(tdrdi->mantissa_ref_viewing_distance));
+ memcpy(tdrdi->additional_shift_present_flag,
+ sei->additional_shift_present_flag, sizeof(tdrdi->additional_shift_present_flag));
+ memcpy(tdrdi->num_sample_shift,
+ sei->num_sample_shift, sizeof(tdrdi->num_sample_shift));
+
+ if (!av_packet_side_data_add(&avctx->coded_side_data, &avctx->nb_coded_side_data,
+ AV_PKT_DATA_3D_REFERENCE_DISPLAYS, tdrdi, size, 0)) {
+ av_free(tdrdi);
+ return AVERROR(ENOMEM);
+ }
+ }
+
#if FF_API_CODEC_PROPS
FF_DISABLE_DEPRECATION_WARNINGS
if ((s->sei.common.film_grain_characteristics && s->sei.common.film_grain_characteristics->present) ||
--
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* [FFmpeg-devel] [PATCH v2 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays side data
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays " James Almer
@ 2025-01-31 20:58 ` James Almer
0 siblings, 0 replies; 11+ messages in thread
From: James Almer @ 2025-01-31 20:58 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/hevc/hevcdec.c | 57 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
Now actually filling the correct side data array.
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 7d3e844945..db97d9b0a2 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -36,6 +36,7 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/stereo3d.h"
+#include "libavutil/tdrdi.h"
#include "libavutil/timecode.h"
#include "aom_film_grain.h"
@@ -4015,6 +4016,60 @@ static int hevc_update_thread_context(AVCodecContext *dst,
}
#endif
+static int hevc_sei_to_context(AVCodecContext *avctx, HEVCSEI *sei)
+{
+ int ret;
+
+ if (sei->tdrdi.num_ref_displays) {
+ AVBufferRef *buf;
+ size_t size;
+ AV3DReferenceDisplaysInfo *tdrdi = av_tdrdi_alloc(&size);
+
+ if (!tdrdi)
+ return AVERROR(ENOMEM);
+
+ buf = av_buffer_create((uint8_t *)tdrdi, size, NULL, NULL, 0);
+ if (!buf) {
+ av_free(tdrdi);
+ return AVERROR(ENOMEM);
+ }
+
+ tdrdi->prec_ref_display_width = sei->tdrdi.prec_ref_display_width;
+ tdrdi->ref_viewing_distance_flag = sei->tdrdi.ref_viewing_distance_flag;
+ tdrdi->prec_ref_viewing_dist = sei->tdrdi.prec_ref_viewing_dist;
+ tdrdi->num_ref_displays = sei->tdrdi.num_ref_displays;
+ memcpy(tdrdi->left_view_id,
+ sei->tdrdi.left_view_id, sizeof(tdrdi->left_view_id));
+ memcpy(tdrdi->right_view_id,
+ sei->tdrdi.right_view_id, sizeof(tdrdi->right_view_id));
+ memcpy(tdrdi->exponent_ref_display_width,
+ sei->tdrdi.exponent_ref_display_width, sizeof(tdrdi->exponent_ref_display_width));
+ memcpy(tdrdi->mantissa_ref_display_width,
+ sei->tdrdi.mantissa_ref_display_width, sizeof(tdrdi->mantissa_ref_display_width));
+ memcpy(tdrdi->exponent_ref_viewing_distance,
+ sei->tdrdi.exponent_ref_viewing_distance, sizeof(tdrdi->exponent_ref_viewing_distance));
+ memcpy(tdrdi->mantissa_ref_viewing_distance,
+ sei->tdrdi.mantissa_ref_viewing_distance, sizeof(tdrdi->mantissa_ref_viewing_distance));
+ memcpy(tdrdi->additional_shift_present_flag,
+ sei->tdrdi.additional_shift_present_flag, sizeof(tdrdi->additional_shift_present_flag));
+ memcpy(tdrdi->num_sample_shift,
+ sei->tdrdi.num_sample_shift, sizeof(tdrdi->num_sample_shift));
+
+ ret = ff_frame_new_side_data_from_buf_ext(avctx, &avctx->decoded_side_data, &avctx->nb_decoded_side_data,
+ AV_FRAME_DATA_3D_REFERENCE_DISPLAYS, &buf);
+ if (ret < 0) {
+ av_buffer_unref(&buf);
+ return ret;
+ }
+ }
+
+ ret = ff_h2645_sei_to_context(avctx, &sei->common);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
static av_cold int hevc_decode_init(AVCodecContext *avctx)
{
HEVCContext *s = avctx->priv_data;
@@ -4038,7 +4093,7 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
return ret;
}
- ret = ff_h2645_sei_to_context(avctx, &s->sei.common);
+ ret = hevc_sei_to_context(avctx, &s->sei);
if (ret < 0)
return ret;
}
--
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays side data
2025-02-05 21:16 ` James Almer
@ 2025-02-05 21:36 ` Michael Niedermayer
0 siblings, 0 replies; 11+ messages in thread
From: Michael Niedermayer @ 2025-02-05 21:36 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 1279 bytes --]
On Wed, Feb 05, 2025 at 06:16:35PM -0300, James Almer wrote:
> On 2/5/2025 6:07 PM, Michael Niedermayer wrote:
> > On Mon, Feb 03, 2025 at 07:35:46PM -0300, James Almer wrote:
> > > Signed-off-by: James Almer <jamrial@gmail.com>
> > > ---
> > > libavcodec/hevc/hevcdec.c | 55 ++++++++++++++++++++++++++++++++++++++-
> > > 1 file changed, 54 insertions(+), 1 deletion(-)
> >
> > seems to fail to build
> > libavcodec/hevc/hevcdec.c: In function ‘hevc_sei_to_context’:
> > libavcodec/hevc/hevcdec.c:4060:15: error: too few arguments to function ‘ff_frame_new_side_data_from_buf_ext’
> > 4060 | ret = ff_frame_new_side_data_from_buf_ext(avctx, &avctx->decoded_side_data, &avctx->nb_decoded_side_data,
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Do you happen to have https://patchwork.ffmpeg.org/project/ffmpeg/patch/20250204211256.10228-1-jamrial@gmail.com/
> also in your tree? That's a separate patchset and currently incompatible
> with this one.
yes i had this locally too
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays side data
2025-02-05 21:07 ` Michael Niedermayer
@ 2025-02-05 21:16 ` James Almer
2025-02-05 21:36 ` Michael Niedermayer
0 siblings, 1 reply; 11+ messages in thread
From: James Almer @ 2025-02-05 21:16 UTC (permalink / raw)
To: ffmpeg-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 920 bytes --]
On 2/5/2025 6:07 PM, Michael Niedermayer wrote:
> On Mon, Feb 03, 2025 at 07:35:46PM -0300, James Almer wrote:
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>> libavcodec/hevc/hevcdec.c | 55 ++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 54 insertions(+), 1 deletion(-)
>
> seems to fail to build
> libavcodec/hevc/hevcdec.c: In function ‘hevc_sei_to_context’:
> libavcodec/hevc/hevcdec.c:4060:15: error: too few arguments to function ‘ff_frame_new_side_data_from_buf_ext’
> 4060 | ret = ff_frame_new_side_data_from_buf_ext(avctx, &avctx->decoded_side_data, &avctx->nb_decoded_side_data,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do you happen to have
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20250204211256.10228-1-jamrial@gmail.com/
also in your tree? That's a separate patchset and currently incompatible
with this one.
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays side data
2025-02-03 22:35 ` [FFmpeg-devel] [PATCH v2 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays side data James Almer
@ 2025-02-05 21:07 ` Michael Niedermayer
2025-02-05 21:16 ` James Almer
0 siblings, 1 reply; 11+ messages in thread
From: Michael Niedermayer @ 2025-02-05 21:07 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 952 bytes --]
On Mon, Feb 03, 2025 at 07:35:46PM -0300, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> libavcodec/hevc/hevcdec.c | 55 ++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 54 insertions(+), 1 deletion(-)
seems to fail to build
libavcodec/hevc/hevcdec.c: In function ‘hevc_sei_to_context’:
libavcodec/hevc/hevcdec.c:4060:15: error: too few arguments to function ‘ff_frame_new_side_data_from_buf_ext’
4060 | ret = ff_frame_new_side_data_from_buf_ext(avctx, &avctx->decoded_side_data, &avctx->nb_decoded_side_data,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[...]
thx
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
than the original author, trying to rewrite it will not make it better.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
* [FFmpeg-devel] [PATCH v2 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays side data
2025-02-03 22:35 [FFmpeg-devel] [PATCH v2 1/6] avutil: add an API to handle Three Dimensional Reference Displays Information James Almer
@ 2025-02-03 22:35 ` James Almer
2025-02-05 21:07 ` Michael Niedermayer
0 siblings, 1 reply; 11+ messages in thread
From: James Almer @ 2025-02-03 22:35 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/hevc/hevcdec.c | 55 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index f9ff22dbac..ffacbcad24 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -35,6 +35,7 @@
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/ref_displays_info.h"
#include "libavutil/stereo3d.h"
#include "libavutil/timecode.h"
@@ -4021,6 +4022,58 @@ static int hevc_update_thread_context(AVCodecContext *dst,
}
#endif
+static int hevc_sei_to_context(AVCodecContext *avctx, HEVCSEI *sei)
+{
+ const HEVCSEITDRDI *tdrdi = sei->tdrdi;
+ int ret;
+
+ if (tdrdi && tdrdi->num_ref_displays) {
+ AVBufferRef *buf;
+ size_t size;
+ AV3DReferenceDisplaysInfo *rdi = av_ref_displays_info_alloc(tdrdi->num_ref_displays, &size);
+
+ if (!rdi)
+ return AVERROR(ENOMEM);
+
+ buf = av_buffer_create((uint8_t *)rdi, size, NULL, NULL, 0);
+ if (!buf) {
+ av_free(rdi);
+ return AVERROR(ENOMEM);
+ }
+
+ rdi->prec_ref_display_width = tdrdi->prec_ref_display_width;
+ rdi->ref_viewing_distance_flag = tdrdi->ref_viewing_distance_flag;
+ rdi->prec_ref_viewing_dist = tdrdi->prec_ref_viewing_dist;
+ rdi->num_ref_displays = tdrdi->num_ref_displays;
+
+ for (int i = 0; i < rdi->num_ref_displays; i++) {
+ AV3DReferenceDisplay *ref = av_ref_displays_info_display(rdi, i);
+
+ ref->left_view_id = tdrdi->left_view_id[i];
+ ref->right_view_id = tdrdi->right_view_id[i];
+ ref->exponent_ref_display_width = tdrdi->exponent_ref_display_width[i];
+ ref->mantissa_ref_display_width = tdrdi->mantissa_ref_display_width[i];
+ ref->exponent_ref_viewing_distance = tdrdi->exponent_ref_viewing_distance[i];
+ ref->mantissa_ref_viewing_distance = tdrdi->mantissa_ref_viewing_distance[i];
+ ref->additional_shift_present_flag = tdrdi->additional_shift_present_flag[i];
+ ref->num_sample_shift = tdrdi->num_sample_shift[i];
+ }
+
+ ret = ff_frame_new_side_data_from_buf_ext(avctx, &avctx->decoded_side_data, &avctx->nb_decoded_side_data,
+ AV_FRAME_DATA_3D_REFERENCE_DISPLAYS, &buf);
+ if (ret < 0) {
+ av_buffer_unref(&buf);
+ return ret;
+ }
+ }
+
+ ret = ff_h2645_sei_to_context(avctx, &sei->common);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
static av_cold int hevc_decode_init(AVCodecContext *avctx)
{
HEVCContext *s = avctx->priv_data;
@@ -4044,7 +4097,7 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
return ret;
}
- ret = ff_h2645_sei_to_context(avctx, &s->sei.common);
+ ret = hevc_sei_to_context(avctx, &s->sei);
if (ret < 0)
return ret;
}
--
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".
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-02-05 21:36 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-31 14:00 [FFmpeg-devel] [PATCH 1/6] avutil: add an API to handle 3D Reference Displays Information James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 2/6] avutil/frame: add a 3D Reference Displays Information side data type James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 3/6] avcodec/packet: " James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 4/6] avformat/dump: add support for 3D Reference Displays Information side data James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 5/6] avfilter/vf_showinfo: " James Almer
2025-01-31 14:00 ` [FFmpeg-devel] [PATCH 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays " James Almer
2025-01-31 20:58 ` [FFmpeg-devel] [PATCH v2 " James Almer
2025-02-03 22:35 [FFmpeg-devel] [PATCH v2 1/6] avutil: add an API to handle Three Dimensional Reference Displays Information James Almer
2025-02-03 22:35 ` [FFmpeg-devel] [PATCH v2 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays side data James Almer
2025-02-05 21:07 ` Michael Niedermayer
2025-02-05 21:16 ` James Almer
2025-02-05 21:36 ` Michael Niedermayer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git