提交 5fd63f3c 编写于 作者: M Michael Niedermayer

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
上级 a9600003
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册