diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2022-11-26 10:10:31 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-11-30 08:28:30 +0100 |
commit | f898a00eb33a05215dff49e413203f0c5e37f46d (patch) | |
tree | 42318f797f9cb7676b884a1488b8ae1005887d88 /Userland/Libraries/LibVideo/VP9/Utilities.h | |
parent | f4af6714d2596af15a651c7ddfe07f40d84d03ae (diff) | |
download | serenity-f898a00eb33a05215dff49e413203f0c5e37f46d.zip |
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".
Diffstat (limited to 'Userland/Libraries/LibVideo/VP9/Utilities.h')
-rw-r--r-- | Userland/Libraries/LibVideo/VP9/Utilities.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Userland/Libraries/LibVideo/VP9/Utilities.h b/Userland/Libraries/LibVideo/VP9/Utilities.h index 08b073791d..8a99ed1d3d 100644 --- a/Userland/Libraries/LibVideo/VP9/Utilities.h +++ b/Userland/Libraries/LibVideo/VP9/Utilities.h @@ -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; +} + } |