Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: silk/NLSF_del_dec_quant.c

Issue 882843002: Update to opus-HEAD-66611f1. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/opus.git@master
Patch Set: Add the contents of Makefile.mips back. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « silk/LPC_analysis_filter.c ('k') | silk/NSQ.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*********************************************************************** 1 /***********************************************************************
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 Redistribution and use in source and binary forms, with or without 3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions 4 modification, are permitted provided that the following conditions
5 are met: 5 are met:
6 - Redistributions of source code must retain the above copyright notice, 6 - Redistributions of source code must retain the above copyright notice,
7 this list of conditions and the following disclaimer. 7 this list of conditions and the following disclaimer.
8 - Redistributions in binary form must reproduce the above copyright 8 - Redistributions in binary form must reproduce the above copyright
9 notice, this list of conditions and the following disclaimer in the 9 notice, this list of conditions and the following disclaimer in the
10 documentation and/or other materials provided with the distribution. 10 documentation and/or other materials provided with the distribution.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 opus_int pred_Q10, diff_Q10, out0_Q10, out1_Q10, rate0_Q5, rate1_Q5; 49 opus_int pred_Q10, diff_Q10, out0_Q10, out1_Q10, rate0_Q5, rate1_Q5;
50 opus_int32 RD_tmp_Q25, min_Q25, min_max_Q25, max_min_Q25, pred_coef_Q1 6; 50 opus_int32 RD_tmp_Q25, min_Q25, min_max_Q25, max_min_Q25, pred_coef_Q1 6;
51 opus_int ind_sort[ NLSF_QUANT_DEL_DEC_STATES ]; 51 opus_int ind_sort[ NLSF_QUANT_DEL_DEC_STATES ];
52 opus_int8 ind[ NLSF_QUANT_DEL_DEC_STATES ][ MAX_LPC_ORDE R ]; 52 opus_int8 ind[ NLSF_QUANT_DEL_DEC_STATES ][ MAX_LPC_ORDE R ];
53 opus_int16 prev_out_Q10[ 2 * NLSF_QUANT_DEL_DEC_STATES ]; 53 opus_int16 prev_out_Q10[ 2 * NLSF_QUANT_DEL_DEC_STATES ];
54 opus_int32 RD_Q25[ 2 * NLSF_QUANT_DEL_DEC_STATES ]; 54 opus_int32 RD_Q25[ 2 * NLSF_QUANT_DEL_DEC_STATES ];
55 opus_int32 RD_min_Q25[ NLSF_QUANT_DEL_DEC_STATES ]; 55 opus_int32 RD_min_Q25[ NLSF_QUANT_DEL_DEC_STATES ];
56 opus_int32 RD_max_Q25[ NLSF_QUANT_DEL_DEC_STATES ]; 56 opus_int32 RD_max_Q25[ NLSF_QUANT_DEL_DEC_STATES ];
57 const opus_uint8 *rates_Q5; 57 const opus_uint8 *rates_Q5;
58 58
59 opus_int out0_Q10_table[2 * NLSF_QUANT_MAX_AMPLITUDE_EXT];
60 opus_int out1_Q10_table[2 * NLSF_QUANT_MAX_AMPLITUDE_EXT];
61
62 for (i = -NLSF_QUANT_MAX_AMPLITUDE_EXT; i <= NLSF_QUANT_MAX_AMPLITUDE_EXT-1; i++)
63 {
64 out0_Q10 = silk_LSHIFT( i, 10 );
65 out1_Q10 = silk_ADD16( out0_Q10, 1024 );
66 if( i > 0 ) {
67 out0_Q10 = silk_SUB16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_AD J, 10 ) );
68 out1_Q10 = silk_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_AD J, 10 ) );
69 } else if( i == 0 ) {
70 out1_Q10 = silk_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_AD J, 10 ) );
71 } else if( i == -1 ) {
72 out0_Q10 = silk_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_AD J, 10 ) );
73 } else {
74 out0_Q10 = silk_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_AD J, 10 ) );
75 out1_Q10 = silk_ADD16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_AD J, 10 ) );
76 }
77 out0_Q10_table[ i + NLSF_QUANT_MAX_AMPLITUDE_EXT ] = silk_SMULWB( (opus_ int32)out0_Q10, quant_step_size_Q16 );
78 out1_Q10_table[ i + NLSF_QUANT_MAX_AMPLITUDE_EXT ] = silk_SMULWB( (opus_ int32)out1_Q10, quant_step_size_Q16 );
79 }
80
59 silk_assert( (NLSF_QUANT_DEL_DEC_STATES & (NLSF_QUANT_DEL_DEC_STATES-1)) == 0 ); /* must be power of two */ 81 silk_assert( (NLSF_QUANT_DEL_DEC_STATES & (NLSF_QUANT_DEL_DEC_STATES-1)) == 0 ); /* must be power of two */
60 82
61 nStates = 1; 83 nStates = 1;
62 RD_Q25[ 0 ] = 0; 84 RD_Q25[ 0 ] = 0;
63 prev_out_Q10[ 0 ] = 0; 85 prev_out_Q10[ 0 ] = 0;
64 for( i = order - 1; ; i-- ) { 86 for( i = order - 1; ; i-- ) {
65 rates_Q5 = &ec_rates_Q5[ ec_ix[ i ] ]; 87 rates_Q5 = &ec_rates_Q5[ ec_ix[ i ] ];
66 pred_coef_Q16 = silk_LSHIFT( (opus_int32)pred_coef_Q8[ i ], 8 ); 88 pred_coef_Q16 = silk_LSHIFT( (opus_int32)pred_coef_Q8[ i ], 8 );
67 in_Q10 = x_Q10[ i ]; 89 in_Q10 = x_Q10[ i ];
68 for( j = 0; j < nStates; j++ ) { 90 for( j = 0; j < nStates; j++ ) {
69 pred_Q10 = silk_SMULWB( pred_coef_Q16, prev_out_Q10[ j ] ); 91 pred_Q10 = silk_SMULWB( pred_coef_Q16, prev_out_Q10[ j ] );
70 res_Q10 = silk_SUB16( in_Q10, pred_Q10 ); 92 res_Q10 = silk_SUB16( in_Q10, pred_Q10 );
71 ind_tmp = silk_SMULWB( (opus_int32)inv_quant_step_size_Q6, res_Q10 ); 93 ind_tmp = silk_SMULWB( (opus_int32)inv_quant_step_size_Q6, res_Q10 );
72 ind_tmp = silk_LIMIT( ind_tmp, -NLSF_QUANT_MAX_AMPLITUDE_EXT, NLSF_ QUANT_MAX_AMPLITUDE_EXT-1 ); 94 ind_tmp = silk_LIMIT( ind_tmp, -NLSF_QUANT_MAX_AMPLITUDE_EXT, NLSF_ QUANT_MAX_AMPLITUDE_EXT-1 );
73 ind[ j ][ i ] = (opus_int8)ind_tmp; 95 ind[ j ][ i ] = (opus_int8)ind_tmp;
74 96
75 /* compute outputs for ind_tmp and ind_tmp + 1 */ 97 /* compute outputs for ind_tmp and ind_tmp + 1 */
76 out0_Q10 = silk_LSHIFT( ind_tmp, 10 ); 98 out0_Q10 = out0_Q10_table[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE_EXT ];
77 out1_Q10 = silk_ADD16( out0_Q10, 1024 ); 99 out1_Q10 = out1_Q10_table[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE_EXT ];
78 if( ind_tmp > 0 ) { 100
79 out0_Q10 = silk_SUB16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVE L_ADJ, 10 ) );
80 out1_Q10 = silk_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVE L_ADJ, 10 ) );
81 } else if( ind_tmp == 0 ) {
82 out1_Q10 = silk_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVE L_ADJ, 10 ) );
83 } else if( ind_tmp == -1 ) {
84 out0_Q10 = silk_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVE L_ADJ, 10 ) );
85 } else {
86 out0_Q10 = silk_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVE L_ADJ, 10 ) );
87 out1_Q10 = silk_ADD16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVE L_ADJ, 10 ) );
88 }
89 out0_Q10 = silk_SMULWB( (opus_int32)out0_Q10, quant_step_size_Q16 ) ;
90 out1_Q10 = silk_SMULWB( (opus_int32)out1_Q10, quant_step_size_Q16 ) ;
91 out0_Q10 = silk_ADD16( out0_Q10, pred_Q10 ); 101 out0_Q10 = silk_ADD16( out0_Q10, pred_Q10 );
92 out1_Q10 = silk_ADD16( out1_Q10, pred_Q10 ); 102 out1_Q10 = silk_ADD16( out1_Q10, pred_Q10 );
93 prev_out_Q10[ j ] = out0_Q10; 103 prev_out_Q10[ j ] = out0_Q10;
94 prev_out_Q10[ j + nStates ] = out1_Q10; 104 prev_out_Q10[ j + nStates ] = out1_Q10;
95 105
96 /* compute RD for ind_tmp and ind_tmp + 1 */ 106 /* compute RD for ind_tmp and ind_tmp + 1 */
97 if( ind_tmp + 1 >= NLSF_QUANT_MAX_AMPLITUDE ) { 107 if( ind_tmp + 1 >= NLSF_QUANT_MAX_AMPLITUDE ) {
98 if( ind_tmp + 1 == NLSF_QUANT_MAX_AMPLITUDE ) { 108 if( ind_tmp + 1 == NLSF_QUANT_MAX_AMPLITUDE ) {
99 rate0_Q5 = rates_Q5[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE ]; 109 rate0_Q5 = rates_Q5[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE ];
100 rate1_Q5 = 280; 110 rate1_Q5 = 280;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 for( j = 0; j < order; j++ ) { 208 for( j = 0; j < order; j++ ) {
199 indices[ j ] = ind[ ind_tmp & ( NLSF_QUANT_DEL_DEC_STATES - 1 ) ][ j ]; 209 indices[ j ] = ind[ ind_tmp & ( NLSF_QUANT_DEL_DEC_STATES - 1 ) ][ j ];
200 silk_assert( indices[ j ] >= -NLSF_QUANT_MAX_AMPLITUDE_EXT ); 210 silk_assert( indices[ j ] >= -NLSF_QUANT_MAX_AMPLITUDE_EXT );
201 silk_assert( indices[ j ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT ); 211 silk_assert( indices[ j ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT );
202 } 212 }
203 indices[ 0 ] += silk_RSHIFT( ind_tmp, NLSF_QUANT_DEL_DEC_STATES_LOG2 ); 213 indices[ 0 ] += silk_RSHIFT( ind_tmp, NLSF_QUANT_DEL_DEC_STATES_LOG2 );
204 silk_assert( indices[ 0 ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT ); 214 silk_assert( indices[ 0 ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT );
205 silk_assert( min_Q25 >= 0 ); 215 silk_assert( min_Q25 >= 0 );
206 return min_Q25; 216 return min_Q25;
207 } 217 }
OLDNEW
« no previous file with comments | « silk/LPC_analysis_filter.c ('k') | silk/NSQ.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698