mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 11:39:43 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
35
Libraries/LibGfx/ImageFormats/WebPSharedLossless.cpp
Normal file
35
Libraries/LibGfx/ImageFormats/WebPSharedLossless.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Nico Weber <thakis@chromium.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/ImageFormats/WebPSharedLossless.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
ErrorOr<CanonicalCode> CanonicalCode::from_bytes(ReadonlyBytes bytes)
|
||||
{
|
||||
auto non_zero_symbol_count = 0;
|
||||
auto last_non_zero_symbol = -1;
|
||||
for (size_t i = 0; i < bytes.size(); i++) {
|
||||
if (bytes[i] != 0) {
|
||||
non_zero_symbol_count++;
|
||||
last_non_zero_symbol = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (non_zero_symbol_count == 1)
|
||||
return CanonicalCode(last_non_zero_symbol);
|
||||
|
||||
return CanonicalCode(TRY(Compress::CanonicalCode::from_bytes(bytes)));
|
||||
}
|
||||
|
||||
ErrorOr<u32> CanonicalCode::read_symbol(LittleEndianInputBitStream& bit_stream) const
|
||||
{
|
||||
return TRY(m_code.visit(
|
||||
[](u32 single_code) -> ErrorOr<u32> { return single_code; },
|
||||
[&bit_stream](Compress::CanonicalCode const& code) { return code.read_symbol(bit_stream); }));
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue