Skip to content

Commit 855b6d0

Browse files
barrbraintdaede
authored andcommitted
Fix DC_PRED and CFL_PRED at tile boundaries
A BlockRegion only knows its absolute offset, not its offset relative to the tile. In predict_intra_inner(), pass the whole region for the tile and the block offset relative to the tile. Signed-off-by: Romain Vimont <rom1v@videolabs.io>
1 parent 6dc9bb0 commit 855b6d0

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

src/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ pub fn encode_tx_block<T: Pixel>(
10261026
if mode.is_intra() {
10271027
let bit_depth = fi.sequence.bit_depth;
10281028
let edge_buf = get_intra_edges(&rec.as_const(), po, tx_size, bit_depth, Some(mode));
1029-
mode.predict_intra(&mut rec.subregion_mut(area), tx_size, bit_depth, &ac, alpha, &edge_buf);
1029+
mode.predict_intra(rec, tile_bo, tx_size, bit_depth, &ac, alpha, &edge_buf);
10301030
}
10311031

10321032
if skip { return (false, -1); }

src/partition.rs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,65 +1009,68 @@ pub fn get_intra_edges<T: Pixel>(
10091009

10101010
impl PredictionMode {
10111011
pub fn predict_intra<T: Pixel>(
1012-
self, dst: &mut PlaneRegionMut<'_, T>, tx_size: TxSize, bit_depth: usize,
1012+
self, dst: &mut PlaneRegionMut<'_, T>, bo: BlockOffset, tx_size: TxSize, bit_depth: usize,
10131013
ac: &[i16], alpha: i16, edge_buf: &AlignedArray<[T; 4 * MAX_TX_SIZE + 1]>
10141014
) {
10151015
assert!(self.is_intra());
10161016

10171017
match tx_size {
10181018
TxSize::TX_4X4 =>
1019-
self.predict_intra_inner::<Block4x4, _>(dst, bit_depth, ac, alpha, edge_buf),
1019+
self.predict_intra_inner::<Block4x4, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10201020
TxSize::TX_8X8 =>
1021-
self.predict_intra_inner::<Block8x8, _>(dst, bit_depth, ac, alpha, edge_buf),
1021+
self.predict_intra_inner::<Block8x8, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10221022
TxSize::TX_16X16 =>
1023-
self.predict_intra_inner::<Block16x16, _>(dst, bit_depth, ac, alpha, edge_buf),
1023+
self.predict_intra_inner::<Block16x16, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10241024
TxSize::TX_32X32 =>
1025-
self.predict_intra_inner::<Block32x32, _>(dst, bit_depth, ac, alpha, edge_buf),
1025+
self.predict_intra_inner::<Block32x32, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10261026
TxSize::TX_64X64 =>
1027-
self.predict_intra_inner::<Block64x64, _>(dst, bit_depth, ac, alpha, edge_buf),
1027+
self.predict_intra_inner::<Block64x64, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10281028

10291029
TxSize::TX_4X8 =>
1030-
self.predict_intra_inner::<Block4x8, _>(dst, bit_depth, ac, alpha, edge_buf),
1030+
self.predict_intra_inner::<Block4x8, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10311031
TxSize::TX_8X4 =>
1032-
self.predict_intra_inner::<Block8x4, _>(dst, bit_depth, ac, alpha, edge_buf),
1032+
self.predict_intra_inner::<Block8x4, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10331033
TxSize::TX_8X16 =>
1034-
self.predict_intra_inner::<Block8x16, _>(dst, bit_depth, ac, alpha, edge_buf),
1034+
self.predict_intra_inner::<Block8x16, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10351035
TxSize::TX_16X8 =>
1036-
self.predict_intra_inner::<Block16x8, _>(dst, bit_depth, ac, alpha, edge_buf),
1036+
self.predict_intra_inner::<Block16x8, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10371037
TxSize::TX_16X32 =>
1038-
self.predict_intra_inner::<Block16x32, _>(dst, bit_depth, ac, alpha, edge_buf),
1038+
self.predict_intra_inner::<Block16x32, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10391039
TxSize::TX_32X16 =>
1040-
self.predict_intra_inner::<Block32x16, _>(dst, bit_depth, ac, alpha, edge_buf),
1040+
self.predict_intra_inner::<Block32x16, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10411041
TxSize::TX_32X64 =>
1042-
self.predict_intra_inner::<Block32x64, _>(dst, bit_depth, ac, alpha, edge_buf),
1042+
self.predict_intra_inner::<Block32x64, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10431043
TxSize::TX_64X32 =>
1044-
self.predict_intra_inner::<Block64x32, _>(dst, bit_depth, ac, alpha, edge_buf),
1044+
self.predict_intra_inner::<Block64x32, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10451045

10461046
TxSize::TX_4X16 =>
1047-
self.predict_intra_inner::<Block4x16, _>(dst, bit_depth, ac, alpha, edge_buf),
1047+
self.predict_intra_inner::<Block4x16, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10481048
TxSize::TX_16X4 =>
1049-
self.predict_intra_inner::<Block16x4, _>(dst, bit_depth, ac, alpha, edge_buf),
1049+
self.predict_intra_inner::<Block16x4, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10501050
TxSize::TX_8X32 =>
1051-
self.predict_intra_inner::<Block8x32, _>(dst, bit_depth, ac, alpha, edge_buf),
1051+
self.predict_intra_inner::<Block8x32, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10521052
TxSize::TX_32X8 =>
1053-
self.predict_intra_inner::<Block32x8, _>(dst, bit_depth, ac, alpha, edge_buf),
1053+
self.predict_intra_inner::<Block32x8, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10541054
TxSize::TX_16X64 =>
1055-
self.predict_intra_inner::<Block16x64, _>(dst, bit_depth, ac, alpha, edge_buf),
1055+
self.predict_intra_inner::<Block16x64, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10561056
TxSize::TX_64X16 =>
1057-
self.predict_intra_inner::<Block64x16, _>(dst, bit_depth, ac, alpha, edge_buf),
1057+
self.predict_intra_inner::<Block64x16, _>(dst, bo, bit_depth, ac, alpha, edge_buf),
10581058
}
10591059
}
10601060

10611061
#[inline(always)]
10621062
fn predict_intra_inner<B: Intra<T>, T: Pixel>(
1063-
self, dst: &mut PlaneRegionMut<'_, T>, bit_depth: usize, ac: &[i16],
1064-
alpha: i16, edge_buf: &AlignedArray<[T; 4 * MAX_TX_SIZE + 1]>
1063+
self, dst: &mut PlaneRegionMut<'_, T>, tile_bo: BlockOffset,
1064+
bit_depth: usize, ac: &[i16], alpha: i16,
1065+
edge_buf: &AlignedArray<[T; 4 * MAX_TX_SIZE + 1]>
10651066
) {
10661067
// left pixels are order from bottom to top and right-aligned
10671068
let (left, not_left) = edge_buf.array.split_at(2*MAX_TX_SIZE);
10681069
let (top_left, above) = not_left.split_at(1);
10691070

1070-
let &Rect { x, y, .. } = dst.rect();
1071+
let BlockOffset { x, y, .. } = tile_bo;
1072+
let area = Area::BlockStartingAt { bo: tile_bo };
1073+
let dst = &mut dst.subregion_mut(area);
10711074

10721075
let mode: PredictionMode = match self {
10731076
PredictionMode::PAETH_PRED => match (x, y) {

src/rdo.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,9 @@ pub fn rdo_mode_decision<T: Pixel>(
734734
.iter()
735735
.map(|&luma_mode| {
736736
let rec = &mut ts.rec.planes[0];
737-
let mut rec_region = rec.subregion_mut(Area::BlockStartingAt { bo: tile_bo });
738737
luma_mode.predict_intra(
739-
&mut rec_region,
738+
rec,
739+
tile_bo,
740740
tx_size,
741741
fi.sequence.bit_depth,
742742
&[0i16; 2],
@@ -745,7 +745,7 @@ pub fn rdo_mode_decision<T: Pixel>(
745745
);
746746

747747
let plane_org = ts.input_tile.planes[0].subregion(Area::BlockStartingAt { bo: tile_bo });
748-
let plane_ref = rec_region.as_const();
748+
let plane_ref = rec.subregion(Area::BlockStartingAt { bo: tile_bo });
749749

750750
(
751751
luma_mode,
@@ -914,9 +914,9 @@ pub fn rdo_cfl_alpha<T: Pixel>(
914914
Some(PredictionMode::UV_CFL_PRED)
915915
);
916916

917-
let mut rec_region = rec.subregion_mut(Area::BlockStartingAt { bo: tile_bo });
918917
PredictionMode::UV_CFL_PRED.predict_intra(
919-
&mut rec_region,
918+
rec,
919+
tile_bo,
920920
uv_tx_size,
921921
bit_depth,
922922
&ac.array,
@@ -925,7 +925,7 @@ pub fn rdo_cfl_alpha<T: Pixel>(
925925
);
926926
sse_wxh(
927927
&input.subregion(Area::BlockStartingAt { bo: tile_bo }),
928-
&rec_region.as_const(),
928+
&rec.subregion(Area::BlockStartingAt { bo: tile_bo }),
929929
uv_tx_size.width(),
930930
uv_tx_size.height()
931931
)

0 commit comments

Comments
 (0)