The type of last_frame_pb_count was chosen to be an int since overflow
is impossible (the spec says the maximum bits per frame is 6144 per
channel and the encoder checks for that).
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
... | ... |
@@ -649,7 +649,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, |
649 | 649 |
sce->band_type[w] = 0; |
650 | 650 |
} |
651 | 651 |
s->psy.bitres.alloc = -1; |
652 |
- s->psy.bitres.bits = avctx->frame_bits / s->channels; |
|
652 |
+ s->psy.bitres.bits = s->last_frame_pb_count / s->channels; |
|
653 | 653 |
s->psy.model->analyze(&s->psy, start_ch, coeffs, wi); |
654 | 654 |
if (s->psy.bitres.alloc > 0) { |
655 | 655 |
/* Lambda unused here on purpose, we need to take psy's unscaled allocation */ |
... | ... |
@@ -819,11 +819,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, |
819 | 819 |
put_bits(&s->pb, 3, TYPE_END); |
820 | 820 |
flush_put_bits(&s->pb); |
821 | 821 |
|
822 |
-#if FF_API_STAT_BITS |
|
823 |
-FF_DISABLE_DEPRECATION_WARNINGS |
|
824 |
- avctx->frame_bits = put_bits_count(&s->pb); |
|
825 |
-FF_ENABLE_DEPRECATION_WARNINGS |
|
826 |
-#endif |
|
822 |
+ s->last_frame_pb_count = put_bits_count(&s->pb); |
|
827 | 823 |
|
828 | 824 |
s->lambda_sum += s->lambda; |
829 | 825 |
s->lambda_count++; |
... | ... |
@@ -911,6 +907,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) |
911 | 911 |
s->channels = avctx->channels; |
912 | 912 |
s->chan_map = aac_chan_configs[s->channels-1]; |
913 | 913 |
s->lambda = avctx->global_quality > 0 ? avctx->global_quality : 120; |
914 |
+ s->last_frame_pb_count = 0; |
|
914 | 915 |
avctx->extradata_size = 5; |
915 | 916 |
avctx->frame_size = 1024; |
916 | 917 |
avctx->initial_padding = 1024; |
... | ... |
@@ -118,6 +118,7 @@ typedef struct AACEncContext { |
118 | 118 |
int last_frame; |
119 | 119 |
int random_state; |
120 | 120 |
float lambda; |
121 |
+ int last_frame_pb_count; ///< number of bits for the previous frame |
|
121 | 122 |
float lambda_sum; ///< sum(lambda), for Qvg reporting |
122 | 123 |
int lambda_count; ///< count(lambda), for Qvg reporting |
123 | 124 |
enum RawDataBlockType cur_type; ///< channel group type cur_channel belongs to |