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.
This commit is contained in:
Nico Weber 2024-05-14 19:32:59 -04:00 committed by Andreas Kling
commit c183f73922
Notes: sideshowbarker 2024-07-17 08:13:43 +09:00

View file

@ -440,17 +440,11 @@ ErrorOr<void> 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;