diff --git a/libcelt/celt.c b/libcelt/celt.c index 3095d3345f80bc1bf34d495f49a1cd8c17f8457e..d582438c79b6b7c4ae2d58467c10537f2e155288 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -711,6 +711,26 @@ int celt_encode(CELTEncoder * restrict st, celt_int16_t * restrict pcm, unsigned } #endif +int celt_encoder_ctl(CELTEncoder * restrict st, int request, celt_int32_t *value) +{ + switch (request) + { + case CELT_SET_COMPLEXITY: + { + if (*value<0 || *value>10) + return CELT_BAD_ARG; + if (*value<=2) + st->pitch_enabled = 0; + else + st->pitch_enabled = 1; + } + break; + default: + return CELT_BAD_REQUEST; + } + return CELT_OK; +} + /****************************************************************************/ /* */ /* DECODER */ diff --git a/libcelt/celt.h b/libcelt/celt.h index 53df4421131552caed577cfbc27f45ab1d2c45f0..32d6a6f155b87e727d65a9bd16607c3682069706 100644 --- a/libcelt/celt.h +++ b/libcelt/celt.h @@ -62,8 +62,12 @@ extern "C" { #define CELT_INTERNAL_ERROR -3 /** The data passed (e.g. compressed data to decoder) is corrupted */ #define CELT_CORRUPTED_DATA -4 +/** Invalid/unsupported request number */ +#define CELT_BAD_REQUEST -5 /* Requests */ +#define CELT_SET_COMPLEXITY 0 + /** GET the frame size used in the current mode */ #define CELT_GET_FRAME_SIZE 1000 /** GET the lookahead used in the current mode */ @@ -119,7 +123,6 @@ EXPORT void celt_mode_destroy(CELTMode *mode); /** Query information from a mode */ EXPORT int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value); - /* Encoder stuff */ @@ -152,6 +155,14 @@ EXPORT void celt_encoder_destroy(CELTEncoder *st); EXPORT int celt_encode_float(CELTEncoder *st, float *pcm, unsigned char *compressed, int nbCompressedBytes); EXPORT int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, int nbCompressedBytes); +/** Query and set encoder parameters + @param st Encoder state + @param request Parameter to change or query + @param value Pointer to a 32-bit int value + @return Error code +*/ +EXPORT int celt_encoder_ctl(CELTEncoder * restrict st, int request, celt_int32_t *value); + /* Decoder stuff */ diff --git a/libcelt/modes.c b/libcelt/modes.c index 2f1db65ede9573ed6188d5749b3394259054d28c..0d52f3c6da95f30d4ac56b70f49f85476e8f49da 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -69,7 +69,7 @@ int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value) *value = CELT_BITSTREAM_VERSION; break; default: - return CELT_BAD_ARG; + return CELT_BAD_REQUEST; } return CELT_OK; } diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c index 469d42a1c2db08f37ba795e81e7135474094bfe2..3ad16eb24a1d2827b9d41dba4fb29b25b249ecd9 100644 --- a/libcelt/quant_bands.c +++ b/libcelt/quant_bands.c @@ -229,7 +229,6 @@ static void unquant_fine_energy_mono(const CELTMode *m, celt_ener_t *eBands, cel for (i=0;i<m->nbEBands;i++) { int q2; - celt_int16_t frac = 1<<fine_quant[i]; celt_word16_t offset; if (fine_quant[i] <= 0) continue;