Skip to content

Commit

Permalink
Demuxer: Fixes HLS seek patch (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuRGeoNix committed Jan 10, 2025
1 parent 69da337 commit 30a0711
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10416,15 +10416,15 @@ static int mov_switch_root(AVFormatContext *s, int64_t target, int index)

if (index >= 0 && index < mov->frag_index.nb_items)
target = mov->frag_index.item[index].moof_offset;
if (avio_seek(s->pb, target, SEEK_SET) != target) {
if (target >= 0 && avio_seek(s->pb, target, SEEK_SET) != target) {
av_log(mov->fc, AV_LOG_ERROR, "root atom offset 0x%"PRIx64": partial file\n", target);
return AVERROR_INVALIDDATA;
}

mov->next_root_atom = 0;
if (index < 0 || index >= mov->frag_index.nb_items)
if ((index < 0 && target >= 0) || index >= mov->frag_index.nb_items)
index = search_frag_moof_offset(&mov->frag_index, target);
if (index < mov->frag_index.nb_items &&
if (index >= 0 && index < mov->frag_index.nb_items &&
mov->frag_index.item[index].moof_offset == target) {
if (index + 1 < mov->frag_index.nb_items)
mov->next_root_atom = mov->frag_index.item[index + 1].moof_offset;
Expand Down Expand Up @@ -10987,4 +10987,4 @@ const FFInputFormat ff_mov_demuxer = {
.read_packet = mov_read_packet,
.read_close = mov_read_close,
.read_seek = mov_read_seek,
};
};

0 comments on commit 30a0711

Please sign in to comment.