ref: 4923f3f80ecd77e8f3c549a7fca31c4fd83c9c4d
parent: 82c985932fc9d64b84e1d6afe8f76f433ed1d21b
author: Jean-Marc Valin <[email protected]>
date: Wed Oct 26 17:36:57 EDT 2011
Moves the main headers from src/ to include/
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,7 +4,7 @@
SUBDIRS = . celt/tests doc
-INCLUDES = -I$(top_srcdir)/celt -I$(top_srcdir)/silk -I$(top_srcdir)/silk/float -I$(top_srcdir)/silk/fixed
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/celt -I$(top_srcdir)/silk -I$(top_srcdir)/silk/float -I$(top_srcdir)/silk/fixed
include celt_sources.mk
include silk_sources.mk
@@ -22,7 +22,7 @@
libopus_la_SOURCES = $(CELT_SOURCES) $(SILK_SOURCES) $(OPUS_SOURCES)
-pkginclude_HEADERS = src/opus.h src/opus_multistream.h celt/opus_types.h celt/opus_defines.h
+pkginclude_HEADERS = include/opus.h include/opus_multistream.h include/opus_types.h include/opus_defines.h
noinst_HEADERS = $(OPUS_HEAD) $(SILK_HEAD) $(CELT_HEAD)
@@ -41,17 +41,17 @@
opus_compare_SOURCES = src/opus_compare.c
opus_compare_LDADD = -lm
-test_opus_api_SOURCES = tests/test_opus_api.c
+test_opus_api_SOURCES = tests/test_opus_api.c tests/test_opus_common.h
test_opus_api_LDADD = libopus.la -lm
-test_opus_encode_SOURCES = tests/test_opus_encode.c
+test_opus_encode_SOURCES = tests/test_opus_encode.c tests/test_opus_common.h
test_opus_encode_LDADD = libopus.la -lm
-test_opus_decode_SOURCES = tests/test_opus_decode.c
+test_opus_decode_SOURCES = tests/test_opus_decode.c tests/test_opus_common.h
test_opus_decode_LDADD = libopus.la -lm
if CUSTOM_MODES
-pkginclude_HEADERS += celt/opus_custom.h
+pkginclude_HEADERS += include/opus_custom.h
noinst_PROGRAMS += opus_custom_demo
opus_custom_demo_SOURCES = celt/opus_custom_demo.c
opus_custom_demo_LDADD = libopus.la -lm
--- a/Makefile.draft
+++ b/Makefile.draft
@@ -53,7 +53,8 @@
CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
endif
-CINCLUDES += silk/ \
+CINCLUDES += include/ \
+ silk/ \
silk/float/ \
silk/fixed/ \
celt/ \
--- a/celt/opus_custom.h
+++ /dev/null
@@ -1,213 +1,0 @@
-/* Copyright (c) 2007-2008 CSIRO
- Copyright (c) 2007-2009 Xiph.Org Foundation
- Copyright (c) 2008 Gregory Maxwell
- Written by Jean-Marc Valin and Gregory Maxwell */
-/**
- @file celt.h
- @brief Contains all the functions for encoding and decoding audio
- */
-
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef OPUS_CUSTOM_H
-#define OPUS_CUSTOM_H
-
-
-#include "opus_defines.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef CUSTOM_MODES
-#define OPUS_CUSTOM_EXPORT OPUS_EXPORT
-#define OPUS_CUSTOM_EXPORT_STATIC OPUS_EXPORT
-#else
-#define OPUS_CUSTOM_EXPORT
-#ifdef CELT_C
-#define OPUS_CUSTOM_EXPORT_STATIC static inline
-#else
-#define OPUS_CUSTOM_EXPORT_STATIC
-#endif
-#endif
-
-/** Contains the state of an encoder. One encoder state is needed
- for each stream. It is initialised once at the beginning of the
- stream. Do *not* re-initialise the state for every frame.
- @brief Encoder state
- */
-typedef struct OpusCustomEncoder OpusCustomEncoder;
-
-/** State of the decoder. One decoder state is needed for each stream.
- It is initialised once at the beginning of the stream. Do *not*
- re-initialise the state for every frame */
-typedef struct OpusCustomDecoder OpusCustomDecoder;
-
-/** The mode contains all the information necessary to create an
- encoder. Both the encoder and decoder need to be initialised
- with exactly the same mode, otherwise the quality will be very
- bad */
-typedef struct OpusCustomMode OpusCustomMode;
-
-/** Creates a new mode struct. This will be passed to an encoder or
- decoder. The mode MUST NOT BE DESTROYED until the encoders and
- decoders that use it are destroyed as well.
- @param Fs Sampling rate (32000 to 96000 Hz)
- @param frame_size Number of samples (per channel) to encode in each
- packet (even values; 64 - 512)
- @param error Returned error code (if NULL, no error will be returned)
- @return A newly created mode
-*/
-OPUS_CUSTOM_EXPORT OpusCustomMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error);
-
-/** Destroys a mode struct. Only call this after all encoders and
- decoders using this mode are destroyed as well.
- @param mode Mode to be destroyed
-*/
-OPUS_CUSTOM_EXPORT void opus_custom_mode_destroy(OpusCustomMode *mode);
-
-/* Encoder */
-
-OPUS_CUSTOM_EXPORT_STATIC int opus_custom_encoder_get_size(const OpusCustomMode *mode, int channels);
-
-/** Creates a new encoder state. Each stream needs its own encoder
- state (can't be shared across simultaneous streams).
- @param mode Contains all the information about the characteristics of
- * the stream (must be the same characteristics as used for the
- * decoder)
- @param channels Number of channels
- @param error Returns an error code
- @return Newly created encoder state.
-*/
-OPUS_CUSTOM_EXPORT OpusCustomEncoder *opus_custom_encoder_create(const OpusCustomMode *mode, int channels, int *error);
-
-OPUS_CUSTOM_EXPORT_STATIC int opus_custom_encoder_init(OpusCustomEncoder *st, const OpusCustomMode *mode, int channels);
-
-/** Destroys a an encoder state.
- @param st Encoder state to be destroyed
- */
-OPUS_CUSTOM_EXPORT void opus_custom_encoder_destroy(OpusCustomEncoder *st);
-
-/** Encodes a frame of audio.
- @param st Encoder state
- @param pcm PCM audio in float format, with a normal range of +/-1.0.
- * Samples with a range beyond +/-1.0 are supported but will
- * be clipped by decoders using the integer API and should
- * only be used if it is known that the far end supports
- * extended dynmaic range. There must be exactly
- * frame_size samples per channel.
- @param compressed The compressed data is written here. This may not alias pcm or
- * optional_synthesis.
- @param nbCompressedBytes Maximum number of bytes to use for compressing the frame
- * (can change from one frame to another)
- @return Number of bytes written to "compressed". Will be the same as
- * "nbCompressedBytes" unless the stream is VBR and will never be larger.
- * If negative, an error has occurred (see error codes). It is IMPORTANT that
- * the length returned be somehow transmitted to the decoder. Otherwise, no
- * decoding is possible.
-*/
-OPUS_CUSTOM_EXPORT int opus_custom_encode_float(OpusCustomEncoder *st, const float *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes);
-
-/** Encodes a frame of audio.
- @param st Encoder state
- @param pcm PCM audio in signed 16-bit format (native endian). There must be
- * exactly frame_size samples per channel.
- @param compressed The compressed data is written here. This may not alias pcm or
- * optional_synthesis.
- @param nbCompressedBytes Maximum number of bytes to use for compressing the frame
- * (can change from one frame to another)
- @return Number of bytes written to "compressed". Will be the same as
- * "nbCompressedBytes" unless the stream is VBR and will never be larger.
- * If negative, an error has occurred (see error codes). It is IMPORTANT that
- * the length returned be somehow transmitted to the decoder. Otherwise, no
- * decoding is possible.
- */
-OPUS_CUSTOM_EXPORT int opus_custom_encode(OpusCustomEncoder *st, const opus_int16 *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes);
-
-/** 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
-*/
-OPUS_CUSTOM_EXPORT int opus_custom_encoder_ctl(OpusCustomEncoder * restrict st, int request, ...);
-
-/* Decoder */
-
-OPUS_CUSTOM_EXPORT_STATIC int opus_custom_decoder_get_size(const OpusCustomMode *mode, int channels);
-
-/** Creates a new decoder state. Each stream needs its own decoder state (can't
- be shared across simultaneous streams).
- @param mode Contains all the information about the characteristics of the
- stream (must be the same characteristics as used for the encoder)
- @param channels Number of channels
- @param error Returns an error code
- @return Newly created decoder state.
- */
-OPUS_CUSTOM_EXPORT OpusCustomDecoder *opus_custom_decoder_create(const OpusCustomMode *mode, int channels, int *error);
-
-OPUS_CUSTOM_EXPORT_STATIC int opus_custom_decoder_init(OpusCustomDecoder *st, const OpusCustomMode *mode, int channels);
-
-/** Destroys a a decoder state.
- @param st Decoder state to be destroyed
- */
-OPUS_CUSTOM_EXPORT void opus_custom_decoder_destroy(OpusCustomDecoder *st);
-
-/** Decodes a frame of audio.
- @param st Decoder state
- @param data Compressed data produced by an encoder
- @param len Number of bytes to read from "data". This MUST be exactly the number
- of bytes returned by the encoder. Using a larger value WILL NOT WORK.
- @param pcm One frame (frame_size samples per channel) of decoded PCM will be
- returned here in float format.
- @return Error code.
- */
-OPUS_CUSTOM_EXPORT int opus_custom_decode_float(OpusCustomDecoder *st, const unsigned char *data, int len, float *pcm, int frame_size);
-
-/** Decodes a frame of audio.
- @param st Decoder state
- @param data Compressed data produced by an encoder
- @param len Number of bytes to read from "data". This MUST be exactly the number
- of bytes returned by the encoder. Using a larger value WILL NOT WORK.
- @param pcm One frame (frame_size samples per channel) of decoded PCM will be
- returned here in 16-bit PCM format (native endian).
- @return Error code.
- */
-OPUS_CUSTOM_EXPORT int opus_custom_decode(OpusCustomDecoder *st, const unsigned char *data, int len, opus_int16 *pcm, int frame_size);
-
-/** Query and set decoder parameters
- @param st Decoder state
- @param request Parameter to change or query
- @param value Pointer to a 32-bit int value
- @return Error code
- */
-OPUS_CUSTOM_EXPORT int opus_custom_decoder_ctl(OpusCustomDecoder * restrict st, int request, ...);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OPUS_CUSTOM_H */
--- a/celt/opus_defines.h
+++ /dev/null
@@ -1,407 +1,0 @@
-/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
- Written by Jean-Marc Valin and Koen Vos */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/**
- * @file opus_defines.h
- * @brief Opus reference implementation constants
- */
-
-#ifndef OPUS_DEFINES_H
-#define OPUS_DEFINES_H
-
-#include "opus_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** @defgroup errorcodes Error codes
- * @{
- */
-/** No error @hideinitializer*/
-#define OPUS_OK 0
-/** One or more invalid/out of range arguments @hideinitializer*/
-#define OPUS_BAD_ARG -1
-/** The mode struct passed is invalid @hideinitializer*/
-#define OPUS_BUFFER_TOO_SMALL -2
-/** An internal error was detected @hideinitializer*/
-#define OPUS_INTERNAL_ERROR -3
-/** The compressed data passed is corrupted @hideinitializer*/
-#define OPUS_INVALID_PACKET -4
-/** Invalid/unsupported request number @hideinitializer*/
-#define OPUS_UNIMPLEMENTED -5
-/** An encoder or decoder structure is invalid or already freed @hideinitializer*/
-#define OPUS_INVALID_STATE -6
-/** Memory allocation has failed @hideinitializer*/
-#define OPUS_ALLOC_FAIL -7
-/**@}*/
-
-/** @cond OPUS_INTERNAL_DOC */
-/**Export control for opus functions */
-
-#if defined(__GNUC__) && defined(OPUS_BUILD)
-# define OPUS_EXPORT __attribute__ ((visibility ("default")))
-#elif defined(WIN32)
-# ifdef OPUS_BUILD
-# define OPUS_EXPORT __declspec(dllexport)
-# else
-# define OPUS_EXPORT __declspec(dllimport)
-# endif
-#else
-# define OPUS_EXPORT
-#endif
-
-/** These are the actual Encoder CTL ID numbers.
- * They should not be used directly by applications. */
-#define OPUS_SET_APPLICATION_REQUEST 4000
-#define OPUS_GET_APPLICATION_REQUEST 4001
-#define OPUS_SET_BITRATE_REQUEST 4002
-#define OPUS_GET_BITRATE_REQUEST 4003
-#define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004
-#define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005
-#define OPUS_SET_VBR_REQUEST 4006
-#define OPUS_GET_VBR_REQUEST 4007
-#define OPUS_SET_BANDWIDTH_REQUEST 4008
-#define OPUS_GET_BANDWIDTH_REQUEST 4009
-#define OPUS_SET_COMPLEXITY_REQUEST 4010
-#define OPUS_GET_COMPLEXITY_REQUEST 4011
-#define OPUS_SET_INBAND_FEC_REQUEST 4012
-#define OPUS_GET_INBAND_FEC_REQUEST 4013
-#define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014
-#define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015
-#define OPUS_SET_DTX_REQUEST 4016
-#define OPUS_GET_DTX_REQUEST 4017
-#define OPUS_SET_VOICE_RATIO_REQUEST 4018
-#define OPUS_GET_VOICE_RATIO_REQUEST 4019
-#define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020
-#define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021
-#define OPUS_SET_FORCE_CHANNELS_REQUEST 4022
-#define OPUS_GET_FORCE_CHANNELS_REQUEST 4023
-#define OPUS_SET_SIGNAL_REQUEST 4024
-#define OPUS_GET_SIGNAL_REQUEST 4025
-#define OPUS_GET_LOOKAHEAD_REQUEST 4027
-/* #define OPUS_RESET_STATE 4028 */
-#define OPUS_GET_FINAL_RANGE_REQUEST 4031
-#define OPUS_GET_PITCH_REQUEST 4033
-
-/* Macros to trigger compilation errors when the wrong types are provided to a CTL */
-#define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
-#define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr)))
-#define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr)))
-/** @endcond */
-
-/** @defgroup ctlvalues Pre-defined values for CTL interface
- * @see genericctls,encoderctls
- * @{
- */
-/* Values for the various encoder CTLs */
-#define OPUS_AUTO -1000 /**<Auto/default setting @hideinitializer*/
-#define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideinitializer*/
-
-/** Best for "standard" VoIP/videoconference applications where listening quality and intelligibility matter most
- * @hideinitializer */
-#define OPUS_APPLICATION_VOIP 2048
-/** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
- * @hideinitializer */
-#define OPUS_APPLICATION_AUDIO 2049
-/** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
- * @hideinitializer */
-#define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051
-
-#define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is voice */
-#define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is music */
-#define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4kHz bandpass @hideinitializer*/
-#define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6kHz bandpass @hideinitializer*/
-#define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8kHz bandpass @hideinitializer*/
-#define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12kHz bandpass @hideinitializer*/
-#define OPUS_BANDWIDTH_FULLBAND 1105 /**<20kHz bandpass @hideinitializer*/
-
-/**@}*/
-
-
-/** @defgroup encoderctls Encoder related CTLs
- * @see genericctls,opusencoder
- * @{
- */
-
-/** Configures the encoder's computational complexity.
- * The supported range is 0-10 inclusive with 10 representing the highest complexity.
- * The default value is 10.
- * @param[in] x <tt>int</tt>: 0-10, inclusive
- * @hideinitializer */
-#define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x)
-/** Gets the encoder's complexity configuration, @see OPUS_SET_COMPLEXITY
- * @param[out] x <tt>int*</tt>: 0-10, inclusive
- * @hideinitializer */
-#define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures the bitrate in the encoder.
- * Rates from 500 to 512000 bits per second are meaningful as well as the
- * special values OPUS_BITRATE_AUTO and OPUS_BITRATE_MAX.
- * The value OPUS_BITRATE_MAX can be used to cause the codec to use as much rate
- * as it can, which is useful for controlling the rate by adjusting the output
- * buffer size.
- * @param[in] x <tt>opus_int32</tt>: bitrate in bits per second.
- * @hideinitializer */
-#define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x)
-/** Gets the encoder's bitrate configuration, @see OPUS_SET_BITRATE
- * @param[out] x <tt>opus_int32*</tt>: bitrate in bits per second.
- * @hideinitializer */
-#define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures VBR in the encoder.
- * The following values are currently supported:
- * - 0 CBR
- * - 1 VBR (default)
- * The configured bitrate may not be met exactly because frames must
- * be an integer number of bytes in length.
- * @warning Only the MDCT mode of Opus can provide hard CBR behavior.
- * @param[in] x <tt>int</tt>: 0; 1 (default)
- * @hideinitializer */
-#define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x)
-/** Gets the encoder's VBR configuration, @see OPUS_SET_VBR
- * @param[out] x <tt>int*</tt>: 0; 1
- * @hideinitializer */
-#define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures constrained VBR in the encoder.
- * The following values are currently supported:
- * - 0 Unconstrained VBR (default)
- * - 1 Maximum one frame buffering delay assuming transport with a serialization speed of the nominal bitrate
- * This setting is irrelevant when the encoder is in CBR mode.
- * @warning Only the MDCT mode of Opus currently heeds the constraint.
- * Speech mode ignores it completely, hybrid mode may fail to obey it
- * if the LPC layer uses more bitrate than the constraint would have
- * permitted.
- * @param[in] x <tt>int</tt>: 0 (default); 1
- * @hideinitializer */
-#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x)
-/** Gets the encoder's constrained VBR configuration @see OPUS_SET_VBR_CONSTRAINT
- * @param[out] x <tt>int*</tt>: 0; 1
- * @hideinitializer */
-#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures mono/stereo forcing in the encoder.
- * This is useful when the caller knows that the input signal is currently a mono
- * source embedded in a stereo stream.
- * @param[in] x <tt>int</tt>: OPUS_AUTO (default); 1 (forced mono); 2 (forced stereo)
- * @hideinitializer */
-#define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x)
-/** Gets the encoder's forced channel configuration, @see OPUS_SET_FORCE_CHANNELS
- * @param[out] x <tt>int*</tt>: OPUS_AUTO; 0; 1
- * @hideinitializer */
-#define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures the encoder's maximum bandpass allowed, @see OPUS_GET_MAX_BANDWIDTH
- * The supported values are:
- * - OPUS_BANDWIDTH_NARROWBAND 4kHz passband
- * - OPUS_BANDWIDTH_MEDIUMBAND 6kHz passband
- * - OPUS_BANDWIDTH_WIDEBAND 8kHz passband
- * - OPUS_BANDWIDTH_SUPERWIDEBAND 12kHz passband
- * - OPUS_BANDWIDTH_FULLBAND 20kHz passband (default)
- * @param[in] x <tt>int</tt>: Bandwidth value
- * @hideinitializer */
-#define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x)
-
-/** Gets the encoder's configured maximum bandpass allowed, @see OPUS_SET_MAX_BANDWIDTH
- * @param[out] x <tt>int*</tt>: Bandwidth value
- * @hideinitializer */
-#define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures the encoder's bandpass, @see OPUS_GET_BANDWIDTH
- * The supported values are:
- * - OPUS_AUTO (default)
- * - OPUS_BANDWIDTH_NARROWBAND 4kHz passband
- * - OPUS_BANDWIDTH_MEDIUMBAND 6kHz passband
- * - OPUS_BANDWIDTH_WIDEBAND 8kHz passband
- * - OPUS_BANDWIDTH_SUPERWIDEBAND 12kHz passband
- * - OPUS_BANDWIDTH_FULLBAND 20kHz passband
- * @param[in] x <tt>int</tt>: Bandwidth value
- * @hideinitializer */
-#define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x)
-
-/** Configures the type of signal being encoded.
- * This is a hint which helps the encoder's mode selection.
- * The supported values are:
- * - OPUS_SIGNAL_AUTO (default)
- * - OPUS_SIGNAL_VOICE
- * - OPUS_SIGNAL_MUSIC
- * @param[in] x <tt>int</tt>: Signal type
- * @hideinitializer */
-#define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x)
-/** Gets the encoder's configured signal type, @see OPUS_SET_SIGNAL
- *
- * @param[out] x <tt>int*</tt>: Signal type
- * @hideinitializer */
-#define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures the encoder's expected percentage of voice
- * opposed to music or other signals.
- *
- * @note This interface is currently more aspiration than actuality. It's
- * ultimately expected to bias an automatic signal classifier, but it currently
- * just shifts the static bitrate to mode mapping around a little bit.
- *
- * @param[in] x <tt>int</tt>: Voice percentage in the range 0-100, inclusive.
- * @hideinitializer */
-#define OPUS_SET_VOICE_RATIO(x) OPUS_SET_VOICE_RATIO_REQUEST, __opus_check_int(x)
-/** Gets the encoder's configured voice ratio value, @see OPUS_SET_VOICE_RATIO
- *
- * @param[out] x <tt>int*</tt>: Voice percentage in the range 0-100, inclusive.
- * @hideinitializer */
-#define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures the encoder's intended application.
- * The initial value is a mandatory argument to the encoder_create function.
- * The supported values are:
- * - OPUS_APPLICATION_VOIP Process signal for improved speech intelligibility
- * - OPUS_APPLICATION_AUDIO Favor faithfulness to the original input
- * @param[in] x <tt>int</tt>: Application value
- * @hideinitializer */
-#define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x)
-/** Gets the encoder's configured application, @see OPUS_SET_APPLICATION
- *
- * @param[out] x <tt>int*</tt>: Application value
- * @hideinitializer */
-#define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x)
-
-/** Gets the total samples of delay added by the entire codec.
- * This can be queried by the encoder and then the provided number of samples can be
- * skipped on from the start of the decoder's output to provide time aligned input
- * and output. From the perspective of a decoding application the real data begins this many
- * samples late.
- *
- * The decoder contribution to this delay is identical for all decoders, but the
- * encoder portion of the delay may vary from implementation to implementation,
- * version to version, or even depend on the encoder's initial configuration.
- * Applications needing delay compensation should call this CTL rather than
- * hard-coding a value.
- * @param[out] x <tt>int*</tt>: Number of lookahead samples
- * @hideinitializer */
-#define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures the encoder's use of inband forward error correction.
- * @note This is only applicable to the LPC layer
- *
- * @param[in] x <tt>int</tt>: FEC flag, 0 (disabled) is default
- * @hideinitializer */
-#define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
-/** Gets encoder's configured use of inband forward error correction, @see OPUS_SET_INBAND_FEC
- *
- * @param[out] x <tt>int*</tt>: FEC flag
- * @hideinitializer */
-#define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures the encoder's expected packet loss percentage.
- * Higher values with trigger progressively more loss resistant behavior in the encoder
- * at the expense of quality at a given bitrate in the lossless case, but greater quality
- * under loss.
- *
- * @param[in] x <tt>int</tt>: Loss percentage in the range 0-100, inclusive.
- * @hideinitializer */
-#define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x)
-/** Gets the encoder's configured packet loss percentage, @see OPUS_SET_PACKET_LOSS_PERC
- *
- * @param[out] x <tt>int*</tt>: Loss percentage in the range 0-100, inclusive.
- * @hideinitializer */
-#define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x)
-
-/** Configures the encoder's use of discontinuous transmission.
- * @note This is only applicable to the LPC layer
- *
- * @param[in] x <tt>int</tt>: DTX flag, 0 (disabled) is default
- * @hideinitializer */
-#define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x)
-/** Gets encoder's configured use of discontinuous transmission, @see OPUS_SET_DTX
- *
- * @param[out] x <tt>int*</tt>: DTX flag
- * @hideinitializer */
-#define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x)
-/**@}*/
-
-/** @defgroup genericctls Generic CTLs
- * @see opus_encoder_ctl,opusencoder,opusdecoder
- * @{
- */
-
-/** Resets the codec state to be equivalent to a freshly initialized state.
- * This should be called when switching streams in order to prevent
- * the back to back decoding from giving different results from
- * one at a time decoding.
- * @hideinitializer */
-#define OPUS_RESET_STATE 4028
-
-/** Gets the final state of the codec's entropy coder.
- * This is used for testing purposes,
- * The encoder and decoder state should be identical after coding a payload
- * (assuming no data corruption or software bugs)
- *
- * @param[out] x <tt>opus_uint32*</tt>: Entropy coder state
- *
- * @hideinitializer */
-#define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x)
-
-/** Gets the pitch of the last decoded frame, if available.
- * This can be used for any post-processing algorithm requiring the use of pitch,
- * e.g. time stretching/shortening. If the last frame was not voiced, or if the
- * pitch was not coded in the frame, then zero is returned.
- *
- * @param[out] x <tt>opus_int32*</tt>: pitch period at 48 kHz (or 0 if not available)
- *
- * @hideinitializer */
-#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x)
-
-/** Gets the encoder's configured bandpass or the decoder's last bandpass, @see OPUS_SET_BANDWIDTH
- * @param[out] x <tt>int*</tt>: Bandwidth value
- * @hideinitializer */
-#define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
-
-/**@}*/
-
-/** @defgroup libinfo Opus library information functions
- * @{
- */
-
-/** Converts an opus error code into a human readable string.
- *
- * @param[in] error <tt>int</tt>: Error number
- * @returns Error string
- */
-OPUS_EXPORT const char *opus_strerror(int error);
-
-/** Gets the libopus version string.
- *
- * @returns Version string
- */
-OPUS_EXPORT const char *opus_get_version_string(void);
-/**@}*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OPUS_DEFINES_H */
--- a/celt/opus_types.h
+++ /dev/null
@@ -1,159 +1,0 @@
-/* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */
-/* Modified by Jean-Marc Valin */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-/* opus_types.h taken from libogg */
-
-/**
- @file opus_types.h
- @brief Opus reference implementation types
-*/
-#ifndef _OPUS_TYPES_H
-#define _OPUS_TYPES_H
-
-/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */
-#if (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H))
-#include <stdint.h>
-
- typedef int16_t opus_int16;
- typedef uint16_t opus_uint16;
- typedef int32_t opus_int32;
- typedef uint32_t opus_uint32;
-#elif defined(_WIN32)
-
-# if defined(__CYGWIN__)
-# include <_G_config.h>
- typedef _G_int32_t opus_int32;
- typedef _G_uint32_t opus_uint32;
- typedef _G_int16 opus_int16;
- typedef _G_uint16 opus_uint16;
-# elif defined(__MINGW32__)
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
-# elif defined(__MWERKS__)
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
-# else
- /* MSVC/Borland */
- typedef __int32 opus_int32;
- typedef unsigned __int32 opus_uint32;
- typedef __int16 opus_int16;
- typedef unsigned __int16 opus_uint16;
-# endif
-
-#elif defined(__MACOS__)
-
-# include <sys/types.h>
- typedef SInt16 opus_int16;
- typedef UInt16 opus_uint16;
- typedef SInt32 opus_int32;
- typedef UInt32 opus_uint32;
-
-#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
-
-# include <sys/types.h>
- typedef int16_t opus_int16;
- typedef u_int16_t opus_uint16;
- typedef int32_t opus_int32;
- typedef u_int32_t opus_uint32;
-
-#elif defined(__BEOS__)
-
- /* Be */
-# include <inttypes.h>
- typedef int16 opus_int16;
- typedef u_int16 opus_uint16;
- typedef int32_t opus_int32;
- typedef u_int32_t opus_uint32;
-
-#elif defined (__EMX__)
-
- /* OS/2 GCC */
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
-
-#elif defined (DJGPP)
-
- /* DJGPP */
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
-
-#elif defined(R5900)
-
- /* PS2 EE */
- typedef int opus_int32;
- typedef unsigned opus_uint32;
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
-
-#elif defined(__SYMBIAN32__)
-
- /* Symbian GCC */
- typedef signed short opus_int16;
- typedef unsigned short opus_uint16;
- typedef signed int opus_int32;
- typedef unsigned int opus_uint32;
-
-#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
-
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef long opus_int32;
- typedef unsigned long opus_uint32;
-
-#elif defined(CONFIG_TI_C6X)
-
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
-
-#else
-
- /* Give up, take a reasonable guess */
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
-
-#endif
-
-#define opus_int int /* used for counters etc; at least 16 bits */
-#define opus_int64 long long
-#define opus_int8 signed char
-
-#define opus_uint unsigned int /* used for counters etc; at least 16 bits */
-#define opus_uint64 unsigned long long
-#define opus_uint8 unsigned char
-
-#endif /* _OPUS_TYPES_H */
--- a/celt/tests/Makefile.am
+++ b/celt/tests/Makefile.am
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_srcdir)/celt
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/celt
METASOURCES = AUTO
TESTS = type-test ectest cwrs32-test dft-test laplace-test mdct-test mathops-test rotation-test
--- a/celt_headers.txt
+++ b/celt_headers.txt
@@ -2,8 +2,8 @@
celt/arch.h \
celt/bands.h \
celt/celt.h \
-celt/opus_types.h \
-celt/opus_defines.h \
+include/opus_types.h \
+include/opus_defines.h \
celt/cwrs.h \
celt/ecintrin.h \
celt/entcode.h \
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -610,10 +610,10 @@
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = @top_srcdir@/src/opus.h \
- @top_srcdir@/celt/opus_types.h \
- @top_srcdir@/celt/opus_defines.h \
- @top_srcdir@/src/opus_multistream.h
+INPUT = @top_srcdir@/include/opus.h \
+ @top_srcdir@/include/opus_types.h \
+ @top_srcdir@/include/opus_defines.h \
+ @top_srcdir@/include/opus_multistream.h
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,9 +1,9 @@
## Process this file with automake to produce Makefile.in
-DOCINPUTS = $(top_srcdir)/src/opus.h \
- $(top_srcdir)/src/opus_multistream.h \
- $(top_srcdir)/celt/opus_defines.h \
- $(top_srcdir)/celt/opus_types.h
+DOCINPUTS = $(top_srcdir)/include/opus.h \
+ $(top_srcdir)/include/opus_multistream.h \
+ $(top_srcdir)/include/opus_defines.h \
+ $(top_srcdir)/include/opus_types.h
doc_DATA = doxygen-build.stamp
--- a/doc/build_draft.sh
+++ b/doc/build_draft.sh
@@ -16,6 +16,7 @@
mkdir "${destdir}/silk/float"
mkdir "${destdir}/silk/fixed"
mkdir "${destdir}/celt"
+mkdir "${destdir}/include"
for f in `cat "${toplevel}"/opus_sources.mk "${toplevel}"/celt_sources.mk \
"${toplevel}"/silk_sources.mk "${toplevel}"/opus_headers.txt \
"${toplevel}"/celt_headers.txt "${toplevel}"/silk_headers.txt \
@@ -25,7 +26,7 @@
cp -a "${toplevel}"/src/opus_demo.c "${destdir}"/src/
cp -a "${toplevel}"/src/opus_compare.c "${destdir}"/src/
cp -a "${toplevel}"/celt/opus_custom_demo.c "${destdir}"/celt/
-cp -a "${toplevel}"/celt/opus_custom.h "${destdir}"/celt/
+cp -a "${toplevel}"/include/opus_custom.h "${destdir}"/celt/
cp -a "${toplevel}"/Makefile.draft "${destdir}"/Makefile
cp -a "${toplevel}"/opus_sources.mk "${destdir}"/
cp -a "${toplevel}"/celt_sources.mk "${destdir}"/
--- /dev/null
+++ b/include/opus.h
@@ -1,0 +1,508 @@
+/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
+ Written by Jean-Marc Valin and Koen Vos */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * @file opus.h
+ * @brief Opus reference implementation API
+ */
+
+#ifndef OPUS_H
+#define OPUS_H
+
+#include "opus_types.h"
+#include "opus_defines.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @mainpage Opus
+ *
+ * The Opus codec is designed for interactive speech and audio transmission over the Internet.
+ * It is designed by the IETF Codec Working Group and incorporates technology from
+ * Skype's SILK codec and Xiph.Org's CELT codec.
+ *
+ * The Opus codec is designed to handle a wide range of interactive audio applications,
+ * including Voice over IP, videoconferencing, in-game chat, and even remote live music
+ * performances. It can scale from low bit-rate narrowband speech to very high quality
+ * stereo music. Its main features are:
+
+ * @li Sampling rates from 8 to 48 kHz
+ * @li Bit-rates from 6 kb/s 510 kb/s
+ * @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR)
+ * @li Audio bandwidth from narrowband to full-band
+ * @li Support for speech and music
+ * @li Support for mono and stereo
+ * @li Frame sizes from 2.5 ms to 60 ms
+ * @li Good loss robustness and packet loss concealment (PLC)
+ * @li Floating point and fixed-point implementation
+ *
+ * Documentation sections:
+ * @li @ref opusencoder
+ * @li @ref opusdecoder
+ * @li @ref repacketizer
+ * @li @ref libinfo
+ */
+
+/** @defgroup opusencoder Opus Encoder
+ * @{
+ *
+ * Since Opus is a stateful codec, the encoding process starts with creating an encoder
+ * state. This can be done with:
+ *
+ * @code
+ * int error;
+ * OpusEncoder *enc;
+ * enc = opus_encoder_create(Fs, channels, application, &error);
+ * @endcode
+ *
+ * From this point, @c enc can be used for encoding an audio stream. An encoder state
+ * @b must @b not be used for more than one stream at the same time. Similarly, the encoder
+ * state @b must @b not be re-initialized for each frame.
+ *
+ * While opus_encoder_create() allocates memory for the state, it's also possible
+ * to initialize pre-allocated memory:
+ *
+ * @code
+ * int size;
+ * int error;
+ * OpusEncoder *enc;
+ * size = opus_encoder_get_size(channels);
+ * enc = malloc(size);
+ * error = opus_encoder_init(enc, Fs, channels, application);
+ * @endcode
+ *
+ * where opus_encoder_get_size() returns the required size for the encoder state. Note that
+ * future versions of this code may change the size, so no assuptions should be made about it.
+ *
+ * The encoder state is always continuous in memory and only a shallow copy is sufficient
+ * to copy it (e.g. memcpy())
+ *
+ * It is possible to change some of the encoder's settings using the opus_encoder_ctl()
+ * interface. All these settings already default to the recommended value, so they should
+ * only be changed when necessary. The most common settings one may want to change are:
+ *
+ * @code
+ * opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate));
+ * opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity));
+ * opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type));
+ * @endcode
+ *
+ * where
+ *
+ * @arg bitrate is in bits per second (b/s)
+ * @arg complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest
+ * @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or OPUS_SIGNAL_MUSIC
+ *
+ * See @ref encoderctls and @ref genericctls for a complete list of parameters that can be set or queried. Most parameters can be set or changed at any time during a stream.
+ *
+ * To encode a frame, opus_encode() or opus_encode_float() must be called with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data:
+ * @code
+ * len = opus_encode(enc, audio_frame, frame_size, packet, max_packet);
+ * @endcode
+ *
+ * where
+ * <ul>
+ * <li>audio_frame is the audio data in opus_int16 (or float for opus_encode_float())</li>
+ * <li>frame_size is the duration of the frame in samples (per channel)</li>
+ * <li>packet is the byte array to which the compressed data is written</li>
+ * <li>max_packet is the maximum number of bytes that can be written in the packet (1276 bytes is recommended)</li>
+ * </ul>
+ *
+ * opus_encode() and opus_encode_frame() return the number of bytes actually written to the packet.
+ * The return value <b>can be negative</b>, which indicates that an error has occurred. If the return value
+ * is 1 byte, then the packet does not need to be transmitted (DTX).
+ *
+ * Once the encoder state if no longer needed, it can be destroyed with
+ *
+ * @code
+ * opus_encoder_destroy(enc);
+ * @endcode
+ *
+ * If the encoder was created with opus_encoder_init() rather than opus_encoder_create(),
+ * then no action is required aside from potentially freeing the memory that was manually
+ * allocated for it (calling free(enc) for the example above)
+ *
+ */
+
+/** Opus encoder state.
+ * This contains the complete state of an Opus encoder.
+ * It is position independent and can be freely copied.
+ * @see opus_encoder_create,opus_encoder_init
+ */
+typedef struct OpusEncoder OpusEncoder;
+
+OPUS_EXPORT int opus_encoder_get_size(int channels);
+
+/**
+ */
+
+/** Allocates and initializes an encoder state.
+ * There are three coding modes:
+ *
+ * @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voice
+ * signals. It enhances the input signal by high-pass filtering and
+ * emphasizing formants and harmonics. Optionally it includes in-band
+ * forward error correction to protect against packet loss. Use this
+ * mode for typical VoIP applications. Because of the enhancement,
+ * even at high bitrates the output may sound different from the input.
+ *
+ * @ref OPUS_APPLICATION_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, broadcast, and applications requiring less
+ * than 15 ms of coding delay.
+ *
+ * @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that
+ * disables the speech-optimized mode in exchange for slightly reduced delay.
+ *
+ * This is useful when the caller knows that the speech-optimized modes will not be needed (use with caution).
+ * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz)
+ * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input signal
+ * @param [in] application <tt>int</tt>: Coding mode (@ref OPUS_APPLICATION_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY)
+ * @param [out] error <tt>int*</tt>: @ref errorcodes
+ * @note Regardless of the sampling rate and number channels selected, the Opus encoder
+ * can switch to a lower audio audio bandwidth or number of channels if the bitrate
+ * selected is too low. This also means that it is safe to always use 48 kHz stereo input
+ * and let the encoder optimize the encoding.
+ */
+OPUS_EXPORT OpusEncoder *opus_encoder_create(
+ opus_int32 Fs,
+ int channels,
+ int application,
+ int *error
+);
+
+/** Initializes a previously allocated encoder state
+ * The memory pointed to by st must be the size returned by opus_encoder_get_size.
+ * This is intended for applications which use their own allocator instead of malloc.
+ * @see opus_encoder_create(),opus_encoder_get_size()
+ * To reset a previously initialized state use the OPUS_RESET_STATE CTL.
+ * @param [in] st <tt>OpusEncoder*</tt>: Encoder state
+ * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz)
+ * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input signal
+ * @param [in] application <tt>int</tt>: Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY)
+ * @retval OPUS_OK Success or @ref errorcodes
+ */
+OPUS_EXPORT int opus_encoder_init(
+ OpusEncoder *st,
+ opus_int32 Fs,
+ int channels,
+ int application
+);
+
+/** Encodes an Opus frame.
+ * The passed frame_size must an opus frame size for the encoder's sampling rate.
+ * For example, at 48kHz the permitted values are 120, 240, 480, or 960.
+ * Passing in a duration of less than 10ms (480 samples at 48kHz) will
+ * prevent the encoder from using the LPC or hybrid modes.
+ * @param [in] st <tt>OpusEncoder*</tt>: Encoder state
+ * @param [in] pcm <tt>opus_int16*</tt>: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16)
+ * @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
+ * @param [out] data <tt>char*</tt>: Output payload (at least max_data_bytes long)
+ * @param [in] max_data_bytes <tt>int</tt>: Allocated memory for payload; don't use for controlling bitrate
+ * @returns length of the data payload (in bytes) or @ref errorcodes
+ */
+OPUS_EXPORT int opus_encode(
+ OpusEncoder *st,
+ const opus_int16 *pcm,
+ int frame_size,
+ unsigned char *data,
+ int max_data_bytes
+);
+
+/** Encodes an Opus frame from floating point input.
+ * The passed frame_size must an opus frame size for the encoder's sampling rate.
+ * For example, at 48kHz the permitted values are 120, 240, 480, or 960.
+ * Passing in a duration of less than 10ms (480 samples at 48kHz) will
+ * prevent the encoder from using the LPC or hybrid modes.
+ * @param [in] st <tt>OpusEncoder*</tt>: Encoder state
+ * @param [in] pcm <tt>float*</tt>: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(float)
+ * @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
+ * @param [out] data <tt>char*</tt>: Output payload (at least max_data_bytes long)
+ * @param [in] max_data_bytes <tt>int</tt>: Allocated memory for payload; don't use for controlling bitrate
+ * @returns length of the data payload (in bytes) or @ref errorcodes
+ */
+OPUS_EXPORT int opus_encode_float(
+ OpusEncoder *st,
+ const float *pcm,
+ int frame_size,
+ unsigned char *data,
+ int max_data_bytes
+);
+
+/** Frees an OpusEncoder allocated by opus_encoder_create.
+ * @param[in] st <tt>OpusEncoder*</tt>: State to be freed.
+ */
+OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st);
+
+/** Perform a CTL function on an Opus encoder.
+ * @see encoderctls
+ */
+OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...);
+/**@}*/
+
+/** @defgroup opusdecoder Opus Decoder
+ * @{
+ *
+ *
+ * The decoding process also starts with creating a decoder
+ * state. This can be done with:
+ * @code
+ * int error;
+ * OpusDecoder *dec;
+ * dec = opus_decoder_create(Fs, channels, &error);
+ * @endcode
+ * where
+ * @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 48000
+ * @li channels is the number of channels (1 or 2)
+ * @li error will hold the error code in case or failure (or OPUS_OK on success)
+ * @li the return value is a newly created decoder state to be used for decoding
+ *
+ * While opus_decoder_create() allocates memory for the state, it's also possible
+ * to initialize pre-allocated memory:
+ * @code
+ * int size;
+ * int error;
+ * OpusDecoder *dec;
+ * size = opus_decoder_get_size(channels);
+ * dec = malloc(size);
+ * error = opus_decoder_init(dec, Fs, channels);
+ * @endcode
+ * where opus_decoder_get_size() returns the required size for the decoder state. Note that
+ * future versions of this code may change the size, so no assuptions should be made about it.
+ *
+ * The decoder state is always continuous in memory and only a shallow copy is sufficient
+ * to copy it (e.g. memcpy())
+ *
+ * To decode a frame, opus_decode() or opus_decode_float() must be called with a packet of compressed audio data:
+ * @code
+ * frame_size = opus_decode(enc, packet, len, decoded, max_size);
+ * @endcode
+ * where
+ *
+ * @li packet is the byte array containing the compressed data
+ * @li len is the exact number of bytes contained in the packet
+ * @li decoded is the decoded audio data in opus_int16 (or float for opus_decode_float())
+ * @li max_size is the max duration of the frame in samples (per channel) that can fit into the decoded_frame array
+ *
+ * opus_decode() and opus_decode_frame() return the number of samples ()per channel) decoded from the packet.
+ * If that value is negative, then an error has occured. This can occur if the packet is corrupted or if the audio
+ * buffer is too small to hold the decoded audio.
+
+*/
+
+/** Opus decoder state.
+ * This contains the complete state of an Opus decoder.
+ * It is position independent and can be freely copied.
+ * @see opus_decoder_create,opus_decoder_init
+ */
+typedef struct OpusDecoder OpusDecoder;
+
+/** Gets the size of an OpusDecoder structure.
+ * @param [in] channels <tt>int</tt>: Number of channels
+ * @returns size
+ */
+OPUS_EXPORT int opus_decoder_get_size(int channels);
+
+/** Allocates and initializes a decoder state.
+ * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz)
+ * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input signal
+ * @param [out] error <tt>int*</tt>: OPUS_OK Success or @ref errorcodes
+ */
+OPUS_EXPORT OpusDecoder *opus_decoder_create(
+ opus_int32 Fs,
+ int channels,
+ int *error
+);
+
+/** Initializes a previously allocated decoder state.
+ * The state must be the size returned by opus_decoder_get_size.
+ * This is intended for applications which use their own allocator instead of malloc. @see opus_decoder_create,opus_decoder_get_size
+ * To reset a previously initialized state use the OPUS_RESET_STATE CTL.
+ * @param [in] st <tt>OpusDecoder*</tt>: Decoder state.
+ * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz)
+ * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input signal
+ * @retval OPUS_OK Success or @ref errorcodes
+ */
+OPUS_EXPORT int opus_decoder_init(
+ OpusDecoder *st,
+ opus_int32 Fs,
+ int channels
+);
+
+/** Decode an Opus frame
+ * @param [in] st <tt>OpusDecoder*</tt>: Decoder state
+ * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
+ * @param [in] len <tt>int</tt>: Number of bytes in payload*
+ * @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length
+ * is frame_size*channels*sizeof(opus_int16)
+ * @param [in] frame_size Number of samples per channel of available space in *pcm,
+ * if less than the maximum frame size (120ms) some frames can not be decoded
+ * @param [in] decode_fec <tt>int</tt>: Flag (0/1) to request that any in-band forward error correction data be
+ * decoded. If no such data is available the frame is decoded as if it were lost.
+ * @returns Number of decoded samples or @ref errorcodes
+ */
+OPUS_EXPORT int opus_decode(
+ OpusDecoder *st,
+ const unsigned char *data,
+ int len,
+ opus_int16 *pcm,
+ int frame_size,
+ int decode_fec
+);
+
+/** Decode an opus frame with floating point output
+ * @param [in] st <tt>OpusDecoder*</tt>: Decoder state
+ * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
+ * @param [in] len <tt>int</tt>: Number of bytes in payload
+ * @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length
+ * is frame_size*channels*sizeof(float)
+ * @param [in] frame_size Number of samples per channel of available space in *pcm,
+ * if less than the maximum frame size (120ms) some frames can not be decoded
+ * @param [in] decode_fec <tt>int</tt>: Flag (0/1) to request that any in-band forward error correction data be
+ * decoded. If no such data is available the frame is decoded as if it were lost.
+ * @returns Number of decoded samples or @ref errorcodes
+ */
+OPUS_EXPORT int opus_decode_float(
+ OpusDecoder *st,
+ const unsigned char *data,
+ int len,
+ float *pcm,
+ int frame_size,
+ int decode_fec
+);
+
+/** Perform a CTL function on an Opus decoder.
+ * @see decoderctls
+ */
+OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...);
+
+/** Frees an OpusDecoder allocated by opus_decoder_create.
+ * @param[in] st <tt>OpusDecoder*</tt>: State to be freed.
+ */
+OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st);
+
+/** Parse an opus packet into one or more frames.
+ * Opus_decode will perform this operation internally so most applications do
+ * not need to use this function.
+ * This function does not copy the frames, the returned pointers are pointers into
+ * the input packet.
+ * @param [in] data <tt>char*</tt>: Opus packet to be parsed
+ * @param [in] len <tt>int</tt>: size of data
+ * @param [out] out_toc <tt>char*</tt>: TOC pointer
+ * @param [out] frames <tt>char*[48]</tt> encapsulated frames
+ * @param [out] size <tt>short[48]</tt> sizes of the encapsulated frames
+ * @param [out] payload_offset <tt>int*</tt>: returns the position of the payload within the packet (in bytes)
+ * @returns number of frames
+ */
+OPUS_EXPORT int opus_packet_parse(
+ const unsigned char *data,
+ int len,
+ unsigned char *out_toc,
+ const unsigned char *frames[48],
+ short size[48],
+ int *payload_offset
+);
+
+/** Gets the bandwidth of an Opus packet.
+ * @param [in] data <tt>char*</tt>: Opus packet
+ * @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass)
+ * @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass)
+ * @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass)
+ * @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass)
+ * @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass)
+ * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
+ */
+OPUS_EXPORT int opus_packet_get_bandwidth(const unsigned char *data);
+
+/** Gets the number of samples per frame from an Opus packet.
+ * @param [in] data <tt>char*</tt>: Opus packet
+ * @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz
+ * @returns Number of samples per frame
+ * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
+ */
+OPUS_EXPORT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs);
+
+/** Gets the number of channels from an Opus packet.
+ * @param [in] data <tt>char*</tt>: Opus packet
+ * @returns Number of channels
+ * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
+ */
+OPUS_EXPORT int opus_packet_get_nb_channels(const unsigned char *data);
+
+/** Gets the number of frame in an Opus packet.
+ * @param [in] packet <tt>char*</tt>: Opus packet
+ * @param [in] len <tt>int</tt>: Length of packet
+ * @returns Number of frames
+ * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
+ */
+OPUS_EXPORT int opus_packet_get_nb_frames(const unsigned char packet[], int len);
+
+/** Gets the number of samples of an Opus packet.
+ * @param [in] dec <tt>OpusDecoder*</tt>: Decoder state
+ * @param [in] packet <tt>char*</tt>: Opus packet
+ * @param [in] len <tt>int</tt>: Length of packet
+ * @returns Number of samples
+ * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
+ */
+OPUS_EXPORT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], int len);
+/**@}*/
+
+/** @defgroup repacketizer Repacketizer
+ * @{
+ *
+ * The repacketizer can be used to merge multiple Opus packets into a single packet
+ * or alternatively to split Opus packets that have previously been merged.
+ *
+ */
+
+typedef struct OpusRepacketizer OpusRepacketizer;
+
+OPUS_EXPORT int opus_repacketizer_get_size(void);
+
+OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp);
+
+OPUS_EXPORT OpusRepacketizer *opus_repacketizer_create(void);
+
+OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp);
+
+OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, int len);
+
+OPUS_EXPORT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, int maxlen);
+
+OPUS_EXPORT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp);
+
+OPUS_EXPORT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, int maxlen);
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OPUS_H */
--- /dev/null
+++ b/include/opus_custom.h
@@ -1,0 +1,213 @@
+/* Copyright (c) 2007-2008 CSIRO
+ Copyright (c) 2007-2009 Xiph.Org Foundation
+ Copyright (c) 2008 Gregory Maxwell
+ Written by Jean-Marc Valin and Gregory Maxwell */
+/**
+ @file celt.h
+ @brief Contains all the functions for encoding and decoding audio
+ */
+
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef OPUS_CUSTOM_H
+#define OPUS_CUSTOM_H
+
+
+#include "opus_defines.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef CUSTOM_MODES
+#define OPUS_CUSTOM_EXPORT OPUS_EXPORT
+#define OPUS_CUSTOM_EXPORT_STATIC OPUS_EXPORT
+#else
+#define OPUS_CUSTOM_EXPORT
+#ifdef CELT_C
+#define OPUS_CUSTOM_EXPORT_STATIC static inline
+#else
+#define OPUS_CUSTOM_EXPORT_STATIC
+#endif
+#endif
+
+/** Contains the state of an encoder. One encoder state is needed
+ for each stream. It is initialised once at the beginning of the
+ stream. Do *not* re-initialise the state for every frame.
+ @brief Encoder state
+ */
+typedef struct OpusCustomEncoder OpusCustomEncoder;
+
+/** State of the decoder. One decoder state is needed for each stream.
+ It is initialised once at the beginning of the stream. Do *not*
+ re-initialise the state for every frame */
+typedef struct OpusCustomDecoder OpusCustomDecoder;
+
+/** The mode contains all the information necessary to create an
+ encoder. Both the encoder and decoder need to be initialised
+ with exactly the same mode, otherwise the quality will be very
+ bad */
+typedef struct OpusCustomMode OpusCustomMode;
+
+/** Creates a new mode struct. This will be passed to an encoder or
+ decoder. The mode MUST NOT BE DESTROYED until the encoders and
+ decoders that use it are destroyed as well.
+ @param Fs Sampling rate (32000 to 96000 Hz)
+ @param frame_size Number of samples (per channel) to encode in each
+ packet (even values; 64 - 512)
+ @param error Returned error code (if NULL, no error will be returned)
+ @return A newly created mode
+*/
+OPUS_CUSTOM_EXPORT OpusCustomMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error);
+
+/** Destroys a mode struct. Only call this after all encoders and
+ decoders using this mode are destroyed as well.
+ @param mode Mode to be destroyed
+*/
+OPUS_CUSTOM_EXPORT void opus_custom_mode_destroy(OpusCustomMode *mode);
+
+/* Encoder */
+
+OPUS_CUSTOM_EXPORT_STATIC int opus_custom_encoder_get_size(const OpusCustomMode *mode, int channels);
+
+/** Creates a new encoder state. Each stream needs its own encoder
+ state (can't be shared across simultaneous streams).
+ @param mode Contains all the information about the characteristics of
+ * the stream (must be the same characteristics as used for the
+ * decoder)
+ @param channels Number of channels
+ @param error Returns an error code
+ @return Newly created encoder state.
+*/
+OPUS_CUSTOM_EXPORT OpusCustomEncoder *opus_custom_encoder_create(const OpusCustomMode *mode, int channels, int *error);
+
+OPUS_CUSTOM_EXPORT_STATIC int opus_custom_encoder_init(OpusCustomEncoder *st, const OpusCustomMode *mode, int channels);
+
+/** Destroys a an encoder state.
+ @param st Encoder state to be destroyed
+ */
+OPUS_CUSTOM_EXPORT void opus_custom_encoder_destroy(OpusCustomEncoder *st);
+
+/** Encodes a frame of audio.
+ @param st Encoder state
+ @param pcm PCM audio in float format, with a normal range of +/-1.0.
+ * Samples with a range beyond +/-1.0 are supported but will
+ * be clipped by decoders using the integer API and should
+ * only be used if it is known that the far end supports
+ * extended dynmaic range. There must be exactly
+ * frame_size samples per channel.
+ @param compressed The compressed data is written here. This may not alias pcm or
+ * optional_synthesis.
+ @param nbCompressedBytes Maximum number of bytes to use for compressing the frame
+ * (can change from one frame to another)
+ @return Number of bytes written to "compressed". Will be the same as
+ * "nbCompressedBytes" unless the stream is VBR and will never be larger.
+ * If negative, an error has occurred (see error codes). It is IMPORTANT that
+ * the length returned be somehow transmitted to the decoder. Otherwise, no
+ * decoding is possible.
+*/
+OPUS_CUSTOM_EXPORT int opus_custom_encode_float(OpusCustomEncoder *st, const float *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes);
+
+/** Encodes a frame of audio.
+ @param st Encoder state
+ @param pcm PCM audio in signed 16-bit format (native endian). There must be
+ * exactly frame_size samples per channel.
+ @param compressed The compressed data is written here. This may not alias pcm or
+ * optional_synthesis.
+ @param nbCompressedBytes Maximum number of bytes to use for compressing the frame
+ * (can change from one frame to another)
+ @return Number of bytes written to "compressed". Will be the same as
+ * "nbCompressedBytes" unless the stream is VBR and will never be larger.
+ * If negative, an error has occurred (see error codes). It is IMPORTANT that
+ * the length returned be somehow transmitted to the decoder. Otherwise, no
+ * decoding is possible.
+ */
+OPUS_CUSTOM_EXPORT int opus_custom_encode(OpusCustomEncoder *st, const opus_int16 *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes);
+
+/** 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
+*/
+OPUS_CUSTOM_EXPORT int opus_custom_encoder_ctl(OpusCustomEncoder * restrict st, int request, ...);
+
+/* Decoder */
+
+OPUS_CUSTOM_EXPORT_STATIC int opus_custom_decoder_get_size(const OpusCustomMode *mode, int channels);
+
+/** Creates a new decoder state. Each stream needs its own decoder state (can't
+ be shared across simultaneous streams).
+ @param mode Contains all the information about the characteristics of the
+ stream (must be the same characteristics as used for the encoder)
+ @param channels Number of channels
+ @param error Returns an error code
+ @return Newly created decoder state.
+ */
+OPUS_CUSTOM_EXPORT OpusCustomDecoder *opus_custom_decoder_create(const OpusCustomMode *mode, int channels, int *error);
+
+OPUS_CUSTOM_EXPORT_STATIC int opus_custom_decoder_init(OpusCustomDecoder *st, const OpusCustomMode *mode, int channels);
+
+/** Destroys a a decoder state.
+ @param st Decoder state to be destroyed
+ */
+OPUS_CUSTOM_EXPORT void opus_custom_decoder_destroy(OpusCustomDecoder *st);
+
+/** Decodes a frame of audio.
+ @param st Decoder state
+ @param data Compressed data produced by an encoder
+ @param len Number of bytes to read from "data". This MUST be exactly the number
+ of bytes returned by the encoder. Using a larger value WILL NOT WORK.
+ @param pcm One frame (frame_size samples per channel) of decoded PCM will be
+ returned here in float format.
+ @return Error code.
+ */
+OPUS_CUSTOM_EXPORT int opus_custom_decode_float(OpusCustomDecoder *st, const unsigned char *data, int len, float *pcm, int frame_size);
+
+/** Decodes a frame of audio.
+ @param st Decoder state
+ @param data Compressed data produced by an encoder
+ @param len Number of bytes to read from "data". This MUST be exactly the number
+ of bytes returned by the encoder. Using a larger value WILL NOT WORK.
+ @param pcm One frame (frame_size samples per channel) of decoded PCM will be
+ returned here in 16-bit PCM format (native endian).
+ @return Error code.
+ */
+OPUS_CUSTOM_EXPORT int opus_custom_decode(OpusCustomDecoder *st, const unsigned char *data, int len, opus_int16 *pcm, int frame_size);
+
+/** Query and set decoder parameters
+ @param st Decoder state
+ @param request Parameter to change or query
+ @param value Pointer to a 32-bit int value
+ @return Error code
+ */
+OPUS_CUSTOM_EXPORT int opus_custom_decoder_ctl(OpusCustomDecoder * restrict st, int request, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OPUS_CUSTOM_H */
--- /dev/null
+++ b/include/opus_defines.h
@@ -1,0 +1,407 @@
+/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
+ Written by Jean-Marc Valin and Koen Vos */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * @file opus_defines.h
+ * @brief Opus reference implementation constants
+ */
+
+#ifndef OPUS_DEFINES_H
+#define OPUS_DEFINES_H
+
+#include "opus_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup errorcodes Error codes
+ * @{
+ */
+/** No error @hideinitializer*/
+#define OPUS_OK 0
+/** One or more invalid/out of range arguments @hideinitializer*/
+#define OPUS_BAD_ARG -1
+/** The mode struct passed is invalid @hideinitializer*/
+#define OPUS_BUFFER_TOO_SMALL -2
+/** An internal error was detected @hideinitializer*/
+#define OPUS_INTERNAL_ERROR -3
+/** The compressed data passed is corrupted @hideinitializer*/
+#define OPUS_INVALID_PACKET -4
+/** Invalid/unsupported request number @hideinitializer*/
+#define OPUS_UNIMPLEMENTED -5
+/** An encoder or decoder structure is invalid or already freed @hideinitializer*/
+#define OPUS_INVALID_STATE -6
+/** Memory allocation has failed @hideinitializer*/
+#define OPUS_ALLOC_FAIL -7
+/**@}*/
+
+/** @cond OPUS_INTERNAL_DOC */
+/**Export control for opus functions */
+
+#if defined(__GNUC__) && defined(OPUS_BUILD)
+# define OPUS_EXPORT __attribute__ ((visibility ("default")))
+#elif defined(WIN32)
+# ifdef OPUS_BUILD
+# define OPUS_EXPORT __declspec(dllexport)
+# else
+# define OPUS_EXPORT __declspec(dllimport)
+# endif
+#else
+# define OPUS_EXPORT
+#endif
+
+/** These are the actual Encoder CTL ID numbers.
+ * They should not be used directly by applications. */
+#define OPUS_SET_APPLICATION_REQUEST 4000
+#define OPUS_GET_APPLICATION_REQUEST 4001
+#define OPUS_SET_BITRATE_REQUEST 4002
+#define OPUS_GET_BITRATE_REQUEST 4003
+#define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004
+#define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005
+#define OPUS_SET_VBR_REQUEST 4006
+#define OPUS_GET_VBR_REQUEST 4007
+#define OPUS_SET_BANDWIDTH_REQUEST 4008
+#define OPUS_GET_BANDWIDTH_REQUEST 4009
+#define OPUS_SET_COMPLEXITY_REQUEST 4010
+#define OPUS_GET_COMPLEXITY_REQUEST 4011
+#define OPUS_SET_INBAND_FEC_REQUEST 4012
+#define OPUS_GET_INBAND_FEC_REQUEST 4013
+#define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014
+#define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015
+#define OPUS_SET_DTX_REQUEST 4016
+#define OPUS_GET_DTX_REQUEST 4017
+#define OPUS_SET_VOICE_RATIO_REQUEST 4018
+#define OPUS_GET_VOICE_RATIO_REQUEST 4019
+#define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020
+#define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021
+#define OPUS_SET_FORCE_CHANNELS_REQUEST 4022
+#define OPUS_GET_FORCE_CHANNELS_REQUEST 4023
+#define OPUS_SET_SIGNAL_REQUEST 4024
+#define OPUS_GET_SIGNAL_REQUEST 4025
+#define OPUS_GET_LOOKAHEAD_REQUEST 4027
+/* #define OPUS_RESET_STATE 4028 */
+#define OPUS_GET_FINAL_RANGE_REQUEST 4031
+#define OPUS_GET_PITCH_REQUEST 4033
+
+/* Macros to trigger compilation errors when the wrong types are provided to a CTL */
+#define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
+#define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr)))
+#define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr)))
+/** @endcond */
+
+/** @defgroup ctlvalues Pre-defined values for CTL interface
+ * @see genericctls,encoderctls
+ * @{
+ */
+/* Values for the various encoder CTLs */
+#define OPUS_AUTO -1000 /**<Auto/default setting @hideinitializer*/
+#define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideinitializer*/
+
+/** Best for "standard" VoIP/videoconference applications where listening quality and intelligibility matter most
+ * @hideinitializer */
+#define OPUS_APPLICATION_VOIP 2048
+/** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
+ * @hideinitializer */
+#define OPUS_APPLICATION_AUDIO 2049
+/** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
+ * @hideinitializer */
+#define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051
+
+#define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is voice */
+#define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is music */
+#define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4kHz bandpass @hideinitializer*/
+#define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6kHz bandpass @hideinitializer*/
+#define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8kHz bandpass @hideinitializer*/
+#define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12kHz bandpass @hideinitializer*/
+#define OPUS_BANDWIDTH_FULLBAND 1105 /**<20kHz bandpass @hideinitializer*/
+
+/**@}*/
+
+
+/** @defgroup encoderctls Encoder related CTLs
+ * @see genericctls,opusencoder
+ * @{
+ */
+
+/** Configures the encoder's computational complexity.
+ * The supported range is 0-10 inclusive with 10 representing the highest complexity.
+ * The default value is 10.
+ * @param[in] x <tt>int</tt>: 0-10, inclusive
+ * @hideinitializer */
+#define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x)
+/** Gets the encoder's complexity configuration, @see OPUS_SET_COMPLEXITY
+ * @param[out] x <tt>int*</tt>: 0-10, inclusive
+ * @hideinitializer */
+#define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the bitrate in the encoder.
+ * Rates from 500 to 512000 bits per second are meaningful as well as the
+ * special values OPUS_BITRATE_AUTO and OPUS_BITRATE_MAX.
+ * The value OPUS_BITRATE_MAX can be used to cause the codec to use as much rate
+ * as it can, which is useful for controlling the rate by adjusting the output
+ * buffer size.
+ * @param[in] x <tt>opus_int32</tt>: bitrate in bits per second.
+ * @hideinitializer */
+#define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x)
+/** Gets the encoder's bitrate configuration, @see OPUS_SET_BITRATE
+ * @param[out] x <tt>opus_int32*</tt>: bitrate in bits per second.
+ * @hideinitializer */
+#define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures VBR in the encoder.
+ * The following values are currently supported:
+ * - 0 CBR
+ * - 1 VBR (default)
+ * The configured bitrate may not be met exactly because frames must
+ * be an integer number of bytes in length.
+ * @warning Only the MDCT mode of Opus can provide hard CBR behavior.
+ * @param[in] x <tt>int</tt>: 0; 1 (default)
+ * @hideinitializer */
+#define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x)
+/** Gets the encoder's VBR configuration, @see OPUS_SET_VBR
+ * @param[out] x <tt>int*</tt>: 0; 1
+ * @hideinitializer */
+#define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures constrained VBR in the encoder.
+ * The following values are currently supported:
+ * - 0 Unconstrained VBR (default)
+ * - 1 Maximum one frame buffering delay assuming transport with a serialization speed of the nominal bitrate
+ * This setting is irrelevant when the encoder is in CBR mode.
+ * @warning Only the MDCT mode of Opus currently heeds the constraint.
+ * Speech mode ignores it completely, hybrid mode may fail to obey it
+ * if the LPC layer uses more bitrate than the constraint would have
+ * permitted.
+ * @param[in] x <tt>int</tt>: 0 (default); 1
+ * @hideinitializer */
+#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x)
+/** Gets the encoder's constrained VBR configuration @see OPUS_SET_VBR_CONSTRAINT
+ * @param[out] x <tt>int*</tt>: 0; 1
+ * @hideinitializer */
+#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures mono/stereo forcing in the encoder.
+ * This is useful when the caller knows that the input signal is currently a mono
+ * source embedded in a stereo stream.
+ * @param[in] x <tt>int</tt>: OPUS_AUTO (default); 1 (forced mono); 2 (forced stereo)
+ * @hideinitializer */
+#define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x)
+/** Gets the encoder's forced channel configuration, @see OPUS_SET_FORCE_CHANNELS
+ * @param[out] x <tt>int*</tt>: OPUS_AUTO; 0; 1
+ * @hideinitializer */
+#define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's maximum bandpass allowed, @see OPUS_GET_MAX_BANDWIDTH
+ * The supported values are:
+ * - OPUS_BANDWIDTH_NARROWBAND 4kHz passband
+ * - OPUS_BANDWIDTH_MEDIUMBAND 6kHz passband
+ * - OPUS_BANDWIDTH_WIDEBAND 8kHz passband
+ * - OPUS_BANDWIDTH_SUPERWIDEBAND 12kHz passband
+ * - OPUS_BANDWIDTH_FULLBAND 20kHz passband (default)
+ * @param[in] x <tt>int</tt>: Bandwidth value
+ * @hideinitializer */
+#define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x)
+
+/** Gets the encoder's configured maximum bandpass allowed, @see OPUS_SET_MAX_BANDWIDTH
+ * @param[out] x <tt>int*</tt>: Bandwidth value
+ * @hideinitializer */
+#define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's bandpass, @see OPUS_GET_BANDWIDTH
+ * The supported values are:
+ * - OPUS_AUTO (default)
+ * - OPUS_BANDWIDTH_NARROWBAND 4kHz passband
+ * - OPUS_BANDWIDTH_MEDIUMBAND 6kHz passband
+ * - OPUS_BANDWIDTH_WIDEBAND 8kHz passband
+ * - OPUS_BANDWIDTH_SUPERWIDEBAND 12kHz passband
+ * - OPUS_BANDWIDTH_FULLBAND 20kHz passband
+ * @param[in] x <tt>int</tt>: Bandwidth value
+ * @hideinitializer */
+#define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x)
+
+/** Configures the type of signal being encoded.
+ * This is a hint which helps the encoder's mode selection.
+ * The supported values are:
+ * - OPUS_SIGNAL_AUTO (default)
+ * - OPUS_SIGNAL_VOICE
+ * - OPUS_SIGNAL_MUSIC
+ * @param[in] x <tt>int</tt>: Signal type
+ * @hideinitializer */
+#define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured signal type, @see OPUS_SET_SIGNAL
+ *
+ * @param[out] x <tt>int*</tt>: Signal type
+ * @hideinitializer */
+#define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's expected percentage of voice
+ * opposed to music or other signals.
+ *
+ * @note This interface is currently more aspiration than actuality. It's
+ * ultimately expected to bias an automatic signal classifier, but it currently
+ * just shifts the static bitrate to mode mapping around a little bit.
+ *
+ * @param[in] x <tt>int</tt>: Voice percentage in the range 0-100, inclusive.
+ * @hideinitializer */
+#define OPUS_SET_VOICE_RATIO(x) OPUS_SET_VOICE_RATIO_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured voice ratio value, @see OPUS_SET_VOICE_RATIO
+ *
+ * @param[out] x <tt>int*</tt>: Voice percentage in the range 0-100, inclusive.
+ * @hideinitializer */
+#define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's intended application.
+ * The initial value is a mandatory argument to the encoder_create function.
+ * The supported values are:
+ * - OPUS_APPLICATION_VOIP Process signal for improved speech intelligibility
+ * - OPUS_APPLICATION_AUDIO Favor faithfulness to the original input
+ * @param[in] x <tt>int</tt>: Application value
+ * @hideinitializer */
+#define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured application, @see OPUS_SET_APPLICATION
+ *
+ * @param[out] x <tt>int*</tt>: Application value
+ * @hideinitializer */
+#define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x)
+
+/** Gets the total samples of delay added by the entire codec.
+ * This can be queried by the encoder and then the provided number of samples can be
+ * skipped on from the start of the decoder's output to provide time aligned input
+ * and output. From the perspective of a decoding application the real data begins this many
+ * samples late.
+ *
+ * The decoder contribution to this delay is identical for all decoders, but the
+ * encoder portion of the delay may vary from implementation to implementation,
+ * version to version, or even depend on the encoder's initial configuration.
+ * Applications needing delay compensation should call this CTL rather than
+ * hard-coding a value.
+ * @param[out] x <tt>int*</tt>: Number of lookahead samples
+ * @hideinitializer */
+#define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's use of inband forward error correction.
+ * @note This is only applicable to the LPC layer
+ *
+ * @param[in] x <tt>int</tt>: FEC flag, 0 (disabled) is default
+ * @hideinitializer */
+#define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
+/** Gets encoder's configured use of inband forward error correction, @see OPUS_SET_INBAND_FEC
+ *
+ * @param[out] x <tt>int*</tt>: FEC flag
+ * @hideinitializer */
+#define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's expected packet loss percentage.
+ * Higher values with trigger progressively more loss resistant behavior in the encoder
+ * at the expense of quality at a given bitrate in the lossless case, but greater quality
+ * under loss.
+ *
+ * @param[in] x <tt>int</tt>: Loss percentage in the range 0-100, inclusive.
+ * @hideinitializer */
+#define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x)
+/** Gets the encoder's configured packet loss percentage, @see OPUS_SET_PACKET_LOSS_PERC
+ *
+ * @param[out] x <tt>int*</tt>: Loss percentage in the range 0-100, inclusive.
+ * @hideinitializer */
+#define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x)
+
+/** Configures the encoder's use of discontinuous transmission.
+ * @note This is only applicable to the LPC layer
+ *
+ * @param[in] x <tt>int</tt>: DTX flag, 0 (disabled) is default
+ * @hideinitializer */
+#define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x)
+/** Gets encoder's configured use of discontinuous transmission, @see OPUS_SET_DTX
+ *
+ * @param[out] x <tt>int*</tt>: DTX flag
+ * @hideinitializer */
+#define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x)
+/**@}*/
+
+/** @defgroup genericctls Generic CTLs
+ * @see opus_encoder_ctl,opusencoder,opusdecoder
+ * @{
+ */
+
+/** Resets the codec state to be equivalent to a freshly initialized state.
+ * This should be called when switching streams in order to prevent
+ * the back to back decoding from giving different results from
+ * one at a time decoding.
+ * @hideinitializer */
+#define OPUS_RESET_STATE 4028
+
+/** Gets the final state of the codec's entropy coder.
+ * This is used for testing purposes,
+ * The encoder and decoder state should be identical after coding a payload
+ * (assuming no data corruption or software bugs)
+ *
+ * @param[out] x <tt>opus_uint32*</tt>: Entropy coder state
+ *
+ * @hideinitializer */
+#define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x)
+
+/** Gets the pitch of the last decoded frame, if available.
+ * This can be used for any post-processing algorithm requiring the use of pitch,
+ * e.g. time stretching/shortening. If the last frame was not voiced, or if the
+ * pitch was not coded in the frame, then zero is returned.
+ *
+ * @param[out] x <tt>opus_int32*</tt>: pitch period at 48 kHz (or 0 if not available)
+ *
+ * @hideinitializer */
+#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x)
+
+/** Gets the encoder's configured bandpass or the decoder's last bandpass, @see OPUS_SET_BANDWIDTH
+ * @param[out] x <tt>int*</tt>: Bandwidth value
+ * @hideinitializer */
+#define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
+
+/**@}*/
+
+/** @defgroup libinfo Opus library information functions
+ * @{
+ */
+
+/** Converts an opus error code into a human readable string.
+ *
+ * @param[in] error <tt>int</tt>: Error number
+ * @returns Error string
+ */
+OPUS_EXPORT const char *opus_strerror(int error);
+
+/** Gets the libopus version string.
+ *
+ * @returns Version string
+ */
+OPUS_EXPORT const char *opus_get_version_string(void);
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OPUS_DEFINES_H */
--- /dev/null
+++ b/include/opus_multistream.h
@@ -1,0 +1,149 @@
+/* Copyright (c) 2011 Xiph.Org Foundation
+ Written by Jean-Marc Valin */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * @file opus_multistream.h
+ * @brief Opus reference implementation multistream API
+ */
+
+#ifndef OPUS_MULTISTREAM_H
+#define OPUS_MULTISTREAM_H
+
+#include "opus.h"
+
+typedef struct OpusMSEncoder OpusMSEncoder;
+typedef struct OpusMSDecoder OpusMSDecoder;
+
+#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr)))
+#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr)))
+
+#define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120
+#define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122
+
+#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y)
+#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y)
+
+/** Allocate and initialize a multistream encoder state object.
+ * Call opus_multistream_encoder_destroy() to release
+ * this object when finished. */
+OPUS_EXPORT OpusMSEncoder *opus_multistream_encoder_create(
+ opus_int32 Fs, /**< Sampling rate of input signal (Hz) */
+ int channels, /**< Number of channels in the input signal */
+ int streams, /**< Total number of streams to encode from the input */
+ int coupled_streams, /**< Number of coupled (stereo) streams to encode */
+ unsigned char *mapping, /**< Encoded mapping between channels and streams */
+ int application, /**< Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
+ int *error /**< Error code */
+);
+
+/** Initialize an already allocated multistream encoder state. */
+OPUS_EXPORT int opus_multistream_encoder_init(
+ OpusMSEncoder *st, /**< Encoder state */
+ opus_int32 Fs, /**< Sampling rate of input signal (Hz) */
+ int channels, /**< Number of channels in the input signal */
+ int streams, /**< Total number of streams to encode from the input */
+ int coupled_streams, /**< Number of coupled (stereo) streams to encode */
+ unsigned char *mapping, /**< Encoded mapping between channels and streams */
+ int application /**< Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
+);
+
+/** Returns length of the data payload (in bytes) or a negative error code */
+OPUS_EXPORT int opus_multistream_encode(
+ OpusMSEncoder *st, /**< Encoder state */
+ const opus_int16 *pcm, /**< Input signal as interleaved samples. Length is frame_size*channels */
+ int frame_size, /**< Number of samples per frame of input signal */
+ unsigned char *data, /**< Output buffer for the compressed payload (no more than max_data_bytes long) */
+ int max_data_bytes /**< Allocated memory for payload; don't use for controlling bitrate */
+);
+
+/** Returns length of the data payload (in bytes) or a negative error code. */
+OPUS_EXPORT int opus_multistream_encode_float(
+ OpusMSEncoder *st, /**< Encoder state */
+ const float *pcm, /**< Input signal interleaved in channel order. length is frame_size*channels */
+ int frame_size, /**< Number of samples per frame of input signal */
+ unsigned char *data, /**< Output buffer for the compressed payload (no more than max_data_bytes long) */
+ int max_data_bytes /**< Allocated memory for payload; don't use for controlling bitrate */
+ );
+
+/** Deallocate a multstream encoder state */
+OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st);
+
+/** Get or set options on a multistream encoder state */
+OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...);
+
+/** Allocate and initialize a multistream decoder state object.
+ * Call opus_multistream_decoder_destroy() to release
+ * this object when finished. */
+OPUS_EXPORT OpusMSDecoder *opus_multistream_decoder_create(
+ opus_int32 Fs, /**< Sampling rate to decode at (Hz) */
+ int channels, /**< Number of channels to decode */
+ int streams, /**< Total number of coded streams in the multistream */
+ int coupled_streams, /**< Number of coupled (stereo) streams in the multistream */
+ unsigned char *mapping, /**< Stream to channel mapping table */
+ int *error /**< Error code */
+);
+
+/** Intialize a previously allocated decoder state object. */
+OPUS_EXPORT int opus_multistream_decoder_init(
+ OpusMSDecoder *st, /**< Encoder state */
+ opus_int32 Fs, /**< Sample rate of input signal (Hz) */
+ int channels, /**< Number of channels in the input signal */
+ int streams, /**< Total number of coded streams */
+ int coupled_streams, /**< Number of coupled (stereo) streams */
+ unsigned char *mapping /**< Stream to channel mapping table */
+);
+
+/** Returns the number of samples decoded or a negative error code */
+OPUS_EXPORT int opus_multistream_decode(
+ OpusMSDecoder *st, /**< Decoder state */
+ const unsigned char *data, /**< Input payload. Use a NULL pointer to indicate packet loss */
+ int len, /**< Number of bytes in payload */
+ opus_int16 *pcm, /**< Output signal, samples interleaved in channel order . length is frame_size*channels */
+ int frame_size, /**< Number of samples per frame of input signal */
+ int decode_fec /**< Flag (0/1) to request that any in-band forward error correction data be */
+ /**< decoded. If no such data is available the frame is decoded as if it were lost. */
+);
+
+/** Returns the number of samples decoded or a negative error code */
+OPUS_EXPORT int opus_multistream_decode_float(
+ OpusMSDecoder *st, /**< Decoder state */
+ const unsigned char *data, /**< Input payload buffer. Use a NULL pointer to indicate packet loss */
+ int len, /**< Number of payload bytes in data */
+ float *pcm, /**< Buffer for the output signal (interleaved iin channel order). length is frame_size*channels */
+ int frame_size, /**< Number of samples per frame of input signal */
+ int decode_fec /**< Flag (0/1) to request that any in-band forward error correction data be */
+ /**< decoded. If no such data is available the frame is decoded as if it were lost. */
+);
+
+
+/** Get or set options on a multistream decoder state */
+OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...);
+
+/** Deallocate a multistream decoder state object */
+OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st);
+
+#endif /* OPUS_MULTISTREAM_H */
--- /dev/null
+++ b/include/opus_types.h
@@ -1,0 +1,159 @@
+/* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */
+/* Modified by Jean-Marc Valin */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/* opus_types.h taken from libogg */
+
+/**
+ @file opus_types.h
+ @brief Opus reference implementation types
+*/
+#ifndef _OPUS_TYPES_H
+#define _OPUS_TYPES_H
+
+/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */
+#if (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H))
+#include <stdint.h>
+
+ typedef int16_t opus_int16;
+ typedef uint16_t opus_uint16;
+ typedef int32_t opus_int32;
+ typedef uint32_t opus_uint32;
+#elif defined(_WIN32)
+
+# if defined(__CYGWIN__)
+# include <_G_config.h>
+ typedef _G_int32_t opus_int32;
+ typedef _G_uint32_t opus_uint32;
+ typedef _G_int16 opus_int16;
+ typedef _G_uint16 opus_uint16;
+# elif defined(__MINGW32__)
+ typedef short opus_int16;
+ typedef unsigned short opus_uint16;
+ typedef int opus_int32;
+ typedef unsigned int opus_uint32;
+# elif defined(__MWERKS__)
+ typedef int opus_int32;
+ typedef unsigned int opus_uint32;
+ typedef short opus_int16;
+ typedef unsigned short opus_uint16;
+# else
+ /* MSVC/Borland */
+ typedef __int32 opus_int32;
+ typedef unsigned __int32 opus_uint32;
+ typedef __int16 opus_int16;
+ typedef unsigned __int16 opus_uint16;
+# endif
+
+#elif defined(__MACOS__)
+
+# include <sys/types.h>
+ typedef SInt16 opus_int16;
+ typedef UInt16 opus_uint16;
+ typedef SInt32 opus_int32;
+ typedef UInt32 opus_uint32;
+
+#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
+
+# include <sys/types.h>
+ typedef int16_t opus_int16;
+ typedef u_int16_t opus_uint16;
+ typedef int32_t opus_int32;
+ typedef u_int32_t opus_uint32;
+
+#elif defined(__BEOS__)
+
+ /* Be */
+# include <inttypes.h>
+ typedef int16 opus_int16;
+ typedef u_int16 opus_uint16;
+ typedef int32_t opus_int32;
+ typedef u_int32_t opus_uint32;
+
+#elif defined (__EMX__)
+
+ /* OS/2 GCC */
+ typedef short opus_int16;
+ typedef unsigned short opus_uint16;
+ typedef int opus_int32;
+ typedef unsigned int opus_uint32;
+
+#elif defined (DJGPP)
+
+ /* DJGPP */
+ typedef short opus_int16;
+ typedef unsigned short opus_uint16;
+ typedef int opus_int32;
+ typedef unsigned int opus_uint32;
+
+#elif defined(R5900)
+
+ /* PS2 EE */
+ typedef int opus_int32;
+ typedef unsigned opus_uint32;
+ typedef short opus_int16;
+ typedef unsigned short opus_uint16;
+
+#elif defined(__SYMBIAN32__)
+
+ /* Symbian GCC */
+ typedef signed short opus_int16;
+ typedef unsigned short opus_uint16;
+ typedef signed int opus_int32;
+ typedef unsigned int opus_uint32;
+
+#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
+
+ typedef short opus_int16;
+ typedef unsigned short opus_uint16;
+ typedef long opus_int32;
+ typedef unsigned long opus_uint32;
+
+#elif defined(CONFIG_TI_C6X)
+
+ typedef short opus_int16;
+ typedef unsigned short opus_uint16;
+ typedef int opus_int32;
+ typedef unsigned int opus_uint32;
+
+#else
+
+ /* Give up, take a reasonable guess */
+ typedef short opus_int16;
+ typedef unsigned short opus_uint16;
+ typedef int opus_int32;
+ typedef unsigned int opus_uint32;
+
+#endif
+
+#define opus_int int /* used for counters etc; at least 16 bits */
+#define opus_int64 long long
+#define opus_int8 signed char
+
+#define opus_uint unsigned int /* used for counters etc; at least 16 bits */
+#define opus_uint64 unsigned long long
+#define opus_uint8 unsigned char
+
+#endif /* _OPUS_TYPES_H */
--- a/opus_headers.txt
+++ b/opus_headers.txt
@@ -1,4 +1,4 @@
OPUS_HEAD = \
-src/opus.h \
-src/opus_multistream.h \
+include/opus.h \
+include/opus_multistream.h \
src/opus_private.h
--- a/src/opus.h
+++ /dev/null
@@ -1,508 +1,0 @@
-/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
- Written by Jean-Marc Valin and Koen Vos */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/**
- * @file opus.h
- * @brief Opus reference implementation API
- */
-
-#ifndef OPUS_H
-#define OPUS_H
-
-#include "opus_types.h"
-#include "opus_defines.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @mainpage Opus
- *
- * The Opus codec is designed for interactive speech and audio transmission over the Internet.
- * It is designed by the IETF Codec Working Group and incorporates technology from
- * Skype's SILK codec and Xiph.Org's CELT codec.
- *
- * The Opus codec is designed to handle a wide range of interactive audio applications,
- * including Voice over IP, videoconferencing, in-game chat, and even remote live music
- * performances. It can scale from low bit-rate narrowband speech to very high quality
- * stereo music. Its main features are:
-
- * @li Sampling rates from 8 to 48 kHz
- * @li Bit-rates from 6 kb/s 510 kb/s
- * @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR)
- * @li Audio bandwidth from narrowband to full-band
- * @li Support for speech and music
- * @li Support for mono and stereo
- * @li Frame sizes from 2.5 ms to 60 ms
- * @li Good loss robustness and packet loss concealment (PLC)
- * @li Floating point and fixed-point implementation
- *
- * Documentation sections:
- * @li @ref opusencoder
- * @li @ref opusdecoder
- * @li @ref repacketizer
- * @li @ref libinfo
- */
-
-/** @defgroup opusencoder Opus Encoder
- * @{
- *
- * Since Opus is a stateful codec, the encoding process starts with creating an encoder
- * state. This can be done with:
- *
- * @code
- * int error;
- * OpusEncoder *enc;
- * enc = opus_encoder_create(Fs, channels, application, &error);
- * @endcode
- *
- * From this point, @c enc can be used for encoding an audio stream. An encoder state
- * @b must @b not be used for more than one stream at the same time. Similarly, the encoder
- * state @b must @b not be re-initialized for each frame.
- *
- * While opus_encoder_create() allocates memory for the state, it's also possible
- * to initialize pre-allocated memory:
- *
- * @code
- * int size;
- * int error;
- * OpusEncoder *enc;
- * size = opus_encoder_get_size(channels);
- * enc = malloc(size);
- * error = opus_encoder_init(enc, Fs, channels, application);
- * @endcode
- *
- * where opus_encoder_get_size() returns the required size for the encoder state. Note that
- * future versions of this code may change the size, so no assuptions should be made about it.
- *
- * The encoder state is always continuous in memory and only a shallow copy is sufficient
- * to copy it (e.g. memcpy())
- *
- * It is possible to change some of the encoder's settings using the opus_encoder_ctl()
- * interface. All these settings already default to the recommended value, so they should
- * only be changed when necessary. The most common settings one may want to change are:
- *
- * @code
- * opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate));
- * opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity));
- * opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type));
- * @endcode
- *
- * where
- *
- * @arg bitrate is in bits per second (b/s)
- * @arg complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest
- * @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or OPUS_SIGNAL_MUSIC
- *
- * See @ref encoderctls and @ref genericctls for a complete list of parameters that can be set or queried. Most parameters can be set or changed at any time during a stream.
- *
- * To encode a frame, opus_encode() or opus_encode_float() must be called with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data:
- * @code
- * len = opus_encode(enc, audio_frame, frame_size, packet, max_packet);
- * @endcode
- *
- * where
- * <ul>
- * <li>audio_frame is the audio data in opus_int16 (or float for opus_encode_float())</li>
- * <li>frame_size is the duration of the frame in samples (per channel)</li>
- * <li>packet is the byte array to which the compressed data is written</li>
- * <li>max_packet is the maximum number of bytes that can be written in the packet (1276 bytes is recommended)</li>
- * </ul>
- *
- * opus_encode() and opus_encode_frame() return the number of bytes actually written to the packet.
- * The return value <b>can be negative</b>, which indicates that an error has occurred. If the return value
- * is 1 byte, then the packet does not need to be transmitted (DTX).
- *
- * Once the encoder state if no longer needed, it can be destroyed with
- *
- * @code
- * opus_encoder_destroy(enc);
- * @endcode
- *
- * If the encoder was created with opus_encoder_init() rather than opus_encoder_create(),
- * then no action is required aside from potentially freeing the memory that was manually
- * allocated for it (calling free(enc) for the example above)
- *
- */
-
-/** Opus encoder state.
- * This contains the complete state of an Opus encoder.
- * It is position independent and can be freely copied.
- * @see opus_encoder_create,opus_encoder_init
- */
-typedef struct OpusEncoder OpusEncoder;
-
-OPUS_EXPORT int opus_encoder_get_size(int channels);
-
-/**
- */
-
-/** Allocates and initializes an encoder state.
- * There are three coding modes:
- *
- * @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voice
- * signals. It enhances the input signal by high-pass filtering and
- * emphasizing formants and harmonics. Optionally it includes in-band
- * forward error correction to protect against packet loss. Use this
- * mode for typical VoIP applications. Because of the enhancement,
- * even at high bitrates the output may sound different from the input.
- *
- * @ref OPUS_APPLICATION_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, broadcast, and applications requiring less
- * than 15 ms of coding delay.
- *
- * @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that
- * disables the speech-optimized mode in exchange for slightly reduced delay.
- *
- * This is useful when the caller knows that the speech-optimized modes will not be needed (use with caution).
- * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz)
- * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input signal
- * @param [in] application <tt>int</tt>: Coding mode (@ref OPUS_APPLICATION_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY)
- * @param [out] error <tt>int*</tt>: @ref errorcodes
- * @note Regardless of the sampling rate and number channels selected, the Opus encoder
- * can switch to a lower audio audio bandwidth or number of channels if the bitrate
- * selected is too low. This also means that it is safe to always use 48 kHz stereo input
- * and let the encoder optimize the encoding.
- */
-OPUS_EXPORT OpusEncoder *opus_encoder_create(
- opus_int32 Fs,
- int channels,
- int application,
- int *error
-);
-
-/** Initializes a previously allocated encoder state
- * The memory pointed to by st must be the size returned by opus_encoder_get_size.
- * This is intended for applications which use their own allocator instead of malloc.
- * @see opus_encoder_create(),opus_encoder_get_size()
- * To reset a previously initialized state use the OPUS_RESET_STATE CTL.
- * @param [in] st <tt>OpusEncoder*</tt>: Encoder state
- * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz)
- * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input signal
- * @param [in] application <tt>int</tt>: Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY)
- * @retval OPUS_OK Success or @ref errorcodes
- */
-OPUS_EXPORT int opus_encoder_init(
- OpusEncoder *st,
- opus_int32 Fs,
- int channels,
- int application
-);
-
-/** Encodes an Opus frame.
- * The passed frame_size must an opus frame size for the encoder's sampling rate.
- * For example, at 48kHz the permitted values are 120, 240, 480, or 960.
- * Passing in a duration of less than 10ms (480 samples at 48kHz) will
- * prevent the encoder from using the LPC or hybrid modes.
- * @param [in] st <tt>OpusEncoder*</tt>: Encoder state
- * @param [in] pcm <tt>opus_int16*</tt>: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16)
- * @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
- * @param [out] data <tt>char*</tt>: Output payload (at least max_data_bytes long)
- * @param [in] max_data_bytes <tt>int</tt>: Allocated memory for payload; don't use for controlling bitrate
- * @returns length of the data payload (in bytes) or @ref errorcodes
- */
-OPUS_EXPORT int opus_encode(
- OpusEncoder *st,
- const opus_int16 *pcm,
- int frame_size,
- unsigned char *data,
- int max_data_bytes
-);
-
-/** Encodes an Opus frame from floating point input.
- * The passed frame_size must an opus frame size for the encoder's sampling rate.
- * For example, at 48kHz the permitted values are 120, 240, 480, or 960.
- * Passing in a duration of less than 10ms (480 samples at 48kHz) will
- * prevent the encoder from using the LPC or hybrid modes.
- * @param [in] st <tt>OpusEncoder*</tt>: Encoder state
- * @param [in] pcm <tt>float*</tt>: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(float)
- * @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
- * @param [out] data <tt>char*</tt>: Output payload (at least max_data_bytes long)
- * @param [in] max_data_bytes <tt>int</tt>: Allocated memory for payload; don't use for controlling bitrate
- * @returns length of the data payload (in bytes) or @ref errorcodes
- */
-OPUS_EXPORT int opus_encode_float(
- OpusEncoder *st,
- const float *pcm,
- int frame_size,
- unsigned char *data,
- int max_data_bytes
-);
-
-/** Frees an OpusEncoder allocated by opus_encoder_create.
- * @param[in] st <tt>OpusEncoder*</tt>: State to be freed.
- */
-OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st);
-
-/** Perform a CTL function on an Opus encoder.
- * @see encoderctls
- */
-OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...);
-/**@}*/
-
-/** @defgroup opusdecoder Opus Decoder
- * @{
- *
- *
- * The decoding process also starts with creating a decoder
- * state. This can be done with:
- * @code
- * int error;
- * OpusDecoder *dec;
- * dec = opus_decoder_create(Fs, channels, &error);
- * @endcode
- * where
- * @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 48000
- * @li channels is the number of channels (1 or 2)
- * @li error will hold the error code in case or failure (or OPUS_OK on success)
- * @li the return value is a newly created decoder state to be used for decoding
- *
- * While opus_decoder_create() allocates memory for the state, it's also possible
- * to initialize pre-allocated memory:
- * @code
- * int size;
- * int error;
- * OpusDecoder *dec;
- * size = opus_decoder_get_size(channels);
- * dec = malloc(size);
- * error = opus_decoder_init(dec, Fs, channels);
- * @endcode
- * where opus_decoder_get_size() returns the required size for the decoder state. Note that
- * future versions of this code may change the size, so no assuptions should be made about it.
- *
- * The decoder state is always continuous in memory and only a shallow copy is sufficient
- * to copy it (e.g. memcpy())
- *
- * To decode a frame, opus_decode() or opus_decode_float() must be called with a packet of compressed audio data:
- * @code
- * frame_size = opus_decode(enc, packet, len, decoded, max_size);
- * @endcode
- * where
- *
- * @li packet is the byte array containing the compressed data
- * @li len is the exact number of bytes contained in the packet
- * @li decoded is the decoded audio data in opus_int16 (or float for opus_decode_float())
- * @li max_size is the max duration of the frame in samples (per channel) that can fit into the decoded_frame array
- *
- * opus_decode() and opus_decode_frame() return the number of samples ()per channel) decoded from the packet.
- * If that value is negative, then an error has occured. This can occur if the packet is corrupted or if the audio
- * buffer is too small to hold the decoded audio.
-
-*/
-
-/** Opus decoder state.
- * This contains the complete state of an Opus decoder.
- * It is position independent and can be freely copied.
- * @see opus_decoder_create,opus_decoder_init
- */
-typedef struct OpusDecoder OpusDecoder;
-
-/** Gets the size of an OpusDecoder structure.
- * @param [in] channels <tt>int</tt>: Number of channels
- * @returns size
- */
-OPUS_EXPORT int opus_decoder_get_size(int channels);
-
-/** Allocates and initializes a decoder state.
- * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz)
- * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input signal
- * @param [out] error <tt>int*</tt>: OPUS_OK Success or @ref errorcodes
- */
-OPUS_EXPORT OpusDecoder *opus_decoder_create(
- opus_int32 Fs,
- int channels,
- int *error
-);
-
-/** Initializes a previously allocated decoder state.
- * The state must be the size returned by opus_decoder_get_size.
- * This is intended for applications which use their own allocator instead of malloc. @see opus_decoder_create,opus_decoder_get_size
- * To reset a previously initialized state use the OPUS_RESET_STATE CTL.
- * @param [in] st <tt>OpusDecoder*</tt>: Decoder state.
- * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz)
- * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input signal
- * @retval OPUS_OK Success or @ref errorcodes
- */
-OPUS_EXPORT int opus_decoder_init(
- OpusDecoder *st,
- opus_int32 Fs,
- int channels
-);
-
-/** Decode an Opus frame
- * @param [in] st <tt>OpusDecoder*</tt>: Decoder state
- * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
- * @param [in] len <tt>int</tt>: Number of bytes in payload*
- * @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length
- * is frame_size*channels*sizeof(opus_int16)
- * @param [in] frame_size Number of samples per channel of available space in *pcm,
- * if less than the maximum frame size (120ms) some frames can not be decoded
- * @param [in] decode_fec <tt>int</tt>: Flag (0/1) to request that any in-band forward error correction data be
- * decoded. If no such data is available the frame is decoded as if it were lost.
- * @returns Number of decoded samples or @ref errorcodes
- */
-OPUS_EXPORT int opus_decode(
- OpusDecoder *st,
- const unsigned char *data,
- int len,
- opus_int16 *pcm,
- int frame_size,
- int decode_fec
-);
-
-/** Decode an opus frame with floating point output
- * @param [in] st <tt>OpusDecoder*</tt>: Decoder state
- * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
- * @param [in] len <tt>int</tt>: Number of bytes in payload
- * @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length
- * is frame_size*channels*sizeof(float)
- * @param [in] frame_size Number of samples per channel of available space in *pcm,
- * if less than the maximum frame size (120ms) some frames can not be decoded
- * @param [in] decode_fec <tt>int</tt>: Flag (0/1) to request that any in-band forward error correction data be
- * decoded. If no such data is available the frame is decoded as if it were lost.
- * @returns Number of decoded samples or @ref errorcodes
- */
-OPUS_EXPORT int opus_decode_float(
- OpusDecoder *st,
- const unsigned char *data,
- int len,
- float *pcm,
- int frame_size,
- int decode_fec
-);
-
-/** Perform a CTL function on an Opus decoder.
- * @see decoderctls
- */
-OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...);
-
-/** Frees an OpusDecoder allocated by opus_decoder_create.
- * @param[in] st <tt>OpusDecoder*</tt>: State to be freed.
- */
-OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st);
-
-/** Parse an opus packet into one or more frames.
- * Opus_decode will perform this operation internally so most applications do
- * not need to use this function.
- * This function does not copy the frames, the returned pointers are pointers into
- * the input packet.
- * @param [in] data <tt>char*</tt>: Opus packet to be parsed
- * @param [in] len <tt>int</tt>: size of data
- * @param [out] out_toc <tt>char*</tt>: TOC pointer
- * @param [out] frames <tt>char*[48]</tt> encapsulated frames
- * @param [out] size <tt>short[48]</tt> sizes of the encapsulated frames
- * @param [out] payload_offset <tt>int*</tt>: returns the position of the payload within the packet (in bytes)
- * @returns number of frames
- */
-OPUS_EXPORT int opus_packet_parse(
- const unsigned char *data,
- int len,
- unsigned char *out_toc,
- const unsigned char *frames[48],
- short size[48],
- int *payload_offset
-);
-
-/** Gets the bandwidth of an Opus packet.
- * @param [in] data <tt>char*</tt>: Opus packet
- * @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass)
- * @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass)
- * @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass)
- * @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass)
- * @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass)
- * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
- */
-OPUS_EXPORT int opus_packet_get_bandwidth(const unsigned char *data);
-
-/** Gets the number of samples per frame from an Opus packet.
- * @param [in] data <tt>char*</tt>: Opus packet
- * @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz
- * @returns Number of samples per frame
- * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
- */
-OPUS_EXPORT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs);
-
-/** Gets the number of channels from an Opus packet.
- * @param [in] data <tt>char*</tt>: Opus packet
- * @returns Number of channels
- * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
- */
-OPUS_EXPORT int opus_packet_get_nb_channels(const unsigned char *data);
-
-/** Gets the number of frame in an Opus packet.
- * @param [in] packet <tt>char*</tt>: Opus packet
- * @param [in] len <tt>int</tt>: Length of packet
- * @returns Number of frames
- * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
- */
-OPUS_EXPORT int opus_packet_get_nb_frames(const unsigned char packet[], int len);
-
-/** Gets the number of samples of an Opus packet.
- * @param [in] dec <tt>OpusDecoder*</tt>: Decoder state
- * @param [in] packet <tt>char*</tt>: Opus packet
- * @param [in] len <tt>int</tt>: Length of packet
- * @returns Number of samples
- * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
- */
-OPUS_EXPORT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], int len);
-/**@}*/
-
-/** @defgroup repacketizer Repacketizer
- * @{
- *
- * The repacketizer can be used to merge multiple Opus packets into a single packet
- * or alternatively to split Opus packets that have previously been merged.
- *
- */
-
-typedef struct OpusRepacketizer OpusRepacketizer;
-
-OPUS_EXPORT int opus_repacketizer_get_size(void);
-
-OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp);
-
-OPUS_EXPORT OpusRepacketizer *opus_repacketizer_create(void);
-
-OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp);
-
-OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, int len);
-
-OPUS_EXPORT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, int maxlen);
-
-OPUS_EXPORT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp);
-
-OPUS_EXPORT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, int maxlen);
-
-/**@}*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OPUS_H */
--- a/src/opus_multistream.h
+++ /dev/null
@@ -1,149 +1,0 @@
-/* Copyright (c) 2011 Xiph.Org Foundation
- Written by Jean-Marc Valin */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/**
- * @file opus_multistream.h
- * @brief Opus reference implementation multistream API
- */
-
-#ifndef OPUS_MULTISTREAM_H
-#define OPUS_MULTISTREAM_H
-
-#include "opus.h"
-
-typedef struct OpusMSEncoder OpusMSEncoder;
-typedef struct OpusMSDecoder OpusMSDecoder;
-
-#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr)))
-#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr)))
-
-#define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120
-#define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122
-
-#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y)
-#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y)
-
-/** Allocate and initialize a multistream encoder state object.
- * Call opus_multistream_encoder_destroy() to release
- * this object when finished. */
-OPUS_EXPORT OpusMSEncoder *opus_multistream_encoder_create(
- opus_int32 Fs, /**< Sampling rate of input signal (Hz) */
- int channels, /**< Number of channels in the input signal */
- int streams, /**< Total number of streams to encode from the input */
- int coupled_streams, /**< Number of coupled (stereo) streams to encode */
- unsigned char *mapping, /**< Encoded mapping between channels and streams */
- int application, /**< Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
- int *error /**< Error code */
-);
-
-/** Initialize an already allocated multistream encoder state. */
-OPUS_EXPORT int opus_multistream_encoder_init(
- OpusMSEncoder *st, /**< Encoder state */
- opus_int32 Fs, /**< Sampling rate of input signal (Hz) */
- int channels, /**< Number of channels in the input signal */
- int streams, /**< Total number of streams to encode from the input */
- int coupled_streams, /**< Number of coupled (stereo) streams to encode */
- unsigned char *mapping, /**< Encoded mapping between channels and streams */
- int application /**< Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
-);
-
-/** Returns length of the data payload (in bytes) or a negative error code */
-OPUS_EXPORT int opus_multistream_encode(
- OpusMSEncoder *st, /**< Encoder state */
- const opus_int16 *pcm, /**< Input signal as interleaved samples. Length is frame_size*channels */
- int frame_size, /**< Number of samples per frame of input signal */
- unsigned char *data, /**< Output buffer for the compressed payload (no more than max_data_bytes long) */
- int max_data_bytes /**< Allocated memory for payload; don't use for controlling bitrate */
-);
-
-/** Returns length of the data payload (in bytes) or a negative error code. */
-OPUS_EXPORT int opus_multistream_encode_float(
- OpusMSEncoder *st, /**< Encoder state */
- const float *pcm, /**< Input signal interleaved in channel order. length is frame_size*channels */
- int frame_size, /**< Number of samples per frame of input signal */
- unsigned char *data, /**< Output buffer for the compressed payload (no more than max_data_bytes long) */
- int max_data_bytes /**< Allocated memory for payload; don't use for controlling bitrate */
- );
-
-/** Deallocate a multstream encoder state */
-OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st);
-
-/** Get or set options on a multistream encoder state */
-OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...);
-
-/** Allocate and initialize a multistream decoder state object.
- * Call opus_multistream_decoder_destroy() to release
- * this object when finished. */
-OPUS_EXPORT OpusMSDecoder *opus_multistream_decoder_create(
- opus_int32 Fs, /**< Sampling rate to decode at (Hz) */
- int channels, /**< Number of channels to decode */
- int streams, /**< Total number of coded streams in the multistream */
- int coupled_streams, /**< Number of coupled (stereo) streams in the multistream */
- unsigned char *mapping, /**< Stream to channel mapping table */
- int *error /**< Error code */
-);
-
-/** Intialize a previously allocated decoder state object. */
-OPUS_EXPORT int opus_multistream_decoder_init(
- OpusMSDecoder *st, /**< Encoder state */
- opus_int32 Fs, /**< Sample rate of input signal (Hz) */
- int channels, /**< Number of channels in the input signal */
- int streams, /**< Total number of coded streams */
- int coupled_streams, /**< Number of coupled (stereo) streams */
- unsigned char *mapping /**< Stream to channel mapping table */
-);
-
-/** Returns the number of samples decoded or a negative error code */
-OPUS_EXPORT int opus_multistream_decode(
- OpusMSDecoder *st, /**< Decoder state */
- const unsigned char *data, /**< Input payload. Use a NULL pointer to indicate packet loss */
- int len, /**< Number of bytes in payload */
- opus_int16 *pcm, /**< Output signal, samples interleaved in channel order . length is frame_size*channels */
- int frame_size, /**< Number of samples per frame of input signal */
- int decode_fec /**< Flag (0/1) to request that any in-band forward error correction data be */
- /**< decoded. If no such data is available the frame is decoded as if it were lost. */
-);
-
-/** Returns the number of samples decoded or a negative error code */
-OPUS_EXPORT int opus_multistream_decode_float(
- OpusMSDecoder *st, /**< Decoder state */
- const unsigned char *data, /**< Input payload buffer. Use a NULL pointer to indicate packet loss */
- int len, /**< Number of payload bytes in data */
- float *pcm, /**< Buffer for the output signal (interleaved iin channel order). length is frame_size*channels */
- int frame_size, /**< Number of samples per frame of input signal */
- int decode_fec /**< Flag (0/1) to request that any in-band forward error correction data be */
- /**< decoded. If no such data is available the frame is decoded as if it were lost. */
-);
-
-
-/** Get or set options on a multistream decoder state */
-OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...);
-
-/** Deallocate a multistream decoder state object */
-OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st);
-
-#endif /* OPUS_MULTISTREAM_H */
--- a/tests/test_opus_api.c
+++ b/tests/test_opus_api.c
@@ -49,7 +49,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
-#include "../src/opus.h"
+#include "../include/opus.h"
#include "test_opus_common.h"
#ifdef VALGRIND
--- a/tests/test_opus_decode.c
+++ b/tests/test_opus_decode.c
@@ -37,7 +37,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
-#include "../src/opus.h"
+#include "../include/opus.h"
#include "test_opus_common.h"
#define MAX_PACKET (1500)
--- a/tests/test_opus_encode.c
+++ b/tests/test_opus_encode.c
@@ -37,7 +37,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
-#include "../src/opus.h"
+#include "../include/opus.h"
#include "../src/opus_private.h"
#include "test_opus_common.h"