forked from i-rinat/libvdpau-va-gl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bitstream.h
62 lines (47 loc) · 1.68 KB
/
bitstream.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright 2013 Rinat Ibragimov
*
* This file is part of libvdpau-va-gl
*
* libvdpau-va-gl distributed under the terms of LGPLv3. See COPYING for details.
*/
#ifndef __BITSTREAM_H
#define __BITSTREAM_H
#include <unistd.h>
#include <stdint.h>
/** @brief State of raw byte stream payload comsumer */
typedef struct _rbsp_state_struct {
const uint8_t *buf_ptr; ///< pointer to beginning of the buffer
size_t byte_count; ///< size of buffer
const uint8_t *cur_ptr; ///< pointer to currently processed byte
int bit_ptr; ///< pointer to currently processed bit
int zeros_in_row; ///< number of consequetive zero bytes so far
int bits_eaten; ///< bit offset of current position not including EPB
} rbsp_state_t;
/** @brief Initialize rbsp state
*
* @param [out] state
* @param [in] buf pointer to byte string
* @param [in] byte_count number of bytes in @param buf
*
* @retval void
*/
void rbsp_attach_buffer(rbsp_state_t *state, const uint8_t *buf, size_t byte_count);
/** @brief Consumes and returns one byte from rbsp
*
* This function handles emulation prevention bytes internally, without their
* exposure to caller. Returns value of successfully consumed byte.
*/
int rbsp_consume_byte(rbsp_state_t *state);
rbsp_state_t rbsp_copy_state(rbsp_state_t *state);
int rbsp_navigate_to_nal_unit(rbsp_state_t *state);
void rbsp_reset_bit_counter(rbsp_state_t *state);
int
rbsp_consume_bit(rbsp_state_t *state);
unsigned int
rbsp_get_u(rbsp_state_t *state, int bitcount);
unsigned int
rbsp_get_uev(rbsp_state_t *state);
int
rbsp_get_sev(rbsp_state_t *state);
#endif