# HG changeset patch # User bcoudurier # Date 1263414655 0 # Node ID dd79e1261e2871a23c30e66eb6044cee6066f14a # Parent 2836866dd7a16f7191deacec36eca96805aa9d2e move pcr/sdt/pat period computation after ts->mux_rate is set, patch by Mike Scheutzow, scheutzow at alcatel-lucent dot com diff -r 2836866dd7a1 -r dd79e1261e28 mpegtsenc.c --- a/mpegtsenc.c Wed Jan 13 20:26:59 2010 +0000 +++ b/mpegtsenc.c Wed Jan 13 20:30:55 2010 +0000 @@ -448,15 +448,6 @@ 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 @@ } 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 @@ 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;