diff options
author | Martin Storsjö <martin@martin.st> | 2011-04-13 11:03:19 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2011-04-14 00:31:34 +0300 |
commit | 3dd82afc748df0f1c49b76e1cd4ea6e35b1001a5 (patch) | |
tree | 2e3de72267c46c12946e89ac0ce0b071844c041b /libavcodec/libopencore-amr.c | |
parent | 70739381213b087cca9570b66561dc57652b6fb9 (diff) | |
download | ffmpeg-3dd82afc748df0f1c49b76e1cd4ea6e35b1001a5.tar.gz |
libopencore-amr, libvo-amrwbenc: Only check the bitrate when changed
Also rename the incorrectly named enc_bitrate to enc_mode, use the
enc_bitrate variable for storing the last chosen bitrate.
This avoids continuous warning log messages if not using an
exactly matching bitrate, while still allowing changing bitrate
at any point.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec/libopencore-amr.c')
-rw-r--r-- | libavcodec/libopencore-amr.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index e6216c9e5e..c8b3a2c1bc 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -81,6 +81,7 @@ typedef struct AMRContext { void *dec_state; void *enc_state; int enc_bitrate; + int enc_mode; } AMRContext; static av_cold int amr_nb_decode_init(AVCodecContext *avctx) @@ -181,7 +182,8 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx) return -1; } - s->enc_bitrate = get_bitrate_mode(avctx->bit_rate, avctx); + s->enc_mode = get_bitrate_mode(avctx->bit_rate, avctx); + s->enc_bitrate = avctx->bit_rate; return 0; } @@ -202,12 +204,15 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, AMRContext *s = avctx->priv_data; int written; - s->enc_bitrate = get_bitrate_mode(avctx->bit_rate, avctx); + if (s->enc_bitrate != avctx->bit_rate) { + s->enc_mode = get_bitrate_mode(avctx->bit_rate, avctx); + s->enc_bitrate = avctx->bit_rate; + } - written = Encoder_Interface_Encode(s->enc_state, s->enc_bitrate, data, + written = Encoder_Interface_Encode(s->enc_state, s->enc_mode, data, frame, 0); av_dlog(avctx, "amr_nb_encode_frame encoded %u bytes, bitrate %u, first byte was %#02x\n", - written, s->enc_bitrate, frame[0]); + written, s->enc_mode, frame[0]); return written; } |