From 720fc5a853dc768b1d2956f95eadf96761082830 Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Mon, 28 Nov 2022 05:10:39 -0600 Subject: LibVideo/VP9: Use unit conversion functions in BlockContext This should make things in there seem a little less magical :^) --- Userland/Libraries/LibVideo/VP9/Context.h | 8 ++++---- Userland/Libraries/LibVideo/VP9/Utilities.h | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibVideo/VP9/Context.h b/Userland/Libraries/LibVideo/VP9/Context.h index 4d380e2f84..e1d16b5f7c 100644 --- a/Userland/Libraries/LibVideo/VP9/Context.h +++ b/Userland/Libraries/LibVideo/VP9/Context.h @@ -69,14 +69,14 @@ public: m_size = size; // From spec, compute_image_size( ) - m_rows = (size.height() + 7u) >> 3u; - m_columns = (size.width() + 7u) >> 3u; + m_rows = pixels_to_blocks(size.height() + 7u); + m_columns = pixels_to_blocks(size.width() + 7u); return m_block_contexts.try_resize(m_rows, m_columns); } u32 rows() const { return m_rows; } u32 columns() const { return m_columns; } - u32 superblock_rows() const { return (rows() + 7u) >> 3u; } - u32 superblock_columns() const { return (columns() + 7u) >> 3u; } + u32 superblock_rows() const { return blocks_to_superblocks(rows() + 7u); } + u32 superblock_columns() const { return blocks_to_superblocks(columns() + 7u); } Vector2D const& block_contexts() const { return m_block_contexts; } diff --git a/Userland/Libraries/LibVideo/VP9/Utilities.h b/Userland/Libraries/LibVideo/VP9/Utilities.h index 1fd3f891a6..516256285b 100644 --- a/Userland/Libraries/LibVideo/VP9/Utilities.h +++ b/Userland/Libraries/LibVideo/VP9/Utilities.h @@ -60,6 +60,18 @@ 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_superblocks(T blocks) +{ + return blocks >> 3; +} + +template +inline T superblocks_to_blocks(T superblocks) +{ + return superblocks << 3; +} + template inline T blocks_to_sub_blocks(T blocks) { -- cgit v1.2.3