Commit 880e8382 authored by elupus's avatar elupus Committed by Michael Niedermayer

respect the maximum position mpegts_get_pcr is allowed to seek to

parent 2130d2f5
...@@ -1719,19 +1719,19 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, ...@@ -1719,19 +1719,19 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
uint8_t buf[TS_PACKET_SIZE]; uint8_t buf[TS_PACKET_SIZE];
int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid; int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid;
pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47;
for(;;) { while(pos < pos_limit) {
avio_seek(s->pb, pos, SEEK_SET); avio_seek(s->pb, pos, SEEK_SET);
if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
return AV_NOPTS_VALUE; return AV_NOPTS_VALUE;
if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
parse_pcr(&timestamp, &pcr_l, buf) == 0) { parse_pcr(&timestamp, &pcr_l, buf) == 0) {
break; *ppos = pos;
return timestamp;
} }
pos += ts->raw_packet_size; pos += ts->raw_packet_size;
} }
*ppos = pos;
return timestamp; return AV_NOPTS_VALUE;
} }
#ifdef USE_SYNCPOINT_SEARCH #ifdef USE_SYNCPOINT_SEARCH
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment