OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM 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 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 30 matching lines...) Expand all Loading... |
41 const uint8_t *const buffer_end = r->buffer_end; | 41 const uint8_t *const buffer_end = r->buffer_end; |
42 const uint8_t *buffer = r->buffer; | 42 const uint8_t *buffer = r->buffer; |
43 const uint8_t *buffer_start = buffer; | 43 const uint8_t *buffer_start = buffer; |
44 BD_VALUE value = r->value; | 44 BD_VALUE value = r->value; |
45 int count = r->count; | 45 int count = r->count; |
46 const size_t bytes_left = buffer_end - buffer; | 46 const size_t bytes_left = buffer_end - buffer; |
47 const size_t bits_left = bytes_left * CHAR_BIT; | 47 const size_t bits_left = bytes_left * CHAR_BIT; |
48 int shift = BD_VALUE_SIZE - CHAR_BIT - (count + CHAR_BIT); | 48 int shift = BD_VALUE_SIZE - CHAR_BIT - (count + CHAR_BIT); |
49 | 49 |
50 if (r->decrypt_cb) { | 50 if (r->decrypt_cb) { |
51 size_t n = MIN(sizeof(r->clear_buffer), bytes_left); | 51 size_t n = VPXMIN(sizeof(r->clear_buffer), bytes_left); |
52 r->decrypt_cb(r->decrypt_state, buffer, r->clear_buffer, (int)n); | 52 r->decrypt_cb(r->decrypt_state, buffer, r->clear_buffer, (int)n); |
53 buffer = r->clear_buffer; | 53 buffer = r->clear_buffer; |
54 buffer_start = r->clear_buffer; | 54 buffer_start = r->clear_buffer; |
55 } | 55 } |
56 if (bits_left > BD_VALUE_SIZE) { | 56 if (bits_left > BD_VALUE_SIZE) { |
57 const int bits = (shift & 0xfffffff8) + CHAR_BIT; | 57 const int bits = (shift & 0xfffffff8) + CHAR_BIT; |
58 BD_VALUE nv; | 58 BD_VALUE nv; |
59 BD_VALUE big_endian_values; | 59 BD_VALUE big_endian_values; |
60 memcpy(&big_endian_values, buffer, sizeof(BD_VALUE)); | 60 memcpy(&big_endian_values, buffer, sizeof(BD_VALUE)); |
61 #if SIZE_MAX == 0xffffffffffffffffULL | 61 #if SIZE_MAX == 0xffffffffffffffffULL |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 | 94 |
95 const uint8_t *vpx_reader_find_end(vpx_reader *r) { | 95 const uint8_t *vpx_reader_find_end(vpx_reader *r) { |
96 // Find the end of the coded buffer | 96 // Find the end of the coded buffer |
97 while (r->count > CHAR_BIT && r->count < BD_VALUE_SIZE) { | 97 while (r->count > CHAR_BIT && r->count < BD_VALUE_SIZE) { |
98 r->count -= CHAR_BIT; | 98 r->count -= CHAR_BIT; |
99 r->buffer--; | 99 r->buffer--; |
100 } | 100 } |
101 return r->buffer; | 101 return r->buffer; |
102 } | 102 } |
OLD | NEW |