Commit aa9ac199 authored by Timo Teräs's avatar Timo Teräs Committed by Michael Niedermayer

mpegencts: Fix overflow in cbr mode period calculations

ts->mux_rate is int (signed 32-bit) type. The period calculations
will start to overflow when mux_rate > 5mbps. This fixes overflows
by converting first to 64-bit type.

Fixes #5044.
Signed-off-by: 's avatarTimo Teräs <timo.teras@iki.fi>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 64f7db55)
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent f2258e98
...@@ -756,11 +756,11 @@ static int mpegts_write_header(AVFormatContext *s) ...@@ -756,11 +756,11 @@ static int mpegts_write_header(AVFormatContext *s)
ts_st = pcr_st->priv_data; ts_st = pcr_st->priv_data;
if (ts->mux_rate > 1) { if (ts->mux_rate > 1) {
service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) / service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period /
(TS_PACKET_SIZE * 8 * 1000); (TS_PACKET_SIZE * 8 * 1000);
ts->sdt_packet_period = (ts->mux_rate * SDT_RETRANS_TIME) / ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME /
(TS_PACKET_SIZE * 8 * 1000); (TS_PACKET_SIZE * 8 * 1000);
ts->pat_packet_period = (ts->mux_rate * PAT_RETRANS_TIME) / ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME /
(TS_PACKET_SIZE * 8 * 1000); (TS_PACKET_SIZE * 8 * 1000);
if (ts->copyts < 1) if (ts->copyts < 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment