Commit 701b1b11 authored by Yushin Cho's avatar Yushin Cho Committed by Yushin Cho

Add max_txsize_rect_lookup[] table, and rewrite largest_uv_tx_size() based on it

parent a74b0084
......@@ -143,7 +143,7 @@ fn cfl_rdo_bench(b: &mut Bencher, bsize: BlockSize) {
let fi = FrameInvariants::<u16>::new(config, sequence);
let mut fs = FrameState::new(&fi);
let offset = BlockOffset { x: 1, y: 1 };
b.iter(|| rdo_cfl_alpha(&mut fs, offset, bsize, fi.sequence.bit_depth, fi.sequence.chroma_sampling))
b.iter(|| rdo_cfl_alpha(&mut fs, offset, bsize, fi.sequence.bit_depth))
}
criterion_group!(intra_prediction, predict::pred_bench,);
......
......@@ -120,6 +120,29 @@ static av1_tx_ind: [[usize; TX_TYPES]; TX_SETS] = [
[7, 8, 9, 12, 10, 11, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6]
];
pub static max_txsize_rect_lookup: [TxSize; BlockSize::BLOCK_SIZES_ALL] = [
// 4X4
TX_4X4,
// 4X8, 8X4, 8X8
TX_4X8, TX_8X4, TX_8X8,
// 8X16, 16X8, 16X16
TX_8X16, TX_16X8, TX_16X16,
// 16X32, 32X16, 32X32
TX_16X32, TX_32X16, TX_32X32,
// 32X64, 64X32,
TX_32X64, TX_64X32,
// 64X64
TX_64X64,
// 64x128, 128x64, 128x128
TX_64X64, TX_64X64, TX_64X64,
// 4x16, 16x4,
TX_4X16, TX_16X4,
// 8x32, 32x8
TX_8X32, TX_32X8,
// 16x64, 64x16
TX_16X64, 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
......
......@@ -1370,7 +1370,7 @@ pub fn write_tx_blocks<T: Pixel>(
if luma_only { return tx_dist };
let uv_tx_size = bsize.largest_uv_tx_size(fi.sequence.chroma_sampling);
let uv_tx_size = bsize.largest_uv_tx_size(xdec, ydec);
let mut bw_uv = (bw * tx_size.width_mi()) >> xdec;
let mut bh_uv = (bh * tx_size.height_mi()) >> ydec;
......@@ -1452,7 +1452,7 @@ pub fn write_tx_tree<T: Pixel>(
if luma_only { return tx_dist };
let uv_tx_size = bsize.largest_uv_tx_size(fi.sequence.chroma_sampling);
let uv_tx_size = bsize.largest_uv_tx_size(xdec, ydec);
let mut bw_uv = (bw * tx_size.width_mi()) >> xdec;
let mut bh_uv = (bh * tx_size.height_mi()) >> ydec;
......
......@@ -13,7 +13,6 @@
use std::ops;
use self::BlockSize::*;
use self::TxSize::*;
use crate::api::ChromaSampling;
use crate::context::*;
use crate::encoder::FrameInvariants;
use crate::mc::*;
......@@ -193,47 +192,12 @@ impl BlockSize {
}
}
pub fn largest_uv_tx_size(self, chroma_sampling: ChromaSampling) -> TxSize {
match chroma_sampling {
ChromaSampling::Cs444 => match self {
BLOCK_64X64 | BLOCK_64X32 | BLOCK_32X64 |
BLOCK_128X128 | BLOCK_128X64 | BLOCK_64X128 => TX_32X32,
BLOCK_64X16 => TX_32X16,
BLOCK_16X64 => TX_16X32,
_ => self.tx_size()
},
ChromaSampling::Cs422 => match self {
BLOCK_4X4 | BLOCK_8X4 => TX_4X4,
BLOCK_8X8 => TX_4X8,
BLOCK_16X8 => TX_8X8,
BLOCK_16X16 => TX_8X16,
BLOCK_32X16 => TX_16X16,
BLOCK_32X32 => TX_16X32,
BLOCK_64X32 | BLOCK_64X64 |
BLOCK_128X64 | BLOCK_128X128 => TX_32X32,
BLOCK_16X4 => TX_8X4,
BLOCK_32X8 => TX_16X8,
BLOCK_64X16 => TX_32X16,
_ => unreachable!() // vertical splits are illegal in 4:2:2
},
ChromaSampling::Cs420 => match self {
BLOCK_4X4 | BLOCK_8X4 | BLOCK_4X8 | BLOCK_8X8 => TX_4X4,
BLOCK_8X16 | BLOCK_4X16 => TX_4X8,
BLOCK_16X8 | BLOCK_16X4 => TX_8X4,
BLOCK_16X16 => TX_8X8,
BLOCK_16X32 => TX_8X16,
BLOCK_32X16 => TX_16X8,
BLOCK_32X32 => TX_16X16,
BLOCK_32X64 => TX_16X32,
BLOCK_64X32 => TX_32X16,
BLOCK_8X32 => TX_4X16,
BLOCK_32X8 => TX_16X4,
BLOCK_16X64 => TX_8X32,
BLOCK_64X16 => TX_32X8,
_ => TX_32X32
}
ChromaSampling::Cs400 => unimplemented!()
}
pub fn largest_uv_tx_size(self, xdec: usize, ydec: usize) -> TxSize {
let plane_bsize = get_plane_block_size(self, xdec, ydec);
debug_assert!((plane_bsize as usize) < BlockSize::BLOCK_SIZES_ALL);
let uv_tx = max_txsize_rect_lookup[plane_bsize as usize];
av1_get_coded_tx_size(uv_tx)
}
pub fn is_sqr(self) -> bool {
......
......@@ -818,7 +818,7 @@ pub fn rdo_mode_decision<T: Pixel>(
false
);
cw.rollback(&cw_checkpoint);
if let Some(cfl) = rdo_cfl_alpha(fs, bo, bsize, fi.sequence.bit_depth, fi.sequence.chroma_sampling) {
if let Some(cfl) = rdo_cfl_alpha(fs, bo, bsize, fi.sequence.bit_depth) {
let wr: &mut dyn Writer = &mut WriterCounter::new();
let tell = wr.tell_frac();
......@@ -890,10 +890,10 @@ pub fn rdo_mode_decision<T: Pixel>(
}
pub fn rdo_cfl_alpha<T: Pixel>(
fs: &mut FrameState<T>, bo: BlockOffset, bsize: BlockSize, bit_depth: usize,
chroma_sampling: ChromaSampling
fs: &mut FrameState<T>, bo: BlockOffset, bsize: BlockSize, bit_depth: usize
) -> Option<CFLParams> {
let uv_tx_size = bsize.largest_uv_tx_size(chroma_sampling);
let PlaneConfig { xdec, ydec, .. } = fs.input.planes[1].cfg;
let uv_tx_size = bsize.largest_uv_tx_size(xdec, ydec);
let mut ac: AlignedArray<[i16; 32 * 32]> = UninitializedAlignedArray();
luma_ac(&mut ac.array, fs, bo, bsize);
......
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