diff options
author | Michael Niedermayer | 2008-04-23 21:16:25 +0000 |
---|---|---|
committer | Michael Niedermayer | 2008-04-23 21:16:25 +0000 |
commit | 5fd63f3c3b316a348bc76353b2b2956d5182135d (patch) | |
tree | e5eaf9ba7bfeb1183888d81891f2506e527fa250 /libavformat/mpegts.c | |
parent | a960000304dedcfc89e62ab09202a535d24b5cca (diff) |
Ensure that the timestamp reading code used for seeking chooses a position
which is a multiple of the packet size from the last packet start instead
of the file start. This fixes some seek issues with randomly cut ts files
and the mysterious "4 byte PCR somehing MTS something bug".
Originally committed as revision 12932 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mpegts.c')
-rw-r--r-- | libavformat/mpegts.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 85586422d4..bd86fafea0 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -90,6 +90,9 @@ struct MpegTSContext { AVFormatContext *stream; /** raw packet size, including FEC if present */ int raw_packet_size; + + int pos47; + /** if true, all pids are analyzed to find streams */ int auto_guess; @@ -1046,6 +1049,8 @@ static void handle_packet(MpegTSContext *ts, const uint8_t *packet) if (p >= p_end) return; + ts->pos47= url_ftell(ts->stream->pb) % ts->raw_packet_size; + if (tss->type == MPEGTS_SECTION) { if (is_start) { /* pointer field present */ @@ -1379,7 +1384,7 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, uint8_t buf[TS_PACKET_SIZE]; int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid; const int find_next= 1; - pos = ((*ppos + ts->raw_packet_size - 1) / ts->raw_packet_size) * ts->raw_packet_size; + pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; if (find_next) { for(;;) { url_fseek(s->pb, pos, SEEK_SET); |