| 1 | /* Copyright (c) 2011 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 | //#ifdef HAVE_CONFIG_H |
| 29 | #include "opus__config.h"cxx . . $ `<file>/external/opusfile/opus/opus__config.h`/ |
| 30 | //#endif |
| 31 | |
| 32 | #include "opus_multistream.h"cxx . . $ `<file>/external/opusfile/opus/opus_multistream.h`/ |
| 33 | #include "opus.h"cxx . . $ `<file>/external/opusfile/opus/opus.h`/ |
| 34 | #include "opus_private.h"cxx . . $ `<file>/external/opusfile/opus/opus_private.h`/ |
| 35 | #include "stack_alloc.h"cxx . . $ `<file>/external/opusfile/opus/celt/stack_alloc.h`/ |
| 36 | #include <stdarg.h> |
| 37 | #include "float_cast.h"cxx . . $ `<file>/external/opusfile/opus/celt/float_cast.h`/ |
| 38 | #include "os_support.h"cxx . . $ `<file>/external/opusfile/opus/celt/os_support.h`/ |
| 39 | |
| 40 | /* DECODER */ |
| 41 | |
| 42 | #if defined(ENABLE_HARDENINGcxx . . $ `opus/opus__config.h:23:9`!) || defined(ENABLE_ASSERTIONS) |
| 43 | static void validate_ms_decodercxx . . $ validate_ms_decoder(f2352feb5c6bddb9).(OpusMSDecodercxx . . $ OpusMSDecoder# *st) |
| 44 | { |
| 45 | validate_layoutcxx . . $ validate_layout(a0a3f1359841bb08).(&st->layoutcxx . . $ OpusMSDecoder#layout.); |
| 46 | } |
| 47 | #define VALIDATE_MS_DECODERcxx . . $ `external/opusfile/opus/opus_multistream_decoder.c:47:9`!(st) validate_ms_decoder(st) |
| 48 | #else |
| 49 | #define VALIDATE_MS_DECODER(st) |
| 50 | #endif |
| 51 | |
| 52 | |
| 53 | opus_int32cxx . . $ opus_int32# opus_multistream_decoder_get_sizecxx . . $ opus_multistream_decoder_get_size(9b79fb6aee4c0440).(int nb_streams, int nb_coupled_streams) |
| 54 | { |
| 55 | int coupled_size; |
| 56 | int mono_size; |
| 57 | |
| 58 | if(nb_streams<1||nb_coupled_streams>nb_streams||nb_coupled_streams<0)return 0; |
| 59 | coupled_size = opus_decoder_get_sizecxx . . $ opus_decoder_get_size(7864480464b09eea).(2); |
| 60 | mono_size = opus_decoder_get_sizecxx . . $ opus_decoder_get_size(7864480464b09eea).(1); |
| 61 | return aligncxx . . $ align(7864480464b09eea).(sizeof(OpusMSDecodercxx . . $ OpusMSDecoder#)) |
| 62 | + nb_coupled_streams * aligncxx . . $ align(7864480464b09eea).(coupled_size) |
| 63 | + (nb_streams-nb_coupled_streams) * aligncxx . . $ align(7864480464b09eea).(mono_size); |
| 64 | } |
| 65 | |
| 66 | int opus_multistream_decoder_initcxx . . $ opus_multistream_decoder_init(3dc05d7ab8591df3).( |
| 67 | OpusMSDecodercxx . . $ OpusMSDecoder# *st, |
| 68 | opus_int32cxx . . $ opus_int32# Fs, |
| 69 | int channels, |
| 70 | int streams, |
| 71 | int coupled_streams, |
| 72 | const unsigned char *mapping |
| 73 | ) |
| 74 | { |
| 75 | int coupled_size; |
| 76 | int mono_size; |
| 77 | int i, ret; |
| 78 | char *ptr; |
| 79 | |
| 80 | if ((channels>255) || (channels<1) || (coupled_streams>streams) || |
| 81 | (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) |
| 82 | return OPUS_BAD_ARGcxx . . $ `external/opusfile/opus/opus_defines.h:48:9`!; |
| 83 | |
| 84 | st->layoutcxx . . $ OpusMSDecoder#layout..nb_channelscxx . . $ ChannelLayout#nb_channels. = channels; |
| 85 | st->layoutcxx . . $ OpusMSDecoder#layout..nb_streamscxx . . $ ChannelLayout#nb_streams. = streams; |
| 86 | st->layoutcxx . . $ OpusMSDecoder#layout..nb_coupled_streamscxx . . $ ChannelLayout#nb_coupled_streams. = coupled_streams; |
| 87 | |
| 88 | for (i=0;i<st->layoutcxx . . $ OpusMSDecoder#layout..nb_channelscxx . . $ ChannelLayout#nb_channels.;i++) |
| 89 | st->layoutcxx . . $ OpusMSDecoder#layout..mappingcxx . . $ ChannelLayout#mapping.[i] = mapping[i]; |
| 90 | if (!validate_layoutcxx . . $ validate_layout(a0a3f1359841bb08).(&st->layoutcxx . . $ OpusMSDecoder#layout.)) |
| 91 | return OPUS_BAD_ARGcxx . . $ `external/opusfile/opus/opus_defines.h:48:9`!; |
| 92 | |
| 93 | ptr = (char*)st + aligncxx . . $ align(7864480464b09eea).(sizeof(OpusMSDecodercxx . . $ OpusMSDecoder#)); |
| 94 | coupled_size = opus_decoder_get_sizecxx . . $ opus_decoder_get_size(7864480464b09eea).(2); |
| 95 | mono_size = opus_decoder_get_sizecxx . . $ opus_decoder_get_size(7864480464b09eea).(1); |
| 96 | |
| 97 | for (i=0;i<st->layoutcxx . . $ OpusMSDecoder#layout..nb_coupled_streamscxx . . $ ChannelLayout#nb_coupled_streams.;i++) |
| 98 | { |
| 99 | ret=opus_decoder_initcxx . . $ opus_decoder_init(9510fc33f634cb6e).((OpusDecodercxx . . $ OpusDecoder#*)ptr, Fs, 2); |
| 100 | if(ret!=OPUS_OKcxx . . $ `external/opusfile/opus/opus_defines.h:46:9`!)return ret; |
| 101 | ptr += aligncxx . . $ align(7864480464b09eea).(coupled_size); |
| 102 | } |
| 103 | for (;i<st->layoutcxx . . $ OpusMSDecoder#layout..nb_streamscxx . . $ ChannelLayout#nb_streams.;i++) |
| 104 | { |
| 105 | ret=opus_decoder_initcxx . . $ opus_decoder_init(9510fc33f634cb6e).((OpusDecodercxx . . $ OpusDecoder#*)ptr, Fs, 1); |
| 106 | if(ret!=OPUS_OKcxx . . $ `external/opusfile/opus/opus_defines.h:46:9`!)return ret; |
| 107 | ptr += aligncxx . . $ align(7864480464b09eea).(mono_size); |
| 108 | } |
| 109 | return OPUS_OKcxx . . $ `external/opusfile/opus/opus_defines.h:46:9`!; |
| 110 | } |
| 111 | |
| 112 | |
| 113 | OpusMSDecodercxx . . $ OpusMSDecoder# *opus_multistream_decoder_createcxx . . $ opus_multistream_decoder_create(a6a4211c0ba04f42).( |
| 114 | opus_int32cxx . . $ opus_int32# Fs, |
| 115 | int channels, |
| 116 | int streams, |
| 117 | int coupled_streams, |
| 118 | const unsigned char *mapping, |
| 119 | int *error |
| 120 | ) |
| 121 | { |
| 122 | int ret; |
| 123 | OpusMSDecodercxx . . $ OpusMSDecoder# *st; |
| 124 | if ((channels>255) || (channels<1) || (coupled_streams>streams) || |
| 125 | (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) |
| 126 | { |
| 127 | if (error) |
| 128 | *error = OPUS_BAD_ARGcxx . . $ `external/opusfile/opus/opus_defines.h:48:9`!; |
| 129 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 130 | } |
| 131 | st = (OpusMSDecodercxx . . $ OpusMSDecoder# *)opus_alloccxx . . $ opus_alloc(bfcfa4d6b7f7ef64).(opus_multistream_decoder_get_sizecxx . . $ opus_multistream_decoder_get_size(9b79fb6aee4c0440).(streams, coupled_streams)); |
| 132 | if (st==NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 133 | { |
| 134 | if (error) |
| 135 | *error = OPUS_ALLOC_FAILcxx . . $ `external/opusfile/opus/opus_defines.h:60:9`!; |
| 136 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 137 | } |
| 138 | ret = opus_multistream_decoder_initcxx . . $ opus_multistream_decoder_init(3dc05d7ab8591df3).(st, Fs, channels, streams, coupled_streams, mapping); |
| 139 | if (error) |
| 140 | *error = ret; |
| 141 | if (ret != OPUS_OKcxx . . $ `external/opusfile/opus/opus_defines.h:46:9`!) |
| 142 | { |
| 143 | opus_freecxx . . $ opus_free(5d22bdacc48458e8).(st); |
| 144 | st = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 145 | } |
| 146 | return st; |
| 147 | } |
| 148 | |
| 149 | static int opus_multistream_packet_validatecxx . . $ opus_multistream_packet_validate(bf4c52f3bf76fa88).(const unsigned char *data, |
| 150 | opus_int32cxx . . $ opus_int32# len, int nb_streams, opus_int32cxx . . $ opus_int32# Fs) |
| 151 | { |
| 152 | int s; |
| 153 | int count; |
| 154 | unsigned char toc; |
| 155 | opus_int16cxx . . $ opus_int16# size[48]; |
| 156 | int samples=0; |
| 157 | opus_int32cxx . . $ opus_int32# packet_offset; |
| 158 | |
| 159 | for (s=0;s<nb_streams;s++) |
| 160 | { |
| 161 | int tmp_samples; |
| 162 | if (len<=0) |
| 163 | return OPUS_INVALID_PACKETcxx . . $ `external/opusfile/opus/opus_defines.h:54:9`!; |
| 164 | count = opus_packet_parse_implcxx . . $ opus_packet_parse_impl(58cc79780d799092).(data, len, s!=nb_streams-1, &toc, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 165 | size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &packet_offset); |
| 166 | if (count<0) |
| 167 | return count; |
| 168 | tmp_samples = opus_packet_get_nb_samplescxx . . $ opus_packet_get_nb_samples(98fdf16c90fffe93).(data, packet_offset, Fs); |
| 169 | if (s!=0 && samples != tmp_samples) |
| 170 | return OPUS_INVALID_PACKETcxx . . $ `external/opusfile/opus/opus_defines.h:54:9`!; |
| 171 | samples = tmp_samples; |
| 172 | data += packet_offset; |
| 173 | len -= packet_offset; |
| 174 | } |
| 175 | return samples; |
| 176 | } |
| 177 | |
| 178 | int opus_multistream_decode_nativecxx . . $ opus_multistream_decode_native(cb7d28c34cf5aff9).( |
| 179 | OpusMSDecodercxx . . $ OpusMSDecoder# *st, |
| 180 | const unsigned char *data, |
| 181 | opus_int32cxx . . $ opus_int32# len, |
| 182 | void *pcm, |
| 183 | opus_copy_channel_out_funccxx . . $ opus_copy_channel_out_func# copy_channel_out, |
| 184 | int frame_size, |
| 185 | int decode_fec, |
| 186 | int soft_clip, |
| 187 | void *user_data |
| 188 | ) |
| 189 | { |
| 190 | opus_int32cxx . . $ opus_int32# Fs; |
| 191 | int coupled_size; |
| 192 | int mono_size; |
| 193 | int s, c; |
| 194 | char *ptr; |
| 195 | int do_plc=0; |
| 196 | VARDECLcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:94:9`!(opus_val16, buf); |
| 197 | ALLOC_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:98:9`!; |
| 198 | |
| 199 | VALIDATE_MS_DECODERcxx . . $ `external/opusfile/opus/opus_multistream_decoder.c:47:9`!(st); |
| 200 | if (frame_size <= 0) |
| 201 | { |
| 202 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 203 | return OPUS_BAD_ARGcxx . . $ `external/opusfile/opus/opus_defines.h:48:9`!; |
| 204 | } |
| 205 | /* Limit frame_size to avoid excessive stack allocations. */ |
| 206 | MUST_SUCCEEDcxx . . $ `external/opusfile/opus/celt/arch.h:82:9`!(opus_multistream_decoder_ctl(st, OPUS_GET_SAMPLE_RATEcxx . . $ `external/opusfile/opus/opus_defines.h:694:9`!(&Fs))); |
| 207 | frame_size = IMINcxx . . $ `external/opusfile/opus/celt/arch.h:101:9`!(frame_size, Fs/25*3); |
| 208 | ALLOCcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:95:9`!(buf, 2*frame_size, opus_val16); |
| 209 | ptr = (char*)st + aligncxx . . $ align(7864480464b09eea).(sizeof(OpusMSDecodercxx . . $ OpusMSDecoder#)); |
| 210 | coupled_size = opus_decoder_get_sizecxx . . $ opus_decoder_get_size(7864480464b09eea).(2); |
| 211 | mono_size = opus_decoder_get_sizecxx . . $ opus_decoder_get_size(7864480464b09eea).(1); |
| 212 | |
| 213 | if (len==0) |
| 214 | do_plc = 1; |
| 215 | if (len < 0) |
| 216 | { |
| 217 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 218 | return OPUS_BAD_ARGcxx . . $ `external/opusfile/opus/opus_defines.h:48:9`!; |
| 219 | } |
| 220 | if (!do_plc && len < 2*st->layoutcxx . . $ OpusMSDecoder#layout..nb_streamscxx . . $ ChannelLayout#nb_streams.-1) |
| 221 | { |
| 222 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 223 | return OPUS_INVALID_PACKETcxx . . $ `external/opusfile/opus/opus_defines.h:54:9`!; |
| 224 | } |
| 225 | if (!do_plc) |
| 226 | { |
| 227 | int ret = opus_multistream_packet_validatecxx . . $ opus_multistream_packet_validate(bf4c52f3bf76fa88).(data, len, st->layoutcxx . . $ OpusMSDecoder#layout..nb_streamscxx . . $ ChannelLayout#nb_streams., Fs); |
| 228 | if (ret < 0) |
| 229 | { |
| 230 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 231 | return ret; |
| 232 | } else if (ret > frame_size) |
| 233 | { |
| 234 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 235 | return OPUS_BUFFER_TOO_SMALLcxx . . $ `external/opusfile/opus/opus_defines.h:50:9`!; |
| 236 | } |
| 237 | } |
| 238 | for (s=0;s<st->layoutcxx . . $ OpusMSDecoder#layout..nb_streamscxx . . $ ChannelLayout#nb_streams.;s++) |
| 239 | { |
| 240 | OpusDecodercxx . . $ OpusDecoder# *dec; |
| 241 | opus_int32cxx . . $ opus_int32# packet_offset; |
| 242 | int ret; |
| 243 | |
| 244 | dec = (OpusDecodercxx . . $ OpusDecoder#*)ptr; |
| 245 | ptr += (s < st->layoutcxx . . $ OpusMSDecoder#layout..nb_coupled_streamscxx . . $ ChannelLayout#nb_coupled_streams.) ? aligncxx . . $ align(7864480464b09eea).(coupled_size) : aligncxx . . $ align(7864480464b09eea).(mono_size); |
| 246 | |
| 247 | if (!do_plc && len<=0) |
| 248 | { |
| 249 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 250 | return OPUS_INTERNAL_ERRORcxx . . $ `external/opusfile/opus/opus_defines.h:52:9`!; |
| 251 | } |
| 252 | packet_offset = 0; |
| 253 | ret = opus_decode_nativecxx . . $ opus_decode_native(6e6dc8054156a6af).(dec, data, len, buf, frame_size, decode_fec, s!=st->layoutcxx . . $ OpusMSDecoder#layout..nb_streamscxx . . $ ChannelLayout#nb_streams.-1, &packet_offset, soft_clip); |
| 254 | data += packet_offset; |
| 255 | len -= packet_offset; |
| 256 | if (ret <= 0) |
| 257 | { |
| 258 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 259 | return ret; |
| 260 | } |
| 261 | frame_size = ret; |
| 262 | if (s < st->layoutcxx . . $ OpusMSDecoder#layout..nb_coupled_streamscxx . . $ ChannelLayout#nb_coupled_streams.) |
| 263 | { |
| 264 | int chan, prev; |
| 265 | prev = -1; |
| 266 | /* Copy "left" audio to the channel(s) where it belongs */ |
| 267 | while ( (chan = get_left_channelcxx . . $ get_left_channel(f091a8981cec74a0).(&st->layoutcxx . . $ OpusMSDecoder#layout., s, prev)) != -1) |
| 268 | { |
| 269 | (*copy_channel_out)(pcm, st->layoutcxx . . $ OpusMSDecoder#layout..nb_channelscxx . . $ ChannelLayout#nb_channels., chan, |
| 270 | buf, 2, frame_size, user_data); |
| 271 | prev = chan; |
| 272 | } |
| 273 | prev = -1; |
| 274 | /* Copy "right" audio to the channel(s) where it belongs */ |
| 275 | while ( (chan = get_right_channelcxx . . $ get_right_channel(f091a8981cec74a0).(&st->layoutcxx . . $ OpusMSDecoder#layout., s, prev)) != -1) |
| 276 | { |
| 277 | (*copy_channel_out)(pcm, st->layoutcxx . . $ OpusMSDecoder#layout..nb_channelscxx . . $ ChannelLayout#nb_channels., chan, |
| 278 | buf+1, 2, frame_size, user_data); |
| 279 | prev = chan; |
| 280 | } |
| 281 | } else { |
| 282 | int chan, prev; |
| 283 | prev = -1; |
| 284 | /* Copy audio to the channel(s) where it belongs */ |
| 285 | while ( (chan = get_mono_channelcxx . . $ get_mono_channel(f091a8981cec74a0).(&st->layoutcxx . . $ OpusMSDecoder#layout., s, prev)) != -1) |
| 286 | { |
| 287 | (*copy_channel_out)(pcm, st->layoutcxx . . $ OpusMSDecoder#layout..nb_channelscxx . . $ ChannelLayout#nb_channels., chan, |
| 288 | buf, 1, frame_size, user_data); |
| 289 | prev = chan; |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | /* Handle muted channels */ |
| 294 | for (c=0;c<st->layoutcxx . . $ OpusMSDecoder#layout..nb_channelscxx . . $ ChannelLayout#nb_channels.;c++) |
| 295 | { |
| 296 | if (st->layoutcxx . . $ OpusMSDecoder#layout..mappingcxx . . $ ChannelLayout#mapping.[c] == 255) |
| 297 | { |
| 298 | (*copy_channel_out)(pcm, st->layoutcxx . . $ OpusMSDecoder#layout..nb_channelscxx . . $ ChannelLayout#nb_channels., c, |
| 299 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, frame_size, user_data); |
| 300 | } |
| 301 | } |
| 302 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 303 | return frame_size; |
| 304 | } |
| 305 | |
| 306 | #if !defined(DISABLE_FLOAT_API) |
| 307 | static void opus_copy_channel_out_floatcxx . . $ opus_copy_channel_out_float(c0f16f7c1c891d4e).( |
| 308 | void *dst, |
| 309 | int dst_stride, |
| 310 | int dst_channel, |
| 311 | const opus_val16cxx . . $ opus_val16# *src, |
| 312 | int src_stride, |
| 313 | int frame_size, |
| 314 | void *user_data |
| 315 | ) |
| 316 | { |
| 317 | float *float_dst; |
| 318 | opus_int32cxx . . $ opus_int32# i; |
| 319 | (void)user_data; |
| 320 | float_dst = (float*)dst; |
| 321 | if (src != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 322 | { |
| 323 | for (i=0;i<frame_size;i++) |
| 324 | #if defined(FIXED_POINT) |
| 325 | float_dst[i*dst_stride+dst_channel] = (1/32768.f)*src[i*src_stride]; |
| 326 | #else |
| 327 | float_dst[i*dst_stride+dst_channel] = src[i*src_stride]; |
| 328 | #endif |
| 329 | } |
| 330 | else |
| 331 | { |
| 332 | for (i=0;i<frame_size;i++) |
| 333 | float_dst[i*dst_stride+dst_channel] = 0; |
| 334 | } |
| 335 | } |
| 336 | #endif |
| 337 | |
| 338 | static void opus_copy_channel_out_shortcxx . . $ opus_copy_channel_out_short(c0f16f7c1c891d4e).( |
| 339 | void *dst, |
| 340 | int dst_stride, |
| 341 | int dst_channel, |
| 342 | const opus_val16cxx . . $ opus_val16# *src, |
| 343 | int src_stride, |
| 344 | int frame_size, |
| 345 | void *user_data |
| 346 | ) |
| 347 | { |
| 348 | opus_int16cxx . . $ opus_int16# *short_dst; |
| 349 | opus_int32cxx . . $ opus_int32# i; |
| 350 | (void)user_data; |
| 351 | short_dst = (opus_int16cxx . . $ opus_int16#*)dst; |
| 352 | if (src != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 353 | { |
| 354 | for (i=0;i<frame_size;i++) |
| 355 | #if defined(FIXED_POINT) |
| 356 | short_dst[i*dst_stride+dst_channel] = src[i*src_stride]; |
| 357 | #else |
| 358 | short_dst[i*dst_stride+dst_channel] = FLOAT2INT16cxx . . $ FLOAT2INT16(16fe5f45793b5599).(src[i*src_stride]); |
| 359 | #endif |
| 360 | } |
| 361 | else |
| 362 | { |
| 363 | for (i=0;i<frame_size;i++) |
| 364 | short_dst[i*dst_stride+dst_channel] = 0; |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | |
| 369 | |
| 370 | #ifdef FIXED_POINT |
| 371 | int opus_multistream_decode( |
| 372 | OpusMSDecoder *st, |
| 373 | const unsigned char *data, |
| 374 | opus_int32 len, |
| 375 | opus_int16 *pcm, |
| 376 | int frame_size, |
| 377 | int decode_fec |
| 378 | ) |
| 379 | { |
| 380 | return opus_multistream_decode_native(st, data, len, |
| 381 | pcm, opus_copy_channel_out_short, frame_size, decode_fec, 0, NULL); |
| 382 | } |
| 383 | |
| 384 | #ifndef DISABLE_FLOAT_API |
| 385 | int opus_multistream_decode_float(OpusMSDecoder *st, const unsigned char *data, |
| 386 | opus_int32 len, float *pcm, int frame_size, int decode_fec) |
| 387 | { |
| 388 | return opus_multistream_decode_native(st, data, len, |
| 389 | pcm, opus_copy_channel_out_float, frame_size, decode_fec, 0, NULL); |
| 390 | } |
| 391 | #endif |
| 392 | |
| 393 | #else |
| 394 | |
| 395 | int opus_multistream_decodecxx . . $ opus_multistream_decode(c82402998d70293e).(OpusMSDecodercxx . . $ OpusMSDecoder# *st, const unsigned char *data, |
| 396 | opus_int32cxx . . $ opus_int32# len, opus_int16cxx . . $ opus_int16# *pcm, int frame_size, int decode_fec) |
| 397 | { |
| 398 | return opus_multistream_decode_nativecxx . . $ opus_multistream_decode_native(cb7d28c34cf5aff9).(st, data, len, |
| 399 | pcm, opus_copy_channel_out_shortcxx . . $ opus_copy_channel_out_short(c0f16f7c1c891d4e)., frame_size, decode_fec, 1, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 400 | } |
| 401 | |
| 402 | int opus_multistream_decode_floatcxx . . $ opus_multistream_decode_float(383536836ff2deb3).( |
| 403 | OpusMSDecodercxx . . $ OpusMSDecoder# *st, |
| 404 | const unsigned char *data, |
| 405 | opus_int32cxx . . $ opus_int32# len, |
| 406 | opus_val16cxx . . $ opus_val16# *pcm, |
| 407 | int frame_size, |
| 408 | int decode_fec |
| 409 | ) |
| 410 | { |
| 411 | return opus_multistream_decode_nativecxx . . $ opus_multistream_decode_native(cb7d28c34cf5aff9).(st, data, len, |
| 412 | pcm, opus_copy_channel_out_floatcxx . . $ opus_copy_channel_out_float(c0f16f7c1c891d4e)., frame_size, decode_fec, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 413 | } |
| 414 | #endif |
| 415 | |
| 416 | int opus_multistream_decoder_ctl_va_listcxx . . $ opus_multistream_decoder_ctl_va_list(d032d9922d7f399f).(OpusMSDecodercxx . . $ OpusMSDecoder# *st, int request, |
| 417 | va_listcxx . . $ va_list# ap) |
| 418 | { |
| 419 | int coupled_size, mono_size; |
| 420 | char *ptr; |
| 421 | int ret = OPUS_OKcxx . . $ `external/opusfile/opus/opus_defines.h:46:9`!; |
| 422 | |
| 423 | coupled_size = opus_decoder_get_sizecxx . . $ opus_decoder_get_size(7864480464b09eea).(2); |
| 424 | mono_size = opus_decoder_get_sizecxx . . $ opus_decoder_get_size(7864480464b09eea).(1); |
| 425 | ptr = (char*)st + aligncxx . . $ align(7864480464b09eea).(sizeof(OpusMSDecodercxx . . $ OpusMSDecoder#)); |
| 426 | switch (request) |
| 427 | { |
| 428 | case OPUS_GET_BANDWIDTH_REQUESTcxx . . $ `external/opusfile/opus/opus_defines.h:139:9`!: |
| 429 | case OPUS_GET_SAMPLE_RATE_REQUESTcxx . . $ `external/opusfile/opus/opus_defines.h:156:9`!: |
| 430 | case OPUS_GET_GAIN_REQUESTcxx . . $ `external/opusfile/opus/opus_defines.h:160:9`!: |
| 431 | case OPUS_GET_LAST_PACKET_DURATION_REQUESTcxx . . $ `external/opusfile/opus/opus_defines.h:163:9`!: |
| 432 | case OPUS_GET_PHASE_INVERSION_DISABLED_REQUESTcxx . . $ `external/opusfile/opus/opus_defines.h:170:9`!: |
| 433 | { |
| 434 | OpusDecodercxx . . $ OpusDecoder# *dec; |
| 435 | /* For int32* GET params, just query the first stream */ |
| 436 | opus_int32cxx . . $ opus_int32# *value = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`!(ap, opus_int32*); |
| 437 | dec = (OpusDecodercxx . . $ OpusDecoder#*)ptr; |
| 438 | ret = opus_decoder_ctlcxx . . $ opus_decoder_ctl(f96ea19e1ec6253).(dec, request, value); |
| 439 | } |
| 440 | break; |
| 441 | case OPUS_GET_FINAL_RANGE_REQUESTcxx . . $ `external/opusfile/opus/opus_defines.h:157:9`!: |
| 442 | { |
| 443 | int s; |
| 444 | opus_uint32cxx . . $ opus_uint32# *value = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`!(ap, opus_uint32*); |
| 445 | opus_uint32cxx . . $ opus_uint32# tmp; |
| 446 | if (!value) |
| 447 | { |
| 448 | goto bad_arg; |
| 449 | } |
| 450 | *value = 0; |
| 451 | for (s=0;s<st->layoutcxx . . $ OpusMSDecoder#layout..nb_streamscxx . . $ ChannelLayout#nb_streams.;s++) |
| 452 | { |
| 453 | OpusDecodercxx . . $ OpusDecoder# *dec; |
| 454 | dec = (OpusDecodercxx . . $ OpusDecoder#*)ptr; |
| 455 | if (s < st->layoutcxx . . $ OpusMSDecoder#layout..nb_coupled_streamscxx . . $ ChannelLayout#nb_coupled_streams.) |
| 456 | ptr += aligncxx . . $ align(7864480464b09eea).(coupled_size); |
| 457 | else |
| 458 | ptr += aligncxx . . $ align(7864480464b09eea).(mono_size); |
| 459 | ret = opus_decoder_ctlcxx . . $ opus_decoder_ctl(f96ea19e1ec6253).(dec, request, &tmp); |
| 460 | if (ret != OPUS_OKcxx . . $ `external/opusfile/opus/opus_defines.h:46:9`!) break; |
| 461 | *value ^= tmp; |
| 462 | } |
| 463 | } |
| 464 | break; |
| 465 | case OPUS_RESET_STATEcxx . . $ `external/opusfile/opus/opus_defines.h:662:9`!: |
| 466 | { |
| 467 | int s; |
| 468 | for (s=0;s<st->layoutcxx . . $ OpusMSDecoder#layout..nb_streamscxx . . $ ChannelLayout#nb_streams.;s++) |
| 469 | { |
| 470 | OpusDecodercxx . . $ OpusDecoder# *dec; |
| 471 | |
| 472 | dec = (OpusDecodercxx . . $ OpusDecoder#*)ptr; |
| 473 | if (s < st->layoutcxx . . $ OpusMSDecoder#layout..nb_coupled_streamscxx . . $ ChannelLayout#nb_coupled_streams.) |
| 474 | ptr += aligncxx . . $ align(7864480464b09eea).(coupled_size); |
| 475 | else |
| 476 | ptr += aligncxx . . $ align(7864480464b09eea).(mono_size); |
| 477 | ret = opus_decoder_ctlcxx . . $ opus_decoder_ctl(f96ea19e1ec6253).(dec, OPUS_RESET_STATEcxx . . $ `external/opusfile/opus/opus_defines.h:662:9`!); |
| 478 | if (ret != OPUS_OKcxx . . $ `external/opusfile/opus/opus_defines.h:46:9`!) |
| 479 | break; |
| 480 | } |
| 481 | } |
| 482 | break; |
| 483 | case OPUS_MULTISTREAM_GET_DECODER_STATE_REQUESTcxx . . $ `external/opusfile/opus/opus_multistream.h:56:9`!: |
| 484 | { |
| 485 | int s; |
| 486 | opus_int32cxx . . $ opus_int32# stream_id; |
| 487 | OpusDecodercxx . . $ OpusDecoder# **value; |
| 488 | stream_id = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`!(ap, opus_int32); |
| 489 | if (stream_id<0 || stream_id >= st->layoutcxx . . $ OpusMSDecoder#layout..nb_streamscxx . . $ ChannelLayout#nb_streams.) |
| 490 | goto bad_arg; |
| 491 | value = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`!(ap, OpusDecoder**); |
| 492 | if (!value) |
| 493 | { |
| 494 | goto bad_arg; |
| 495 | } |
| 496 | for (s=0;s<stream_id;s++) |
| 497 | { |
| 498 | if (s < st->layoutcxx . . $ OpusMSDecoder#layout..nb_coupled_streamscxx . . $ ChannelLayout#nb_coupled_streams.) |
| 499 | ptr += aligncxx . . $ align(7864480464b09eea).(coupled_size); |
| 500 | else |
| 501 | ptr += aligncxx . . $ align(7864480464b09eea).(mono_size); |
| 502 | } |
| 503 | *value = (OpusDecodercxx . . $ OpusDecoder#*)ptr; |
| 504 | } |
| 505 | break; |
| 506 | case OPUS_SET_GAIN_REQUESTcxx . . $ `external/opusfile/opus/opus_defines.h:159:9`!: |
| 507 | case OPUS_SET_PHASE_INVERSION_DISABLED_REQUESTcxx . . $ `external/opusfile/opus/opus_defines.h:169:9`!: |
| 508 | { |
| 509 | int s; |
| 510 | /* This works for int32 params */ |
| 511 | opus_int32cxx . . $ opus_int32# value = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`!(ap, opus_int32); |
| 512 | for (s=0;s<st->layoutcxx . . $ OpusMSDecoder#layout..nb_streamscxx . . $ ChannelLayout#nb_streams.;s++) |
| 513 | { |
| 514 | OpusDecodercxx . . $ OpusDecoder# *dec; |
| 515 | |
| 516 | dec = (OpusDecodercxx . . $ OpusDecoder#*)ptr; |
| 517 | if (s < st->layoutcxx . . $ OpusMSDecoder#layout..nb_coupled_streamscxx . . $ ChannelLayout#nb_coupled_streams.) |
| 518 | ptr += aligncxx . . $ align(7864480464b09eea).(coupled_size); |
| 519 | else |
| 520 | ptr += aligncxx . . $ align(7864480464b09eea).(mono_size); |
| 521 | ret = opus_decoder_ctlcxx . . $ opus_decoder_ctl(f96ea19e1ec6253).(dec, request, value); |
| 522 | if (ret != OPUS_OKcxx . . $ `external/opusfile/opus/opus_defines.h:46:9`!) |
| 523 | break; |
| 524 | } |
| 525 | } |
| 526 | break; |
| 527 | default: |
| 528 | ret = OPUS_UNIMPLEMENTEDcxx . . $ `external/opusfile/opus/opus_defines.h:56:9`!; |
| 529 | break; |
| 530 | } |
| 531 | return ret; |
| 532 | bad_arg: |
| 533 | return OPUS_BAD_ARGcxx . . $ `external/opusfile/opus/opus_defines.h:48:9`!; |
| 534 | } |
| 535 | |
| 536 | int opus_multistream_decoder_ctlcxx . . $ opus_multistream_decoder_ctl(a38a95fcbae8cbdc).(OpusMSDecodercxx . . $ OpusMSDecoder# *st, int request, ...) |
| 537 | { |
| 538 | int ret; |
| 539 | va_listcxx . . $ va_list# ap; |
| 540 | va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(ap, request); |
| 541 | ret = opus_multistream_decoder_ctl_va_listcxx . . $ opus_multistream_decoder_ctl_va_list(d032d9922d7f399f).(st, request, ap); |
| 542 | va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(ap); |
| 543 | return ret; |
| 544 | } |
| 545 | |
| 546 | void opus_multistream_decoder_destroycxx . . $ opus_multistream_decoder_destroy(f2352feb5c6bddb9).(OpusMSDecodercxx . . $ OpusMSDecoder# *st) |
| 547 | { |
| 548 | opus_freecxx . . $ opus_free(5d22bdacc48458e8).(st); |
| 549 | } |