Smart Remote 3 nRF52 v1.2
opus.h
1 /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
2  Written by Jean-Marc Valin and Koen Vos */
3 /*
4  Redistribution and use in source and binary forms, with or without
5  modification, are permitted provided that the following conditions
6  are met:
7 
8  - Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10 
11  - Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in the
13  documentation and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
33 #ifndef OPUS_H
34 #define OPUS_H
35 
36 #include "opus_types.h"
37 #include "opus_defines.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
167 typedef struct OpusEncoder OpusEncoder;
168 
174 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels);
175 
211 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create(
212  opus_int32 Fs,
213  int channels,
214  int application,
215  int *error
216 );
217 
231 OPUS_EXPORT int opus_encoder_init(
232  OpusEncoder *st,
233  opus_int32 Fs,
234  int channels,
235  int application
236 ) OPUS_ARG_NONNULL(1);
237 
266 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode(
267  OpusEncoder *st,
268  const opus_int16 *pcm,
269  int frame_size,
270  unsigned char *data,
271  opus_int32 max_data_bytes
272 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
273 
307 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float(
308  OpusEncoder *st,
309  const float *pcm,
310  int frame_size,
311  unsigned char *data,
312  opus_int32 max_data_bytes
313 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
314 
318 OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st);
319 
331 OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
403 typedef struct OpusDecoder OpusDecoder;
404 
410 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels);
411 
427 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create(
428  opus_int32 Fs,
429  int channels,
430  int *error
431 );
432 
444 OPUS_EXPORT int opus_decoder_init(
445  OpusDecoder *st,
446  opus_int32 Fs,
447  int channels
448 ) OPUS_ARG_NONNULL(1);
449 
466 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode(
467  OpusDecoder *st,
468  const unsigned char *data,
469  opus_int32 len,
470  opus_int16 *pcm,
471  int frame_size,
472  int decode_fec
473 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
474 
491 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float(
492  OpusDecoder *st,
493  const unsigned char *data,
494  opus_int32 len,
495  float *pcm,
496  int frame_size,
497  int decode_fec
498 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
499 
511 OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
512 
516 OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st);
517 
531 OPUS_EXPORT int opus_packet_parse(
532  const unsigned char *data,
533  opus_int32 len,
534  unsigned char *out_toc,
535  const unsigned char *frames[48],
536  opus_int16 size[48],
537  int *payload_offset
538 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
539 
549 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1);
550 
560 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1);
561 
567 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1);
568 
576 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1);
577 
588 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);
589 
598 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);
599 
610 OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem);
611 
612 
759 typedef struct OpusRepacketizer OpusRepacketizer;
760 
764 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void);
765 
783 OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
784 
788 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void);
789 
794 OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp);
795 
843 OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
844 
845 
877 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);
878 
889 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
890 
920 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1);
921 
934 OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len);
935 
947 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len);
948 
963 OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams);
964 
978 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams);
979 
982 #ifdef __cplusplus
983 }
984 #endif
985 
986 #endif /* OPUS_H */

Documentation feedback | Developer Zone | Subscribe | Updated