OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 int16_t dither1_Q7, dither2_Q7, dither_gain_Q14, shft; | 385 int16_t dither1_Q7, dither2_Q7, dither_gain_Q14, shft; |
386 | 386 |
387 if (AvgPitchGain_Q12 < 614) /* this threshold should be equal to that in deco de_spec() */ | 387 if (AvgPitchGain_Q12 < 614) /* this threshold should be equal to that in deco de_spec() */ |
388 { | 388 { |
389 for (k = 0; k < length-2; k += 3) | 389 for (k = 0; k < length-2; k += 3) |
390 { | 390 { |
391 /* new random unsigned int32_t */ | 391 /* new random unsigned int32_t */ |
392 seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515; | 392 seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515; |
393 | 393 |
394 /* fixed-point dither sample between -64 and 64 (Q7) */ | 394 /* fixed-point dither sample between -64 and 64 (Q7) */ |
395 dither1_Q7 = (int16_t)(((int32_t)seed + 16777216) >> 25); | 395 dither1_Q7 = (int16_t)(((int32_t)(seed + 16777216)) >> 25); |
396 | 396 |
397 /* new random unsigned int32_t */ | 397 /* new random unsigned int32_t */ |
398 seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515; | 398 seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515; |
399 | 399 |
400 /* fixed-point dither sample between -64 and 64 */ | 400 /* fixed-point dither sample between -64 and 64 */ |
401 dither2_Q7 = (int16_t)((seed + 16777216) >> 25); | 401 dither2_Q7 = (int16_t)(((int32_t)(seed + 16777216)) >> 25); |
kwiberg-webrtc
2016/02/25 11:57:00
Here, I'm actually changing the behavior. The old
tlegrand-webrtc
2016/02/26 10:21:40
I think this changes should be fine.
| |
402 | 402 |
403 shft = (int16_t)(WEBRTC_SPL_RSHIFT_U32(seed, 25) & 15); | 403 shft = (int16_t)(WEBRTC_SPL_RSHIFT_U32(seed, 25) & 15); |
404 if (shft < 5) | 404 if (shft < 5) |
405 { | 405 { |
406 bufQ7[k] = dither1_Q7; | 406 bufQ7[k] = dither1_Q7; |
407 bufQ7[k+1] = dither2_Q7; | 407 bufQ7[k+1] = dither2_Q7; |
408 bufQ7[k+2] = 0; | 408 bufQ7[k+2] = 0; |
409 } | 409 } |
410 else if (shft < 10) | 410 else if (shft < 10) |
411 { | 411 { |
(...skipping 13 matching lines...) Expand all Loading... | |
425 { | 425 { |
426 dither_gain_Q14 = (int16_t)(22528 - WEBRTC_SPL_MUL(10, AvgPitchGain_Q12)); | 426 dither_gain_Q14 = (int16_t)(22528 - WEBRTC_SPL_MUL(10, AvgPitchGain_Q12)); |
427 | 427 |
428 /* dither on half of the coefficients */ | 428 /* dither on half of the coefficients */ |
429 for (k = 0; k < length-1; k += 2) | 429 for (k = 0; k < length-1; k += 2) |
430 { | 430 { |
431 /* new random unsigned int32_t */ | 431 /* new random unsigned int32_t */ |
432 seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515; | 432 seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515; |
433 | 433 |
434 /* fixed-point dither sample between -64 and 64 */ | 434 /* fixed-point dither sample between -64 and 64 */ |
435 dither1_Q7 = (int16_t)(((int32_t)seed + 16777216) >> 25); | 435 dither1_Q7 = (int16_t)(((int32_t)(seed + 16777216)) >> 25); |
436 | 436 |
437 /* dither sample is placed in either even or odd index */ | 437 /* dither sample is placed in either even or odd index */ |
438 shft = (int16_t)(WEBRTC_SPL_RSHIFT_U32(seed, 25) & 1); /* either 0 or 1 */ | 438 shft = (int16_t)(WEBRTC_SPL_RSHIFT_U32(seed, 25) & 1); /* either 0 or 1 */ |
439 | 439 |
440 bufQ7[k + shft] = (int16_t)((dither_gain_Q14 * dither1_Q7 + 8192) >> 14); | 440 bufQ7[k + shft] = (int16_t)((dither_gain_Q14 * dither1_Q7 + 8192) >> 14); |
441 bufQ7[k + 1 - shft] = 0; | 441 bufQ7[k + 1 - shft] = 0; |
442 } | 442 } |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2025 | 2025 |
2026 index_gQQ[k] = pos2QQ + WebRtcIsacfix_kQuantMinGain[k]; //ATTN: ok? | 2026 index_gQQ[k] = pos2QQ + WebRtcIsacfix_kQuantMinGain[k]; //ATTN: ok? |
2027 if (index_gQQ[k] < 0) { | 2027 if (index_gQQ[k] < 0) { |
2028 index_gQQ[k] = 0; | 2028 index_gQQ[k] = 0; |
2029 } | 2029 } |
2030 else if (index_gQQ[k] > WebRtcIsacfix_kMaxIndGain[k]) { | 2030 else if (index_gQQ[k] > WebRtcIsacfix_kMaxIndGain[k]) { |
2031 index_gQQ[k] = WebRtcIsacfix_kMaxIndGain[k]; | 2031 index_gQQ[k] = WebRtcIsacfix_kMaxIndGain[k]; |
2032 } | 2032 } |
2033 } | 2033 } |
2034 } | 2034 } |
OLD | NEW |