In VBR the MDCT modes rate control could dramatically over/undershoot after a frame size change
because the adaptive rate control offset was not being scaled.
This commit is contained in:
parent
9f555bc4e7
commit
de0b977547
1 changed files with 3 additions and 2 deletions
|
@ -1382,8 +1382,9 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
|
||||||
/* The target rate in 8th bits per frame */
|
/* The target rate in 8th bits per frame */
|
||||||
opus_int32 target;
|
opus_int32 target;
|
||||||
opus_int32 min_allowed;
|
opus_int32 min_allowed;
|
||||||
|
int lm_diff = st->mode->maxLM - LM;
|
||||||
|
|
||||||
target = vbr_rate + st->vbr_offset - ((40*C+20)<<BITRES);
|
target = vbr_rate + (st->vbr_offset>>lm_diff) - ((40*C+20)<<BITRES);
|
||||||
|
|
||||||
/* Shortblocks get a large boost in bitrate, but since they
|
/* Shortblocks get a large boost in bitrate, but since they
|
||||||
are uncommon long blocks are not greatly affected */
|
are uncommon long blocks are not greatly affected */
|
||||||
|
@ -1437,7 +1438,7 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
|
||||||
/*printf ("%d\n", st->vbr_reservoir);*/
|
/*printf ("%d\n", st->vbr_reservoir);*/
|
||||||
|
|
||||||
/* Compute the offset we need to apply in order to reach the target */
|
/* Compute the offset we need to apply in order to reach the target */
|
||||||
st->vbr_drift += (opus_int32)MULT16_32_Q15(alpha,delta-st->vbr_offset-st->vbr_drift);
|
st->vbr_drift += (opus_int32)MULT16_32_Q15(alpha,(delta<<lm_diff)-st->vbr_offset-st->vbr_drift);
|
||||||
st->vbr_offset = -st->vbr_drift;
|
st->vbr_offset = -st->vbr_drift;
|
||||||
/*printf ("%d\n", st->vbr_drift);*/
|
/*printf ("%d\n", st->vbr_drift);*/
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue