1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:57:44 +00:00

LibVideo/VP9: Consolidate frame size calculations

This moves all the frame size calculation to `FrameContext`, where the
subsampling is easily accessible to determine the size for each plane.
The internal framebuffer size has also been reduced to the exact frame
size that is output.
This commit is contained in:
Zaggy1024 2023-04-18 20:16:44 -05:00 committed by Tim Flynn
parent 57c7389200
commit f2c0cee522
5 changed files with 61 additions and 77 deletions

View file

@ -94,6 +94,20 @@ public:
u32 columns() const { return m_columns; }
u32 superblock_rows() const { return blocks_ceiled_to_superblocks(rows()); }
u32 superblock_columns() const { return blocks_ceiled_to_superblocks(columns()); }
// 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()),
};
}
return size();
}
Vector2D<FrameBlockContext> const& block_contexts() const { return m_block_contexts; }