Read tx_depth under TxMode::Select on key frames
Browse files at this commitab946374b262f8f76e09e9ac9db96c0b15c23d35Parent: 1ee1fd3- feat
- read tx_depth under TxMode::Select on key frames
4 changed files +446 -27
- crates/ec-av1/src/cdf.rs +25 -0
- crates/ec-av1/src/cdf_state.rs +17 -0
- crates/ec-av1/src/decode.rs +239 -13
- crates/ec-av1/src/stream.rs +165 -14
crates/ec-av1/src/cdf.rsmodified+25 -0
| @@ -326,6 +326,31 @@ pub const FILTER_INTRA: [[u16; 3]; 4] = [ | |||
| 326 | /// `FILTER_INTRA_MODES` a `use_filter_intra` block picks. | 326 | /// `FILTER_INTRA_MODES` a `use_filter_intra` block picks. |
| 327 | pub const FILTER_INTRA_MODE: [u16; 6] = [8949, 12776, 17211, 29558, 32768, 0]; | 327 | pub const FILTER_INTRA_MODE: [u16; 6] = [8949, 12776, 17211, 29558, 32768, 0]; |
| 328 | 328 | ||
| 329 | +/// `default_tx_size_cdf[0]` (entropymode.c): an 8x8 block's `tx_depth` flag | ||
| 330 | +/// (`TX8` vs `TX4`), indexed by `tx_size_context` (0..=2). | ||
| 331 | +pub const TX_SIZE_CAT0: [[u16; 3]; 3] = [[19968, 32768, 0], [19968, 32768, 0], [24320, 32768, 0]]; | ||
| 332 | +/// `default_tx_size_cdf[1]` (entropymode.c): a 16x16 block's `tx_depth` | ||
| 333 | +/// (`TX16`/`TX8`/`TX4`), indexed by `tx_size_context`. | ||
| 334 | +pub const TX_SIZE_CAT1: [[u16; 4]; 3] = [ | ||
| 335 | + [12272, 30172, 32768, 0], | ||
| 336 | + [12272, 30172, 32768, 0], | ||
| 337 | + [18677, 30848, 32768, 0], | ||
| 338 | +]; | ||
| 339 | +/// `default_tx_size_cdf[2]` (entropymode.c): a 32x32 block's `tx_depth` | ||
| 340 | +/// (`TX32`/`TX16`/`TX8`), indexed by `tx_size_context`. | ||
| 341 | +pub const TX_SIZE_CAT2: [[u16; 4]; 3] = [ | ||
| 342 | + [12986, 15180, 32768, 0], | ||
| 343 | + [12986, 15180, 32768, 0], | ||
| 344 | + [24302, 25602, 32768, 0], | ||
| 345 | +]; | ||
| 346 | +/// `default_tx_size_cdf[3]` (entropymode.c): a 64x64 block's `tx_depth` | ||
| 347 | +/// (`TX64`/`TX32`/`TX16`), indexed by `tx_size_context`. | ||
| 348 | +pub const TX_SIZE_CAT3: [[u16; 4]; 3] = [ | ||
| 349 | + [5782, 11475, 32768, 0], | ||
| 350 | + [5782, 11475, 32768, 0], | ||
| 351 | + [16803, 22759, 32768, 0], | ||
| 352 | +]; | ||
| 353 | + | ||
| 329 | /// `Default_Cfl_Alpha_Cdf` (spec 9.4): a `UV_CFL_PRED` block's per-plane | 354 | /// `Default_Cfl_Alpha_Cdf` (spec 9.4): a `UV_CFL_PRED` block's per-plane |
| 330 | /// alpha magnitude (spec 5.11.45's `cfl_alpha_u`/`cfl_alpha_v`), indexed by | 355 | /// alpha magnitude (spec 5.11.45's `cfl_alpha_u`/`cfl_alpha_v`), indexed by |
| 331 | /// the joint sign's context (`CFL_CONTEXT_U`/`CFL_CONTEXT_V`, | 356 | /// the joint sign's context (`CFL_CONTEXT_U`/`CFL_CONTEXT_V`, |
crates/ec-av1/src/cdf_state.rsmodified+17 -0
| @@ -260,6 +260,15 @@ pub(crate) struct Cdfs { | |||
| 260 | pub filter_intra: [[u16; 3]; 4], | 260 | pub filter_intra: [[u16; 3]; 4], |
| 261 | /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks. | 261 | /// Which `FILTER_INTRA_MODES` entry a `use_filter_intra` block picks. |
| 262 | pub filter_intra_mode: [u16; 6], | 262 | pub filter_intra_mode: [u16; 6], |
| 263 | + /// `TxMode::Select`'s `tx_depth` flag at an 8x8 block, by `tx_size_context` | ||
| 264 | + /// (0..=2) -- see [`cdf::TX_SIZE_CAT0`]. | ||
| 265 | + pub tx_size_cat0: [[u16; 3]; 3], | ||
| 266 | + /// `tx_depth` at a 16x16 block -- see [`cdf::TX_SIZE_CAT1`]. | ||
| 267 | + pub tx_size_cat1: [[u16; 4]; 3], | ||
| 268 | + /// `tx_depth` at a 32x32 block -- see [`cdf::TX_SIZE_CAT2`]. | ||
| 269 | + pub tx_size_cat2: [[u16; 4]; 3], | ||
| 270 | + /// `tx_depth` at a 64x64 block -- see [`cdf::TX_SIZE_CAT3`]. | ||
| 271 | + pub tx_size_cat3: [[u16; 4]; 3], | ||
| 263 | } | 272 | } |
| 264 | 273 | ||
| 265 | /// One motion vector component's adapting state (spec 9.4's `Default_Mv_*`, | 274 | /// One motion vector component's adapting state (spec 9.4's `Default_Mv_*`, |
| @@ -434,6 +443,10 @@ impl Cdfs { | |||
| 434 | .for_each(MvComponentCdfs::reset_counts); | 443 | .for_each(MvComponentCdfs::reset_counts); |
| 435 | reset2(&mut self.filter_intra); | 444 | reset2(&mut self.filter_intra); |
| 436 | reset1(&mut self.filter_intra_mode); | 445 | reset1(&mut self.filter_intra_mode); |
| 446 | + reset2(&mut self.tx_size_cat0); | ||
| 447 | + reset2(&mut self.tx_size_cat1); | ||
| 448 | + reset2(&mut self.tx_size_cat2); | ||
| 449 | + reset2(&mut self.tx_size_cat3); | ||
| 437 | } | 450 | } |
| 438 | 451 | ||
| 439 | /// The defaults a key frame starts from (spec 8.4, `init_coeff_cdfs` and | 452 | /// The defaults a key frame starts from (spec 8.4, `init_coeff_cdfs` and |
| @@ -793,6 +806,10 @@ impl Cdfs { | |||
| 793 | mv_comp: [MvComponentCdfs::new(), MvComponentCdfs::new()], | 806 | mv_comp: [MvComponentCdfs::new(), MvComponentCdfs::new()], |
| 794 | filter_intra: cdf::FILTER_INTRA, | 807 | filter_intra: cdf::FILTER_INTRA, |
| 795 | filter_intra_mode: cdf::FILTER_INTRA_MODE, | 808 | filter_intra_mode: cdf::FILTER_INTRA_MODE, |
| 809 | + tx_size_cat0: cdf::TX_SIZE_CAT0, | ||
| 810 | + tx_size_cat1: cdf::TX_SIZE_CAT1, | ||
| 811 | + tx_size_cat2: cdf::TX_SIZE_CAT2, | ||
| 812 | + tx_size_cat3: cdf::TX_SIZE_CAT3, | ||
| 796 | } | 813 | } |
| 797 | } | 814 | } |
| 798 | 815 | ||
crates/ec-av1/src/decode.rsmodified+239 -13
| @@ -61,6 +61,19 @@ static DEBLOCK_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicU | |||
| 61 | pub(crate) fn deblock_hits() -> usize { | 61 | pub(crate) fn deblock_hits() -> usize { |
| 62 | DEBLOCK_HITS.load(std::sync::atomic::Ordering::Relaxed) | 62 | DEBLOCK_HITS.load(std::sync::atomic::Ordering::Relaxed) |
| 63 | } | 63 | } |
| 64 | + | ||
| 65 | +/// How many [`read_tx_size`] reads resolved a `tx_depth` strictly less than | ||
| 66 | +/// the block's own side, across every call in the process -- the same | ||
| 67 | +/// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream | ||
| 68 | +/// actually exercised a *split* transform under `TxMode::Select` rather than | ||
| 69 | +/// every block coincidentally resolving `depth=0` (indistinguishable from | ||
| 70 | +/// `TxMode::Largest` pixel-wise). | ||
| 71 | +static TX_DEPTH_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | ||
| 72 | + | ||
| 73 | +/// Current value of [`TX_DEPTH_HITS`]. | ||
| 74 | +pub(crate) fn tx_depth_hits() -> usize { | ||
| 75 | + TX_DEPTH_HITS.load(std::sync::atomic::Ordering::Relaxed) | ||
| 76 | +} | ||
| 64 | const SUB_MI: u32 = 4; | 77 | const SUB_MI: u32 = 4; |
| 65 | const MI: usize = 4; | 78 | const MI: usize = 4; |
| 66 | const SB: usize = 64; | 79 | const SB: usize = 64; |
| @@ -1098,6 +1111,10 @@ fn decode_block( | |||
| 1098 | v: &mut PlaneBuf, | 1111 | v: &mut PlaneBuf, |
| 1099 | base_q_idx: u8, | 1112 | base_q_idx: u8, |
| 1100 | enable_filter_intra: bool, | 1113 | enable_filter_intra: bool, |
| 1114 | + scan32: &[u16], | ||
| 1115 | + scan16: &[u16], | ||
| 1116 | + scan8: &[u16], | ||
| 1117 | + tx_select: bool, | ||
| 1101 | ) -> Result<()> { | 1118 | ) -> Result<()> { |
| 1102 | let (r, c) = at; | 1119 | let (r, c) = at; |
| 1103 | let (px, py) = (c * SUB, r * SUB); | 1120 | let (px, py) = (c * SUB, r * SUB); |
| @@ -1110,8 +1127,31 @@ fn decode_block( | |||
| 1110 | side, | 1127 | side, |
| 1111 | enable_filter_intra, | 1128 | enable_filter_intra, |
| 1112 | )?; | 1129 | )?; |
| 1130 | + let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); | ||
| 1131 | + // `TxMode::Select`'s `tx_depth` (spec 5.11.16): read for every intra | ||
| 1132 | + // block, skipped or not. `logical_tx` is what the loop filter's edge | ||
| 1133 | + // lookup and the next block's own `tx_size_context` want (the *nominal* | ||
| 1134 | + // transform size -- 64 even for the 64x64 corner-scanned case, spec | ||
| 1135 | + // 5.11.40); `coeff_tx_side` is the actual coded coefficient grid's side, | ||
| 1136 | + // which only differs from it at that one corner case. | ||
| 1137 | + let (logical_tx, coeff_tx_side) = if tx_select { | ||
| 1138 | + let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side); | ||
| 1139 | + if resolved == 4 { | ||
| 1140 | + return Err(unsupported( | ||
| 1141 | + "a resolved 4x4 luma transform (TxMode::Select depth exhausted; this decoder has no 4x4 luma coefficient tables)", | ||
| 1142 | + )); | ||
| 1143 | + } | ||
| 1144 | + (resolved, if resolved == 64 { 32 } else { resolved }) | ||
| 1145 | + } else { | ||
| 1146 | + (side, luma_tx) | ||
| 1147 | + }; | ||
| 1148 | + let luma_set = if tx_select { | ||
| 1149 | + txbset_for(logical_tx) | ||
| 1150 | + } else { | ||
| 1151 | + luma_set | ||
| 1152 | + }; | ||
| 1153 | + let luma_scan = scan_for(coeff_tx_side, scan32, scan16, scan8); | ||
| 1113 | let reach = Reach::of(side, px, py, y.width, y.height); | 1154 | let reach = Reach::of(side, px, py, y.width, y.height); |
| 1114 | - let (luma_grid, u_grid, v_grid); | ||
| 1115 | let (cpx, cpy) = (px / 2, py / 2); | 1155 | let (cpx, cpy) = (px / 2, py / 2); |
| 1116 | let chroma_side = side / 2; | 1156 | let chroma_side = side / 2; |
| 1117 | if skip { | 1157 | if skip { |
| @@ -1148,16 +1188,20 @@ fn decode_block( | |||
| 1148 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | 1188 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 1149 | None, | 1189 | None, |
| 1150 | ); | 1190 | ); |
| 1151 | - luma_grid = vec![0i32; side * side]; | 1191 | + let luma_grid = vec![0i32; side * side]; |
| 1152 | - u_grid = vec![0i32; chroma_side * chroma_side]; | 1192 | + let u_grid = vec![0i32; chroma_side * chroma_side]; |
| 1153 | - v_grid = vec![0i32; chroma_side * chroma_side]; | 1193 | + let v_grid = vec![0i32; chroma_side * chroma_side]; |
| 1154 | - } else { | 1194 | + neighbours.record(at, side, mode, &[luma_grid, u_grid, v_grid]); |
| 1195 | + } else if !tx_select || logical_tx == side { | ||
| 1196 | + // A single luma transform unit -- the old path, unchanged (including | ||
| 1197 | + // the 64x64 corner case, `logical_tx == side == 64` with | ||
| 1198 | + // `coeff_tx_side == 32`). | ||
| 1155 | let around = neighbours.around(at, side); | 1199 | let around = neighbours.around(at, side); |
| 1156 | - luma_grid = read_plane( | 1200 | + let luma_grid = read_plane( |
| 1157 | dec, | 1201 | dec, |
| 1158 | cdfs, | 1202 | cdfs, |
| 1159 | luma_set, | 1203 | luma_set, |
| 1160 | - scans.0, | 1204 | + luma_scan, |
| 1161 | 0, | 1205 | 0, |
| 1162 | around[0], | 1206 | around[0], |
| 1163 | mode, | 1207 | mode, |
| @@ -1167,13 +1211,13 @@ fn decode_block( | |||
| 1167 | px, | 1211 | px, |
| 1168 | py, | 1212 | py, |
| 1169 | side, | 1213 | side, |
| 1170 | - luma_tx, | 1214 | + coeff_tx_side, |
| 1171 | base_q_idx, | 1215 | base_q_idx, |
| 1172 | None, | 1216 | None, |
| 1173 | filter_intra, | 1217 | filter_intra, |
| 1174 | )?; | 1218 | )?; |
| 1175 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 1219 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| 1176 | - u_grid = read_plane( | 1220 | + let u_grid = read_plane( |
| 1177 | dec, | 1221 | dec, |
| 1178 | cdfs, | 1222 | cdfs, |
| 1179 | chroma_set, | 1223 | chroma_set, |
| @@ -1192,7 +1236,7 @@ fn decode_block( | |||
| 1192 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | 1236 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), |
| 1193 | None, | 1237 | None, |
| 1194 | )?; | 1238 | )?; |
| 1195 | - v_grid = read_plane( | 1239 | + let v_grid = read_plane( |
| 1196 | dec, | 1240 | dec, |
| 1197 | cdfs, | 1241 | cdfs, |
| 1198 | chroma_set, | 1242 | chroma_set, |
| @@ -1211,13 +1255,94 @@ fn decode_block( | |||
| 1211 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | 1255 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 1212 | None, | 1256 | None, |
| 1213 | )?; | 1257 | )?; |
| 1258 | + neighbours.record(at, side, mode, &[luma_grid, u_grid, v_grid]); | ||
| 1259 | + } else { | ||
| 1260 | + // Several luma transform units, raster order (spec | ||
| 1261 | + // `transform_block`'s loop): the block's resolved transform is | ||
| 1262 | + // genuinely smaller than its own side, so each tile of it predicts | ||
| 1263 | + // and codes independently, its own context read fresh off whatever | ||
| 1264 | + // the earlier tiles in this same block already wrote -- the same | ||
| 1265 | + // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf. | ||
| 1266 | + let n_axis = side / logical_tx; | ||
| 1267 | + for tu_row in 0..n_axis { | ||
| 1268 | + for tu_col in 0..n_axis { | ||
| 1269 | + let tu_mi = ( | ||
| 1270 | + mi_r + tu_row * (logical_tx / MI), | ||
| 1271 | + mi_c + tu_col * (logical_tx / MI), | ||
| 1272 | + ); | ||
| 1273 | + let tu_px = px + tu_col * logical_tx; | ||
| 1274 | + let tu_py = py + tu_row * logical_tx; | ||
| 1275 | + let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0]; | ||
| 1276 | + let tu_reach = Reach::of(logical_tx, tu_px, tu_py, y.width, y.height); | ||
| 1277 | + let tu_grid = read_plane( | ||
| 1278 | + dec, | ||
| 1279 | + cdfs, | ||
| 1280 | + luma_set, | ||
| 1281 | + luma_scan, | ||
| 1282 | + 0, | ||
| 1283 | + tu_around, | ||
| 1284 | + mode, | ||
| 1285 | + mode, | ||
| 1286 | + tu_reach, | ||
| 1287 | + y, | ||
| 1288 | + tu_px, | ||
| 1289 | + tu_py, | ||
| 1290 | + logical_tx, | ||
| 1291 | + logical_tx, | ||
| 1292 | + base_q_idx, | ||
| 1293 | + None, | ||
| 1294 | + filter_intra, | ||
| 1295 | + )?; | ||
| 1296 | + neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); | ||
| 1297 | + } | ||
| 1298 | + } | ||
| 1299 | + let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | ||
| 1300 | + let chroma_around = neighbours.around(at, side); | ||
| 1301 | + let u_grid = read_plane( | ||
| 1302 | + dec, | ||
| 1303 | + cdfs, | ||
| 1304 | + chroma_set, | ||
| 1305 | + scans.1, | ||
| 1306 | + 1, | ||
| 1307 | + chroma_around[1], | ||
| 1308 | + mode, | ||
| 1309 | + DC_PRED, | ||
| 1310 | + Reach::none(), | ||
| 1311 | + u, | ||
| 1312 | + cpx, | ||
| 1313 | + cpy, | ||
| 1314 | + chroma_side, | ||
| 1315 | + chroma_tx, | ||
| 1316 | + base_q_idx, | ||
| 1317 | + alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | ||
| 1318 | + None, | ||
| 1319 | + )?; | ||
| 1320 | + let v_grid = read_plane( | ||
| 1321 | + dec, | ||
| 1322 | + cdfs, | ||
| 1323 | + chroma_set, | ||
| 1324 | + scans.1, | ||
| 1325 | + 2, | ||
| 1326 | + chroma_around[2], | ||
| 1327 | + mode, | ||
| 1328 | + DC_PRED, | ||
| 1329 | + Reach::none(), | ||
| 1330 | + v, | ||
| 1331 | + cpx, | ||
| 1332 | + cpy, | ||
| 1333 | + chroma_side, | ||
| 1334 | + chroma_tx, | ||
| 1335 | + base_q_idx, | ||
| 1336 | + alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | ||
| 1337 | + None, | ||
| 1338 | + )?; | ||
| 1339 | + neighbours.record_split_luma(at, side, mode, [&u_grid, &v_grid]); | ||
| 1214 | } | 1340 | } |
| 1215 | - neighbours.record(at, side, mode, &[luma_grid, u_grid, v_grid]); | ||
| 1216 | neighbours.fill_skip_grid((r * (SUB / MI), c * (SUB / MI)), side / MI, skip); | 1341 | neighbours.fill_skip_grid((r * (SUB / MI), c * (SUB / MI)), side / MI, skip); |
| 1217 | neighbours.fill_lf_grid( | 1342 | neighbours.fill_lf_grid( |
| 1218 | (r * (SUB / MI), c * (SUB / MI)), | 1343 | (r * (SUB / MI), c * (SUB / MI)), |
| 1219 | side / MI, | 1344 | side / MI, |
| 1220 | - side as u8, | 1345 | + logical_tx as u8, |
| 1221 | false, | 1346 | false, |
| 1222 | ); | 1347 | ); |
| 1223 | Ok(()) | 1348 | Ok(()) |
| @@ -1246,6 +1371,7 @@ fn decode_leaf8( | |||
| 1246 | v: &mut PlaneBuf, | 1371 | v: &mut PlaneBuf, |
| 1247 | base_q_idx: u8, | 1372 | base_q_idx: u8, |
| 1248 | enable_filter_intra: bool, | 1373 | enable_filter_intra: bool, |
| 1374 | + tx_select: bool, | ||
| 1249 | ) -> Result<usize> { | 1375 | ) -> Result<usize> { |
| 1250 | let (r, c) = outer_at; | 1376 | let (r, c) = outer_at; |
| 1251 | let mut above_mode = neighbours.above_mode[c]; | 1377 | let mut above_mode = neighbours.above_mode[c]; |
| @@ -1269,6 +1395,19 @@ fn decode_leaf8( | |||
| 1269 | 8, | 1395 | 8, |
| 1270 | enable_filter_intra, | 1396 | enable_filter_intra, |
| 1271 | )?; | 1397 | )?; |
| 1398 | + // `TxMode::Select`'s `tx_depth` at an 8x8 leaf (spec 5.11.16): the only | ||
| 1399 | + // depths an 8x8 block offers are `TX8` (depth 0, this decoder's one | ||
| 1400 | + // supported case) and `TX4` (depth 1, which this crate has no 4x4 luma | ||
| 1401 | + // coefficient tables for) -- read to stay in sync, then refuse rather | ||
| 1402 | + // than silently miscode. | ||
| 1403 | + if tx_select { | ||
| 1404 | + let resolved = read_tx_size(dec, cdfs, neighbours, leaf_mi, 8); | ||
| 1405 | + if resolved == 4 { | ||
| 1406 | + return Err(unsupported( | ||
| 1407 | + "a resolved 4x4 luma transform (TxMode::Select depth exhausted; this decoder has no 4x4 luma coefficient tables)", | ||
| 1408 | + )); | ||
| 1409 | + } | ||
| 1410 | + } | ||
| 1272 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); | 1411 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); |
| 1273 | let reach = Reach::of(8, px, py, y.width, y.height); | 1412 | let reach = Reach::of(8, px, py, y.width, y.height); |
| 1274 | let (cpx, cpy) = (px / 2, py / 2); | 1413 | let (cpx, cpy) = (px / 2, py / 2); |
| @@ -1600,6 +1739,70 @@ fn tx_px_at(n: &Neighbours, chroma: bool, mi_r: usize, mi_c: usize) -> u32 { | |||
| 1600 | if chroma { luma_tx / 2 } else { luma_tx } | 1739 | if chroma { luma_tx / 2 } else { luma_tx } |
| 1601 | } | 1740 | } |
| 1602 | 1741 | ||
| 1742 | +/// `get_tx_size_context` (spec 9.3's `TxDepthCtx`, libaom | ||
| 1743 | +/// `TXFM_CONTEXT`/`entropymode.c`): the sum of two boolean terms, each | ||
| 1744 | +/// present only when its neighbour exists inside the true frame -- whether | ||
| 1745 | +/// the block immediately above (at this block's own leftmost mi column) or | ||
| 1746 | +/// to the left (at its own topmost mi row) coded a transform at least as wide | ||
| 1747 | +/// as `own_side`. | ||
| 1748 | +fn tx_size_context(n: &Neighbours, (mi_r, mi_c): (usize, usize), own_side: usize) -> usize { | ||
| 1749 | + let above = mi_r > 0 && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_side; | ||
| 1750 | + let left = mi_c > 0 && tx_px_at(n, false, mi_r, mi_c - 1) as usize >= own_side; | ||
| 1751 | + usize::from(above) + usize::from(left) | ||
| 1752 | +} | ||
| 1753 | + | ||
| 1754 | +/// `read_tx_size`/`read_selected_tx_size` (spec 5.11.16): under | ||
| 1755 | +/// `TxMode::Select`, an intra block's `tx_depth` symbol, resolved straight to | ||
| 1756 | +/// the transform's own side in pixels (`side >> depth`) -- this decoder's | ||
| 1757 | +/// four square categories (8/16/32/64) each halve at most twice, matching | ||
| 1758 | +/// libaom's own per-size depth cap (`cdf::TX_SIZE_CAT0`..`TX_SIZE_CAT3`). | ||
| 1759 | +fn read_tx_size( | ||
| 1760 | + dec: &mut SymbolDecoder, | ||
| 1761 | + cdfs: &mut Cdfs, | ||
| 1762 | + n: &Neighbours, | ||
| 1763 | + at_mi: (usize, usize), | ||
| 1764 | + side: usize, | ||
| 1765 | +) -> usize { | ||
| 1766 | + let ctx = tx_size_context(n, at_mi, side); | ||
| 1767 | + let depth = match side { | ||
| 1768 | + 8 => dec.symbol(&mut cdfs.tx_size_cat0[ctx]), | ||
| 1769 | + 16 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), | ||
| 1770 | + 32 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), | ||
| 1771 | + 64 => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), | ||
| 1772 | + _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64"), | ||
| 1773 | + }; | ||
| 1774 | + if depth != 0 { | ||
| 1775 | + TX_DEPTH_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 1776 | + } | ||
| 1777 | + side >> depth | ||
| 1778 | +} | ||
| 1779 | + | ||
| 1780 | +/// The luma coefficient scan table for a resolved transform side -- 32/16/8, | ||
| 1781 | +/// the only three sizes a `TxMode::Select` block's coded coefficient grid | ||
| 1782 | +/// ([`read_tx_size`]'s resolved side, or 32 at the 64x64 corner case) can be. | ||
| 1783 | +fn scan_for<'a>(tx_px: usize, scan32: &'a [u16], scan16: &'a [u16], scan8: &'a [u16]) -> &'a [u16] { | ||
| 1784 | + match tx_px { | ||
| 1785 | + 32 => scan32, | ||
| 1786 | + 16 => scan16, | ||
| 1787 | + 8 => scan8, | ||
| 1788 | + _ => unreachable!("read_tx_size never resolves the coefficient grid to anything else"), | ||
| 1789 | + } | ||
| 1790 | +} | ||
| 1791 | + | ||
| 1792 | +/// The [`TxbSet`] a resolved luma transform side reads its coefficient tables | ||
| 1793 | +/// from -- 64 is only ever the 64x64-block, depth-0, corner-scanned case | ||
| 1794 | +/// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching | ||
| 1795 | +/// set. | ||
| 1796 | +fn txbset_for(tx_px: usize) -> TxbSet { | ||
| 1797 | + match tx_px { | ||
| 1798 | + 64 => TxbSet::Luma64, | ||
| 1799 | + 32 => TxbSet::Luma32, | ||
| 1800 | + 16 => TxbSet::Luma16, | ||
| 1801 | + 8 => TxbSet::Luma8, | ||
| 1802 | + _ => unreachable!("read_tx_size never resolves a block's own side to anything else"), | ||
| 1803 | + } | ||
| 1804 | +} | ||
| 1805 | + | ||
| 1603 | /// `tx_size_wide_unit_log2`/`tx_size_high_unit_log2`: `log2(px / 4)`, the | 1806 | /// `tx_size_wide_unit_log2`/`tx_size_high_unit_log2`: `log2(px / 4)`, the |
| 1604 | /// index [`tx_dim_to_filter_length`] and the chroma 4-vs-6 choice key on. | 1807 | /// index [`tx_dim_to_filter_length`] and the chroma 4-vs-6 choice key on. |
| 1605 | fn unit_log2(px: u32) -> i32 { | 1808 | fn unit_log2(px: u32) -> i32 { |
| @@ -2140,6 +2343,7 @@ pub fn decode_key_frame_tile( | |||
| 2140 | enable_filter_intra: bool, | 2343 | enable_filter_intra: bool, |
| 2141 | cdef: &CdefParams, | 2344 | cdef: &CdefParams, |
| 2142 | loop_filter: &LoopFilterParams, | 2345 | loop_filter: &LoopFilterParams, |
| 2346 | + tx_select: bool, | ||
| 2143 | ) -> Result<Picture> { | 2347 | ) -> Result<Picture> { |
| 2144 | decode_key_frame_tile_with_cdfs( | 2348 | decode_key_frame_tile_with_cdfs( |
| 2145 | data, | 2349 | data, |
| @@ -2152,6 +2356,7 @@ pub fn decode_key_frame_tile( | |||
| 2152 | cdef, | 2356 | cdef, |
| 2153 | loop_filter, | 2357 | loop_filter, |
| 2154 | None, | 2358 | None, |
| 2359 | + tx_select, | ||
| 2155 | ) | 2360 | ) |
| 2156 | .map(|(picture, _)| picture) | 2361 | .map(|(picture, _)| picture) |
| 2157 | } | 2362 | } |
| @@ -2175,6 +2380,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2175 | cdef: &CdefParams, | 2380 | cdef: &CdefParams, |
| 2176 | loop_filter: &LoopFilterParams, | 2381 | loop_filter: &LoopFilterParams, |
| 2177 | initial_cdfs: Option<Cdfs>, | 2382 | initial_cdfs: Option<Cdfs>, |
| 2383 | + tx_select: bool, | ||
| 2178 | ) -> Result<(Picture, Cdfs)> { | 2384 | ) -> Result<(Picture, Cdfs)> { |
| 2179 | if mi_cols == 0 || mi_rows == 0 { | 2385 | if mi_cols == 0 || mi_rows == 0 { |
| 2180 | return Err(unsupported("a frame with no mode-info grid")); | 2386 | return Err(unsupported("a frame with no mode-info grid")); |
| @@ -2280,6 +2486,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2280 | &mut v, | 2486 | &mut v, |
| 2281 | base_q_idx, | 2487 | base_q_idx, |
| 2282 | enable_filter_intra, | 2488 | enable_filter_intra, |
| 2489 | + &scan32, | ||
| 2490 | + &scan16, | ||
| 2491 | + &scan8, | ||
| 2492 | + tx_select, | ||
| 2283 | )?; | 2493 | )?; |
| 2284 | } | 2494 | } |
| 2285 | PARTITION_SPLIT => { | 2495 | PARTITION_SPLIT => { |
| @@ -2337,6 +2547,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2337 | &mut v, | 2547 | &mut v, |
| 2338 | base_q_idx, | 2548 | base_q_idx, |
| 2339 | enable_filter_intra, | 2549 | enable_filter_intra, |
| 2550 | + &scan32, | ||
| 2551 | + &scan16, | ||
| 2552 | + &scan8, | ||
| 2553 | + tx_select, | ||
| 2340 | )?; | 2554 | )?; |
| 2341 | } | 2555 | } |
| 2342 | PARTITION_SPLIT => { | 2556 | PARTITION_SPLIT => { |
| @@ -2374,6 +2588,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2374 | &mut v, | 2588 | &mut v, |
| 2375 | base_q_idx, | 2589 | base_q_idx, |
| 2376 | enable_filter_intra, | 2590 | enable_filter_intra, |
| 2591 | + &scan32, | ||
| 2592 | + &scan16, | ||
| 2593 | + &scan8, | ||
| 2594 | + tx_select, | ||
| 2377 | )?; | 2595 | )?; |
| 2378 | continue; | 2596 | continue; |
| 2379 | } | 2597 | } |
| @@ -2417,6 +2635,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2417 | &mut v, | 2635 | &mut v, |
| 2418 | base_q_idx, | 2636 | base_q_idx, |
| 2419 | enable_filter_intra, | 2637 | enable_filter_intra, |
| 2638 | + tx_select, | ||
| 2420 | )?; | 2639 | )?; |
| 2421 | prev_leaf = Some((leaf_mi, leaf_mode)); | 2640 | prev_leaf = Some((leaf_mi, leaf_mode)); |
| 2422 | } | 2641 | } |
| @@ -2479,6 +2698,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2479 | &mut v, | 2698 | &mut v, |
| 2480 | base_q_idx, | 2699 | base_q_idx, |
| 2481 | enable_filter_intra, | 2700 | enable_filter_intra, |
| 2701 | + tx_select, | ||
| 2482 | )?; | 2702 | )?; |
| 2483 | prev_leaf = Some((leaf_mi, leaf_mode)); | 2703 | prev_leaf = Some((leaf_mi, leaf_mode)); |
| 2484 | } | 2704 | } |
| @@ -3871,7 +4091,8 @@ mod tests { | |||
| 3871 | 128, | 4091 | 128, |
| 3872 | false, | 4092 | false, |
| 3873 | &CdefParams::default(), | 4093 | &CdefParams::default(), |
| 3874 | - &LoopFilterParams::default() | 4094 | + &LoopFilterParams::default(), |
| 4095 | + false | ||
| 3875 | ) | 4096 | ) |
| 3876 | .is_err() | 4097 | .is_err() |
| 3877 | ); | 4098 | ); |
| @@ -3912,6 +4133,7 @@ mod tests { | |||
| 3912 | false, | 4133 | false, |
| 3913 | &CdefParams::default(), | 4134 | &CdefParams::default(), |
| 3914 | &LoopFilterParams::default(), | 4135 | &LoopFilterParams::default(), |
| 4136 | + false, | ||
| 3915 | ) | 4137 | ) |
| 3916 | .unwrap(); | 4138 | .unwrap(); |
| 3917 | assert_eq!(decoded.width, w, "{w}x{h}: decoded width"); | 4139 | assert_eq!(decoded.width, w, "{w}x{h}: decoded width"); |
| @@ -3993,6 +4215,7 @@ mod tests { | |||
| 3993 | false, | 4215 | false, |
| 3994 | &CdefParams::default(), | 4216 | &CdefParams::default(), |
| 3995 | &LoopFilterParams::default(), | 4217 | &LoopFilterParams::default(), |
| 4218 | + false, | ||
| 3996 | ) | 4219 | ) |
| 3997 | .unwrap(); | 4220 | .unwrap(); |
| 3998 | assert!( | 4221 | assert!( |
| @@ -4176,6 +4399,7 @@ mod tests { | |||
| 4176 | false, | 4399 | false, |
| 4177 | &CdefParams::default(), | 4400 | &CdefParams::default(), |
| 4178 | &LoopFilterParams::default(), | 4401 | &LoopFilterParams::default(), |
| 4402 | + false, | ||
| 4179 | ) | 4403 | ) |
| 4180 | .unwrap(); | 4404 | .unwrap(); |
| 4181 | assert_eq!(ours.y, ffmpeg_decoded.y, "{width}x{height}: luma vs ffmpeg"); | 4405 | assert_eq!(ours.y, ffmpeg_decoded.y, "{width}x{height}: luma vs ffmpeg"); |
| @@ -4246,6 +4470,7 @@ mod tests { | |||
| 4246 | false, | 4470 | false, |
| 4247 | &CdefParams::default(), | 4471 | &CdefParams::default(), |
| 4248 | &LoopFilterParams::default(), | 4472 | &LoopFilterParams::default(), |
| 4473 | + false, | ||
| 4249 | ) | 4474 | ) |
| 4250 | .unwrap(); | 4475 | .unwrap(); |
| 4251 | assert_eq!( | 4476 | assert_eq!( |
| @@ -4519,6 +4744,7 @@ mod tests { | |||
| 4519 | false, | 4744 | false, |
| 4520 | &CdefParams::default(), | 4745 | &CdefParams::default(), |
| 4521 | &LoopFilterParams::default(), | 4746 | &LoopFilterParams::default(), |
| 4747 | + false, | ||
| 4522 | ) | 4748 | ) |
| 4523 | .unwrap(); | 4749 | .unwrap(); |
| 4524 | assert_eq!(reference.y, ffmpeg_frames[0].y, "frame 0 luma vs ffmpeg"); | 4750 | assert_eq!(reference.y, ffmpeg_frames[0].y, "frame 0 luma vs ffmpeg"); |
crates/ec-av1/src/stream.rsmodified+165 -14
| @@ -92,22 +92,22 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 92 | "a frame with cdef_bits > 0 (this decoder never reads the per-64x64 cdef_idx symbol)", | 92 | "a frame with cdef_bits > 0 (this decoder never reads the per-64x64 cdef_idx symbol)", |
| 93 | )); | 93 | )); |
| 94 | } | 94 | } |
| 95 | - // Every `decode_block` call below assumes the block's transform is | 95 | + // An intra frame's `decode_key_frame_tile*` now reads `tx_depth` |
| 96 | - // its own full size (`TxMode::Largest`, which is all this crate's own | 96 | + // under `TxMode::Select` (lane-av1txsel, spec 5.11.16): the key-frame |
| 97 | - // encoder ever writes, spec `read_tx_size` inferring the max depth | 97 | + // decode path threads `tx_select` through `decode_block`/ |
| 98 | - // with no bits) -- it never reads a `tx_depth` symbol at all. A real | 98 | + // `decode_leaf8`, and refuses on its own (a named `unsupported`, not |
| 99 | - // encoder's `TxMode::Select` (spec 5.9.2's `tx_mode` bit) codes one | 99 | + // a silent desync) the one case it still cannot code -- a resolved |
| 100 | - // per intra block, and skipping that read does not error -- the | 100 | + // 4x4 luma transform, which has no coefficient tables here. This |
| 101 | - // decoder just goes on consuming the next bits as if they were the | 101 | + // refusal is narrowed to what genuinely still has no reader at all: |
| 102 | - // uv_mode/coefficient symbols they are not, so the block "decodes" | 102 | + // `decode_inter_frame`'s inter path never threads `tx_select` |
| 103 | - // syntactically clean into low-energy garbage: lane-av1real r3's | 103 | + // through its own block loop, so an inter frame under |
| 104 | - // luma-near-flat-vs-ffmpeg-gradient bug. Refuse before that, the same | 104 | + // `TxMode::Select` still desyncs the same way the comment above used |
| 105 | - // way as the CDEF case above, rather than silently miscode every | 105 | + // to describe for every frame -- lane-av1real r3's |
| 106 | - // `TxMode::Select` stream. | 106 | + // luma-near-flat-vs-ffmpeg-gradient bug. |
| 107 | - if header.tx_mode == TxMode::Select { | 107 | + if header.tx_mode == TxMode::Select && header.frame_type != FrameType::Key { |
| 108 | return Err(Error::unsupported( | 108 | return Err(Error::unsupported( |
| 109 | "AV1 decode_stream", | 109 | "AV1 decode_stream", |
| 110 | - "a frame using TxMode::Select (this decoder never reads a tx_depth symbol, so it desyncs after the first intra block's mode)", | 110 | + "an inter frame using TxMode::Select (this decoder's inter path never reads a tx_depth symbol, so it desyncs after the first block's mode)", |
| 111 | )); | 111 | )); |
| 112 | } | 112 | } |
| 113 | // lane-av1real r11's blindness-audit sweep (`read_intra_frame_mode_info`, | 113 | // lane-av1real r11's blindness-audit sweep (`read_intra_frame_mode_info`, |
| @@ -214,6 +214,7 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 214 | &header.cdef, | 214 | &header.cdef, |
| 215 | &header.loop_filter, | 215 | &header.loop_filter, |
| 216 | initial_cdfs, | 216 | initial_cdfs, |
| 217 | + header.tx_mode == TxMode::Select, | ||
| 217 | )? | 218 | )? |
| 218 | } else { | 219 | } else { |
| 219 | let last_slot = header.ref_frame_idx[0] as usize; | 220 | let last_slot = header.ref_frame_idx[0] as usize; |
| @@ -339,6 +340,7 @@ mod tests { | |||
| 339 | false, | 340 | false, |
| 340 | &ec_av1_syntax::CdefParams::default(), | 341 | &ec_av1_syntax::CdefParams::default(), |
| 341 | &ec_av1_syntax::LoopFilterParams::default(), | 342 | &ec_av1_syntax::LoopFilterParams::default(), |
| 343 | + false, | ||
| 342 | ) | 344 | ) |
| 343 | .unwrap(); | 345 | .unwrap(); |
| 344 | let via_stream = decode_stream(&encoded.stream).unwrap(); | 346 | let via_stream = decode_stream(&encoded.stream).unwrap(); |
| @@ -996,6 +998,155 @@ mod tests { | |||
| 996 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg"); | 998 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg"); |
| 997 | } | 999 | } |
| 998 | 1000 | ||
| 1001 | + /// As [`a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact`], | ||
| 1002 | + /// but WITHOUT `--enable-tx-size-search=0` -- the one flag every other | ||
| 1003 | + /// recipe in this file pins off specifically to keep the stream on | ||
| 1004 | + /// `TxMode::Largest`. Dropped, aomenc's RD is free to pick | ||
| 1005 | + /// `TxMode::Select` and split some blocks' luma transform below their own | ||
| 1006 | + /// side (spec 5.11.16), which is what this test's `tx_depth_hits()` | ||
| 1007 | + /// counter proves actually happened -- a stream that resolves every | ||
| 1008 | + /// `tx_depth` to 0 would pixel-match by construction (identical to | ||
| 1009 | + /// `TxMode::Largest`) without exercising the new split-TU decode path at | ||
| 1010 | + /// all. Same multi-seed retry shape as | ||
| 1011 | + /// [`a_real_aomenc_inter_sequence_with_cdf_forwarding_decodes_pixel_exact`]: | ||
| 1012 | + /// aomenc's own RD is free (with tx-size search on) to also occasionally | ||
| 1013 | + /// pick `allow_screen_content_tools` on this content, a separate, | ||
| 1014 | + /// already-named refusal -- try several seeds, and the first stream that | ||
| 1015 | + /// both decodes AND actually split a transform must be pixel-exact. | ||
| 1016 | + #[test] | ||
| 1017 | + fn a_real_aomenc_intra_stream_with_tx_select_decodes_pixel_exact() { | ||
| 1018 | + if !have_ffmpeg() { | ||
| 1019 | + eprintln!( | ||
| 1020 | + "SKIP a_real_aomenc_intra_stream_with_tx_select_decodes_pixel_exact: no ffmpeg" | ||
| 1021 | + ); | ||
| 1022 | + return; | ||
| 1023 | + } | ||
| 1024 | + if !have_aomenc() { | ||
| 1025 | + eprintln!( | ||
| 1026 | + "SKIP a_real_aomenc_intra_stream_with_tx_select_decodes_pixel_exact: no aomenc at {}", | ||
| 1027 | + aomenc_path().display() | ||
| 1028 | + ); | ||
| 1029 | + return; | ||
| 1030 | + } | ||
| 1031 | + let (width, height) = (64usize, 64usize); | ||
| 1032 | + let mut refusals = Vec::new(); | ||
| 1033 | + for attempt in 0..40u32 { | ||
| 1034 | + let seed = 42 + attempt; | ||
| 1035 | + // A flat gradient never has enough local detail for the RD | ||
| 1036 | + // search to prefer a split transform over the block's own full | ||
| 1037 | + // size -- `mandelbrot`'s fractal boundary gives every attempt | ||
| 1038 | + // (a different `start_scale`) sharp, varied-frequency edges. | ||
| 1039 | + let source = format!( | ||
| 1040 | + "mandelbrot=size=64x64:start_scale={}:rate=25", | ||
| 1041 | + 3.0 - f64::from(attempt) * 0.06 | ||
| 1042 | + ); | ||
| 1043 | + let y4m = Command::new("ffmpeg") | ||
| 1044 | + .args([ | ||
| 1045 | + "-v", | ||
| 1046 | + "error", | ||
| 1047 | + "-f", | ||
| 1048 | + "lavfi", | ||
| 1049 | + "-i", | ||
| 1050 | + &source, | ||
| 1051 | + // Desaturated: chroma stays flat (constant 128) so | ||
| 1052 | + // `uv_mode` always resolves to `DC_PRED` and this | ||
| 1053 | + // decoder's still-unsupported directional-chroma round-2 | ||
| 1054 | + // gap never fires, leaving the luma detail alone to | ||
| 1055 | + // drive whether `TxMode::Select`'s RD splits a block. | ||
| 1056 | + "-vf", | ||
| 1057 | + "hue=s=0", | ||
| 1058 | + "-pix_fmt", | ||
| 1059 | + "yuv420p", | ||
| 1060 | + "-t", | ||
| 1061 | + "0.04", | ||
| 1062 | + "-f", | ||
| 1063 | + "yuv4mpegpipe", | ||
| 1064 | + "-", | ||
| 1065 | + ]) | ||
| 1066 | + .stdin(Stdio::null()) | ||
| 1067 | + .stdout(Stdio::piped()) | ||
| 1068 | + .stderr(Stdio::piped()) | ||
| 1069 | + .output() | ||
| 1070 | + .expect("ffmpeg failed to run"); | ||
| 1071 | + assert!( | ||
| 1072 | + y4m.status.success(), | ||
| 1073 | + "ffmpeg fixture: {}", | ||
| 1074 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 1075 | + ); | ||
| 1076 | + let mut child = Command::new(aomenc_path()) | ||
| 1077 | + .args([ | ||
| 1078 | + "--codec=av1", | ||
| 1079 | + "--passes=1", | ||
| 1080 | + "--end-usage=q", | ||
| 1081 | + "--cq-level=45", | ||
| 1082 | + "--cpu-used=0", | ||
| 1083 | + "--enable-rect-partitions=0", | ||
| 1084 | + "--enable-ab-partitions=0", | ||
| 1085 | + "--enable-1to4-partitions=0", | ||
| 1086 | + "--enable-filter-intra=0", | ||
| 1087 | + "--enable-angle-delta=0", | ||
| 1088 | + "--enable-cdef=0", | ||
| 1089 | + // Loop restoration is a named refusal (aomenc's RD picks | ||
| 1090 | + // Sgrproj on this kind of content) -- off in every recipe | ||
| 1091 | + // whose test targets a different surface. | ||
| 1092 | + "--enable-restoration=0", | ||
| 1093 | + "--max-partition-size=32", | ||
| 1094 | + "--enable-palette=0", | ||
| 1095 | + "--enable-intrabc=0", | ||
| 1096 | + "--enable-cfl-intra=1", | ||
| 1097 | + "--obu", | ||
| 1098 | + "-o", | ||
| 1099 | + "-", | ||
| 1100 | + "-", | ||
| 1101 | + ]) | ||
| 1102 | + .stdin(Stdio::piped()) | ||
| 1103 | + .stdout(Stdio::piped()) | ||
| 1104 | + .stderr(Stdio::piped()) | ||
| 1105 | + .spawn() | ||
| 1106 | + .expect("aomenc failed to start"); | ||
| 1107 | + child | ||
| 1108 | + .stdin | ||
| 1109 | + .take() | ||
| 1110 | + .expect("aomenc stdin") | ||
| 1111 | + .write_all(&y4m.stdout) | ||
| 1112 | + .expect("writing y4m to aomenc"); | ||
| 1113 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 1114 | + assert!( | ||
| 1115 | + out.status.success(), | ||
| 1116 | + "aomenc refused the fixture: {}", | ||
| 1117 | + String::from_utf8_lossy(&out.stderr) | ||
| 1118 | + ); | ||
| 1119 | + let stream = out.stdout; | ||
| 1120 | + let before = decode::tx_depth_hits(); | ||
| 1121 | + let frames = match decode_stream(&stream) { | ||
| 1122 | + Ok(frames) => frames, | ||
| 1123 | + Err(e) => { | ||
| 1124 | + refusals.push(format!("seed {seed}: {e}")); | ||
| 1125 | + continue; | ||
| 1126 | + } | ||
| 1127 | + }; | ||
| 1128 | + if decode::tx_depth_hits() == before { | ||
| 1129 | + refusals.push(format!( | ||
| 1130 | + "seed {seed}: decoded, but no block resolved a split tx_depth" | ||
| 1131 | + )); | ||
| 1132 | + continue; | ||
| 1133 | + } | ||
| 1134 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | ||
| 1135 | + assert_eq!( | ||
| 1136 | + frames[0].y, ffmpeg_frames[0].y, | ||
| 1137 | + "luma vs ffmpeg (seed {seed})" | ||
| 1138 | + ); | ||
| 1139 | + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})"); | ||
| 1140 | + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})"); | ||
| 1141 | + return; | ||
| 1142 | + } | ||
| 1143 | + eprintln!( | ||
| 1144 | + "SKIP a_real_aomenc_intra_stream_with_tx_select_decodes_pixel_exact: every attempt \ | ||
| 1145 | + hit a named refusal or never split a transform:\n{}", | ||
| 1146 | + refusals.join("\n") | ||
| 1147 | + ); | ||
| 1148 | + } | ||
| 1149 | + | ||
| 999 | /// As above, but a multi-frame inter sequence -- `--lag-in-frames=0 | 1150 | /// As above, but a multi-frame inter sequence -- `--lag-in-frames=0 |
| 1000 | /// --auto-alt-ref=0` keep every non-key frame a simple forward | 1151 | /// --auto-alt-ref=0` keep every non-key frame a simple forward |
| 1001 | /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this | 1152 | /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this |