diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c index 54e459844f..0746798dab 100644 --- a/libavcodec/aac_ac3_parser.c +++ b/libavcodec/aac_ac3_parser.c @@ -97,8 +97,13 @@ get_next: avctx->audio_service_type = s->service_type; } - if (avctx->codec_id != AV_CODEC_ID_EAC3) - avctx->bit_rate = s->bit_rate; + /* 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; + } } return i; diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h index c2506a5bfd..b04041f69d 100644 --- a/libavcodec/aac_ac3_parser.h +++ b/libavcodec/aac_ac3_parser.h @@ -55,6 +55,8 @@ typedef struct AACAC3ParseContext { uint64_t state; int need_next_header; + int frame_number; + int last_bit_rate; enum AVCodecID codec_id; } AACAC3ParseContext; diff --git a/tests/ref/fate/adtstoasc_ticket3715 b/tests/ref/fate/adtstoasc_ticket3715 index 49fa3eb8d9..3b473ee99e 100644 --- a/tests/ref/fate/adtstoasc_ticket3715 +++ b/tests/ref/fate/adtstoasc_ticket3715 @@ -1,4 +1,4 @@ -4110be924e21846d0e174fac679b062e *tests/data/fate/adtstoasc_ticket3715.mov +3e63cbb6bb6ec756d79fab2632fef305 *tests/data/fate/adtstoasc_ticket3715.mov 33324 tests/data/fate/adtstoasc_ticket3715.mov #extradata 0: 2, 0x00340022 #tb 0: 1/44100