mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibVideo/VP9: Specify which spec section defines certain behaviors
This commit is contained in:
parent
ce524214c9
commit
91572a49c4
Notes:
sideshowbarker
2024-07-18 09:23:53 +09:00
Author: https://github.com/FalseHonesty Commit: https://github.com/SerenityOS/serenity/commit/91572a49c4a Pull-request: https://github.com/SerenityOS/serenity/pull/8349 Reviewed-by: https://github.com/Lubrsi
6 changed files with 51 additions and 36 deletions
|
@ -37,13 +37,6 @@ u8 BitStream::read_f(size_t n)
|
|||
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()
|
||||
{
|
||||
if (!m_current_byte.has_value())
|
||||
|
@ -63,30 +56,6 @@ u16 BitStream::read_f16()
|
|||
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 */
|
||||
bool BitStream::init_bool(size_t bytes)
|
||||
{
|
||||
|
@ -139,4 +108,35 @@ bool BitStream::exit_bool()
|
|||
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();
|
||||
bool read_bit();
|
||||
|
||||
/* (9.1) */
|
||||
u8 read_f(size_t n);
|
||||
i8 read_s(size_t n);
|
||||
u8 read_f8();
|
||||
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);
|
||||
|
||||
/* (4.9.2) */
|
||||
i8 read_s(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:
|
||||
u8 const* m_data_ptr { nullptr };
|
||||
size_t m_bytes_remaining { 0 };
|
||||
|
|
|
@ -22,6 +22,7 @@ Decoder::Decoder()
|
|||
{
|
||||
}
|
||||
|
||||
/* (6.1) */
|
||||
bool Decoder::parse_frame(ByteBuffer const& frame_data)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/* (6.2) */
|
||||
bool Decoder::uncompressed_header()
|
||||
{
|
||||
auto frame_marker = m_bit_stream->read_f(2);
|
||||
|
|
|
@ -40,6 +40,7 @@ private:
|
|||
return StudioSwing;
|
||||
}
|
||||
|
||||
/* (6.2) Uncompressed Header Syntax */
|
||||
bool uncompressed_header();
|
||||
bool frame_sync_code();
|
||||
bool color_config();
|
||||
|
@ -59,6 +60,7 @@ private:
|
|||
bool setup_past_independence();
|
||||
bool trailing_bits();
|
||||
|
||||
/* (6.3) Compressed Header Syntax */
|
||||
bool compressed_header();
|
||||
bool read_tx_mode();
|
||||
bool tx_mode_probs();
|
||||
|
@ -79,6 +81,7 @@ private:
|
|||
u8 update_mv_prob(u8 prob);
|
||||
bool setup_compound_reference_mode();
|
||||
|
||||
/* (6.4) Decode Tiles Syntax */
|
||||
bool decode_tiles();
|
||||
bool clear_above_context();
|
||||
u32 get_tile_offset(u32 tile_num, u32 mis, u32 tile_size_log2);
|
||||
|
|
|
@ -44,6 +44,7 @@ enum class SyntaxElementType {
|
|||
|
||||
class SyntaxElementCounter final {
|
||||
public:
|
||||
/* (8.3) Clear Counts Process */
|
||||
void clear_counts();
|
||||
|
||||
u8 m_counts_intra_mode[BLOCK_SIZE_GROUPS][INTRA_MODES];
|
||||
|
|
|
@ -41,10 +41,14 @@ public:
|
|||
TreeSelectionValue m_value;
|
||||
};
|
||||
|
||||
/* (9.3.3) */
|
||||
template<typename T = int>
|
||||
T parse_tree(SyntaxElementType type);
|
||||
/* (9.3.1) */
|
||||
TreeSelection select_tree(SyntaxElementType type);
|
||||
/* (9.3.2) */
|
||||
u8 select_tree_probability(SyntaxElementType type, u8 node);
|
||||
/* (9.3.4) */
|
||||
void count_syntax_element(SyntaxElementType type, int value);
|
||||
|
||||
void set_default_intra_mode_variables(u8 idx, u8 idy)
|
||||
|
|
Loading…
Reference in a new issue