summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorZaggy1024 <zaggy1024@gmail.com>2022-11-28 05:10:39 -0600
committerAndreas Kling <kling@serenityos.org>2022-11-30 08:28:30 +0100
commit720fc5a853dc768b1d2956f95eadf96761082830 (patch)
treef9ec0dd770a05e4ff38dfc8963d98ca773f2ee22 /Userland
parent1fe22f21410509c680700bfe66a83d3021a94804 (diff)
downloadserenity-720fc5a853dc768b1d2956f95eadf96761082830.zip
LibVideo/VP9: Use unit conversion functions in BlockContext
This should make things in there seem a little less magical :^)
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibVideo/VP9/Context.h8
-rw-r--r--Userland/Libraries/LibVideo/VP9/Utilities.h12
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<FrameBlockContext> 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
@@ -61,6 +61,18 @@ inline Gfx::Size<u8> block_size_to_sub_blocks(BlockSubsize size)
}
template<Integral T>
+inline T blocks_to_superblocks(T blocks)
+{
+ return blocks >> 3;
+}
+
+template<Integral T>
+inline T superblocks_to_blocks(T superblocks)
+{
+ return superblocks << 3;
+}
+
+template<Integral T>
inline T blocks_to_sub_blocks(T blocks)
{
return blocks << 1;