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

Side by Side Diff: silk/enc_API.c

Issue 107243004: Updating Opus to release 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « silk/dec_API.c ('k') | silk/encode_pulses.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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 *encSizeBytes = sizeof( silk_encoder ); 62 *encSizeBytes = sizeof( silk_encoder );
63 63
64 return ret; 64 return ret;
65 } 65 }
66 66
67 /*************************/ 67 /*************************/
68 /* Init or Reset encoder */ 68 /* Init or Reset encoder */
69 /*************************/ 69 /*************************/
70 opus_int silk_InitEncoder( /* O Returns error co de */ 70 opus_int silk_InitEncoder( /* O Returns error co de */
71 void *encState, /* I/O State */ 71 void *encState, /* I/O State */
72 int arch, /* I Run-time archite cture */
72 silk_EncControlStruct *encStatus /* O Encoder Status */ 73 silk_EncControlStruct *encStatus /* O Encoder Status */
73 ) 74 )
74 { 75 {
75 silk_encoder *psEnc; 76 silk_encoder *psEnc;
76 opus_int n, ret = SILK_NO_ERROR; 77 opus_int n, ret = SILK_NO_ERROR;
77 78
78 psEnc = (silk_encoder *)encState; 79 psEnc = (silk_encoder *)encState;
79 80
80 /* Reset encoder */ 81 /* Reset encoder */
81 silk_memset( psEnc, 0, sizeof( silk_encoder ) ); 82 silk_memset( psEnc, 0, sizeof( silk_encoder ) );
82 for( n = 0; n < ENCODER_NUM_CHANNELS; n++ ) { 83 for( n = 0; n < ENCODER_NUM_CHANNELS; n++ ) {
83 if( ret += silk_init_encoder( &psEnc->state_Fxx[ n ] ) ) { 84 if( ret += silk_init_encoder( &psEnc->state_Fxx[ n ], arch ) ) {
84 silk_assert( 0 ); 85 silk_assert( 0 );
85 } 86 }
86 } 87 }
87 88
88 psEnc->nChannelsAPI = 1; 89 psEnc->nChannelsAPI = 1;
89 psEnc->nChannelsInternal = 1; 90 psEnc->nChannelsInternal = 1;
90 91
91 /* Read control structure */ 92 /* Read control structure */
92 if( ret += silk_QueryEncoder( encState, encStatus ) ) { 93 if( ret += silk_QueryEncoder( encState, encStatus ) ) {
93 silk_assert( 0 ); 94 silk_assert( 0 );
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 opus_int n, i, nBits, flags, tmp_payloadSize_ms = 0, tmp_complexity = 0, r et = 0; 150 opus_int n, i, nBits, flags, tmp_payloadSize_ms = 0, tmp_complexity = 0, r et = 0;
150 opus_int nSamplesToBuffer, nSamplesToBufferMax, nBlocksOf10ms; 151 opus_int nSamplesToBuffer, nSamplesToBufferMax, nBlocksOf10ms;
151 opus_int nSamplesFromInput = 0, nSamplesFromInputMax; 152 opus_int nSamplesFromInput = 0, nSamplesFromInputMax;
152 opus_int speech_act_thr_for_switch_Q8; 153 opus_int speech_act_thr_for_switch_Q8;
153 opus_int32 TargetRate_bps, MStargetRates_bps[ 2 ], channelRate_bps, LBRR_sym bol, sum; 154 opus_int32 TargetRate_bps, MStargetRates_bps[ 2 ], channelRate_bps, LBRR_sym bol, sum;
154 silk_encoder *psEnc = ( silk_encoder * )encState; 155 silk_encoder *psEnc = ( silk_encoder * )encState;
155 VARDECL( opus_int16, buf ); 156 VARDECL( opus_int16, buf );
156 opus_int transition, curr_block, tot_blocks; 157 opus_int transition, curr_block, tot_blocks;
157 SAVE_STACK; 158 SAVE_STACK;
158 159
160 if (encControl->reducedDependency)
161 {
162 psEnc->state_Fxx[0].sCmn.first_frame_after_reset = 1;
163 psEnc->state_Fxx[1].sCmn.first_frame_after_reset = 1;
164 }
159 psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded = psEnc->state_Fxx[ 1 ].sCmn.nFram esEncoded = 0; 165 psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded = psEnc->state_Fxx[ 1 ].sCmn.nFram esEncoded = 0;
160 166
161 /* Check values in encoder control structure */ 167 /* Check values in encoder control structure */
162 if( ( ret = check_control_input( encControl ) != 0 ) ) { 168 if( ( ret = check_control_input( encControl ) != 0 ) ) {
163 silk_assert( 0 ); 169 silk_assert( 0 );
164 RESTORE_STACK; 170 RESTORE_STACK;
165 return ret; 171 return ret;
166 } 172 }
167 173
168 encControl->switchReady = 0; 174 encControl->switchReady = 0;
169 175
170 if( encControl->nChannelsInternal > psEnc->nChannelsInternal ) { 176 if( encControl->nChannelsInternal > psEnc->nChannelsInternal ) {
171 /* Mono -> Stereo transition: init state of second channel and stereo st ate */ 177 /* Mono -> Stereo transition: init state of second channel and stereo st ate */
172 ret += silk_init_encoder( &psEnc->state_Fxx[ 1 ] ); 178 ret += silk_init_encoder( &psEnc->state_Fxx[ 1 ], psEnc->state_Fxx[ 0 ]. sCmn.arch );
173 silk_memset( psEnc->sStereo.pred_prev_Q13, 0, sizeof( psEnc->sStereo.pre d_prev_Q13 ) ); 179 silk_memset( psEnc->sStereo.pred_prev_Q13, 0, sizeof( psEnc->sStereo.pre d_prev_Q13 ) );
174 silk_memset( psEnc->sStereo.sSide, 0, sizeof( psEnc->sStereo.sSide ) ); 180 silk_memset( psEnc->sStereo.sSide, 0, sizeof( psEnc->sStereo.sSide ) );
175 psEnc->sStereo.mid_side_amp_Q0[ 0 ] = 0; 181 psEnc->sStereo.mid_side_amp_Q0[ 0 ] = 0;
176 psEnc->sStereo.mid_side_amp_Q0[ 1 ] = 1; 182 psEnc->sStereo.mid_side_amp_Q0[ 1 ] = 1;
177 psEnc->sStereo.mid_side_amp_Q0[ 2 ] = 0; 183 psEnc->sStereo.mid_side_amp_Q0[ 2 ] = 0;
178 psEnc->sStereo.mid_side_amp_Q0[ 3 ] = 1; 184 psEnc->sStereo.mid_side_amp_Q0[ 3 ] = 1;
179 psEnc->sStereo.width_prev_Q14 = 0; 185 psEnc->sStereo.width_prev_Q14 = 0;
180 psEnc->sStereo.smth_width_Q14 = SILK_FIX_CONST( 1, 14 ); 186 psEnc->sStereo.smth_width_Q14 = SILK_FIX_CONST( 1, 14 );
181 if( psEnc->nChannelsAPI == 2 ) { 187 if( psEnc->nChannelsAPI == 2 ) {
182 silk_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->st ate_Fxx[ 0 ].sCmn.resampler_state, sizeof( silk_resampler_state_struct ) ); 188 silk_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->st ate_Fxx[ 0 ].sCmn.resampler_state, sizeof( silk_resampler_state_struct ) );
(...skipping 11 matching lines...) Expand all
194 curr_block = 0; 200 curr_block = 0;
195 if( prefillFlag ) { 201 if( prefillFlag ) {
196 /* Only accept input length of 10 ms */ 202 /* Only accept input length of 10 ms */
197 if( nBlocksOf10ms != 1 ) { 203 if( nBlocksOf10ms != 1 ) {
198 silk_assert( 0 ); 204 silk_assert( 0 );
199 RESTORE_STACK; 205 RESTORE_STACK;
200 return SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; 206 return SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;
201 } 207 }
202 /* Reset Encoder */ 208 /* Reset Encoder */
203 for( n = 0; n < encControl->nChannelsInternal; n++ ) { 209 for( n = 0; n < encControl->nChannelsInternal; n++ ) {
204 if( (ret = silk_init_encoder( &psEnc->state_Fxx[ n ] ) ) != 0 ) { 210 ret = silk_init_encoder( &psEnc->state_Fxx[ n ], psEnc->state_Fxx[ n ].sCmn.arch );
205 silk_assert( 0 ); 211 silk_assert( !ret );
206 }
207 } 212 }
208 tmp_payloadSize_ms = encControl->payloadSize_ms; 213 tmp_payloadSize_ms = encControl->payloadSize_ms;
209 encControl->payloadSize_ms = 10; 214 encControl->payloadSize_ms = 10;
210 tmp_complexity = encControl->complexity; 215 tmp_complexity = encControl->complexity;
211 encControl->complexity = 0; 216 encControl->complexity = 0;
212 for( n = 0; n < encControl->nChannelsInternal; n++ ) { 217 for( n = 0; n < encControl->nChannelsInternal; n++ ) {
213 psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; 218 psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0;
214 psEnc->state_Fxx[ n ].sCmn.prefillFlag = 1; 219 psEnc->state_Fxx[ n ].sCmn.prefillFlag = 1;
215 } 220 }
216 } else { 221 } else {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 for( n = 0; n < encControl->nChannelsInternal; n++ ) { 547 for( n = 0; n < encControl->nChannelsInternal; n++ ) {
543 psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; 548 psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0;
544 psEnc->state_Fxx[ n ].sCmn.prefillFlag = 0; 549 psEnc->state_Fxx[ n ].sCmn.prefillFlag = 0;
545 } 550 }
546 } 551 }
547 552
548 RESTORE_STACK; 553 RESTORE_STACK;
549 return ret; 554 return ret;
550 } 555 }
551 556
OLDNEW
« no previous file with comments | « silk/dec_API.c ('k') | silk/encode_pulses.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698