/src/mozilla-central/third_party/aom/aom_dsp/daalaboolreader.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
3 | | * |
4 | | * This source code is subject to the terms of the BSD 2 Clause License and |
5 | | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
6 | | * was not distributed with this source code in the LICENSE file, you can |
7 | | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
8 | | * Media Patent License 1.0 was not distributed with this source code in the |
9 | | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
10 | | */ |
11 | | |
12 | | #include "aom_dsp/daalaboolreader.h" |
13 | | |
14 | 0 | int aom_daala_reader_init(daala_reader *r, const uint8_t *buffer, int size) { |
15 | 0 | if (size && !buffer) { |
16 | 0 | return 1; |
17 | 0 | } |
18 | 0 | r->buffer_end = buffer + size; |
19 | 0 | r->buffer = buffer; |
20 | 0 | od_ec_dec_init(&r->ec, buffer, size); |
21 | | #if CONFIG_ACCOUNTING |
22 | | r->accounting = NULL; |
23 | | #endif |
24 | | return 0; |
25 | 0 | } |
26 | | |
27 | 0 | const uint8_t *aom_daala_reader_find_begin(daala_reader *r) { |
28 | 0 | return r->buffer; |
29 | 0 | } |
30 | | |
31 | 0 | const uint8_t *aom_daala_reader_find_end(daala_reader *r) { |
32 | 0 | return r->buffer_end; |
33 | 0 | } |
34 | | |
35 | 0 | uint32_t aom_daala_reader_tell(const daala_reader *r) { |
36 | 0 | return od_ec_dec_tell(&r->ec); |
37 | 0 | } |
38 | | |
39 | 0 | uint32_t aom_daala_reader_tell_frac(const daala_reader *r) { |
40 | 0 | return od_ec_dec_tell_frac(&r->ec); |
41 | 0 | } |
42 | | |
43 | 0 | int aom_daala_reader_has_overflowed(const daala_reader *r) { |
44 | 0 | const uint32_t tell_bits = aom_daala_reader_tell(r); |
45 | 0 | const uint32_t tell_bytes = (tell_bits + 7) >> 3; |
46 | 0 | return ((ptrdiff_t)tell_bytes > r->buffer_end - r->buffer); |
47 | 0 | } |