Implements OPUS_{GET,SET}_LSB_DEPTH

This implements an API used in future encoders to avoid dynalloc doing silly things
on periodic LSB patterns and to reduce the bitrate on near-silence.
This commit is contained in:
Jean-Marc Valin 2012-07-11 02:54:47 -04:00 committed by Gregory Maxwell
parent 02f19c26f1
commit 1cd5d95b3f
4 changed files with 42 additions and 0 deletions

View file

@ -156,6 +156,7 @@ struct OpusCustomEncoder {
int signalling;
int constrained_vbr; /* If zero, VBR can do whatever it likes with the rate */
int loss_rate;
int lsb_depth;
/* Everything beyond this point gets cleared on a reset */
#define ENCODER_RESET_START rng
@ -266,6 +267,7 @@ OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_init(CELTEncoder *st, const CELTMod
st->vbr = 0;
st->force_intra = 0;
st->complexity = 5;
st->lsb_depth=24;
opus_custom_encoder_ctl(st, OPUS_RESET_STATE);
@ -1823,6 +1825,20 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...)
st->stream_channels = value;
}
break;
case OPUS_SET_LSB_DEPTH_REQUEST:
{
opus_int32 value = va_arg(ap, opus_int32);
if (value<8 || value>24)
goto bad_arg;
st->lsb_depth=value;
}
break;
case OPUS_GET_LSB_DEPTH_REQUEST:
{
opus_int32 *value = va_arg(ap, opus_int32*);
*value=st->lsb_depth;
}
break;
case OPUS_RESET_STATE:
{
int i;