blob: 6eaea166f5a86ee5dbadff4a6b24677b2d148bb1 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/*
* Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "BitStream.h"
#include "LookupTables.h"
#include "ProbabilityTables.h"
#include "SyntaxElementCounter.h"
#include "TreeParser.h"
#include <AK/ByteBuffer.h>
#include <AK/OwnPtr.h>
namespace Video::VP9 {
class Decoder {
public:
Decoder();
bool parse_frame(const ByteBuffer&);
void dump_info();
private:
FrameType read_frame_type()
{
if (m_bit_stream->read_bit())
return NonKeyFrame;
return KeyFrame;
}
ColorRange read_color_range()
{
if (m_bit_stream->read_bit())
return FullSwing;
return StudioSwing;
}
bool uncompressed_header();
bool frame_sync_code();
bool color_config();
bool frame_size();
bool render_size();
bool frame_size_with_refs();
bool compute_image_size();
bool read_interpolation_filter();
bool loop_filter_params();
bool quantization_params();
i8 read_delta_q();
bool segmentation_params();
u8 read_prob();
bool tile_info();
u16 calc_min_log2_tile_cols();
u16 calc_max_log2_tile_cols();
bool setup_past_independence();
bool trailing_bits();
bool compressed_header();
bool read_tx_mode();
bool tx_mode_probs();
u8 diff_update_prob(u8 prob);
u8 decode_term_subexp();
u8 inv_remap_prob(u8 delta_prob, u8 prob);
u8 inv_recenter_nonneg(u8 v, u8 m);
bool read_coef_probs();
bool read_skip_prob();
bool read_inter_mode_probs();
bool read_interp_filter_probs();
bool read_is_inter_probs();
bool frame_reference_mode();
bool frame_reference_mode_probs();
bool read_y_mode_probs();
bool read_partition_probs();
bool mv_probs();
u8 update_mv_prob(u8 prob);
bool setup_compound_reference_mode();
bool decode_tiles();
bool clear_above_context();
u32 get_tile_offset(u32 tile_num, u32 mis, u32 tile_size_log2);
bool decode_tile();
bool clear_left_context();
bool decode_partition(u32 row, u32 col, u8 block_subsize);
u8 m_profile { 0 };
u8 m_frame_to_show_map_index { 0 };
u16 m_header_size_in_bytes { 0 };
u8 m_refresh_frame_flags { 0 };
u8 m_loop_filter_level { 0 };
u8 m_loop_filter_sharpness { 0 };
bool m_loop_filter_delta_enabled { false };
FrameType m_frame_type;
FrameType m_last_frame_type;
bool m_show_frame { false };
bool m_error_resilient_mode { false };
bool m_frame_is_intra { false };
u8 m_reset_frame_context { 0 };
bool m_allow_high_precision_mv { false };
u8 m_ref_frame_idx[3];
u8 m_ref_frame_sign_bias[LastFrame + 3];
bool m_refresh_frame_context { false };
bool m_frame_parallel_decoding_mode { false };
u8 m_frame_context_idx { 0 };
u8 m_bit_depth { 0 };
ColorSpace m_color_space;
ColorRange m_color_range;
bool m_subsampling_x { false };
bool m_subsampling_y { false };
u32 m_frame_width { 0 };
u32 m_frame_height { 0 };
u16 m_render_width { 0 };
u16 m_render_height { 0 };
bool m_render_and_frame_size_different { false };
u32 m_mi_cols { 0 };
u32 m_mi_rows { 0 };
u32 m_sb64_cols { 0 };
u32 m_sb64_rows { 0 };
InterpolationFilter m_interpolation_filter;
bool m_lossless { false };
u8 m_segmentation_tree_probs[7];
u8 m_segmentation_pred_prob[3];
bool m_feature_enabled[8][4];
u8 m_feature_data[8][4];
bool m_segmentation_abs_or_delta_update { false };
u16 m_tile_cols_log2 { 0 };
u16 m_tile_rows_log2 { 0 };
i8 m_loop_filter_ref_deltas[MAX_REF_FRAMES];
i8 m_loop_filter_mode_deltas[2];
u32 m_mi_row_start { 0 };
u32 m_mi_row_end { 0 };
u32 m_mi_col_start { 0 };
u32 m_mi_col_end { 0 };
bool m_use_hp { false };
TXMode m_tx_mode;
ReferenceMode m_reference_mode;
ReferenceFrame m_comp_fixed_ref;
ReferenceFrame m_comp_var_ref[2];
OwnPtr<BitStream> m_bit_stream;
OwnPtr<ProbabilityTables> m_probability_tables;
OwnPtr<SyntaxElementCounter> m_syntax_element_counter;
NonnullOwnPtr<TreeParser> m_tree_parser;
};
}
|