From: Bibin Baby <[email protected]>

read_data_continuous() hands the EXT-X-MAP initialization section to the
inner demuxer in chunks of at most buf_size bytes, tracking progress in
init_sec_buf_read_offset. The copy, however, always started at the
beginning of init_sec_buf, so every chunk after the first repeated the
same leading bytes and the rest of the init section was never delivered.

The byte count is right and only the content is wrong, so the inner
demuxer reaches the segment data at the correct position but parses
garbage for everything past the first buf_size bytes of the init
section. For fMP4 the usual outcome is that moov is never seen:

    [mov,mp4,m4a,3gp,3g2,mj2 @ ...] moov atom not found

Any initialization section larger than the playlist IO buffer
(INITIAL_BUFFER_SIZE, 32 KiB) is affected, whether from a large moov or
from a sizable top-level box ahead of it. The same bytes read through
file:, pipe: or the concat protocol demux fine.

Resume the copy at init_sec_buf_read_offset. This is a no-op whenever
the init section fits in a single read, which is why it went unnoticed
since EXT-X-MAP support was added in 9099079488.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/24603
Signed-off-by: Bibin Baby <[email protected]>
---
 libavformat/hls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index daca226f67..b6a89f3d09 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1848,7 +1848,7 @@ restart:
     if (v->init_sec_buf_read_offset < v->init_sec_data_len) {
         /* Push init section out first before first actual segment */
         int copy_size = FFMIN(v->init_sec_data_len - 
v->init_sec_buf_read_offset, buf_size);
-        memcpy(buf, v->init_sec_buf, copy_size);
+        memcpy(buf, v->init_sec_buf + v->init_sec_buf_read_offset, copy_size);
         v->init_sec_buf_read_offset += copy_size;
         return copy_size;
     }
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to