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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 ptrGarbage = &encoded[streamLenLB + 1 + streamLenUB]; | 708 ptrGarbage = &encoded[streamLenLB + 1 + streamLenUB]; |
709 limit = streamLen + (255 - encoded[streamLenLB]); | 709 limit = streamLen + (255 - encoded[streamLenLB]); |
710 } | 710 } |
711 minBytes = (minBytes > limit) ? limit : minBytes; | 711 minBytes = (minBytes > limit) ? limit : minBytes; |
712 | 712 |
713 garbageLen = (minBytes > streamLen) ? (uint8_t)(minBytes - streamLen) : 0; | 713 garbageLen = (minBytes > streamLen) ? (uint8_t)(minBytes - streamLen) : 0; |
714 | 714 |
715 /* Save data for creation of multiple bit-streams. */ | 715 /* Save data for creation of multiple bit-streams. */ |
716 /* If bit-stream too short then add garbage at the end. */ | 716 /* If bit-stream too short then add garbage at the end. */ |
717 if (garbageLen > 0) { | 717 if (garbageLen > 0) { |
718 for (k = 0; k < garbageLen; k++) { | 718 /* Overwrite the garbage area to avoid leaking possibly sensitive data |
719 ptrGarbage[k] = (uint8_t)(rand() & 0xFF); | 719 over the network. This also makes the output deterministic. */ |
720 } | 720 memset(ptrGarbage, 0, garbageLen); |
| 721 |
721 /* For a correct length of the upper-band bit-stream together | 722 /* For a correct length of the upper-band bit-stream together |
722 * with the garbage. Garbage is embeded in upper-band bit-stream. | 723 * with the garbage. Garbage is embeded in upper-band bit-stream. |
723 * That is the only way to preserve backward compatibility. */ | 724 * That is the only way to preserve backward compatibility. */ |
724 if ((instISAC->bandwidthKHz == isac8kHz) || | 725 if ((instISAC->bandwidthKHz == isac8kHz) || |
725 (streamLenUB == 0)) { | 726 (streamLenUB == 0)) { |
726 encoded[streamLenLB] = garbageLen; | 727 encoded[streamLenLB] = garbageLen; |
727 } else { | 728 } else { |
728 encoded[streamLenLB] += garbageLen; | 729 encoded[streamLenLB] += garbageLen; |
729 /* Write the length of the garbage at the end of the upper-band | 730 /* Write the length of the garbage at the end of the upper-band |
730 * bit-stream, if exists. This helps for sanity check. */ | 731 * bit-stream, if exists. This helps for sanity check. */ |
(...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2376 * - ISAC_main_inst : iSAC instance | 2377 * - ISAC_main_inst : iSAC instance |
2377 * | 2378 * |
2378 * Return value : sampling rate in Hertz. Decoder output is | 2379 * Return value : sampling rate in Hertz. Decoder output is |
2379 * sampled at this rate. | 2380 * sampled at this rate. |
2380 * | 2381 * |
2381 */ | 2382 */ |
2382 uint16_t WebRtcIsac_DecSampRate(ISACStruct* ISAC_main_inst) { | 2383 uint16_t WebRtcIsac_DecSampRate(ISACStruct* ISAC_main_inst) { |
2383 ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; | 2384 ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; |
2384 return instISAC->decoderSamplingRateKHz == kIsacWideband ? 16000 : 32000; | 2385 return instISAC->decoderSamplingRateKHz == kIsacWideband ? 16000 : 32000; |
2385 } | 2386 } |
OLD | NEW |