digiKam
bitstream.h
Go to the documentation of this file.
1 /*
2  * H.265 video codec.
3  * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
4  *
5  * This file is part of libde265.
6  *
7  * libde265 is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * libde265 is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with libde265. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef DE265_BITSTREAM_H
22 #define DE265_BITSTREAM_H
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 #include <stdio.h>
29 #ifdef HAVE_STDBOOL_H
30 #include <stdbool.h>
31 #endif
32 #include <stdint.h>
33 
34 
35 #define MAX_UVLC_LEADING_ZEROS 20
36 #define UVLC_ERROR -99999
37 
38 
39 typedef struct {
40  uint8_t* data;
42 
43  uint64_t nextbits; // left-aligned bits
45 } bitreader;
46 
47 void bitreader_init(bitreader*, unsigned char* buffer, int len);
48 void bitreader_refill(bitreader*); // refill to at least 56+1 bits
51 int get_bits(bitreader*, int n);
52 int get_bits_fast(bitreader*, int n);
53 int peek_bits(bitreader*, int n);
54 void skip_bits(bitreader*, int n);
55 void skip_bits_fast(bitreader*, int n);
58 int get_uvlc(bitreader*); // may return UVLC_ERROR
59 int get_svlc(bitreader*); // may return UVLC_ERROR
60 
61 bool check_rbsp_trailing_bits(bitreader*); // return true if remaining filler bits are all zero
62 
63 #endif
void bitreader_refill(bitreader *)
void skip_bits(bitreader *, int n)
void skip_bits_fast(bitreader *, int n)
int get_uvlc(bitreader *)
void bitreader_init(bitreader *, unsigned char *buffer, int len)
int peek_bits(bitreader *, int n)
int get_bits(bitreader *, int n)
bool check_rbsp_trailing_bits(bitreader *)
int next_bit(bitreader *)
void skip_to_byte_boundary(bitreader *)
int next_bit_norefill(bitreader *)
int get_bits_fast(bitreader *, int n)
void prepare_for_CABAC(bitreader *)
int get_svlc(bitreader *)
Definition: bitstream.h:39
uint8_t * data
Definition: bitstream.h:40
int bytes_remaining
Definition: bitstream.h:41
uint64_t nextbits
Definition: bitstream.h:43
int nextbits_cnt
Definition: bitstream.h:44