ref: c18fb1d0314e386ee07e80048c2dd1de625c017d
parent: c591e1542a06e8edf4de2f9cd331e182847818f4
author: Jean-Marc Valin <[email protected]>
date: Tue Sep 30 03:36:54 EDT 2008
Added celt_encoder_ctl() and CELT_SET_COMPLEXITY
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -711,6 +711,26 @@
}
#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 */
--- a/libcelt/celt.h
+++ b/libcelt/celt.h
@@ -62,8 +62,12 @@
#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 @@
/** Query information from a mode */
EXPORT int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value);
-
/* Encoder stuff */
@@ -151,6 +154,14 @@
*/
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 */
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -69,7 +69,7 @@
*value = CELT_BITSTREAM_VERSION;
break;
default:
- return CELT_BAD_ARG;
+ return CELT_BAD_REQUEST;
}
return CELT_OK;
}
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -229,7 +229,6 @@
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;