Commit 744a2365 authored by Romain Vimont's avatar Romain Vimont Committed by Thomas Daede

Use tiling structures

Encode the frame as a single tile using the new tiling structures.
parent 52a01a3f
......@@ -48,6 +48,7 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
let mut fb = FrameBlocks::new(fi.sb_width * 16, fi.sb_height * 16);
let bc = BlockContext::new(&mut fb);
let mut fs = FrameState::new(&fi);
let mut ts = fs.as_tile_state_mut();
// For now, restoration unit size is locked to superblock size.
let mut cw = ContextWriter::new(&mut fc, bc);
......@@ -61,7 +62,7 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
for &mode in RAV1E_INTRA_MODES {
let sbo = SuperBlockOffset { x: sbx, y: sby };
for p in 1..3 {
fs.qc.update(fi.base_q_idx, tx_size, mode.is_intra(), 8, fi.dc_delta_q[p], fi.ac_delta_q[p]);
ts.qc.update(fi.base_q_idx, tx_size, mode.is_intra(), 8, fi.dc_delta_q[p], fi.ac_delta_q[p]);
for by in 0..8 {
for bx in 0..8 {
// For ex, 8x8 tx should be applied to even numbered (bx,by)
......@@ -72,10 +73,10 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
};
let bo = sbo.block_offset(bx, by);
let tx_bo = BlockOffset { x: bo.x + bx, y: bo.y + by };
let po = tx_bo.plane_offset(&fs.input.planes[p].cfg);
let po = tx_bo.plane_offset(&ts.input.planes[p].cfg);
encode_tx_block(
&mut fi,
&mut fs,
&mut ts,
&mut cw,
&mut w,
p,
......@@ -145,8 +146,9 @@ fn cfl_rdo_bench(b: &mut Bencher, bsize: BlockSize) {
let sequence = Sequence::new(&Default::default());
let fi = FrameInvariants::<u16>::new(config, sequence);
let mut fs = FrameState::new(&fi);
let mut ts = fs.as_tile_state_mut();
let offset = BlockOffset { x: 1, y: 1 };
b.iter(|| rdo_cfl_alpha(&mut fs, offset, bsize, fi.sequence.bit_depth))
b.iter(|| rdo_cfl_alpha(&mut ts, offset, bsize, fi.sequence.bit_depth))
}
fn ec_bench(c: &mut Criterion) {
......
......@@ -41,10 +41,9 @@ fn run_sad_bench<T: Pixel>(b: &mut Bencher, &(bs, bit_depth): &(BlockSize, usize
let h = 480;
let input_plane = new_plane::<T>(&mut ra, w, h);
let rec_plane = new_plane::<T>(&mut ra, w, h);
let po = PlaneOffset { x: 0, y: 0 };
let plane_org = input_plane.slice(po);
let plane_ref = rec_plane.slice(po);
let plane_org = input_plane.as_region();
let plane_ref = rec_plane.as_region();
b.iter(|| {
let _ =
......
......@@ -88,7 +88,7 @@ pub fn intra_dc_4x4(b: &mut Bencher) {
let (mut block, above, left) = generate_block(&mut rng);
b.iter(|| {
Block4x4::pred_dc(&mut block.as_mut_slice(), &above[..4], &left[..4]);
Block4x4::pred_dc(&mut block.as_region_mut(), &above[..4], &left[..4]);
})
}
......@@ -98,7 +98,7 @@ pub fn intra_dc_left_4x4(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_dc_left(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[..4]
);
......@@ -111,7 +111,7 @@ pub fn intra_dc_top_4x4(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_dc_top(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[..4]
);
......@@ -123,7 +123,7 @@ pub fn intra_h_4x4(b: &mut Bencher) {
let (mut block, _above, left) = generate_block(&mut rng);
b.iter(|| {
Block4x4::pred_h(&mut block.as_mut_slice(), &left[..4]);
Block4x4::pred_h(&mut block.as_region_mut(), &left[..4]);
})
}
......@@ -132,7 +132,7 @@ pub fn intra_v_4x4(b: &mut Bencher) {
let (mut block, above, _left) = generate_block(&mut rng);
b.iter(|| {
Block4x4::pred_v(&mut block.as_mut_slice(), &above[..4]);
Block4x4::pred_v(&mut block.as_region_mut(), &above[..4]);
})
}
......@@ -143,7 +143,7 @@ pub fn intra_paeth_4x4(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_paeth(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[..4],
above_left
......@@ -157,7 +157,7 @@ pub fn intra_smooth_4x4(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_smooth(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[..4]
);
......@@ -170,7 +170,7 @@ pub fn intra_smooth_h_4x4(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_smooth_h(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[..4]
);
......@@ -183,7 +183,7 @@ pub fn intra_smooth_v_4x4(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_smooth_v(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[..4]
);
......@@ -198,7 +198,7 @@ pub fn intra_cfl_4x4(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_cfl(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&ac,
alpha,
8,
......@@ -215,7 +215,7 @@ pub fn intra_dc_4x4_u8(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_dc(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[32 - 4..]
);
......@@ -228,7 +228,7 @@ pub fn intra_dc_128_4x4_u8(b: &mut Bencher) {
let (mut block, _above, _left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_dc_128(&mut block.as_mut_slice(), 8);
Block4x4::pred_dc_128(&mut block.as_region_mut(), 8);
})
}
......@@ -239,7 +239,7 @@ pub fn intra_dc_left_4x4_u8(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_dc_left(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[32 - 4..]
);
......@@ -253,7 +253,7 @@ pub fn intra_dc_top_4x4_u8(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_dc_top(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[32 - 4..]
);
......@@ -266,7 +266,7 @@ pub fn intra_h_4x4_u8(b: &mut Bencher) {
let (mut block, _above, left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_h(&mut block.as_mut_slice(), &left[32 - 4..]);
Block4x4::pred_h(&mut block.as_region_mut(), &left[32 - 4..]);
})
}
......@@ -276,7 +276,7 @@ pub fn intra_v_4x4_u8(b: &mut Bencher) {
let (mut block, above, _left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_v(&mut block.as_mut_slice(), &above[..4]);
Block4x4::pred_v(&mut block.as_region_mut(), &above[..4]);
})
}
......@@ -288,7 +288,7 @@ pub fn intra_paeth_4x4_u8(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_paeth(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[32 - 4..],
above_left
......@@ -303,7 +303,7 @@ pub fn intra_smooth_4x4_u8(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_smooth(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[32 - 4..]
);
......@@ -317,7 +317,7 @@ pub fn intra_smooth_h_4x4_u8(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_smooth_h(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[32 - 4..]
);
......@@ -331,7 +331,7 @@ pub fn intra_smooth_v_4x4_u8(b: &mut Bencher) {
b.iter(|| {
Block4x4::pred_smooth_v(
&mut block.as_mut_slice(),
&mut block.as_region_mut(),
&above[..4],
&left[32 - 4..]
);
......
......@@ -3194,7 +3194,7 @@ impl<'a> ContextWriter<'a> {
}
// rather than test writing and rolling back the cdf, we just count Q8 bits using the current cdf
pub fn count_lrf_switchable(&mut self, w: &dyn Writer, rs: &RestorationState,
pub fn count_lrf_switchable(&mut self, w: &dyn Writer, rs: &TileRestorationState,
filter: RestorationFilter, pli: usize) -> u32 {
let nsym = &self.fc.lrf_switchable_cdf.len()-1;
match filter {
......@@ -3224,7 +3224,7 @@ impl<'a> ContextWriter<'a> {
}
pub fn write_lrf<T: Pixel>(
&mut self, w: &mut dyn Writer, fi: &FrameInvariants<T>, rs: &mut RestorationState, sbo: SuperBlockOffset
&mut self, w: &mut dyn Writer, fi: &FrameInvariants<T>, rs: &mut TileRestorationStateMut, sbo: SuperBlockOffset
) {
if !fi.allow_intrabc { // TODO: also disallow if lossless
for pli in 0..PLANES {
......@@ -3232,7 +3232,7 @@ impl<'a> ContextWriter<'a> {
if let Some(filter) = rp.restoration_unit(sbo).map(|ru| ru.filter) {
match filter {
RestorationFilter::None => {
match rp.cfg.lrf_type {
match rp.rp_cfg.lrf_type {
RESTORE_WIENER => {
symbol_with_update!(self, w, 0, &mut self.fc.lrf_wiener_cdf);
}
......@@ -3247,7 +3247,7 @@ impl<'a> ContextWriter<'a> {
}
}
RestorationFilter::Sgrproj{set, xqd} => {
match rp.cfg.lrf_type {
match rp.rp_cfg.lrf_type {
RESTORE_SGRPROJ => {
symbol_with_update!(self, w, 1, &mut self.fc.lrf_sgrproj_cdf);
}
......@@ -3278,7 +3278,7 @@ impl<'a> ContextWriter<'a> {
}
}
RestorationFilter::Wiener{coeffs} => {
match rp.cfg.lrf_type {
match rp.rp_cfg.lrf_type {
RESTORE_WIENER => {
symbol_with_update!(self, w, 1, &mut self.fc.lrf_wiener_cdf);
}
......
This diff is collapsed.
......@@ -12,6 +12,7 @@ pub use self::nasm::*;
#[cfg(any(not(target_arch = "x86_64"), not(feature = "nasm")))]
pub use self::native::*;
use crate::tiling::*;
use crate::util::Pixel;
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
......@@ -250,17 +251,17 @@ mod nasm {
}
pub fn put_8tap<T: Pixel>(
dst: &mut PlaneMutSlice<'_, T>, src: PlaneSlice<'_, T>, width: usize,
dst: &mut PlaneRegionMut<'_, T>, src: PlaneSlice<'_, T>, width: usize,
height: usize, col_frac: i32, row_frac: i32, mode_x: FilterMode,
mode_y: FilterMode, bit_depth: usize
) {
if mem::size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
debug_assert!(bit_depth == 8);
let dst_stride = dst.plane.cfg.stride as isize;
let dst_stride = dst.plane_cfg.stride as isize;
let src_stride = src.plane.cfg.stride as isize;
unsafe {
select_put_fn_avx2(mode_x, mode_y)(
dst.as_mut_ptr() as *mut _,
dst.data_ptr_mut() as *mut _,
dst_stride,
src.as_ptr() as *const _,
src_stride,
......@@ -304,15 +305,15 @@ mod nasm {
}
pub fn mc_avg<T: Pixel>(
dst: &mut PlaneMutSlice<'_, T>, tmp1: &[i16], tmp2: &[i16], width: usize,
dst: &mut PlaneRegionMut<'_, T>, tmp1: &[i16], tmp2: &[i16], width: usize,
height: usize, bit_depth: usize
) {
if mem::size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
debug_assert!(bit_depth == 8);
let dst_stride = dst.plane.cfg.stride as isize;
let dst_stride = dst.plane_cfg.stride as isize;
unsafe {
rav1e_avg_avx2(
dst.as_mut_ptr() as *mut _,
dst.data_ptr_mut() as *mut _,
dst_stride,
tmp1.as_ptr(),
tmp2.as_ptr(),
......@@ -357,7 +358,7 @@ mod native {
}
pub fn put_8tap<T: Pixel>(
dst: &mut PlaneMutSlice<'_, T>, src: PlaneSlice<'_, T>, width: usize,
dst: &mut PlaneRegionMut<'_, T>, src: PlaneSlice<'_, T>, width: usize,
height: usize, col_frac: i32, row_frac: i32, mode_x: FilterMode,
mode_y: FilterMode, bit_depth: usize
) {
......@@ -522,7 +523,7 @@ mod native {
}
pub fn mc_avg<T: Pixel>(
dst: &mut PlaneMutSlice<'_, T>, tmp1: &[i16], tmp2: &[i16], width: usize,
dst: &mut PlaneRegionMut<'_, T>, tmp1: &[i16], tmp2: &[i16], width: usize,
height: usize, bit_depth: usize
) {
let max_sample_val = ((1 << bit_depth) - 1) as i32;
......
This diff is collapsed.
......@@ -18,6 +18,7 @@ use crate::encoder::FrameInvariants;
use crate::mc::*;
use crate::plane::*;
use crate::predict::*;
use crate::tiling::*;
use crate::util::*;
// LAST_FRAME through ALTREF_FRAME correspond to slots 0-6.
......@@ -851,14 +852,13 @@ pub enum MvJointType {
}
pub fn get_intra_edges<T: Pixel>(
dst: &Plane<T>,
dst: &PlaneRegion<'_, T>,
po: PlaneOffset,
tx_size: TxSize,
bit_depth: usize,
opt_mode: Option<PredictionMode>
) -> AlignedArray<[T; 4 * MAX_TX_SIZE + 1]> {
let plane_cfg = &dst.cfg;
let dst = dst.as_slice();
let plane_cfg = &dst.plane_cfg;
let mut edge_buf: AlignedArray<[T; 4 * MAX_TX_SIZE + 1]> =
UninitializedAlignedArray();
......@@ -952,7 +952,7 @@ pub fn get_intra_edges<T: Pixel>(
);
let num_avail = if y != 0 && has_tr(bo, bsize) {
tx_size.width().min(plane_cfg.width - x - tx_size.width())
tx_size.width().min(dst.rect().width - x - tx_size.width())
} else {
0
};
......@@ -983,7 +983,7 @@ pub fn get_intra_edges<T: Pixel>(
);
let num_avail = if x != 0 && has_bl(bo, bsize) {
tx_size.height().min(plane_cfg.height - y - tx_size.height())
tx_size.height().min(dst.rect().height - y - tx_size.height())
} else {
0
};
......@@ -1009,7 +1009,7 @@ pub fn get_intra_edges<T: Pixel>(
impl PredictionMode {
pub fn predict_intra<T: Pixel>(
self, dst: &mut PlaneMutSlice<'_, T>, tx_size: TxSize, bit_depth: usize,
self, dst: &mut PlaneRegionMut<'_, T>, tx_size: TxSize, bit_depth: usize,
ac: &[i16], alpha: i16, edge_buf: &AlignedArray<[T; 4 * MAX_TX_SIZE + 1]>
) {
assert!(self.is_intra());
......@@ -1060,15 +1060,14 @@ impl PredictionMode {
#[inline(always)]
fn predict_intra_inner<B: Intra<T>, T: Pixel>(
self, dst: &mut PlaneMutSlice<'_, T>, bit_depth: usize, ac: &[i16],
self, dst: &mut PlaneRegionMut<'_, T>, bit_depth: usize, ac: &[i16],
alpha: i16, edge_buf: &AlignedArray<[T; 4 * MAX_TX_SIZE + 1]>
) {
// left pixels are order from bottom to top and right-aligned
let (left, not_left) = edge_buf.array.split_at(2*MAX_TX_SIZE);
let (top_left, above) = not_left.split_at(1);
let x = dst.x;
let y = dst.y;
let &Rect { x, y, .. } = dst.rect();
let mode: PredictionMode = match self {
PredictionMode::PAETH_PRED => match (x, y) {
......@@ -1164,10 +1163,11 @@ impl PredictionMode {
pub fn predict_inter<T: Pixel>(
self, fi: &FrameInvariants<T>, p: usize, po: PlaneOffset,
dst: &mut PlaneMutSlice<'_, T>, width: usize, height: usize,
dst: &mut PlaneRegionMut<'_, T>, width: usize, height: usize,
ref_frames: [RefType; 2], mvs: [MotionVector; 2]
) {
assert!(!self.is_intra());
let frame_po = dst.to_frame_plane_offset(po);
let mode = FilterMode::REGULAR;
let is_compound =
......@@ -1194,7 +1194,7 @@ impl PredictionMode {
if !is_compound {
if let Some(ref rec) = fi.rec_buffer.frames[fi.ref_frames[ref_frames[0].to_index()] as usize] {
let (row_frac, col_frac, src) = get_params(&rec.frame.planes[p], po, mvs[0]);
let (row_frac, col_frac, src) = get_params(&rec.frame.planes[p], frame_po, mvs[0]);
put_8tap(
dst,
src,
......@@ -1212,7 +1212,7 @@ impl PredictionMode {
[UninitializedAlignedArray(), UninitializedAlignedArray()];
for i in 0..2 {
if let Some(ref rec) = fi.rec_buffer.frames[fi.ref_frames[ref_frames[i].to_index()] as usize] {
let (row_frac, col_frac, src) = get_params(&rec.frame.planes[p], po, mvs[i]);
let (row_frac, col_frac, src) = get_params(&rec.frame.planes[p], frame_po, mvs[i]);
prep_8tap(
&mut tmp[i].array,
src,
......
This diff is collapsed.
This diff is collapsed.
......@@ -16,7 +16,6 @@ pub use self::native::*;
use super::*;
use crate::partition::TxType;
use crate::plane::PlaneMutSlice;
static COSPI_INV: [i32; 64] = [
4096, 4095, 4091, 4085, 4076, 4065, 4052, 4036, 4017, 3996, 3973, 3948,
......@@ -1518,7 +1517,7 @@ mod nasm {
fn match_tx_type(tx_type: TxType) -> InvTxfmFunc;
fn inv_txfm2d_add<T>(
input: &[i32], output: &mut PlaneMutSlice<'_, T>, tx_type: TxType,
input: &[i32], output: &mut PlaneRegionMut<'_, T>, tx_type: TxType,
bd: usize
) where
T: Pixel,
......@@ -1540,11 +1539,11 @@ mod nasm {
}
}
let stride = output.plane.cfg.stride as isize;
let stride = output.plane_cfg.stride as isize;
unsafe {
// perform the inverse transform
Self::match_tx_type(tx_type)(
output.as_mut_ptr() as *mut _,
output.data_ptr_mut() as *mut _,
stride,
coeff16.array.as_ptr(),
(coeff_w * coeff_h) as i32
......@@ -1661,7 +1660,7 @@ mod native {
const INTERMEDIATE_SHIFT: usize;
fn inv_txfm2d_add<T: Pixel>(
input: &[i32], output: &mut PlaneMutSlice<'_, T>, tx_type: TxType,
input: &[i32], output: &mut PlaneRegionMut<'_, T>, tx_type: TxType,
bd: usize
) where
T: Pixel,
......@@ -1756,7 +1755,7 @@ macro_rules! impl_iht_fns {
$(
paste::item! {
pub fn [<iht $W x $H _add>]<T: Pixel>(
input: &[i32], output: &mut PlaneMutSlice<'_, T>, tx_type: TxType,
input: &[i32], output: &mut PlaneRegionMut<'_, T>, tx_type: TxType,
bit_depth: usize
) where
T: Pixel,
......
......@@ -11,8 +11,8 @@ pub use self::forward::*;
pub use self::inverse::*;
use crate::partition::{TxSize, TxType, TX_TYPES};
use crate::plane::PlaneMutSlice;
use crate::predict::*;
use crate::tiling::*;
use crate::util::*;
mod forward;
......@@ -174,7 +174,7 @@ pub fn forward_transform(
}
pub fn inverse_transform_add<T: Pixel>(
input: &[i32], output: &mut PlaneMutSlice<'_, T>, tx_size: TxSize,
input: &[i32], output: &mut PlaneRegionMut<'_, T>, tx_size: TxSize,
tx_type: TxType, bit_depth: usize
) {
use self::TxSize::*;
......@@ -223,7 +223,7 @@ mod test {
*r = i16::cast_from(*s) - i16::cast_from(*d);
}
forward_transform(res, freq, tx_size.width(), tx_size, tx_type, 8);
inverse_transform_add(freq, &mut dst.as_mut_slice(), tx_size, tx_type, 8);
inverse_transform_add(freq, &mut dst.as_region_mut(), tx_size, tx_type, 8);
for (s, d) in src.iter().zip(dst.data.iter()) {
assert!(i16::abs(i16::cast_from(*s) - i16::cast_from(*d)) <= tolerance);
......
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