Commit b55b6611 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Adding constrained VBR mode

parent d8571e4b
celt @ 6f6e8b39
Subproject commit 7c328c2d7a9bb28b837d935658ec05bfd7746aa6
Subproject commit 6f6e8b39842a7d175e89f47e4d37ad5de8143ad2
......@@ -125,6 +125,11 @@ extern "C" {
#define OPUS_GET_VOICE_RATIO_REQUEST 19
#define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __check_int_ptr(x)
#define OPUS_SET_VBR_CONSTRAINT_REQUEST 20
#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __check_int(x)
#define OPUS_GET_VBR_CONSTRAINT_REQUEST 21
#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __check_int_ptr(x)
typedef struct OpusEncoder OpusEncoder;
typedef struct OpusDecoder OpusDecoder;
......
......@@ -360,6 +360,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
if (st->use_vbr)
{
celt_encoder_ctl(st->celt_enc, CELT_SET_VBR(1));
celt_encoder_ctl(st->celt_enc, CELT_SET_VBR_CONSTRAINT(st->vbr_constraint));
celt_encoder_ctl(st->celt_enc, CELT_SET_BITRATE(st->bitrate_bps));
nb_compr_bytes = max_data_bytes-1;
} else {
......@@ -616,6 +617,18 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...)
*value = st->voice_ratio;
}
break;
case OPUS_SET_VBR_CONSTRAINT_REQUEST:
{
int value = va_arg(ap, int);
st->vbr_constraint = value;
}
break;
case OPUS_GET_VBR_CONSTRAINT_REQUEST:
{
int *value = va_arg(ap, int*);
*value = st->vbr_constraint;
}
break;
default:
fprintf(stderr, "unknown opus_encoder_ctl() request: %d", request);
break;
......
......@@ -51,6 +51,7 @@ struct OpusEncoder {
/* Sampling rate (at the API level) */
int Fs;
int use_vbr;
int vbr_constraint;
int bitrate_bps;
int encoder_buffer;
int delay_compensation;
......
......@@ -82,6 +82,7 @@ int main(int argc, char *argv[])
int complexity;
int use_inbandfec;
int use_dtx;
int cvbr = 0;
int packet_loss_perc;
int count=0, count_act=0, k;
int skip;
......@@ -169,6 +170,9 @@ int main(int argc, char *argv[])
} else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-inbandfec" ) == 0 ) {
use_inbandfec = 1;
args++;
} else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-cvbr" ) == 0 ) {
cvbr = 1;
args++;
} else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-dtx") == 0 ) {
use_dtx = 1;
args++;
......@@ -222,6 +226,7 @@ int main(int argc, char *argv[])
opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate_bps));
opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(bandwidth));
opus_encoder_ctl(enc, OPUS_SET_VBR_FLAG(use_vbr));
opus_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(cvbr));
opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity));
opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC_FLAG(use_inbandfec));
opus_encoder_ctl(enc, OPUS_SET_DTX_FLAG(use_dtx));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment