Commit b84bee75 authored by Michael Bebenita's avatar Michael Bebenita

Move subsize lookup into BlockSize.

parent 748f622a
......@@ -197,181 +197,6 @@ static size_group_lookup: [u8; BlockSize::BLOCK_SIZES_ALL] = [
static num_pels_log2_lookup: [u8; BlockSize::BLOCK_SIZES_ALL] = [
4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 13, 13, 14, 6, 6, 8, 8, 10, 10];
pub static subsize_lookup: [[BlockSize; BlockSize::BLOCK_SIZES_ALL]; EXT_PARTITION_TYPES] =
[
[ // PARTITION_NONE
// 4X4
BLOCK_4X4,
// 4X8, 8X4, 8X8
BLOCK_4X8, BLOCK_8X4, BLOCK_8X8,
// 8X16, 16X8, 16X16
BLOCK_8X16, BLOCK_16X8, BLOCK_16X16,
// 16X32, 32X16, 32X32
BLOCK_16X32, BLOCK_32X16, BLOCK_32X32,
// 32X64, 64X32, 64X64
BLOCK_32X64, BLOCK_64X32, BLOCK_64X64,
// 64x128, 128x64, 128x128
BLOCK_64X128, BLOCK_128X64, BLOCK_128X128,
// 4X16, 16X4, 8X32
BLOCK_4X16, BLOCK_16X4, BLOCK_8X32,
// 32X8, 16X64, 64X16
BLOCK_32X8, BLOCK_16X64, BLOCK_64X16
], [ // PARTITION_HORZ
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_VERT
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_SPLIT
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X4,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X8,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X16,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X32,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X64,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_HORZ_A
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
], [ // PARTITION_HORZ_B
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_VERT_A
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_VERT_B
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_HORZ_4
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X4,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X8,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X16,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_VERT_4
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X16,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X32,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X64,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
]
];
pub const PLANE_TYPES: usize = 2;
const REF_TYPES: usize = 2;
pub const SKIP_CONTEXTS: usize = 3;
......
......@@ -1724,7 +1724,7 @@ fn encode_partition_bottomup(seq: &Sequence, fi: &FrameInvariants, fs: &mut Fram
w_post_cdef.rollback(&w_post_checkpoint);
partition = PartitionType::PARTITION_SPLIT;
subsize = get_subsize(bsize, partition);
subsize = bsize.subsize(partition);
let nosplit_rd_cost = rd_cost;
......@@ -1794,7 +1794,7 @@ fn encode_partition_bottomup(seq: &Sequence, fi: &FrameInvariants, fs: &mut Fram
}
}
subsize = get_subsize(bsize, partition);
subsize = bsize.subsize(partition);
if bsize >= BlockSize::BLOCK_8X8 &&
(bsize == BlockSize::BLOCK_8X8 || partition != PartitionType::PARTITION_SPLIT) {
......@@ -1843,7 +1843,7 @@ fn encode_partition_topdown(seq: &Sequence, fi: &FrameInvariants, fs: &mut Frame
partition < PartitionType::PARTITION_INVALID);
let hbs = bs >> 1; // Half the block size in blocks
let subsize = get_subsize(bsize, partition);
let subsize = bsize.subsize(partition);
let pmv = MotionVector { row: 0, col: 0 };
if bsize >= BlockSize::BLOCK_8X8 {
......
......@@ -148,6 +148,185 @@ impl BlockSize {
pub fn is_sub8x8(self) -> bool {
self.width_log2().min(self.height_log2()) < 3
}
const SUBSIZE_LOOKUP: [[BlockSize; BlockSize::BLOCK_SIZES_ALL]; EXT_PARTITION_TYPES] =
[
[ // PARTITION_NONE
// 4X4
BLOCK_4X4,
// 4X8, 8X4, 8X8
BLOCK_4X8, BLOCK_8X4, BLOCK_8X8,
// 8X16, 16X8, 16X16
BLOCK_8X16, BLOCK_16X8, BLOCK_16X16,
// 16X32, 32X16, 32X32
BLOCK_16X32, BLOCK_32X16, BLOCK_32X32,
// 32X64, 64X32, 64X64
BLOCK_32X64, BLOCK_64X32, BLOCK_64X64,
// 64x128, 128x64, 128x128
BLOCK_64X128, BLOCK_128X64, BLOCK_128X128,
// 4X16, 16X4, 8X32
BLOCK_4X16, BLOCK_16X4, BLOCK_8X32,
// 32X8, 16X64, 64X16
BLOCK_32X8, BLOCK_16X64, BLOCK_64X16
], [ // PARTITION_HORZ
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_VERT
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_SPLIT
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X4,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X8,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X16,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X32,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X64,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_HORZ_A
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
], [ // PARTITION_HORZ_B
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X4,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X16,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X32,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_128X64,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_VERT_A
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_VERT_B
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X8,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X32,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X64,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X128,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_HORZ_4
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X4,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_32X8,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_64X16,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
], [ // PARTITION_VERT_4
// 4X4
BLOCK_INVALID,
// 4X8, 8X4, 8X8
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 8X16, 16X8, 16X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X16,
// 16X32, 32X16, 32X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X32,
// 32X64, 64X32, 64X64
BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X64,
// 64x128, 128x64, 128x128
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 4X16, 16X4, 8X32
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID,
// 32X8, 16X64, 64X16
BLOCK_INVALID, BLOCK_INVALID, BLOCK_INVALID
]
];
pub fn subsize(self, partition: PartitionType) -> BlockSize {
BlockSize::SUBSIZE_LOOKUP[partition as usize][self as usize]
}
}
/// Transform Size
......@@ -884,7 +1063,3 @@ pub enum TxSet {
// Discrete Trig transforms w/ flip (9) + Identity (1) + 1D Hor/Ver (6)
TX_SET_ALL16
}
pub fn get_subsize(bsize: BlockSize, partition: PartitionType) -> BlockSize {
subsize_lookup[partition as usize][bsize as usize]
}
......@@ -661,7 +661,7 @@ pub fn rdo_partition_decision(
child_modes.push(mode_decision);
}
PartitionType::PARTITION_SPLIT => {
let subsize = get_subsize(bsize, partition);
let subsize = bsize.subsize(partition);
if subsize == BlockSize::BLOCK_INVALID {
continue;
......
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