| 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 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 size_t size, | 45 size_t size, |
| 46 vpx_decrypt_cb decrypt_cb, | 46 vpx_decrypt_cb decrypt_cb, |
| 47 void *decrypt_state); | 47 void *decrypt_state); |
| 48 | 48 |
| 49 void vp9_reader_fill(vp9_reader *r); | 49 void vp9_reader_fill(vp9_reader *r); |
| 50 | 50 |
| 51 int vp9_reader_has_error(vp9_reader *r); | 51 int vp9_reader_has_error(vp9_reader *r); |
| 52 | 52 |
| 53 const uint8_t *vp9_reader_find_end(vp9_reader *r); | 53 const uint8_t *vp9_reader_find_end(vp9_reader *r); |
| 54 | 54 |
| 55 static int vp9_read(vp9_reader *r, int prob) { | 55 static INLINE int vp9_read(vp9_reader *r, int prob) { |
| 56 unsigned int bit = 0; | 56 unsigned int bit = 0; |
| 57 BD_VALUE value; | 57 BD_VALUE value; |
| 58 BD_VALUE bigsplit; | 58 BD_VALUE bigsplit; |
| 59 int count; | 59 int count; |
| 60 unsigned int range; | 60 unsigned int range; |
| 61 unsigned int split = (r->range * prob + (256 - prob)) >> CHAR_BIT; | 61 unsigned int split = (r->range * prob + (256 - prob)) >> CHAR_BIT; |
| 62 | 62 |
| 63 if (r->count < 0) | 63 if (r->count < 0) |
| 64 vp9_reader_fill(r); | 64 vp9_reader_fill(r); |
| 65 | 65 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 82 value <<= shift; | 82 value <<= shift; |
| 83 count -= shift; | 83 count -= shift; |
| 84 } | 84 } |
| 85 r->value = value; | 85 r->value = value; |
| 86 r->count = count; | 86 r->count = count; |
| 87 r->range = range; | 87 r->range = range; |
| 88 | 88 |
| 89 return bit; | 89 return bit; |
| 90 } | 90 } |
| 91 | 91 |
| 92 static int vp9_read_bit(vp9_reader *r) { | 92 static INLINE int vp9_read_bit(vp9_reader *r) { |
| 93 return vp9_read(r, 128); // vp9_prob_half | 93 return vp9_read(r, 128); // vp9_prob_half |
| 94 } | 94 } |
| 95 | 95 |
| 96 static int vp9_read_literal(vp9_reader *r, int bits) { | 96 static INLINE int vp9_read_literal(vp9_reader *r, int bits) { |
| 97 int literal = 0, bit; | 97 int literal = 0, bit; |
| 98 | 98 |
| 99 for (bit = bits - 1; bit >= 0; bit--) | 99 for (bit = bits - 1; bit >= 0; bit--) |
| 100 literal |= vp9_read_bit(r) << bit; | 100 literal |= vp9_read_bit(r) << bit; |
| 101 | 101 |
| 102 return literal; | 102 return literal; |
| 103 } | 103 } |
| 104 | 104 |
| 105 static int vp9_read_tree(vp9_reader *r, const vp9_tree_index *tree, | 105 static INLINE int vp9_read_tree(vp9_reader *r, const vp9_tree_index *tree, |
| 106 const vp9_prob *probs) { | 106 const vp9_prob *probs) { |
| 107 vp9_tree_index i = 0; | 107 vp9_tree_index i = 0; |
| 108 | 108 |
| 109 while ((i = tree[i + vp9_read(r, probs[i >> 1])]) > 0) | 109 while ((i = tree[i + vp9_read(r, probs[i >> 1])]) > 0) |
| 110 continue; | 110 continue; |
| 111 | 111 |
| 112 return -i; | 112 return -i; |
| 113 } | 113 } |
| 114 | 114 |
| 115 #ifdef __cplusplus | 115 #ifdef __cplusplus |
| 116 } // extern "C" | 116 } // extern "C" |
| 117 #endif | 117 #endif |
| 118 | 118 |
| 119 #endif // VP9_DECODER_VP9_READER_H_ | 119 #endif // VP9_DECODER_VP9_READER_H_ |
| OLD | NEW |