From c183f73922182231d998bc26a0f284dde364ef7f Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 14 May 2024 19:32:59 -0400 Subject: [PATCH] LibGfx/WebPWriter: Use write_VP8L_chunk() in animation frame writing This code path still has a redundant copy of the compressed data after this change, but it's less code this way. No behavior change. --- Userland/Libraries/LibGfx/ImageFormats/WebPWriter.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.cpp b/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.cpp index 3c62ab32581..3c7ade91408 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.cpp @@ -440,17 +440,11 @@ ErrorOr WebPAnimationWriter::add_frame(Bitmap& bitmap, int duration_ms, In return Error::from_string_literal("Frame does not fit in animation dimensions"); // FIXME: The whole writing-and-reading-into-buffer over-and-over is awkward and inefficient. - AllocatingMemoryStream vp8l_header_stream; - TRY(write_VP8L_header(vp8l_header_stream, bitmap.width(), bitmap.height(), true)); - auto vp8l_header_bytes = TRY(vp8l_header_stream.read_until_eof()); auto vp8l_data_bytes = TRY(compress_VP8L_image_data(bitmap)); AllocatingMemoryStream vp8l_chunk_stream; - TRY(write_chunk_header(vp8l_chunk_stream, "VP8L"sv, vp8l_header_bytes.size() + vp8l_data_bytes.size())); - TRY(vp8l_chunk_stream.write_until_depleted(vp8l_header_bytes)); - TRY(vp8l_chunk_stream.write_until_depleted(vp8l_data_bytes)); - TRY(align_to_two(vp8l_chunk_stream)); + TRY(write_VP8L_chunk(vp8l_chunk_stream, bitmap.width(), bitmap.height(), true, vp8l_data_bytes)); auto vp8l_chunk_bytes = TRY(vp8l_chunk_stream.read_until_eof()); ANMFChunk chunk;