Commit 0b4b1e00 authored by michael's avatar michael

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".


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@12932 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 90969cd2
...@@ -90,6 +90,9 @@ struct MpegTSContext { ...@@ -90,6 +90,9 @@ struct MpegTSContext {
AVFormatContext *stream; AVFormatContext *stream;
/** raw packet size, including FEC if present */ /** raw packet size, including FEC if present */
int raw_packet_size; int raw_packet_size;
int pos47;
/** if true, all pids are analyzed to find streams */ /** if true, all pids are analyzed to find streams */
int auto_guess; int auto_guess;
...@@ -1046,6 +1049,8 @@ static void handle_packet(MpegTSContext *ts, const uint8_t *packet) ...@@ -1046,6 +1049,8 @@ static void handle_packet(MpegTSContext *ts, const uint8_t *packet)
if (p >= p_end) if (p >= p_end)
return; return;
ts->pos47= url_ftell(ts->stream->pb) % ts->raw_packet_size;
if (tss->type == MPEGTS_SECTION) { if (tss->type == MPEGTS_SECTION) {
if (is_start) { if (is_start) {
/* pointer field present */ /* pointer field present */
...@@ -1379,7 +1384,7 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, ...@@ -1379,7 +1384,7 @@ 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;
const int find_next= 1; 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) { if (find_next) {
for(;;) { for(;;) {
url_fseek(s->pb, pos, SEEK_SET); url_fseek(s->pb, pos, SEEK_SET);
......
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