diff --git a/libcelt/celt.c b/libcelt/celt.c index 411ba45849e7336494d7c9686c7b7d7c55e2d276..f1d22783813d3f2ae4197770b0003d103d0b4158 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -1751,14 +1751,6 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...) va_start(ap, request); switch (request) { - case CELT_GET_MODE_REQUEST: - { - const CELTMode ** value = va_arg(ap, const CELTMode**); - if (value==0) - goto bad_arg; - *value=st->mode; - } - break; case CELT_SET_COMPLEXITY_REQUEST: { int value = va_arg(ap, celt_int32); @@ -1821,12 +1813,6 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...) st->stream_channels = value; } break; - case CELT_SET_SIGNALLING_REQUEST: - { - celt_int32 value = va_arg(ap, celt_int32); - st->signalling = value; - } - break; case CELT_RESET_STATE: { CELT_MEMSET((char*)&st->ENCODER_RESET_START, 0, @@ -1844,6 +1830,22 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...) st->clip = value; } break; +#ifdef OPUS_BUILD + case CELT_SET_SIGNALLING_REQUEST: + { + celt_int32 value = va_arg(ap, celt_int32); + st->signalling = value; + } + break; + case CELT_GET_MODE_REQUEST: + { + const CELTMode ** value = va_arg(ap, const CELTMode**); + if (value==0) + goto bad_arg; + *value=st->mode; + } + break; +#endif default: goto bad_request; } @@ -2701,14 +2703,6 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...) va_start(ap, request); switch (request) { - case CELT_GET_MODE_REQUEST: - { - const CELTMode ** value = va_arg(ap, const CELTMode**); - if (value==0) - goto bad_arg; - *value=st->mode; - } - break; case CELT_SET_START_BAND_REQUEST: { celt_int32 value = va_arg(ap, celt_int32); @@ -2733,12 +2727,6 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...) st->stream_channels = value; } break; - case CELT_SET_SIGNALLING_REQUEST: - { - celt_int32 value = va_arg(ap, celt_int32); - st->signalling = value; - } - break; case CELT_GET_AND_CLEAR_ERROR_REQUEST: { int *value = va_arg(ap, int*); @@ -2763,6 +2751,22 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...) ((char*)&st->DECODER_RESET_START - (char*)st)); } break; +#ifdef OPUS_BUILD + case CELT_GET_MODE_REQUEST: + { + const CELTMode ** value = va_arg(ap, const CELTMode**); + if (value==0) + goto bad_arg; + *value=st->mode; + } + break; + case CELT_SET_SIGNALLING_REQUEST: + { + celt_int32 value = va_arg(ap, celt_int32); + st->signalling = value; + } + break; +#endif default: goto bad_request; } diff --git a/libcelt/celt.h b/libcelt/celt.h index b6f2e26d07a9f68b0df5d59181d5c3a02fb58e12..11eb425ab70041879c6e8a95fe6aee31f929f008 100644 --- a/libcelt/celt.h +++ b/libcelt/celt.h @@ -50,7 +50,7 @@ extern "C" { #endif #define _celt_check_int(x) (((void)((x) == (celt_int32)0)), (celt_int32)(x)) -#define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (CELTMode**)(ptr))) +#define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr))) #define _celt_check_int_ptr(ptr) ((ptr) + ((ptr) - (int*)(ptr))) /* Error codes */ @@ -71,10 +71,8 @@ extern "C" { /** Memory allocation has failed */ #define CELT_ALLOC_FAIL -7 -/* Requests */ -#define CELT_GET_MODE_REQUEST 1 -/** Get the CELTMode used by an encoder or decoder */ -#define CELT_GET_MODE(x) CELT_GET_MODE_REQUEST, _celt_check_mode_ptr_ptr(x) + +/* Encoder/decoder Requests */ #define CELT_SET_COMPLEXITY_REQUEST 2 /** Controls the complexity from 0-10 (int) */ @@ -92,8 +90,8 @@ extern "C" { /** Set the target VBR rate in bits per second(int); 0=CBR (default) */ #define CELT_SET_BITRATE(x) CELT_SET_BITRATE_REQUEST, _celt_check_int(x) -/** Reset the encoder/decoder memories to zero*/ #define CELT_RESET_STATE_REQUEST 8 +/** Reset the encoder/decoder memories to zero*/ #define CELT_RESET_STATE CELT_RESET_STATE_REQUEST #define CELT_SET_VBR_CONSTRAINT_REQUEST 10 @@ -111,6 +109,9 @@ extern "C" { #define CELT_GET_LOOKAHEAD_REQUEST 17 #define CELT_GET_LOOKAHEAD(x) CELT_GET_LOOKAHEAD_REQUEST, _celt_check_int_ptr(x) +#define CELT_SET_CHANNELS_REQUEST 18 +#define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, _celt_check_int(x) + /* Internal */ #define CELT_SET_START_BAND_REQUEST 10000 #define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, _celt_check_int(x) @@ -118,11 +119,7 @@ extern "C" { #define CELT_SET_END_BAND_REQUEST 10001 #define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, _celt_check_int(x) -#define CELT_SET_CHANNELS_REQUEST 10002 -#define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, _celt_check_int(x) -#define CELT_SET_SIGNALLING_REQUEST 10003 -#define CELT_SET_SIGNALLING(x) CELT_SET_SIGNALLING_REQUEST, _celt_check_int(x) /** Contains the state of an encoder. One encoder state is needed for each stream. It is initialised once at the beginning of the diff --git a/libcelt/modes.h b/libcelt/modes.h index 8ea39e93eb2e8393c4ebdb5c2e1e991ebc75e111..9e0384e2417152188662369b98085d331e5dbdff 100644 --- a/libcelt/modes.h +++ b/libcelt/modes.h @@ -100,6 +100,13 @@ struct CELTMode { #endif #ifdef OPUS_BUILD +#define CELT_SET_SIGNALLING_REQUEST 10003 +#define CELT_SET_SIGNALLING(x) CELT_SET_SIGNALLING_REQUEST, _celt_check_int(x) + +#define CELT_GET_MODE_REQUEST 10004 +/** Get the CELTMode used by an encoder or decoder */ +#define CELT_GET_MODE(x) CELT_GET_MODE_REQUEST, _celt_check_mode_ptr_ptr(x) + /* Prototypes for _ec versions of the encoder/decoder calls (not public) */ int celt_encode_with_ec(CELTEncoder * restrict st, const celt_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc); int celt_encode_with_ec_float(CELTEncoder * restrict st, const float * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc);