mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:07:44 +00:00
LibGfx/LibVideo: Check for overreads only at end of a VPX range decode
Errors are now deferred until `finish_decode()` is finished, meaning branches to return errors only need to occur at the end of a ranged decode. If VPX_DEBUG is enabled, a debug message will be printed immediately when an overread occurs. Average decoding times for `Tests/LibGfx/test-inputs/4.webp` improve by about 4.7% with this change, absolute decode times changing from 27.4ms±1.1ms down to 26.1ms±1.0ms.
This commit is contained in:
parent
873b0e9470
commit
24ae35086d
8 changed files with 353 additions and 366 deletions
|
@ -20,8 +20,8 @@ public:
|
|||
static ErrorOr<BooleanDecoder> initialize(ReadonlyBytes data);
|
||||
|
||||
/* (9.2) */
|
||||
ErrorOr<bool> read_bool(u8 probability);
|
||||
ErrorOr<u8> read_literal(u8 bits);
|
||||
bool read_bool(u8 probability);
|
||||
u8 read_literal(u8 bits);
|
||||
|
||||
ErrorOr<void> finish_decode();
|
||||
|
||||
|
@ -37,12 +37,14 @@ private:
|
|||
, m_value(static_cast<ValueType>(*data) << reserve_bits)
|
||||
, m_value_bits_left(8)
|
||||
{
|
||||
fill_reservoir();
|
||||
}
|
||||
|
||||
ErrorOr<void> fill_reservoir();
|
||||
void fill_reservoir();
|
||||
|
||||
u8 const* m_data;
|
||||
size_t m_bytes_left { 0 };
|
||||
bool m_overread { false };
|
||||
// This value will never exceed 255. If this is a u8, the compiler will generate a truncation in read_bool().
|
||||
u32 m_range { 0 };
|
||||
ValueType m_value { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue