| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 /*----------------------------------------------------------------* | 41 /*----------------------------------------------------------------* |
| 42 * main encoder function | 42 * main encoder function |
| 43 *---------------------------------------------------------------*/ | 43 *---------------------------------------------------------------*/ |
| 44 | 44 |
| 45 void WebRtcIlbcfix_EncodeImpl( | 45 void WebRtcIlbcfix_EncodeImpl( |
| 46 uint16_t *bytes, /* (o) encoded data bits iLBC */ | 46 uint16_t *bytes, /* (o) encoded data bits iLBC */ |
| 47 const int16_t *block, /* (i) speech vector to encode */ | 47 const int16_t *block, /* (i) speech vector to encode */ |
| 48 IlbcEncoder *iLBCenc_inst /* (i/o) the general encoder | 48 IlbcEncoder *iLBCenc_inst /* (i/o) the general encoder |
| 49 state */ | 49 state */ |
| 50 ){ | 50 ){ |
| 51 int n, meml_gotten, Nfor; | 51 size_t n, meml_gotten, Nfor; |
| 52 int16_t diff, start_pos; | 52 size_t diff, start_pos; |
| 53 int index; | 53 size_t index; |
| 54 int subcount, subframe; | 54 size_t subcount, subframe; |
| 55 int16_t start_count, end_count; | 55 size_t start_count, end_count; |
| 56 int16_t *residual; | 56 int16_t *residual; |
| 57 int32_t en1, en2; | 57 int32_t en1, en2; |
| 58 int16_t scale, max; | 58 int16_t scale, max; |
| 59 int16_t *syntdenum; | 59 int16_t *syntdenum; |
| 60 int16_t *decresidual; | 60 int16_t *decresidual; |
| 61 int16_t *reverseResidual; | 61 int16_t *reverseResidual; |
| 62 int16_t *reverseDecresidual; | 62 int16_t *reverseDecresidual; |
| 63 /* Stack based */ | 63 /* Stack based */ |
| 64 int16_t weightdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; | 64 int16_t weightdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; |
| 65 int16_t dataVec[BLOCKL_MAX + LPC_FILTERORDER]; | 65 int16_t dataVec[BLOCKL_MAX + LPC_FILTERORDER]; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 /* Reuse som buffers to save stack memory */ | 79 /* Reuse som buffers to save stack memory */ |
| 80 residual = &iLBCenc_inst->lpc_buffer[LPC_LOOKBACK+BLOCKL_MAX-iLBCenc_inst->blo
ckl]; | 80 residual = &iLBCenc_inst->lpc_buffer[LPC_LOOKBACK+BLOCKL_MAX-iLBCenc_inst->blo
ckl]; |
| 81 syntdenum = mem; /* syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX] and mem are
used non overlapping in the code */ | 81 syntdenum = mem; /* syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX] and mem are
used non overlapping in the code */ |
| 82 decresidual = residual; /* Already encoded residual is overwritten by the
decoded version */ | 82 decresidual = residual; /* Already encoded residual is overwritten by the
decoded version */ |
| 83 reverseResidual = data; /* data and reverseResidual are used non overlappi
ng in the code */ | 83 reverseResidual = data; /* data and reverseResidual are used non overlappi
ng in the code */ |
| 84 reverseDecresidual = reverseResidual; /* Already encoded residual is overwritt
en by the decoded version */ | 84 reverseDecresidual = reverseResidual; /* Already encoded residual is overwritt
en by the decoded version */ |
| 85 | 85 |
| 86 #ifdef SPLIT_10MS | 86 #ifdef SPLIT_10MS |
| 87 | 87 |
| 88 WebRtcSpl_MemSetW16 ( (int16_t *) iLBCbits_inst, 0, | 88 WebRtcSpl_MemSetW16 ( (int16_t *) iLBCbits_inst, 0, |
| 89 (int16_t) (sizeof(iLBC_bits) / sizeof(int16_t)) ); | 89 sizeof(iLBC_bits) / sizeof(int16_t) ); |
| 90 | 90 |
| 91 start_pos = iLBCenc_inst->start_pos; | 91 start_pos = iLBCenc_inst->start_pos; |
| 92 diff = iLBCenc_inst->diff; | 92 diff = iLBCenc_inst->diff; |
| 93 | 93 |
| 94 if (iLBCenc_inst->section != 0){ | 94 if (iLBCenc_inst->section != 0){ |
| 95 WEBRTC_SPL_MEMCPY_W16 (weightdenum, weightdenumbuf, | 95 WEBRTC_SPL_MEMCPY_W16 (weightdenum, weightdenumbuf, |
| 96 SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); | 96 SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); |
| 97 /* Un-Packetize the frame into parameters */ | 97 /* Un-Packetize the frame into parameters */ |
| 98 last_bit = WebRtcIlbcfix_UnpackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLB
Cenc_inst->mode); | 98 last_bit = WebRtcIlbcfix_UnpackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLB
Cenc_inst->mode); |
| 99 if (last_bit) | 99 if (last_bit) |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 if (iLBCenc_inst->mode == 20) | 310 if (iLBCenc_inst->mode == 20) |
| 311 { | 311 { |
| 312 start_count = 0; | 312 start_count = 0; |
| 313 end_count = Nfor; | 313 end_count = Nfor; |
| 314 } | 314 } |
| 315 if (iLBCenc_inst->mode == 30) | 315 if (iLBCenc_inst->mode == 30) |
| 316 { | 316 { |
| 317 if (iLBCenc_inst->section == 1) | 317 if (iLBCenc_inst->section == 1) |
| 318 { | 318 { |
| 319 start_count = 0; | 319 start_count = 0; |
| 320 end_count = WEBRTC_SPL_MIN (Nfor, 2); | 320 end_count = WEBRTC_SPL_MIN (Nfor, ((size_t)2)); |
| 321 } | 321 } |
| 322 if (iLBCenc_inst->section == 2) | 322 if (iLBCenc_inst->section == 2) |
| 323 { | 323 { |
| 324 start_count = WEBRTC_SPL_MIN (Nfor, 2); | 324 start_count = WEBRTC_SPL_MIN (Nfor, ((size_t)2)); |
| 325 end_count = Nfor; | 325 end_count = Nfor; |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 #else | 328 #else |
| 329 start_count = 0; | 329 start_count = 0; |
| 330 end_count = (int16_t)Nfor; | 330 end_count = Nfor; |
| 331 #endif | 331 #endif |
| 332 | 332 |
| 333 /* loop over subframes to encode */ | 333 /* loop over subframes to encode */ |
| 334 | 334 |
| 335 for (subframe = start_count; subframe < end_count; subframe++){ | 335 for (subframe = start_count; subframe < end_count; subframe++){ |
| 336 | 336 |
| 337 /* encode subframe */ | 337 /* encode subframe */ |
| 338 | 338 |
| 339 WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index+subcount*CB_N
STAGES, | 339 WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index+subcount*CB_N
STAGES, |
| 340 iLBCbits_inst->gain_index+subcount*CB_NSTAGES, | 340 iLBCbits_inst->gain_index+subcount*CB_NSTAGES, |
| 341 &residual[(iLBCbits_inst->startIdx+1+subframe)*SUBL
], | 341 &residual[(iLBCbits_inst->startIdx+1+subframe)*SUBL
], |
| 342 mem, MEM_LF_TBL, SUBL, | 342 mem, MEM_LF_TBL, SUBL, |
| 343 &weightdenum[(iLBCbits_inst->startIdx+1+subframe)*(
LPC_FILTERORDER+1)], | 343 &weightdenum[(iLBCbits_inst->startIdx+1+subframe)*(
LPC_FILTERORDER+1)], |
| 344 (int16_t)subcount); | 344 subcount); |
| 345 | 345 |
| 346 /* construct decoded vector */ | 346 /* construct decoded vector */ |
| 347 | 347 |
| 348 WebRtcIlbcfix_CbConstruct(&decresidual[(iLBCbits_inst->startIdx+1+subframe
)*SUBL], | 348 WebRtcIlbcfix_CbConstruct(&decresidual[(iLBCbits_inst->startIdx+1+subframe
)*SUBL], |
| 349 iLBCbits_inst->cb_index+subcount*CB_NSTAGES, | 349 iLBCbits_inst->cb_index+subcount*CB_NSTAGES, |
| 350 iLBCbits_inst->gain_index+subcount*CB_NSTAGES, | 350 iLBCbits_inst->gain_index+subcount*CB_NSTAGES, |
| 351 mem, MEM_LF_TBL, | 351 mem, MEM_LF_TBL, |
| 352 SUBL | 352 SUBL |
| 353 ); | 353 ); |
| 354 | 354 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 379 | 379 |
| 380 /* backward prediction of subframes */ | 380 /* backward prediction of subframes */ |
| 381 | 381 |
| 382 if (iLBCbits_inst->startIdx > 1) { | 382 if (iLBCbits_inst->startIdx > 1) { |
| 383 | 383 |
| 384 /* create reverse order vectors | 384 /* create reverse order vectors |
| 385 (The decresidual does not need to be copied since it is | 385 (The decresidual does not need to be copied since it is |
| 386 contained in the same vector as the residual) | 386 contained in the same vector as the residual) |
| 387 */ | 387 */ |
| 388 | 388 |
| 389 int Nback = iLBCbits_inst->startIdx - 1; | 389 size_t Nback = iLBCbits_inst->startIdx - 1; |
| 390 WebRtcSpl_MemCpyReversedOrder(&reverseResidual[Nback*SUBL-1], residual, Nbac
k*SUBL); | 390 WebRtcSpl_MemCpyReversedOrder(&reverseResidual[Nback*SUBL-1], residual, Nbac
k*SUBL); |
| 391 | 391 |
| 392 /* setup memory */ | 392 /* setup memory */ |
| 393 | 393 |
| 394 meml_gotten = SUBL*(iLBCenc_inst->nsub+1-iLBCbits_inst->startIdx); | 394 meml_gotten = SUBL*(iLBCenc_inst->nsub+1-iLBCbits_inst->startIdx); |
| 395 if( meml_gotten > CB_MEML ) { | 395 if( meml_gotten > CB_MEML ) { |
| 396 meml_gotten=CB_MEML; | 396 meml_gotten=CB_MEML; |
| 397 } | 397 } |
| 398 | 398 |
| 399 WebRtcSpl_MemCpyReversedOrder(&mem[CB_MEML-1], &decresidual[Nback*SUBL], mem
l_gotten); | 399 WebRtcSpl_MemCpyReversedOrder(&mem[CB_MEML-1], &decresidual[Nback*SUBL], mem
l_gotten); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 427 end_count = (Nfor >= 2) ? 0 : (2 - NFor); | 427 end_count = (Nfor >= 2) ? 0 : (2 - NFor); |
| 428 } | 428 } |
| 429 if (iLBCenc_inst->section == 2) | 429 if (iLBCenc_inst->section == 2) |
| 430 { | 430 { |
| 431 start_count = (Nfor >= 2) ? 0 : (2 - NFor); | 431 start_count = (Nfor >= 2) ? 0 : (2 - NFor); |
| 432 end_count = Nback; | 432 end_count = Nback; |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 #else | 435 #else |
| 436 start_count = 0; | 436 start_count = 0; |
| 437 end_count = (int16_t)Nback; | 437 end_count = Nback; |
| 438 #endif | 438 #endif |
| 439 | 439 |
| 440 /* loop over subframes to encode */ | 440 /* loop over subframes to encode */ |
| 441 | 441 |
| 442 for (subframe = start_count; subframe < end_count; subframe++){ | 442 for (subframe = start_count; subframe < end_count; subframe++){ |
| 443 | 443 |
| 444 /* encode subframe */ | 444 /* encode subframe */ |
| 445 | 445 |
| 446 WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index+subcount*CB_N
STAGES, | 446 WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index+subcount*CB_N
STAGES, |
| 447 iLBCbits_inst->gain_index+subcount*CB_NSTAGES, &rev
erseResidual[subframe*SUBL], | 447 iLBCbits_inst->gain_index+subcount*CB_NSTAGES, &rev
erseResidual[subframe*SUBL], |
| 448 mem, MEM_LF_TBL, SUBL, | 448 mem, MEM_LF_TBL, SUBL, |
| 449 &weightdenum[(iLBCbits_inst->startIdx-2-subframe)*(
LPC_FILTERORDER+1)], | 449 &weightdenum[(iLBCbits_inst->startIdx-2-subframe)*(
LPC_FILTERORDER+1)], |
| 450 (int16_t)subcount); | 450 subcount); |
| 451 | 451 |
| 452 /* construct decoded vector */ | 452 /* construct decoded vector */ |
| 453 | 453 |
| 454 WebRtcIlbcfix_CbConstruct(&reverseDecresidual[subframe*SUBL], | 454 WebRtcIlbcfix_CbConstruct(&reverseDecresidual[subframe*SUBL], |
| 455 iLBCbits_inst->cb_index+subcount*CB_NSTAGES, | 455 iLBCbits_inst->cb_index+subcount*CB_NSTAGES, |
| 456 iLBCbits_inst->gain_index+subcount*CB_NSTAGES, | 456 iLBCbits_inst->gain_index+subcount*CB_NSTAGES, |
| 457 mem, MEM_LF_TBL, SUBL | 457 mem, MEM_LF_TBL, SUBL |
| 458 ); | 458 ); |
| 459 | 459 |
| 460 /* update memory */ | 460 /* update memory */ |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 } | 509 } |
| 510 else | 510 else |
| 511 { | 511 { |
| 512 iLBCenc_inst->section++; | 512 iLBCenc_inst->section++; |
| 513 WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, | 513 WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, |
| 514 SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); | 514 SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); |
| 515 } | 515 } |
| 516 #endif | 516 #endif |
| 517 | 517 |
| 518 } | 518 } |
| OLD | NEW |