ref: 79b34eb83e53268a520affed056a46030999d270
parent: 9faf74088285e6b0b8a125ba606dece8c165f663
author: Jean-Marc Valin <[email protected]>
date: Sun Dec 5 12:22:06 EST 2010
Add API support for unconstrained VBR celtenc now defaults to unconstrained VBR.
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -1313,6 +1313,12 @@
}
}
break;
+ case CELT_SET_VBR_CONSTRAINT_REQUEST:
+ {
+ celt_int32 value = va_arg(ap, celt_int32);
+ st->constrained_vbr = value;
+ }
+ break;
case CELT_SET_VBR_RATE_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
--- a/libcelt/celt.h
+++ b/libcelt/celt.h
@@ -95,6 +95,9 @@
#define CELT_RESET_STATE_REQUEST 8
#define CELT_RESET_STATE CELT_RESET_STATE_REQUEST
+#define CELT_SET_VBR_CONSTRAINT_REQUEST 10
+#define CELT_SET_VBR_CONSTRAINT(x) CELT_SET_VBR_CONSTRAINT_REQUEST, _celt_check_int(x)
+
#define CELT_SET_START_BAND_REQUEST 10000
#define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, _celt_check_int(x)
--- a/tools/celtenc.c
+++ b/tools/celtenc.c
@@ -255,6 +255,7 @@
void *st;
unsigned char bits[MAX_FRAME_BYTES];
int with_cbr = 0;
+ int with_cvbr = 0;
int with_skeleton = 0;
int total_bytes = 0;
int peak_bytes = 0;
@@ -262,6 +263,7 @@
{
{"bitrate", required_argument, NULL, 0},
{"cbr",no_argument,NULL, 0},
+ {"cvbr",no_argument,NULL, 0},
{"comp", required_argument, NULL, 0},
{"noltp", no_argument, NULL, 0},
{"independent", no_argument, NULL, 0},
@@ -328,6 +330,9 @@
} else if (strcmp(long_options[option_index].name,"cbr")==0)
{
with_cbr=1;
+ } else if (strcmp(long_options[option_index].name,"cvbr")==0)
+ {
+ with_cvbr=1;
} else if (strcmp(long_options[option_index].name,"skeleton")==0)
{
with_skeleton=1;
@@ -529,7 +534,15 @@
fprintf (stderr, "VBR request failed\n");
return 1;
}
- }
+ if (!with_cvbr)
+ {
+ if (celt_encoder_ctl(st, CELT_SET_VBR_CONSTRAINT(0)) != CELT_OK)
+ {
+ fprintf (stderr, "VBR constraint failed\n");
+ return 1;
+ }
+ }
+ }
if (celt_encoder_ctl(st, CELT_SET_PREDICTION(prediction)) != CELT_OK)
{