summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.cpp11
-rw-r--r--Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.h9
-rw-r--r--Userland/Libraries/LibVideo/VP9/Context.h2
-rw-r--r--Userland/Libraries/LibVideo/VP9/Parser.cpp6
4 files changed, 19 insertions, 9 deletions
diff --git a/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.cpp b/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.cpp
index 69b3a91d76..7b51b419e4 100644
--- a/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.cpp
+++ b/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.cpp
@@ -11,14 +11,19 @@
namespace Gfx {
-/* 9.2.1 */
ErrorOr<BooleanDecoder> BooleanDecoder::initialize(MaybeOwned<BigEndianInputBitStream> bit_stream, size_t size_in_bytes)
{
VERIFY(bit_stream->is_aligned_to_byte_boundary());
auto value = TRY(bit_stream->read_value<u8>());
u8 range = 255;
u64 bits_left = (8 * size_in_bytes) - 8;
- BooleanDecoder decoder { move(bit_stream), value, range, bits_left };
+ return BooleanDecoder { move(bit_stream), value, range, bits_left };
+}
+
+/* 9.2.1 */
+ErrorOr<BooleanDecoder> BooleanDecoder::initialize_vp9(MaybeOwned<BigEndianInputBitStream> bit_stream, size_t size_in_bytes)
+{
+ BooleanDecoder decoder = TRY(initialize(move(bit_stream), size_in_bytes));
if (TRY(decoder.read_bool(128)))
return Error::from_string_literal("Range decoder marker was non-zero");
return decoder;
@@ -63,7 +68,7 @@ ErrorOr<u8> BooleanDecoder::read_literal(u8 bits)
}
/* 9.2.3 */
-ErrorOr<void> BooleanDecoder::finish_decode()
+ErrorOr<void> BooleanDecoder::finish_decode_vp9()
{
while (m_bits_left > 0) {
auto padding_read_size = min(m_bits_left, 64);
diff --git a/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.h b/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.h
index d17a4ee2c7..e56e165329 100644
--- a/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.h
+++ b/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.h
@@ -14,13 +14,18 @@
namespace Gfx {
+// Can decode bitstreams encoded with VP8's and VP9's arithmetic boolean encoder.
class BooleanDecoder {
public:
- /* (9.2) */
static ErrorOr<BooleanDecoder> initialize(MaybeOwned<BigEndianInputBitStream> bit_stream, size_t size_in_bytes);
+
+ /* (9.2) */
+ static ErrorOr<BooleanDecoder> initialize_vp9(MaybeOwned<BigEndianInputBitStream> bit_stream, size_t size_in_bytes);
+
ErrorOr<bool> read_bool(u8 probability);
ErrorOr<u8> read_literal(u8 bits);
- ErrorOr<void> finish_decode();
+
+ ErrorOr<void> finish_decode_vp9();
private:
BooleanDecoder(MaybeOwned<BigEndianInputBitStream>&& bit_stream, u8 value, u8 range, u64 bits_left)
diff --git a/Userland/Libraries/LibVideo/VP9/Context.h b/Userland/Libraries/LibVideo/VP9/Context.h
index 9c6b7e7b29..24c2d7a427 100644
--- a/Userland/Libraries/LibVideo/VP9/Context.h
+++ b/Userland/Libraries/LibVideo/VP9/Context.h
@@ -229,7 +229,7 @@ public:
auto context_view = frame_context.m_block_contexts.view(rows_start, columns_start, height, width);
auto bit_stream = DECODER_TRY_ALLOC(try_make<BigEndianInputBitStream>(DECODER_TRY_ALLOC(try_make<FixedMemoryStream>(*frame_context.stream))));
- auto decoder = DECODER_TRY(DecoderErrorCategory::Corrupted, BooleanDecoder::initialize(move(bit_stream), tile_size));
+ auto decoder = DECODER_TRY(DecoderErrorCategory::Corrupted, BooleanDecoder::initialize_vp9(move(bit_stream), tile_size));
return TileContext {
frame_context,
diff --git a/Userland/Libraries/LibVideo/VP9/Parser.cpp b/Userland/Libraries/LibVideo/VP9/Parser.cpp
index 7128bddce6..a0453da52b 100644
--- a/Userland/Libraries/LibVideo/VP9/Parser.cpp
+++ b/Userland/Libraries/LibVideo/VP9/Parser.cpp
@@ -593,7 +593,7 @@ void Parser::setup_past_independence()
DecoderErrorOr<void> Parser::compressed_header(FrameContext& frame_context)
{
- auto decoder = TRY_READ(BooleanDecoder::initialize(MaybeOwned(frame_context.bit_stream), frame_context.header_size_in_bytes));
+ auto decoder = TRY_READ(BooleanDecoder::initialize_vp9(MaybeOwned(frame_context.bit_stream), frame_context.header_size_in_bytes));
frame_context.transform_mode = TRY(read_tx_mode(decoder, frame_context));
if (frame_context.transform_mode == TransformMode::Select)
TRY(tx_mode_probs(decoder));
@@ -610,7 +610,7 @@ DecoderErrorOr<void> Parser::compressed_header(FrameContext& frame_context)
TRY(read_partition_probs(decoder));
TRY(mv_probs(decoder, frame_context));
}
- TRY_READ(decoder.finish_decode());
+ TRY_READ(decoder.finish_decode_vp9());
return {};
}
@@ -1002,7 +1002,7 @@ DecoderErrorOr<void> Parser::decode_tile(TileContext& tile_context)
TRY(decode_partition(tile_context, row, col, Block_64x64));
}
}
- TRY_READ(tile_context.decoder.finish_decode());
+ TRY_READ(tile_context.decoder.finish_decode_vp9());
return {};
}