1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:47:46 +00:00

LibVideo/VP9: Specify more units in Parser::residual()

Previously, the variables were named similarly to the names in spec
which aren't very human-readable. This adds some utility functions for
dimensional unit conversions and names the variables in residual()
based on their units.

References to 4x4 blocks were also renamed to call them sub-blocks
instead, since unit conversion functions would not be able to begin
with "4x4_blocks".
This commit is contained in:
Zaggy1024 2022-11-26 10:10:31 -06:00 committed by Andreas Kling
parent f4af6714d2
commit f898a00eb3
3 changed files with 112 additions and 71 deletions

View file

@ -8,6 +8,9 @@
#pragma once
#include <AK/Types.h>
#include <LibGfx/Size.h>
#include "LookupTables.h"
namespace Video::VP9 {
@ -42,4 +45,50 @@ inline T brev(C bit_count, T value)
return result;
}
inline Gfx::Size<u8> block_size_to_sub_blocks(BlockSubsize size)
{
return Gfx::Size<u8>(num_4x4_blocks_wide_lookup[size], num_4x4_blocks_high_lookup[size]);
}
template<Integral T>
inline T blocks_to_sub_blocks(T blocks)
{
return blocks << 1;
}
template<Integral T>
inline T sub_blocks_to_blocks(T sub_blocks)
{
return sub_blocks >> 1;
}
template<Integral T>
inline T sub_blocks_to_pixels(T sub_blocks)
{
return sub_blocks << 2;
}
template<Integral T>
inline T pixels_to_sub_blocks(T pixels)
{
return pixels >> 2;
}
template<Integral T>
inline T blocks_to_pixels(T blocks)
{
return sub_blocks_to_pixels(blocks_to_sub_blocks(blocks));
}
template<Integral T>
inline T pixels_to_blocks(T pixels)
{
return sub_blocks_to_blocks(pixels_to_sub_blocks(pixels));
}
inline u8 transform_size_to_sub_blocks(TXSize transform_size)
{
return 1 << transform_size;
}
}