Chromium Code Reviews| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 const uint8_t *stream_ptr; | 183 const uint8_t *stream_ptr; |
| 184 uint32_t cdf_tmp; | 184 uint32_t cdf_tmp; |
| 185 int16_t candQ7; | 185 int16_t candQ7; |
| 186 int k; | 186 int k; |
| 187 | 187 |
| 188 stream_ptr = streamdata->stream + streamdata->stream_index; | 188 stream_ptr = streamdata->stream + streamdata->stream_index; |
| 189 W_upper = streamdata->W_upper; | 189 W_upper = streamdata->W_upper; |
| 190 if (streamdata->stream_index == 0) /* first time decoder is called for this stream */ | 190 if (streamdata->stream_index == 0) /* first time decoder is called for this stream */ |
| 191 { | 191 { |
| 192 /* read first word from bytestream */ | 192 /* read first word from bytestream */ |
| 193 if (stream_ptr + 3 - streamdata->stream >= STREAM_SIZE_MAX_60) | |
|
hlundin-webrtc
2016/02/23 13:16:10
Please, comment on why you use STREAM_SIZE_MAX_60
kwiberg-webrtc
2016/02/23 13:48:02
I extracted a named constant. Pretty?
| |
| 194 return -1; // Would read out of bounds. Malformed input? | |
| 193 streamval = *stream_ptr << 24; | 195 streamval = *stream_ptr << 24; |
| 194 streamval |= *++stream_ptr << 16; | 196 streamval |= *++stream_ptr << 16; |
| 195 streamval |= *++stream_ptr << 8; | 197 streamval |= *++stream_ptr << 8; |
| 196 streamval |= *++stream_ptr; | 198 streamval |= *++stream_ptr; |
| 197 } else { | 199 } else { |
| 198 streamval = streamdata->streamval; | 200 streamval = streamdata->streamval; |
| 199 } | 201 } |
| 200 | 202 |
| 201 | 203 |
| 202 for (k = 0; k < N; k++) | 204 for (k = 0; k < N; k++) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 /* shift interval to start at zero */ | 272 /* shift interval to start at zero */ |
| 271 W_upper -= ++W_lower; | 273 W_upper -= ++W_lower; |
| 272 | 274 |
| 273 /* add integer to bitstream */ | 275 /* add integer to bitstream */ |
| 274 streamval -= W_lower; | 276 streamval -= W_lower; |
| 275 | 277 |
| 276 /* renormalize interval and update streamval */ | 278 /* renormalize interval and update streamval */ |
| 277 while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */ | 279 while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */ |
| 278 { | 280 { |
| 279 /* read next byte from stream */ | 281 /* read next byte from stream */ |
| 282 if (stream_ptr + 1 - streamdata->stream >= STREAM_SIZE_MAX_60) | |
|
hlundin-webrtc
2016/02/23 13:16:10
and here.
| |
| 283 return -1; // Would read out of bounds. Malformed input? | |
| 280 streamval = (streamval << 8) | *++stream_ptr; | 284 streamval = (streamval << 8) | *++stream_ptr; |
| 281 W_upper <<= 8; | 285 W_upper <<= 8; |
| 282 } | 286 } |
| 283 } | 287 } |
| 284 | 288 |
| 285 streamdata->stream_index = (int)(stream_ptr - streamdata->stream); | 289 streamdata->stream_index = (int)(stream_ptr - streamdata->stream); |
| 286 streamdata->W_upper = W_upper; | 290 streamdata->W_upper = W_upper; |
| 287 streamdata->streamval = streamval; | 291 streamdata->streamval = streamval; |
| 288 | 292 |
| 289 /* find number of bytes in original stream (determined by current interval wid th) */ | 293 /* find number of bytes in original stream (determined by current interval wid th) */ |
| 290 if ( W_upper > 0x01FFFFFF ) | 294 if ( W_upper > 0x01FFFFFF ) |
| 291 return streamdata->stream_index - 2; | 295 return streamdata->stream_index - 2; |
| 292 else | 296 else |
| 293 return streamdata->stream_index - 1; | 297 return streamdata->stream_index - 1; |
| 294 } | 298 } |
| OLD | NEW |