diff options
author | Alexander Strasser <eclipse7@gmx.net> | 2020-07-17 21:51:43 +0300 |
---|---|---|
committer | Alexander Strasser <eclipse7@gmx.net> | 2020-08-12 18:35:38 +0300 |
commit | ecd71916d1e573a4b91b1fd182f3d232a1693dff (patch) | |
tree | fb8d22b243642a6781ad6a1c1f975d48281ddd96 /libavcodec | |
parent | 1201687da268c11459891a80ca1972aeaca8db88 (diff) |
lavc/aac_ac3_parser: fix potential overflow when averaging bitrate
The new code is analog to how it's done in our mpegaudio parser.
Acked-by: Jun Zhao <barryjzhao@tencent.com>
Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/aac_ac3_parser.c | 5 | ||||
-rw-r--r-- | libavcodec/aac_ac3_parser.h | 1 |
2 files changed, 2 insertions, 4 deletions
diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c index 0746798dab..e5d4b53339 100644 --- a/libavcodec/aac_ac3_parser.c +++ b/libavcodec/aac_ac3_parser.c @@ -100,9 +100,8 @@ get_next: /* Calculate the average bit rate */ s->frame_number++; if (avctx->codec_id != AV_CODEC_ID_EAC3) { - avctx->bit_rate = - (s->last_bit_rate * (s->frame_number -1) + s->bit_rate)/s->frame_number; - s->last_bit_rate = avctx->bit_rate; + avctx->bit_rate += + (s->bit_rate - avctx->bit_rate) / s->frame_number; } } diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h index b04041f69d..8b93cbf84f 100644 --- a/libavcodec/aac_ac3_parser.h +++ b/libavcodec/aac_ac3_parser.h @@ -56,7 +56,6 @@ typedef struct AACAC3ParseContext { int need_next_header; int frame_number; - int last_bit_rate; enum AVCodecID codec_id; } AACAC3ParseContext; |