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 #ifndef AOM_AOM_DSP_BITREADER_BUFFER_H_ 13 #define AOM_AOM_DSP_BITREADER_BUFFER_H_ 14 15 #include <limits.h> 16 17 #include "aom/aom_integer.h" 18 #include "config/aom_config.h" 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 typedef void (*aom_rb_error_handler)(void *data); 25 26 struct aom_read_bit_buffer { 27 const uint8_t *bit_buffer; 28 const uint8_t *bit_buffer_end; 29 uint32_t bit_offset; 30 31 void *error_handler_data; 32 aom_rb_error_handler error_handler; 33 }; 34 35 size_t aom_rb_bytes_read(const struct aom_read_bit_buffer *rb); 36 37 int aom_rb_read_bit(struct aom_read_bit_buffer *rb); 38 39 int aom_rb_read_literal(struct aom_read_bit_buffer *rb, int bits); 40 41 uint32_t aom_rb_read_uvlc(struct aom_read_bit_buffer *rb); 42 43 #if CONFIG_AV1_DECODER 44 uint32_t aom_rb_read_unsigned_literal(struct aom_read_bit_buffer *rb, int bits); 45 46 int aom_rb_read_inv_signed_literal(struct aom_read_bit_buffer *rb, int bits); 47 48 int16_t aom_rb_read_signed_primitive_refsubexpfin( 49 struct aom_read_bit_buffer *rb, uint16_t n, uint16_t k, int16_t ref); 50 #endif // CONFIG_AV1_DECODER 51 52 #ifdef __cplusplus 53 } // extern "C" 54 #endif 55 56 #endif // AOM_AOM_DSP_BITREADER_BUFFER_H_ 57