mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
LibGfx/WebPWriter: Extract write_VP8L_coded_image()
This commit is contained in:
parent
d9aa594e86
commit
9dfb254c73
Notes:
sideshowbarker
2024-07-17 03:00:02 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/9dfb254c73 Pull-request: https://github.com/SerenityOS/serenity/pull/24483 Reviewed-by: https://github.com/gmta ✅
1 changed files with 14 additions and 7 deletions
|
@ -213,14 +213,8 @@ static ErrorOr<CanonicalCode> write_normal_code_lengths(LittleEndianOutputBitStr
|
|||
return CanonicalCode::from_bytes(bit_lengths.span().trim(code_count));
|
||||
}
|
||||
|
||||
static ErrorOr<void> write_VP8L_image_data(Stream& stream, Bitmap const& bitmap, bool& is_fully_opaque)
|
||||
static ErrorOr<void> write_VP8L_coded_image(LittleEndianOutputBitStream& bit_stream, Bitmap const& bitmap, bool& is_fully_opaque)
|
||||
{
|
||||
LittleEndianOutputBitStream bit_stream { MaybeOwned<Stream>(stream) };
|
||||
|
||||
// image-stream = optional-transform spatially-coded-image
|
||||
// optional-transform = (%b1 transform optional-transform) / %b0
|
||||
TRY(bit_stream.write_bits(0u, 1u)); // No transform for now.
|
||||
|
||||
// https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#5_image_data
|
||||
// spatially-coded-image = color-cache-info meta-prefix data
|
||||
|
||||
|
@ -303,6 +297,19 @@ static ErrorOr<void> write_VP8L_image_data(Stream& stream, Bitmap const& bitmap,
|
|||
// Image data.
|
||||
TRY(write_image_data(bit_stream, bitmap, prefix_code_group));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> write_VP8L_image_data(Stream& stream, Bitmap const& bitmap, bool& is_fully_opaque)
|
||||
{
|
||||
LittleEndianOutputBitStream bit_stream { MaybeOwned<Stream>(stream) };
|
||||
|
||||
// image-stream = optional-transform spatially-coded-image
|
||||
// optional-transform = (%b1 transform optional-transform) / %b0
|
||||
TRY(bit_stream.write_bits(0u, 1u)); // No transform for now.
|
||||
|
||||
TRY(write_VP8L_coded_image(bit_stream, bitmap, is_fully_opaque));
|
||||
|
||||
// FIXME: Make ~LittleEndianOutputBitStream do this, or make it VERIFY() that it has happened at least.
|
||||
TRY(bit_stream.align_to_byte_boundary());
|
||||
TRY(bit_stream.flush_buffer_to_stream());
|
||||
|
|
Loading…
Reference in a new issue