diff options
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/BitStream.cpp | 62 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/BitStream.h | 15 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Decoder.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Decoder.h | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/TreeParser.h | 4 |
6 files changed, 51 insertions, 36 deletions
diff --git a/Userland/Libraries/LibVideo/VP9/BitStream.cpp b/Userland/Libraries/LibVideo/VP9/BitStream.cpp index f51cdbf25a..f10467d71b 100644 --- a/Userland/Libraries/LibVideo/VP9/BitStream.cpp +++ b/Userland/Libraries/LibVideo/VP9/BitStream.cpp @@ -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; +} + } diff --git a/Userland/Libraries/LibVideo/VP9/BitStream.h b/Userland/Libraries/LibVideo/VP9/BitStream.h index 3331d4e23c..0d89d116aa 100644 --- a/Userland/Libraries/LibVideo/VP9/BitStream.h +++ b/Userland/Libraries/LibVideo/VP9/BitStream.h @@ -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 }; diff --git a/Userland/Libraries/LibVideo/VP9/Decoder.cpp b/Userland/Libraries/LibVideo/VP9/Decoder.cpp index 77c9e58377..8511dad917 100644 --- a/Userland/Libraries/LibVideo/VP9/Decoder.cpp +++ b/Userland/Libraries/LibVideo/VP9/Decoder.cpp @@ -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); diff --git a/Userland/Libraries/LibVideo/VP9/Decoder.h b/Userland/Libraries/LibVideo/VP9/Decoder.h index dd175667ba..fa57eed26b 100644 --- a/Userland/Libraries/LibVideo/VP9/Decoder.h +++ b/Userland/Libraries/LibVideo/VP9/Decoder.h @@ -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); diff --git a/Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.h b/Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.h index 336e3897f8..740f7189bb 100644 --- a/Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.h +++ b/Userland/Libraries/LibVideo/VP9/SyntaxElementCounter.h @@ -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]; diff --git a/Userland/Libraries/LibVideo/VP9/TreeParser.h b/Userland/Libraries/LibVideo/VP9/TreeParser.h index f7c7febd34..02cfaf2c86 100644 --- a/Userland/Libraries/LibVideo/VP9/TreeParser.h +++ b/Userland/Libraries/LibVideo/VP9/TreeParser.h @@ -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) |