Decode a real (non-straddle) SPLIT of a 16x16 leaf, fix the whole-64x64-superblock dequant scale
Browse files at this commit761f32ceafcb28be4300599768960dda5f49fadcParent: 24df967- fix
- decode a real (non-straddle) SPLIT of a 16x16 leaf, fix the whole-64x64-superblock dequant scale
1 changed file +62 -14
- crates/ec-av1/src/decode.rs +62 -14
crates/ec-av1/src/decode.rsmodified+62 -14
| @@ -237,9 +237,9 @@ fn read_coeffs( | |||
| 237 | if let Some(tx_type) = coding.tx_type.as_deref_mut() { | 237 | if let Some(tx_type) = coding.tx_type.as_deref_mut() { |
| 238 | let t = dec.symbol(tx_type); | 238 | let t = dec.symbol(tx_type); |
| 239 | if t != 1 { | 239 | if t != 1 { |
| 240 | - return Err(unsupported( | 240 | + return Err(unsupported(format!( |
| 241 | - "a transform type other than DCT_DCT (round 2: inter/other intra tx sets)", | 241 | + "a transform type other than DCT_DCT (round 2: inter/other intra tx sets), symbol {t}" |
| 242 | - )); | 242 | + ))); |
| 243 | } | 243 | } |
| 244 | } | 244 | } |
| 245 | 245 | ||
| @@ -655,16 +655,20 @@ fn read_plane( | |||
| 655 | let levels = if tx_side == side { | 655 | let levels = if tx_side == side { |
| 656 | grid | 656 | grid |
| 657 | } else { | 657 | } else { |
| 658 | - let mut full = vec![0i32; tx_side * tx_side]; | 658 | + // `grid` is `tx_side x tx_side` (the coded corner); `dequant_and_inverse` |
| 659 | - for row in 0..side { | 659 | + // wants the true `side x side` transform, with dqDenom (spec 7.12.3) |
| 660 | - full[row * tx_side..][..side].copy_from_slice(&grid[row * side..][..side]); | 660 | + // keyed by that true size, not the coded corner's -- so the corner |
| 661 | + // goes into the top-left of a `side`-sized grid, not the reverse. | ||
| 662 | + let mut full = vec![0i32; side * side]; | ||
| 663 | + for row in 0..tx_side { | ||
| 664 | + full[row * side..][..tx_side].copy_from_slice(&grid[row * tx_side..][..tx_side]); | ||
| 661 | } | 665 | } |
| 662 | full | 666 | full |
| 663 | }; | 667 | }; |
| 664 | - let residual = dequant_and_inverse(&levels, tx_side, 8, i32::from(base_q_idx)); | 668 | + let residual = dequant_and_inverse(&levels, side, 8, i32::from(base_q_idx)); |
| 665 | - plane.reconstruct(x, y, tx_side, predict_mode, reach, &residual); | 669 | + plane.reconstruct(x, y, side, predict_mode, reach, &residual); |
| 666 | Ok(if tx_side == side { | 670 | Ok(if tx_side == side { |
| 667 | - residual_grid_placeholder(&levels, tx_side) | 671 | + residual_grid_placeholder(&levels, side) |
| 668 | } else { | 672 | } else { |
| 669 | levels | 673 | levels |
| 670 | }) | 674 | }) |
| @@ -1075,11 +1079,7 @@ pub fn decode_key_frame_tile( | |||
| 1075 | let ctx16 = neighbours.partition_ctx(at16, SUB); | 1079 | let ctx16 = neighbours.partition_ctx(at16, SUB); |
| 1076 | if has_cols16 && has_rows16 { | 1080 | if has_cols16 && has_rows16 { |
| 1077 | let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); | 1081 | let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); |
| 1078 | - if part16 != PARTITION_NONE { | 1082 | + if part16 == PARTITION_NONE { |
| 1079 | - return Err(unsupported( | ||
| 1080 | - "a partition below 16x16 (this encoder never writes one)", | ||
| 1081 | - )); | ||
| 1082 | - } | ||
| 1083 | decode_block( | 1083 | decode_block( |
| 1084 | &mut dec, | 1084 | &mut dec, |
| 1085 | &mut cdfs, | 1085 | &mut cdfs, |
| @@ -1099,6 +1099,54 @@ pub fn decode_key_frame_tile( | |||
| 1099 | )?; | 1099 | )?; |
| 1100 | continue; | 1100 | continue; |
| 1101 | } | 1101 | } |
| 1102 | + if part16 != PARTITION_SPLIT { | ||
| 1103 | + return Err(unsupported( | ||
| 1104 | + "a partition below 16x16 other than a clean split (this encoder never writes one)", | ||
| 1105 | + )); | ||
| 1106 | + } | ||
| 1107 | + // A real (non-straddle) SPLIT of a | ||
| 1108 | + // whole 16x16 into four 8x8 leaves -- | ||
| 1109 | + // the same recursion the straddle | ||
| 1110 | + // path below already runs when the | ||
| 1111 | + // true frame edge forces it, just | ||
| 1112 | + // over all four positions instead of | ||
| 1113 | + // the one or two the edge leaves. | ||
| 1114 | + let (mi_row0, mi_col0) = | ||
| 1115 | + (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | ||
| 1116 | + let mut prev_leaf: Option<((usize, usize), usize)> = None; | ||
| 1117 | + for i in 0..4 { | ||
| 1118 | + let (mr, mc) = | ||
| 1119 | + (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2); | ||
| 1120 | + let leaf_mi = (mr as usize, mc as usize); | ||
| 1121 | + let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); | ||
| 1122 | + let part8 = | ||
| 1123 | + dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | ||
| 1124 | + if part8 != PARTITION_NONE { | ||
| 1125 | + return Err(unsupported( | ||
| 1126 | + "a partition below 8x8 (this encoder never writes one)", | ||
| 1127 | + )); | ||
| 1128 | + } | ||
| 1129 | + let leaf_mode = decode_leaf8( | ||
| 1130 | + &mut dec, | ||
| 1131 | + &mut cdfs, | ||
| 1132 | + &mut neighbours, | ||
| 1133 | + at16, | ||
| 1134 | + leaf_mi, | ||
| 1135 | + (&scan8, &scan4), | ||
| 1136 | + prev_leaf, | ||
| 1137 | + &mut y, | ||
| 1138 | + &mut u, | ||
| 1139 | + &mut v, | ||
| 1140 | + base_q_idx, | ||
| 1141 | + )?; | ||
| 1142 | + prev_leaf = Some((leaf_mi, leaf_mode)); | ||
| 1143 | + } | ||
| 1144 | + if let Some((_, mode)) = prev_leaf { | ||
| 1145 | + neighbours.above_mode[sc] = mode; | ||
| 1146 | + neighbours.left_mode[sr] = mode; | ||
| 1147 | + } | ||
| 1148 | + continue; | ||
| 1149 | + } | ||
| 1102 | // The true edge falls inside this 16x16 | 1150 | // The true edge falls inside this 16x16 |
| 1103 | // leaf itself (mod-32==8 target sizes, | 1151 | // leaf itself (mod-32==8 target sizes, |
| 1104 | // lane-av1-rect): one axis only -- an 8x8 | 1152 | // lane-av1-rect): one axis only -- an 8x8 |