Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: James Almer <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] [release/7.1] backport some IAMF fixes (PR #21331)
Date: Tue, 30 Dec 2025 23:26:08 -0000
Message-ID: <176713716882.25.5226893501759429641@4457048688e7> (raw)

PR #21331 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21331
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21331.patch


>From bdfaec89febaabaf05cb4d5df72396b548ce6178 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Sat, 27 Dec 2025 17:08:30 -0300
Subject: [PATCH 1/3] avformat/iamf_parse: fix setting denominator in
 AVIAMFLayer.demixing_matrix

The format of demixing_matrix is Q15 fixed point values.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 03a981445ee89a567e5a98ec88cbbbb8d3e3af72)
---
 libavformat/iamf_parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 8fe7e1bb0e..1050219591 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -487,7 +487,7 @@ static int ambisonics_config(void *s, AVIOContext *pb,
             return AVERROR(ENOMEM);
 
         for (int i = 0; i < demixing_matrix_size; i++)
-            layer->demixing_matrix[i] = av_make_q(sign_extend(avio_rb16(pb), 16), 1 << 8);
+            layer->demixing_matrix[i] = av_make_q(sign_extend(avio_rb16(pb), 16), 1 << 15);
 
         for (int i = 0; i < substream_count; i++) {
             IAMFSubStream *substream = &audio_element->substreams[i];
-- 
2.49.1


>From c0272bf65474a636262e59625da4c918bbf8e19a Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Sat, 27 Dec 2025 18:06:32 -0300
Subject: [PATCH 2/3] avformat/iamf_writer: fix writting some ambisonics fields
 in Audio Elements

The fields are defined as 8 bit long unsigned ints. Fortunately, writing most sane values
as leb is equivalent, which is why no tests are affected.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 21ff60d2cf7dfe00400ffef6a8843736f4cf9a2f)
---
 libavformat/iamf_writer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c
index 27926f859a..d13bd8fecc 100644
--- a/libavformat/iamf_writer.c
+++ b/libavformat/iamf_writer.c
@@ -586,8 +586,8 @@ static int ambisonics_config(const IAMFAudioElement *audio_element,
     const AVIAMFLayer *layer = element->layers[0];
 
     ffio_write_leb(dyn_bc, 0); // ambisonics_mode
-    ffio_write_leb(dyn_bc, layer->ch_layout.nb_channels); // output_channel_count
-    ffio_write_leb(dyn_bc, audio_element->nb_substreams); // substream_count
+    avio_w8(dyn_bc, layer->ch_layout.nb_channels); // output_channel_count
+    avio_w8(dyn_bc, audio_element->nb_substreams); // substream_count
 
     if (layer->ch_layout.order == AV_CHANNEL_ORDER_AMBISONIC)
         for (int i = 0; i < layer->ch_layout.nb_channels; i++)
-- 
2.49.1


>From 40b336e65043cbde6136ed338a18e3941dd0e6da Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Sat, 27 Dec 2025 19:11:07 -0300
Subject: [PATCH 3/3] avformat/iamf_writer: check that stream count is
 consistent for ambisonic Audio Elements

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit a0fc454871c116d5bd1bbec5138dfe3ffcb1f11d)
---
 libavformat/iamf_writer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c
index d13bd8fecc..61d69373d9 100644
--- a/libavformat/iamf_writer.c
+++ b/libavformat/iamf_writer.c
@@ -583,8 +583,12 @@ static int ambisonics_config(const IAMFAudioElement *audio_element,
                              AVIOContext *dyn_bc)
 {
     const AVIAMFAudioElement *element = audio_element->celement;
+    const IAMFLayer *ilayer = &audio_element->layers[0];
     const AVIAMFLayer *layer = element->layers[0];
 
+    if (audio_element->nb_substreams != ilayer->substream_count)
+        return AVERROR(EINVAL);
+
     ffio_write_leb(dyn_bc, 0); // ambisonics_mode
     avio_w8(dyn_bc, layer->ch_layout.nb_channels); // output_channel_count
     avio_w8(dyn_bc, audio_element->nb_substreams); // substream_count
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2025-12-30 23:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=176713716882.25.5226893501759429641@4457048688e7 \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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