From b1c7bbc4ba05d3acb6388db2a74868c92d0d49ec Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Mon, 28 Nov 2022 09:04:58 -0600 Subject: LibVideo/VP9: Make get_tile_offset static and remove magic numbers This can use the new utility functions for converting units now. --- Userland/Libraries/LibVideo/VP9/Parser.cpp | 14 +++++++------- Userland/Libraries/LibVideo/VP9/Parser.h | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibVideo/VP9/Parser.cpp b/Userland/Libraries/LibVideo/VP9/Parser.cpp index ae60ae8f0c..7e073a0e53 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.cpp +++ b/Userland/Libraries/LibVideo/VP9/Parser.cpp @@ -845,6 +845,13 @@ DecoderErrorOr Parser::update_mv_prob(u8 prob) return prob; } +static u32 get_tile_offset(u32 tile_start, u32 frame_size_in_blocks, u32 tile_size_log2) +{ + u32 superblocks = blocks_ceiled_to_superblocks(frame_size_in_blocks); + u32 offset = superblocks_to_blocks((tile_start * superblocks) >> tile_size_log2); + return min(offset, frame_size_in_blocks); +} + DecoderErrorOr Parser::decode_tiles(FrameContext& frame_context) { auto log2_dimensions = frame_context.log2_of_tile_counts; @@ -888,13 +895,6 @@ DecoderErrorOr Parser::decode_tiles(FrameContext& frame_context) return {}; } -u32 Parser::get_tile_offset(u32 tile_num, u32 mis, u32 tile_size_log2) -{ - u32 super_blocks = (mis + 7) >> 3u; - u32 offset = ((tile_num * super_blocks) >> tile_size_log2) << 3u; - return min(offset, mis); -} - DecoderErrorOr Parser::decode_tile(TileContext& tile_context) { for (auto row = tile_context.rows_start; row < tile_context.rows_end; row += 8) { diff --git a/Userland/Libraries/LibVideo/VP9/Parser.h b/Userland/Libraries/LibVideo/VP9/Parser.h index f22b77417e..768a150c48 100644 --- a/Userland/Libraries/LibVideo/VP9/Parser.h +++ b/Userland/Libraries/LibVideo/VP9/Parser.h @@ -92,7 +92,6 @@ private: /* (6.4) Decode Tiles Syntax */ DecoderErrorOr decode_tiles(FrameContext&); - u32 get_tile_offset(u32 tile_num, u32 mis, u32 tile_size_log2); DecoderErrorOr decode_tile(TileContext&); void clear_left_context(TileContext&); DecoderErrorOr decode_partition(TileContext&, u32 row, u32 column, BlockSubsize subsize); -- cgit v1.2.3