avformat/mov: fix cases where we discard iamf packets from enabled streams release/7.0
authorJames Almer <jamrial@gmail.com>
Fri, 27 Feb 2026 13:41:31 +0000 (10:41 -0300)
committerJames Almer <jamrial@gmail.com>
Fri, 27 Feb 2026 15:27:55 +0000 (12:27 -0300)
Given the entire iamf struct is inside a single Track, if the first iamf stream
(which is the one sharing the index and id from the Track) was to be disabled,
then packets from every iamf stream would be discarded.
Fix this by actually going through the entire iamf Sample and discarding those
from the disabled streams only.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 16ee3d8d99a2f2e83a2559e958e19ede813b29f8)

libavformat/iamf_reader.c
libavformat/mov.c
libavformat/version.h

index 6b6360d3146e6ed48ed6340230eae32c1a9e7ccd..d83bd1a0063bae25ee8f87e6740268ece15a5599 100644 (file)
@@ -94,6 +94,9 @@ static int audio_frame_obu(AVFormatContext *s, const IAMFDemuxContext *c,
         memcpy(side_data, c->recon, c->recon_size);
     }
 
+    if (st->discard == AVDISCARD_ALL)
+        pkt->flags |= AV_PKT_FLAG_DISCARD;
+
     pkt->stream_index = st->index;
     return 0;
 }
index b638ca06544339c89e22bf3f43b58d67b3d89be4..1dd8bef4e4f97002f46cb13daa2ee55c64b5c94f 100644 (file)
@@ -10114,7 +10114,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
         sample->size = FFMIN(sample->size, (mov->next_root_atom - sample->pos));
     }
 
-    if (st->discard != AVDISCARD_ALL) {
+    if (st->discard != AVDISCARD_ALL || sc->iamf) {
         int64_t ret64 = avio_seek(sc->pb, sample->pos, SEEK_SET);
         if (ret64 != sample->pos) {
             av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n",
@@ -10149,6 +10149,12 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
                     return ret;
                 }
                 size -= ret;
+
+                if (pkt->flags & AV_PKT_FLAG_DISCARD) {
+                    av_packet_unref(pkt);
+                    ret = 0;
+                    continue;
+                }
                 pkt->pts = pts; pkt->dts = dts;
                 pkt->pos = pos; pkt->flags |= flags;
                 pkt->duration = duration;
index b32ddb36171e59e77fc6e197a9951740fbb9eb8d..b3c03a373b83bd8152b03c77bc593397782f0ebd 100644 (file)
@@ -32,7 +32,7 @@
 #include "version_major.h"
 
 #define LIBAVFORMAT_VERSION_MINOR   1
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MICRO 102
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \