* [FFmpeg-devel] [PATCH v2 2/6] avutil/frame: add a 3D Reference Displays Information side data type
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-03 22:35 ` [FFmpeg-devel] [PATCH v2 3/6] avfilter/vf_showinfo: add support for 3D Reference Displays Information side data James Almer
` (3 subsequent siblings)
4 siblings, 0 replies; 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>
---
No changes since last version.
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 v2 3/6] avfilter/vf_showinfo: add support for 3D Reference Displays Information 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 ` [FFmpeg-devel] [PATCH v2 2/6] avutil/frame: add a 3D Reference Displays Information side data type James Almer
@ 2025-02-03 22:35 ` James Almer
2025-02-03 22:35 ` [FFmpeg-devel] [PATCH 4/6] avcodec/hevc/sei: ensure num_ref_displays is not set unless the SEI message is valid James Almer
` (2 subsequent siblings)
4 siblings, 0 replies; 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>
---
No changes since last version.
libavfilter/vf_showinfo.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 8109ca7fce..29700f5d68 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/ref_displays_info.h"
#include "libavutil/timestamp.h"
#include "libavutil/timecode.h"
#include "libavutil/mastering_display_metadata.h"
@@ -152,6 +153,13 @@ static void dump_roi(AVFilterContext *ctx, const AVFrameSideData *sd)
}
}
+static void dump_ref_displays_info(AVFilterContext *ctx, const AVFrameSideData *sd)
+{
+ const AV3DReferenceDisplaysInfo *rdi = (const AV3DReferenceDisplaysInfo *)sd->data;
+
+ av_log(ctx, AV_LOG_INFO, "number of reference displays: %u", rdi->num_ref_displays);
+}
+
static void dump_detection_bbox(AVFilterContext *ctx, const AVFrameSideData *sd)
{
int nb_bboxes;
@@ -860,6 +868,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_ref_displays_info(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 4/6] avcodec/hevc/sei: ensure num_ref_displays is not set unless the SEI message is valid
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 2/6] avutil/frame: add a 3D Reference Displays Information side data type James Almer
2025-02-03 22:35 ` [FFmpeg-devel] [PATCH v2 3/6] avfilter/vf_showinfo: add support for 3D Reference Displays Information side data James Almer
@ 2025-02-03 22:35 ` James Almer
2025-02-03 22:35 ` [FFmpeg-devel] [PATCH 5/6] avcodec/hevc/sei: dynamically allocate 3D Reference Displays Information SEI messages James Almer
2025-02-03 22:35 ` [FFmpeg-devel] [PATCH v2 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays side data James Almer
4 siblings, 0 replies; 11+ messages in thread
From: James Almer @ 2025-02-03 22:35 UTC (permalink / raw)
To: ffmpeg-devel
This field can be used the same way "present" is used for other message types.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/hevc/sei.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
index e11a33773c..8793d86fdc 100644
--- a/libavcodec/hevc/sei.c
+++ b/libavcodec/hevc/sei.c
@@ -152,6 +152,8 @@ static int decode_nal_sei_timecode(HEVCSEITimeCode *s, GetBitContext *gb)
static int decode_nal_sei_3d_reference_displays_info(HEVCSEITDRDI *s, GetBitContext *gb)
{
+ unsigned int num_ref_displays;
+
s->prec_ref_display_width = get_ue_golomb(gb);
if (s->prec_ref_display_width > 31)
return AVERROR_INVALIDDATA;
@@ -161,12 +163,12 @@ static int decode_nal_sei_3d_reference_displays_info(HEVCSEITDRDI *s, GetBitCont
if (s->prec_ref_viewing_dist > 31)
return AVERROR_INVALIDDATA;
}
- s->num_ref_displays = get_ue_golomb(gb);
- if (s->num_ref_displays > 31)
+ num_ref_displays = get_ue_golomb(gb);
+ if (num_ref_displays > 31)
return AVERROR_INVALIDDATA;
- s->num_ref_displays += 1;
+ num_ref_displays += 1;
- for (int i = 0; i < s->num_ref_displays; i++) {
+ for (int i = 0; i < num_ref_displays; i++) {
int length;
s->left_view_id[i] = get_ue_golomb(gb);
s->right_view_id[i] = get_ue_golomb(gb);
@@ -199,6 +201,7 @@ static int decode_nal_sei_3d_reference_displays_info(HEVCSEITDRDI *s, GetBitCont
}
}
s->three_dimensional_reference_displays_extension_flag = get_bits1(gb);
+ s->num_ref_displays = num_ref_displays;
return 0;
}
--
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] avcodec/hevc/sei: dynamically allocate 3D Reference Displays Information SEI messages
2025-02-03 22:35 [FFmpeg-devel] [PATCH v2 1/6] avutil: add an API to handle Three Dimensional Reference Displays Information James Almer
` (2 preceding siblings ...)
2025-02-03 22:35 ` [FFmpeg-devel] [PATCH 4/6] avcodec/hevc/sei: ensure num_ref_displays is not set unless the SEI message is valid James Almer
@ 2025-02-03 22:35 ` James Almer
2025-02-06 1:56 ` Michael Niedermayer
2025-02-03 22:35 ` [FFmpeg-devel] [PATCH v2 6/6] avcodec/hevc/hevcdec: export 3D Reference Displays side data James Almer
4 siblings, 1 reply; 11+ messages in thread
From: James Almer @ 2025-02-03 22:35 UTC (permalink / raw)
To: ffmpeg-devel
Considerably reduces the size of HEVCSEI and eliminates data copy between threads.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/hevc/hevcdec.c | 4 ++--
libavcodec/hevc/refs.c | 4 ++--
libavcodec/hevc/sei.c | 6 +++++-
libavcodec/hevc/sei.h | 6 +++++-
4 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index e9c045f7a1..f9ff22dbac 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -429,7 +429,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
static int export_multilayer(HEVCContext *s, const HEVCVPS *vps)
{
- const HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
+ const HEVCSEITDRDI *tdrdi = s->sei.tdrdi;
av_freep(&s->view_ids_available);
s->nb_view_ids_available = 0;
@@ -4015,7 +4015,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
s->sei.common.frame_packing = s0->sei.common.frame_packing;
s->sei.common.display_orientation = s0->sei.common.display_orientation;
s->sei.common.alternative_transfer = s0->sei.common.alternative_transfer;
- s->sei.tdrdi = s0->sei.tdrdi;
+ av_refstruct_replace(&s->sei.tdrdi, s0->sei.tdrdi);
return 0;
}
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index dd7f7f95a8..d1d2f27a9b 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -104,7 +104,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l)
// add view ID side data if it's nontrivial
if (vps->nb_layers > 1 || view_id) {
- HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
+ HEVCSEITDRDI *tdrdi = s->sei.tdrdi;
AVFrameSideData *sd = av_frame_side_data_new(&frame->f->side_data,
&frame->f->nb_side_data,
AV_FRAME_DATA_VIEW_ID,
@@ -113,7 +113,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l)
goto fail;
*(int*)sd->data = view_id;
- if (tdrdi->num_ref_displays) {
+ if (tdrdi && tdrdi->num_ref_displays) {
AVStereo3D *stereo_3d;
stereo_3d = av_stereo3d_create_side_data(frame->f);
diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
index 8793d86fdc..588516043b 100644
--- a/libavcodec/hevc/sei.c
+++ b/libavcodec/hevc/sei.c
@@ -220,7 +220,11 @@ static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte,
case SEI_TYPE_TIME_CODE:
return decode_nal_sei_timecode(&s->timecode, gb);
case SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
- return decode_nal_sei_3d_reference_displays_info(&s->tdrdi, gb);
+ av_refstruct_unref(&s->tdrdi);
+ s->tdrdi = av_refstruct_allocz(sizeof(*s->tdrdi));
+ if (!s->tdrdi)
+ return AVERROR(ENOMEM);
+ return decode_nal_sei_3d_reference_displays_info(s->tdrdi, gb);
default: {
int ret = ff_h2645_sei_message_decode(&s->common, type, AV_CODEC_ID_HEVC,
gb, gbyte, logctx);
diff --git a/libavcodec/hevc/sei.h b/libavcodec/hevc/sei.h
index ee640003bc..42ee6a20b7 100644
--- a/libavcodec/hevc/sei.h
+++ b/libavcodec/hevc/sei.h
@@ -24,6 +24,7 @@
#include <stdint.h>
#include "libavutil/buffer.h"
+#include "libavutil/refstruct.h"
#include "libavcodec/get_bits.h"
#include "libavcodec/h2645_sei.h"
@@ -101,7 +102,9 @@ typedef struct HEVCSEI {
HEVCSEIPictureTiming picture_timing;
int active_seq_parameter_set_id;
HEVCSEITimeCode timecode;
- HEVCSEITDRDI tdrdi;
+
+ // Dynamic allocations due to large size.
+ HEVCSEITDRDI *tdrdi;
} HEVCSEI;
struct HEVCParamSets;
@@ -118,6 +121,7 @@ int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
*/
static inline void ff_hevc_reset_sei(HEVCSEI *sei)
{
+ av_refstruct_unref(&sei->tdrdi);
ff_h2645_sei_reset(&sei->common);
}
--
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 5/6] avcodec/hevc/sei: dynamically allocate 3D Reference Displays Information SEI messages
2025-02-03 22:35 ` [FFmpeg-devel] [PATCH 5/6] avcodec/hevc/sei: dynamically allocate 3D Reference Displays Information SEI messages James Almer
@ 2025-02-06 1:56 ` Michael Niedermayer
2025-02-06 2:50 ` [FFmpeg-devel] [PATCH v2 " James Almer
0 siblings, 1 reply; 11+ messages in thread
From: Michael Niedermayer @ 2025-02-06 1:56 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 1861 bytes --]
On Mon, Feb 03, 2025 at 07:35:45PM -0300, James Almer wrote:
> Considerably reduces the size of HEVCSEI and eliminates data copy between threads.
>
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> libavcodec/hevc/hevcdec.c | 4 ++--
> libavcodec/hevc/refs.c | 4 ++--
> libavcodec/hevc/sei.c | 6 +++++-
> libavcodec/hevc/sei.h | 6 +++++-
> 4 files changed, 14 insertions(+), 6 deletions(-)
this segfaults here, will probably retest tomorrow without other patches
but i removed the ones you pointed to
[vist#0:0/hevc @ 0x12015580] [dec:hevc @ 0x1201b240] View with index 1 requested, but only 1 views available in current video sequence (more views may or may not be available in later sequences).
==307141== Thread 6 dec0:0:hevc:
==307141== Invalid read of size 1
==307141== at 0x93F313: export_multilayer (in ffmpeg/ffmpeg_g)
==307141== by 0x94B51F: hevc_receive_frame (in ffmpeg/ffmpeg_g)
==307141== by 0x8798AA: ff_decode_receive_frame_internal (in ffmpeg/ffmpeg_g)
==307141== by 0x879F54: decode_receive_frame_internal (in ffmpeg/ffmpeg_g)
==307141== by 0x87A229: avcodec_send_packet (in ffmpeg/ffmpeg_g)
==307141== by 0x2FBE13: decoder_thread (in ffmpeg/ffmpeg_g)
==307141== by 0x31D6AE: task_wrapper (in ffmpeg/ffmpeg_g)
==307141== by 0x4A06608: start_thread (pthread_create.c:477)
==307141== by 0x772A352: clone (clone.S:95)
==307141== Address 0x3 is not stack'd, malloc'd or (recently) free'd
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Any man who breaks a law that conscience tells him is unjust and willingly
accepts the penalty by staying in jail in order to arouse the conscience of
the community on the injustice of the law is at that moment expressing the
very highest respect for law. - Martin Luther King Jr
[-- 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 5/6] avcodec/hevc/sei: dynamically allocate 3D Reference Displays Information SEI messages
2025-02-06 1:56 ` Michael Niedermayer
@ 2025-02-06 2:50 ` James Almer
0 siblings, 0 replies; 11+ messages in thread
From: James Almer @ 2025-02-06 2:50 UTC (permalink / raw)
To: ffmpeg-devel
Considerably reduces the size of HEVCSEI.
Signed-off-by: James Almer <jamrial@gmail.com>
---
Fixed segfaults.
libavcodec/hevc/hevcdec.c | 10 +++++-----
libavcodec/hevc/refs.c | 4 ++--
libavcodec/hevc/sei.c | 6 +++++-
libavcodec/hevc/sei.h | 6 +++++-
4 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index e9c045f7a1..881538fb91 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -429,7 +429,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
static int export_multilayer(HEVCContext *s, const HEVCVPS *vps)
{
- const HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
+ const HEVCSEITDRDI *tdrdi = s->sei.tdrdi;
av_freep(&s->view_ids_available);
s->nb_view_ids_available = 0;
@@ -444,7 +444,7 @@ static int export_multilayer(HEVCContext *s, const HEVCVPS *vps)
if (!s->view_ids_available)
return AVERROR(ENOMEM);
- if (tdrdi->num_ref_displays) {
+ if (tdrdi && tdrdi->num_ref_displays) {
s->view_pos_available = av_calloc(vps->nb_layers, sizeof(*s->view_pos_available));
if (!s->view_pos_available)
return AVERROR(ENOMEM);
@@ -454,9 +454,9 @@ static int export_multilayer(HEVCContext *s, const HEVCVPS *vps)
s->view_ids_available[i] = vps->view_id[i];
if (s->view_pos_available) {
- s->view_pos_available[i] = vps->view_id[i] == tdrdi->left_view_id[0] ?
+ s->view_pos_available[i] = tdrdi && (vps->view_id[i] == tdrdi->left_view_id[0]) ?
AV_STEREO3D_VIEW_LEFT :
- vps->view_id[i] == tdrdi->right_view_id[0] ?
+ tdrdi && (vps->view_id[i] == tdrdi->right_view_id[0]) ?
AV_STEREO3D_VIEW_RIGHT : AV_STEREO3D_VIEW_UNSPEC;
}
}
@@ -4015,7 +4015,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
s->sei.common.frame_packing = s0->sei.common.frame_packing;
s->sei.common.display_orientation = s0->sei.common.display_orientation;
s->sei.common.alternative_transfer = s0->sei.common.alternative_transfer;
- s->sei.tdrdi = s0->sei.tdrdi;
+ av_refstruct_replace(&s->sei.tdrdi, s0->sei.tdrdi);
return 0;
}
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index dd7f7f95a8..d1d2f27a9b 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -104,7 +104,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l)
// add view ID side data if it's nontrivial
if (vps->nb_layers > 1 || view_id) {
- HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
+ HEVCSEITDRDI *tdrdi = s->sei.tdrdi;
AVFrameSideData *sd = av_frame_side_data_new(&frame->f->side_data,
&frame->f->nb_side_data,
AV_FRAME_DATA_VIEW_ID,
@@ -113,7 +113,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l)
goto fail;
*(int*)sd->data = view_id;
- if (tdrdi->num_ref_displays) {
+ if (tdrdi && tdrdi->num_ref_displays) {
AVStereo3D *stereo_3d;
stereo_3d = av_stereo3d_create_side_data(frame->f);
diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
index 8793d86fdc..588516043b 100644
--- a/libavcodec/hevc/sei.c
+++ b/libavcodec/hevc/sei.c
@@ -220,7 +220,11 @@ static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte,
case SEI_TYPE_TIME_CODE:
return decode_nal_sei_timecode(&s->timecode, gb);
case SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
- return decode_nal_sei_3d_reference_displays_info(&s->tdrdi, gb);
+ av_refstruct_unref(&s->tdrdi);
+ s->tdrdi = av_refstruct_allocz(sizeof(*s->tdrdi));
+ if (!s->tdrdi)
+ return AVERROR(ENOMEM);
+ return decode_nal_sei_3d_reference_displays_info(s->tdrdi, gb);
default: {
int ret = ff_h2645_sei_message_decode(&s->common, type, AV_CODEC_ID_HEVC,
gb, gbyte, logctx);
diff --git a/libavcodec/hevc/sei.h b/libavcodec/hevc/sei.h
index ee640003bc..42ee6a20b7 100644
--- a/libavcodec/hevc/sei.h
+++ b/libavcodec/hevc/sei.h
@@ -24,6 +24,7 @@
#include <stdint.h>
#include "libavutil/buffer.h"
+#include "libavutil/refstruct.h"
#include "libavcodec/get_bits.h"
#include "libavcodec/h2645_sei.h"
@@ -101,7 +102,9 @@ typedef struct HEVCSEI {
HEVCSEIPictureTiming picture_timing;
int active_seq_parameter_set_id;
HEVCSEITimeCode timecode;
- HEVCSEITDRDI tdrdi;
+
+ // Dynamic allocations due to large size.
+ HEVCSEITDRDI *tdrdi;
} HEVCSEI;
struct HEVCParamSets;
@@ -118,6 +121,7 @@ int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
*/
static inline void ff_hevc_reset_sei(HEVCSEI *sei)
{
+ av_refstruct_unref(&sei->tdrdi);
ff_h2645_sei_reset(&sei->common);
}
--
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-02-03 22:35 [FFmpeg-devel] [PATCH v2 1/6] avutil: add an API to handle Three Dimensional Reference Displays Information James Almer
` (3 preceding siblings ...)
2025-02-03 22:35 ` [FFmpeg-devel] [PATCH 5/6] avcodec/hevc/sei: dynamically allocate 3D Reference Displays Information SEI messages James Almer
@ 2025-02-03 22:35 ` James Almer
2025-02-05 21:07 ` Michael Niedermayer
4 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
* 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
* 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-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