blob: 2cfc1e52d8f9c36d13c330e1eae09968a3020dd9 (
plain)
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
|
/*
* Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Optional.h>
#include <AK/Types.h>
namespace Video::VP9 {
class BitStream {
public:
BitStream(const u8* data, size_t size)
: m_data_ptr(data)
, m_bytes_remaining(size)
{
}
u8 read_byte();
bool read_bit();
u8 read_f(size_t n);
i8 read_s(size_t n);
u8 read_f8();
u16 read_f16();
u8 read_literal(size_t n);
u64 get_position();
size_t bytes_remaining();
size_t bits_remaining();
bool init_bool(size_t bytes);
bool read_bool(u8 probability);
bool exit_bool();
private:
const u8* m_data_ptr { nullptr };
size_t m_bytes_remaining { 0 };
Optional<u8> m_current_byte;
i8 m_current_bit_position { 0 };
u64 m_bytes_read { 0 };
u8 m_bool_value { 0 };
u8 m_bool_range { 0 };
u64 m_bool_max_bits { 0 };
};
}
|