Commit c7693dbb authored by Raphaël Zumer's avatar Raphaël Zumer
Browse files

Move get_plane_block_size() to BlockSize::subsampled_size()

parent 940dc37d
......@@ -168,38 +168,6 @@ pub static sub_tx_size_map: [TxSize; TxSize::TX_SIZES_ALL] = [
TX_32X16, // TX_64X16
];
static ss_size_lookup: [[[BlockSize; 2]; 2]; BlockSize::BLOCK_SIZES_ALL] = [
// ss_x == 0 ss_x == 0 ss_x == 1 ss_x == 1
// ss_y == 0 ss_y == 1 ss_y == 0 ss_y == 1
[ [ BLOCK_4X4, BLOCK_4X4 ], [BLOCK_4X4, BLOCK_4X4 ] ],
[ [ BLOCK_4X8, BLOCK_4X4 ], [BLOCK_4X4, BLOCK_4X4 ] ],
[ [ BLOCK_8X4, BLOCK_4X4 ], [BLOCK_4X4, BLOCK_4X4 ] ],
[ [ BLOCK_8X8, BLOCK_8X4 ], [BLOCK_4X8, BLOCK_4X4 ] ],
[ [ BLOCK_8X16, BLOCK_8X8 ], [BLOCK_4X16, BLOCK_4X8 ] ],
[ [ BLOCK_16X8, BLOCK_16X4 ], [BLOCK_8X8, BLOCK_8X4 ] ],
[ [ BLOCK_16X16, BLOCK_16X8 ], [BLOCK_8X16, BLOCK_8X8 ] ],
[ [ BLOCK_16X32, BLOCK_16X16 ], [BLOCK_8X32, BLOCK_8X16 ] ],
[ [ BLOCK_32X16, BLOCK_32X8 ], [BLOCK_16X16, BLOCK_16X8 ] ],
[ [ BLOCK_32X32, BLOCK_32X16 ], [BLOCK_16X32, BLOCK_16X16 ] ],
[ [ BLOCK_32X64, BLOCK_32X32 ], [BLOCK_16X64, BLOCK_16X32 ] ],
[ [ BLOCK_64X32, BLOCK_64X16 ], [BLOCK_32X32, BLOCK_32X16 ] ],
[ [ BLOCK_64X64, BLOCK_64X32 ], [BLOCK_32X64, BLOCK_32X32 ] ],
[ [ BLOCK_64X128, BLOCK_64X64 ], [ BLOCK_INVALID, BLOCK_32X64 ] ],
[ [ BLOCK_128X64, BLOCK_INVALID ], [ BLOCK_64X64, BLOCK_64X32 ] ],
[ [ BLOCK_128X128, BLOCK_128X64 ], [ BLOCK_64X128, BLOCK_64X64 ] ],
[ [ BLOCK_4X16, BLOCK_4X8 ], [BLOCK_4X16, BLOCK_4X8 ] ],
[ [ BLOCK_16X4, BLOCK_16X4 ], [BLOCK_8X4, BLOCK_8X4 ] ],
[ [ BLOCK_8X32, BLOCK_8X16 ], [BLOCK_INVALID, BLOCK_4X16 ] ],
[ [ BLOCK_32X8, BLOCK_INVALID ], [BLOCK_16X8, BLOCK_16X4 ] ],
[ [ BLOCK_16X64, BLOCK_16X32 ], [BLOCK_INVALID, BLOCK_8X32 ] ],
[ [ BLOCK_64X16, BLOCK_INVALID ], [BLOCK_32X16, BLOCK_32X8 ] ]
];
pub fn get_plane_block_size(bsize: BlockSize, subsampling_x: usize, subsampling_y: usize)
-> BlockSize {
ss_size_lookup[bsize as usize][subsampling_x][subsampling_y]
}
// Generates 4 bit field in which each bit set to 1 represents
// a blocksize partition 1111 means we split 64x64, 32x32, 16x16
// and 8x8. 1000 means we just split the 64x64 to 32x32
......@@ -1538,7 +1506,7 @@ impl<'a> BlockContext<'a> {
let plane_bsize = if plane == 0 {
bsize
} else {
get_plane_block_size(bsize, xdec2, ydec2)
bsize.subsampled_size(xdec2, ydec2)
};
let bw = plane_bsize.width_mi();
let bh = plane_bsize.height_mi();
......
......@@ -1010,7 +1010,7 @@ pub fn motion_compensate<T: Pixel>(
let luma_tile_rect = ts.tile_rect();
for p in 0..num_planes {
let plane_bsize = if p == 0 { bsize }
else { get_plane_block_size(bsize, u_xdec, u_ydec) };
else { bsize.subsampled_size(u_xdec, u_ydec) };
let rec = &mut ts.rec.planes[p];
let po = tile_bo.plane_offset(&rec.plane_cfg);
......@@ -1278,7 +1278,7 @@ pub fn luma_ac<T: Pixel>(
ac: &mut [i16], ts: &mut TileStateMut<'_, T>, tile_bo: BlockOffset, bsize: BlockSize
) {
let PlaneConfig { xdec, ydec, .. } = ts.input.planes[1].cfg;
let plane_bsize = get_plane_block_size(bsize, xdec, ydec);
let plane_bsize = bsize.subsampled_size(xdec, ydec);
let bo = if bsize.is_sub8x8(xdec, ydec) {
let offset = bsize.sub8x8_offset(xdec, ydec);
tile_bo.with_offset(offset.0, offset.1)
......@@ -1367,7 +1367,7 @@ pub fn write_tx_blocks<T: Pixel>(
bw_uv /= uv_tx_size.width_mi();
bh_uv /= uv_tx_size.height_mi();
let plane_bsize = get_plane_block_size(bsize, xdec, ydec);
let plane_bsize = bsize.subsampled_size(xdec, ydec);
if chroma_mode.is_cfl() {
luma_ac(&mut ac.array, ts, tile_bo, bsize);
......@@ -1456,7 +1456,7 @@ pub fn write_tx_tree<T: Pixel>(
bw_uv /= uv_tx_size.width_mi();
bh_uv /= uv_tx_size.height_mi();
let plane_bsize = get_plane_block_size(bsize, xdec, ydec);
let plane_bsize = bsize.subsampled_size(xdec, ydec);
if bw_uv > 0 && bh_uv > 0 {
// TODO: Disable these asserts temporarilly, since chroma_sampling_422_aom and chroma_sampling_444_aom
......
......@@ -236,8 +236,52 @@ impl BlockSize {
}
}
/// Source: Subsampled_Size (AV1 specification section 5.11.38)
pub fn subsampled_size(self, xdec: usize, ydec: usize) -> BlockSize {
match (xdec, ydec) {
(0, 0) /* 4:4:4 */ => self,
(1, 0) /* 4:2:2 */ => match self {
BLOCK_4X4 | BLOCK_8X4 => BLOCK_4X4,
BLOCK_8X8 => BLOCK_4X8,
BLOCK_16X4 => BLOCK_8X4,
BLOCK_16X8 => BLOCK_8X8,
BLOCK_16X16 => BLOCK_8X16,
BLOCK_32X8 => BLOCK_16X8,
BLOCK_32X16 => BLOCK_16X16,
BLOCK_32X32 => BLOCK_16X32,
BLOCK_64X16 => BLOCK_32X16,
BLOCK_64X32 => BLOCK_32X32,
BLOCK_64X64 => BLOCK_32X64,
BLOCK_128X64 => BLOCK_64X64,
BLOCK_128X128 => BLOCK_64X128,
_ => BLOCK_INVALID
},
(1, 1) /* 4:2:0 */ => match self {
BLOCK_4X4 | BLOCK_4X8 | BLOCK_8X4 | BLOCK_8X8 => BLOCK_4X4,
BLOCK_4X16 | BLOCK_8X16 => BLOCK_4X8,
BLOCK_8X32 => BLOCK_4X16,
BLOCK_16X4 | BLOCK_16X8 => BLOCK_8X4,
BLOCK_16X16 => BLOCK_8X8,
BLOCK_16X32 => BLOCK_8X16,
BLOCK_16X64 => BLOCK_8X32,
BLOCK_32X8 => BLOCK_16X4,
BLOCK_32X16 => BLOCK_16X8,
BLOCK_32X32 => BLOCK_16X16,
BLOCK_32X64 => BLOCK_16X32,
BLOCK_64X16 => BLOCK_32X8,
BLOCK_64X32 => BLOCK_32X16,
BLOCK_64X64 => BLOCK_32X32,
BLOCK_64X128 => BLOCK_32X64,
BLOCK_128X64 => BLOCK_64X32,
BLOCK_128X128 => BLOCK_64X64,
_ => BLOCK_INVALID
},
_ => unreachable!()
}
}
pub fn largest_chroma_tx_size(self, xdec: usize, ydec: usize) -> TxSize {
let plane_bsize = get_plane_block_size(self, xdec, ydec);
let plane_bsize = self.subsampled_size(xdec, ydec);
let uv_tx = max_txsize_rect_lookup[plane_bsize as usize];
av1_get_coded_tx_size(uv_tx)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment