mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
avformat: fix overflows during bit rate calculation
The bit_rate field has type int64_t since commit
7404f3bdb9
.
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
This commit is contained in:
parent
2b0112d42d
commit
ad5807f8aa
@ -116,7 +116,7 @@ static int adx_read_header(AVFormatContext *s)
|
||||
|
||||
par->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
par->codec_id = s->iformat->raw_codec_id;
|
||||
par->bit_rate = par->sample_rate * par->channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES;
|
||||
par->bit_rate = (int64_t)par->sample_rate * par->channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES;
|
||||
|
||||
avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate);
|
||||
|
||||
|
@ -181,7 +181,7 @@ static int get_aiff_header(AVFormatContext *s, int size,
|
||||
par->block_align = (av_get_bits_per_sample(par->codec_id) * par->channels) >> 3;
|
||||
|
||||
if (aiff->block_duration) {
|
||||
par->bit_rate = par->sample_rate * (par->block_align << 3) /
|
||||
par->bit_rate = (int64_t)par->sample_rate * (par->block_align << 3) /
|
||||
aiff->block_duration;
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ static int aiff_read_header(AVFormatContext *s)
|
||||
st->codecpar->block_align = 35;
|
||||
}
|
||||
aiff->block_duration = 160;
|
||||
st->codecpar->bit_rate = st->codecpar->sample_rate * (st->codecpar->block_align << 3) /
|
||||
st->codecpar->bit_rate = (int64_t)st->codecpar->sample_rate * (st->codecpar->block_align << 3) /
|
||||
aiff->block_duration;
|
||||
}
|
||||
break;
|
||||
|
@ -65,7 +65,7 @@ static int apc_read_header(AVFormatContext *s)
|
||||
}
|
||||
|
||||
st->codecpar->bits_per_coded_sample = 4;
|
||||
st->codecpar->bit_rate = st->codecpar->bits_per_coded_sample * st->codecpar->channels
|
||||
st->codecpar->bit_rate = (int64_t)st->codecpar->bits_per_coded_sample * st->codecpar->channels
|
||||
* st->codecpar->sample_rate;
|
||||
st->codecpar->block_align = 1;
|
||||
|
||||
|
@ -108,7 +108,7 @@ static int bfi_read_header(AVFormatContext * s)
|
||||
astream->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
|
||||
astream->codecpar->bits_per_coded_sample = 8;
|
||||
astream->codecpar->bit_rate =
|
||||
astream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;
|
||||
(int64_t)astream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;
|
||||
avio_seek(pb, chunk_header - 3, SEEK_SET);
|
||||
avpriv_set_pts_info(astream, 64, 1, astream->codecpar->sample_rate);
|
||||
return 0;
|
||||
|
@ -557,7 +557,7 @@ static int ea_read_header(AVFormatContext *s)
|
||||
st->codecpar->channels = ea->num_channels;
|
||||
st->codecpar->sample_rate = ea->sample_rate;
|
||||
st->codecpar->bits_per_coded_sample = ea->bytes * 8;
|
||||
st->codecpar->bit_rate = st->codecpar->channels *
|
||||
st->codecpar->bit_rate = (int64_t)st->codecpar->channels *
|
||||
st->codecpar->sample_rate *
|
||||
st->codecpar->bits_per_coded_sample / 4;
|
||||
st->codecpar->block_align = st->codecpar->channels *
|
||||
|
@ -748,7 +748,7 @@ static int iff_read_header(AVFormatContext *s)
|
||||
}
|
||||
|
||||
st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);
|
||||
st->codecpar->bit_rate = st->codecpar->channels * st->codecpar->sample_rate * st->codecpar->bits_per_coded_sample;
|
||||
st->codecpar->bit_rate = (int64_t)st->codecpar->channels * st->codecpar->sample_rate * st->codecpar->bits_per_coded_sample;
|
||||
st->codecpar->block_align = st->codecpar->channels * st->codecpar->bits_per_coded_sample;
|
||||
if (st->codecpar->codec_tag == ID_DSD && st->codecpar->block_align <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
@ -113,7 +113,7 @@ static int sox_read_header(AVFormatContext *s)
|
||||
|
||||
st->codecpar->sample_rate = sample_rate;
|
||||
st->codecpar->bits_per_coded_sample = 32;
|
||||
st->codecpar->bit_rate = st->codecpar->sample_rate *
|
||||
st->codecpar->bit_rate = (int64_t)st->codecpar->sample_rate *
|
||||
st->codecpar->bits_per_coded_sample *
|
||||
st->codecpar->channels;
|
||||
st->codecpar->block_align = st->codecpar->bits_per_coded_sample *
|
||||
|
@ -126,7 +126,7 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
|
||||
}
|
||||
}
|
||||
|
||||
par->bit_rate = par->sample_rate * par->channels * par->bits_per_coded_sample;
|
||||
par->bit_rate = (int64_t)par->sample_rate * par->channels * par->bits_per_coded_sample;
|
||||
|
||||
if (max_size <= 0)
|
||||
max_size = 2048;
|
||||
|
@ -140,7 +140,7 @@ static int vqf_read_header(AVFormatContext *s)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
st->codecpar->bit_rate = read_bitrate * 1000;
|
||||
st->codecpar->bit_rate = (int64_t)read_bitrate * 1000;
|
||||
break;
|
||||
case MKTAG('D','S','I','Z'): // size of compressed data
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ static int wsd_read_header(AVFormatContext *s)
|
||||
st->codecpar->sample_rate = avio_rb32(pb) / 8;
|
||||
avio_skip(pb, 4);
|
||||
st->codecpar->channels = avio_r8(pb) & 0xF;
|
||||
st->codecpar->bit_rate = st->codecpar->channels * st->codecpar->sample_rate * 8LL;
|
||||
st->codecpar->bit_rate = (int64_t)st->codecpar->channels * st->codecpar->sample_rate * 8LL;
|
||||
if (!st->codecpar->channels)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user