Mercurial > libavformat.hg
comparison utils.c @ 2043:3446000701c4 libavformat
Fix reading PTSs and DTSs in libavformat, by reverting r8465.
Such commit introduced some regressions (see the "Possible bug in reading
PTS/DTS" and "[BUG] no video transcoding" threads on ffmpeg-devel).
author | lucabe |
---|---|
date | Thu, 26 Apr 2007 10:49:48 +0000 |
parents | 964dff992628 |
children | 4611fce2f394 |
comparison
equal
deleted
inserted
replaced
2042:27f583883ab4 | 2043:3446000701c4 |
---|---|
1481 AVStream *st; | 1481 AVStream *st; |
1482 int read_size, i, ret; | 1482 int read_size, i, ret; |
1483 int64_t end_time; | 1483 int64_t end_time; |
1484 int64_t filesize, offset, duration; | 1484 int64_t filesize, offset, duration; |
1485 | 1485 |
1486 av_read_frame_flush(ic); | 1486 /* free previous packet */ |
1487 if (ic->cur_st && ic->cur_st->parser) | |
1488 av_free_packet(&ic->cur_pkt); | |
1489 ic->cur_st = NULL; | |
1490 | |
1491 /* flush packet queue */ | |
1492 flush_packet_queue(ic); | |
1493 | |
1494 for(i=0;i<ic->nb_streams;i++) { | |
1495 st = ic->streams[i]; | |
1496 if (st->parser) { | |
1497 av_parser_close(st->parser); | |
1498 st->parser= NULL; | |
1499 } | |
1500 } | |
1487 | 1501 |
1488 /* we read the first packets to get the first PTS (not fully | 1502 /* we read the first packets to get the first PTS (not fully |
1489 accurate, but it is enough now) */ | 1503 accurate, but it is enough now) */ |
1490 url_fseek(&ic->pb, 0, SEEK_SET); | 1504 url_fseek(&ic->pb, 0, SEEK_SET); |
1491 read_size = 0; | 1505 read_size = 0; |
2182 | 2196 |
2183 pkt->dts= st->pts_buffer[0]; | 2197 pkt->dts= st->pts_buffer[0]; |
2184 } | 2198 } |
2185 | 2199 |
2186 if(st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && st->cur_dts >= pkt->dts){ | 2200 if(st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && st->cur_dts >= pkt->dts){ |
2187 av_log(NULL, AV_LOG_ERROR, "error, non monotone timestamps %"PRId64" >= %"PRId64" st:%d\n", st->cur_dts, pkt->dts, st->index); | 2201 av_log(NULL, AV_LOG_ERROR, "error, non monotone timestamps %"PRId64" >= %"PRId64"\n", st->cur_dts, pkt->dts); |
2188 return -1; | 2202 return -1; |
2189 } | 2203 } |
2190 if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts < pkt->dts){ | 2204 if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts < pkt->dts){ |
2191 av_log(NULL, AV_LOG_ERROR, "error, pts < dts (%"PRId64" < %"PRId64")\n", | 2205 av_log(NULL, AV_LOG_ERROR, "error, pts < dts\n"); |
2192 pkt->pts, pkt->dts); | |
2193 return -1; | 2206 return -1; |
2194 } | 2207 } |
2195 | 2208 |
2196 // av_log(NULL, AV_LOG_DEBUG, "av_write_frame: pts2:%"PRId64" dts2:%"PRId64"\n", pkt->pts, pkt->dts); | 2209 // av_log(NULL, AV_LOG_DEBUG, "av_write_frame: pts2:%"PRId64" dts2:%"PRId64"\n", pkt->pts, pkt->dts); |
2197 st->cur_dts= pkt->dts; | 2210 st->cur_dts= pkt->dts; |