forge
Explore
Log in

Don't you dare go Hollow

Constrained intra prediction stops at prediction

Browse files at this commit

18b2689f1efbfe6924639ac0d0286f3376251212Ahmet Kaan GümüşParent: 4b8dc73
  • fix
    • constrained intra prediction stops at prediction
Show full message
fix(h264): constrained intra prediction stops at prediction

constrained_intra_pred_flag makes an inter neighbour unavailable as an
intra *prediction* source (8.3.1.1, 8.3.1.2). It does not change the
neighbour availability the residual contexts read: clause 9.2.1 and
9.3.3.1.1.9 exclude an inter neighbour there only when slice data
partitioning is in use, which this decoder refuses outright. Feeding the
constrained availability into nC and coded_block_flag desynchronised
CI_MW_D, whose whole point is constrained intra prediction.

JVT full-sequence sweep: 26 of 26 in-scope vectors bit-exact end to end,
9 refused by name (8 interlaced, 1 FMO), nothing unaccounted.
crates/ec-h264/src/decoder.rsmodified+12 -4
@@ -1169,8 +1169,9 @@ fn decode_macroblock(
1169 r,1169 r,
1170 ctx,1170 ctx,
1171 mb_addr,1171 mb_addr,
1172- &intra_nbr,1172+ &nbr,
1173 MbFinish {1173 MbFinish {
1174+ pred_nbr: intra_nbr,
1174 is_i16,1175 is_i16,
1175 i16_mode,1176 i16_mode,
1176 cbp_luma,1177 cbp_luma,
@@ -1185,6 +1186,12 @@ fn decode_macroblock(
1185 1186
1186 /// Everything the shared residual path needs after prediction is decided.1187 /// Everything the shared residual path needs after prediction is decided.
1187 struct MbFinish {1188 struct MbFinish {
1189+ /// Neighbour availability for *prediction*, which honours
1190+ /// constrained_intra_pred_flag. The residual contexts use the plain
1191+ /// availability instead — clause 9.2.1 and 9.3.3.1.1.9 only exclude an
1192+ /// inter neighbour there when slice data partitioning is in use, and this
1193+ /// decoder refuses partitioned slices outright.
1194+ pred_nbr: MbNeighbors,
1188 is_i16: bool,1195 is_i16: bool,
1189 i16_mode: u8,1196 i16_mode: u8,
1190 cbp_luma: u8,1197 cbp_luma: u8,
@@ -1255,7 +1262,7 @@ fn finish_macroblock(
1255 stride: pic.y.stride,1262 stride: pic.y.stride,
1256 origin: pic.y.origin + (mb_y * 16) * pic.y.stride + mb_x * 16,1263 origin: pic.y.origin + (mb_y * 16) * pic.y.stride + mb_x * 16,
1257 };1264 };
1258- pred_16x16(m.i16_mode, &mut w, nbr.b, nbr.a);1265+ pred_16x16(m.i16_mode, &mut w, m.pred_nbr.b, m.pred_nbr.a);
1259 // Luma DC: un-zigzag over the 4x4 DC array, Hadamard + scale.1266 // Luma DC: un-zigzag over the 4x4 DC array, Hadamard + scale.
1260 let (na, nb) = luma_nz_pair(pic, nbr, bx0, by0);1267 let (na, nb) = luma_nz_pair(pic, nbr, bx0, by0);
1261 let dc_tc = r.residual_block(&mut scan, BlockCat::LumaDc, na, nb)?;1268 let dc_tc = r.residual_block(&mut scan, BlockCat::LumaDc, na, nb)?;
@@ -1305,7 +1312,7 @@ fn finish_macroblock(
1305 let origin = pic.y.at(x, y);1312 let origin = pic.y.at(x, y);
1306 let stride = pic.y.stride;1313 let stride = pic.y.stride;
1307 if m.intra {1314 if m.intra {
1308- let n = gather_nbr4(pic, nbr, blk, x, y);1315+ let n = gather_nbr4(pic, &m.pred_nbr, blk, x, y);
1309 let mut p = [0u8; 16];1316 let mut p = [0u8; 16];
1310 pred_4x4(m.modes[blk], &n, &mut p);1317 pred_4x4(m.modes[blk], &n, &mut p);
1311 if tc == 0 {1318 if tc == 0 {
@@ -1348,7 +1355,7 @@ fn finish_macroblock(
1348 stride: plane.stride,1355 stride: plane.stride,
1349 origin: plane.origin + (mb_y * 8) * plane.stride + mb_x * 8,1356 origin: plane.origin + (mb_y * 8) * plane.stride + mb_x * 8,
1350 };1357 };
1351- pred_chroma_8x8(m.chroma_mode, &mut w, nbr.b, nbr.a);1358+ pred_chroma_8x8(m.chroma_mode, &mut w, m.pred_nbr.b, m.pred_nbr.a);
1352 }1359 }
1353 }1360 }
1354 let mut chroma_dc = [[0i32; 4]; 2];1361 let mut chroma_dc = [[0i32; 4]; 2];
@@ -1674,6 +1681,7 @@ fn decode_inter_mb(
1674 mb_addr,1681 mb_addr,
1675 &nbr,1682 &nbr,
1676 MbFinish {1683 MbFinish {
1684+ pred_nbr: nbr,
1677 is_i16: false,1685 is_i16: false,
1678 i16_mode: 0,1686 i16_mode: 0,
1679 cbp_luma,1687 cbp_luma,