LibVideo/VP9: Revert framebuffer size reduction to allow OOB blocks

The framebuffer size was reduced in f2c0cee, but this caused some niche
block layouts to write outside of the frame.

This could be fixed by adding checks to see if a block being predicted/
reconstructed is within the frame, but the branches introduced by that
reduce performance slightly. Therefore, it's better to keep the
framebuffer sized according to the decoded frame size in 8x8 blocks so
that any block can be decoded without bounds checking.

A test was added to ensure that this continues to work.
This commit is contained in:
Zaggy1024 2023-05-01 08:48:51 -05:00 committed by Tim Flynn
parent 6cec431720
commit 1422f7f904
4 changed files with 12 additions and 6 deletions

View file

@ -9,3 +9,4 @@ endforeach()
install(FILES vp9_in_webm.webm DESTINATION usr/Tests/LibVideo)
install(FILES vp9_4k.webm DESTINATION usr/Tests/LibVideo)
install(FILES vp9_clamp_reference_mvs.webm DESTINATION usr/Tests/LibVideo)
install(FILES vp9_oob_blocks.webm DESTINATION usr/Tests/LibVideo)

View file

@ -54,6 +54,11 @@ TEST_CASE(webm_in_vp9)
decode_video("./vp9_in_webm.webm"sv, 25);
}
TEST_CASE(vp9_oob_blocks)
{
decode_video("./vp9_oob_blocks.webm"sv, 240);
}
BENCHMARK_CASE(vp9_4k)
{
decode_video("./vp9_4k.webm"sv, 2);

Binary file not shown.

View file

@ -105,16 +105,16 @@ public:
// Calculates the output size for each plane in the frame.
Gfx::Size<u32> decoded_size(bool uv) const
{
// NOTE: According to the spec, this would be `y_size_to_uv_size(subsampling, blocks_to_pixels(blocks_size))`.
// We are deviating from that by creating smaller buffers to fit just the data we will store in an output
// frame or reference frame buffer.
if (uv) {
return {
y_size_to_uv_size(color_config.subsampling_y, size().width()),
y_size_to_uv_size(color_config.subsampling_y, size().height()),
y_size_to_uv_size(color_config.subsampling_y, blocks_to_pixels(columns())),
y_size_to_uv_size(color_config.subsampling_y, blocks_to_pixels(rows())),
};
}
return size();
return {
blocks_to_pixels(columns()),
blocks_to_pixels(rows()),
};
}
Vector2D<FrameBlockContext> const& block_contexts() const { return m_block_contexts; }