A prediction block 4 or fewer samples wide reads the REGULAR narrow subpel kernel under EIGHTTAP_SHARP too -- spec 7.11.3.4 filterIdx sends EIGHTTAP and EIGHTTAP_SHARP to filter index 4, and libaom's av1_interp_4tap[MULTITAP_SHARP] is av1_sub_pel_filters_4 (filter.h:239-244, comment "For w<=4, MULTITAP_SHARP is the same as EIGHTTAP_REGULAR")
Browse files at this commit53b4e5685bc8491e829ecc2dc777156a138f3351Parent: e148046- fix
- a prediction block 4 or fewer samples wide reads the REGULAR narrow subpel kernel under EIGHTTAP_SHARP too -- spec 7.11.3.4 filterIdx sends EIGHTTAP and EIGHTTAP_SHARP to filter index 4, and libaom's av1_interp_4tap[MULTITAP_SHARP] is av1_sub_pel_filters_4 (filter.h:239-244, comment "For w<=4, MULTITAP_SHARP is the same as EIGHTTAP_REGULAR")
- we used the 8-tap sharp table there, invisible above 4 samples so it only bit 4-wide chroma. Cherry-picked from lane-gmaffine 3bb10f1
- unit test pins all four narrow mappings (regular->4, smooth->4smooth, sharp->4, bilinear->bilinear)
1 changed file +35 -3
- crates/ec-av1/src/mc.rs +35 -3
crates/ec-av1/src/mc.rsmodified+35 -3
| @@ -119,8 +119,11 @@ const SUBPEL_FILTERS_SMOOTH_4: [[i32; 8]; 16] = [ | ||
| 119 | 119 | [0, 0, 2, 34, 62, 30, 0, 0], |
| 120 | 120 | ]; |
| 121 | 121 | |
| 122 | -/// `Subpel_Filters[EIGHTTAP_SHARP]` (`av1_sub_pel_filters_8sharp`) -- unlike | |
| 123 | -/// REGULAR/SMOOTH, spec 7.11.3.4 never swaps this for a narrow-block table. | |
| 122 | +/// `Subpel_Filters[EIGHTTAP_SHARP]` (`av1_sub_pel_filters_8sharp`). A block | |
| 123 | +/// whose dimension is 4 or less does NOT read this table: spec 7.11.3.4's | |
| 124 | +/// `filterIdx` sends both EIGHTTAP and EIGHTTAP_SHARP to filter index 4, and | |
| 125 | +/// libaom agrees -- `av1_interp_4tap[MULTITAP_SHARP]` is `av1_sub_pel_filters_4`, | |
| 126 | +/// the REGULAR narrow kernel (`filter.h:243`), not a sharp one (lane-gmaffine r5). | |
| 124 | 127 | const SUBPEL_FILTERS_SHARP: [[i32; 8]; 16] = [ |
| 125 | 128 | [0, 0, 0, 128, 0, 0, 0, 0], |
| 126 | 129 | [-2, 2, -6, 126, 8, -2, 2, 0], |
| @@ -181,7 +184,7 @@ impl InterpFilterKind { | ||
| 181 | 184 | match self { |
| 182 | 185 | InterpFilterKind::Regular => (&SUBPEL_FILTERS, &SUBPEL_FILTERS_4), |
| 183 | 186 | InterpFilterKind::Smooth => (&SUBPEL_FILTERS_SMOOTH, &SUBPEL_FILTERS_SMOOTH_4), |
| 184 | - InterpFilterKind::Sharp => (&SUBPEL_FILTERS_SHARP, &SUBPEL_FILTERS_SHARP), | |
| 187 | + InterpFilterKind::Sharp => (&SUBPEL_FILTERS_SHARP, &SUBPEL_FILTERS_4), | |
| 185 | 188 | InterpFilterKind::Bilinear => (&SUBPEL_FILTERS_BILINEAR, &SUBPEL_FILTERS_BILINEAR), |
| 186 | 189 | } |
| 187 | 190 | } |
| @@ -921,6 +924,35 @@ mod tests { | ||
| 921 | 924 | ); |
| 922 | 925 | } |
| 923 | 926 | |
| 927 | + /// lane-gmaffine r5 root cause: a block 4 or fewer samples wide reads | |
| 928 | + /// `Subpel_Filters[4]` -- the REGULAR narrow kernel -- for BOTH | |
| 929 | + /// `EIGHTTAP` and `EIGHTTAP_SHARP` (spec 7.11.3.4's `filterIdx`, libaom | |
| 930 | + /// `av1_interp_4tap[MULTITAP_SHARP] == av1_sub_pel_filters_4`, | |
| 931 | + /// `filter.h:243`). We used the 8-tap sharp kernel there, which is | |
| 932 | + /// invisible above 4 samples and so only ever bit the 4x4 chroma of an | |
| 933 | + /// 8x8 (or smaller) luma leaf. | |
| 934 | + #[test] | |
| 935 | + fn a_narrow_block_reads_the_regular_four_tap_kernel_under_every_sharpness() { | |
| 936 | + use crate::mc::{SUBPEL_FILTERS_4, SUBPEL_FILTERS_BILINEAR, SUBPEL_FILTERS_SMOOTH_4}; | |
| 937 | + for kind in [ | |
| 938 | + InterpFilterKind::Regular, | |
| 939 | + InterpFilterKind::Smooth, | |
| 940 | + InterpFilterKind::Sharp, | |
| 941 | + InterpFilterKind::Bilinear, | |
| 942 | + ] { | |
| 943 | + let (wide, narrow) = kind.tables(); | |
| 944 | + let want: &[[i32; 8]; 16] = match kind { | |
| 945 | + InterpFilterKind::Regular | InterpFilterKind::Sharp => &SUBPEL_FILTERS_4, | |
| 946 | + InterpFilterKind::Smooth => &SUBPEL_FILTERS_SMOOTH_4, | |
| 947 | + InterpFilterKind::Bilinear => &SUBPEL_FILTERS_BILINEAR, | |
| 948 | + }; | |
| 949 | + assert_eq!(narrow, want, "{kind:?}: wrong narrow-block kernel"); | |
| 950 | + if kind == InterpFilterKind::Sharp { | |
| 951 | + assert_ne!(wide, narrow, "sharp's wide kernel is not its narrow one"); | |
| 952 | + } | |
| 953 | + } | |
| 954 | + } | |
| 955 | + | |
| 924 | 956 | #[test] |
| 925 | 957 | fn integer_mv_is_identity() { |
| 926 | 958 | let width = 12; |