mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:07:35 +00:00
LibVideo/VP9: Convert the Parser to use AK/BitStream.h
This doesn't appear to have had a measurable impact on performance, and behavior is the same. With the tiles using independent BooleanDecoders with their own backing BitStreams, we're even one step closer to threaded tiles!
This commit is contained in:
parent
6f39c44160
commit
fb0c226da3
10 changed files with 499 additions and 581 deletions
41
Userland/Libraries/LibVideo/VP9/BooleanDecoder.h
Normal file
41
Userland/Libraries/LibVideo/VP9/BooleanDecoder.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
|
||||
* Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/BitStream.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Video::VP9 {
|
||||
|
||||
class BooleanDecoder {
|
||||
public:
|
||||
/* (9.2) */
|
||||
static ErrorOr<BooleanDecoder> initialize(MaybeOwned<BigEndianInputBitStream> bit_stream, size_t bytes);
|
||||
ErrorOr<bool> read_bool(u8 probability);
|
||||
ErrorOr<u8> read_literal(u8 bits);
|
||||
size_t bits_remaining() const;
|
||||
ErrorOr<void> finish_decode();
|
||||
|
||||
private:
|
||||
BooleanDecoder(MaybeOwned<BigEndianInputBitStream>&& bit_stream, u8 value, u8 range, u64 bits_left)
|
||||
: m_bit_stream(move(bit_stream))
|
||||
, m_value(value)
|
||||
, m_range(range)
|
||||
, m_bits_left(bits_left)
|
||||
{
|
||||
}
|
||||
|
||||
MaybeOwned<BigEndianInputBitStream> m_bit_stream;
|
||||
u8 m_value { 0 };
|
||||
u8 m_range { 0 };
|
||||
u64 m_bits_left { 0 };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue