Refactor max_blocks_wide/high computation
Factor common codes that show up in multiple places.
Change-Id: I0a72213a151f74bdad926d59f86f0a28d00968fc
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index f515786..30ddde8 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -678,6 +678,30 @@
return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
}
+static INLINE int max_block_wide(const MACROBLOCKD *xd, const BLOCK_SIZE bsize,
+ const int plane) {
+ int max_blocks_wide = block_size_wide[bsize];
+ const struct macroblockd_plane *const pd = &xd->plane[plane];
+
+ if (xd->mb_to_right_edge < 0)
+ max_blocks_wide += xd->mb_to_right_edge >> (3 + pd->subsampling_x);
+
+ // Scale the width in the transform block unit.
+ return max_blocks_wide >> tx_size_wide_log2[0];
+}
+
+static INLINE int max_block_high(const MACROBLOCKD *xd, const BLOCK_SIZE bsize,
+ const int plane) {
+ int max_blocks_high = block_size_high[bsize];
+ const struct macroblockd_plane *const pd = &xd->plane[plane];
+
+ if (xd->mb_to_bottom_edge < 0)
+ max_blocks_high += xd->mb_to_bottom_edge >> (3 + pd->subsampling_y);
+
+ // Scale the width in the transform block unit.
+ return max_blocks_high >> tx_size_wide_log2[0];
+}
+
static INLINE void av1_zero_above_context(AV1_COMMON *const cm,
int mi_col_start, int mi_col_end) {
const int width = mi_col_end - mi_col_start;