Commit f3b44ef4 authored by Gregory Maxwell's avatar Gregory Maxwell
Browse files

Add get_mode CTL for the encoder and decoder.

parent 9a44cde2
......@@ -918,6 +918,14 @@ 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_t);
......@@ -1351,6 +1359,14 @@ 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_RESET_STATE:
{
const CELTMode *mode = st->mode;
......@@ -1369,11 +1385,9 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...)
}
va_end(ap);
return CELT_OK;
#if 0 /* Put this back in if you ever need "bad_arg" */
bad_arg:
va_end(ap);
return CELT_BAD_ARG;
#endif
bad_request:
va_end(ap);
return CELT_UNIMPLEMENTED;
......
......@@ -52,6 +52,7 @@ extern "C" {
#endif
#define _celt_check_int(x) (((void)((x) == (celt_int32_t)0)), (celt_int32_t)(x))
#define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (CELTMode**)(ptr)))
/* Error codes */
/** No error */
......@@ -68,6 +69,9 @@ extern "C" {
#define CELT_UNIMPLEMENTED -5
/* 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)
#define CELT_SET_COMPLEXITY_REQUEST 2
/** Controls the complexity from 0-10 (int) */
#define CELT_SET_COMPLEXITY(x) CELT_SET_COMPLEXITY_REQUEST, _celt_check_int(x)
......
Markdown is supported
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