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>
This commit is contained in:
Alexander Strasser 2020-07-17 20:51:43 +02:00
parent 1201687da2
commit ecd71916d1
3 changed files with 3 additions and 5 deletions

View File

@ -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;
}
}

View File

@ -56,7 +56,6 @@ typedef struct AACAC3ParseContext {
int need_next_header;
int frame_number;
int last_bit_rate;
enum AVCodecID codec_id;
} AACAC3ParseContext;

View File

@ -1,4 +1,4 @@
3e63cbb6bb6ec756d79fab2632fef305 *tests/data/fate/adtstoasc_ticket3715.mov
29ef0632a8eb5c336bf45a1d5076626e *tests/data/fate/adtstoasc_ticket3715.mov
33324 tests/data/fate/adtstoasc_ticket3715.mov
#extradata 0: 2, 0x00340022
#tb 0: 1/44100