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>
pull/346/head
Alexander Strasser 4 years ago
parent 1201687da2
commit ecd71916d1
  1. 5
      libavcodec/aac_ac3_parser.c
  2. 1
      libavcodec/aac_ac3_parser.h
  3. 2
      tests/ref/fate/adtstoasc_ticket3715

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

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

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

Loading…
Cancel
Save