[PR] [release/9.0] avformat/iamf_writer: don't discard skip samples signaled through side data for Opus (PR #24299)

ffmpeg-devel via ffmpeg-devel <[email protected]>
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <[email protected]>
PR #24299 opened by ffmpeg-devel
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24299
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24299.patch

**Backport:** https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24286

If it's set, then it should be used.

Fixes issue #24285.


>From e47273f4d9227152dcbf543cebaf9e2430ddbcc4 Mon Sep 17 00:00:00 2001
From: James Almer <[email protected]>
Date: Wed, 26 Aug 2026 20:13:51 -0300
Subject: [PATCH] avformat/iamf_writer: don't discard skip samples signaled
 through side data for Opus

If it's set, then it should be used.
Fixes issue #24285.

Signed-off-by: James Almer <[email protected]>
(cherry picked from commit 3acec0a1af2dda0a0838689b8b8649e7deb080a0)
---
 libavformat/iamf_writer.c                       | 7 ++++---
 tests/ref/fate/iamf-5_1-copy                    | 4 ++--
 tests/ref/fate/iamf-ambisonic_1-projection-copy | 4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c
index 3014f0daa1..15f83b85b0 100644
--- a/libavformat/iamf_writer.c
+++ b/libavformat/iamf_writer.c
@@ -1274,9 +1274,10 @@ int ff_iamf_write_audio_frame(const IAMFContext *iamf, AVIOContext *pb,
 
     if (codec_config->codec_id == AV_CODEC_ID_OPUS) {
         // IAMF's num_samples_to_trim_at_start is the same as Opus's pre-skip.
-        skip_samples = pkt->dts < 0
-            ? av_rescale(-pkt->dts, 48000, pkt->time_base.den)
-            : 0;
+        if (!skip_samples)
+            skip_samples = pkt->dts < 0
+                ? av_rescale(-pkt->dts, 48000, pkt->time_base.den)
+                : 0;
         discard_padding = av_rescale(discard_padding, 48000, pkt->time_base.den);
     }
 
diff --git a/tests/ref/fate/iamf-5_1-copy b/tests/ref/fate/iamf-5_1-copy
index d487ea6d63..676c6d22ba 100644
--- a/tests/ref/fate/iamf-5_1-copy
+++ b/tests/ref/fate/iamf-5_1-copy
@@ -1,5 +1,5 @@
-f9315a1ef9a95f590711516a6f88b767 *tests/data/fate/iamf-5_1-copy.iamf
-20190 tests/data/fate/iamf-5_1-copy.iamf
+705719e33dbaff262a12cc5bea412f24 *tests/data/fate/iamf-5_1-copy.iamf
+20202 tests/data/fate/iamf-5_1-copy.iamf
 #extradata 0:       19, 0x3a0e0490
 #extradata 1:       19, 0x3a0e0490
 #extradata 2:       19, 0x3a04048f
diff --git a/tests/ref/fate/iamf-ambisonic_1-projection-copy b/tests/ref/fate/iamf-ambisonic_1-projection-copy
index bdf12c5e10..fad4902971 100644
--- a/tests/ref/fate/iamf-ambisonic_1-projection-copy
+++ b/tests/ref/fate/iamf-ambisonic_1-projection-copy
@@ -1,5 +1,5 @@
-9fd745ba5bca8b42b6b80d1c5ecae507 *tests/data/fate/iamf-ambisonic_1-projection-copy.iamf
-118707 tests/data/fate/iamf-ambisonic_1-projection-copy.iamf
+5ac799e55c8893fbc5455825dc83c5f2 *tests/data/fate/iamf-ambisonic_1-projection-copy.iamf
+118720 tests/data/fate/iamf-ambisonic_1-projection-copy.iamf
 #extradata 0:       19, 0x3a04048f
 #extradata 1:       19, 0x3a04048f
 #extradata 2:       19, 0x3a04048f
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.