| 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 | |
| 34 | /* Find least-squares prediction gain for one signal based on another and quantize it */ |
| 35 | opus_int32cxx . . $ opus_int32# silk_stereo_find_predictorcxx . . $ silk_stereo_find_predictor(e2681b1f7efbe9b8).( /* O Returns predictor in Q13 */ |
| 36 | opus_int32cxx . . $ opus_int32# *ratio_Q14, /* O Ratio of residual and mid energies */ |
| 37 | const opus_int16cxx . . $ opus_int16# x[], /* I Basis signal */ |
| 38 | const opus_int16cxx . . $ opus_int16# y[], /* I Target signal */ |
| 39 | opus_int32cxx . . $ opus_int32# mid_res_amp_Q0[], /* I/O Smoothed mid, residual norms */ |
| 40 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! length, /* I Number of samples */ |
| 41 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! smooth_coef_Q16 /* I Smoothing coefficient */ |
| 42 | ) |
| 43 | { |
| 44 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! scale, scale1, scale2; |
| 45 | opus_int32cxx . . $ opus_int32# nrgx, nrgy, corr, pred_Q13, pred2_Q10; |
| 46 | |
| 47 | /* Find predictor */ |
| 48 | silk_sum_sqr_shiftcxx . . $ silk_sum_sqr_shift(98426d2fcb017784).( &nrgx, &scale1, x, length ); |
| 49 | silk_sum_sqr_shiftcxx . . $ silk_sum_sqr_shift(98426d2fcb017784).( &nrgy, &scale2, y, length ); |
| 50 | scale = silk_max_intcxx . . $ silk_max_int(9b79fb6aee4c0440).( scale1, scale2 ); |
| 51 | scale = scale + ( scale & 1 ); /* make even */ |
| 52 | nrgy = silk_RSHIFT32cxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:509:9`!( nrgy, scale - scale2 ); |
| 53 | nrgx = silk_RSHIFT32cxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:509:9`!( nrgx, scale - scale1 ); |
| 54 | nrgx = silk_max_intcxx . . $ silk_max_int(9b79fb6aee4c0440).( nrgx, 1 ); |
| 55 | corr = silk_inner_prod_aligned_scalecxx . . $ silk_inner_prod_aligned_scale(29e14252b8d2a269).( x, y, scale, length ); |
| 56 | pred_Q13 = silk_DIV32_varQcxx . . $ silk_DIV32_varQ(2326284602b0bb2d).( corr, nrgx, 13 ); |
| 57 | pred_Q13 = silk_LIMITcxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:581:9`!( pred_Q13, -(1 << 14), 1 << 14 ); |
| 58 | pred2_Q10 = silk_SMULWBcxx . . $ `external/opusfile/opus/silk/macros.h:43:9`!( pred_Q13, pred_Q13 ); |
| 59 | |
| 60 | /* Faster update for signals with large prediction parameters */ |
| 61 | smooth_coef_Q16 = (opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`!)silk_max_intcxx . . $ silk_max_int(9b79fb6aee4c0440).( smooth_coef_Q16, silk_abscxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:588:9`!( pred2_Q10 ) ); |
| 62 | |
| 63 | /* Smoothed mid and residual norms */ |
| 64 | silk_assertcxx . . $ `external/opusfile/opus/silk/typedef.h:74:11`!( smooth_coef_Q16 < 32768 ); |
| 65 | scale = silk_RSHIFTcxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:511:9`!( scale, 1 ); |
| 66 | mid_res_amp_Q0[ 0 ] = silk_SMLAWBcxx . . $ `external/opusfile/opus/silk/macros.h:50:9`!( mid_res_amp_Q0[ 0 ], silk_LSHIFTcxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:505:9`!( silk_SQRT_APPROX( nrgx ), scale ) - mid_res_amp_Q0[ 0 ], |
| 67 | smooth_coef_Q16 ); |
| 68 | /* Residual energy = nrgy - 2 * pred * corr + pred^2 * nrgx */ |
| 69 | nrgy = silk_SUB_LSHIFT32cxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:527:9`!( nrgy, silk_SMULWBcxx . . $ `external/opusfile/opus/silk/macros.h:43:9`!( corr, pred_Q13 ), 3 + 1 ); |
| 70 | nrgy = silk_ADD_LSHIFT32cxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:522:9`!( nrgy, silk_SMULWBcxx . . $ `external/opusfile/opus/silk/macros.h:43:9`!( nrgx, pred2_Q10 ), 6 ); |
| 71 | mid_res_amp_Q0[ 1 ] = silk_SMLAWBcxx . . $ `external/opusfile/opus/silk/macros.h:50:9`!( mid_res_amp_Q0[ 1 ], silk_LSHIFTcxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:505:9`!( silk_SQRT_APPROX( nrgy ), scale ) - mid_res_amp_Q0[ 1 ], |
| 72 | smooth_coef_Q16 ); |
| 73 | |
| 74 | /* Ratio of smoothed residual and mid norms */ |
| 75 | *ratio_Q14 = silk_DIV32_varQcxx . . $ silk_DIV32_varQ(2326284602b0bb2d).( mid_res_amp_Q0[ 1 ], silk_maxcxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:540:9`!( mid_res_amp_Q0[ 0 ], 1 ), 14 ); |
| 76 | *ratio_Q14 = silk_LIMITcxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:581:9`!( *ratio_Q14, 0, 32767 ); |
| 77 | |
| 78 | return pred_Q13; |
| 79 | } |