Commit 330ac9df authored by Frank Bossen's avatar Frank Bossen Committed by Luca Barbato

Move retrieval of edges for intra prediction into a separate function

When testing multiples intra prediction modes for a same block, edges
are now retrieved only once instead of repeatedly for each mode
parent d92d9a2a
......@@ -1736,7 +1736,9 @@ pub fn encode_tx_block(
assert!(tx_size.sqr() <= TxSize::TX_32X32 || tx_type == TxType::DCT_DCT);
if mode.is_intra() {
mode.predict_intra(&mut rec.mut_slice(po), tx_size, fi.sequence.bit_depth, &ac, alpha, p, fi.w_in_b, fi.h_in_b);
let bit_depth = fi.sequence.bit_depth;
let edge_buf = get_intra_edges(&rec.slice(po), tx_size, bit_depth, p, fi.w_in_b, fi.h_in_b, Some(mode));
mode.predict_intra(&mut rec.mut_slice(po), tx_size, bit_depth, &ac, alpha, &edge_buf);
}
if skip { return (false, -1); }
......
This diff is collapsed.
......@@ -598,16 +598,23 @@ pub fn rdo_mode_decision(fi: &FrameInvariants, fs: &mut FrameState,
};
let intra_mode_set = RAV1E_INTRA_MODES;
let mut sads = intra_mode_set.iter().map(|&luma_mode| {
let rec = &mut fs.rec.planes[0];
let po = bo.plane_offset(&rec.cfg);
luma_mode.predict_intra(&mut rec.mut_slice(&po), tx_size, fi.sequence.bit_depth, &[0i16; 2], 0, 0, fi.w_in_b, fi.h_in_b);
let plane_org = fs.input.planes[0].slice(&po);
let plane_ref = rec.slice(&po);
(luma_mode, get_sad(&plane_org, &plane_ref, tx_size.height(), tx_size.width(), fi.sequence.bit_depth))
}).collect::<Vec<_>>();
let mut sads = {
let edge_buf = {
let rec = &mut fs.rec.planes[0];
let po = bo.plane_offset(&rec.cfg);
get_intra_edges(&rec.slice(&po), tx_size, fi.sequence.bit_depth, 0, fi.w_in_b, fi.h_in_b, None)
};
intra_mode_set.iter().map(|&luma_mode| {
let rec = &mut fs.rec.planes[0];
let po = bo.plane_offset(&rec.cfg);
luma_mode.predict_intra(&mut rec.mut_slice(&po), tx_size, fi.sequence.bit_depth, &[0i16; 2], 0, &edge_buf);
let plane_org = fs.input.planes[0].slice(&po);
let plane_ref = rec.slice(&po);
(luma_mode, get_sad(&plane_org, &plane_ref, tx_size.height(), tx_size.width(), fi.sequence.bit_depth))
}).collect::<Vec<_>>()
};
sads.sort_by_key(|a| a.1);
......@@ -749,15 +756,14 @@ pub fn rdo_cfl_alpha(
let po = bo.plane_offset(&fs.input.planes[p].cfg);
(-16i16..17i16)
.min_by_key(|&alpha| {
let edge_buf = get_intra_edges(&rec.slice(&po), uv_tx_size, bit_depth, p, 0, 0, Some(PredictionMode::UV_CFL_PRED));
PredictionMode::UV_CFL_PRED.predict_intra(
&mut rec.mut_slice(&po),
uv_tx_size,
bit_depth,
&ac,
alpha,
p,
0, // don't care about frame width for CFL prediction
0 // don't care about frame height for CFL prediction
&edge_buf
);
sse_wxh(
&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