diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-05-23 06:25:44 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-05-23 06:25:44 +0000 |
commit | 84df78b476ca127e104195c5f90e0546cb2e70c9 (patch) | |
tree | 2ab31e9e1fcdc7e37dd691918c7e01898a1b2d1c /libavformat | |
parent | c69d224102acff478a85f678c0327604f10ec997 (diff) | |
download | ffmpeg-84df78b476ca127e104195c5f90e0546cb2e70c9.tar.gz |
simplify pes timestamps fetching, based on a patch by corp186, chasedouglas at gmail dot com
Originally committed as revision 18910 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mpegtsenc.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 04145d5818..c29f9bb87c 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -701,7 +701,6 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) uint8_t *buf= pkt->data; uint8_t *data= NULL; MpegTSWriteStream *ts_st = st->priv_data; - const uint8_t *access_unit_index = NULL; const uint64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE); int64_t dts = AV_NOPTS_VALUE, pts = AV_NOPTS_VALUE; @@ -732,14 +731,6 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) buf = data; size = pkt->size+6; } - access_unit_index = buf; - } else { - access_unit_index = pkt->data; - } - - if (!access_unit_index) { - av_log(s, AV_LOG_ERROR, "error, could not find access unit start\n"); - return -1; } if (st->codec->codec_type == CODEC_TYPE_SUBTITLE || @@ -750,6 +741,11 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) return 0; } + if (ts_st->payload_pts == AV_NOPTS_VALUE) { + ts_st->payload_dts = dts; + ts_st->payload_pts = pts; + } + // audio while (size > 0) { len = DEFAULT_PES_PAYLOAD_SIZE - ts_st->payload_index; @@ -759,19 +755,12 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) buf += len; size -= len; ts_st->payload_index += len; - if (access_unit_index && access_unit_index < buf && - ts_st->payload_pts == AV_NOPTS_VALUE && - ts_st->payload_dts == AV_NOPTS_VALUE) { - ts_st->payload_dts = dts; - ts_st->payload_pts = pts; - } if (ts_st->payload_index >= DEFAULT_PES_PAYLOAD_SIZE) { mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index, ts_st->payload_pts, ts_st->payload_dts); ts_st->payload_pts = AV_NOPTS_VALUE; ts_st->payload_dts = AV_NOPTS_VALUE; ts_st->payload_index = 0; - access_unit_index = NULL; // unset access unit to avoid setting pts/dts again } } |