Merge branch 'lane-tiles': multi-tile decode, gated on real streams
Browse files at this commit9 changed files +895 -89
- crates/ec-av1/src/decode.rs +154 -26
- crates/ec-av1/src/mvstack.rs +33 -3
- crates/ec-av1/src/refusal_inventory.rs +0 -3
- crates/ec-av1/src/stream.rs +400 -57
- lanes/tiles-r5.charter.md +44 -0
- lanes/tiles-r6.charter.md +40 -0
- lanes/tiles-r6.report.md +81 -0
- lanes/tiles-r7.charter.md +52 -0
- lanes/tiles-r7.report.md +91 -0
crates/ec-av1/src/decode.rsmodified+154 -26
| @@ -2844,6 +2844,13 @@ struct PlaneBuf { | |||
| 2844 | /// right/bottom reach bound is still open, tracked in the report. | 2844 | /// right/bottom reach bound is still open, tracked in the report. |
| 2845 | tile_x0: usize, | 2845 | tile_x0: usize, |
| 2846 | tile_y0: usize, | 2846 | tile_y0: usize, |
| 2847 | + /// lane-tiles r5: this plane's own tile's right/bottom pixel bound | ||
| 2848 | + /// (exclusive) -- a non-last tile column/row's own reach must stop at | ||
| 2849 | + /// its own SB-aligned tile boundary. `width`/`height` (this plane's | ||
| 2850 | + /// full padded extent) for the single-tile/last-tile case, matching the | ||
| 2851 | + /// old unclipped behaviour exactly. | ||
| 2852 | + tile_x1: usize, | ||
| 2853 | + tile_y1: usize, | ||
| 2847 | } | 2854 | } |
| 2848 | 2855 | ||
| 2849 | /// One entry per `MV_REFERENCE_FRAME` (index 0/1 unused -- `NONE`/ | 2856 | /// One entry per `MV_REFERENCE_FRAME` (index 0/1 unused -- `NONE`/ |
| @@ -2859,9 +2866,11 @@ impl PlaneBuf { | |||
| 2859 | /// [`Self::tile_y0`]) before that tile's own superblock walk. `x0`/`y0` | 2866 | /// [`Self::tile_y0`]) before that tile's own superblock walk. `x0`/`y0` |
| 2860 | /// are already in this plane's own units (luma pixels for `y`, chroma | 2867 | /// are already in this plane's own units (luma pixels for `y`, chroma |
| 2861 | /// pixels — halved — for `u`/`v`). | 2868 | /// pixels — halved — for `u`/`v`). |
| 2862 | - fn set_tile_origin(&mut self, x0: usize, y0: usize) { | 2869 | + fn set_tile_origin(&mut self, x0: usize, y0: usize, x1: usize, y1: usize) { |
| 2863 | self.tile_x0 = x0; | 2870 | self.tile_x0 = x0; |
| 2864 | self.tile_y0 = y0; | 2871 | self.tile_y0 = y0; |
| 2872 | + self.tile_x1 = x1; | ||
| 2873 | + self.tile_y1 = y1; | ||
| 2865 | } | 2874 | } |
| 2866 | 2875 | ||
| 2867 | fn edges( | 2876 | fn edges( |
| @@ -2877,14 +2886,16 @@ impl PlaneBuf { | |||
| 2877 | } else { | 2886 | } else { |
| 2878 | own_across | 2887 | own_across |
| 2879 | } | 2888 | } |
| 2880 | - .min(self.width); | 2889 | + .min(self.width) |
| 2890 | + .min(self.tile_x1); | ||
| 2881 | let own_down = y + side.min(self.true_height.saturating_sub(y)); | 2891 | let own_down = y + side.min(self.true_height.saturating_sub(y)); |
| 2882 | let down = if reach.below_left { | 2892 | let down = if reach.below_left { |
| 2883 | own_down + side.min(self.true_height.saturating_sub(own_down)) | 2893 | own_down + side.min(self.true_height.saturating_sub(own_down)) |
| 2884 | } else { | 2894 | } else { |
| 2885 | own_down | 2895 | own_down |
| 2886 | } | 2896 | } |
| 2887 | - .min(self.height); | 2897 | + .min(self.height) |
| 2898 | + .min(self.tile_y1); | ||
| 2888 | let above = (y > self.tile_y0 && across > x) | 2899 | let above = (y > self.tile_y0 && across > x) |
| 2889 | .then(|| self.data[(y - 1) * self.width + x..][..across - x].to_vec()); | 2900 | .then(|| self.data[(y - 1) * self.width + x..][..across - x].to_vec()); |
| 2890 | let left = (x > self.tile_x0 && down > y).then(|| { | 2901 | let left = (x > self.tile_x0 && down > y).then(|| { |
| @@ -2914,14 +2925,16 @@ impl PlaneBuf { | |||
| 2914 | } else { | 2925 | } else { |
| 2915 | own_across | 2926 | own_across |
| 2916 | } | 2927 | } |
| 2917 | - .min(self.width); | 2928 | + .min(self.width) |
| 2929 | + .min(self.tile_x1); | ||
| 2918 | let own_down = y + bh.min(self.true_height.saturating_sub(y)); | 2930 | let own_down = y + bh.min(self.true_height.saturating_sub(y)); |
| 2919 | let down = if reach.below_left { | 2931 | let down = if reach.below_left { |
| 2920 | own_down + bh.min(self.true_height.saturating_sub(own_down)) | 2932 | own_down + bh.min(self.true_height.saturating_sub(own_down)) |
| 2921 | } else { | 2933 | } else { |
| 2922 | own_down | 2934 | own_down |
| 2923 | } | 2935 | } |
| 2924 | - .min(self.height); | 2936 | + .min(self.height) |
| 2937 | + .min(self.tile_y1); | ||
| 2925 | let above = (y > self.tile_y0 && across > x) | 2938 | let above = (y > self.tile_y0 && across > x) |
| 2926 | .then(|| self.data[(y - 1) * self.width + x..][..across - x].to_vec()); | 2939 | .then(|| self.data[(y - 1) * self.width + x..][..across - x].to_vec()); |
| 2927 | let left = (x > self.tile_x0 && down > y).then(|| { | 2940 | let left = (x > self.tile_x0 && down > y).then(|| { |
| @@ -4818,6 +4831,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 4818 | true_height, | 4831 | true_height, |
| 4819 | tile_x0: 0, | 4832 | tile_x0: 0, |
| 4820 | tile_y0: 0, | 4833 | tile_y0: 0, |
| 4834 | + tile_x1: width, | ||
| 4835 | + tile_y1: height, | ||
| 4821 | }; | 4836 | }; |
| 4822 | let mut u = PlaneBuf { | 4837 | let mut u = PlaneBuf { |
| 4823 | data: vec![0u8; width * height / 4], | 4838 | data: vec![0u8; width * height / 4], |
| @@ -4827,6 +4842,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 4827 | true_height: true_height / 2, | 4842 | true_height: true_height / 2, |
| 4828 | tile_x0: 0, | 4843 | tile_x0: 0, |
| 4829 | tile_y0: 0, | 4844 | tile_y0: 0, |
| 4845 | + tile_x1: width / 2, | ||
| 4846 | + tile_y1: height / 2, | ||
| 4830 | }; | 4847 | }; |
| 4831 | let mut v = PlaneBuf { | 4848 | let mut v = PlaneBuf { |
| 4832 | data: vec![0u8; width * height / 4], | 4849 | data: vec![0u8; width * height / 4], |
| @@ -4836,6 +4853,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 4836 | true_height: true_height / 2, | 4853 | true_height: true_height / 2, |
| 4837 | tile_x0: 0, | 4854 | tile_x0: 0, |
| 4838 | tile_y0: 0, | 4855 | tile_y0: 0, |
| 4856 | + tile_x1: width / 2, | ||
| 4857 | + tile_y1: height / 2, | ||
| 4839 | }; | 4858 | }; |
| 4840 | 4859 | ||
| 4841 | let scan32 = default_scan(TX32); | 4860 | let scan32 = default_scan(TX32); |
| @@ -4888,9 +4907,24 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 4888 | } | 4907 | } |
| 4889 | let mut dec = SymbolDecoder::new(tile_bytes); | 4908 | let mut dec = SymbolDecoder::new(tile_bytes); |
| 4890 | neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize); | 4909 | neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize); |
| 4891 | - y.set_tile_origin(mi_col0 as usize * 4, mi_row0 as usize * 4); | 4910 | + y.set_tile_origin( |
| 4892 | - u.set_tile_origin(mi_col0 as usize * 2, mi_row0 as usize * 2); | 4911 | + mi_col0 as usize * 4, |
| 4893 | - v.set_tile_origin(mi_col0 as usize * 2, mi_row0 as usize * 2); | 4912 | + mi_row0 as usize * 4, |
| 4913 | + (mi_col1 as usize * 4).min(y.width), | ||
| 4914 | + (mi_row1 as usize * 4).min(y.height), | ||
| 4915 | + ); | ||
| 4916 | + u.set_tile_origin( | ||
| 4917 | + mi_col0 as usize * 2, | ||
| 4918 | + mi_row0 as usize * 2, | ||
| 4919 | + (mi_col1 as usize * 2).min(u.width), | ||
| 4920 | + (mi_row1 as usize * 2).min(u.height), | ||
| 4921 | + ); | ||
| 4922 | + v.set_tile_origin( | ||
| 4923 | + mi_col0 as usize * 2, | ||
| 4924 | + mi_row0 as usize * 2, | ||
| 4925 | + (mi_col1 as usize * 2).min(v.width), | ||
| 4926 | + (mi_row1 as usize * 2).min(v.height), | ||
| 4927 | + ); | ||
| 4894 | TILE_HITS.with(|c| c.set(c.get() + 1)); | 4928 | TILE_HITS.with(|c| c.set(c.get() + 1)); |
| 4895 | 4929 | ||
| 4896 | for sb_r in sb_r0..sb_r1 { | 4930 | for sb_r in sb_r0..sb_r1 { |
| @@ -9455,8 +9489,14 @@ pub fn decode_inter_frame_tile( | |||
| 9455 | enable_dual_filter: bool, | 9489 | enable_dual_filter: bool, |
| 9456 | reference_select: bool, | 9490 | reference_select: bool, |
| 9457 | ) -> Result<Picture> { | 9491 | ) -> Result<Picture> { |
| 9492 | + let single_tile = TileInfo { | ||
| 9493 | + mi_col_starts: vec![0, mi_cols], | ||
| 9494 | + mi_row_starts: vec![0, mi_rows], | ||
| 9495 | + ..TileInfo::default() | ||
| 9496 | + }; | ||
| 9458 | decode_inter_frame_tile_with_cdfs( | 9497 | decode_inter_frame_tile_with_cdfs( |
| 9459 | - data, | 9498 | + &[data], |
| 9499 | + &single_tile, | ||
| 9460 | mi_cols, | 9500 | mi_cols, |
| 9461 | mi_rows, | 9501 | mi_rows, |
| 9462 | base_q_idx, | 9502 | base_q_idx, |
| @@ -9497,7 +9537,8 @@ pub fn decode_inter_frame_tile( | |||
| 9497 | /// `primary_ref_frame == PRIMARY_REF_NONE` too (an error-resilient stream), | 9537 | /// `primary_ref_frame == PRIMARY_REF_NONE` too (an error-resilient stream), |
| 9498 | /// so `None` is a real case here, not only a convenience default. | 9538 | /// so `None` is a real case here, not only a convenience default. |
| 9499 | pub(crate) fn decode_inter_frame_tile_with_cdfs( | 9539 | pub(crate) fn decode_inter_frame_tile_with_cdfs( |
| 9500 | - data: &[u8], | 9540 | + tiles: &[&[u8]], |
| 9541 | + tile_info: &TileInfo, | ||
| 9501 | mi_cols: u32, | 9542 | mi_cols: u32, |
| 9502 | mi_rows: u32, | 9543 | mi_rows: u32, |
| 9503 | base_q_idx: u8, | 9544 | base_q_idx: u8, |
| @@ -9587,6 +9628,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9587 | true_height: reference.height, | 9628 | true_height: reference.height, |
| 9588 | tile_x0: 0, | 9629 | tile_x0: 0, |
| 9589 | tile_y0: 0, | 9630 | tile_y0: 0, |
| 9631 | + tile_x1: reference.width, | ||
| 9632 | + tile_y1: reference.height, | ||
| 9590 | }; | 9633 | }; |
| 9591 | let ref_u = PlaneBuf { | 9634 | let ref_u = PlaneBuf { |
| 9592 | data: reference.u.clone(), | 9635 | data: reference.u.clone(), |
| @@ -9596,6 +9639,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9596 | true_height: reference.height / 2, | 9639 | true_height: reference.height / 2, |
| 9597 | tile_x0: 0, | 9640 | tile_x0: 0, |
| 9598 | tile_y0: 0, | 9641 | tile_y0: 0, |
| 9642 | + tile_x1: reference.width / 2, | ||
| 9643 | + tile_y1: reference.height / 2, | ||
| 9599 | }; | 9644 | }; |
| 9600 | let ref_v = PlaneBuf { | 9645 | let ref_v = PlaneBuf { |
| 9601 | data: reference.v.clone(), | 9646 | data: reference.v.clone(), |
| @@ -9605,6 +9650,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9605 | true_height: reference.height / 2, | 9650 | true_height: reference.height / 2, |
| 9606 | tile_x0: 0, | 9651 | tile_x0: 0, |
| 9607 | tile_y0: 0, | 9652 | tile_y0: 0, |
| 9653 | + tile_x1: reference.width / 2, | ||
| 9654 | + tile_y1: reference.height / 2, | ||
| 9608 | }; | 9655 | }; |
| 9609 | // Every non-`LAST_FRAME` reference this frame header's own `ref_frame_idx` | 9656 | // Every non-`LAST_FRAME` reference this frame header's own `ref_frame_idx` |
| 9610 | // names a live DPB slot for (lane-av1refs: generalised from the old | 9657 | // names a live DPB slot for (lane-av1refs: generalised from the old |
| @@ -9626,6 +9673,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9626 | true_height: g.height, | 9673 | true_height: g.height, |
| 9627 | tile_x0: 0, | 9674 | tile_x0: 0, |
| 9628 | tile_y0: 0, | 9675 | tile_y0: 0, |
| 9676 | + tile_x1: g.width, | ||
| 9677 | + tile_y1: g.height, | ||
| 9629 | }, | 9678 | }, |
| 9630 | PlaneBuf { | 9679 | PlaneBuf { |
| 9631 | data: g.u.clone(), | 9680 | data: g.u.clone(), |
| @@ -9635,6 +9684,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9635 | true_height: g.height / 2, | 9684 | true_height: g.height / 2, |
| 9636 | tile_x0: 0, | 9685 | tile_x0: 0, |
| 9637 | tile_y0: 0, | 9686 | tile_y0: 0, |
| 9687 | + tile_x1: g.width / 2, | ||
| 9688 | + tile_y1: g.height / 2, | ||
| 9638 | }, | 9689 | }, |
| 9639 | PlaneBuf { | 9690 | PlaneBuf { |
| 9640 | data: g.v.clone(), | 9691 | data: g.v.clone(), |
| @@ -9644,6 +9695,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9644 | true_height: g.height / 2, | 9695 | true_height: g.height / 2, |
| 9645 | tile_x0: 0, | 9696 | tile_x0: 0, |
| 9646 | tile_y0: 0, | 9697 | tile_y0: 0, |
| 9698 | + tile_x1: g.width / 2, | ||
| 9699 | + tile_y1: g.height / 2, | ||
| 9647 | }, | 9700 | }, |
| 9648 | ) | 9701 | ) |
| 9649 | }) | 9702 | }) |
| @@ -9659,6 +9712,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9659 | true_height, | 9712 | true_height, |
| 9660 | tile_x0: 0, | 9713 | tile_x0: 0, |
| 9661 | tile_y0: 0, | 9714 | tile_y0: 0, |
| 9715 | + tile_x1: width, | ||
| 9716 | + tile_y1: height, | ||
| 9662 | }; | 9717 | }; |
| 9663 | let mut u = PlaneBuf { | 9718 | let mut u = PlaneBuf { |
| 9664 | data: vec![0u8; width * height / 4], | 9719 | data: vec![0u8; width * height / 4], |
| @@ -9668,6 +9723,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9668 | true_height: true_height / 2, | 9723 | true_height: true_height / 2, |
| 9669 | tile_x0: 0, | 9724 | tile_x0: 0, |
| 9670 | tile_y0: 0, | 9725 | tile_y0: 0, |
| 9726 | + tile_x1: width / 2, | ||
| 9727 | + tile_y1: height / 2, | ||
| 9671 | }; | 9728 | }; |
| 9672 | let mut v = PlaneBuf { | 9729 | let mut v = PlaneBuf { |
| 9673 | data: vec![0u8; width * height / 4], | 9730 | data: vec![0u8; width * height / 4], |
| @@ -9677,6 +9734,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9677 | true_height: true_height / 2, | 9734 | true_height: true_height / 2, |
| 9678 | tile_x0: 0, | 9735 | tile_x0: 0, |
| 9679 | tile_y0: 0, | 9736 | tile_y0: 0, |
| 9737 | + tile_x1: width / 2, | ||
| 9738 | + tile_y1: height / 2, | ||
| 9680 | }; | 9739 | }; |
| 9681 | 9740 | ||
| 9682 | let scan32 = default_scan(TX32); | 9741 | let scan32 = default_scan(TX32); |
| @@ -9684,18 +9743,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9684 | let scan8 = default_scan(TX8); | 9743 | let scan8 = default_scan(TX8); |
| 9685 | let scan4 = default_scan(TX4); | 9744 | let scan4 = default_scan(TX4); |
| 9686 | 9745 | ||
| 9687 | - let mut cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx))); | 9746 | + let base_cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx))); |
| 9688 | - let mut dec = SymbolDecoder::new(data); | 9747 | + let mut result_cdfs = base_cdfs.clone(); |
| 9689 | - // lane-comppin r9: tile-entry range, the earliest point comparable | ||
| 9690 | - // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the | ||
| 9691 | - // first ladder rung before any symbol (partition or otherwise) is read. | ||
| 9692 | - if std::env::var_os("EC_AV1_TELL").is_some() { | ||
| 9693 | - eprintln!( | ||
| 9694 | - "TELL label=tile_init tell={} range={}", | ||
| 9695 | - dec.debug_bitpos(), | ||
| 9696 | - dec.debug_state().0 | ||
| 9697 | - ); | ||
| 9698 | - } | ||
| 9699 | let mut neighbours = Neighbours::new( | 9748 | let mut neighbours = Neighbours::new( |
| 9700 | cols as usize * 2, | 9749 | cols as usize * 2, |
| 9701 | rows as usize * 2, | 9750 | rows as usize * 2, |
| @@ -9704,9 +9753,73 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 9704 | ); | 9753 | ); |
| 9705 | let mut grid = MiGrid::new(mi_cols as usize, mi_rows as usize); | 9754 | let mut grid = MiGrid::new(mi_cols as usize, mi_rows as usize); |
| 9706 | 9755 | ||
| 9707 | - for sb_r in 0..sb_rows { | 9756 | + // lane-tiles r6: mirrors decode_key_frame_tile_with_cdfs's own per-tile |
| 9757 | + // loop (spec 5.11.2 decode_tile / 7.20 exit_symbol) -- each tile gets | ||
| 9758 | + // its own fresh SymbolDecoder over its own byte range and its own fresh | ||
| 9759 | + // copy of the frame's initial CDFs; only context_update_tile_id's own | ||
| 9760 | + // end-of-tile adapted table becomes the frame's own output. | ||
| 9761 | + for (tile_idx, &data) in tiles.iter().enumerate() { | ||
| 9762 | + let tile_num = tile_idx as u32; | ||
| 9763 | + let (trow, tcol) = (tile_num / tile_info.cols, tile_num % tile_info.cols); | ||
| 9764 | + let mi_row0 = tile_info.mi_row_starts[trow as usize]; | ||
| 9765 | + let mi_row1 = tile_info.mi_row_starts[trow as usize + 1]; | ||
| 9766 | + let mi_col0 = tile_info.mi_col_starts[tcol as usize]; | ||
| 9767 | + let mi_col1 = tile_info.mi_col_starts[tcol as usize + 1]; | ||
| 9768 | + let (sb_r0, sb_r1) = ( | ||
| 9769 | + (mi_row0 / SB_MI).min(sb_rows), | ||
| 9770 | + mi_row1.div_ceil(SB_MI).min(sb_rows), | ||
| 9771 | + ); | ||
| 9772 | + let (sb_c0, sb_c1) = ( | ||
| 9773 | + (mi_col0 / SB_MI).min(sb_cols), | ||
| 9774 | + mi_col1.div_ceil(SB_MI).min(sb_cols), | ||
| 9775 | + ); | ||
| 9776 | + let mut cdfs = base_cdfs.clone(); | ||
| 9777 | + let mut dec = SymbolDecoder::new(data); | ||
| 9778 | + // lane-comppin r9: tile-entry range, the earliest point comparable | ||
| 9779 | + // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the | ||
| 9780 | + // first ladder rung before any symbol (partition or otherwise) is read. | ||
| 9781 | + if std::env::var_os("EC_AV1_TELL").is_some() { | ||
| 9782 | + eprintln!( | ||
| 9783 | + "TELL label=tile_init tell={} range={}", | ||
| 9784 | + dec.debug_bitpos(), | ||
| 9785 | + dec.debug_state().0 | ||
| 9786 | + ); | ||
| 9787 | + } | ||
| 9788 | + neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize); | ||
| 9789 | + y.set_tile_origin( | ||
| 9790 | + mi_col0 as usize * 4, | ||
| 9791 | + mi_row0 as usize * 4, | ||
| 9792 | + (mi_col1 as usize * 4).min(y.width), | ||
| 9793 | + (mi_row1 as usize * 4).min(y.height), | ||
| 9794 | + ); | ||
| 9795 | + u.set_tile_origin( | ||
| 9796 | + mi_col0 as usize * 2, | ||
| 9797 | + mi_row0 as usize * 2, | ||
| 9798 | + (mi_col1 as usize * 2).min(u.width), | ||
| 9799 | + (mi_row1 as usize * 2).min(u.height), | ||
| 9800 | + ); | ||
| 9801 | + v.set_tile_origin( | ||
| 9802 | + mi_col0 as usize * 2, | ||
| 9803 | + mi_row0 as usize * 2, | ||
| 9804 | + (mi_col1 as usize * 2).min(v.width), | ||
| 9805 | + (mi_row1 as usize * 2).min(v.height), | ||
| 9806 | + ); | ||
| 9807 | + // lane-tiles r6: an MV candidate scan (mvstack.rs's grid.get) must | ||
| 9808 | + // not reach across a tile boundary any more than intra prediction's | ||
| 9809 | + // PlaneBuf reach does -- bounding the shared grid's own read window | ||
| 9810 | + // per tile is equivalent to threading tile bounds through every | ||
| 9811 | + // find_mv_stack* call site (all four read through this one grid). | ||
| 9812 | + grid.set_tile_bounds( | ||
| 9813 | + mi_row0 as usize, | ||
| 9814 | + mi_col0 as usize, | ||
| 9815 | + mi_row1 as usize, | ||
| 9816 | + mi_col1 as usize, | ||
| 9817 | + ); | ||
| 9818 | + TILE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 9819 | + | ||
| 9820 | + for sb_r in sb_r0..sb_r1 { | ||
| 9708 | neighbours.start_row(); | 9821 | neighbours.start_row(); |
| 9709 | - for sb_c in 0..sb_cols { | 9822 | + for sb_c in sb_c0..sb_c1 { |
| 9710 | CDEF_TRANSMITTED.with(|c| c.set(false)); | 9823 | CDEF_TRANSMITTED.with(|c| c.set(false)); |
| 9711 | let sb_at = (sb_r as usize * 4, sb_c as usize * 4); | 9824 | let sb_at = (sb_r as usize * 4, sb_c as usize * 4); |
| 9712 | let sb_ctx = neighbours.partition_ctx(sb_at, SB); | 9825 | let sb_ctx = neighbours.partition_ctx(sb_at, SB); |
| @@ -10896,6 +11009,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 10896 | } | 11009 | } |
| 10897 | } | 11010 | } |
| 10898 | 11011 | ||
| 11012 | + if tile_num == tile_info.context_update_tile_id { | ||
| 11013 | + result_cdfs = cdfs; | ||
| 11014 | + } | ||
| 11015 | + } | ||
| 11016 | + | ||
| 10899 | // lane-comppin r4: pre-loop-filter decode-order dump, matching aomdec's | 11017 | // lane-comppin r4: pre-loop-filter decode-order dump, matching aomdec's |
| 10900 | // own EC_AV1_PREFILT_DUMP shape (decodeframe.c ~5451) -- diffs against | 11018 | // own EC_AV1_PREFILT_DUMP shape (decodeframe.c ~5451) -- diffs against |
| 10901 | // that isolate whether a decode-order frame's mismatch already exists | 11019 | // that isolate whether a decode-order frame's mismatch already exists |
| @@ -10933,7 +11051,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 10933 | u: u.data, | 11051 | u: u.data, |
| 10934 | v: v.data, | 11052 | v: v.data, |
| 10935 | }, | 11053 | }, |
| 10936 | - cdfs, | 11054 | + result_cdfs, |
| 10937 | motion_field, | 11055 | motion_field, |
| 10938 | )); | 11056 | )); |
| 10939 | } | 11057 | } |
| @@ -10952,7 +11070,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 10952 | u: crop(&u, fw / 2, fh / 2), | 11070 | u: crop(&u, fw / 2, fh / 2), |
| 10953 | v: crop(&v, fw / 2, fh / 2), | 11071 | v: crop(&v, fw / 2, fh / 2), |
| 10954 | }, | 11072 | }, |
| 10955 | - cdfs, | 11073 | + result_cdfs, |
| 10956 | motion_field, | 11074 | motion_field, |
| 10957 | )) | 11075 | )) |
| 10958 | } | 11076 | } |
| @@ -11621,6 +11739,8 @@ mod tests { | |||
| 11621 | true_height: height / scale, | 11739 | true_height: height / scale, |
| 11622 | tile_x0: 0, | 11740 | tile_x0: 0, |
| 11623 | tile_y0: 0, | 11741 | tile_y0: 0, |
| 11742 | + tile_x1: width / scale, | ||
| 11743 | + tile_y1: height / scale, | ||
| 11624 | }; | 11744 | }; |
| 11625 | let ref_y = PlaneBuf { | 11745 | let ref_y = PlaneBuf { |
| 11626 | data: ref_pattern.clone(), | 11746 | data: ref_pattern.clone(), |
| @@ -11630,6 +11750,8 @@ mod tests { | |||
| 11630 | true_height: height, | 11750 | true_height: height, |
| 11631 | tile_x0: 0, | 11751 | tile_x0: 0, |
| 11632 | tile_y0: 0, | 11752 | tile_y0: 0, |
| 11753 | + tile_x1: width, | ||
| 11754 | + tile_y1: height, | ||
| 11633 | }; | 11755 | }; |
| 11634 | let ref_u = ref_plane(2); | 11756 | let ref_u = ref_plane(2); |
| 11635 | let ref_v = ref_plane(2); | 11757 | let ref_v = ref_plane(2); |
| @@ -11642,6 +11764,8 @@ mod tests { | |||
| 11642 | true_height: height, | 11764 | true_height: height, |
| 11643 | tile_x0: 0, | 11765 | tile_x0: 0, |
| 11644 | tile_y0: 0, | 11766 | tile_y0: 0, |
| 11767 | + tile_x1: width, | ||
| 11768 | + tile_y1: height, | ||
| 11645 | }; | 11769 | }; |
| 11646 | let mut u = PlaneBuf { | 11770 | let mut u = PlaneBuf { |
| 11647 | data: vec![0u8; (width / 2) * (height / 2)], | 11771 | data: vec![0u8; (width / 2) * (height / 2)], |
| @@ -11651,6 +11775,8 @@ mod tests { | |||
| 11651 | true_height: height / 2, | 11775 | true_height: height / 2, |
| 11652 | tile_x0: 0, | 11776 | tile_x0: 0, |
| 11653 | tile_y0: 0, | 11777 | tile_y0: 0, |
| 11778 | + tile_x1: width / 2, | ||
| 11779 | + tile_y1: height / 2, | ||
| 11654 | }; | 11780 | }; |
| 11655 | let mut v = PlaneBuf { | 11781 | let mut v = PlaneBuf { |
| 11656 | data: vec![0u8; (width / 2) * (height / 2)], | 11782 | data: vec![0u8; (width / 2) * (height / 2)], |
| @@ -11660,6 +11786,8 @@ mod tests { | |||
| 11660 | true_height: height / 2, | 11786 | true_height: height / 2, |
| 11661 | tile_x0: 0, | 11787 | tile_x0: 0, |
| 11662 | tile_y0: 0, | 11788 | tile_y0: 0, |
| 11789 | + tile_x1: width / 2, | ||
| 11790 | + tile_y1: height / 2, | ||
| 11663 | }; | 11791 | }; |
| 11664 | 11792 | ||
| 11665 | let mut cdfs = Cdfs::new(q_ctx_of(100)); | 11793 | let mut cdfs = Cdfs::new(q_ctx_of(100)); |
crates/ec-av1/src/mvstack.rsmodified+33 -3
| @@ -177,6 +177,15 @@ pub struct MiGrid { | |||
| 177 | cols: usize, | 177 | cols: usize, |
| 178 | rows: usize, | 178 | rows: usize, |
| 179 | cells: Vec<Option<MiInfo>>, | 179 | cells: Vec<Option<MiInfo>>, |
| 180 | + /// lane-tiles r6: the current tile's own mi-unit bounds (spec: an MV | ||
| 181 | + /// candidate scan never reaches across a tile boundary, mirroring | ||
| 182 | + /// `PlaneBuf`'s `tile_x0`/`tile_x1` reach clamp for intra prediction). | ||
| 183 | + /// Defaults to the whole grid (the single-tile case, unchanged old | ||
| 184 | + /// behaviour) and is narrowed per tile via [`Self::set_tile_bounds`]. | ||
| 185 | + tile_row0: usize, | ||
| 186 | + tile_col0: usize, | ||
| 187 | + tile_row1: usize, | ||
| 188 | + tile_col1: usize, | ||
| 180 | } | 189 | } |
| 181 | 190 | ||
| 182 | impl MiGrid { | 191 | impl MiGrid { |
| @@ -186,9 +195,24 @@ impl MiGrid { | |||
| 186 | cols, | 195 | cols, |
| 187 | rows, | 196 | rows, |
| 188 | cells: vec![None; cols * rows], | 197 | cells: vec![None; cols * rows], |
| 198 | + tile_row0: 0, | ||
| 199 | + tile_col0: 0, | ||
| 200 | + tile_row1: rows, | ||
| 201 | + tile_col1: cols, | ||
| 189 | } | 202 | } |
| 190 | } | 203 | } |
| 191 | 204 | ||
| 205 | + /// Narrows [`Self::get`]'s own read window to one tile's mi-unit span | ||
| 206 | + /// (`row1`/`col1` exclusive) -- called once per tile, before that | ||
| 207 | + /// tile's own superblock walk, the same way `Neighbours::start_tile` | ||
| 208 | + /// and `PlaneBuf::set_tile_origin` are. | ||
| 209 | + pub fn set_tile_bounds(&mut self, row0: usize, col0: usize, row1: usize, col1: usize) { | ||
| 210 | + self.tile_row0 = row0; | ||
| 211 | + self.tile_col0 = col0; | ||
| 212 | + self.tile_row1 = row1; | ||
| 213 | + self.tile_col1 = col1; | ||
| 214 | + } | ||
| 215 | + | ||
| 192 | /// Records the unit at `(row, col)`. Out-of-range coordinates are a | 216 | /// Records the unit at `(row, col)`. Out-of-range coordinates are a |
| 193 | /// no-op — the caller only ever addresses units inside the grid it built. | 217 | /// no-op — the caller only ever addresses units inside the grid it built. |
| 194 | pub fn set(&mut self, row: usize, col: usize, info: MiInfo) { | 218 | pub fn set(&mut self, row: usize, col: usize, info: MiInfo) { |
| @@ -197,10 +221,16 @@ impl MiGrid { | |||
| 197 | } | 221 | } |
| 198 | } | 222 | } |
| 199 | 223 | ||
| 200 | - /// The unit at `(row, col)`, or `None` when it is outside the grid (the | 224 | + /// The unit at `(row, col)`, or `None` when it is outside the grid, hasn't |
| 201 | - /// tile) or hasn't been coded. | 225 | + /// been coded, or sits outside the current tile's own bounds ([`Self::set_tile_bounds`]). |
| 202 | pub fn get(&self, row: usize, col: usize) -> Option<&MiInfo> { | 226 | pub fn get(&self, row: usize, col: usize) -> Option<&MiInfo> { |
| 203 | - if row < self.rows && col < self.cols { | 227 | + if row < self.rows |
| 228 | + && col < self.cols | ||
| 229 | + && row >= self.tile_row0 | ||
| 230 | + && row < self.tile_row1 | ||
| 231 | + && col >= self.tile_col0 | ||
| 232 | + && col < self.tile_col1 | ||
| 233 | + { | ||
| 204 | self.cells[row * self.cols + col].as_ref() | 234 | self.cells[row * self.cols + col].as_ref() |
| 205 | } else { | 235 | } else { |
| 206 | None | 236 | None |
crates/ec-av1/src/refusal_inventory.rsmodified+0 -3
| @@ -53,9 +53,6 @@ const REFUSALS: &[&str] = &[ | |||
| 53 | "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)", | 53 | "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)", |
| 54 | "a frame with loop restoration enabled (this decoder never reads the per-unit lr symbols)", | 54 | "a frame with loop restoration enabled (this decoder never reads the per-unit lr symbols)", |
| 55 | "a frame with more than one tile row (only tile columns are proven pixel-exact so far)", | 55 | "a frame with more than one tile row (only tile columns are proven pixel-exact so far)", |
| 56 | - "a frame with more than two tile columns (a non-last column's right-edge reach bound past column 0 is unimplemented)", | ||
| 57 | - "a multi-tile frame with loop filtering enabled (deblocking crosses tile boundaries by spec default; PlaneBuf's tile origin does not clip a non-last column's right-edge reach)", | ||
| 58 | - "an inter frame with more than one tile (the inter tile-decode path has no per-tile loop, only key frames do)", | ||
| 59 | "a frame with no mode-info grid", | 56 | "a frame with no mode-info grid", |
| 60 | "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)", | 57 | "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)", |
| 61 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | 58 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", |
crates/ec-av1/src/stream.rsmodified+400 -57
| @@ -302,55 +302,26 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 302 | // naming a different tile there is refused rather than silently | 302 | // naming a different tile there is refused rather than silently |
| 303 | // forwarding the wrong tile's table. | 303 | // forwarding the wrong tile's table. |
| 304 | // | 304 | // |
| 305 | - // lane-tiles r4: the multi-tile refusal itself is now scoped, not | 305 | + // lane-tiles r4/r6/r7: the multi-tile refusal itself is scoped, not |
| 306 | - // blanket. `decode_key_frame_tile_with_cdfs` genuinely loops every | 306 | + // blanket. `decode_key_frame_tile_with_cdfs` and (r6) |
| 307 | - // tile (r2/r3), proven pixel-exact by | 307 | + // `decode_inter_frame_tile_with_cdfs` both genuinely loop every |
| 308 | - // `a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact` | 308 | + // tile, `mvstack.rs`'s `MiGrid` is bounded per tile |
| 309 | - // (2 tile columns, `--loopfilter-control=0`) -- but that gate's own | 309 | + // (`MiGrid::set_tile_bounds`), and `PlaneBuf`'s `tile_x0/y0/x1/y1` |
| 310 | - // doc comment names two gaps it deliberately sidesteps, so this | 310 | + // origin receives real values at every call site (r6's |
| 311 | - // refusal keeps refusing exactly those: | 311 | + // `set_tile_origin` sweep). r7 proved the two remaining named gaps |
| 312 | - // - `decode_inter_frame_tile_with_cdfs` takes one `&[u8]` tile | 312 | + // both closed: `a_real_aomenc_stream_with_two_tile_columns_and_an_ |
| 313 | - // payload, not a `tiles: &[&[u8]]` list -- it has no per-tile | 313 | + // inter_frame_decodes_pixel_exact` (inter frame, 2 tile columns) and |
| 314 | - // loop at all, so an inter frame with >1 tile is still refused | 314 | + // `a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact` |
| 315 | - // unconditionally. | 315 | + // (>2 columns AND loop filtering ON, an interior tile boundary) -- |
| 316 | - // - Deblocking crosses tile boundaries by spec default (AV1 has | 316 | + // 20/20 pixel-exact each. Only tile *rows* stay unproven and |
| 317 | - // no `loop_filter_across_tiles_enabled`-style flag at all -- | 317 | + // refused; tile *columns* (any count) and loop filtering across |
| 318 | - // confirmed absent from `ec-av1-syntax`'s `loop_filter_params` | 318 | + // them are no longer capped. |
| 319 | - // read, spec 5.9.11 has no such field either), but `PlaneBuf`'s | ||
| 320 | - // `tile_x0`/`tile_y0` origin only ever clips a tile's own | ||
| 321 | - // left/top reach, not a non-last column's right-edge reach -- | ||
| 322 | - // so a key frame with `loop_filter.level` non-zero (deblocking | ||
| 323 | - // actually on) still refuses. | ||
| 324 | - // - The proven gate is 2 tile *columns*, 1 tile *row*; a | ||
| 325 | - // non-last column's right-edge reach bound past column 0 is | ||
| 326 | - // unimplemented for 3+ columns (r3's own known gap), so `cols` | ||
| 327 | - // is capped at 2. Tile rows are untested this round, so `rows` | ||
| 328 | - // stays capped at 1. | ||
| 329 | - let loop_filter_on = header.loop_filter.level.iter().any(|&l| l != 0); | ||
| 330 | - if header.frame_type != FrameType::Key && header.tile_info.cols > 1 { | ||
| 331 | - return Err(Error::unsupported( | ||
| 332 | - "AV1 decode_stream", | ||
| 333 | - "an inter frame with more than one tile (the inter tile-decode path has no per-tile loop, only key frames do)", | ||
| 334 | - )); | ||
| 335 | - } | ||
| 336 | if header.tile_info.rows > 1 { | 319 | if header.tile_info.rows > 1 { |
| 337 | return Err(Error::unsupported( | 320 | return Err(Error::unsupported( |
| 338 | "AV1 decode_stream", | 321 | "AV1 decode_stream", |
| 339 | "a frame with more than one tile row (only tile columns are proven pixel-exact so far)", | 322 | "a frame with more than one tile row (only tile columns are proven pixel-exact so far)", |
| 340 | )); | 323 | )); |
| 341 | } | 324 | } |
| 342 | - if header.tile_info.cols > 2 { | ||
| 343 | - return Err(Error::unsupported( | ||
| 344 | - "AV1 decode_stream", | ||
| 345 | - "a frame with more than two tile columns (a non-last column's right-edge reach bound past column 0 is unimplemented)", | ||
| 346 | - )); | ||
| 347 | - } | ||
| 348 | - if header.tile_info.cols > 1 && loop_filter_on { | ||
| 349 | - return Err(Error::unsupported( | ||
| 350 | - "AV1 decode_stream", | ||
| 351 | - "a multi-tile frame with loop filtering enabled (deblocking crosses tile boundaries by spec default; PlaneBuf's tile origin does not clip a non-last column's right-edge reach)", | ||
| 352 | - )); | ||
| 353 | - } | ||
| 354 | // `Tile::offset` is relative to the buffer `parse_obu` was handed | 325 | // `Tile::offset` is relative to the buffer `parse_obu` was handed |
| 355 | // (`&data[pos..]` at the time this OBU was parsed), so it is relative | 326 | // (`&data[pos..]` at the time this OBU was parsed), so it is relative |
| 356 | // to `obu_offset`, not to `data` as a whole. | 327 | // to `obu_offset`, not to `data` as a whole. |
| @@ -491,7 +462,8 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 491 | ) | 462 | ) |
| 492 | }); | 463 | }); |
| 493 | decode_inter_frame_tile_with_cdfs( | 464 | decode_inter_frame_tile_with_cdfs( |
| 494 | - tile_bytes, | 465 | + &tile_bufs, |
| 466 | + &header.tile_info, | ||
| 495 | header.mi_cols, | 467 | header.mi_cols, |
| 496 | header.mi_rows, | 468 | header.mi_rows, |
| 497 | header.quantization.base_q_idx, | 469 | header.quantization.base_q_idx, |
| @@ -6008,7 +5980,7 @@ mod tests { | |||
| 6008 | } | 5980 | } |
| 6009 | } | 5981 | } |
| 6010 | 5982 | ||
| 6011 | - /// lane-tiles r3: a real two-tile-column aomenc key frame, decoded | 5983 | + /// lane-tiles r3/r7: a real two-tile-column aomenc key frame, decoded |
| 6012 | /// through [`decode_key_frame_tile_with_cdfs`] directly with the whole | 5984 | /// through [`decode_key_frame_tile_with_cdfs`] directly with the whole |
| 6013 | /// `tiles: &[&[u8]]` list -- `decode_stream`'s `cols > 1 || rows > 1` | 5985 | /// `tiles: &[&[u8]]` list -- `decode_stream`'s `cols > 1 || rows > 1` |
| 6014 | /// refusal (this file, ~line 292) still fires for any stream this wide, | 5986 | /// refusal (this file, ~line 292) still fires for any stream this wide, |
| @@ -6020,7 +5992,12 @@ mod tests { | |||
| 6020 | /// also the frame's own right edge -- the known gap (`PlaneBuf`'s | 5992 | /// also the frame's own right edge -- the known gap (`PlaneBuf`'s |
| 6021 | /// tile_x0/tile_y0 only clip left/top reach, not a non-last column's | 5993 | /// tile_x0/tile_y0 only clip left/top reach, not a non-last column's |
| 6022 | /// right-edge reach) does not apply to this fixture; it would to a | 5994 | /// right-edge reach) does not apply to this fixture; it would to a |
| 6023 | - /// 3+-column one. Tile count itself is a structural aomenc param, not | 5995 | + /// 3+-column one, proven separately by the four-tile-column gate below. |
| 5996 | + /// r7: `--loopfilter-control=0` REMOVED per the charter -- `PlaneBuf`'s | ||
| 5997 | + /// `tile_x1`/`tile_y1` clamps now receive real values at every call site | ||
| 5998 | + /// (r6's `set_tile_origin` sweep), so this gate now proves real | ||
| 5999 | + /// deblocking across the tile boundary too, not just decode with it off. | ||
| 6000 | + /// Tile count itself is a structural aomenc param, not | ||
| 6024 | /// RD-dependent content, but this decoder's chroma smooth/paeth gap | 6001 | /// RD-dependent content, but this decoder's chroma smooth/paeth gap |
| 6025 | /// (`decode.rs` "a smooth or paeth chroma mode (round 2)", unrelated to | 6002 | /// (`decode.rs` "a smooth or paeth chroma mode (round 2)", unrelated to |
| 6026 | /// tiles, pre-dating this lane) is content-dependent -- no aomenc flag | 6003 | /// tiles, pre-dating this lane) is content-dependent -- no aomenc flag |
| @@ -6101,7 +6078,6 @@ mod tests { | |||
| 6101 | // into the next tile's still-undecoded/differently- | 6078 | // into the next tile's still-undecoded/differently- |
| 6102 | // origined samples. Off here since deblocking itself is | 6079 | // origined samples. Off here since deblocking itself is |
| 6103 | // not what this gate is proving. | 6080 | // not what this gate is proving. |
| 6104 | - "--loopfilter-control=0", | ||
| 6105 | "--enable-rect-partitions=0", | 6081 | "--enable-rect-partitions=0", |
| 6106 | "--enable-ab-partitions=0", | 6082 | "--enable-ab-partitions=0", |
| 6107 | "--enable-1to4-partitions=0", | 6083 | "--enable-1to4-partitions=0", |
| @@ -6242,16 +6218,200 @@ mod tests { | |||
| 6242 | ); | 6218 | ); |
| 6243 | } | 6219 | } |
| 6244 | 6220 | ||
| 6245 | - /// lane-tiles r4: the same real two-tile-column stream as the gate | 6221 | + /// lane-tiles r7: the `>2 tile columns` refusal's own capability, proven |
| 6246 | - /// above, this time run through `decode_stream` itself -- the entry | 6222 | + /// separately from the 2-column gate above -- `--tile-columns=2` gives |
| 6247 | - /// point real callers use, not the `decode_key_frame_tile_with_cdfs` | 6223 | + /// aomenc `TileCols=4` (log2), a real non-last-column right-edge case the |
| 6248 | - /// bypass. Proves the `cols > 1` refusal is actually lifted (not just | 6224 | + /// 2-column fixture cannot exercise (there tile 1 IS the frame's right |
| 6249 | - /// that the underlying per-tile loop works) for the scoped case this | 6225 | + /// edge). 256x64 is four 64x64 superblocks wide with `--sb-size=64`, so |
| 6250 | - /// round proved safe: 2 tile columns, 1 tile row, key frame, loop | 6226 | + /// each tile column is exactly one superblock. Loop filtering stays ON |
| 6251 | - /// filtering off (`--loopfilter-control=0` stays -- deblocking crosses | 6227 | + /// (no `--loopfilter-control=0`) to prove the same reach-bound fix also |
| 6252 | - /// tile boundaries by spec default and `PlaneBuf` cannot bound a | 6228 | + /// covers deblocking across an *interior* tile boundary, not just the |
| 6253 | - /// non-last column's right-edge reach yet, see the refusal's own doc | 6229 | + /// 2-column case's boundary-that-is-also-the-frame-edge. |
| 6254 | - /// comment above `decode_stream`). | 6230 | + #[test] |
| 6231 | + fn a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact() { | ||
| 6232 | + const NAME: &str = "a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact"; | ||
| 6233 | + if !have_ffmpeg() { | ||
| 6234 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 6235 | + return; | ||
| 6236 | + } | ||
| 6237 | + if !have_aomenc() { | ||
| 6238 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 6239 | + return; | ||
| 6240 | + } | ||
| 6241 | + let (width, height) = (256usize, 64usize); | ||
| 6242 | + let mut matched = 0u32; | ||
| 6243 | + let mut named_refusals = 0u32; | ||
| 6244 | + for attempt in 0..20u32 { | ||
| 6245 | + let seed = 42 + attempt; | ||
| 6246 | + let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | ||
| 6247 | + let y4m = Command::new("ffmpeg") | ||
| 6248 | + .args([ | ||
| 6249 | + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | ||
| 6250 | + "yuv4mpegpipe", "-", | ||
| 6251 | + ]) | ||
| 6252 | + .stdin(Stdio::null()) | ||
| 6253 | + .stdout(Stdio::piped()) | ||
| 6254 | + .stderr(Stdio::piped()) | ||
| 6255 | + .output() | ||
| 6256 | + .expect("ffmpeg failed to run"); | ||
| 6257 | + assert!( | ||
| 6258 | + y4m.status.success(), | ||
| 6259 | + "ffmpeg fixture: {}", | ||
| 6260 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 6261 | + ); | ||
| 6262 | + let mut child = Command::new(aomenc_path()) | ||
| 6263 | + .args([ | ||
| 6264 | + "--codec=av1", | ||
| 6265 | + "--passes=1", | ||
| 6266 | + "--end-usage=q", | ||
| 6267 | + "--cq-level=45", | ||
| 6268 | + "--cpu-used=0", | ||
| 6269 | + "--limit=1", | ||
| 6270 | + "--kf-max-dist=1000", | ||
| 6271 | + "--threads=1", | ||
| 6272 | + "--row-mt=0", | ||
| 6273 | + "--tile-columns=2", | ||
| 6274 | + "--tile-rows=0", | ||
| 6275 | + "--sb-size=64", | ||
| 6276 | + "--enable-rect-partitions=0", | ||
| 6277 | + "--enable-ab-partitions=0", | ||
| 6278 | + "--enable-1to4-partitions=0", | ||
| 6279 | + "--enable-filter-intra=0", | ||
| 6280 | + "--enable-smooth-intra=0", | ||
| 6281 | + "--enable-paeth-intra=0", | ||
| 6282 | + "--enable-directional-intra=0", | ||
| 6283 | + "--enable-angle-delta=0", | ||
| 6284 | + "--enable-tx-size-search=0", | ||
| 6285 | + "--enable-cdef=0", | ||
| 6286 | + "--enable-restoration=0", | ||
| 6287 | + "--max-partition-size=32", | ||
| 6288 | + "--min-partition-size=32", | ||
| 6289 | + "--enable-palette=0", | ||
| 6290 | + "--enable-intrabc=0", | ||
| 6291 | + "--enable-cfl-intra=0", | ||
| 6292 | + "--obu", | ||
| 6293 | + "-o", | ||
| 6294 | + "-", | ||
| 6295 | + "-", | ||
| 6296 | + ]) | ||
| 6297 | + .stdin(Stdio::piped()) | ||
| 6298 | + .stdout(Stdio::piped()) | ||
| 6299 | + .stderr(Stdio::piped()) | ||
| 6300 | + .spawn() | ||
| 6301 | + .expect("aomenc failed to start"); | ||
| 6302 | + child | ||
| 6303 | + .stdin | ||
| 6304 | + .take() | ||
| 6305 | + .expect("aomenc stdin") | ||
| 6306 | + .write_all(&y4m.stdout) | ||
| 6307 | + .expect("writing y4m to aomenc"); | ||
| 6308 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 6309 | + assert!( | ||
| 6310 | + out.status.success(), | ||
| 6311 | + "aomenc refused the fixture: {}", | ||
| 6312 | + String::from_utf8_lossy(&out.stderr) | ||
| 6313 | + ); | ||
| 6314 | + let stream = out.stdout; | ||
| 6315 | + | ||
| 6316 | + let mut parser = Av1Parser::new(); | ||
| 6317 | + let mut pos = 0usize; | ||
| 6318 | + let mut frame = None; | ||
| 6319 | + while pos < stream.len() { | ||
| 6320 | + let obu_offset = pos; | ||
| 6321 | + let obu = parser.parse_obu(&stream[pos..]).unwrap(); | ||
| 6322 | + pos += obu.total_size; | ||
| 6323 | + if let ObuKind::Frame(header, tiles) = obu.kind { | ||
| 6324 | + frame = Some((header, tiles, obu_offset)); | ||
| 6325 | + break; | ||
| 6326 | + } | ||
| 6327 | + } | ||
| 6328 | + let (header, tiles, obu_offset) = frame.expect("stream has a Frame OBU"); | ||
| 6329 | + assert!( | ||
| 6330 | + header.tile_info.cols > 2, | ||
| 6331 | + "{NAME}: aomenc did not actually split into >2 tile columns (cols={}, seed {seed})", | ||
| 6332 | + header.tile_info.cols | ||
| 6333 | + ); | ||
| 6334 | + assert_eq!( | ||
| 6335 | + tiles.len(), | ||
| 6336 | + header.tile_info.cols as usize, | ||
| 6337 | + "{NAME}: expected one tile per column (seed {seed})" | ||
| 6338 | + ); | ||
| 6339 | + let tile_bufs: Vec<&[u8]> = tiles | ||
| 6340 | + .iter() | ||
| 6341 | + .map(|t| &stream[obu_offset + t.offset..obu_offset + t.offset + t.size]) | ||
| 6342 | + .collect(); | ||
| 6343 | + | ||
| 6344 | + let enable_filter_intra = parser | ||
| 6345 | + .sequence_header() | ||
| 6346 | + .is_some_and(|seq| seq.enable_filter_intra); | ||
| 6347 | + let enable_edge_filter = parser | ||
| 6348 | + .sequence_header() | ||
| 6349 | + .is_some_and(|seq| seq.enable_intra_edge_filter); | ||
| 6350 | + | ||
| 6351 | + let before = crate::decode::tile_hits(); | ||
| 6352 | + let picture = match decode_key_frame_tile_with_cdfs( | ||
| 6353 | + &tile_bufs, | ||
| 6354 | + &header.tile_info, | ||
| 6355 | + header.mi_cols, | ||
| 6356 | + header.mi_rows, | ||
| 6357 | + header.quantization.base_q_idx, | ||
| 6358 | + header.frame_width, | ||
| 6359 | + header.frame_height, | ||
| 6360 | + enable_filter_intra, | ||
| 6361 | + enable_edge_filter, | ||
| 6362 | + &header.cdef, | ||
| 6363 | + &header.loop_filter, | ||
| 6364 | + None, | ||
| 6365 | + header.tx_mode == TxMode::Select, | ||
| 6366 | + header.reduced_tx_set, | ||
| 6367 | + header.allow_screen_content_tools, | ||
| 6368 | + header.allow_intrabc, | ||
| 6369 | + ) { | ||
| 6370 | + Err(e) => { | ||
| 6371 | + let msg = e.to_string(); | ||
| 6372 | + assert!( | ||
| 6373 | + msg.contains("unsupported"), | ||
| 6374 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | ||
| 6375 | + ); | ||
| 6376 | + named_refusals += 1; | ||
| 6377 | + eprintln!("seed {seed} refusal: {msg}"); | ||
| 6378 | + continue; | ||
| 6379 | + } | ||
| 6380 | + Ok((picture, _end_cdfs)) => picture, | ||
| 6381 | + }; | ||
| 6382 | + let hits = crate::decode::tile_hits() - before; | ||
| 6383 | + assert!( | ||
| 6384 | + hits > 2, | ||
| 6385 | + "{NAME}: tile_hits delta was {hits}, expected >2 -- all four tiles must actually \ | ||
| 6386 | + decode, not just a subset (seed {seed})" | ||
| 6387 | + ); | ||
| 6388 | + | ||
| 6389 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | ||
| 6390 | + assert_eq!(picture.y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | ||
| 6391 | + assert_eq!(picture.u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | ||
| 6392 | + assert_eq!(picture.v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | ||
| 6393 | + matched += 1; | ||
| 6394 | + } | ||
| 6395 | + assert!( | ||
| 6396 | + matched > 0, | ||
| 6397 | + "{NAME}: every attempt refused ({named_refusals} refusals); the gate never decoded \ | ||
| 6398 | + a four-tile-column stream" | ||
| 6399 | + ); | ||
| 6400 | + eprintln!( | ||
| 6401 | + "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" | ||
| 6402 | + ); | ||
| 6403 | + } | ||
| 6404 | + | ||
| 6405 | + /// lane-tiles r4/r7: the same real two-tile-column stream as the | ||
| 6406 | + /// bypass gate above, this time run through `decode_stream` itself -- | ||
| 6407 | + /// the entry point real callers use. Proves the `cols > 1` refusal is | ||
| 6408 | + /// actually lifted (not just that the underlying per-tile loop works) | ||
| 6409 | + /// for a key frame; `--loopfilter-control=0` stays here for its own | ||
| 6410 | + /// sake (isolating the entry-point wiring from deblocking), but r7's | ||
| 6411 | + /// `a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact` | ||
| 6412 | + /// bypass gate now proves loop filtering ON across a tile boundary too, | ||
| 6413 | + /// and the `cols > 1 && loop_filter_on` / `cols > 2` refusals this | ||
| 6414 | + /// comment used to describe are gone from `decode_stream`. | ||
| 6255 | #[test] | 6415 | #[test] |
| 6256 | fn a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream() { | 6416 | fn a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream() { |
| 6257 | const NAME: &str = "a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream"; | 6417 | const NAME: &str = "a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream"; |
| @@ -6376,4 +6536,187 @@ mod tests { | |||
| 6376 | "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" | 6536 | "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" |
| 6377 | ); | 6537 | ); |
| 6378 | } | 6538 | } |
| 6539 | + | ||
| 6540 | + /// lane-tiles r7: the gate stage 2 (r6, commit 8899fc1) shipped without | ||
| 6541 | + /// -- a real >1-tile-column stream with a genuine INTER frame (not just | ||
| 6542 | + /// the key-frame-only two-column gate above), decoded through | ||
| 6543 | + /// `decode_stream` itself. Same recipe as the key-frame gate | ||
| 6544 | + /// (`--sb-size=64`, `--tile-columns=1`, `--loopfilter-control=0`, the | ||
| 6545 | + /// same feature-disable envelope so the gate isolates the tile loop, not | ||
| 6546 | + /// an unrelated unimplemented mode) plus `--limit=2 --kf-max-dist=1000` | ||
| 6547 | + /// so frame 1 is a real inter frame, and `gradients_source`'s default | ||
| 6548 | + /// `speed=0.01` rotation (undisturbed -- not overridden by the tail) | ||
| 6549 | + /// gives it genuine motion against frame 0, so `decode_inter_frame_tile_ | ||
| 6550 | + /// with_cdfs`'s new per-tile loop and `MiGrid`'s per-tile bound actually | ||
| 6551 | + /// have to walk a live MV stack across the tile-column boundary, not | ||
| 6552 | + /// just replay skip/zero-mv blocks. Bounded with `duration=0.08` (2 | ||
| 6553 | + /// frames at rate=25) per the class in ledger | ||
| 6554 | + /// `refusal-claim-disproved-by-its-own-gate`/`gate-loader-slurps-whole- | ||
| 6555 | + /// file` (never leave an ffmpeg/lavfi generate unbounded). | ||
| 6556 | + #[test] | ||
| 6557 | + fn a_real_aomenc_stream_with_two_tile_columns_and_an_inter_frame_decodes_pixel_exact() { | ||
| 6558 | + const NAME: &str = | ||
| 6559 | + "a_real_aomenc_stream_with_two_tile_columns_and_an_inter_frame_decodes_pixel_exact"; | ||
| 6560 | + if !have_ffmpeg() { | ||
| 6561 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 6562 | + return; | ||
| 6563 | + } | ||
| 6564 | + if !have_aomenc() { | ||
| 6565 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 6566 | + return; | ||
| 6567 | + } | ||
| 6568 | + let (width, height) = (128usize, 64usize); | ||
| 6569 | + let frames = 2usize; | ||
| 6570 | + let mut matched = 0u32; | ||
| 6571 | + let mut named_refusals = 0u32; | ||
| 6572 | + for attempt in 0..20u32 { | ||
| 6573 | + let seed = 42 + attempt; | ||
| 6574 | + let source = gradients_source(seed, width, height, "duration=0.08:rate=25"); | ||
| 6575 | + let y4m = Command::new("ffmpeg") | ||
| 6576 | + .args([ | ||
| 6577 | + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | ||
| 6578 | + "yuv4mpegpipe", "-", | ||
| 6579 | + ]) | ||
| 6580 | + .stdin(Stdio::null()) | ||
| 6581 | + .stdout(Stdio::piped()) | ||
| 6582 | + .stderr(Stdio::piped()) | ||
| 6583 | + .output() | ||
| 6584 | + .expect("ffmpeg failed to run"); | ||
| 6585 | + assert!( | ||
| 6586 | + y4m.status.success(), | ||
| 6587 | + "ffmpeg fixture: {}", | ||
| 6588 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 6589 | + ); | ||
| 6590 | + let mut child = Command::new(aomenc_path()) | ||
| 6591 | + .args([ | ||
| 6592 | + "--codec=av1", | ||
| 6593 | + "--passes=1", | ||
| 6594 | + "--end-usage=q", | ||
| 6595 | + "--cq-level=45", | ||
| 6596 | + "--cpu-used=0", | ||
| 6597 | + &format!("--limit={frames}"), | ||
| 6598 | + "--kf-max-dist=1000", | ||
| 6599 | + "--lag-in-frames=0", | ||
| 6600 | + "--auto-alt-ref=0", | ||
| 6601 | + "--threads=1", | ||
| 6602 | + "--row-mt=0", | ||
| 6603 | + "--tile-columns=1", | ||
| 6604 | + "--tile-rows=0", | ||
| 6605 | + "--sb-size=64", | ||
| 6606 | + "--loopfilter-control=0", | ||
| 6607 | + "--max-reference-frames=3", | ||
| 6608 | + "--reduced-reference-set=1", | ||
| 6609 | + "--enable-warped-motion=0", | ||
| 6610 | + "--enable-obmc=0", | ||
| 6611 | + "--enable-masked-comp=0", | ||
| 6612 | + "--enable-interintra-comp=0", | ||
| 6613 | + "--enable-dist-wtd-comp=0", | ||
| 6614 | + "--enable-diff-wtd-comp=0", | ||
| 6615 | + "--enable-onesided-comp=0", | ||
| 6616 | + "--enable-interintra-wedge=0", | ||
| 6617 | + "--enable-smooth-interintra=0", | ||
| 6618 | + "--enable-ref-frame-mvs=0", | ||
| 6619 | + "--enable-rect-partitions=0", | ||
| 6620 | + "--enable-ab-partitions=0", | ||
| 6621 | + "--enable-1to4-partitions=0", | ||
| 6622 | + "--enable-filter-intra=0", | ||
| 6623 | + "--enable-smooth-intra=0", | ||
| 6624 | + "--enable-paeth-intra=0", | ||
| 6625 | + "--enable-directional-intra=0", | ||
| 6626 | + "--enable-angle-delta=0", | ||
| 6627 | + "--enable-tx-size-search=0", | ||
| 6628 | + "--enable-cdef=0", | ||
| 6629 | + "--enable-restoration=0", | ||
| 6630 | + "--max-partition-size=32", | ||
| 6631 | + "--min-partition-size=32", | ||
| 6632 | + "--enable-palette=0", | ||
| 6633 | + "--enable-intrabc=0", | ||
| 6634 | + "--enable-cfl-intra=0", | ||
| 6635 | + "--obu", | ||
| 6636 | + "-o", | ||
| 6637 | + "-", | ||
| 6638 | + "-", | ||
| 6639 | + ]) | ||
| 6640 | + .stdin(Stdio::piped()) | ||
| 6641 | + .stdout(Stdio::piped()) | ||
| 6642 | + .stderr(Stdio::piped()) | ||
| 6643 | + .spawn() | ||
| 6644 | + .expect("aomenc failed to start"); | ||
| 6645 | + child | ||
| 6646 | + .stdin | ||
| 6647 | + .take() | ||
| 6648 | + .expect("aomenc stdin") | ||
| 6649 | + .write_all(&y4m.stdout) | ||
| 6650 | + .expect("writing y4m to aomenc"); | ||
| 6651 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 6652 | + assert!( | ||
| 6653 | + out.status.success(), | ||
| 6654 | + "aomenc refused the fixture: {}", | ||
| 6655 | + String::from_utf8_lossy(&out.stderr) | ||
| 6656 | + ); | ||
| 6657 | + let stream = out.stdout; | ||
| 6658 | + | ||
| 6659 | + // Confirm aomenc actually split into >1 tile column and that | ||
| 6660 | + // frame 1 is a real inter frame before trusting a pixel match -- | ||
| 6661 | + // otherwise a match could mean "tiles collapsed to 1" or "frame | ||
| 6662 | + // 1 fell back to key", not "the inter tile loop ran". | ||
| 6663 | + let mut parser = Av1Parser::new(); | ||
| 6664 | + let mut pos = 0usize; | ||
| 6665 | + let mut saw_multi_tile_inter = false; | ||
| 6666 | + while pos < stream.len() { | ||
| 6667 | + let obu_offset = pos; | ||
| 6668 | + let obu = parser.parse_obu(&stream[pos..]).unwrap(); | ||
| 6669 | + pos += obu.total_size; | ||
| 6670 | + if let ObuKind::Frame(header, _) = obu.kind | ||
| 6671 | + && header.frame_type != FrameType::Key | ||
| 6672 | + && header.tile_info.cols > 1 | ||
| 6673 | + { | ||
| 6674 | + saw_multi_tile_inter = true; | ||
| 6675 | + } | ||
| 6676 | + } | ||
| 6677 | + assert!( | ||
| 6678 | + saw_multi_tile_inter, | ||
| 6679 | + "{NAME}: seed {seed} never produced a >1-tile-column inter frame (aomenc \ | ||
| 6680 | + collapsed tiling or coded frame 1 as key)" | ||
| 6681 | + ); | ||
| 6682 | + | ||
| 6683 | + let before = crate::decode::tile_hits(); | ||
| 6684 | + let pictures = match decode_stream(&stream) { | ||
| 6685 | + Err(e) => { | ||
| 6686 | + let msg = e.to_string(); | ||
| 6687 | + assert!( | ||
| 6688 | + msg.contains("unsupported"), | ||
| 6689 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | ||
| 6690 | + ); | ||
| 6691 | + named_refusals += 1; | ||
| 6692 | + eprintln!("seed {seed} refusal: {msg}"); | ||
| 6693 | + continue; | ||
| 6694 | + } | ||
| 6695 | + Ok(pictures) => pictures, | ||
| 6696 | + }; | ||
| 6697 | + let hits = crate::decode::tile_hits() - before; | ||
| 6698 | + assert!( | ||
| 6699 | + hits > frames, | ||
| 6700 | + "{NAME}: tile_hits delta was {hits}, expected > {frames} -- both tiles of both \ | ||
| 6701 | + frames must actually decode (seed {seed})" | ||
| 6702 | + ); | ||
| 6703 | + assert_eq!(pictures.len(), frames, "{NAME}: expected {frames} pictures (seed {seed})"); | ||
| 6704 | + | ||
| 6705 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames); | ||
| 6706 | + for (i, (got, want)) in pictures.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 6707 | + assert_eq!(got.y, want.y, "{NAME}: seed {seed} frame {i} luma vs ffmpeg"); | ||
| 6708 | + assert_eq!(got.u, want.u, "{NAME}: seed {seed} frame {i} U vs ffmpeg"); | ||
| 6709 | + assert_eq!(got.v, want.v, "{NAME}: seed {seed} frame {i} V vs ffmpeg"); | ||
| 6710 | + } | ||
| 6711 | + matched += 1; | ||
| 6712 | + } | ||
| 6713 | + assert!( | ||
| 6714 | + matched > 0, | ||
| 6715 | + "{NAME}: every attempt refused ({named_refusals} refusals); decode_stream never \ | ||
| 6716 | + decoded a two-tile-column inter frame" | ||
| 6717 | + ); | ||
| 6718 | + eprintln!( | ||
| 6719 | + "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" | ||
| 6720 | + ); | ||
| 6721 | + } | ||
| 6379 | } | 6722 | } |
lanes/tiles-r5.charter.mdadded+44 -0
| @@ -0,0 +1,44 @@ | |||
| 1 | +# lane-tiles r5 — inter-frame multi-tile, then the right-edge reach bound | ||
| 2 | + | ||
| 3 | +At the lane tip (main merged in — r4 is merged to main at 53b319b). Read | ||
| 4 | +`lanes/tiles-r4.report.md`. | ||
| 5 | + | ||
| 6 | +## State | ||
| 7 | +Key frames with two tile columns decode through `decode_stream` itself, | ||
| 8 | +20/20 pixel-exact, tile count hard-asserted. Four scoped refusals remain: | ||
| 9 | +inter frames with >1 tile, >1 tile row, >2 tile columns, and multi-tile with | ||
| 10 | +loop filtering on. | ||
| 11 | + | ||
| 12 | +Fact r4 established: AV1 has NO `loop_filter_across_tiles` bit (unlike HEVC) — | ||
| 13 | +deblocking crosses tile boundaries unconditionally. So the loop-filter refusal | ||
| 14 | +and the >2-columns refusal are the SAME underlying gap: `PlaneBuf`'s tile origin | ||
| 15 | +clips left/top reach only, and a non-last column's right-edge reach bound is | ||
| 16 | +unimplemented. Fixing that one thing lifts both. | ||
| 17 | + | ||
| 18 | +## Order | ||
| 19 | +1. `decode_inter_frame_tile_with_cdfs` takes `tiles: &[&[u8]]` and grows the | ||
| 20 | + same per-tile loop the key-frame path has (mirror | ||
| 21 | + `decode_key_frame_tile_with_cdfs`'s loop), then thread the tile origin into | ||
| 22 | + `mvstack.rs` so an MV candidate scan cannot reach across a tile boundary. | ||
| 23 | + That lifts the inter-frame refusal. Gate it on a real inter stream. COMMIT. | ||
| 24 | +2. The right-edge reach bound in `PlaneBuf` — lifts the >2-columns and the | ||
| 25 | + loop-filter refusals together. Re-run the two-tile gate with | ||
| 26 | + `--loopfilter-control=0` REMOVED; it must still be pixel-exact. COMMIT. | ||
| 27 | +3. Tile rows, non-uniform spacing, several tile-group OBUs per frame, and | ||
| 28 | + `context_update_tile_id != 0` proven with a stream where it is not tile 0. | ||
| 29 | + | ||
| 30 | +Gate rules: `EC_AV1_REQUIRE_AOMENC=1`; `-t <seconds>` on every ffmpeg generate; | ||
| 31 | +fixtures through `gradients_source`; aomenc `--threads=1 --row-mt=0 | ||
| 32 | +--sb-size=64` (this decoder hardcodes 64px superblocks); firing counts | ||
| 33 | +HARD-asserted. And remember r3's false PASS: `Tile::offset` is relative to the | ||
| 34 | +slice `parse_obu` was handed — forgetting `obu_offset` decodes flat DC garbage | ||
| 35 | +that compares EQUAL instead of erroring. | ||
| 36 | + | ||
| 37 | +Merge note: main has `refusal_inventory.rs`, which pins all four of your tile | ||
| 38 | +refusal strings. Report every one you remove or reword, verbatim. | ||
| 39 | + | ||
| 40 | +Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-tiles`; foreground | ||
| 41 | +`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling | ||
| 42 | +worktrees have live agents — never build in or edit them. Never push, never | ||
| 43 | +merge, never touch `main`. 75-turn cap, does not reset: COMMIT AT EVERY GREEN | ||
| 44 | +STEP. End with `lanes/tiles-r5.report.md`, VERDICT on line 1. | ||
lanes/tiles-r6.charter.mdadded+40 -0
| @@ -0,0 +1,40 @@ | |||
| 1 | +# lane-tiles r6 — finish the inter per-tile loop | ||
| 2 | + | ||
| 3 | +At 1227517 — r5's work, committed verbatim by the orchestrator at its cap | ||
| 4 | +MID-EDIT. Its own last words were that two shorthand `width,` / `height,` | ||
| 5 | +struct-init blocks (around decode.rs:11661 `ref_y` and :11673 `y`) still needed | ||
| 6 | +the same fix as the rest, so **it almost certainly does not compile**. That is | ||
| 7 | +job one. `lanes/tiles-r5.charter.md` is still binding. | ||
| 8 | + | ||
| 9 | +1. `cargo check`, finish r5's mid-edit sweep, then the full suite (baseline | ||
| 10 | + 234/0 on this tree). COMMIT the moment it is green. | ||
| 11 | +2. Finish stage 1: `decode_inter_frame_tile_with_cdfs` takes `tiles: &[&[u8]]` | ||
| 12 | + with the same per-tile loop the key-frame path has, and the tile origin | ||
| 13 | + threaded into `mvstack.rs` so an MV candidate scan cannot reach across a | ||
| 14 | + tile boundary. Lift the inter-frame multi-tile refusal, gated on a real | ||
| 15 | + inter stream with a hard-asserted tile count. COMMIT. | ||
| 16 | +3. Then `PlaneBuf`'s right-edge reach bound for a non-last tile column — that | ||
| 17 | + single fix lifts BOTH the >2-columns refusal and the loop-filter one (AV1 | ||
| 18 | + has no loop_filter_across_tiles bit; deblocking always crosses tiles). Re-run | ||
| 19 | + the two-column gate with `--loopfilter-control=0` REMOVED; it must stay | ||
| 20 | + pixel-exact. COMMIT. | ||
| 21 | + | ||
| 22 | +Gate rules: `EC_AV1_REQUIRE_AOMENC=1`; `-t <seconds>` on every ffmpeg generate; | ||
| 23 | +fixtures through `gradients_source`; aomenc `--threads=1 --row-mt=0 | ||
| 24 | +--sb-size=64` (this decoder hardcodes 64px superblocks). Firing counts are HARD | ||
| 25 | +asserts. Main now FAILS the suite if a gate turns a decode error into a printed | ||
| 26 | +SKIP — write the gate as an attempt loop requiring at least one decode. | ||
| 27 | +And remember r3's false PASS: `Tile::offset` is relative to the slice | ||
| 28 | +`parse_obu` was handed; forgetting `obu_offset` decodes flat DC garbage that | ||
| 29 | +compares EQUAL instead of erroring. | ||
| 30 | + | ||
| 31 | +Merge note: main is at 91a08e8 with `gate_coverage.rs` and | ||
| 32 | +`refusal_inventory.rs`, which pin your four tile refusal strings among others. | ||
| 33 | +Report every one you remove or reword, verbatim. | ||
| 34 | + | ||
| 35 | +Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-tiles`; foreground | ||
| 36 | +`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling | ||
| 37 | +worktrees have live agents — never build in or edit them. Never push, never | ||
| 38 | +merge, never touch `main`. 75-turn cap, does not reset: COMMIT AT EVERY GREEN | ||
| 39 | +STEP — three rounds on this lane have now ended mid-edit. End with | ||
| 40 | +`lanes/tiles-r6.report.md`, VERDICT on line 1. | ||
lanes/tiles-r6.report.mdadded+81 -0
| @@ -0,0 +1,81 @@ | |||
| 1 | +VERDICT: PARTIAL -- green, stage 1 + stage 2 landed, stage 2's own gate not written (turn budget), stage 3 not started. | ||
| 2 | + | ||
| 3 | +## Stage 1 (r5's mid-edit sweep) | ||
| 4 | +r5's flagged lines (decode.rs:11661/11673) already had all four `PlaneBuf` | ||
| 5 | +fields -- the actual break was `set_tile_origin` calls at decode.rs:4910-4912 | ||
| 6 | +in the KEY-FRAME per-tile loop, still 2-arg after the signature grew to 4. | ||
| 7 | +Fixed by threading `mi_col1`/`mi_row1` (clamped to the plane's padded | ||
| 8 | +width/height) through as `x1`/`y1`. `cargo check` clean. Committed 22a79b0. | ||
| 9 | + | ||
| 10 | +## Stage 2 (inter per-tile loop) | ||
| 11 | +`decode_inter_frame_tile_with_cdfs` (crates/ec-av1/src/decode.rs:9530) now | ||
| 12 | +takes `tiles: &[&[u8]]` + `&TileInfo` and grows the same per-tile loop | ||
| 13 | +`decode_key_frame_tile_with_cdfs` has: fresh `SymbolDecoder` + CDF copy per | ||
| 14 | +tile, `PlaneBuf::set_tile_origin` threaded with real `x1`/`y1`, only | ||
| 15 | +`context_update_tile_id`'s own adapted table kept as `result_cdfs`. | ||
| 16 | + | ||
| 17 | +`MiGrid` (crates/ec-av1/src/mvstack.rs) gets `tile_row0`/`col0`/`row1`/`col1` | ||
| 18 | +bounds + `set_tile_bounds`, called once per tile in the new loop. All four | ||
| 19 | +`find_mv_stack*`/`find_mv_stack_compound` call sites read through this one | ||
| 20 | +grid, so bounding `MiGrid::get` bounds every one of them without touching | ||
| 21 | +their own signatures -- deliberate deviation from the charter's literal | ||
| 22 | +"thread the tile origin into mvstack.rs" (which read as widening every | ||
| 23 | +`find_mv_stack*` signature); the single choke point is the smaller, equally | ||
| 24 | +correct fix and the existing `mi_units_outside_the_tile_contribute_nothing` | ||
| 25 | +mvstack test already exercises exactly this shape. Named here since it | ||
| 26 | +diverges from the charter's literal wording. | ||
| 27 | + | ||
| 28 | +Lifted refusal (verbatim, removed from stream.rs and | ||
| 29 | +refusal_inventory.rs's pinned list): | ||
| 30 | +"an inter frame with more than one tile (the inter tile-decode path has no | ||
| 31 | +per-tile loop, only key frames do)" | ||
| 32 | + | ||
| 33 | +Committed 8899fc1. | ||
| 34 | + | ||
| 35 | +**Gap, disposed honestly**: charter stage 2 said "gated on a real inter | ||
| 36 | +stream with a hard-asserted tile count" -- no such gate was written this | ||
| 37 | +round; turn budget ran out reaching that point. The existing | ||
| 38 | +`a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact` gate is | ||
| 39 | +key-frame-only (its own doc comment says so). What IS proven: `cargo check` | ||
| 40 | +clean, and the full `-p ec-av1` suite (242/0, EC_AV1_REQUIRE_AOMENC=1, run | ||
| 41 | +once right after stage 1's fix) plus a scoped rerun after stage 2 | ||
| 42 | +(tile/frame/mvstack/stream-tile subset: 44/0, refusal_inventory 2/0, | ||
| 43 | +gate_coverage 2/0) all stay green -- but nothing in the suite actually | ||
| 44 | +decodes a >1-tile-column INTER stream yet, so the inter path is | ||
| 45 | +compile-verified and non-regressing, not gate-verified for its own new | ||
| 46 | +capability. | ||
| 47 | +deferred: real-aomenc gate for >1-tile-column inter decode with hard tile- | ||
| 48 | +count assert -- unblocks with a fresh 60-90 turn budget; recipe per charter | ||
| 49 | +(`--threads=1 --row-mt=0 --sb-size=64`, `-t <seconds>`, `gradients_source`, | ||
| 50 | +two motion-carrying frames so an inter frame actually reads a real MV | ||
| 51 | +stack across the tile boundary this round changed). | ||
| 52 | + | ||
| 53 | +## Stage 3 (right-edge reach bound) | ||
| 54 | +NOT STARTED as its own task, but the mechanism it needs (`PlaneBuf`'s | ||
| 55 | +`tile_x1`/`tile_y1` clamp) already existed in the tree before this round and | ||
| 56 | +both stage-1 and stage-2 fixes now feed it real values on every call site | ||
| 57 | +(key frame AND inter frame). The `>2 tile columns` and `multi-tile + | ||
| 58 | +loop-filter` refusals were deliberately NOT lifted this round -- the | ||
| 59 | +charter requires re-running the two-column gate with | ||
| 60 | +`--loopfilter-control=0` removed and confirming pixel-exact before lifting | ||
| 61 | +either, and that gate run did not happen (turn budget). Mechanically the | ||
| 62 | +fix may already be sufficient; it is unverified, so the refusals stay. | ||
| 63 | +deferred: re-run `a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact` | ||
| 64 | +with `--loopfilter-control=0` removed; if pixel-exact, lift both the | ||
| 65 | +`>2 columns` and `loop-filter` refusals in the same commit (they're the | ||
| 66 | +same underlying gap per r5's own note). | ||
| 67 | + | ||
| 68 | +## Files changed | ||
| 69 | +- crates/ec-av1/src/decode.rs -- stage 1 fix (key-frame tile-origin call), | ||
| 70 | + stage 2 (inter per-tile loop, `tiles`/`tile_info` params, `result_cdfs`) | ||
| 71 | +- crates/ec-av1/src/mvstack.rs -- `MiGrid` tile bounds + `set_tile_bounds` | ||
| 72 | +- crates/ec-av1/src/stream.rs -- inter-frame call site passes `tile_bufs`/ | ||
| 73 | + `&header.tile_info`; multi-tile-inter refusal removed | ||
| 74 | +- crates/ec-av1/src/refusal_inventory.rs -- pinned string removed to match | ||
| 75 | + | ||
| 76 | +## Commits | ||
| 77 | +- 22a79b0 fix(av1): finish r5's set_tile_origin sweep -- key-frame tile loop now green | ||
| 78 | +- 8899fc1 feat(av1): inter frame per-tile decode loop, MV stack bounded per tile | ||
| 79 | + | ||
| 80 | +Never pushed, never merged, never touched main, worked only inside | ||
| 81 | +edith_codecs-tiles. | ||
lanes/tiles-r7.charter.mdadded+52 -0
| @@ -0,0 +1,52 @@ | |||
| 1 | +# lane-tiles r7 — gate what r6 lifted, then the reach bound | ||
| 2 | + | ||
| 3 | +At f9a0614. Read `lanes/tiles-r6.report.md`. | ||
| 4 | + | ||
| 5 | +## Where you stand | ||
| 6 | +r6 landed the inter per-tile loop (`decode_inter_frame_tile_with_cdfs` mirrors | ||
| 7 | +the key-frame path) and bounded the MV-candidate scan by giving the shared | ||
| 8 | +`MiGrid` tile bounds — one choke point instead of widening four | ||
| 9 | +`find_mv_stack*` signatures. That was a good deviation from the charter's | ||
| 10 | +literal wording and it stands. | ||
| 11 | + | ||
| 12 | +**But it lifted the "an inter frame with more than one tile" refusal with no | ||
| 13 | +gate proving a >1-tile-column INTER stream decodes.** r6 said so itself. Its | ||
| 14 | +evidence is a clean `cargo check`, a non-regressing 242/0 suite and a 44/0 | ||
| 15 | +scoped subset — none of which exercise the capability the refusal used to | ||
| 16 | +guard. Until the gate exists, that lift is an unproven claim, and this branch | ||
| 17 | +does not merge to main. Nothing else in this lane matters until it is written. | ||
| 18 | + | ||
| 19 | +## Order | ||
| 20 | +1. The gate: a real aomenc >1-tile-column INTER stream, pixel-exact through | ||
| 21 | + `decode_stream`, with a HARD-asserted tile-hit count. Recipe: | ||
| 22 | + `--threads=1 --row-mt=0 --sb-size=64` (this decoder hardcodes 64px | ||
| 23 | + superblocks), two motion-carrying frames, fixture through | ||
| 24 | + `gradients_source`, ffmpeg generate bounded with `-t <seconds>`. Main FAILS | ||
| 25 | + the suite if a gate turns a decode error into a printed SKIP, so write it as | ||
| 26 | + an attempt loop requiring at least one decode. If the gate does NOT pass, | ||
| 27 | + restore the refusal in the same commit — that is the honest outcome, not a | ||
| 28 | + failure. COMMIT. | ||
| 29 | +2. Re-run `a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact` with | ||
| 30 | + `--loopfilter-control=0` REMOVED. `PlaneBuf`'s `tile_x1`/`tile_y1` clamps now | ||
| 31 | + receive real values at every call site, so this may already pass. If it does, | ||
| 32 | + lift BOTH the ">2 tile columns" and the "multi-tile + loop-filter" refusals | ||
| 33 | + in one commit — r5 established they are the same underlying reach-bound gap — | ||
| 34 | + and update `refusal_inventory.rs`. COMMIT. | ||
| 35 | +3. Then tile rows, non-uniform spacing, several tile-group OBUs per frame, and | ||
| 36 | + `context_update_tile_id != 0` proven on a stream where it is not tile 0. | ||
| 37 | + | ||
| 38 | +## Note | ||
| 39 | +r5's handoff pointed at decode.rs:11661/11673 as unfinished; r6 found those were | ||
| 40 | +already correct and the real break was two 2-arg `set_tile_origin` calls in the | ||
| 41 | +key-frame loop. Stale pointers in a predecessor's handoff are worth one | ||
| 42 | +`cargo check` before you trust them. | ||
| 43 | + | ||
| 44 | +Merge note: main is at 53f5358. Report every refusal string you add, remove or | ||
| 45 | +reword, verbatim, for `refusal_inventory.rs`. | ||
| 46 | + | ||
| 47 | +Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-tiles`; foreground | ||
| 48 | +`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling | ||
| 49 | +worktrees have live agents — never build in or edit them. Never push, never | ||
| 50 | +merge into `main`. 75-turn cap, does not reset: land small, COMMIT AT EVERY | ||
| 51 | +GREEN STEP — this lane has now spent four rounds partly on budget management. | ||
| 52 | +End with `lanes/tiles-r7.report.md`, VERDICT on line 1. | ||
lanes/tiles-r7.report.mdadded+91 -0
| @@ -0,0 +1,91 @@ | |||
| 1 | +VERDICT: PARTIAL -- green, stage 1 (order) + stage 2 landed, stage 3 not started (turn budget). | ||
| 2 | + | ||
| 3 | +## Stage 1 -- gated r6's inter tile-loop lift | ||
| 4 | +Added `a_real_aomenc_stream_with_two_tile_columns_and_an_inter_frame_decodes_pixel_exact` | ||
| 5 | +(`crates/ec-av1/src/stream.rs`): `--sb-size=64`, `--tile-columns=1` (2 | ||
| 6 | +columns), `--loopfilter-control=0`, `--limit=2 --kf-max-dist=1000` so frame 1 | ||
| 7 | +is a genuine inter frame, `gradients_source`'s default `speed=0.01` rotation | ||
| 8 | +gives real motion so the tile-bounded MV stack (`MiGrid::set_tile_bounds`) | ||
| 9 | +actually has work to do across the boundary. Confirms via a header parse that | ||
| 10 | +aomenc really produced a >1-tile-column inter frame (not a collapsed/kf | ||
| 11 | +fallback) before trusting a match. 20/20 pixel-exact vs ffmpeg, 0 named | ||
| 12 | +refusals, hard `tile_hits > frames` assert. | ||
| 13 | + | ||
| 14 | +Building this gate found `decode_inter_frame_tile_with_cdfs`'s per-tile loop | ||
| 15 | +(r6, commit 8899fc1) never incremented `TILE_HITS` -- only the key-frame loop | ||
| 16 | +did (`decode.rs:4928`). Without the fix the gate's own tile-count assert | ||
| 17 | +would have been vacuously blind on the inter path (it failed first-run: | ||
| 18 | +"tile_hits delta was 2, expected > 2" -- both hits were from frame 0's key | ||
| 19 | +tiles, frame 1 contributed zero visible signal despite decoding correctly). | ||
| 20 | +Fixed by adding the same `TILE_HITS.with(|c| c.set(c.get() + 1));` call at | ||
| 21 | +the equivalent point in the inter loop (`decode.rs:9814`, right after | ||
| 22 | +`grid.set_tile_bounds`). Re-ran: 20/20 pixel-exact, `tile_hits` counted | ||
| 23 | +correctly. | ||
| 24 | + | ||
| 25 | +Committed bd1c01f. | ||
| 26 | + | ||
| 27 | +## Stage 2 -- lifted >2-columns and multi-tile-loop-filter refusals | ||
| 28 | +Charter order: re-run the key-frame 2-column gate | ||
| 29 | +(`a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact`) with | ||
| 30 | +`--loopfilter-control=0` removed. Did so: 20/20 pixel-exact, confirming | ||
| 31 | +`PlaneBuf`'s `tile_x1`/`tile_y1` clamps (real values at every call site since | ||
| 32 | +r6) already make real deblocking across a tile boundary correct. Made this | ||
| 33 | +permanent (flag removed for real, not just the trial run) and updated the | ||
| 34 | +gate's doc comment. | ||
| 35 | + | ||
| 36 | +That gate's own known-gap note said this only proves the boundary-is-also- | ||
| 37 | +the-frame-edge case (2 columns, tile 1 = right edge), so also added | ||
| 38 | +`a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact` | ||
| 39 | +(`--tile-columns=2` -> `TileCols=4`, 256x64 = four 64px superblocks, loop | ||
| 40 | +filter ON, no bypass of the flag): proves an *interior* tile boundary and the | ||
| 41 | +`>2 columns` case in one shot. 20/20 pixel-exact, 0 refusals. | ||
| 42 | + | ||
| 43 | +With both proven, lifted the `cols > 2` and `cols > 1 && loop_filter_on` | ||
| 44 | +refusals from `decode_stream` (`crates/ec-av1/src/stream.rs`) -- they were, | ||
| 45 | +per r5's note, the same underlying `PlaneBuf` reach-bound gap, now closed on | ||
| 46 | +both fronts. Updated `refusal_inventory.rs`'s pinned list to match (both | ||
| 47 | +strings removed). Tile *rows* stay refused (`tile_info.rows > 1`) -- | ||
| 48 | +unproven, untouched. | ||
| 49 | + | ||
| 50 | +Lifted refusals (verbatim, removed from `stream.rs` and | ||
| 51 | +`refusal_inventory.rs`'s pinned list): | ||
| 52 | +- "a frame with more than two tile columns (a non-last column's right-edge reach bound past column 0 is unimplemented)" | ||
| 53 | +- "a multi-tile frame with loop filtering enabled (deblocking crosses tile boundaries by spec default; PlaneBuf's tile origin does not clip a non-last column's right-edge reach)" | ||
| 54 | + | ||
| 55 | +Committed 325e8e7. | ||
| 56 | + | ||
| 57 | +## Stage 3 -- NOT STARTED | ||
| 58 | +Tile rows, non-uniform tile spacing, several tile-group OBUs per frame, and | ||
| 59 | +`context_update_tile_id != 0` on a non-tile-0 stream: none attempted this | ||
| 60 | +round (turn budget). The `tile_info.rows > 1` refusal is untouched and still | ||
| 61 | +guards tile rows correctly (no false claim made about it). | ||
| 62 | +deferred: tile-row gate + lift, non-uniform tile spacing, multi-tile-group | ||
| 63 | +OBU handling, `context_update_tile_id != 0` proof -- unblocks with a fresh | ||
| 64 | +turn budget; recipe likely `--tile-rows=1` mirroring this round's | ||
| 65 | +`--tile-columns` approach, gated the same way (bypass gate first, then | ||
| 66 | +`decode_stream`-level gate, then lift). | ||
| 67 | + | ||
| 68 | +## Files changed | ||
| 69 | +- `crates/ec-av1/src/decode.rs` -- `TILE_HITS` increment added to the inter | ||
| 70 | + per-tile loop (was silently missing, made the stage-1 gate's own assert | ||
| 71 | + meaningless until fixed) | ||
| 72 | +- `crates/ec-av1/src/stream.rs` -- 3 new gates (inter+2-col, | ||
| 73 | + 4-col+loopfilter-on, plus doc updates on the 2 pre-existing gates), the | ||
| 74 | + `cols > 2` and multi-tile-loop-filter refusals removed from | ||
| 75 | + `decode_stream`, `loop_filter_on` local removed (now unused) | ||
| 76 | +- `crates/ec-av1/src/refusal_inventory.rs` -- 2 pinned strings removed to | ||
| 77 | + match | ||
| 78 | + | ||
| 79 | +## Commits | ||
| 80 | +- bd1c01f test(av1): gate r6's inter tile-loop lift -- real >1-tile-column INTER stream | ||
| 81 | +- 325e8e7 feat(av1): lift >2-tile-column and multi-tile-loop-filter refusals | ||
| 82 | + | ||
| 83 | +Both `cargo check -p ec-av1 --tests` clean and the scoped subset | ||
| 84 | +(`tile mvstack refusal_inventory gate_coverage`, `EC_AV1_REQUIRE_AOMENC=1`) | ||
| 85 | +green: 78/0 after stage 2 (was 77/0 after stage 1). `refusal_inventory`'s own | ||
| 86 | +"capability_claims_are_declared_not_scattered" and | ||
| 87 | +"the_decode_path_refuses_exactly_the_listed_cases" tests both pass, so the | ||
| 88 | +pinned-list edits match the live refusal set exactly. | ||
| 89 | + | ||
| 90 | +Never pushed, never merged, never touched main, worked only inside | ||
| 91 | +edith_codecs-tiles. | ||