mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibVideo/VP9: Copy data to reference frames row by row
This changes the order of the loop copying data to a reference frame store so that it copies each row in a contiguous line rather than copying a column at a time, which caused unnecessary branches. This reduces the decode time on a fairly long 720p YouTube video by about 14.5% (~43.5s to ~37.2s).
This commit is contained in:
parent
dfd0eb877f
commit
5cd5edc3bd
Notes:
sideshowbarker
2024-07-16 23:17:55 +09:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/SerenityOS/serenity/commit/5cd5edc3bd Pull-request: https://github.com/SerenityOS/serenity/pull/18360
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <AK/TypedTransfer.h>
|
||||
#include <LibGfx/Size.h>
|
||||
#include <LibVideo/Color/CodingIndependentCodePoints.h>
|
||||
|
||||
|
@ -1766,15 +1767,15 @@ DecoderErrorOr<void> Decoder::update_reference_frames(FrameContext const& frame_
|
|||
stride >>= frame_context.color_config.subsampling_x;
|
||||
}
|
||||
|
||||
auto original_buffer = get_output_buffer(plane);
|
||||
auto const& original_buffer = get_output_buffer(plane);
|
||||
auto& frame_store_buffer = reference_frame.frame_planes[plane];
|
||||
frame_store_buffer.resize_and_keep_capacity(width * height);
|
||||
VERIFY(original_buffer.size() >= frame_store_buffer.size());
|
||||
|
||||
for (auto x = 0u; x < width; x++) {
|
||||
for (auto y = 0u; y < height; y++) {
|
||||
auto sample = original_buffer[index_from_row_and_column(y, x, stride)];
|
||||
frame_store_buffer[index_from_row_and_column(y, x, width)] = sample;
|
||||
}
|
||||
for (auto y = 0u; y < height; y++) {
|
||||
auto const* source = &original_buffer[index_from_row_and_column(y, 0, stride)];
|
||||
auto* destination = &frame_store_buffer[index_from_row_and_column(y, 0, width)];
|
||||
AK::TypedTransfer<RemoveReference<decltype(*destination)>>::copy(destination, source, width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue