mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
LibVideo/VP9: Specify which spec section defines certain behaviors
This commit is contained in:
parent
ce524214c9
commit
91572a49c4
6 changed files with 51 additions and 36 deletions
|
@ -37,13 +37,6 @@ u8 BitStream::read_f(size_t n)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
i8 BitStream::read_s(size_t n)
|
|
||||||
{
|
|
||||||
auto value = read_f(n);
|
|
||||||
auto sign = read_bit();
|
|
||||||
return sign ? -value : value;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 BitStream::read_f8()
|
u8 BitStream::read_f8()
|
||||||
{
|
{
|
||||||
if (!m_current_byte.has_value())
|
if (!m_current_byte.has_value())
|
||||||
|
@ -63,30 +56,6 @@ u16 BitStream::read_f16()
|
||||||
return (read_f8() << 8u) | read_f8();
|
return (read_f8() << 8u) | read_f8();
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 BitStream::read_literal(size_t n)
|
|
||||||
{
|
|
||||||
u8 return_value = 0;
|
|
||||||
for (size_t i = 0; i < n; i++) {
|
|
||||||
return_value = (2 * return_value) + read_bool(128);
|
|
||||||
}
|
|
||||||
return return_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 BitStream::get_position()
|
|
||||||
{
|
|
||||||
return (m_bytes_read * 8) + (7 - m_current_bit_position);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t BitStream::bytes_remaining()
|
|
||||||
{
|
|
||||||
return m_bytes_remaining;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t BitStream::bits_remaining()
|
|
||||||
{
|
|
||||||
return (bytes_remaining() * 8) + m_current_bit_position + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 9.2.1 */
|
/* 9.2.1 */
|
||||||
bool BitStream::init_bool(size_t bytes)
|
bool BitStream::init_bool(size_t bytes)
|
||||||
{
|
{
|
||||||
|
@ -139,4 +108,35 @@ bool BitStream::exit_bool()
|
||||||
return padding_element == 0;
|
return padding_element == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 BitStream::read_literal(size_t n)
|
||||||
|
{
|
||||||
|
u8 return_value = 0;
|
||||||
|
for (size_t i = 0; i < n; i++) {
|
||||||
|
return_value = (2 * return_value) + read_bool(128);
|
||||||
|
}
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 BitStream::read_s(size_t n)
|
||||||
|
{
|
||||||
|
auto value = read_f(n);
|
||||||
|
auto sign = read_bit();
|
||||||
|
return sign ? -value : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 BitStream::get_position()
|
||||||
|
{
|
||||||
|
return (m_bytes_read * 8) + (7 - m_current_bit_position);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t BitStream::bytes_remaining()
|
||||||
|
{
|
||||||
|
return m_bytes_remaining;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t BitStream::bits_remaining()
|
||||||
|
{
|
||||||
|
return (bytes_remaining() * 8) + m_current_bit_position + 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,20 +21,25 @@ public:
|
||||||
|
|
||||||
u8 read_byte();
|
u8 read_byte();
|
||||||
bool read_bit();
|
bool read_bit();
|
||||||
|
|
||||||
|
/* (9.1) */
|
||||||
u8 read_f(size_t n);
|
u8 read_f(size_t n);
|
||||||
i8 read_s(size_t n);
|
|
||||||
u8 read_f8();
|
u8 read_f8();
|
||||||
u16 read_f16();
|
u16 read_f16();
|
||||||
|
|
||||||
|
/* (9.2) */
|
||||||
|
bool init_bool(size_t bytes);
|
||||||
|
bool read_bool(u8 probability);
|
||||||
|
bool exit_bool();
|
||||||
u8 read_literal(size_t n);
|
u8 read_literal(size_t n);
|
||||||
|
|
||||||
|
/* (4.9.2) */
|
||||||
|
i8 read_s(size_t n);
|
||||||
|
|
||||||
u64 get_position();
|
u64 get_position();
|
||||||
size_t bytes_remaining();
|
size_t bytes_remaining();
|
||||||
size_t bits_remaining();
|
size_t bits_remaining();
|
||||||
|
|
||||||
bool init_bool(size_t bytes);
|
|
||||||
bool read_bool(u8 probability);
|
|
||||||
bool exit_bool();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u8 const* m_data_ptr { nullptr };
|
u8 const* m_data_ptr { nullptr };
|
||||||
size_t m_bytes_remaining { 0 };
|
size_t m_bytes_remaining { 0 };
|
||||||
|
|
|
@ -22,6 +22,7 @@ Decoder::Decoder()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (6.1) */
|
||||||
bool Decoder::parse_frame(ByteBuffer const& frame_data)
|
bool Decoder::parse_frame(ByteBuffer const& frame_data)
|
||||||
{
|
{
|
||||||
m_bit_stream = make<BitStream>(frame_data.data(), frame_data.size());
|
m_bit_stream = make<BitStream>(frame_data.data(), frame_data.size());
|
||||||
|
@ -49,6 +50,7 @@ bool Decoder::parse_frame(ByteBuffer const& frame_data)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (6.2) */
|
||||||
bool Decoder::uncompressed_header()
|
bool Decoder::uncompressed_header()
|
||||||
{
|
{
|
||||||
auto frame_marker = m_bit_stream->read_f(2);
|
auto frame_marker = m_bit_stream->read_f(2);
|
||||||
|
|
|
@ -40,6 +40,7 @@ private:
|
||||||
return StudioSwing;
|
return StudioSwing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (6.2) Uncompressed Header Syntax */
|
||||||
bool uncompressed_header();
|
bool uncompressed_header();
|
||||||
bool frame_sync_code();
|
bool frame_sync_code();
|
||||||
bool color_config();
|
bool color_config();
|
||||||
|
@ -59,6 +60,7 @@ private:
|
||||||
bool setup_past_independence();
|
bool setup_past_independence();
|
||||||
bool trailing_bits();
|
bool trailing_bits();
|
||||||
|
|
||||||
|
/* (6.3) Compressed Header Syntax */
|
||||||
bool compressed_header();
|
bool compressed_header();
|
||||||
bool read_tx_mode();
|
bool read_tx_mode();
|
||||||
bool tx_mode_probs();
|
bool tx_mode_probs();
|
||||||
|
@ -79,6 +81,7 @@ private:
|
||||||
u8 update_mv_prob(u8 prob);
|
u8 update_mv_prob(u8 prob);
|
||||||
bool setup_compound_reference_mode();
|
bool setup_compound_reference_mode();
|
||||||
|
|
||||||
|
/* (6.4) Decode Tiles Syntax */
|
||||||
bool decode_tiles();
|
bool decode_tiles();
|
||||||
bool clear_above_context();
|
bool clear_above_context();
|
||||||
u32 get_tile_offset(u32 tile_num, u32 mis, u32 tile_size_log2);
|
u32 get_tile_offset(u32 tile_num, u32 mis, u32 tile_size_log2);
|
||||||
|
|
|
@ -44,6 +44,7 @@ enum class SyntaxElementType {
|
||||||
|
|
||||||
class SyntaxElementCounter final {
|
class SyntaxElementCounter final {
|
||||||
public:
|
public:
|
||||||
|
/* (8.3) Clear Counts Process */
|
||||||
void clear_counts();
|
void clear_counts();
|
||||||
|
|
||||||
u8 m_counts_intra_mode[BLOCK_SIZE_GROUPS][INTRA_MODES];
|
u8 m_counts_intra_mode[BLOCK_SIZE_GROUPS][INTRA_MODES];
|
||||||
|
|
|
@ -41,10 +41,14 @@ public:
|
||||||
TreeSelectionValue m_value;
|
TreeSelectionValue m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* (9.3.3) */
|
||||||
template<typename T = int>
|
template<typename T = int>
|
||||||
T parse_tree(SyntaxElementType type);
|
T parse_tree(SyntaxElementType type);
|
||||||
|
/* (9.3.1) */
|
||||||
TreeSelection select_tree(SyntaxElementType type);
|
TreeSelection select_tree(SyntaxElementType type);
|
||||||
|
/* (9.3.2) */
|
||||||
u8 select_tree_probability(SyntaxElementType type, u8 node);
|
u8 select_tree_probability(SyntaxElementType type, u8 node);
|
||||||
|
/* (9.3.4) */
|
||||||
void count_syntax_element(SyntaxElementType type, int value);
|
void count_syntax_element(SyntaxElementType type, int value);
|
||||||
|
|
||||||
void set_default_intra_mode_variables(u8 idx, u8 idy)
|
void set_default_intra_mode_variables(u8 idx, u8 idy)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue