1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 04:37: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:
Zaggy1024 2023-06-01 19:16:57 -05:00 committed by Andreas Kling
parent 873b0e9470
commit 24ae35086d
8 changed files with 353 additions and 366 deletions

View file

@ -65,7 +65,7 @@ public:
// 9.2.1: The Boolean decoding process specified in section 9.2.2 is invoked to read a marker syntax element from the
// bitstream. It is a requirement of bitstream conformance that the value read is equal to 0.
auto decoder = DECODER_TRY(DecoderErrorCategory::Corrupted, BooleanDecoder::initialize(compressed_header_data));
if (DECODER_TRY(DecoderErrorCategory::Corrupted, decoder.read_bool(128)))
if (decoder.read_bool(128))
return DecoderError::corrupted("Range decoder marker was non-zero"sv);
DECODER_TRY(DecoderErrorCategory::Corrupted, bit_stream.discard(size));