opus.h   opus.h 
skipping to change at line 35 skipping to change at line 35
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef OPUS_H #ifndef OPUS_H
#define OPUS_H #define OPUS_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#if defined(__GNUC__) && defined(CELT_BUILD) #if defined(__GNUC__) && defined(OPUS_BUILD)
#define EXPORT __attribute__ ((visibility ("default"))) #define OPUS_EXPORT __attribute__ ((visibility ("default")))
#elif defined(WIN32) #elif defined(WIN32)
#define EXPORT __declspec(dllexport) #define OPUS_EXPORT __declspec(dllexport)
#else #else
#define EXPORT #define OPUS_EXPORT
#endif #endif
#define __check_int(x) (((void)((x) == (int)0)), (int)(x)) #define __check_int(x) (((void)((x) == (int)0)), (int)(x))
#define __check_int_ptr(ptr) ((ptr) + ((ptr) - (int*)(ptr))) #define __check_int_ptr(ptr) ((ptr) + ((ptr) - (int*)(ptr)))
/* Error codes */ /* Error codes */
/** No error */ /** No error */
#define OPUS_OK 0 #define OPUS_OK 0
/** An (or more) invalid argument (e.g. out of range) */ /** An (or more) invalid argument (e.g. out of range) */
#define OPUS_BAD_ARG -1 #define OPUS_BAD_ARG -1
/** The mode struct passed is invalid */ /** The mode struct passed is invalid */
#define OPUS_INVALID_MODE -2 #define OPUS_BUFFER_TOO_SMALL -2
/** An internal error was detected */ /** An internal error was detected */
#define OPUS_INTERNAL_ERROR -3 #define OPUS_INTERNAL_ERROR -3
/** The data passed (e.g. compressed data to decoder) is corrupted */ /** The data passed (e.g. compressed data to decoder) is corrupted */
#define OPUS_CORRUPTED_DATA -4 #define OPUS_CORRUPTED_DATA -4
/** Invalid/unsupported request number */ /** Invalid/unsupported request number */
#define OPUS_UNIMPLEMENTED -5 #define OPUS_UNIMPLEMENTED -5
/** An encoder or decoder structure is invalid or already freed */ /** An encoder or decoder structure is invalid or already freed */
#define OPUS_INVALID_STATE -6 #define OPUS_INVALID_STATE -6
/** Memory allocation has failed */ /** Memory allocation has failed */
#define OPUS_ALLOC_FAIL -7 #define OPUS_ALLOC_FAIL -7
#define OPUS_TEST_RANGE_CODER_STATE 1 #define OPUS_TEST_RANGE_CODER_STATE 1
#define OPUS_MODE_AUTO 2000 #define OPUS_BITRATE_AUTO -1
#define OPUS_MODE_VOICE 2001
#define OPUS_MODE_AUDIO 2002 #define OPUS_APPLICATION_VOIP 2000
#define OPUS_APPLICATION_AUDIO 2001
#define MODE_SILK_ONLY 1000
#define MODE_HYBRID 1001 #define OPUS_SIGNAL_AUTO 3000
#define MODE_CELT_ONLY 1002 #define OPUS_SIGNAL_VOICE 3001
#define OPUS_SIGNAL_MUSIC 3002
#define BANDWIDTH_AUTO 1100
#define BANDWIDTH_NARROWBAND 1101 #define MODE_SILK_ONLY 1000
#define BANDWIDTH_MEDIUMBAND 1102 #define MODE_HYBRID 1001
#define BANDWIDTH_WIDEBAND 1103 #define MODE_CELT_ONLY 1002
#define BANDWIDTH_SUPERWIDEBAND 1104
#define BANDWIDTH_FULLBAND 1105 #define OPUS_BANDWIDTH_AUTO 1100
#define OPUS_BANDWIDTH_NARROWBAND 1101
#define OPUS_BANDWIDTH_MEDIUMBAND 1102
#define OPUS_BANDWIDTH_WIDEBAND 1103
#define OPUS_BANDWIDTH_SUPERWIDEBAND 1104
#define OPUS_BANDWIDTH_FULLBAND 1105
#define OPUS_SET_MODE_REQUEST 0 #define OPUS_SET_MODE_REQUEST 0
#define OPUS_SET_MODE(x) OPUS_SET_MODE_REQUEST, __check_int(x) #define OPUS_SET_MODE(x) OPUS_SET_MODE_REQUEST, __check_int(x)
#define OPUS_GET_MODE_REQUEST 1 #define OPUS_GET_MODE_REQUEST 1
#define OPUS_GET_MODE(x) OPUS_GET_MODE_REQUEST, __check_int_ptr(x) #define OPUS_GET_MODE(x) OPUS_GET_MODE_REQUEST, __check_int_ptr(x)
#define OPUS_SET_BITRATE_REQUEST 2 #define OPUS_SET_BITRATE_REQUEST 2
#define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __check_int(x) #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __check_int(x)
#define OPUS_GET_BITRATE_REQUEST 3 #define OPUS_GET_BITRATE_REQUEST 3
#define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __check_int_ptr(x) #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __check_int_ptr(x)
skipping to change at line 131 skipping to change at line 136
#define OPUS_SET_VOICE_RATIO_REQUEST 18 #define OPUS_SET_VOICE_RATIO_REQUEST 18
#define OPUS_SET_VOICE_RATIO(x) OPUS_SET_VOICE_RATIO_REQUEST, __check_int(x ) #define OPUS_SET_VOICE_RATIO(x) OPUS_SET_VOICE_RATIO_REQUEST, __check_int(x )
#define OPUS_GET_VOICE_RATIO_REQUEST 19 #define OPUS_GET_VOICE_RATIO_REQUEST 19
#define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __check_int_p tr(x) #define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __check_int_p tr(x)
#define OPUS_SET_VBR_CONSTRAINT_REQUEST 20 #define OPUS_SET_VBR_CONSTRAINT_REQUEST 20
#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __check _int(x) #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __check _int(x)
#define OPUS_GET_VBR_CONSTRAINT_REQUEST 21 #define OPUS_GET_VBR_CONSTRAINT_REQUEST 21
#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __check _int_ptr(x) #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __check _int_ptr(x)
#define OPUS_SET_FORCE_MONO_REQUEST 22
#define OPUS_SET_FORCE_MONO(x) OPUS_SET_FORCE_MONO_REQUEST, __check_int(x)
#define OPUS_GET_FORCE_MONO_REQUEST 23
#define OPUS_GET_FORCE_MONO(x) OPUS_GET_FORCE_MONO_REQUEST, __check_int_ptr
(x)
#define OPUS_SET_SIGNAL_REQUEST 24
#define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __check_int(x)
#define OPUS_GET_SIGNAL_REQUEST 25
#define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __check_int_ptr(x)
typedef struct OpusEncoder OpusEncoder; typedef struct OpusEncoder OpusEncoder;
typedef struct OpusDecoder OpusDecoder; typedef struct OpusDecoder OpusDecoder;
OpusEncoder *opus_encoder_create(int Fs, int channels); /*
* There are two coding modes:
* OPUS_MODE_VOICE gives best quality at a given bitrate for voice signals.
It enhances the
* input signal by high-pass filtering and emphasizing formants and harm
onics. Optionally
* it includes in-band forward error correction to protect against packe
t loss. Use this
* mode for typical VoIP applications. Because of the enhancement, even
at high bitrates
* the output may sound different from the input.
* OPUS_MODE_AUDIO gives best quality at a given bitrate for most non-voice
signals like music.
* Use this mode for music and mixed (music/voice) content, and applicat
ions requiring less
* than 15 ms of coding delay.
*/
/* Returns initialized encoder state */
OPUS_EXPORT OpusEncoder *opus_encoder_create(
int Fs, /* Sampling rate of input signal (Hz) */
int channels, /* Number of channels (1/2) in input signal
*/
int application /* Coding mode (OPUS_APPLICATION_VOI
P/OPUS_APPLICATION_AUDIO) */
);
OPUS_EXPORT OpusEncoder *opus_encoder_init(
OpusEncoder *st, /* Encoder state */
int Fs, /* Sampling rate of input signal (Hz) */
int channels, /* Number of channels (1/2) in input signal
*/
int application /* Coding mode (OPUS_APPLICATION_VOI
P/OPUS_APPLICATION_AUDIO) */
);
/* returns length of data payload (in bytes) */ /* returns length of data payload (in bytes) */
int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, OPUS_EXPORT int opus_encode(
unsigned char *data, int max_data_bytes); OpusEncoder *st, /* Encoder state */
const short *pcm, /* Input signal (interleaved if 2 channels)
void opus_encoder_destroy(OpusEncoder *st); . length is frame_size*channels */
int frame_size, /* Number of samples per frame of input sig
int opus_encoder_ctl(OpusEncoder *st, int request, ...); nal */
unsigned char *data, /* Output payload (no more than max_data_by
OpusDecoder *opus_decoder_create(int Fs, int channels); tes long) */
int max_data_bytes /* Allocated memory for payload; don't use
for controlling bitrate */
);
OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st);
OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...);
OPUS_EXPORT OpusDecoder *opus_decoder_create(
int Fs, /* Sampling rate of output signal (Hz) */
int channels /* Number of channels (1/2) in output signa
l */
);
OPUS_EXPORT OpusDecoder *opus_decoder_init(OpusDecoder *st,
int Fs, /* Sampling rate of output signal (Hz) */
int channels /* Number of channels (1/2) in output signa
l */
);
/* returns (CELT) error code */ /* returns (CELT) error code */
int opus_decode(OpusDecoder *st, const unsigned char *data, int len, OPUS_EXPORT int opus_decode(
short *pcm, int frame_size, int decode_fec); OpusDecoder *st, /* Decoder state */
const unsigned char *data, /* Input payload. Use a NULL pointer to ind
int opus_decoder_ctl(OpusDecoder *st, int request, ...); icate packet loss */
int len, /* Number of bytes in payload */
void opus_decoder_destroy(OpusDecoder *st); short *pcm, /* Output signal (interleaved if 2 channels
). length is frame_size*channels */
int frame_size, /* Number of samples per frame of input sig
nal */
int decode_fec /* Flag (0/1) to request that any in-band f
orward error correction data be */
/* decoded. If no such data is available th
e frame is decoded as if it were lost. */
);
OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...);
OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st);
OPUS_EXPORT int opus_packet_get_bandwidth(const unsigned char *data);
OPUS_EXPORT int opus_packet_get_samples_per_frame(const unsigned char *data
, int Fs);
OPUS_EXPORT int opus_packet_get_nb_channels(const unsigned char *data);
OPUS_EXPORT int opus_packet_get_nb_frames(const unsigned char packet[], int
len);
OPUS_EXPORT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const u
nsigned char packet[], int len);
int opus_packet_get_bandwidth(const unsigned char *data); OPUS_EXPORT const char *opus_strerror(int error);
int opus_packet_get_samples_per_frame(const unsigned char *data, int Fs);
int opus_packet_get_nb_channels(const unsigned char *data);
int opus_packet_get_nb_frames(const unsigned char packet[], int len);
int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char
packet[], int len);
/* For testing purposes: the encoder and decoder state should always be ide ntical after coding a payload */
#if OPUS_TEST_RANGE_CODER_STATE #if OPUS_TEST_RANGE_CODER_STATE
int opus_encoder_get_final_range(OpusEncoder *st); OPUS_EXPORT int opus_encoder_get_final_range(OpusEncoder *st);
int opus_decoder_get_final_range(OpusDecoder *st); OPUS_EXPORT int opus_decoder_get_final_range(OpusDecoder *st);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* OPUS_H */ #endif /* OPUS_H */
 End of changes. 12 change blocks. 
42 lines changed or deleted 128 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/