Opus: opus.h Source File

Opus audio codec (RFC 6716): API and operations manual
1.1

- Main Page
- Modules
- Files

- File List
- Globals

opus.h
Go to the documentation of this file.

    00001 /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
    00002    Written by Jean-Marc Valin and Koen Vos */
    00003 /*
    00004    Redistribution and use in source and binary forms, with or without
    00005    modification, are permitted provided that the following conditions
    00006    are met:
    00007
    00008    - Redistributions of source code must retain the above copyright
    00009    notice, this list of conditions and the following disclaimer.
    00010
    00011    - Redistributions in binary form must reproduce the above copyright
    00012    notice, this list of conditions and the following disclaimer in the
    00013    documentation and/or other materials provided with the distribution.
    00014
    00015    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    00016    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    00017    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    00018    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
    00019    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    00020    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    00021    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    00022    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    00023    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00024    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    00025    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00026 */
    00027
    00033 #ifndef OPUS_H
    00034 #define OPUS_H
    00035
    00036 #include "opus_types.h"
    00037 #include "opus_defines.h"
    00038
    00039 #ifdef __cplusplus
    00040 extern "C" {
    00041 #endif
    00042
    00164 typedef struct OpusEncoder OpusEncoder;
    00165
    00171 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels);
    00172
    00208 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create(
    00209     opus_int32 Fs,
    00210     int channels,
    00211     int application,
    00212     int *error
    00213 );
    00214
    00228 OPUS_EXPORT int opus_encoder_init(
    00229     OpusEncoder *st,
    00230     opus_int32 Fs,
    00231     int channels,
    00232     int application
    00233 ) OPUS_ARG_NONNULL(1);
    00234
    00263 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode(
    00264     OpusEncoder *st,
    00265     const opus_int16 *pcm,
    00266     int frame_size,
    00267     unsigned char *data,
    00268     opus_int32 max_data_bytes
    00269 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
    00270
    00304 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float(
    00305     OpusEncoder *st,
    00306     const float *pcm,
    00307     int frame_size,
    00308     unsigned char *data,
    00309     opus_int32 max_data_bytes
    00310 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
    00311
    00315 OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st);
    00316
    00328 OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
    00399 typedef struct OpusDecoder OpusDecoder;
    00400
    00406 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels);
    00407
    00423 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create(
    00424     opus_int32 Fs,
    00425     int channels,
    00426     int *error
    00427 );
    00428
    00440 OPUS_EXPORT int opus_decoder_init(
    00441     OpusDecoder *st,
    00442     opus_int32 Fs,
    00443     int channels
    00444 ) OPUS_ARG_NONNULL(1);
    00445
    00462 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode(
    00463     OpusDecoder *st,
    00464     const unsigned char *data,
    00465     opus_int32 len,
    00466     opus_int16 *pcm,
    00467     int frame_size,
    00468     int decode_fec
    00469 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
    00470
    00487 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float(
    00488     OpusDecoder *st,
    00489     const unsigned char *data,
    00490     opus_int32 len,
    00491     float *pcm,
    00492     int frame_size,
    00493     int decode_fec
    00494 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
    00495
    00507 OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
    00508
    00512 OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st);
    00513
    00527 OPUS_EXPORT int opus_packet_parse(
    00528    const unsigned char *data,
    00529    opus_int32 len,
    00530    unsigned char *out_toc,
    00531    const unsigned char *frames[48],
    00532    opus_int16 size[48],
    00533    int *payload_offset
    00534 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
    00535
    00545 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1);
    00546
    00556 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1);
    00557
    00563 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1);
    00564
    00572 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1);
    00573
    00584 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);
    00585
    00594 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);
    00595
    00606 OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem);
    00607
    00608
    00751 typedef struct OpusRepacketizer OpusRepacketizer;
    00752
    00756 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void);
    00757
    00775 OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
    00776
    00780 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void);
    00781
    00786 OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp);
    00787
    00835 OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
    00836
    00837
    00869 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);
    00870
    00881 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
    00882
    00912 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1);
    00913
    00926 OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len);
    00927
    00939 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len);
    00940
    00955 OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams);
    00956
    00970 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams);
    00971
    00974 #ifdef __cplusplus
    00975 }
    00976 #endif
    00977
    00978 #endif /* OPUS_H */

All Files Functions Typedefs Defines

For more information visit the Opus Website. |