summaryrefslogtreecommitdiff
path: root/libavcodec/libvo-amrwbenc.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2011-04-13 11:03:19 +0300
committerMartin Storsjö <martin@martin.st>2011-04-14 00:31:34 +0300
commit3dd82afc748df0f1c49b76e1cd4ea6e35b1001a5 (patch)
tree2e3de72267c46c12946e89ac0ce0b071844c041b /libavcodec/libvo-amrwbenc.c
parent70739381213b087cca9570b66561dc57652b6fb9 (diff)
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/libvo-amrwbenc.c')
-rw-r--r--libavcodec/libvo-amrwbenc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c
index b194bf04bb..d3db5f847a 100644
--- a/libavcodec/libvo-amrwbenc.c
+++ b/libavcodec/libvo-amrwbenc.c
@@ -27,6 +27,7 @@
typedef struct AMRWBContext {
void *state;
int mode;
+ int last_bitrate;
int allow_dtx;
} AMRWBContext;
@@ -70,7 +71,8 @@ static av_cold int amr_wb_encode_init(AVCodecContext *avctx)
return AVERROR(ENOSYS);
}
- s->mode = get_wb_bitrate_mode(avctx->bit_rate, avctx);
+ s->mode = get_wb_bitrate_mode(avctx->bit_rate, avctx);
+ s->last_bitrate = avctx->bit_rate;
avctx->frame_size = 320;
avctx->coded_frame = avcodec_alloc_frame();
@@ -97,7 +99,10 @@ static int amr_wb_encode_frame(AVCodecContext *avctx,
AMRWBContext *s = avctx->priv_data;
int size;
- s->mode = get_wb_bitrate_mode(avctx->bit_rate, avctx);
+ if (s->last_bitrate != avctx->bit_rate) {
+ s->mode = get_wb_bitrate_mode(avctx->bit_rate, avctx);
+ s->last_bitrate = avctx->bit_rate;
+ }
size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx);
return size;
}