diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..cd0ee3d0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + name: ${{ matrix.platform.name }} ${{ matrix.config.name }} + runs-on: ${{ matrix.platform.os }} + + strategy: + matrix: + platform: + - { name: Windows VS2017, os: windows-2016 } + - { name: Windows VS2019, os: windows-latest } + - { name: Linux GCC, os: ubuntu-latest } + - { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ } + - { name: MacOS XCode, os: macos-latest } + config: + - { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE } + - { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE } + + include: + - platform: { name: MacOS XCode, os: macos-latest } + config: { name: Frameworks, flags: -DSFML_BUILD_FRAMEWORKS=TRUE } + - platform: { name: MacOS XCode, os: macos-latest } + config: { name: iOS, flags: -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/cmake/toolchains/iOS.toolchain.cmake -DIOS_PLATFORM=SIMULATOR } + - platform: { name: Android, os: ubuntu-latest } + config: { name: x86, flags: -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$GITHUB_WORKSPACE/android-ndk-r18b -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26 } + - platform: { name: Android, os: ubuntu-latest } + config: { name: armeabi-v7a, flags: -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$GITHUB_WORKSPACE/android-ndk-r18b -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26 } + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Install Linux Dependencies + if: runner.os == 'Linux' + run: sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev + + + - name: Install Android Components + if: matrix.platform.name == 'Android' + run: | + echo "y" | /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "cmake;3.10.2.4988404" --sdk_root=ANDROID_SDK_ROOT + sudo ln -sf /usr/local/lib/android/sdk/cmake/3.10.2.4988404/bin/cmake /usr/bin/cmake + wget -nv https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip -P $GITHUB_WORKSPACE + unzip -qq -d $GITHUB_WORKSPACE android-ndk-r18b-linux-x86_64.zip + + + - name: Configure CMake + shell: bash + run: cmake -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install -DSFML_BUILD_EXAMPLES=TRUE -DCMAKE_VERBOSE_MAKEFILE=ON -DSFML_BUILD_TEST_SUITE=TRUE ${{matrix.platform.flags}} ${{matrix.config.flags}} + + - name: Build + shell: bash + run: cmake --build $GITHUB_WORKSPACE/build --config Release --target install diff --git a/cmake/Modules/FindOpus.cmake b/cmake/Modules/FindOpus.cmake deleted file mode 100644 index bdbc76ef..00000000 --- a/cmake/Modules/FindOpus.cmake +++ /dev/null @@ -1,43 +0,0 @@ -# This file was taken from Unvanquished, -# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium -# It's licensed under the terms of the 3-clause OpenBSD license. -# Modifications Copyright 2014-2015 the openage authors. -# See copying.md for further legal info. - -# - Find opus library -# Find the native Opus headers and libraries. -# This module defines -# OPUS_INCLUDE_DIRS - where to find opus/opus.h, opus/opusfile.h, etc -# OPUS_LIBRARIES - List of libraries when using libopus -# OPUS_FOUND - True if opus is found. - -# find the opusfile header, defines our api. -find_path(OPUS_INCLUDE_DIR - NAMES opus/opusfile.h - DOC "Opus include directory" -) -mark_as_advanced(OPUS_INCLUDE_DIR) - -# look for libopusfile, the highlevel container-aware api. -find_library(OPUSFILE_LIBRARY - NAMES opusfile - DOC "Path to OpusFile library" -) -mark_as_advanced(OPUSFILE_LIBRARY) - -# find libopus, the core codec component. -find_library(OPUS_LIBRARY - NAMES opus - DOC "Path to Opus library" -) -mark_as_advanced(OPUS_LIBRARY) - - -# handle the QUIETLY and REQUIRED arguments and set OPUSFILE_FOUND to TRUE if -# all listed variables are TRUE -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Opus DEFAULT_MSG OPUSFILE_LIBRARY OPUS_LIBRARY OPUS_INCLUDE_DIR) - -# export the variables -set(OPUS_LIBRARIES "${OPUSFILE_LIBRARY}" "${OPUS_LIBRARY}") -set(OPUS_INCLUDE_DIRS "${OPUS_INCLUDE_DIR}" "${OPUS_INCLUDE_DIR}/opus") diff --git a/cmake/SFMLConfigDependencies.cmake.in b/cmake/SFMLConfigDependencies.cmake.in index 862ca140..c5813bd6 100644 --- a/cmake/SFMLConfigDependencies.cmake.in +++ b/cmake/SFMLConfigDependencies.cmake.in @@ -78,7 +78,6 @@ if(SFML_STATIC_LIBRARIES) sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "Vorbis" SEARCH_NAMES "vorbis") sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "Ogg" SEARCH_NAMES "ogg") sfml_bind_dependency(TARGET FLAC FRIENDLY_NAME "FLAC" SEARCH_NAMES "FLAC") - sfml_bind_dependency(TARGET Opus FRIENDLY_NAME "Opus" SEARCH_NAMES "Opus") endif() if (FIND_SFML_DEPENDENCIES_NOTFOUND) diff --git a/examples/sound/Sound.cpp b/examples/sound/Sound.cpp index 25162d4f..e71aa0d0 100644 --- a/examples/sound/Sound.cpp +++ b/examples/sound/Sound.cpp @@ -90,9 +90,6 @@ int main() // Play music from an ogg file playMusic("orchestral.ogg"); - // Play music from an opus file - playMusic("error.opus"); - // Play music from a flac file playMusic("ding.flac"); diff --git a/examples/sound/resources/error.opus b/examples/sound/resources/error.opus deleted file mode 100644 index 55823645..00000000 Binary files a/examples/sound/resources/error.opus and /dev/null differ diff --git a/extlibs/headers/opus/opus.h b/extlibs/headers/opus/opus.h deleted file mode 100644 index 93a53a2f..00000000 --- a/extlibs/headers/opus/opus.h +++ /dev/null @@ -1,978 +0,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 COPYRIGHT OWNER - 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 to 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 Support for multichannel (up to 255 channels) - * @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 opus_encoder - * @li @ref opus_decoder - * @li @ref opus_repacketizer - * @li @ref opus_multistream - * @li @ref opus_libinfo - * @li @ref opus_custom - */ - -/** @defgroup opus_encoder Opus Encoder - * @{ - * - * @brief This page describes the process and functions used to encode Opus. - * - * 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 opus_encoderctls and @ref opus_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 - *
OpusEncoder
structure.
- * @param[in] channels int: Number of channels.
- * This must be 1 or 2.
- * @returns The size in bytes.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT 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 mode can only be set on an newly initialized or freshly reset encoder
- * because it changes the codec delay.
- *
- * This is useful when the caller knows that the speech-optimized modes will not be needed (use with caution).
- * @param [in] Fs opus_int32: Sampling rate of input signal (Hz)
- * This must be one of 8000, 12000, 16000,
- * 24000, or 48000.
- * @param [in] channels int: Number of channels (1 or 2) in input signal
- * @param [in] application int: Coding mode (@ref OPUS_APPLICATION_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY)
- * @param [out] error int*: @ref opus_errorcodes
- * @note Regardless of the sampling rate and number channels selected, the Opus encoder
- * can switch to a lower 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 OPUS_WARN_UNUSED_RESULT 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 at least 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 OpusEncoder*: Encoder state
- * @param [in] Fs opus_int32: Sampling rate of input signal (Hz)
- * This must be one of 8000, 12000, 16000,
- * 24000, or 48000.
- * @param [in] channels int: Number of channels (1 or 2) in input signal
- * @param [in] application int: Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY)
- * @retval #OPUS_OK Success or @ref opus_errorcodes
- */
-OPUS_EXPORT int opus_encoder_init(
- OpusEncoder *st,
- opus_int32 Fs,
- int channels,
- int application
-) OPUS_ARG_NONNULL(1);
-
-/** Encodes an Opus frame.
- * @param [in] st OpusEncoder*: Encoder state
- * @param [in] pcm opus_int16*: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16)
- * @param [in] frame_size int: Number of samples per channel in the
- * input signal.
- * This must be an Opus frame size for
- * the encoder's sampling rate.
- * For example, at 48 kHz the permitted
- * values are 120, 240, 480, 960, 1920,
- * and 2880.
- * Passing in a duration of less than
- * 10 ms (480 samples at 48 kHz) will
- * prevent the encoder from using the LPC
- * or hybrid modes.
- * @param [out] data unsigned char*: Output payload.
- * This must contain storage for at
- * least \a max_data_bytes.
- * @param [in] max_data_bytes opus_int32: Size of the allocated
- * memory for the output
- * payload. This may be
- * used to impose an upper limit on
- * the instant bitrate, but should
- * not be used as the only bitrate
- * control. Use #OPUS_SET_BITRATE to
- * control the bitrate.
- * @returns The length of the encoded packet (in bytes) on success or a
- * negative error code (see @ref opus_errorcodes) on failure.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode(
- OpusEncoder *st,
- const opus_int16 *pcm,
- int frame_size,
- unsigned char *data,
- opus_int32 max_data_bytes
-) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
-
-/** Encodes an Opus frame from floating point input.
- * @param [in] st OpusEncoder*: Encoder state
- * @param [in] pcm float*: Input in float format (interleaved if 2 channels), 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 dynamic range.
- * length is frame_size*channels*sizeof(float)
- * @param [in] frame_size int: Number of samples per channel in the
- * input signal.
- * This must be an Opus frame size for
- * the encoder's sampling rate.
- * For example, at 48 kHz the permitted
- * values are 120, 240, 480, 960, 1920,
- * and 2880.
- * Passing in a duration of less than
- * 10 ms (480 samples at 48 kHz) will
- * prevent the encoder from using the LPC
- * or hybrid modes.
- * @param [out] data unsigned char*: Output payload.
- * This must contain storage for at
- * least \a max_data_bytes.
- * @param [in] max_data_bytes opus_int32: Size of the allocated
- * memory for the output
- * payload. This may be
- * used to impose an upper limit on
- * the instant bitrate, but should
- * not be used as the only bitrate
- * control. Use #OPUS_SET_BITRATE to
- * control the bitrate.
- * @returns The length of the encoded packet (in bytes) on success or a
- * negative error code (see @ref opus_errorcodes) on failure.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float(
- OpusEncoder *st,
- const float *pcm,
- int frame_size,
- unsigned char *data,
- opus_int32 max_data_bytes
-) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
-
-/** Frees an OpusEncoder
allocated by opus_encoder_create().
- * @param[in] st OpusEncoder*: State to be freed.
- */
-OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st);
-
-/** Perform a CTL function on an Opus encoder.
- *
- * Generally the request and subsequent arguments are generated
- * by a convenience macro.
- * @param st OpusEncoder*: Encoder state.
- * @param request This and all remaining parameters should be replaced by one
- * of the convenience macros in @ref opus_genericctls or
- * @ref opus_encoderctls.
- * @see opus_genericctls
- * @see opus_encoderctls
- */
-OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
-/**@}*/
-
-/** @defgroup opus_decoder Opus Decoder
- * @{
- *
- * @brief This page describes the process and functions used to decode Opus.
- *
- * 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 of 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(dec, packet, len, decoded, max_size, 0);
- * @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_float() return the number of samples (per channel) decoded from the packet.
- * If that value is negative, then an error has occurred. This can occur if the packet is corrupted or if the audio
- * buffer is too small to hold the decoded audio.
- *
- * Opus is a stateful codec with overlapping blocks and as a result Opus
- * packets are not coded independently of each other. Packets must be
- * passed into the decoder serially and in the correct order for a correct
- * decode. Lost packets can be replaced with loss concealment by calling
- * the decoder with a null pointer and zero length for the missing packet.
- *
- * A single codec state may only be accessed from a single thread at
- * a time and any required locking must be performed by the caller. Separate
- * streams must be decoded with separate decoder states and can be decoded
- * in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOSTACK
- * defined.
- *
- */
-
-/** 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 int: Number of channels.
- * This must be 1 or 2.
- * @returns The size in bytes.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels);
-
-/** Allocates and initializes a decoder state.
- * @param [in] Fs opus_int32: Sample rate to decode at (Hz).
- * This must be one of 8000, 12000, 16000,
- * 24000, or 48000.
- * @param [in] channels int: Number of channels (1 or 2) to decode
- * @param [out] error int*: #OPUS_OK Success or @ref opus_errorcodes
- *
- * Internally Opus stores data at 48000 Hz, so that should be the default
- * value for Fs. However, the decoder can efficiently decode to buffers
- * at 8, 12, 16, and 24 kHz so if for some reason the caller cannot use
- * data at the full sample rate, or knows the compressed data doesn't
- * use the full frequency range, it can request decoding at a reduced
- * rate. Likewise, the decoder is capable of filling in either mono or
- * interleaved stereo pcm buffers, at the caller's request.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create(
- opus_int32 Fs,
- int channels,
- int *error
-);
-
-/** Initializes a previously allocated decoder state.
- * The state must be at least 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 OpusDecoder*: Decoder state.
- * @param [in] Fs opus_int32: Sampling rate to decode to (Hz).
- * This must be one of 8000, 12000, 16000,
- * 24000, or 48000.
- * @param [in] channels int: Number of channels (1 or 2) to decode
- * @retval #OPUS_OK Success or @ref opus_errorcodes
- */
-OPUS_EXPORT int opus_decoder_init(
- OpusDecoder *st,
- opus_int32 Fs,
- int channels
-) OPUS_ARG_NONNULL(1);
-
-/** Decode an Opus packet.
- * @param [in] st OpusDecoder*: Decoder state
- * @param [in] data char*: Input payload. Use a NULL pointer to indicate packet loss
- * @param [in] len opus_int32: Number of bytes in payload*
- * @param [out] pcm opus_int16*: 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 \a pcm.
- * If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will
- * not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1),
- * then frame_size needs to be exactly the duration of audio that is missing, otherwise the
- * decoder will not be in the optimal state to decode the next incoming packet. For the PLC and
- * FEC cases, frame_size must be a multiple of 2.5 ms.
- * @param [in] decode_fec int: Flag (0 or 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 opus_errorcodes
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode(
- OpusDecoder *st,
- const unsigned char *data,
- opus_int32 len,
- opus_int16 *pcm,
- int frame_size,
- int decode_fec
-) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
-
-/** Decode an Opus packet with floating point output.
- * @param [in] st OpusDecoder*: Decoder state
- * @param [in] data char*: Input payload. Use a NULL pointer to indicate packet loss
- * @param [in] len opus_int32: Number of bytes in payload
- * @param [out] pcm float*: 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 \a pcm.
- * If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will
- * not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1),
- * then frame_size needs to be exactly the duration of audio that is missing, otherwise the
- * decoder will not be in the optimal state to decode the next incoming packet. For the PLC and
- * FEC cases, frame_size must be a multiple of 2.5 ms.
- * @param [in] decode_fec int: Flag (0 or 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 opus_errorcodes
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float(
- OpusDecoder *st,
- const unsigned char *data,
- opus_int32 len,
- float *pcm,
- int frame_size,
- int decode_fec
-) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
-
-/** Perform a CTL function on an Opus decoder.
- *
- * Generally the request and subsequent arguments are generated
- * by a convenience macro.
- * @param st OpusDecoder*: Decoder state.
- * @param request This and all remaining parameters should be replaced by one
- * of the convenience macros in @ref opus_genericctls or
- * @ref opus_decoderctls.
- * @see opus_genericctls
- * @see opus_decoderctls
- */
-OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
-
-/** Frees an OpusDecoder
allocated by opus_decoder_create().
- * @param[in] st OpusDecoder*: 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 char*: Opus packet to be parsed
- * @param [in] len opus_int32: size of data
- * @param [out] out_toc char*: TOC pointer
- * @param [out] frames char*[48] encapsulated frames
- * @param [out] size opus_int16[48] sizes of the encapsulated frames
- * @param [out] payload_offset int*: 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,
- opus_int32 len,
- unsigned char *out_toc,
- const unsigned char *frames[48],
- opus_int16 size[48],
- int *payload_offset
-) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
-
-/** Gets the bandwidth of an Opus packet.
- * @param [in] data char*: 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 OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1);
-
-/** Gets the number of samples per frame from an Opus packet.
- * @param [in] data char*: Opus packet.
- * This must contain at least one byte of
- * data.
- * @param [in] Fs opus_int32: Sampling rate in Hz.
- * This must be a multiple of 400, or
- * inaccurate results will be returned.
- * @returns Number of samples per frame.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1);
-
-/** Gets the number of channels from an Opus packet.
- * @param [in] data char*: Opus packet
- * @returns Number of channels
- * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1);
-
-/** Gets the number of frames in an Opus packet.
- * @param [in] packet char*: Opus packet
- * @param [in] len opus_int32: Length of packet
- * @returns Number of frames
- * @retval OPUS_BAD_ARG Insufficient data was passed to the function
- * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1);
-
-/** Gets the number of samples of an Opus packet.
- * @param [in] packet char*: Opus packet
- * @param [in] len opus_int32: Length of packet
- * @param [in] Fs opus_int32: Sampling rate in Hz.
- * This must be a multiple of 400, or
- * inaccurate results will be returned.
- * @returns Number of samples
- * @retval OPUS_BAD_ARG Insufficient data was passed to the function
- * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigned char packet[], opus_int32 len, opus_int32 Fs) OPUS_ARG_NONNULL(1);
-
-/** Gets the number of samples of an Opus packet.
- * @param [in] dec OpusDecoder*: Decoder state
- * @param [in] packet char*: Opus packet
- * @param [in] len opus_int32: Length of packet
- * @returns Number of samples
- * @retval OPUS_BAD_ARG Insufficient data was passed to the function
- * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
-
-/** Applies soft-clipping to bring a float signal within the [-1,1] range. If
- * the signal is already in that range, nothing is done. If there are values
- * outside of [-1,1], then the signal is clipped as smoothly as possible to
- * both fit in the range and avoid creating excessive distortion in the
- * process.
- * @param [in,out] pcm float*: Input PCM and modified PCM
- * @param [in] frame_size int Number of samples per channel to process
- * @param [in] channels int: Number of channels
- * @param [in,out] softclip_mem float*: State memory for the soft clipping process (one float per channel, initialized to zero)
- */
-OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem);
-
-
-/**@}*/
-
-/** @defgroup opus_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. Splitting valid Opus packets is always guaranteed to succeed,
- * whereas merging valid packets only succeeds if all frames have the same
- * mode, bandwidth, and frame size, and when the total duration of the merged
- * packet is no more than 120 ms.
- * The repacketizer currently only operates on elementary Opus
- * streams. It will not manipualte multistream packets successfully, except in
- * the degenerate case where they consist of data from a single stream.
- *
- * The repacketizing process starts with creating a repacketizer state, either
- * by calling opus_repacketizer_create() or by allocating the memory yourself,
- * e.g.,
- * @code
- * OpusRepacketizer *rp;
- * rp = (OpusRepacketizer*)malloc(opus_repacketizer_get_size());
- * if (rp != NULL)
- * opus_repacketizer_init(rp);
- * @endcode
- *
- * Then the application should submit packets with opus_repacketizer_cat(),
- * extract new packets with opus_repacketizer_out() or
- * opus_repacketizer_out_range(), and then reset the state for the next set of
- * input packets via opus_repacketizer_init().
- *
- * For example, to split a sequence of packets into individual frames:
- * @code
- * unsigned char *data;
- * int len;
- * while (get_next_packet(&data, &len))
- * {
- * unsigned char out[1276];
- * opus_int32 out_len;
- * int nb_frames;
- * int err;
- * int i;
- * err = opus_repacketizer_cat(rp, data, len);
- * if (err != OPUS_OK)
- * {
- * release_packet(data);
- * return err;
- * }
- * nb_frames = opus_repacketizer_get_nb_frames(rp);
- * for (i = 0; i < nb_frames; i++)
- * {
- * out_len = opus_repacketizer_out_range(rp, i, i+1, out, sizeof(out));
- * if (out_len < 0)
- * {
- * release_packet(data);
- * return (int)out_len;
- * }
- * output_next_packet(out, out_len);
- * }
- * opus_repacketizer_init(rp);
- * release_packet(data);
- * }
- * @endcode
- *
- * Alternatively, to combine a sequence of frames into packets that each
- * contain up to TARGET_DURATION_MS
milliseconds of data:
- * @code
- * // The maximum number of packets with duration TARGET_DURATION_MS occurs
- * // when the frame size is 2.5 ms, for a total of (TARGET_DURATION_MS*2/5)
- * // packets.
- * unsigned char *data[(TARGET_DURATION_MS*2/5)+1];
- * opus_int32 len[(TARGET_DURATION_MS*2/5)+1];
- * int nb_packets;
- * unsigned char out[1277*(TARGET_DURATION_MS*2/2)];
- * opus_int32 out_len;
- * int prev_toc;
- * nb_packets = 0;
- * while (get_next_packet(data+nb_packets, len+nb_packets))
- * {
- * int nb_frames;
- * int err;
- * nb_frames = opus_packet_get_nb_frames(data[nb_packets], len[nb_packets]);
- * if (nb_frames < 1)
- * {
- * release_packets(data, nb_packets+1);
- * return nb_frames;
- * }
- * nb_frames += opus_repacketizer_get_nb_frames(rp);
- * // If adding the next packet would exceed our target, or it has an
- * // incompatible TOC sequence, output the packets we already have before
- * // submitting it.
- * // N.B., The nb_packets > 0 check ensures we've submitted at least one
- * // packet since the last call to opus_repacketizer_init(). Otherwise a
- * // single packet longer than TARGET_DURATION_MS would cause us to try to
- * // output an (invalid) empty packet. It also ensures that prev_toc has
- * // been set to a valid value. Additionally, len[nb_packets] > 0 is
- * // guaranteed by the call to opus_packet_get_nb_frames() above, so the
- * // reference to data[nb_packets][0] should be valid.
- * if (nb_packets > 0 && (
- * ((prev_toc & 0xFC) != (data[nb_packets][0] & 0xFC)) ||
- * opus_packet_get_samples_per_frame(data[nb_packets], 48000)*nb_frames >
- * TARGET_DURATION_MS*48))
- * {
- * out_len = opus_repacketizer_out(rp, out, sizeof(out));
- * if (out_len < 0)
- * {
- * release_packets(data, nb_packets+1);
- * return (int)out_len;
- * }
- * output_next_packet(out, out_len);
- * opus_repacketizer_init(rp);
- * release_packets(data, nb_packets);
- * data[0] = data[nb_packets];
- * len[0] = len[nb_packets];
- * nb_packets = 0;
- * }
- * err = opus_repacketizer_cat(rp, data[nb_packets], len[nb_packets]);
- * if (err != OPUS_OK)
- * {
- * release_packets(data, nb_packets+1);
- * return err;
- * }
- * prev_toc = data[nb_packets][0];
- * nb_packets++;
- * }
- * // Output the final, partial packet.
- * if (nb_packets > 0)
- * {
- * out_len = opus_repacketizer_out(rp, out, sizeof(out));
- * release_packets(data, nb_packets);
- * if (out_len < 0)
- * return (int)out_len;
- * output_next_packet(out, out_len);
- * }
- * @endcode
- *
- * An alternate way of merging packets is to simply call opus_repacketizer_cat()
- * unconditionally until it fails. At that point, the merged packet can be
- * obtained with opus_repacketizer_out() and the input packet for which
- * opus_repacketizer_cat() needs to be re-added to a newly reinitialized
- * repacketizer state.
- */
-
-typedef struct OpusRepacketizer OpusRepacketizer;
-
-/** Gets the size of an OpusRepacketizer
structure.
- * @returns The size in bytes.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void);
-
-/** (Re)initializes a previously allocated repacketizer state.
- * The state must be at least the size returned by opus_repacketizer_get_size().
- * This can be used for applications which use their own allocator instead of
- * malloc().
- * It must also be called to reset the queue of packets waiting to be
- * repacketized, which is necessary if the maximum packet duration of 120 ms
- * is reached or if you wish to submit packets with a different Opus
- * configuration (coding mode, audio bandwidth, frame size, or channel count).
- * Failure to do so will prevent a new packet from being added with
- * opus_repacketizer_cat().
- * @see opus_repacketizer_create
- * @see opus_repacketizer_get_size
- * @see opus_repacketizer_cat
- * @param rp OpusRepacketizer*: The repacketizer state to
- * (re)initialize.
- * @returns A pointer to the same repacketizer state that was passed in.
- */
-OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
-
-/** Allocates memory and initializes the new repacketizer with
- * opus_repacketizer_init().
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void);
-
-/** Frees an OpusRepacketizer
allocated by
- * opus_repacketizer_create().
- * @param[in] rp OpusRepacketizer*: State to be freed.
- */
-OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp);
-
-/** Add a packet to the current repacketizer state.
- * This packet must match the configuration of any packets already submitted
- * for repacketization since the last call to opus_repacketizer_init().
- * This means that it must have the same coding mode, audio bandwidth, frame
- * size, and channel count.
- * This can be checked in advance by examining the top 6 bits of the first
- * byte of the packet, and ensuring they match the top 6 bits of the first
- * byte of any previously submitted packet.
- * The total duration of audio in the repacketizer state also must not exceed
- * 120 ms, the maximum duration of a single packet, after adding this packet.
- *
- * The contents of the current repacketizer state can be extracted into new
- * packets using opus_repacketizer_out() or opus_repacketizer_out_range().
- *
- * In order to add a packet with a different configuration or to add more
- * audio beyond 120 ms, you must clear the repacketizer state by calling
- * opus_repacketizer_init().
- * If a packet is too large to add to the current repacketizer state, no part
- * of it is added, even if it contains multiple frames, some of which might
- * fit.
- * If you wish to be able to add parts of such packets, you should first use
- * another repacketizer to split the packet into pieces and add them
- * individually.
- * @see opus_repacketizer_out_range
- * @see opus_repacketizer_out
- * @see opus_repacketizer_init
- * @param rp OpusRepacketizer*: The repacketizer state to which to
- * add the packet.
- * @param[in] data const unsigned char*: The packet data.
- * The application must ensure
- * this pointer remains valid
- * until the next call to
- * opus_repacketizer_init() or
- * opus_repacketizer_destroy().
- * @param len opus_int32: The number of bytes in the packet data.
- * @returns An error code indicating whether or not the operation succeeded.
- * @retval #OPUS_OK The packet's contents have been added to the repacketizer
- * state.
- * @retval #OPUS_INVALID_PACKET The packet did not have a valid TOC sequence,
- * the packet's TOC sequence was not compatible
- * with previously submitted packets (because
- * the coding mode, audio bandwidth, frame size,
- * or channel count did not match), or adding
- * this packet would increase the total amount of
- * audio stored in the repacketizer state to more
- * than 120 ms.
- */
-OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
-
-
-/** Construct a new packet from data previously submitted to the repacketizer
- * state via opus_repacketizer_cat().
- * @param rp OpusRepacketizer*: The repacketizer state from which to
- * construct the new packet.
- * @param begin int: The index of the first frame in the current
- * repacketizer state to include in the output.
- * @param end int: One past the index of the last frame in the
- * current repacketizer state to include in the
- * output.
- * @param[out] data const unsigned char*: The buffer in which to
- * store the output packet.
- * @param maxlen opus_int32: The maximum number of bytes to store in
- * the output buffer. In order to guarantee
- * success, this should be at least
- * 1276
for a single frame,
- * or for multiple frames,
- * 1277*(end-begin)
.
- * However, 1*(end-begin)
plus
- * the size of all packet data submitted to
- * the repacketizer since the last call to
- * opus_repacketizer_init() or
- * opus_repacketizer_create() is also
- * sufficient, and possibly much smaller.
- * @returns The total size of the output packet on success, or an error code
- * on failure.
- * @retval #OPUS_BAD_ARG [begin,end)
was an invalid range of
- * frames (begin < 0, begin >= end, or end >
- * opus_repacketizer_get_nb_frames()).
- * @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the
- * complete output packet.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
-
-/** Return the total number of frames contained in packet data submitted to
- * the repacketizer state so far via opus_repacketizer_cat() since the last
- * call to opus_repacketizer_init() or opus_repacketizer_create().
- * This defines the valid range of packets that can be extracted with
- * opus_repacketizer_out_range() or opus_repacketizer_out().
- * @param rp OpusRepacketizer*: The repacketizer state containing the
- * frames.
- * @returns The total number of frames contained in the packet data submitted
- * to the repacketizer state.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
-
-/** Construct a new packet from data previously submitted to the repacketizer
- * state via opus_repacketizer_cat().
- * This is a convenience routine that returns all the data submitted so far
- * in a single packet.
- * It is equivalent to calling
- * @code
- * opus_repacketizer_out_range(rp, 0, opus_repacketizer_get_nb_frames(rp),
- * data, maxlen)
- * @endcode
- * @param rp OpusRepacketizer*: The repacketizer state from which to
- * construct the new packet.
- * @param[out] data const unsigned char*: The buffer in which to
- * store the output packet.
- * @param maxlen opus_int32: The maximum number of bytes to store in
- * the output buffer. In order to guarantee
- * success, this should be at least
- * 1277*opus_repacketizer_get_nb_frames(rp)
.
- * However,
- * 1*opus_repacketizer_get_nb_frames(rp)
- * plus the size of all packet data
- * submitted to the repacketizer since the
- * last call to opus_repacketizer_init() or
- * opus_repacketizer_create() is also
- * sufficient, and possibly much smaller.
- * @returns The total size of the output packet on success, or an error code
- * on failure.
- * @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the
- * complete output packet.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1);
-
-/** Pads a given Opus packet to a larger size (possibly changing the TOC sequence).
- * @param[in,out] data const unsigned char*: The buffer containing the
- * packet to pad.
- * @param len opus_int32: The size of the packet.
- * This must be at least 1.
- * @param new_len opus_int32: The desired size of the packet after padding.
- * This must be at least as large as len.
- * @returns an error code
- * @retval #OPUS_OK \a on success.
- * @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len.
- * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet.
- */
-OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len);
-
-/** Remove all padding from a given Opus packet and rewrite the TOC sequence to
- * minimize space usage.
- * @param[in,out] data const unsigned char*: The buffer containing the
- * packet to strip.
- * @param len opus_int32: The size of the packet.
- * This must be at least 1.
- * @returns The new size of the output packet on success, or an error code
- * on failure.
- * @retval #OPUS_BAD_ARG \a len was less than 1.
- * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len);
-
-/** Pads a given Opus multi-stream packet to a larger size (possibly changing the TOC sequence).
- * @param[in,out] data const unsigned char*: The buffer containing the
- * packet to pad.
- * @param len opus_int32: The size of the packet.
- * This must be at least 1.
- * @param new_len opus_int32: The desired size of the packet after padding.
- * This must be at least 1.
- * @param nb_streams opus_int32: The number of streams (not channels) in the packet.
- * This must be at least as large as len.
- * @returns an error code
- * @retval #OPUS_OK \a on success.
- * @retval #OPUS_BAD_ARG \a len was less than 1.
- * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet.
- */
-OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams);
-
-/** Remove all padding from a given Opus multi-stream packet and rewrite the TOC sequence to
- * minimize space usage.
- * @param[in,out] data const unsigned char*: The buffer containing the
- * packet to strip.
- * @param len opus_int32: The size of the packet.
- * This must be at least 1.
- * @param nb_streams opus_int32: The number of streams (not channels) in the packet.
- * This must be at least 1.
- * @returns The new size of the output packet on success, or an error code
- * on failure.
- * @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len.
- * @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams);
-
-/**@}*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OPUS_H */
diff --git a/extlibs/headers/opus/opus_defines.h b/extlibs/headers/opus/opus_defines.h
deleted file mode 100644
index 265089f6..00000000
--- a/extlibs/headers/opus/opus_defines.h
+++ /dev/null
@@ -1,726 +0,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 COPYRIGHT OWNER
- 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 opus_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 */
-
-#ifndef OPUS_EXPORT
-# if defined(WIN32)
-# ifdef OPUS_BUILD
-# define OPUS_EXPORT __declspec(dllexport)
-# else
-# define OPUS_EXPORT
-# endif
-# elif defined(__GNUC__) && defined(OPUS_BUILD)
-# define OPUS_EXPORT __attribute__ ((visibility ("default")))
-# else
-# define OPUS_EXPORT
-# endif
-#endif
-
-# if !defined(OPUS_GNUC_PREREQ)
-# if defined(__GNUC__)&&defined(__GNUC_MINOR__)
-# define OPUS_GNUC_PREREQ(_maj,_min) \
- ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
-# else
-# define OPUS_GNUC_PREREQ(_maj,_min) 0
-# endif
-# endif
-
-#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
-# if OPUS_GNUC_PREREQ(3,0)
-# define OPUS_RESTRICT __restrict__
-# elif (defined(_MSC_VER) && _MSC_VER >= 1400)
-# define OPUS_RESTRICT __restrict
-# else
-# define OPUS_RESTRICT
-# endif
-#else
-# define OPUS_RESTRICT restrict
-#endif
-
-#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
-# if OPUS_GNUC_PREREQ(2,7)
-# define OPUS_INLINE __inline__
-# elif (defined(_MSC_VER))
-# define OPUS_INLINE __inline
-# else
-# define OPUS_INLINE
-# endif
-#else
-# define OPUS_INLINE inline
-#endif
-
-/**Warning attributes for opus functions
- * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out
- * some paranoid null checks. */
-#if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
-# define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
-#else
-# define OPUS_WARN_UNUSED_RESULT
-#endif
-#if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
-# define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x)))
-#else
-# define OPUS_ARG_NONNULL(_x)
-#endif
-
-/** These are the actual Encoder CTL ID numbers.
- * They should not be used directly by applications.
- * In general, SETs should be even and GETs should be odd.*/
-#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_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_SAMPLE_RATE_REQUEST 4029
-#define OPUS_GET_FINAL_RANGE_REQUEST 4031
-#define OPUS_GET_PITCH_REQUEST 4033
-#define OPUS_SET_GAIN_REQUEST 4034
-#define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */
-#define OPUS_SET_LSB_DEPTH_REQUEST 4036
-#define OPUS_GET_LSB_DEPTH_REQUEST 4037
-#define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039
-#define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040
-#define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041
-#define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042
-#define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043
-
-/* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */
-
-/* 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)))
-#define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr)))
-/** @endcond */
-
-/** @defgroup opus_ctlvalues Pre-defined values for CTL interface
- * @see opus_genericctls, opus_encoderctls
- * @{
- */
-/* Values for the various encoder CTLs */
-#define OPUS_AUTO -1000 /**Fs
value passed to opus_encoder_init()
- * or opus_decoder_init().
- * @param[out] x opus_int32 *: Sampling rate of encoder or decoder.
- * @hideinitializer
- */
-#define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_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 opus_int32 *: 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 (FEC).
- * @note This is only applicable to the LPC layer
- * @see OPUS_GET_INBAND_FEC
- * @param[in] x opus_int32: Allowed values:
- * streams
parameter used
- * to initialize the encoder.
- * @param[out] y OpusEncoder**: Returns a pointer to the given
- * encoder state.
- * @retval OPUS_BAD_ARG The index of the requested stream was out of range.
- * @hideinitializer
- */
-#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y)
-
-/** Gets the decoder state for an individual stream of a multistream decoder.
- * @param[in] x opus_int32: The index of the stream whose decoder you
- * wish to retrieve.
- * This must be non-negative and less than
- * the streams
parameter used
- * to initialize the decoder.
- * @param[out] y OpusDecoder**: Returns a pointer to the given
- * decoder state.
- * @retval OPUS_BAD_ARG The index of the requested stream was out of range.
- * @hideinitializer
- */
-#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y)
-
-/**@}*/
-
-/** @defgroup opus_multistream Opus Multistream API
- * @{
- *
- * The multistream API allows individual Opus streams to be combined into a
- * single packet, enabling support for up to 255 channels. Unlike an
- * elementary Opus stream, the encoder and decoder must negotiate the channel
- * configuration before the decoder can successfully interpret the data in the
- * packets produced by the encoder. Some basic information, such as packet
- * duration, can be computed without any special negotiation.
- *
- * The format for multistream Opus packets is defined in the
- * Ogg
- * encapsulation specification and is based on the self-delimited Opus
- * framing described in Appendix B of RFC 6716.
- * Normal Opus packets are just a degenerate case of multistream Opus packets,
- * and can be encoded or decoded with the multistream API by setting
- * streams
to 1
when initializing the encoder or
- * decoder.
- *
- * Multistream Opus streams can contain up to 255 elementary Opus streams.
- * These may be either "uncoupled" or "coupled", indicating that the decoder
- * is configured to decode them to either 1 or 2 channels, respectively.
- * The streams are ordered so that all coupled streams appear at the
- * beginning.
- *
- * A mapping
table defines which decoded channel i
- * should be used for each input/output (I/O) channel j
. This table is
- * typically provided as an unsigned char array.
- * Let i = mapping[j]
be the index for I/O channel j
.
- * If i < 2*coupled_streams
, then I/O channel j
is
- * encoded as the left channel of stream (i/2)
if i
- * is even, or as the right channel of stream (i/2)
if
- * i
is odd. Otherwise, I/O channel j
is encoded as
- * mono in stream (i - coupled_streams)
, unless it has the special
- * value 255, in which case it is omitted from the encoding entirely (the
- * decoder will reproduce it as silence). Each value i
must either
- * be the special value 255 or be less than streams + coupled_streams
.
- *
- * The output channels specified by the encoder
- * should use the
- * Vorbis
- * channel ordering. A decoder may wish to apply an additional permutation
- * to the mapping the encoder used to achieve a different output channel
- * order (e.g. for outputing in WAV order).
- *
- * Each multistream packet contains an Opus packet for each stream, and all of
- * the Opus packets in a single multistream packet must have the same
- * duration. Therefore the duration of a multistream packet can be extracted
- * from the TOC sequence of the first stream, which is located at the
- * beginning of the packet, just like an elementary Opus stream:
- *
- * @code
- * int nb_samples;
- * int nb_frames;
- * nb_frames = opus_packet_get_nb_frames(data, len);
- * if (nb_frames < 1)
- * return nb_frames;
- * nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames;
- * @endcode
- *
- * The general encoding and decoding process proceeds exactly the same as in
- * the normal @ref opus_encoder and @ref opus_decoder APIs.
- * See their documentation for an overview of how to use the corresponding
- * multistream functions.
- */
-
-/** Opus multistream encoder state.
- * This contains the complete state of a multistream Opus encoder.
- * It is position independent and can be freely copied.
- * @see opus_multistream_encoder_create
- * @see opus_multistream_encoder_init
- */
-typedef struct OpusMSEncoder OpusMSEncoder;
-
-/** Opus multistream decoder state.
- * This contains the complete state of a multistream Opus decoder.
- * It is position independent and can be freely copied.
- * @see opus_multistream_decoder_create
- * @see opus_multistream_decoder_init
- */
-typedef struct OpusMSDecoder OpusMSDecoder;
-
-/**\name Multistream encoder functions */
-/**@{*/
-
-/** Gets the size of an OpusMSEncoder structure.
- * @param streams int: The total number of streams to encode from the
- * input.
- * This must be no more than 255.
- * @param coupled_streams int: Number of coupled (2 channel) streams
- * to encode.
- * This must be no larger than the total
- * number of streams.
- * Additionally, The total number of
- * encoded channels (streams +
- * coupled_streams
) must be no
- * more than 255.
- * @returns The size in bytes on success, or a negative error code
- * (see @ref opus_errorcodes) on error.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size(
- int streams,
- int coupled_streams
-);
-
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_surround_encoder_get_size(
- int channels,
- int mapping_family
-);
-
-
-/** Allocates and initializes a multistream encoder state.
- * Call opus_multistream_encoder_destroy() to release
- * this object when finished.
- * @param Fs opus_int32: Sampling rate of the input signal (in Hz).
- * This must be one of 8000, 12000, 16000,
- * 24000, or 48000.
- * @param channels int: Number of channels in the input signal.
- * This must be at most 255.
- * It may be greater than the number of
- * coded channels (streams +
- * coupled_streams
).
- * @param streams int: The total number of streams to encode from the
- * input.
- * This must be no more than the number of channels.
- * @param coupled_streams int: Number of coupled (2 channel) streams
- * to encode.
- * This must be no larger than the total
- * number of streams.
- * Additionally, The total number of
- * encoded channels (streams +
- * coupled_streams
) must be no
- * more than the number of input channels.
- * @param[in] mapping const unsigned char[channels]
: Mapping from
- * encoded channels to input channels, as described in
- * @ref opus_multistream. As an extra constraint, the
- * multistream encoder does not allow encoding coupled
- * streams for which one channel is unused since this
- * is never a good idea.
- * @param application int: The target encoder application.
- * This must be one of the following:
- * streams +
- * coupled_streams
).
- * @param streams int: The total number of streams to encode from the
- * input.
- * This must be no more than the number of channels.
- * @param coupled_streams int: Number of coupled (2 channel) streams
- * to encode.
- * This must be no larger than the total
- * number of streams.
- * Additionally, The total number of
- * encoded channels (streams +
- * coupled_streams
) must be no
- * more than the number of input channels.
- * @param[in] mapping const unsigned char[channels]
: Mapping from
- * encoded channels to input channels, as described in
- * @ref opus_multistream. As an extra constraint, the
- * multistream encoder does not allow encoding coupled
- * streams for which one channel is unused since this
- * is never a good idea.
- * @param application int: The target encoder application.
- * This must be one of the following:
- * frame_size*channels
- * samples.
- * @param frame_size int: Number of samples per channel in the input
- * signal.
- * This must be an Opus frame size for the
- * encoder's sampling rate.
- * For example, at 48 kHz the permitted values
- * are 120, 240, 480, 960, 1920, and 2880.
- * Passing in a duration of less than 10 ms
- * (480 samples at 48 kHz) will prevent the
- * encoder from using the LPC or hybrid modes.
- * @param[out] data unsigned char*: Output payload.
- * This must contain storage for at
- * least \a max_data_bytes.
- * @param [in] max_data_bytes opus_int32: Size of the allocated
- * memory for the output
- * payload. This may be
- * used to impose an upper limit on
- * the instant bitrate, but should
- * not be used as the only bitrate
- * control. Use #OPUS_SET_BITRATE to
- * control the bitrate.
- * @returns The length of the encoded packet (in bytes) on success or a
- * negative error code (see @ref opus_errorcodes) on failure.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode(
- OpusMSEncoder *st,
- const opus_int16 *pcm,
- int frame_size,
- unsigned char *data,
- opus_int32 max_data_bytes
-) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
-
-/** Encodes a multistream Opus frame from floating point input.
- * @param st OpusMSEncoder*: Multistream encoder state.
- * @param[in] pcm const float*: The input signal as interleaved
- * samples 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
- * dynamic range.
- * This must contain
- * frame_size*channels
- * samples.
- * @param frame_size int: Number of samples per channel in the input
- * signal.
- * This must be an Opus frame size for the
- * encoder's sampling rate.
- * For example, at 48 kHz the permitted values
- * are 120, 240, 480, 960, 1920, and 2880.
- * Passing in a duration of less than 10 ms
- * (480 samples at 48 kHz) will prevent the
- * encoder from using the LPC or hybrid modes.
- * @param[out] data unsigned char*: Output payload.
- * This must contain storage for at
- * least \a max_data_bytes.
- * @param [in] max_data_bytes opus_int32: Size of the allocated
- * memory for the output
- * payload. This may be
- * used to impose an upper limit on
- * the instant bitrate, but should
- * not be used as the only bitrate
- * control. Use #OPUS_SET_BITRATE to
- * control the bitrate.
- * @returns The length of the encoded packet (in bytes) on success or a
- * negative error code (see @ref opus_errorcodes) on failure.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float(
- OpusMSEncoder *st,
- const float *pcm,
- int frame_size,
- unsigned char *data,
- opus_int32 max_data_bytes
-) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
-
-/** Frees an OpusMSEncoder
allocated by
- * opus_multistream_encoder_create().
- * @param st OpusMSEncoder*: Multistream encoder state to be freed.
- */
-OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st);
-
-/** Perform a CTL function on a multistream Opus encoder.
- *
- * Generally the request and subsequent arguments are generated by a
- * convenience macro.
- * @param st OpusMSEncoder*: Multistream encoder state.
- * @param request This and all remaining parameters should be replaced by one
- * of the convenience macros in @ref opus_genericctls,
- * @ref opus_encoderctls, or @ref opus_multistream_ctls.
- * @see opus_genericctls
- * @see opus_encoderctls
- * @see opus_multistream_ctls
- */
-OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
-
-/**@}*/
-
-/**\name Multistream decoder functions */
-/**@{*/
-
-/** Gets the size of an OpusMSDecoder
structure.
- * @param streams int: The total number of streams coded in the
- * input.
- * This must be no more than 255.
- * @param coupled_streams int: Number streams to decode as coupled
- * (2 channel) streams.
- * This must be no larger than the total
- * number of streams.
- * Additionally, The total number of
- * coded channels (streams +
- * coupled_streams
) must be no
- * more than 255.
- * @returns The size in bytes on success, or a negative error code
- * (see @ref opus_errorcodes) on error.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size(
- int streams,
- int coupled_streams
-);
-
-/** Allocates and initializes a multistream decoder state.
- * Call opus_multistream_decoder_destroy() to release
- * this object when finished.
- * @param Fs opus_int32: Sampling rate to decode at (in Hz).
- * This must be one of 8000, 12000, 16000,
- * 24000, or 48000.
- * @param channels int: Number of channels to output.
- * This must be at most 255.
- * It may be different from the number of coded
- * channels (streams +
- * coupled_streams
).
- * @param streams int: The total number of streams coded in the
- * input.
- * This must be no more than 255.
- * @param coupled_streams int: Number of streams to decode as coupled
- * (2 channel) streams.
- * This must be no larger than the total
- * number of streams.
- * Additionally, The total number of
- * coded channels (streams +
- * coupled_streams
) must be no
- * more than 255.
- * @param[in] mapping const unsigned char[channels]
: Mapping from
- * coded channels to output channels, as described in
- * @ref opus_multistream.
- * @param[out] error int *: Returns #OPUS_OK on success, or an error
- * code (see @ref opus_errorcodes) on
- * failure.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_create(
- opus_int32 Fs,
- int channels,
- int streams,
- int coupled_streams,
- const unsigned char *mapping,
- int *error
-) OPUS_ARG_NONNULL(5);
-
-/** Intialize a previously allocated decoder state object.
- * The memory pointed to by \a st must be at least the size returned by
- * opus_multistream_encoder_get_size().
- * This is intended for applications which use their own allocator instead of
- * malloc.
- * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
- * @see opus_multistream_decoder_create
- * @see opus_multistream_deocder_get_size
- * @param st OpusMSEncoder*: Multistream encoder state to initialize.
- * @param Fs opus_int32: Sampling rate to decode at (in Hz).
- * This must be one of 8000, 12000, 16000,
- * 24000, or 48000.
- * @param channels int: Number of channels to output.
- * This must be at most 255.
- * It may be different from the number of coded
- * channels (streams +
- * coupled_streams
).
- * @param streams int: The total number of streams coded in the
- * input.
- * This must be no more than 255.
- * @param coupled_streams int: Number of streams to decode as coupled
- * (2 channel) streams.
- * This must be no larger than the total
- * number of streams.
- * Additionally, The total number of
- * coded channels (streams +
- * coupled_streams
) must be no
- * more than 255.
- * @param[in] mapping const unsigned char[channels]
: Mapping from
- * coded channels to output channels, as described in
- * @ref opus_multistream.
- * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
- * on failure.
- */
-OPUS_EXPORT int opus_multistream_decoder_init(
- OpusMSDecoder *st,
- opus_int32 Fs,
- int channels,
- int streams,
- int coupled_streams,
- const unsigned char *mapping
-) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
-
-/** Decode a multistream Opus packet.
- * @param st OpusMSDecoder*: Multistream decoder state.
- * @param[in] data const unsigned char*: Input payload.
- * Use a NULL
- * pointer to indicate packet
- * loss.
- * @param len opus_int32: Number of bytes in payload.
- * @param[out] pcm opus_int16*: Output signal, with interleaved
- * samples.
- * This must contain room for
- * frame_size*channels
- * samples.
- * @param frame_size int: The number of samples per channel of
- * available space in \a pcm.
- * If this is less than the maximum packet duration
- * (120 ms; 5760 for 48kHz), this function will not be capable
- * of decoding some packets. In the case of PLC (data==NULL)
- * or FEC (decode_fec=1), then frame_size needs to be exactly
- * the duration of audio that is missing, otherwise the
- * decoder will not be in the optimal state to decode the
- * next incoming packet. For the PLC and FEC cases, frame_size
- * must be a multiple of 2.5 ms.
- * @param decode_fec int: Flag (0 or 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 samples decoded on success or a negative error code
- * (see @ref opus_errorcodes) on failure.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode(
- OpusMSDecoder *st,
- const unsigned char *data,
- opus_int32 len,
- opus_int16 *pcm,
- int frame_size,
- int decode_fec
-) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
-
-/** Decode a multistream Opus packet with floating point output.
- * @param st OpusMSDecoder*: Multistream decoder state.
- * @param[in] data const unsigned char*: Input payload.
- * Use a NULL
- * pointer to indicate packet
- * loss.
- * @param len opus_int32: Number of bytes in payload.
- * @param[out] pcm opus_int16*: Output signal, with interleaved
- * samples.
- * This must contain room for
- * frame_size*channels
- * samples.
- * @param frame_size int: The number of samples per channel of
- * available space in \a pcm.
- * If this is less than the maximum packet duration
- * (120 ms; 5760 for 48kHz), this function will not be capable
- * of decoding some packets. In the case of PLC (data==NULL)
- * or FEC (decode_fec=1), then frame_size needs to be exactly
- * the duration of audio that is missing, otherwise the
- * decoder will not be in the optimal state to decode the
- * next incoming packet. For the PLC and FEC cases, frame_size
- * must be a multiple of 2.5 ms.
- * @param decode_fec int: Flag (0 or 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 samples decoded on success or a negative error code
- * (see @ref opus_errorcodes) on failure.
- */
-OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float(
- OpusMSDecoder *st,
- const unsigned char *data,
- opus_int32 len,
- float *pcm,
- int frame_size,
- int decode_fec
-) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
-
-/** Perform a CTL function on a multistream Opus decoder.
- *
- * Generally the request and subsequent arguments are generated by a
- * convenience macro.
- * @param st OpusMSDecoder*: Multistream decoder state.
- * @param request This and all remaining parameters should be replaced by one
- * of the convenience macros in @ref opus_genericctls,
- * @ref opus_decoderctls, or @ref opus_multistream_ctls.
- * @see opus_genericctls
- * @see opus_decoderctls
- * @see opus_multistream_ctls
- */
-OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
-
-/** Frees an OpusMSDecoder
allocated by
- * opus_multistream_decoder_create().
- * @param st OpusMSDecoder: Multistream decoder state to be freed.
- */
-OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st);
-
-/**@}*/
-
-/**@}*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OPUS_MULTISTREAM_H */
diff --git a/extlibs/headers/opus/opus_types.h b/extlibs/headers/opus/opus_types.h
deleted file mode 100644
index b28e03ae..00000000
--- a/extlibs/headers/opus/opus_types.h
+++ /dev/null
@@ -1,159 +0,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 COPYRIGHT OWNER
- 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 based on ogg_types.h 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 stdio
(FILE *
), memory buffers, and URLs
- (including NULL
pointer was passed where one was unexpected, or an
- internal memory allocation failed, or an internal library error was
- encountered.*/
-#define OP_EFAULT (-129)
-/**The stream used a feature that is not implemented, such as an unsupported
- channel family.*/
-#define OP_EIMPL (-130)
-/**One or more parameters to a function were invalid.*/
-#define OP_EINVAL (-131)
-/**A purported Ogg Opus stream did not begin with an Ogg page, a purported
- header packet did not start with one of the required strings, "OpusHead" or
- "OpusTags", or a link in a chained file was encountered that did not
- contain any logical Opus streams.*/
-#define OP_ENOTFORMAT (-132)
-/**A required header packet was not properly formatted, contained illegal
- values, or was missing altogether.*/
-#define OP_EBADHEADER (-133)
-/**The ID header contained an unrecognized version number.*/
-#define OP_EVERSION (-134)
-/*Currently not used at all.*/
-#define OP_ENOTAUDIO (-135)
-/**An audio packet failed to decode properly.
- This is usually caused by a multistream Ogg packet where the durations of
- the individual Opus packets contained in it are not all the same.*/
-#define OP_EBADPACKET (-136)
-/**We failed to find data we had seen before, or the bitstream structure was
- sufficiently malformed that seeking to the target destination was
- impossible.*/
-#define OP_EBADLINK (-137)
-/**An operation that requires seeking was requested on an unseekable stream.*/
-#define OP_ENOSEEK (-138)
-/**The first or last granule position of a link failed basic validity checks.*/
-#define OP_EBADTIMESTAMP (-139)
-
-/*@}*/
-/*@}*/
-
-/**\defgroup header_info Header Information*/
-/*@{*/
-
-/**The maximum number of channels in an Ogg Opus stream.*/
-#define OPUS_CHANNEL_COUNT_MAX (255)
-
-/**Ogg Opus bitstream information.
- This contains the basic playback parameters for a stream, and corresponds to
- the initial ID header packet of an Ogg Opus stream.*/
-struct OpusHead{
- /**The Ogg Opus format version, in the range 0...255.
- The top 4 bits represent a "major" version, and the bottom four bits
- represent backwards-compatible "minor" revisions.
- The current specification describes version 1.
- This library will recognize versions up through 15 as backwards compatible
- with the current specification.
- An earlier draft of the specification described a version 0, but the only
- difference between version 1 and version 0 is that version 0 did
- not specify the semantics for handling the version field.*/
- int version;
- /**The number of channels, in the range 1...255.*/
- int channel_count;
- /**The number of samples that should be discarded from the beginning of the
- stream.*/
- unsigned pre_skip;
- /**The sampling rate of the original input.
- All Opus audio is coded at 48 kHz, and should also be decoded at 48 kHz
- for playback (unless the target hardware does not support this sampling
- rate).
- However, this field may be used to resample the audio back to the original
- sampling rate, for example, when saving the output to a file.*/
- opus_uint32 input_sample_rate;
- /**The gain to apply to the decoded output, in dB, as a Q8 value in the range
- -32768...32767.
- The libopusfile API will automatically apply this gain to the
- decoded output before returning it, scaling it by
- pow(10,output_gain/(20.0*256))
.*/
- int output_gain;
- /**The channel mapping family, in the range 0...255.
- Channel mapping family 0 covers mono or stereo in a single stream.
- Channel mapping family 1 covers 1 to 8 channels in one or more streams,
- using the Vorbis speaker assignments.
- Channel mapping family 255 covers 1 to 255 channels in one or more
- streams, but without any defined speaker assignment.*/
- int mapping_family;
- /**The number of Opus streams in each Ogg packet, in the range 1...255.*/
- int stream_count;
- /**The number of coupled Opus streams in each Ogg packet, in the range
- 0...127.
- This must satisfy 0 <= coupled_count <= stream_count
and
- coupled_count + stream_count <= 255
.
- The coupled streams appear first, before all uncoupled streams, in an Ogg
- Opus packet.*/
- int coupled_count;
- /**The mapping from coded stream channels to output channels.
- Let index=mapping[k]
be the value for channel k
.
- If index<2*coupled_count
, then it refers to the left channel
- from stream (index/2)
if even, and the right channel from
- stream (index/2)
if odd.
- Otherwise, it refers to the output of the uncoupled stream
- (index-coupled_count)
.*/
- unsigned char mapping[OPUS_CHANNEL_COUNT_MAX];
-};
-
-/**The metadata from an Ogg Opus stream.
-
- This structure holds the in-stream metadata corresponding to the 'comment'
- header packet of an Ogg Opus stream.
- The comment header is meant to be used much like someone jotting a quick
- note on the label of a CD.
- It should be a short, to the point text note that can be more than a couple
- words, but not more than a short paragraph.
-
- The metadata is stored as a series of (tag, value) pairs, in length-encoded
- string vectors, using the same format as Vorbis (without the final "framing
- bit"), Theora, and Speex, except for the packet header.
- The first occurrence of the '=' character delimits the tag and value.
- A particular tag may occur more than once, and order is significant.
- The character set encoding for the strings is always UTF-8, but the tag
- names are limited to ASCII, and treated as case-insensitive.
- See the Vorbis
- comment header specification for details.
-
- In filling in this structure, libopusfile will null-terminate the
- #user_comments strings for safety.
- However, the bitstream format itself treats them as 8-bit clean vectors,
- possibly containing NUL characters, so the #comment_lengths array should be
- treated as their authoritative length.
-
- This structure is binary and source-compatible with a
- vorbis_comment
, and pointers to it may be freely cast to
- vorbis_comment
pointers, and vice versa.
- It is provided as a separate type to avoid introducing a compile-time
- dependency on the libvorbis headers.*/
-struct OpusTags{
- /**The array of comment string vectors.*/
- char **user_comments;
- /**An array of the corresponding length of each vector, in bytes.*/
- int *comment_lengths;
- /**The total number of comment streams.*/
- int comments;
- /**The null-terminated vendor string.
- This identifies the software used to encode the stream.*/
- char *vendor;
-};
-
-/**\name Picture tag image formats*/
-/*@{*/
-
-/**The MIME type was not recognized, or the image data did not match the
- declared MIME type.*/
-#define OP_PIC_FORMAT_UNKNOWN (-1)
-/**The MIME type indicates the image data is really a URL.*/
-#define OP_PIC_FORMAT_URL (0)
-/**The image is a JPEG.*/
-#define OP_PIC_FORMAT_JPEG (1)
-/**The image is a PNG.*/
-#define OP_PIC_FORMAT_PNG (2)
-/**The image is a GIF.*/
-#define OP_PIC_FORMAT_GIF (3)
-
-/*@}*/
-
-/**The contents of a METADATA_BLOCK_PICTURE tag.*/
-struct OpusPictureTag{
- /**The picture type according to the ID3v2 APIC frame:
- "-->"
to signify that the data part
- is a URL pointing to the picture instead of the picture data itself.
- In this case, a terminating NUL is appended to the URL string in #data,
- but #data_length is set to the length of the string excluding that
- terminating NUL.*/
- char *mime_type;
- /**The description of the picture, in UTF-8.*/
- char *description;
- /**The width of the picture in pixels.*/
- opus_uint32 width;
- /**The height of the picture in pixels.*/
- opus_uint32 height;
- /**The color depth of the picture in bits-per-pixel (not
- bits-per-channel).*/
- opus_uint32 depth;
- /**For indexed-color pictures (e.g., GIF), the number of colors used, or 0
- for non-indexed pictures.*/
- opus_uint32 colors;
- /**The length of the picture data in bytes.*/
- opus_uint32 data_length;
- /**The binary picture data.*/
- unsigned char *data;
- /**The format of the picture data, if known.
- One of
- NULL
to merely test the header
- for validity.
- \param[in] _data The contents of the ID header packet.
- \param _len The number of bytes of data in the ID header packet.
- \return 0 on success or a negative value on error.
- \retval #OP_ENOTFORMAT If the data does not start with the "OpusHead"
- string.
- \retval #OP_EVERSION If the version field signaled a version this library
- does not know how to parse.
- \retval #OP_EIMPL If the channel mapping family was 255, which general
- purpose players should not attempt to play.
- \retval #OP_EBADHEADER If the contents of the packet otherwise violate the
- Ogg Opus specification:
- _gp-_head->pre_skip
.
- Granule position values smaller than OpusHead#pre_skip correspond to audio
- that should never be played, and thus have no associated sample offset.
- This function returns -1 for such values.
- This function also correctly handles extremely large granule positions,
- which may have wrapped around to a negative number when stored in a signed
- ogg_int64_t value.
- \param _head The #OpusHead information from the ID header of the stream.
- \param _gp The granule position to convert.
- \return The sample offset associated with the given granule position
- (counting at a 48 kHz sampling rate), or the special value -1 on
- error (i.e., the granule position was smaller than the pre-skip
- amount).*/
-ogg_int64_t opus_granule_sample(const OpusHead *_head,ogg_int64_t _gp)
- OP_ARG_NONNULL(1);
-
-/**Parses the contents of the 'comment' header packet of an Ogg Opus stream.
- \param[out] _tags An uninitialized #OpusTags structure.
- This returns the contents of the parsed packet.
- The contents of this structure are untouched on error.
- This may be NULL
to merely test the header
- for validity.
- \param[in] _data The contents of the 'comment' header packet.
- \param _len The number of bytes of data in the 'info' header packet.
- \retval 0 Success.
- \retval #OP_ENOTFORMAT If the data does not start with the "OpusTags"
- string.
- \retval #OP_EBADHEADER If the contents of the packet otherwise violate the
- Ogg Opus specification.
- \retval #OP_EFAULT If there wasn't enough memory to store the tags.*/
-OP_WARN_UNUSED_RESULT int opus_tags_parse(OpusTags *_tags,
- const unsigned char *_data,size_t _len) OP_ARG_NONNULL(2);
-
-/**Performs a deep copy of an #OpusTags structure.
- \param _dst The #OpusTags structure to copy into.
- If this function fails, the contents of this structure remain
- untouched.
- \param _src The #OpusTags structure to copy from.
- \retval 0 Success.
- \retval #OP_EFAULT If there wasn't enough memory to copy the tags.*/
-int opus_tags_copy(OpusTags *_dst,const OpusTags *_src) OP_ARG_NONNULL(1);
-
-/**Initializes an #OpusTags structure.
- This should be called on a freshly allocated #OpusTags structure before
- attempting to use it.
- \param _tags The #OpusTags structure to initialize.*/
-void opus_tags_init(OpusTags *_tags) OP_ARG_NONNULL(1);
-
-/**Add a (tag, value) pair to an initialized #OpusTags structure.
- \note Neither opus_tags_add() nor opus_tags_add_comment() support values
- containing embedded NULs, although the bitstream format does support them.
- To add such tags, you will need to manipulate the #OpusTags structure
- directly.
- \param _tags The #OpusTags structure to add the (tag, value) pair to.
- \param _tag A NUL-terminated, case-insensitive, ASCII string containing
- the tag to add (without an '=' character).
- \param _value A NUL-terminated UTF-8 containing the corresponding value.
- \return 0 on success, or a negative value on failure.
- \retval #OP_EFAULT An internal memory allocation failed.*/
-int opus_tags_add(OpusTags *_tags,const char *_tag,const char *_value)
- OP_ARG_NONNULL(1) OP_ARG_NONNULL(2) OP_ARG_NONNULL(3);
-
-/**Add a comment to an initialized #OpusTags structure.
- \note Neither opus_tags_add_comment() nor opus_tags_add() support comments
- containing embedded NULs, although the bitstream format does support them.
- To add such tags, you will need to manipulate the #OpusTags structure
- directly.
- \param _tags The #OpusTags structure to add the comment to.
- \param _comment A NUL-terminated UTF-8 string containing the comment in
- "TAG=value" form.
- \return 0 on success, or a negative value on failure.
- \retval #OP_EFAULT An internal memory allocation failed.*/
-int opus_tags_add_comment(OpusTags *_tags,const char *_comment)
- OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
-
-/**Replace the binary suffix data at the end of the packet (if any).
- \param _tags An initialized #OpusTags structure.
- \param _data A buffer of binary data to append after the encoded user
- comments.
- The least significant bit of the first byte of this data must
- be set (to ensure the data is preserved by other editors).
- \param _len The number of bytes of binary data to append.
- This may be zero to remove any existing binary suffix data.
- \return 0 on success, or a negative value on error.
- \retval #OP_EINVAL \a _len was negative, or \a _len was positive but
- \a _data was NULL
or the least significant
- bit of the first byte was not set.
- \retval #OP_EFAULT An internal memory allocation failed.*/
-int opus_tags_set_binary_suffix(OpusTags *_tags,
- const unsigned char *_data,int _len) OP_ARG_NONNULL(1);
-
-/**Look up a comment value by its tag.
- \param _tags An initialized #OpusTags structure.
- \param _tag The tag to look up.
- \param _count The instance of the tag.
- The same tag can appear multiple times, each with a distinct
- value, so an index is required to retrieve them all.
- The order in which these values appear is significant and
- should be preserved.
- Use opus_tags_query_count() to get the legal range for the
- \a _count parameter.
- \return A pointer to the queried tag's value.
- This points directly to data in the #OpusTags structure.
- It should not be modified or freed by the application, and
- modifications to the structure may invalidate the pointer.
- \retval NULL If no matching tag is found.*/
-const char *opus_tags_query(const OpusTags *_tags,const char *_tag,int _count)
- OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
-
-/**Look up the number of instances of a tag.
- Call this first when querying for a specific tag and then iterate over the
- number of instances with separate calls to opus_tags_query() to retrieve
- all the values for that tag in order.
- \param _tags An initialized #OpusTags structure.
- \param _tag The tag to look up.
- \return The number of instances of this particular tag.*/
-int opus_tags_query_count(const OpusTags *_tags,const char *_tag)
- OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
-
-/**Retrieve the binary suffix data at the end of the packet (if any).
- \param _tags An initialized #OpusTags structure.
- \param[out] _len Returns the number of bytes of binary suffix data returned.
- \return A pointer to the binary suffix data, or NULL
if none
- was present.*/
-const unsigned char *opus_tags_get_binary_suffix(const OpusTags *_tags,
- int *_len) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
-
-/**Get the album gain from an R128_ALBUM_GAIN tag, if one was specified.
- This searches for the first R128_ALBUM_GAIN tag with a valid signed,
- 16-bit decimal integer value and returns the value.
- This routine is exposed merely for convenience for applications which wish
- to do something special with the album gain (i.e., display it).
- If you simply wish to apply the album gain instead of the header gain, you
- can use op_set_gain_offset() with an #OP_ALBUM_GAIN type and no offset.
- \param _tags An initialized #OpusTags structure.
- \param[out] _gain_q8 The album gain, in 1/256ths of a dB.
- This will lie in the range [-32768,32767], and should
- be applied in addition to the header gain.
- On error, no value is returned, and the previous
- contents remain unchanged.
- \return 0 on success, or a negative value on error.
- \retval #OP_FALSE There was no album gain available in the given tags.*/
-int opus_tags_get_album_gain(const OpusTags *_tags,int *_gain_q8)
- OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
-
-/**Get the track gain from an R128_TRACK_GAIN tag, if one was specified.
- This searches for the first R128_TRACK_GAIN tag with a valid signed,
- 16-bit decimal integer value and returns the value.
- This routine is exposed merely for convenience for applications which wish
- to do something special with the track gain (i.e., display it).
- If you simply wish to apply the track gain instead of the header gain, you
- can use op_set_gain_offset() with an #OP_TRACK_GAIN type and no offset.
- \param _tags An initialized #OpusTags structure.
- \param[out] _gain_q8 The track gain, in 1/256ths of a dB.
- This will lie in the range [-32768,32767], and should
- be applied in addition to the header gain.
- On error, no value is returned, and the previous
- contents remain unchanged.
- \return 0 on success, or a negative value on error.
- \retval #OP_FALSE There was no track gain available in the given tags.*/
-int opus_tags_get_track_gain(const OpusTags *_tags,int *_gain_q8)
- OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
-
-/**Clears the #OpusTags structure.
- This should be called on an #OpusTags structure after it is no longer
- needed.
- It will free all memory used by the structure members.
- \param _tags The #OpusTags structure to clear.*/
-void opus_tags_clear(OpusTags *_tags) OP_ARG_NONNULL(1);
-
-/**Check if \a _comment is an instance of a \a _tag_name tag.
- \see opus_tagncompare
- \param _tag_name A NUL-terminated, case-insensitive, ASCII string containing
- the name of the tag to check for (without the terminating
- '=' character).
- \param _comment The comment string to check.
- \return An integer less than, equal to, or greater than zero if \a _comment
- is found respectively, to be less than, to match, or be greater
- than a "tag=value" string whose tag matches \a _tag_name.*/
-int opus_tagcompare(const char *_tag_name,const char *_comment);
-
-/**Check if \a _comment is an instance of a \a _tag_name tag.
- This version is slightly more efficient than opus_tagcompare() if the length
- of the tag name is already known (e.g., because it is a constant).
- \see opus_tagcompare
- \param _tag_name A case-insensitive ASCII string containing the name of the
- tag to check for (without the terminating '=' character).
- \param _tag_len The number of characters in the tag name.
- This must be non-negative.
- \param _comment The comment string to check.
- \return An integer less than, equal to, or greater than zero if \a _comment
- is found respectively, to be less than, to match, or be greater
- than a "tag=value" string whose tag matches the first \a _tag_len
- characters of \a _tag_name.*/
-int opus_tagncompare(const char *_tag_name,int _tag_len,const char *_comment);
-
-/**Parse a single METADATA_BLOCK_PICTURE tag.
- This decodes the BASE64-encoded content of the tag and returns a structure
- with the MIME type, description, image parameters (if known), and the
- compressed image data.
- If the MIME type indicates the presence of an image format we recognize
- (JPEG, PNG, or GIF) and the actual image data contains the magic signature
- associated with that format, then the OpusPictureTag::format field will be
- set to the corresponding format.
- This is provided as a convenience to avoid requiring applications to parse
- the MIME type and/or do their own format detection for the commonly used
- formats.
- In this case, we also attempt to extract the image parameters directly from
- the image data (overriding any that were present in the tag, which the
- specification says applications are not meant to rely on).
- The application must still provide its own support for actually decoding the
- image data and, if applicable, retrieving that data from URLs.
- \param[out] _pic Returns the parsed picture data.
- No sanitation is done on the type, MIME type, or
- description fields, so these might return invalid values.
- The contents of this structure are left unmodified on
- failure.
- \param _tag The METADATA_BLOCK_PICTURE tag contents.
- The leading "METADATA_BLOCK_PICTURE=" portion is optional,
- to allow the function to be used on either directly on the
- values in OpusTags::user_comments or on the return value
- of opus_tags_query().
- \return 0 on success or a negative value on error.
- \retval #OP_ENOTFORMAT The METADATA_BLOCK_PICTURE contents were not valid.
- \retval #OP_EFAULT There was not enough memory to store the picture tag
- contents.*/
-OP_WARN_UNUSED_RESULT int opus_picture_tag_parse(OpusPictureTag *_pic,
- const char *_tag) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
-
-/**Initializes an #OpusPictureTag structure.
- This should be called on a freshly allocated #OpusPictureTag structure
- before attempting to use it.
- \param _pic The #OpusPictureTag structure to initialize.*/
-void opus_picture_tag_init(OpusPictureTag *_pic) OP_ARG_NONNULL(1);
-
-/**Clears the #OpusPictureTag structure.
- This should be called on an #OpusPictureTag structure after it is no longer
- needed.
- It will free all memory used by the structure members.
- \param _pic The #OpusPictureTag structure to clear.*/
-void opus_picture_tag_clear(OpusPictureTag *_pic) OP_ARG_NONNULL(1);
-
-/*@}*/
-
-/*@}*/
-
-/**\defgroup url_options URL Reading Options*/
-/*@{*/
-/**\name URL reading options
- Options for op_url_stream_create() and associated functions.
- These allow you to provide proxy configuration parameters, skip SSL
- certificate checks, etc.
- Options are processed in order, and if the same option is passed multiple
- times, only the value specified by the last occurrence has an effect
- (unless otherwise specified).
- They may be expanded in the future.*/
-/*@{*/
-
-/**@cond PRIVATE*/
-
-/*These are the raw numbers used to define the request codes.
- They should not be used directly.*/
-#define OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST (6464)
-#define OP_HTTP_PROXY_HOST_REQUEST (6528)
-#define OP_HTTP_PROXY_PORT_REQUEST (6592)
-#define OP_HTTP_PROXY_USER_REQUEST (6656)
-#define OP_HTTP_PROXY_PASS_REQUEST (6720)
-#define OP_GET_SERVER_INFO_REQUEST (6784)
-
-#define OP_URL_OPT(_request) ((_request)+(char *)0)
-
-/*These macros trigger compilation errors or warnings if the wrong types are
- provided to one of the URL options.*/
-#define OP_CHECK_INT(_x) ((void)((_x)==(opus_int32)0),(opus_int32)(_x))
-#define OP_CHECK_CONST_CHAR_PTR(_x) ((_x)+((_x)-(const char *)(_x)))
-#define OP_CHECK_SERVER_INFO_PTR(_x) ((_x)+((_x)-(OpusServerInfo *)(_x)))
-
-/**@endcond*/
-
-/**HTTP/Shoutcast/Icecast server information associated with a URL.*/
-struct OpusServerInfo{
- /**The name of the server (icy-name/ice-name).
- This is NULL
if there was no icy-name
or
- ice-name
header.*/
- char *name;
- /**A short description of the server (icy-description/ice-description).
- This is NULL
if there was no icy-description
or
- ice-description
header.*/
- char *description;
- /**The genre the server falls under (icy-genre/ice-genre).
- This is NULL
if there was no icy-genre
or
- ice-genre
header.*/
- char *genre;
- /**The homepage for the server (icy-url/ice-url).
- This is NULL
if there was no icy-url
or
- ice-url
header.*/
- char *url;
- /**The software used by the origin server (Server).
- This is NULL
if there was no Server
header.*/
- char *server;
- /**The media type of the entity sent to the recepient (Content-Type).
- This is NULL
if there was no Content-Type
- header.*/
- char *content_type;
- /**The nominal stream bitrate in kbps (icy-br/ice-bitrate).
- This is -1
if there was no icy-br
or
- ice-bitrate
header.*/
- opus_int32 bitrate_kbps;
- /**Flag indicating whether the server is public (1
) or not
- (0
) (icy-pub/ice-public).
- This is -1
if there was no icy-pub
or
- ice-public
header.*/
- int is_public;
- /**Flag indicating whether the server is using HTTPS instead of HTTP.
- This is 0
unless HTTPS is being used.
- This may not match the protocol used in the original URL if there were
- redirections.*/
- int is_ssl;
-};
-
-/**Initializes an #OpusServerInfo structure.
- All fields are set as if the corresponding header was not available.
- \param _info The #OpusServerInfo structure to initialize.
- \note If you use this function, you must link against libopusurl.*/
-void opus_server_info_init(OpusServerInfo *_info) OP_ARG_NONNULL(1);
-
-/**Clears the #OpusServerInfo structure.
- This should be called on an #OpusServerInfo structure after it is no longer
- needed.
- It will free all memory used by the structure members.
- \param _info The #OpusServerInfo structure to clear.
- \note If you use this function, you must link against libopusurl.*/
-void opus_server_info_clear(OpusServerInfo *_info) OP_ARG_NONNULL(1);
-
-/**Skip the certificate check when connecting via TLS/SSL (https).
- \param _b opus_int32
: Whether or not to skip the certificate
- check.
- The check will be skipped if \a _b is non-zero, and will not be
- skipped if \a _b is zero.
- \hideinitializer*/
-#define OP_SSL_SKIP_CERTIFICATE_CHECK(_b) \
- OP_URL_OPT(OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST),OP_CHECK_INT(_b)
-
-/**Proxy connections through the given host.
- If no port is specified via #OP_HTTP_PROXY_PORT, the port number defaults
- to 8080 (http-alt).
- All proxy parameters are ignored for non-http and non-https URLs.
- \param _host const char *
: The proxy server hostname.
- This may be NULL
to disable the use of a proxy
- server.
- \hideinitializer*/
-#define OP_HTTP_PROXY_HOST(_host) \
- OP_URL_OPT(OP_HTTP_PROXY_HOST_REQUEST),OP_CHECK_CONST_CHAR_PTR(_host)
-
-/**Use the given port when proxying connections.
- This option only has an effect if #OP_HTTP_PROXY_HOST is specified with a
- non-NULL
\a _host.
- If this option is not provided, the proxy port number defaults to 8080
- (http-alt).
- All proxy parameters are ignored for non-http and non-https URLs.
- \param _port opus_int32
: The proxy server port.
- This must be in the range 0...65535 (inclusive), or the
- URL function this is passed to will fail.
- \hideinitializer*/
-#define OP_HTTP_PROXY_PORT(_port) \
- OP_URL_OPT(OP_HTTP_PROXY_PORT_REQUEST),OP_CHECK_INT(_port)
-
-/**Use the given user name for authentication when proxying connections.
- All proxy parameters are ignored for non-http and non-https URLs.
- \param _user const char *: The proxy server user name.
- This may be NULL
to disable proxy
- authentication.
- A non-NULL
value only has an effect
- if #OP_HTTP_PROXY_HOST and #OP_HTTP_PROXY_PASS
- are also specified with non-NULL
- arguments.
- \hideinitializer*/
-#define OP_HTTP_PROXY_USER(_user) \
- OP_URL_OPT(OP_HTTP_PROXY_USER_REQUEST),OP_CHECK_CONST_CHAR_PTR(_user)
-
-/**Use the given password for authentication when proxying connections.
- All proxy parameters are ignored for non-http and non-https URLs.
- \param _pass const char *: The proxy server password.
- This may be NULL
to disable proxy
- authentication.
- A non-NULL
value only has an effect
- if #OP_HTTP_PROXY_HOST and #OP_HTTP_PROXY_USER
- are also specified with non-NULL
- arguments.
- \hideinitializer*/
-#define OP_HTTP_PROXY_PASS(_pass) \
- OP_URL_OPT(OP_HTTP_PROXY_PASS_REQUEST),OP_CHECK_CONST_CHAR_PTR(_pass)
-
-/**Parse information about the streaming server (if any) and return it.
- Very little validation is done.
- In particular, OpusServerInfo::url may not be a valid URL,
- OpusServerInfo::bitrate_kbps may not really be in kbps, and
- OpusServerInfo::content_type may not be a valid MIME type.
- The character set of the string fields is not specified anywhere, and should
- not be assumed to be valid UTF-8.
- \param _info OpusServerInfo *: Returns information about the server.
- If there is any error opening the stream, the
- contents of this structure remain
- unmodified.
- On success, fills in the structure with the
- server information that was available, if
- any.
- After a successful return, the contents of
- this structure should be freed by calling
- opus_server_info_clear().
- \hideinitializer*/
-#define OP_GET_SERVER_INFO(_info) \
- OP_URL_OPT(OP_GET_SERVER_INFO_REQUEST),OP_CHECK_SERVER_INFO_PTR(_info)
-
-/*@}*/
-/*@}*/
-
-/**\defgroup stream_callbacks Abstract Stream Reading Interface*/
-/*@{*/
-/**\name Functions for reading from streams
- These functions define the interface used to read from and seek in a stream
- of data.
- A stream does not need to implement seeking, but the decoder will not be
- able to seek if it does not do so.
- These functions also include some convenience routines for working with
- standard FILE
pointers, complete streams stored in a single
- block of memory, or URLs.*/
-/*@{*/
-
-/**Reads up to \a _nbytes bytes of data from \a _stream.
- \param _stream The stream to read from.
- \param[out] _ptr The buffer to store the data in.
- \param _nbytes The maximum number of bytes to read.
- This function may return fewer, though it will not
- return zero unless it reaches end-of-file.
- \return The number of bytes successfully read, or a negative value on
- error.*/
-typedef int (*op_read_func)(void *_stream,unsigned char *_ptr,int _nbytes);
-
-/**Sets the position indicator for \a _stream.
- The new position, measured in bytes, is obtained by adding \a _offset
- bytes to the position specified by \a _whence.
- If \a _whence is set to SEEK_SET
, SEEK_CUR
, or
- SEEK_END
, the offset is relative to the start of the stream,
- the current position indicator, or end-of-file, respectively.
- \retval 0 Success.
- \retval -1 Seeking is not supported or an error occurred.
- errno
need not be set.*/
-typedef int (*op_seek_func)(void *_stream,opus_int64 _offset,int _whence);
-
-/**Obtains the current value of the position indicator for \a _stream.
- \return The current position indicator.*/
-typedef opus_int64 (*op_tell_func)(void *_stream);
-
-/**Closes the underlying stream.
- \retval 0 Success.
- \retval EOF An error occurred.
- errno
need not be set.*/
-typedef int (*op_close_func)(void *_stream);
-
-/**The callbacks used to access non-FILE
stream resources.
- The function prototypes are basically the same as for the stdio functions
- fread()
, fseek()
, ftell()
, and
- fclose()
.
- The differences are that the FILE *
arguments have been
- replaced with a void *
, which is to be used as a pointer to
- whatever internal data these functions might need, that #seek and #tell
- take and return 64-bit offsets, and that #seek must return -1 if
- the stream is unseekable.*/
-struct OpusFileCallbacks{
- /**Used to read data from the stream.
- This must not be NULL
.*/
- op_read_func read;
- /**Used to seek in the stream.
- This may be NULL
if seeking is not implemented.*/
- op_seek_func seek;
- /**Used to return the current read position in the stream.
- This may be NULL
if seeking is not implemented.*/
- op_tell_func tell;
- /**Used to close the stream when the decoder is freed.
- This may be NULL
to leave the stream open.*/
- op_close_func close;
-};
-
-/**Opens a stream with fopen()
and fills in a set of callbacks
- that can be used to access it.
- This is useful to avoid writing your own portable 64-bit seeking wrappers,
- and also avoids cross-module linking issues on Windows, where a
- FILE *
must be accessed by routines defined in the same module
- that opened it.
- \param[out] _cb The callbacks to use for this file.
- If there is an error opening the file, nothing will be
- filled in here.
- \param _path The path to the file to open.
- On Windows, this string must be UTF-8 (to allow access to
- files whose names cannot be represented in the current
- MBCS code page).
- All other systems use the native character encoding.
- \param _mode The mode to open the file in.
- \return A stream handle to use with the callbacks, or NULL
on
- error.*/
-OP_WARN_UNUSED_RESULT void *op_fopen(OpusFileCallbacks *_cb,
- const char *_path,const char *_mode) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2)
- OP_ARG_NONNULL(3);
-
-/**Opens a stream with fdopen()
and fills in a set of callbacks
- that can be used to access it.
- This is useful to avoid writing your own portable 64-bit seeking wrappers,
- and also avoids cross-module linking issues on Windows, where a
- FILE *
must be accessed by routines defined in the same module
- that opened it.
- \param[out] _cb The callbacks to use for this file.
- If there is an error opening the file, nothing will be
- filled in here.
- \param _fd The file descriptor to open.
- \param _mode The mode to open the file in.
- \return A stream handle to use with the callbacks, or NULL
on
- error.*/
-OP_WARN_UNUSED_RESULT void *op_fdopen(OpusFileCallbacks *_cb,
- int _fd,const char *_mode) OP_ARG_NONNULL(1) OP_ARG_NONNULL(3);
-
-/**Opens a stream with freopen()
and fills in a set of callbacks
- that can be used to access it.
- This is useful to avoid writing your own portable 64-bit seeking wrappers,
- and also avoids cross-module linking issues on Windows, where a
- FILE *
must be accessed by routines defined in the same module
- that opened it.
- \param[out] _cb The callbacks to use for this file.
- If there is an error opening the file, nothing will be
- filled in here.
- \param _path The path to the file to open.
- On Windows, this string must be UTF-8 (to allow access
- to files whose names cannot be represented in the
- current MBCS code page).
- All other systems use the native character encoding.
- \param _mode The mode to open the file in.
- \param _stream A stream previously returned by op_fopen(), op_fdopen(),
- or op_freopen().
- \return A stream handle to use with the callbacks, or NULL
on
- error.*/
-OP_WARN_UNUSED_RESULT void *op_freopen(OpusFileCallbacks *_cb,
- const char *_path,const char *_mode,void *_stream) OP_ARG_NONNULL(1)
- OP_ARG_NONNULL(2) OP_ARG_NONNULL(3) OP_ARG_NONNULL(4);
-
-/**Creates a stream that reads from the given block of memory.
- This block of memory must contain the complete stream to decode.
- This is useful for caching small streams (e.g., sound effects) in RAM.
- \param[out] _cb The callbacks to use for this stream.
- If there is an error creating the stream, nothing will be
- filled in here.
- \param _data The block of memory to read from.
- \param _size The size of the block of memory.
- \return A stream handle to use with the callbacks, or NULL
on
- error.*/
-OP_WARN_UNUSED_RESULT void *op_mem_stream_create(OpusFileCallbacks *_cb,
- const unsigned char *_data,size_t _size) OP_ARG_NONNULL(1);
-
-/**Creates a stream that reads from the given URL.
- This function behaves identically to op_url_stream_create(), except that it
- takes a va_list instead of a variable number of arguments.
- It does not call the va_end
macro, and because it invokes the
- va_arg
macro, the value of \a _ap is undefined after the call.
- \note If you use this function, you must link against libopusurl.
- \param[out] _cb The callbacks to use for this stream.
- If there is an error creating the stream, nothing will
- be filled in here.
- \param _url The URL to read from.
- Currently only the NULL
.
- \return A stream handle to use with the callbacks, or NULL
on
- error.*/
-OP_WARN_UNUSED_RESULT void *op_url_stream_vcreate(OpusFileCallbacks *_cb,
- const char *_url,va_list _ap) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
-
-/**Creates a stream that reads from the given URL.
- \note If you use this function, you must link against libopusurl.
- \param[out] _cb The callbacks to use for this stream.
- If there is an error creating the stream, nothing will be
- filled in here.
- \param _url The URL to read from.
- Currently only the NULL
.
- \return A stream handle to use with the callbacks, or NULL
on
- error.*/
-OP_WARN_UNUSED_RESULT void *op_url_stream_create(OpusFileCallbacks *_cb,
- const char *_url,...) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
-
-/*@}*/
-/*@}*/
-
-/**\defgroup stream_open_close Opening and Closing*/
-/*@{*/
-/**\name Functions for opening and closing streams
-
- These functions allow you to test a stream to see if it is Opus, open it,
- and close it.
- Several flavors are provided for each of the built-in stream types, plus a
- more general version which takes a set of application-provided callbacks.*/
-/*@{*/
-
-/**Test to see if this is an Opus stream.
- For good results, you will need at least 57 bytes (for a pure Opus-only
- stream).
- Something like 512 bytes will give more reliable results for multiplexed
- streams.
- This function is meant to be a quick-rejection filter.
- Its purpose is not to guarantee that a stream is a valid Opus stream, but to
- ensure that it looks enough like Opus that it isn't going to be recognized
- as some other format (except possibly an Opus stream that is also
- multiplexed with other codecs, such as video).
- \param[out] _head The parsed ID header contents.
- You may pass NULL
if you do not need
- this information.
- If the function fails, the contents of this structure
- remain untouched.
- \param _initial_data An initial buffer of data from the start of the
- stream.
- \param _initial_bytes The number of bytes in \a _initial_data.
- \return 0 if the data appears to be Opus, or a negative value on error.
- \retval #OP_FALSE There was not enough data to tell if this was an Opus
- stream or not.
- \retval #OP_EFAULT An internal memory allocation failed.
- \retval #OP_EIMPL The stream used a feature that is not implemented,
- such as an unsupported channel family.
- \retval #OP_ENOTFORMAT If the data did not contain a recognizable ID
- header for an Opus stream.
- \retval #OP_EVERSION If the version field signaled a version this library
- does not know how to parse.
- \retval #OP_EBADHEADER The ID header was not properly formatted or contained
- illegal values.*/
-int op_test(OpusHead *_head,
- const unsigned char *_initial_data,size_t _initial_bytes);
-
-/**Open a stream from the given file path.
- \param _path The path to the file to open.
- \param[out] _error Returns 0 on success, or a failure code on error.
- You may pass in NULL
if you don't want the
- failure code.
- The failure code will be #OP_EFAULT if the file could not
- be opened, or one of the other failure codes from
- op_open_callbacks() otherwise.
- \return A freshly opened \c OggOpusFile, or NULL
on error.*/
-OP_WARN_UNUSED_RESULT OggOpusFile *op_open_file(const char *_path,int *_error)
- OP_ARG_NONNULL(1);
-
-/**Open a stream from a memory buffer.
- \param _data The memory buffer to open.
- \param _size The number of bytes in the buffer.
- \param[out] _error Returns 0 on success, or a failure code on error.
- You may pass in NULL
if you don't want the
- failure code.
- See op_open_callbacks() for a full list of failure codes.
- \return A freshly opened \c OggOpusFile, or NULL
on error.*/
-OP_WARN_UNUSED_RESULT OggOpusFile *op_open_memory(const unsigned char *_data,
- size_t _size,int *_error);
-
-/**Open a stream from a URL.
- This function behaves identically to op_open_url(), except that it
- takes a va_list instead of a variable number of arguments.
- It does not call the va_end
macro, and because it invokes the
- va_arg
macro, the value of \a _ap is undefined after the call.
- \note If you use this function, you must link against libopusurl.
- \param _url The URL to open.
- Currently only the NULL
if you don't want
- the failure code.
- See op_open_callbacks() for a full list of failure
- codes.
- \param[in,out] _ap A list of the \ref url_options "optional flags" to
- use.
- This is a variable-length list of options terminated
- with NULL
.
- \return A freshly opened \c OggOpusFile, or NULL
on error.*/
-OP_WARN_UNUSED_RESULT OggOpusFile *op_vopen_url(const char *_url,
- int *_error,va_list _ap) OP_ARG_NONNULL(1);
-
-/**Open a stream from a URL.
- \note If you use this function, you must link against libopusurl.
- \param _url The URL to open.
- Currently only the NULL
if you don't want the
- failure code.
- See op_open_callbacks() for a full list of failure codes.
- \param ... The \ref url_options "optional flags" to use.
- This is a variable-length list of options terminated with
- NULL
.
- \return A freshly opened \c OggOpusFile, or NULL
on error.*/
-OP_WARN_UNUSED_RESULT OggOpusFile *op_open_url(const char *_url,
- int *_error,...) OP_ARG_NONNULL(1);
-
-/**Open a stream using the given set of callbacks to access it.
- \param _source The stream to read from (e.g., a FILE *
).
- \param _cb The callbacks with which to access the stream.
- read()
must
- be implemented.
- seek()
and
- tell()
may
- be NULL
, or may always return -1 to
- indicate a source is unseekable, but if
- seek()
is
- implemented and succeeds on a particular source, then
- tell()
must
- also.
- close()
may
- be NULL
, but if it is not, it will be
- called when the \c OggOpusFile is destroyed by
- op_free().
- It will not be called if op_open_callbacks() fails
- with an error.
- \param _initial_data An initial buffer of data from the start of the
- stream.
- Applications can read some number of bytes from the
- start of the stream to help identify this as an Opus
- stream, and then provide them here to allow the
- stream to be opened, even if it is unseekable.
- \param _initial_bytes The number of bytes in \a _initial_data.
- If the stream is seekable, its current position (as
- reported by
- tell()
- at the start of this function) must be equal to
- \a _initial_bytes.
- Otherwise, seeking to absolute positions will
- generate inconsistent results.
- \param[out] _error Returns 0 on success, or a failure code on error.
- You may pass in NULL
if you don't want
- the failure code.
- The failure code will be one of
- seek()
- was implemented and succeeded on this source, but
- tell()
- did not, or the starting position indicator was
- not equal to \a _initial_bytes.NULL
on error.
- libopusfile does not take ownership of the source
- if the call fails.
- The calling application is responsible for closing the source if
- this call returns an error.*/
-OP_WARN_UNUSED_RESULT OggOpusFile *op_open_callbacks(void *_source,
- const OpusFileCallbacks *_cb,const unsigned char *_initial_data,
- size_t _initial_bytes,int *_error) OP_ARG_NONNULL(2);
-
-/**Partially open a stream from the given file path.
- \see op_test_callbacks
- \param _path The path to the file to open.
- \param[out] _error Returns 0 on success, or a failure code on error.
- You may pass in NULL
if you don't want the
- failure code.
- The failure code will be #OP_EFAULT if the file could not
- be opened, or one of the other failure codes from
- op_open_callbacks() otherwise.
- \return A partially opened \c OggOpusFile, or NULL
on error.*/
-OP_WARN_UNUSED_RESULT OggOpusFile *op_test_file(const char *_path,int *_error)
- OP_ARG_NONNULL(1);
-
-/**Partially open a stream from a memory buffer.
- \see op_test_callbacks
- \param _data The memory buffer to open.
- \param _size The number of bytes in the buffer.
- \param[out] _error Returns 0 on success, or a failure code on error.
- You may pass in NULL
if you don't want the
- failure code.
- See op_open_callbacks() for a full list of failure codes.
- \return A partially opened \c OggOpusFile, or NULL
on error.*/
-OP_WARN_UNUSED_RESULT OggOpusFile *op_test_memory(const unsigned char *_data,
- size_t _size,int *_error);
-
-/**Partially open a stream from a URL.
- This function behaves identically to op_test_url(), except that it
- takes a va_list instead of a variable number of arguments.
- It does not call the va_end
macro, and because it invokes the
- va_arg
macro, the value of \a _ap is undefined after the call.
- \note If you use this function, you must link against libopusurl.
- \see op_test_url
- \see op_test_callbacks
- \param _url The URL to open.
- Currently only the NULL
if you don't want
- the failure code.
- See op_open_callbacks() for a full list of failure
- codes.
- \param[in,out] _ap A list of the \ref url_options "optional flags" to
- use.
- This is a variable-length list of options terminated
- with NULL
.
- \return A partially opened \c OggOpusFile, or NULL
on error.*/
-OP_WARN_UNUSED_RESULT OggOpusFile *op_vtest_url(const char *_url,
- int *_error,va_list _ap) OP_ARG_NONNULL(1);
-
-/**Partially open a stream from a URL.
- \note If you use this function, you must link against libopusurl.
- \see op_test_callbacks
- \param _url The URL to open.
- Currently only the NULL
if you don't want the
- failure code.
- See op_open_callbacks() for a full list of failure
- codes.
- \param ... The \ref url_options "optional flags" to use.
- This is a variable-length list of options terminated
- with NULL
.
- \return A partially opened \c OggOpusFile, or NULL
on error.*/
-OP_WARN_UNUSED_RESULT OggOpusFile *op_test_url(const char *_url,
- int *_error,...) OP_ARG_NONNULL(1);
-
-/**Partially open a stream using the given set of callbacks to access it.
- This tests for Opusness and loads the headers for the first link.
- It does not seek (although it tests for seekability).
- You can query a partially open stream for the few pieces of basic
- information returned by op_serialno(), op_channel_count(), op_head(), and
- op_tags() (but only for the first link).
- You may also determine if it is seekable via a call to op_seekable().
- You cannot read audio from the stream, seek, get the size or duration,
- get information from links other than the first one, or even get the total
- number of links until you finish opening the stream with op_test_open().
- If you do not need to do any of these things, you can dispose of it with
- op_free() instead.
-
- This function is provided mostly to simplify porting existing code that used
- libvorbisfile.
- For new code, you are likely better off using op_test() instead, which
- is less resource-intensive, requires less data to succeed, and imposes a
- hard limit on the amount of data it examines (important for unseekable
- sources, where all such data must be buffered until you are sure of the
- stream type).
- \param _source The stream to read from (e.g., a FILE *
).
- \param _cb The callbacks with which to access the stream.
- read()
must
- be implemented.
- seek()
and
- tell()
may
- be NULL
, or may always return -1 to
- indicate a source is unseekable, but if
- seek()
is
- implemented and succeeds on a particular source, then
- tell()
must
- also.
- close()
may
- be NULL
, but if it is not, it will be
- called when the \c OggOpusFile is destroyed by
- op_free().
- It will not be called if op_open_callbacks() fails
- with an error.
- \param _initial_data An initial buffer of data from the start of the
- stream.
- Applications can read some number of bytes from the
- start of the stream to help identify this as an Opus
- stream, and then provide them here to allow the
- stream to be tested more thoroughly, even if it is
- unseekable.
- \param _initial_bytes The number of bytes in \a _initial_data.
- If the stream is seekable, its current position (as
- reported by
- tell()
- at the start of this function) must be equal to
- \a _initial_bytes.
- Otherwise, seeking to absolute positions will
- generate inconsistent results.
- \param[out] _error Returns 0 on success, or a failure code on error.
- You may pass in NULL
if you don't want
- the failure code.
- See op_open_callbacks() for a full list of failure
- codes.
- \return A partially opened \c OggOpusFile, or NULL
on error.
- libopusfile does not take ownership of the source
- if the call fails.
- The calling application is responsible for closing the source if
- this call returns an error.*/
-OP_WARN_UNUSED_RESULT OggOpusFile *op_test_callbacks(void *_source,
- const OpusFileCallbacks *_cb,const unsigned char *_initial_data,
- size_t _initial_bytes,int *_error) OP_ARG_NONNULL(2);
-
-/**Finish opening a stream partially opened with op_test_callbacks() or one of
- the associated convenience functions.
- If this function fails, you are still responsible for freeing the
- \c OggOpusFile with op_free().
- \param _of The \c OggOpusFile to finish opening.
- \return 0 on success, or a negative value on error.
- \retval #OP_EREAD An underlying read, seek, or tell operation failed
- when it should have succeeded.
- \retval #OP_EFAULT There was a memory allocation failure, or an
- internal library error.
- \retval #OP_EIMPL The stream used a feature that is not implemented,
- such as an unsupported channel family.
- \retval #OP_EINVAL The stream was not partially opened with
- op_test_callbacks() or one of the associated
- convenience functions.
- \retval #OP_ENOTFORMAT The stream contained a link that did not have any
- logical Opus streams in it.
- \retval #OP_EBADHEADER A required header packet was not properly
- formatted, contained illegal values, or was
- missing altogether.
- \retval #OP_EVERSION An ID header contained an unrecognized version
- number.
- \retval #OP_EBADLINK We failed to find data we had seen before after
- seeking.
- \retval #OP_EBADTIMESTAMP The first or last timestamp in a link failed basic
- validity checks.*/
-int op_test_open(OggOpusFile *_of) OP_ARG_NONNULL(1);
-
-/**Release all memory used by an \c OggOpusFile.
- \param _of The \c OggOpusFile to free.*/
-void op_free(OggOpusFile *_of);
-
-/*@}*/
-/*@}*/
-
-/**\defgroup stream_info Stream Information*/
-/*@{*/
-/**\name Functions for obtaining information about streams
-
- These functions allow you to get basic information about a stream, including
- seekability, the number of links (for chained streams), plus the size,
- duration, bitrate, header parameters, and meta information for each link
- (or, where available, the stream as a whole).
- Some of these (size, duration) are only available for seekable streams.
- You can also query the current stream position, link, and playback time,
- and instantaneous bitrate during playback.
-
- Some of these functions may be used successfully on the partially open
- streams returned by op_test_callbacks() or one of the associated
- convenience functions.
- Their documention will indicate so explicitly.*/
-/*@{*/
-
-/**Returns whether or not the data source being read is seekable.
- This is true if
- seek()
and
- tell()
callbacks are both
- non-NULL
,seek()
callback was
- successfully executed at least once, andtell()
callback was
- successfully able to report the position indicator afterwards.op_head(_of,_li)->channel_count
, but
- is provided for convenience.
- This function may be called on partially-opened streams, but it will always
- return the channel count of the Opus stream in the first link.
- \param _of The \c OggOpusFile from which to retrieve the channel count.
- \param _li The index of the link whose channel count should be retrieved.
- Use a negative number to get the channel count of the current
- link.
- \return The channel count of the given link.
- If \a _li is greater than the total number of links, this returns
- the channel count of the last link.
- If the source is not seekable, this always returns the channel count
- of the current link.*/
-int op_channel_count(const OggOpusFile *_of,int _li) OP_ARG_NONNULL(1);
-
-/**Get the total (compressed) size of the stream, or of an individual link in
- a (possibly-chained) Ogg Opus stream, including all headers and Ogg muxing
- overhead.
- \warning If the Opus stream (or link) is concurrently multiplexed with other
- logical streams (e.g., video), this returns the size of the entire stream
- (or link), not just the number of bytes in the first logical Opus stream.
- Returning the latter would require scanning the entire file.
- \param _of The \c OggOpusFile from which to retrieve the compressed size.
- \param _li The index of the link whose compressed size should be computed.
- Use a negative number to get the compressed size of the entire
- stream.
- \return The compressed size of the entire stream if \a _li is negative, the
- compressed size of link \a _li if it is non-negative, or a negative
- value on error.
- The compressed size of the entire stream may be smaller than that
- of the underlying source if trailing garbage was detected in the
- file.
- \retval #OP_EINVAL The source is not seekable (so we can't know the length),
- \a _li wasn't less than the total number of links in
- the stream, or the stream was only partially open.*/
-opus_int64 op_raw_total(const OggOpusFile *_of,int _li) OP_ARG_NONNULL(1);
-
-/**Get the total PCM length (number of samples at 48 kHz) of the stream, or of
- an individual link in a (possibly-chained) Ogg Opus stream.
- Users looking for op_time_total()
should use op_pcm_total()
- instead.
- Because timestamps in Opus are fixed at 48 kHz, there is no need for a
- separate function to convert this to seconds (and leaving it out avoids
- introducing floating point to the API, for those that wish to avoid it).
- \param _of The \c OggOpusFile from which to retrieve the PCM offset.
- \param _li The index of the link whose PCM length should be computed.
- Use a negative number to get the PCM length of the entire stream.
- \return The PCM length of the entire stream if \a _li is negative, the PCM
- length of link \a _li if it is non-negative, or a negative value on
- error.
- \retval #OP_EINVAL The source is not seekable (so we can't know the length),
- \a _li wasn't less than the total number of links in
- the stream, or the stream was only partially open.*/
-ogg_int64_t op_pcm_total(const OggOpusFile *_of,int _li) OP_ARG_NONNULL(1);
-
-/**Get the ID header information for the given link in a (possibly chained) Ogg
- Opus stream.
- This function may be called on partially-opened streams, but it will always
- return the ID header information of the Opus stream in the first link.
- \param _of The \c OggOpusFile from which to retrieve the ID header
- information.
- \param _li The index of the link whose ID header information should be
- retrieved.
- Use a negative number to get the ID header information of the
- current link.
- For an unseekable stream, \a _li is ignored, and the ID header
- information for the current link is always returned, if
- available.
- \return The contents of the ID header for the given link.*/
-const OpusHead *op_head(const OggOpusFile *_of,int _li) OP_ARG_NONNULL(1);
-
-/**Get the comment header information for the given link in a (possibly
- chained) Ogg Opus stream.
- This function may be called on partially-opened streams, but it will always
- return the tags from the Opus stream in the first link.
- \param _of The \c OggOpusFile from which to retrieve the comment header
- information.
- \param _li The index of the link whose comment header information should be
- retrieved.
- Use a negative number to get the comment header information of
- the current link.
- For an unseekable stream, \a _li is ignored, and the comment
- header information for the current link is always returned, if
- available.
- \return The contents of the comment header for the given link, or
- NULL
if this is an unseekable stream that encountered
- an invalid link.*/
-const OpusTags *op_tags(const OggOpusFile *_of,int _li) OP_ARG_NONNULL(1);
-
-/**Retrieve the index of the current link.
- This is the link that produced the data most recently read by
- op_read_float() or its associated functions, or, after a seek, the link
- that the seek target landed in.
- Reading more data may advance the link index (even on the first read after a
- seek).
- \param _of The \c OggOpusFile from which to retrieve the current link index.
- \return The index of the current link on success, or a negative value on
- failure.
- For seekable streams, this is a number between 0 and the value
- returned by op_link_count().
- For unseekable streams, this value starts at 0 and increments by one
- each time a new link is encountered (even though op_link_count()
- always returns 1).
- \retval #OP_EINVAL The stream was only partially open.*/
-int op_current_link(const OggOpusFile *_of) OP_ARG_NONNULL(1);
-
-/**Computes the bitrate of the stream, or of an individual link in a
- (possibly-chained) Ogg Opus stream.
- The stream must be seekable to compute the bitrate.
- For unseekable streams, use op_bitrate_instant() to get periodic estimates.
- \warning If the Opus stream (or link) is concurrently multiplexed with other
- logical streams (e.g., video), this uses the size of the entire stream (or
- link) to compute the bitrate, not just the number of bytes in the first
- logical Opus stream.
- Returning the latter requires scanning the entire file, but this may be done
- by decoding the whole file and calling op_bitrate_instant() once at the
- end.
- Install a trivial decoding callback with op_set_decode_callback() if you
- wish to skip actual decoding during this process.
- \param _of The \c OggOpusFile from which to retrieve the bitrate.
- \param _li The index of the link whose bitrate should be computed.
- Use a negative number to get the bitrate of the whole stream.
- \return The bitrate on success, or a negative value on error.
- \retval #OP_EINVAL The stream was only partially open, the stream was not
- seekable, or \a _li was larger than the number of
- links.*/
-opus_int32 op_bitrate(const OggOpusFile *_of,int _li) OP_ARG_NONNULL(1);
-
-/**Compute the instantaneous bitrate, measured as the ratio of bits to playable
- samples decoded since a) the last call to op_bitrate_instant(), b) the last
- seek, or c) the start of playback, whichever was most recent.
- This will spike somewhat after a seek or at the start/end of a chain
- boundary, as pre-skip, pre-roll, and end-trimming causes samples to be
- decoded but not played.
- \param _of The \c OggOpusFile from which to retrieve the bitrate.
- \return The bitrate, in bits per second, or a negative value on error.
- \retval #OP_FALSE No data has been decoded since any of the events
- described above.
- \retval #OP_EINVAL The stream was only partially open.*/
-opus_int32 op_bitrate_instant(OggOpusFile *_of) OP_ARG_NONNULL(1);
-
-/**Obtain the current value of the position indicator for \a _of.
- \param _of The \c OggOpusFile from which to retrieve the position indicator.
- \return The byte position that is currently being read from.
- \retval #OP_EINVAL The stream was only partially open.*/
-opus_int64 op_raw_tell(const OggOpusFile *_of) OP_ARG_NONNULL(1);
-
-/**Obtain the PCM offset of the next sample to be read.
- If the stream is not properly timestamped, this might not increment by the
- proper amount between reads, or even return monotonically increasing
- values.
- \param _of The \c OggOpusFile from which to retrieve the PCM offset.
- \return The PCM offset of the next sample to be read.
- \retval #OP_EINVAL The stream was only partially open.*/
-ogg_int64_t op_pcm_tell(const OggOpusFile *_of) OP_ARG_NONNULL(1);
-
-/*@}*/
-/*@}*/
-
-/**\defgroup stream_seeking Seeking*/
-/*@{*/
-/**\name Functions for seeking in Opus streams
-
- These functions let you seek in Opus streams, if the underlying source
- support it.
- Seeking is implemented for all built-in stream I/O routines, though some
- individual sources may not be seekable (pipes, live HTTP streams, or HTTP
- streams from a server that does not support Range
requests).
-
- op_raw_seek() is the fastest: it is guaranteed to perform at most one
- physical seek, but, since the target is a byte position, makes no guarantee
- how close to a given time it will come.
- op_pcm_seek() provides sample-accurate seeking.
- The number of physical seeks it requires is still quite small (often 1 or
- 2, even in highly variable bitrate streams).
-
- Seeking in Opus requires decoding some pre-roll amount before playback to
- allow the internal state to converge (as if recovering from packet loss).
- This is handled internally by libopusfile, but means there is
- little extra overhead for decoding up to the exact position requested
- (since it must decode some amount of audio anyway).
- It also means that decoding after seeking may not return exactly the same
- values as would be obtained by decoding the stream straight through.
- However, such differences are expected to be smaller than the loss
- introduced by Opus's lossy compression.*/
-/*@{*/
-
-/**Seek to a byte offset relative to the compressed data.
- This also scans packets to update the PCM cursor.
- It will cross a logical bitstream boundary, but only if it can't get any
- packets out of the tail of the link to which it seeks.
- \param _of The \c OggOpusFile in which to seek.
- \param _byte_offset The byte position to seek to.
- \return 0 on success, or a negative error code on failure.
- \retval #OP_EREAD The underlying seek operation failed.
- \retval #OP_EINVAL The stream was only partially open, or the target was
- outside the valid range for the stream.
- \retval #OP_ENOSEEK This stream is not seekable.
- \retval #OP_EBADLINK Failed to initialize a decoder for a stream for an
- unknown reason.*/
-int op_raw_seek(OggOpusFile *_of,opus_int64 _byte_offset) OP_ARG_NONNULL(1);
-
-/**Seek to the specified PCM offset, such that decoding will begin at exactly
- the requested position.
- \param _of The \c OggOpusFile in which to seek.
- \param _pcm_offset The PCM offset to seek to.
- This is in samples at 48 kHz relative to the start of the
- stream.
- \return 0 on success, or a negative value on error.
- \retval #OP_EREAD An underlying read or seek operation failed.
- \retval #OP_EINVAL The stream was only partially open, or the target was
- outside the valid range for the stream.
- \retval #OP_ENOSEEK This stream is not seekable.
- \retval #OP_EBADLINK We failed to find data we had seen before, or the
- bitstream structure was sufficiently malformed that
- seeking to the target destination was impossible.*/
-int op_pcm_seek(OggOpusFile *_of,ogg_int64_t _pcm_offset) OP_ARG_NONNULL(1);
-
-/*@}*/
-/*@}*/
-
-/**\defgroup stream_decoding Decoding*/
-/*@{*/
-/**\name Functions for decoding audio data
-
- These functions retrieve actual decoded audio data from the stream.
- The general functions, op_read() and op_read_float() return 16-bit or
- floating-point output, both using native endian ordering.
- The number of channels returned can change from link to link in a chained
- stream.
- There are special functions, op_read_stereo() and op_read_float_stereo(),
- which always output two channels, to simplify applications which do not
- wish to handle multichannel audio.
- These downmix multichannel files to two channels, so they can always return
- samples in the same format for every link in a chained file.
-
- If the rest of your audio processing chain can handle floating point, those
- routines should be preferred, as floating point output avoids introducing
- clipping and other issues which might be avoided entirely if, e.g., you
- scale down the volume at some other stage.
- However, if you intend to direct consume 16-bit samples, the conversion in
- libopusfile provides noise-shaping dithering and, if compiled
- against libopus 1.1 or later, soft-clipping prevention.
-
- libopusfile can also be configured at compile time to use the
- fixed-point libopus API.
- If so, libopusfile's floating-point API may also be disabled.
- In that configuration, nothing in libopusfile will use any
- floating-point operations, to simplify support on devices without an
- adequate FPU.
-
- \warning HTTPS streams may be be vulnerable to truncation attacks if you do
- not check the error return code from op_read_float() or its associated
- functions.
- If the remote peer does not close the connection gracefully (with a TLS
- "close notify" message), these functions will return #OP_EREAD instead of 0
- when they reach the end of the file.
- If you are reading from an \a _nsamples*\a
- _nchannels
samples in the requested
- format.
- \retval #OP_DEC_USE_DEFAULT No decoding was done.
- libopusfile should decode normally
- instead.*/
-typedef int (*op_decode_cb_func)(void *_ctx,OpusMSDecoder *_decoder,void *_pcm,
- const ogg_packet *_op,int _nsamples,int _nchannels,int _format,int _li);
-
-/**Sets the packet decode callback function.
- This is called once for each packet that needs to be decoded.
- A call to this function is no guarantee that the audio will eventually be
- delivered to the application.
- Some or all of the data from the packet may be discarded (i.e., at the
- beginning or end of a link, or after a seek), however the callback is
- required to provide all of it.
- \param _of The \c OggOpusFile on which to set the decode callback.
- \param _decode_cb The callback function to call.
- This may be NULL
to disable calling the
- callback.
- \param _ctx The application-provided context pointer to pass to the
- callback on each call.*/
-void op_set_decode_callback(OggOpusFile *_of,
- op_decode_cb_func _decode_cb,void *_ctx) OP_ARG_NONNULL(1);
-
-/**Gain offset type that indicates that the provided offset is relative to the
- header gain.
- This is the default.*/
-#define OP_HEADER_GAIN (0)
-
-/**Gain offset type that indicates that the provided offset is relative to the
- R128_ALBUM_GAIN value (if any), in addition to the header gain.*/
-#define OP_ALBUM_GAIN (3007)
-
-/**Gain offset type that indicates that the provided offset is relative to the
- R128_TRACK_GAIN value (if any), in addition to the header gain.*/
-#define OP_TRACK_GAIN (3008)
-
-/**Gain offset type that indicates that the provided offset should be used as
- the gain directly, without applying any the header or track gains.*/
-#define OP_ABSOLUTE_GAIN (3009)
-
-/**Sets the gain to be used for decoded output.
- By default, the gain in the header is applied with no additional offset.
- The total gain (including header gain and/or track gain, if applicable, and
- this offset), will be clamped to [-32768,32767]/256 dB.
- This is more than enough to saturate or underflow 16-bit PCM.
- \note The new gain will not be applied to any already buffered, decoded
- output.
- This means you cannot change it sample-by-sample, as at best it will be
- updated packet-by-packet.
- It is meant for setting a target volume level, rather than applying smooth
- fades, etc.
- \param _of The \c OggOpusFile on which to set the gain offset.
- \param _gain_type One of #OP_HEADER_GAIN, #OP_ALBUM_GAIN,
- #OP_TRACK_GAIN, or #OP_ABSOLUTE_GAIN.
- \param _gain_offset_q8 The gain offset to apply, in 1/256ths of a dB.
- \return 0 on success or a negative value on error.
- \retval #OP_EINVAL The \a _gain_type was unrecognized.*/
-int op_set_gain_offset(OggOpusFile *_of,
- int _gain_type,opus_int32 _gain_offset_q8) OP_ARG_NONNULL(1);
-
-/**Sets whether or not dithering is enabled for 16-bit decoding.
- By default, when libopusfile is compiled to use floating-point
- internally, calling op_read() or op_read_stereo() will first decode to
- float, and then convert to fixed-point using noise-shaping dithering.
- This flag can be used to disable that dithering.
- When the application uses op_read_float() or op_read_float_stereo(), or when
- the library has been compiled to decode directly to fixed point, this flag
- has no effect.
- \param _of The \c OggOpusFile on which to enable or disable dithering.
- \param _enabled A non-zero value to enable dithering, or 0 to disable it.*/
-void op_set_dither_enabled(OggOpusFile *_of,int _enabled) OP_ARG_NONNULL(1);
-
-/**Reads more samples from the stream.
- \note Although \a _buf_size must indicate the total number of values that
- can be stored in \a _pcm, the return value is the number of samples
- per channel.
- This is done because
- libopus
API
- as closely as we're able,[-32768,32767)
.
- Multiple channels are interleaved using the
- Vorbis
- channel ordering.
- This must have room for at least \a _buf_size values.
- \param _buf_size The number of values that can be stored in \a _pcm.
- It is recommended that this be large enough for at
- least 120 ms of data at 48 kHz per channel (5760
- values per channel).
- Smaller buffers will simply return less data, possibly
- consuming more memory to buffer the data internally.
- libopusfile may return less data than
- requested.
- If so, there is no guarantee that the remaining data
- in \a _pcm will be unmodified.
- \param[out] _li The index of the link this data was decoded from.
- You may pass NULL
if you do not need this
- information.
- If this function fails (returning a negative value),
- this parameter is left unset.
- \return The number of samples read per channel on success, or a negative
- value on failure.
- The channel count can be retrieved on success by calling
- op_head(_of,*_li)
.
- The number of samples returned may be 0 if the buffer was too small
- to store even a single sample for all channels, or if end-of-file
- was reached.
- The list of possible failure codes follows.
- Most of them can only be returned by unseekable, chained streams
- that encounter a new link.
- \retval #OP_HOLE There was a hole in the data, and some samples
- may have been skipped.
- Call this function again to continue decoding
- past the hole.
- \retval #OP_EREAD An underlying read operation failed.
- This may signal a truncation attack from an
- libopus
API
- as closely as we're able,[-1.0,1.0]
.
- Multiple channels are interleaved using the
- Vorbis
- channel ordering.
- This must have room for at least \a _buf_size floats.
- \param _buf_size The number of floats that can be stored in \a _pcm.
- It is recommended that this be large enough for at
- least 120 ms of data at 48 kHz per channel (5760
- samples per channel).
- Smaller buffers will simply return less data, possibly
- consuming more memory to buffer the data internally.
- If less than \a _buf_size values are returned,
- libopusfile makes no guarantee that the
- remaining data in \a _pcm will be unmodified.
- \param[out] _li The index of the link this data was decoded from.
- You may pass NULL
if you do not need this
- information.
- If this function fails (returning a negative value),
- this parameter is left unset.
- \return The number of samples read per channel on success, or a negative
- value on failure.
- The channel count can be retrieved on success by calling
- op_head(_of,*_li)
.
- The number of samples returned may be 0 if the buffer was too small
- to store even a single sample for all channels, or if end-of-file
- was reached.
- The list of possible failure codes follows.
- Most of them can only be returned by unseekable, chained streams
- that encounter a new link.
- \retval #OP_HOLE There was a hole in the data, and some samples
- may have been skipped.
- Call this function again to continue decoding
- past the hole.
- \retval #OP_EREAD An underlying read operation failed.
- This may signal a truncation attack from an
- [-32768,32767)
.
- The left and right channels are interleaved in the
- buffer.
- This must have room for at least \a _buf_size values.
- \param _buf_size The number of values that can be stored in \a _pcm.
- It is recommended that this be large enough for at
- least 120 ms of data at 48 kHz per channel (11520
- values total).
- Smaller buffers will simply return less data, possibly
- consuming more memory to buffer the data internally.
- If less than \a _buf_size values are returned,
- libopusfile makes no guarantee that the
- remaining data in \a _pcm will be unmodified.
- \return The number of samples read per channel on success, or a negative
- value on failure.
- The number of samples returned may be 0 if the buffer was too small
- to store even a single sample for both channels, or if end-of-file
- was reached.
- The list of possible failure codes follows.
- Most of them can only be returned by unseekable, chained streams
- that encounter a new link.
- \retval #OP_HOLE There was a hole in the data, and some samples
- may have been skipped.
- Call this function again to continue decoding
- past the hole.
- \retval #OP_EREAD An underlying read operation failed.
- This may signal a truncation attack from an
- [-1.0,1.0]
.
- The left and right channels are interleaved in the
- buffer.
- This must have room for at least \a _buf_size values.
- \param _buf_size The number of values that can be stored in \a _pcm.
- It is recommended that this be large enough for at
- least 120 ms of data at 48 kHz per channel (11520
- values total).
- Smaller buffers will simply return less data, possibly
- consuming more memory to buffer the data internally.
- If less than \a _buf_size values are returned,
- libopusfile makes no guarantee that the
- remaining data in \a _pcm will be unmodified.
- \return The number of samples read per channel on success, or a negative
- value on failure.
- The number of samples returned may be 0 if the buffer was too small
- to store even a single sample for both channels, or if end-of-file
- was reached.
- The list of possible failure codes follows.
- Most of them can only be returned by unseekable, chained streams
- that encounter a new link.
- \retval #OP_HOLE There was a hole in the data, and some samples
- may have been skipped.
- Call this function again to continue decoding
- past the hole.
- \retval #OP_EREAD An underlying read operation failed.
- This may signal a truncation attack from an
-