blob: 22187357e0b6be52acbf574eb78995ff5f478cf2 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * 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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AOM_DSP_BITREADER_BUFFER_H_
13#define AOM_DSP_BITREADER_BUFFER_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#include <limits.h>
16
Yaowu Xuf883b422016-08-30 14:01:10 -070017#include "aom/aom_integer.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070018
19#ifdef __cplusplus
20extern "C" {
21#endif
22
Yaowu Xuf883b422016-08-30 14:01:10 -070023typedef void (*aom_rb_error_handler)(void *data);
Yaowu Xuc27fc142016-08-22 16:08:15 -070024
Yaowu Xuf883b422016-08-30 14:01:10 -070025struct aom_read_bit_buffer {
Yaowu Xuc27fc142016-08-22 16:08:15 -070026 const uint8_t *bit_buffer;
27 const uint8_t *bit_buffer_end;
James Zern71a37de2017-04-20 16:03:13 -070028 uint32_t bit_offset;
Yaowu Xuc27fc142016-08-22 16:08:15 -070029
30 void *error_handler_data;
Yaowu Xuf883b422016-08-30 14:01:10 -070031 aom_rb_error_handler error_handler;
Yaowu Xuc27fc142016-08-22 16:08:15 -070032};
33
Yaowu Xuf883b422016-08-30 14:01:10 -070034size_t aom_rb_bytes_read(struct aom_read_bit_buffer *rb);
Yaowu Xuc27fc142016-08-22 16:08:15 -070035
Yaowu Xuf883b422016-08-30 14:01:10 -070036int aom_rb_read_bit(struct aom_read_bit_buffer *rb);
Yaowu Xuc27fc142016-08-22 16:08:15 -070037
Yaowu Xuf883b422016-08-30 14:01:10 -070038int aom_rb_read_literal(struct aom_read_bit_buffer *rb, int bits);
Yaowu Xuc27fc142016-08-22 16:08:15 -070039
Yaowu Xuf883b422016-08-30 14:01:10 -070040int aom_rb_read_signed_literal(struct aom_read_bit_buffer *rb, int bits);
Yaowu Xuc27fc142016-08-22 16:08:15 -070041
Yaowu Xuf883b422016-08-30 14:01:10 -070042int aom_rb_read_inv_signed_literal(struct aom_read_bit_buffer *rb, int bits);
Yaowu Xuc27fc142016-08-22 16:08:15 -070043
44#ifdef __cplusplus
45} // extern "C"
46#endif
47
Yaowu Xuf883b422016-08-30 14:01:10 -070048#endif // AOM_DSP_BITREADER_BUFFER_H_