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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 * - bitstream : payload bitstream | 73 * - bitstream : payload bitstream |
74 * - len_bitstream_in_bytes : number of 8-bit words in the bit stream | 74 * - len_bitstream_in_bytes : number of 8-bit words in the bit stream |
75 * | 75 * |
76 * Output: | 76 * Output: |
77 * - crc : checksum | 77 * - crc : checksum |
78 * | 78 * |
79 * Return value : 0 - Ok | 79 * Return value : 0 - Ok |
80 * -1 - Error | 80 * -1 - Error |
81 */ | 81 */ |
82 | 82 |
83 int16_t WebRtcIsac_GetCrc(const int16_t* bitstream, | 83 int WebRtcIsac_GetCrc(const int16_t* bitstream, |
84 int16_t len_bitstream_in_bytes, | 84 int len_bitstream_in_bytes, |
85 uint32_t* crc) | 85 uint32_t* crc) |
86 { | 86 { |
87 uint8_t* bitstream_ptr_uw8; | 87 uint8_t* bitstream_ptr_uw8; |
88 uint32_t crc_state; | 88 uint32_t crc_state; |
89 int byte_cntr; | 89 int byte_cntr; |
90 int crc_tbl_indx; | 90 int crc_tbl_indx; |
91 | 91 |
92 /* Sanity Check. */ | 92 /* Sanity Check. */ |
93 if (bitstream == NULL) { | 93 if (bitstream == NULL) { |
94 return -1; | 94 return -1; |
95 } | 95 } |
96 /* cast to UWord8 pointer */ | 96 /* cast to UWord8 pointer */ |
97 bitstream_ptr_uw8 = (uint8_t *)bitstream; | 97 bitstream_ptr_uw8 = (uint8_t *)bitstream; |
98 | 98 |
99 /* initialize */ | 99 /* initialize */ |
100 crc_state = 0xFFFFFFFF; | 100 crc_state = 0xFFFFFFFF; |
101 | 101 |
102 for (byte_cntr = 0; byte_cntr < len_bitstream_in_bytes; byte_cntr++) { | 102 for (byte_cntr = 0; byte_cntr < len_bitstream_in_bytes; byte_cntr++) { |
103 crc_tbl_indx = (WEBRTC_SPL_RSHIFT_U32(crc_state, 24) ^ | 103 crc_tbl_indx = (WEBRTC_SPL_RSHIFT_U32(crc_state, 24) ^ |
104 bitstream_ptr_uw8[byte_cntr]) & 0xFF; | 104 bitstream_ptr_uw8[byte_cntr]) & 0xFF; |
105 crc_state = (crc_state << 8) ^ kCrcTable[crc_tbl_indx]; | 105 crc_state = (crc_state << 8) ^ kCrcTable[crc_tbl_indx]; |
106 } | 106 } |
107 | 107 |
108 *crc = ~crc_state; | 108 *crc = ~crc_state; |
109 return 0; | 109 return 0; |
110 } | 110 } |
OLD | NEW |