webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
opus_private.h
Go to the documentation of this file.
1 /* Copyright (c) 2012 Xiph.Org Foundation
2  Written by Jean-Marc Valin */
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 
28 
29 #ifndef OPUS_PRIVATE_H
30 #define OPUS_PRIVATE_H
31 
32 #include "arch.h"
33 #include "opus.h"
34 #include "celt.h"
35 
36 #include <stddef.h> /* offsetof */
37 
39  unsigned char toc;
40  int nb_frames;
41  const unsigned char *frames[48];
43  int framesize;
44 };
45 
46 typedef struct ChannelLayout {
50  unsigned char mapping[256];
52 
53 int validate_layout(const ChannelLayout *layout);
54 int get_left_channel(const ChannelLayout *layout, int stream_id, int prev);
55 int get_right_channel(const ChannelLayout *layout, int stream_id, int prev);
56 int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev);
57 
58 
59 
60 #define MODE_SILK_ONLY 1000
61 #define MODE_HYBRID 1001
62 #define MODE_CELT_ONLY 1002
63 
64 #define OPUS_SET_VOICE_RATIO_REQUEST 11018
65 #define OPUS_GET_VOICE_RATIO_REQUEST 11019
66 
76 #define OPUS_SET_VOICE_RATIO(x) OPUS_SET_VOICE_RATIO_REQUEST, __opus_check_int(x)
77 
81 #define OPUS_GET_VOICE_RATIO(x) OPUS_GET_VOICE_RATIO_REQUEST, __opus_check_int_ptr(x)
82 
83 
84 #define OPUS_SET_FORCE_MODE_REQUEST 11002
85 #define OPUS_SET_FORCE_MODE(x) OPUS_SET_FORCE_MODE_REQUEST, __opus_check_int(x)
86 
87 typedef void (*downmix_func)(const void *, opus_val32 *, int, int, int, int, int);
88 void downmix_float(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C);
89 void downmix_int(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C);
90 
91 int encode_size(int size, unsigned char *data);
92 
93 opus_int32 frame_size_select(opus_int32 frame_size, int variable_duration, opus_int32 Fs);
94 
95 opus_int32 compute_frame_size(const void *analysis_pcm, int frame_size,
96  int variable_duration, int C, opus_int32 Fs, int bitrate_bps,
97  int delay_compensation, downmix_func downmix
98 #ifndef DISABLE_FLOAT_API
99  , float *subframe_mem
100 #endif
101  );
102 
103 opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
104  unsigned char *data, opus_int32 out_data_bytes, int lsb_depth,
105  const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2,
106  int analysis_channels, downmix_func downmix, int float_api);
107 
108 int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 len,
109  opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited,
110  opus_int32 *packet_offset, int soft_clip);
111 
112 /* Make sure everything is properly aligned. */
113 static OPUS_INLINE int align(int i)
114 {
115  struct foo {char c; union { void* p; opus_int32 i; opus_val32 v; } u;};
116 
117  unsigned int alignment = offsetof(struct foo, u);
118 
119  /* Optimizing compilers should optimize div and multiply into and
120  for all sensible alignment values. */
121  return ((i + alignment - 1) / alignment) * alignment;
122 }
123 
124 int opus_packet_parse_impl(const unsigned char *data, opus_int32 len,
125  int self_delimited, unsigned char *out_toc,
126  const unsigned char *frames[48], opus_int16 size[48],
127  int *payload_offset, opus_int32 *packet_offset);
128 
130  unsigned char *data, opus_int32 maxlen, int self_delimited, int pad);
131 
132 int pad_frame(unsigned char *data, opus_int32 len, opus_int32 new_len);
133 
134 #endif /* OPUS_PRIVATE_H */
opus_int16 len[48]
Definition: opus_private.h:42
opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen, int self_delimited, int pad)
Definition: repacketizer.c:102
int nb_channels
Definition: opus_private.h:47
Definition: opus_encoder.c:62
EGLStreamKHR EGLint EGLint EGLint size
Definition: eglext.h:984
DOMString p
Definition: WebCryptoAPI.idl:116
int c
Definition: cpp_unittests.cpp:275
GLuint GLuint end
Definition: gl2ext.h:323
short opus_int16
Definition: opus_types.h:144
OPENSSL_EXPORT pem_password_cb void * u
Definition: pem.h:398
Definition: opus_private.h:46
Contains all the functions for encoding and decoding audio.
int nb_frames
Definition: opus_private.h:40
opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_size, unsigned char *data, opus_int32 out_data_bytes, int lsb_depth, const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, int analysis_channels, downmix_func downmix, int float_api)
Definition: opus_encoder.c:937
int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev)
Definition: opus_multistream.c:81
int pad
Definition: statusor_test.cc:47
int nb_coupled_streams
Definition: opus_private.h:49
float opus_val16
Definition: arch.h:148
int encode_size(int size, unsigned char *data)
Definition: opus.c:140
void
Definition: AVFoundationCFSoftLinking.h:81
int
Definition: runtests.py:53
EGLStreamKHR EGLint EGLint offset
Definition: eglext.h:984
int get_right_channel(const ChannelLayout *layout, int stream_id, int prev)
Definition: opus_multistream.c:69
int opus_int32
Definition: opus_types.h:146
int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 len, opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited, opus_int32 *packet_offset, int soft_clip)
Definition: opus_decoder.c:598
endif
Definition: downloads.php:90
int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, int self_delimited, unsigned char *out_toc, const unsigned char *frames[48], opus_int16 size[48], int *payload_offset, opus_int32 *packet_offset)
Definition: opus.c:194
int framesize
Definition: opus_private.h:43
void(* downmix_func)(const void *, opus_val32 *, int, int, int, int, int)
Definition: opus_private.h:87
void downmix_int(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C)
Definition: opus_encoder.c:773
void downmix_float(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C)
Definition: opus_encoder.c:738
def sub(pattern, replacement, s)
Definition: common.py:63
opus_int32 frame_size_select(opus_int32 frame_size, int variable_duration, opus_int32 Fs)
Definition: opus_encoder.c:807
const GLfloat * v
Definition: gl2.h:514
std::string stream_id
Definition: peerconnection_jni.cc:2055
Definition: opus_decoder.c:55
EGLStreamKHR EGLint EGLint EGLint const void * data
Definition: eglext.h:984
const unsigned char * frames[48]
Definition: opus_private.h:41
for i
Definition: complexityMeasures.m:24
Definition: type_traits_unittest.cc:77
unsigned char toc
Definition: opus_private.h:39
int pad_frame(unsigned char *data, opus_int32 len, opus_int32 new_len)
Definition: opus_private.h:38
int get_left_channel(const ChannelLayout *layout, int stream_id, int prev)
Definition: opus_multistream.c:57
Opus reference implementation API.
Definition: gtest_output_test_.cc:628
Various architecture definitions for CELT.
struct ChannelLayout ChannelLayout
float opus_val32
Definition: arch.h:149
int nb_streams
Definition: opus_private.h:48
Definition: interfaces.idl:174
int validate_layout(const ChannelLayout *layout)
Definition: opus_multistream.c:41
opus_int32 compute_frame_size(const void *analysis_pcm, int frame_size, int variable_duration, int C, opus_int32 Fs, int bitrate_bps, int delay_compensation, downmix_func downmix, float *subframe_mem)
Definition: opus_encoder.c:828