Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mark Harris
Opus
Commits
b6f90613
Commit
b6f90613
authored
Oct 05, 2008
by
Jean-Marc Valin
Browse files
celt_encoder_ctl() is a bit more type-safe.
parent
25ec9ac3
Changes
3
Hide whitespace changes
Inline
Side-by-side
libcelt/celt.c
View file @
b6f90613
...
...
@@ -51,6 +51,7 @@
#include
"stack_alloc.h"
#include
"mathops.h"
#include
"float_cast.h"
#include
<stdarg.h>
static
const
celt_word16_t
preemph
=
QCONST16
(
0
.
8
f
,
15
);
...
...
@@ -718,24 +719,34 @@ int celt_encode(CELTEncoder * restrict st, const celt_int16_t * pcm, celt_int16_
}
#endif
int
celt_encoder_ctl
(
CELTEncoder
*
restrict
st
,
int
request
,
celt_int32_t
*
value
)
int
celt_encoder_ctl
(
CELTEncoder
*
restrict
st
,
int
request
,
...
)
{
va_list
ap
;
va_start
(
ap
,
request
);
switch
(
request
)
{
case
CELT_SET_COMPLEXITY
:
case
CELT_SET_COMPLEXITY
_REQUEST
:
{
if
(
*
value
<
0
||
*
value
>
10
)
return
CELT_BAD_ARG
;
if
(
*
value
<=
2
)
int
value
=
va_arg
(
ap
,
int
);
if
(
value
<
0
||
value
>
10
)
goto
bad_arg
;
if
(
value
<=
2
)
st
->
pitch_enabled
=
0
;
else
st
->
pitch_enabled
=
1
;
}
break
;
default:
return
CELT_BAD_REQUEST
;
goto
bad_request
;
}
va_end
(
ap
);
return
CELT_OK
;
bad_arg:
va_end
(
ap
);
return
CELT_BAD_ARG
;
bad_request:
va_end
(
ap
);
return
CELT_UNIMPLEMENTED
;
}
/****************************************************************************/
...
...
libcelt/celt.h
View file @
b6f90613
...
...
@@ -51,6 +51,8 @@ extern "C" {
#define EXPORT
#endif
#define _celt_check_int(x) (((void)((x) == (int)0)), (int)(x))
/* Error codes */
/** No error */
#define CELT_OK 0
...
...
@@ -63,10 +65,12 @@ extern "C" {
/** 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
#define CELT_
UNIMPLEMENTED
-5
/* Requests */
#define CELT_SET_COMPLEXITY 0
/** Controls the complexity from 0-10 (int) */
#define CELT_SET_COMPLEXITY_REQUEST 2
#define CELT_SET_COMPLEXITY(x) CELT_SET_COMPLEXITY_REQUEST, _celt_check_int(x)
/** GET the frame size used in the current mode */
#define CELT_GET_FRAME_SIZE 1000
...
...
@@ -161,7 +165,7 @@ EXPORT int celt_encode(CELTEncoder *st, const celt_int16_t *pcm, celt_int16_t *o
@param value Pointer to a 32-bit int value
@return Error code
*/
EXPORT
int
celt_encoder_ctl
(
CELTEncoder
*
st
,
int
request
,
celt_int32_t
*
value
);
EXPORT
int
celt_encoder_ctl
(
CELTEncoder
*
st
,
int
request
,
...
);
/* Decoder stuff */
...
...
libcelt/modes.c
View file @
b6f90613
...
...
@@ -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_REQUEST
;
return
CELT_
UNIMPLEMENTED
;
}
return
CELT_OK
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment