diff options
author | Mike Scheutzow <scheutzow@alcatel-lucent.com> | 2010-01-13 23:30:55 +0300 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2010-01-13 23:30:55 +0300 |
commit | 49f6fd8f3f6f324f1cfbad250e4053b0ddb21c9d (patch) | |
tree | 680b687b98cbb65e951523e299cc3fb62aef7981 | |
parent | 6b18a3f5ba80fb01116220fc94246d916d6afbe1 (diff) |
move pcr/sdt/pat period computation after ts->mux_rate is set, patch by Mike Scheutzow, scheutzow at alcatel-lucent dot com
Originally committed as revision 21198 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/mpegtsenc.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 7e78559e04..f616fe6381 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -448,15 +448,6 @@ static int mpegts_write_header(AVFormatContext *s) service->pcr_pid = ts_st->pid; } - if (total_bit_rate <= 8 * 1024) - total_bit_rate = 8 * 1024; - service->pcr_packet_period = (total_bit_rate * PCR_RETRANS_TIME) / - (TS_PACKET_SIZE * 8 * 1000); - ts->sdt_packet_period = (total_bit_rate * SDT_RETRANS_TIME) / - (TS_PACKET_SIZE * 8 * 1000); - ts->pat_packet_period = (total_bit_rate * PAT_RETRANS_TIME) / - (TS_PACKET_SIZE * 8 * 1000); - ts->mux_rate = 1; // avoid div by 0 /* write info at the start of the file, so that it will be fast to @@ -471,6 +462,9 @@ static int mpegts_write_header(AVFormatContext *s) } pat_pmt_size = url_ftell(s->pb) - pos; + if (total_bit_rate <= 8 * 1024) + total_bit_rate = 8 * 1024; + total_bit_rate += total_bit_rate * 4 / (TS_PACKET_SIZE-4) + /* TS header size */ 1000 * 8 * sdt_size / PAT_RETRANS_TIME + /* SDT size */ @@ -485,6 +479,13 @@ static int mpegts_write_header(AVFormatContext *s) else ts->mux_rate = total_bit_rate; + service->pcr_packet_period = (ts->mux_rate * PCR_RETRANS_TIME) / + (TS_PACKET_SIZE * 8 * 1000); + ts->sdt_packet_period = (ts->mux_rate * SDT_RETRANS_TIME) / + (TS_PACKET_SIZE * 8 * 1000); + ts->pat_packet_period = (ts->mux_rate * PAT_RETRANS_TIME) / + (TS_PACKET_SIZE * 8 * 1000); + // output a PCR as soon as possible service->pcr_packet_count = service->pcr_packet_period; |