| 1 | /*********************************************************************** |
| 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
| 3 | Redistribution and use in source and binary forms, with or without |
| 4 | modification, are permitted provided that the following conditions |
| 5 | are met: |
| 6 | - Redistributions of source code must retain the above copyright notice, |
| 7 | this list of conditions and the following disclaimer. |
| 8 | - Redistributions in binary form must reproduce the above copyright |
| 9 | notice, this list of conditions and the following disclaimer in the |
| 10 | documentation and/or other materials provided with the distribution. |
| 11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the |
| 12 | names of specific contributors, may be used to endorse or promote |
| 13 | products derived from this software without specific prior written |
| 14 | permission. |
| 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 | 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 "main.h"cxx . . $ `<file>/external/opusfile/opus/silk/main.h`/ |
| 33 | #include "stack_alloc.h"cxx . . $ `<file>/external/opusfile/opus/celt/stack_alloc.h`/ |
| 34 | #include "PLC.h"cxx . . $ `<file>/external/opusfile/opus/silk/PLC.h`/ |
| 35 | |
| 36 | /****************/ |
| 37 | /* Decode frame */ |
| 38 | /****************/ |
| 39 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! silk_decode_framecxx . . $ silk_decode_frame(cefb5b6d44164d9c).( |
| 40 | silk_decoder_statecxx . . $ silk_decoder_state# *psDec, /* I/O Pointer to Silk decoder state */ |
| 41 | ec_deccxx . . $ ec_dec# *psRangeDec, /* I/O Compressor data structure */ |
| 42 | opus_int16cxx . . $ opus_int16# pOut[], /* O Pointer to output speech frame */ |
| 43 | opus_int32cxx . . $ opus_int32# *pN, /* O Pointer to size of output frame */ |
| 44 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ |
| 45 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! condCoding, /* I The type of conditional coding to use */ |
| 46 | int arch /* I Run-time architecture */ |
| 47 | ) |
| 48 | { |
| 49 | VARDECLcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:94:9`!( silk_decoder_control, psDecCtrl ); |
| 50 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! L, mv_len, ret = 0; |
| 51 | SAVE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:96:9`!; |
| 52 | |
| 53 | L = psDec->frame_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_10#frame_length.; |
| 54 | ALLOCcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:95:9`!( psDecCtrl, 1, silk_decoder_control ); |
| 55 | psDecCtrl->LTP_scale_Q14cxx . . $ $anonymous_type_c9846ade8c67dd67_11#LTP_scale_Q14. = 0; |
| 56 | |
| 57 | /* Safety checks */ |
| 58 | celt_assertcxx . . $ `external/opusfile/opus/celt/arch.h:80:9`!( L > 0 && L <= MAX_FRAME_LENGTHcxx . . $ `external/opusfile/opus/silk/define.h:97:9`! ); |
| 59 | |
| 60 | if( lostFlag == FLAG_DECODE_NORMALcxx . . $ `external/opusfile/opus/silk/control.h:39:9`! || |
| 61 | ( lostFlag == FLAG_DECODE_LBRRcxx . . $ `external/opusfile/opus/silk/control.h:41:9`! && psDec->LBRR_flagscxx . . $ $anonymous_type_c9846ade8c67dd67_10#LBRR_flags.[ psDec->nFramesDecodedcxx . . $ $anonymous_type_c9846ade8c67dd67_10#nFramesDecoded. ] == 1 ) ) |
| 62 | { |
| 63 | VARDECLcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:94:9`!( opus_int16, pulses ); |
| 64 | ALLOCcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:95:9`!( pulses, (L + SHELL_CODEC_FRAME_LENGTHcxx . . $ `external/opusfile/opus/silk/define.h:168:9`! - 1) & |
| 65 | ~(SHELL_CODEC_FRAME_LENGTHcxx . . $ `external/opusfile/opus/silk/define.h:168:9`! - 1), opus_int16 ); |
| 66 | /*********************************************/ |
| 67 | /* Decode quantization indices of side info */ |
| 68 | /*********************************************/ |
| 69 | silk_decode_indicescxx . . $ silk_decode_indices(9b8b62953f1146f3).( psDec, psRangeDec, psDec->nFramesDecodedcxx . . $ $anonymous_type_c9846ade8c67dd67_10#nFramesDecoded., lostFlag, condCoding ); |
| 70 | |
| 71 | /*********************************************/ |
| 72 | /* Decode quantization indices of excitation */ |
| 73 | /*********************************************/ |
| 74 | silk_decode_pulsescxx . . $ silk_decode_pulses(2cc810bc97bf43df).( psRangeDec, pulses, psDec->indicescxx . . $ $anonymous_type_c9846ade8c67dd67_10#indices..signalTypecxx . . $ $anonymous_type_c9846ade8c67dd67_6#signalType., |
| 75 | psDec->indicescxx . . $ $anonymous_type_c9846ade8c67dd67_10#indices..quantOffsetTypecxx . . $ $anonymous_type_c9846ade8c67dd67_6#quantOffsetType., psDec->frame_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_10#frame_length. ); |
| 76 | |
| 77 | /********************************************/ |
| 78 | /* Decode parameters and pulse signal */ |
| 79 | /********************************************/ |
| 80 | silk_decode_parameterscxx . . $ silk_decode_parameters(34334dd9f9bfd38c).( psDec, psDecCtrl, condCoding ); |
| 81 | |
| 82 | /********************************************************/ |
| 83 | /* Run inverse NSQ */ |
| 84 | /********************************************************/ |
| 85 | silk_decode_corecxx . . $ silk_decode_core(9cfceb12ad7136d6).( psDec, psDecCtrl, pOut, pulses, arch ); |
| 86 | |
| 87 | /********************************************************/ |
| 88 | /* Update PLC state */ |
| 89 | /********************************************************/ |
| 90 | silk_PLCcxx . . $ silk_PLC(c3b96a4ab8009228).( psDec, psDecCtrl, pOut, 0, arch ); |
| 91 | |
| 92 | psDec->lossCntcxx . . $ $anonymous_type_c9846ade8c67dd67_10#lossCnt. = 0; |
| 93 | psDec->prevSignalTypecxx . . $ $anonymous_type_c9846ade8c67dd67_10#prevSignalType. = psDec->indicescxx . . $ $anonymous_type_c9846ade8c67dd67_10#indices..signalTypecxx . . $ $anonymous_type_c9846ade8c67dd67_6#signalType.; |
| 94 | celt_assertcxx . . $ `external/opusfile/opus/celt/arch.h:80:9`!( psDec->prevSignalType >= 0 && psDec->prevSignalType <= 2 ); |
| 95 | |
| 96 | /* A frame has been decoded without errors */ |
| 97 | psDec->first_frame_after_resetcxx . . $ $anonymous_type_c9846ade8c67dd67_10#first_frame_after_reset. = 0; |
| 98 | } else { |
| 99 | /* Handle packet loss by extrapolation */ |
| 100 | psDec->indicescxx . . $ $anonymous_type_c9846ade8c67dd67_10#indices..signalTypecxx . . $ $anonymous_type_c9846ade8c67dd67_6#signalType. = psDec->prevSignalTypecxx . . $ $anonymous_type_c9846ade8c67dd67_10#prevSignalType.; |
| 101 | silk_PLCcxx . . $ silk_PLC(c3b96a4ab8009228).( psDec, psDecCtrl, pOut, 1, arch ); |
| 102 | } |
| 103 | |
| 104 | /*************************/ |
| 105 | /* Update output buffer. */ |
| 106 | /*************************/ |
| 107 | celt_assertcxx . . $ `external/opusfile/opus/celt/arch.h:80:9`!( psDec->ltp_mem_length >= psDec->frame_length ); |
| 108 | mv_len = psDec->ltp_mem_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_10#ltp_mem_length. - psDec->frame_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_10#frame_length.; |
| 109 | silk_memmovecxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:422:9`!( psDec->outBuf, &psDec->outBuf[ psDec->frame_length ], mv_len * sizeof(opus_int16) ); |
| 110 | silk_memcpycxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:420:9`!( &psDec->outBuf[ mv_len ], pOut, psDec->frame_length * sizeof( opus_int16 ) ); |
| 111 | |
| 112 | /************************************************/ |
| 113 | /* Comfort noise generation / estimation */ |
| 114 | /************************************************/ |
| 115 | silk_CNGcxx . . $ silk_CNG(3e85da5896dfe775).( psDec, psDecCtrl, pOut, L ); |
| 116 | |
| 117 | /****************************************************************/ |
| 118 | /* Ensure smooth connection of extrapolated and good frames */ |
| 119 | /****************************************************************/ |
| 120 | silk_PLC_glue_framescxx . . $ silk_PLC_glue_frames(aa4c92c1b43506b0).( psDec, pOut, L ); |
| 121 | |
| 122 | /* Update some decoder state variables */ |
| 123 | psDec->lagPrevcxx . . $ $anonymous_type_c9846ade8c67dd67_10#lagPrev. = psDecCtrl->pitchLcxx . . $ $anonymous_type_c9846ade8c67dd67_11#pitchL.[ psDec->nb_subfrcxx . . $ $anonymous_type_c9846ade8c67dd67_10#nb_subfr. - 1 ]; |
| 124 | |
| 125 | /* Set output frame length */ |
| 126 | *pN = L; |
| 127 | |
| 128 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 129 | return ret; |
| 130 | } |