Commit 472adcd154 for ffmpeg
commit 472adcd154f23740820b3ab0b0f0f5e051dcc8a6
Author: Kacper Michajłow <kasper93@gmail.com>
Date: Wed Oct 28 02:09:24 2026 +0100
avformat/dashdec: seek the input only of a whole file
seek_data() moved the input of any Representation without an
initialization section to the positions of its demuxer. The input of a
byte range is opened with the "offset" option, from which the http and
libcurl protocols count the positions while they seek to positions in
the file, so a seek that reached the protocol landed as many bytes
before the target as the range starts at and returned the wrong data.
Seek the input only when it is a whole file, and fail the seek
otherwise.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 9aacf9b7f7..f0ee580023 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1938,10 +1938,18 @@ static int update_init_section(struct representation *pls)
return 0;
}
+static int is_whole_file(const struct representation *pls)
+{
+ return pls->cur_seg && !pls->init_sec_data_len &&
+ !pls->cur_seg->url_offset && pls->cur_seg->size < 0;
+}
+
static int64_t seek_data(void *opaque, int64_t offset, int whence)
{
struct representation *v = opaque;
- if (v->n_fragments && !v->init_sec_data_len) {
+ /* Avoid seeking for non-whole files, where an "offset" does not correspond
+ * to a position in the input. AVIO sets 0 position at "offset" of the input. */
+ if (is_whole_file(v)) {
return avio_seek(v->input, offset, whence);
}