Commit f9427c36 authored by Frank Bossen's avatar Frank Bossen Committed by fbossen

Add directional intra modes

parent 837d8ffa
...@@ -135,9 +135,9 @@ impl SpeedSettings { ...@@ -135,9 +135,9 @@ impl SpeedSettings {
} }
fn prediction_modes_preset(speed: usize) -> PredictionModesSetting { fn prediction_modes_preset(speed: usize) -> PredictionModesSetting {
if speed <= 1 { if speed <= 3 {
PredictionModesSetting::ComplexAll PredictionModesSetting::ComplexAll
} else if speed <= 3 { } else if speed <= 4 {
PredictionModesSetting::ComplexKeyframes PredictionModesSetting::ComplexKeyframes
} else { } else {
PredictionModesSetting::Simple PredictionModesSetting::Simple
......
...@@ -2028,63 +2028,6 @@ impl ContextWriter { ...@@ -2028,63 +2028,6 @@ impl ContextWriter {
} }
} }
fn has_tr(&mut self, bo: &BlockOffset, bsize: BlockSize) -> bool {
let sb_mi_size = BLOCK_64X64.width_mi(); /* Assume 64x64 for now */
let mask_row = bo.y & LOCAL_BLOCK_MASK;
let mask_col = bo.x & LOCAL_BLOCK_MASK;
let target_n4_w = bsize.width_mi();
let target_n4_h = bsize.height_mi();
let mut bs = target_n4_w.max(target_n4_h);
if bs > BLOCK_64X64.width_mi() {
return false;
}
let mut has_tr = !((mask_row & bs) != 0 && (mask_col & bs) != 0);
/* TODO: assert its a power of two */
while bs < sb_mi_size {
if (mask_col & bs) != 0 {
if (mask_col & (2 * bs) != 0) && (mask_row & (2 * bs) != 0) {
has_tr = false;
break;
}
} else {
break;
}
bs <<= 1;
}
/* The left hand of two vertical rectangles always has a top right (as the
* block above will have been decoded) */
if (target_n4_w < target_n4_h) && (bo.x & target_n4_w) == 0 {
has_tr = true;
}
/* The bottom of two horizontal rectangles never has a top right (as the block
* to the right won't have been decoded) */
if (target_n4_w > target_n4_h) && (bo.y & target_n4_h) != 0 {
has_tr = false;
}
/* The bottom left square of a Vertical A (in the old format) does
* not have a top right as it is decoded before the right hand
* rectangle of the partition */
/*
if blk.partition == PartitionType::PARTITION_VERT_A {
if blk.n4_w == blk.n4_h {
if (mask_row & bs) != 0 {
has_tr = false;
}
}
}
*/
has_tr
}
fn find_valid_col_offs(&mut self, col_offset: isize, mi_col: usize) -> isize { fn find_valid_col_offs(&mut self, col_offset: isize, mi_col: usize) -> isize {
cmp::max(col_offset, -(mi_col as isize)) cmp::max(col_offset, -(mi_col as isize))
} }
...@@ -2420,7 +2363,7 @@ impl ContextWriter { ...@@ -2420,7 +2363,7 @@ impl ContextWriter {
&mut newmv_count, bsize, is_compound); &mut newmv_count, bsize, is_compound);
col_match |= found_match; col_match |= found_match;
} }
if self.has_tr(bo, bsize) { if has_tr(bo, bsize) {
let found_match = self.scan_blk_mbmi(&bo.with_offset(target_n4_w as isize, -1), ref_frames, mv_stack, let found_match = self.scan_blk_mbmi(&bo.with_offset(target_n4_w as isize, -1), ref_frames, mv_stack,
&mut newmv_count, is_compound); &mut newmv_count, is_compound);
row_match |= found_match; row_match |= found_match;
......
...@@ -340,7 +340,7 @@ impl Sequence { ...@@ -340,7 +340,7 @@ impl Sequence {
still_picture: false, still_picture: false,
reduced_still_picture_hdr: false, reduced_still_picture_hdr: false,
monochrome: false, monochrome: false,
enable_intra_edge_filter: true, enable_intra_edge_filter: false,
enable_interintra_compound: false, enable_interintra_compound: false,
enable_masked_compound: false, enable_masked_compound: false,
enable_dual_filter: false, enable_dual_filter: false,
...@@ -1733,7 +1733,7 @@ pub fn encode_tx_block( ...@@ -1733,7 +1733,7 @@ pub fn encode_tx_block(
assert!(tx_size.sqr() <= TxSize::TX_32X32 || tx_type == TxType::DCT_DCT); assert!(tx_size.sqr() <= TxSize::TX_32X32 || tx_type == TxType::DCT_DCT);
if mode.is_intra() { if mode.is_intra() {
mode.predict_intra(&mut rec.mut_slice(po), tx_size, bit_depth, &ac, alpha); mode.predict_intra(&mut rec.mut_slice(po), tx_size, bit_depth, &ac, alpha, p, fi.w_in_b, fi.h_in_b);
} }
if skip { return (false, -1); } if skip { return (false, -1); }
......
This diff is collapsed.
...@@ -33,7 +33,13 @@ pub static RAV1E_INTRA_MODES: &'static [PredictionMode] = &[ ...@@ -33,7 +33,13 @@ pub static RAV1E_INTRA_MODES: &'static [PredictionMode] = &[
PredictionMode::SMOOTH_PRED, PredictionMode::SMOOTH_PRED,
PredictionMode::SMOOTH_H_PRED, PredictionMode::SMOOTH_H_PRED,
PredictionMode::SMOOTH_V_PRED, PredictionMode::SMOOTH_V_PRED,
PredictionMode::PAETH_PRED PredictionMode::PAETH_PRED,
PredictionMode::D45_PRED,
PredictionMode::D135_PRED,
PredictionMode::D117_PRED,
PredictionMode::D153_PRED,
PredictionMode::D207_PRED,
PredictionMode::D63_PRED,
]; ];
// Intra prediction modes tested at high speed levels // Intra prediction modes tested at high speed levels
...@@ -757,8 +763,127 @@ where ...@@ -757,8 +763,127 @@ where
Self::pred_dc_top(output, stride, above, left); Self::pred_dc_top(output, stride, above, left);
Self::pred_cfl_inner(output, stride, &ac, alpha, bit_depth); Self::pred_cfl_inner(output, stride, &ac, alpha, bit_depth);
} }
#[cfg_attr(feature = "comparative_bench", inline(never))]
fn pred_directional(
output: &mut [T], stride: usize, above: &[T], left: &[T], top_left: &[T], angle: usize, bit_depth: usize
) {
let sample_max = ((1 << bit_depth) - 1) as i32;
let angle_delta = 0;
let p_angle = angle; // TODO use Mode_to_Angle
let upsample_above = 0;
let upsample_left = 0;
let enable_intra_edge_filter = false; // FIXME
if enable_intra_edge_filter {
// TODO
}
fn dr_intra_derivative(p_angle: usize) -> usize {
match p_angle {
4 => 1023,
7 => 547,
10 => 372,
14 => 273,
17 => 215,
20 => 178,
23 => 151,
26 => 132,
29 => 116,
32 => 102,
36 => 90,
39 => 80,
42 => 71,
45 => 64,
48 => 57,
51 => 51,
54 => 45,
58 => 40,
61 => 35,
64 => 31,
67 => 27,
70 => 23,
73 => 19,
76 => 15,
81 => 11,
84 => 7,
87 => 3,
_ => 0
}
}
let dx = if p_angle < 90 {
dr_intra_derivative(p_angle)
} else if p_angle > 90 && p_angle < 180 {
dr_intra_derivative(180 - p_angle)
} else {
0 // undefined
};
let dy = if p_angle > 90 && p_angle < 180 {
dr_intra_derivative(p_angle - 90)
} else if p_angle > 180 {
dr_intra_derivative(270 - p_angle)
} else {
0 // undefined
};
if p_angle < 90 {
for i in 0..Self::H {
for j in 0..Self::W {
let idx = (i + 1) * dx;
let base = (idx >> (6 - upsample_above)) + (j << upsample_above);
let shift = (((idx << upsample_above) >> 1) & 31) as i32;
let max_base_x = (Self::H + Self::W - 1) << upsample_above;
output[i * stride + j] = if base < max_base_x {
let a: i32 = above[base].into();
let b: i32 = above[base + 1].into();
(a * (32 - shift) + b * shift + 16) >> 5
} else {
let c: i32 = above[max_base_x].into();
c
}.max(0).min(sample_max).as_();
}
}
} else if p_angle > 90 && p_angle < 180 {
for i in 0..Self::H {
for j in 0..Self::W {
let idx = (j << 6) as isize - ((i + 1) * dx) as isize;
let base = idx >> (6 - upsample_above);
if base >= -(1 << upsample_above) {
let shift = (((idx << upsample_above) >> 1) & 31) as i32;
let a: i32 = if base < 0 { top_left[0] } else { above[base as usize] }.into();
let b: i32 = above[(base + 1) as usize].into();
output[i * stride + j] = ((a * (32 - shift) + b * shift + 16) >> 5).max(0).min(sample_max).as_();
} else {
let idx = (i << 6) as isize - ((j + 1) * dy) as isize;
let base = idx >> (6 - upsample_left);
let shift = (((idx << upsample_left) >> 1) & 31) as i32;
let a: i32 = if base < 0 { top_left[0] } else { left[Self::W + Self::H - 1 - base as usize] }.into();
let b: i32 = left[Self::W + Self::H - (2 + base) as usize].into();
output[i * stride + j] = ((a * (32 - shift) + b * shift + 16) >> 5).max(0).min(sample_max).as_();
}
}
}
} else if p_angle > 180 {
for i in 0..Self::H {
for j in 0..Self::W {
let idx = (j + 1) * dy;
let base = (idx >> (6 - upsample_left)) + (i << upsample_left);
let shift = (((idx << upsample_left) >> 1) & 31) as i32;
let a: i32 = left[Self::W + Self::H - 1 - base].into();
let b: i32 = left[Self::W + Self::H - 2 - base].into();
output[i * stride + j] = ((a * (32 - shift) + b * shift + 16) >> 5).max(0).min(sample_max).as_();
}
}
}
}
} }
pub trait Inter: Dim {} pub trait Inter: Dim {}
#[cfg(all(test, feature = "aom"))] #[cfg(all(test, feature = "aom"))]
......
...@@ -736,7 +736,10 @@ pub fn rdo_cfl_alpha( ...@@ -736,7 +736,10 @@ pub fn rdo_cfl_alpha(
uv_tx_size, uv_tx_size,
bit_depth, bit_depth,
&ac, &ac,
alpha alpha,
p,
0, // don't care about frame width for CFL prediction
0 // don't care about frame height for CFL prediction
); );
sse_wxh( sse_wxh(
&input.slice(&po), &input.slice(&po),
......
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