mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-16 06:22:17 +00:00
LibGfx/WebPWriter: Extract another align_to_two() helper
This commit is contained in:
parent
0175fff659
commit
33acd4e747
Notes:
sideshowbarker
2024-07-17 22:09:47 +09:00
Author: https://github.com/nico
Commit: 33acd4e747
Pull-request: https://github.com/SerenityOS/serenity/pull/24332
1 changed files with 12 additions and 10 deletions
|
@ -198,6 +198,16 @@ static ErrorOr<ByteBuffer> compress_VP8L_image_data(Bitmap const& bitmap)
|
||||||
return vp8l_data_stream.read_until_eof();
|
return vp8l_data_stream.read_until_eof();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Consider using LibRIFF for RIFF writing details. (It currently has no writing support.)
|
||||||
|
static ErrorOr<void> align_to_two(Stream& stream, size_t number_of_bytes_written)
|
||||||
|
{
|
||||||
|
// https://developers.google.com/speed/webp/docs/riff_container
|
||||||
|
// "If Chunk Size is odd, a single padding byte -- which MUST be 0 to conform with RIFF -- is added."
|
||||||
|
if (number_of_bytes_written % 2 != 0)
|
||||||
|
TRY(stream.write_value<u8>(0));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
static u8 vp8x_flags_from_header(VP8XHeader const& header)
|
static u8 vp8x_flags_from_header(VP8XHeader const& header)
|
||||||
{
|
{
|
||||||
u8 flags = 0;
|
u8 flags = 0;
|
||||||
|
@ -279,11 +289,7 @@ static ErrorOr<void> write_VP8X_chunk(Stream& stream, VP8XHeader const& header)
|
||||||
// FIXME: Consider using LibRIFF for RIFF writing details. (It currently has no writing support.)
|
// FIXME: Consider using LibRIFF for RIFF writing details. (It currently has no writing support.)
|
||||||
static ErrorOr<void> align_to_two(AllocatingMemoryStream& stream)
|
static ErrorOr<void> align_to_two(AllocatingMemoryStream& stream)
|
||||||
{
|
{
|
||||||
// https://developers.google.com/speed/webp/docs/riff_container
|
return align_to_two(stream, stream.used_buffer_size());
|
||||||
// "If Chunk Size is odd, a single padding byte -- which MUST be 0 to conform with RIFF -- is added."
|
|
||||||
if (stream.used_buffer_size() % 2 != 0)
|
|
||||||
TRY(stream.write_value<u8>(0));
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> WebPWriter::encode(Stream& stream, Bitmap const& bitmap, Options const& options)
|
ErrorOr<void> WebPWriter::encode(Stream& stream, Bitmap const& bitmap, Options const& options)
|
||||||
|
@ -352,11 +358,7 @@ private:
|
||||||
|
|
||||||
static ErrorOr<void> align_to_two(SeekableStream& stream)
|
static ErrorOr<void> align_to_two(SeekableStream& stream)
|
||||||
{
|
{
|
||||||
// https://developers.google.com/speed/webp/docs/riff_container
|
return align_to_two(stream, TRY(stream.tell()));
|
||||||
// "If Chunk Size is odd, a single padding byte -- which MUST be 0 to conform with RIFF -- is added."
|
|
||||||
if (TRY(stream.tell()) % 2 != 0)
|
|
||||||
TRY(stream.write_value<u8>(0));
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ErrorOr<void> write_ANMF_chunk(Stream& stream, ANMFChunk const& chunk)
|
static ErrorOr<void> write_ANMF_chunk(Stream& stream, ANMFChunk const& chunk)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue