From 194be1f43ea391eb986732707435176e579265aa Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 18 May 2014 12:12:59 +0200 Subject: lavf: switch to AVStream.time_base as the hint for the muxer timebase Previously, AVStream.codec.time_base was used for that purpose, which was quite confusing for the callers. This change also opens the path for removing AVStream.codec. The change in the lavf-mkv test is due to the native timebase (1/1000) being used instead of the default one (1/90000), so the packets are now sent to the crc muxer in the same order in which they are demuxed (previously some of them got reordered because of inexact timestamp conversion). --- libavformat/mpegtsenc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'libavformat/mpegtsenc.c') diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 04cabe5f8d..838702e8fa 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -194,6 +194,7 @@ typedef struct MpegTSWriteStream { int payload_flags; uint8_t *payload; AVFormatContext *amux; + AVRational user_tb; } MpegTSWriteStream; static void mpegts_write_pat(AVFormatContext *s) @@ -480,13 +481,17 @@ static int mpegts_write_header(AVFormatContext *s) /* assign pids to each stream */ for(i = 0;i < s->nb_streams; i++) { st = s->streams[i]; - avpriv_set_pts_info(st, 33, 1, 90000); + ts_st = av_mallocz(sizeof(MpegTSWriteStream)); if (!ts_st) { ret = AVERROR(ENOMEM); goto fail; } st->priv_data = ts_st; + + ts_st->user_tb = st->time_base; + avpriv_set_pts_info(st, 33, 1, 90000); + ts_st->payload = av_mallocz(ts->pes_payload_size); if (!ts_st->payload) { ret = AVERROR(ENOMEM); @@ -557,7 +562,8 @@ static int mpegts_write_header(AVFormatContext *s) pcr_st = s->streams[0]; ts_st = pcr_st->priv_data; service->pcr_pid = ts_st->pid; - } + } else + ts_st = pcr_st->priv_data; if (ts->mux_rate > 1) { service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) / @@ -583,8 +589,9 @@ static int mpegts_write_header(AVFormatContext *s) } } else { // max delta PCR 0.1s + // TODO: should be avg_frame_rate service->pcr_packet_period = - pcr_st->codec->time_base.den/(10*pcr_st->codec->time_base.num); + ts_st->user_tb.den / (10 * ts_st->user_tb.num); } } -- cgit v1.2.3