00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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(5);
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
00754 typedef struct OpusRepacketizer OpusRepacketizer;
00755
00759 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void);
00760
00778 OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
00779
00783 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void);
00784
00789 OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp);
00790
00838 OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
00839
00840
00872 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);
00873
00884 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
00885
00915 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1);
00916
00929 OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len);
00930
00942 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len);
00943
00958 OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams);
00959
00973 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams);
00974
00977 #ifdef __cplusplus
00978 }
00979 #endif
00980
00981 #endif