Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/9] avformat/iamf_writer: ensure each layer's channel layout contains all channels from the previous one
@ 2025-06-18  1:38 James Almer
  2025-06-18  1:38 ` [FFmpeg-devel] [PATCH 2/9] avformat/iamf_parse: try to retype the channel layout for ambisonics_mode == 0 James Almer
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: James Almer @ 2025-06-18  1:38 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/iamf_writer.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c
index 60a0990504..e34afb9a2c 100644
--- a/libavformat/iamf_writer.c
+++ b/libavformat/iamf_writer.c
@@ -245,7 +245,9 @@ int ff_iamf_add_audio_element(IAMFContext *iamf, const AVStreamGroup *stg, void
                 return AVERROR(EINVAL);
             }
         }
-    } else
+    } else {
+        AVBPrint bp;
+
         for (int j, i = 0; i < iamf_audio_element->nb_layers; i++) {
             const AVIAMFLayer *layer = iamf_audio_element->layers[i];
             for (j = 0; j < FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts); j++)
@@ -257,7 +259,6 @@ int ff_iamf_add_audio_element(IAMFContext *iamf, const AVStreamGroup *stg, void
                     if (!av_channel_layout_compare(&layer->ch_layout, &ff_iamf_expanded_scalable_ch_layouts[j]))
                         break;
                 if (j >= FF_ARRAY_ELEMS(ff_iamf_expanded_scalable_ch_layouts)) {
-                    AVBPrint bp;
                     av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
                     av_channel_layout_describe_bprint(&layer->ch_layout, &bp);
                     av_log(log_ctx, AV_LOG_ERROR, "Unsupported channel layout in Audio Element id %"PRId64
@@ -267,7 +268,26 @@ int ff_iamf_add_audio_element(IAMFContext *iamf, const AVStreamGroup *stg, void
                     return AVERROR(EINVAL);
                 }
             }
+
+            if (!i)
+                continue;
+
+            const AVIAMFLayer *prev_layer = iamf_audio_element->layers[i-1];
+            uint64_t prev_mask = av_channel_layout_subset(&prev_layer->ch_layout, UINT64_MAX);
+            if (av_channel_layout_subset(&layer->ch_layout, prev_mask) != prev_mask || (layer->ch_layout.nb_channels <=
+                                                                                        prev_layer->ch_layout.nb_channels)) {
+                av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
+                av_bprintf(&bp, "Channel layout \"");
+                av_channel_layout_describe_bprint(&layer->ch_layout, &bp);
+                av_bprintf(&bp, "\" can't follow channel layout \"");
+                av_channel_layout_describe_bprint(&prev_layer->ch_layout, &bp);
+                av_bprintf(&bp, "\" in Scalable Audio Element id %"PRId64, stg->id);
+                av_log(log_ctx, AV_LOG_ERROR, "%s\n", bp.str);
+                av_bprint_finalize(&bp, NULL);
+                return AVERROR(EINVAL);
+            }
         }
+    }
 
     for (int i = 0; i < iamf->nb_audio_elements; i++) {
         if (stg->id == iamf->audio_elements[i]->audio_element_id) {
-- 
2.50.0

_______________________________________________
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] 9+ messages in thread

end of thread, other threads:[~2025-06-18  1:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-18  1:38 [FFmpeg-devel] [PATCH 1/9] avformat/iamf_writer: ensure each layer's channel layout contains all channels from the previous one James Almer
2025-06-18  1:38 ` [FFmpeg-devel] [PATCH 2/9] avformat/iamf_parse: try to retype the channel layout for ambisonics_mode == 0 James Almer
2025-06-18  1:38 ` [FFmpeg-devel] [PATCH 3/9] tests/iamf: reorder muxed streams James Almer
2025-06-18  1:38 ` [FFmpeg-devel] [PATCH 4/9] tests/iamf: rename BACK to SIDE filterchain labels in the 5.1.4 iamf tests James Almer
2025-06-18  1:39 ` [FFmpeg-devel] [PATCH 5/9] avformat/iamf: fix setting channel layout for Scalable layers James Almer
2025-06-18  1:39 ` [FFmpeg-devel] [PATCH 6/9] avformat/iamf_writer: factorize out getting loudspeaker_layout values James Almer
2025-06-18  1:39 ` [FFmpeg-devel] [PATCH 7/9] avformat/iamf_writer: add extra constrains for Parameter Sets in Audio Elements James Almer
2025-06-18  1:39 ` [FFmpeg-devel] [PATCH 8/9] avformat/iamf_writer: reindent after previous commit James Almer
2025-06-18  1:39 ` [FFmpeg-devel] [PATCH 9/9] avformat/iamf_writer: use named constants in more places James Almer

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