[FFmpeg-cvslog] acenc: remove deprecated avctx->frame_bits use

Rostislav Pehlivanov git at videolan.org
Fri Dec 18 15:28:54 CET 2015


ffmpeg | branch: master | Rostislav Pehlivanov <atomnuker at gmail.com> | Fri Dec 18 14:27:13 2015 +0000| [4386f17bbdf79d19339ab8434b15109dedfb9551] | committer: Rostislav Pehlivanov

acenc: remove deprecated avctx->frame_bits use

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 at gmail.com>
Reviewed-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4386f17bbdf79d19339ab8434b15109dedfb9551
---

 libavcodec/aacenc.c |    9 +++------
 libavcodec/aacenc.h |    1 +
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 3b7dc16..20a8f5a 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -649,7 +649,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
                         sce->band_type[w] = 0;
             }
             s->psy.bitres.alloc = -1;
-            s->psy.bitres.bits = avctx->frame_bits / s->channels;
+            s->psy.bitres.bits = s->last_frame_pb_count / s->channels;
             s->psy.model->analyze(&s->psy, start_ch, coeffs, wi);
             if (s->psy.bitres.alloc > 0) {
                 /* 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,
     put_bits(&s->pb, 3, TYPE_END);
     flush_put_bits(&s->pb);
 
-#if FF_API_STAT_BITS
-FF_DISABLE_DEPRECATION_WARNINGS
-    avctx->frame_bits = put_bits_count(&s->pb);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
+    s->last_frame_pb_count = put_bits_count(&s->pb);
 
     s->lambda_sum += s->lambda;
     s->lambda_count++;
@@ -911,6 +907,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
     s->channels = avctx->channels;
     s->chan_map = aac_chan_configs[s->channels-1];
     s->lambda = avctx->global_quality > 0 ? avctx->global_quality : 120;
+    s->last_frame_pb_count = 0;
     avctx->extradata_size = 5;
     avctx->frame_size = 1024;
     avctx->initial_padding = 1024;
diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
index 2b721d3..a4a49c5 100644
--- a/libavcodec/aacenc.h
+++ b/libavcodec/aacenc.h
@@ -118,6 +118,7 @@ typedef struct AACEncContext {
     int last_frame;
     int random_state;
     float lambda;
+    int last_frame_pb_count;                     ///< number of bits for the previous frame
     float lambda_sum;                            ///< sum(lambda), for Qvg reporting
     int lambda_count;                            ///< count(lambda), for Qvg reporting
     enum RawDataBlockType cur_type;              ///< channel group type cur_channel belongs to



More information about the ffmpeg-cvslog mailing list