From f898a00eb33a05215dff49e413203f0c5e37f46d Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Sat, 26 Nov 2022 10:10:31 -0600 Subject: 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". --- Userland/Libraries/LibVideo/VP9/Utilities.h | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'Userland/Libraries/LibVideo/VP9/Utilities.h') 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 +#include + +#include "LookupTables.h" namespace Video::VP9 { @@ -42,4 +45,50 @@ inline T brev(C bit_count, T value) return result; } +inline Gfx::Size block_size_to_sub_blocks(BlockSubsize size) +{ + return Gfx::Size(num_4x4_blocks_wide_lookup[size], num_4x4_blocks_high_lookup[size]); +} + +template +inline T blocks_to_sub_blocks(T blocks) +{ + return blocks << 1; +} + +template +inline T sub_blocks_to_blocks(T sub_blocks) +{ + return sub_blocks >> 1; +} + +template +inline T sub_blocks_to_pixels(T sub_blocks) +{ + return sub_blocks << 2; +} + +template +inline T pixels_to_sub_blocks(T pixels) +{ + return pixels >> 2; +} + +template +inline T blocks_to_pixels(T blocks) +{ + return sub_blocks_to_pixels(blocks_to_sub_blocks(blocks)); +} + +template +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; +} + } -- cgit v1.2.3