diff options
Diffstat (limited to 'lib/rbcodec/codecs/libopus/opus_private.h')
-rw-r--r-- | lib/rbcodec/codecs/libopus/opus_private.h | 96 |
1 files changed, 85 insertions, 11 deletions
diff --git a/lib/rbcodec/codecs/libopus/opus_private.h b/lib/rbcodec/codecs/libopus/opus_private.h index 3177f52442..09783ceefc 100644 --- a/lib/rbcodec/codecs/libopus/opus_private.h +++ b/lib/rbcodec/codecs/libopus/opus_private.h | |||
@@ -33,6 +33,9 @@ | |||
33 | #include "opus.h" | 33 | #include "opus.h" |
34 | #include "celt.h" | 34 | #include "celt.h" |
35 | 35 | ||
36 | #include <stdarg.h> /* va_list */ | ||
37 | #include <stddef.h> /* offsetof */ | ||
38 | |||
36 | struct OpusRepacketizer { | 39 | struct OpusRepacketizer { |
37 | unsigned char toc; | 40 | unsigned char toc; |
38 | int nb_frames; | 41 | int nb_frames; |
@@ -48,12 +51,59 @@ typedef struct ChannelLayout { | |||
48 | unsigned char mapping[256]; | 51 | unsigned char mapping[256]; |
49 | } ChannelLayout; | 52 | } ChannelLayout; |
50 | 53 | ||
54 | typedef enum { | ||
55 | MAPPING_TYPE_NONE, | ||
56 | MAPPING_TYPE_SURROUND, | ||
57 | MAPPING_TYPE_AMBISONICS | ||
58 | } MappingType; | ||
59 | |||
60 | struct OpusMSEncoder { | ||
61 | ChannelLayout layout; | ||
62 | int arch; | ||
63 | int lfe_stream; | ||
64 | int application; | ||
65 | int variable_duration; | ||
66 | MappingType mapping_type; | ||
67 | opus_int32 bitrate_bps; | ||
68 | /* Encoder states go here */ | ||
69 | /* then opus_val32 window_mem[channels*120]; */ | ||
70 | /* then opus_val32 preemph_mem[channels]; */ | ||
71 | }; | ||
72 | |||
73 | struct OpusMSDecoder { | ||
74 | ChannelLayout layout; | ||
75 | /* Decoder states go here */ | ||
76 | }; | ||
77 | |||
78 | int opus_multistream_encoder_ctl_va_list(struct OpusMSEncoder *st, int request, | ||
79 | va_list ap); | ||
80 | int opus_multistream_decoder_ctl_va_list(struct OpusMSDecoder *st, int request, | ||
81 | va_list ap); | ||
82 | |||
51 | int validate_layout(const ChannelLayout *layout); | 83 | int validate_layout(const ChannelLayout *layout); |
52 | int get_left_channel(const ChannelLayout *layout, int stream_id, int prev); | 84 | int get_left_channel(const ChannelLayout *layout, int stream_id, int prev); |
53 | int get_right_channel(const ChannelLayout *layout, int stream_id, int prev); | 85 | int get_right_channel(const ChannelLayout *layout, int stream_id, int prev); |
54 | int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev); | 86 | int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev); |
55 | 87 | ||
56 | 88 | typedef void (*opus_copy_channel_in_func)( | |
89 | opus_val16 *dst, | ||
90 | int dst_stride, | ||
91 | const void *src, | ||
92 | int src_stride, | ||
93 | int src_channel, | ||
94 | int frame_size, | ||
95 | void *user_data | ||
96 | ); | ||
97 | |||
98 | typedef void (*opus_copy_channel_out_func)( | ||
99 | void *dst, | ||
100 | int dst_stride, | ||
101 | int dst_channel, | ||
102 | const opus_val16 *src, | ||
103 | int src_stride, | ||
104 | int frame_size, | ||
105 | void *user_data | ||
106 | ); | ||
57 | 107 | ||
58 | #define MODE_SILK_ONLY 1000 | 108 | #define MODE_SILK_ONLY 1000 |
59 | #define MODE_HYBRID 1001 | 109 | #define MODE_HYBRID 1001 |
@@ -90,14 +140,6 @@ int encode_size(int size, unsigned char *data); | |||
90 | 140 | ||
91 | opus_int32 frame_size_select(opus_int32 frame_size, int variable_duration, opus_int32 Fs); | 141 | opus_int32 frame_size_select(opus_int32 frame_size, int variable_duration, opus_int32 Fs); |
92 | 142 | ||
93 | opus_int32 compute_frame_size(const void *analysis_pcm, int frame_size, | ||
94 | int variable_duration, int C, opus_int32 Fs, int bitrate_bps, | ||
95 | int delay_compensation, downmix_func downmix | ||
96 | #ifndef DISABLE_FLOAT_API | ||
97 | , float *subframe_mem | ||
98 | #endif | ||
99 | ); | ||
100 | |||
101 | opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_size, | 143 | opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_size, |
102 | unsigned char *data, opus_int32 out_data_bytes, int lsb_depth, | 144 | unsigned char *data, opus_int32 out_data_bytes, int lsb_depth, |
103 | const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, | 145 | const void *analysis_pcm, opus_int32 analysis_size, int c1, int c2, |
@@ -107,10 +149,16 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 le | |||
107 | opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited, | 149 | opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited, |
108 | opus_int32 *packet_offset, int soft_clip); | 150 | opus_int32 *packet_offset, int soft_clip); |
109 | 151 | ||
110 | /* Make sure everything's aligned to sizeof(void *) bytes */ | 152 | /* Make sure everything is properly aligned. */ |
111 | static OPUS_INLINE int align(int i) | 153 | static OPUS_INLINE int align(int i) |
112 | { | 154 | { |
113 | return (i+(int)sizeof(void *)-1)&-(int)sizeof(void *); | 155 | struct foo {char c; union { void* p; opus_int32 i; opus_val32 v; } u;}; |
156 | |||
157 | unsigned int alignment = offsetof(struct foo, u); | ||
158 | |||
159 | /* Optimizing compilers should optimize div and multiply into and | ||
160 | for all sensible alignment values. */ | ||
161 | return ((i + alignment - 1) / alignment) * alignment; | ||
114 | } | 162 | } |
115 | 163 | ||
116 | int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, | 164 | int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, |
@@ -123,4 +171,30 @@ opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int | |||
123 | 171 | ||
124 | int pad_frame(unsigned char *data, opus_int32 len, opus_int32 new_len); | 172 | int pad_frame(unsigned char *data, opus_int32 len, opus_int32 new_len); |
125 | 173 | ||
174 | int opus_multistream_encode_native | ||
175 | ( | ||
176 | struct OpusMSEncoder *st, | ||
177 | opus_copy_channel_in_func copy_channel_in, | ||
178 | const void *pcm, | ||
179 | int analysis_frame_size, | ||
180 | unsigned char *data, | ||
181 | opus_int32 max_data_bytes, | ||
182 | int lsb_depth, | ||
183 | downmix_func downmix, | ||
184 | int float_api, | ||
185 | void *user_data | ||
186 | ); | ||
187 | |||
188 | int opus_multistream_decode_native( | ||
189 | struct OpusMSDecoder *st, | ||
190 | const unsigned char *data, | ||
191 | opus_int32 len, | ||
192 | void *pcm, | ||
193 | opus_copy_channel_out_func copy_channel_out, | ||
194 | int frame_size, | ||
195 | int decode_fec, | ||
196 | int soft_clip, | ||
197 | void *user_data | ||
198 | ); | ||
199 | |||
126 | #endif /* OPUS_PRIVATE_H */ | 200 | #endif /* OPUS_PRIVATE_H */ |