Merge branch 'lane-av1tx4': TX4 luma decode and the 1D transform classes
Browse files at this commit6 changed files +1081 -52
- crates/ec-av1/src/cdf.rs +449 -0
- crates/ec-av1/src/cdf_state.rs +143 -0
- crates/ec-av1/src/decode.rs +308 -48
- crates/ec-av1/src/encode.rs +18 -4
- crates/ec-av1/src/msac.rs +7 -0
- crates/ec-av1/src/stream.rs +156 -0
crates/ec-av1/src/cdf.rsmodified+449 -0
| @@ -3008,6 +3008,14 @@ pub const EOB_PT_64_LUMA: [u16; 8] = [2374, 2772, 4583, 7276, 12288, 19706, 3276 | |||
| 3008 | /// EOB_PT_64_LUMA_Q3, q-context 3: the same table as [`EOB_PT_64_LUMA`], for `base_q_idx` 121..=255. | 3008 | /// EOB_PT_64_LUMA_Q3, q-context 3: the same table as [`EOB_PT_64_LUMA`], for `base_q_idx` 121..=255. |
| 3009 | pub const EOB_PT_64_LUMA_Q3: [u16; 8] = [6307, 7541, 12060, 16358, 22553, 27865, 32768, 0]; | 3009 | pub const EOB_PT_64_LUMA_Q3: [u16; 8] = [6307, 7541, 12060, 16358, 22553, 27865, 32768, 0]; |
| 3010 | 3010 | ||
| 3011 | +/// The `EOB_PT_64_LUMA` sibling of [`EOB_PT_16_LUMA_CLASS1`] | ||
| 3012 | +/// (`av1_default_eob_multi64_cdfs[q][0][1]`), for an 8x8 luma TU whose | ||
| 3013 | +/// `tx_type` resolves `V_DCT`/`H_DCT`. | ||
| 3014 | +pub const EOB_PT_64_LUMA_CLASS1_Q0: [u16; 8] = [335, 730, 1459, 5494, 8755, 12997, 32768, 0]; | ||
| 3015 | +pub const EOB_PT_64_LUMA_CLASS1_Q1: [u16; 8] = [401, 605, 1029, 2563, 5845, 12626, 32768, 0]; | ||
| 3016 | +pub const EOB_PT_64_LUMA_CLASS1: [u16; 8] = [497, 810, 1315, 3000, 7004, 15641, 32768, 0]; | ||
| 3017 | +pub const EOB_PT_64_LUMA_CLASS1_Q3: [u16; 8] = [1289, 2320, 3971, 7926, 14153, 24291, 32768, 0]; | ||
| 3018 | + | ||
| 3011 | /// EOB_PT_16_CHROMA_Q0, q-context 0: the same table as [`EOB_PT_16_CHROMA`], for `base_q_idx` 0..=20. | 3019 | /// EOB_PT_16_CHROMA_Q0, q-context 0: the same table as [`EOB_PT_16_CHROMA`], for `base_q_idx` 0..=20. |
| 3012 | pub const EOB_PT_16_CHROMA_Q0: [u16; 6] = [3247, 4950, 9688, 14563, 32768, 0]; | 3020 | pub const EOB_PT_16_CHROMA_Q0: [u16; 6] = [3247, 4950, 9688, 14563, 32768, 0]; |
| 3013 | 3021 | ||
| @@ -3936,3 +3944,444 @@ pub const TXB_SKIP_LUMA_64_Q3_CTX: [[u16; 3]; 7] = [ | |||
| 3936 | [30026, 32768, 0], | 3944 | [30026, 32768, 0], |
| 3937 | [32441, 32768, 0], | 3945 | [32441, 32768, 0], |
| 3938 | ]; | 3946 | ]; |
| 3947 | + | ||
| 3948 | +// The tables below extend the `_LUMA_8`/`Luma8Set1` straddling-16x16 support | ||
| 3949 | +// above to a resolved `TX4` (spec `TX_4X4`) luma transform unit: a | ||
| 3950 | +// `TxMode::Select` 8x8 leaf or 16x16 block whose `tx_depth` read exhausts | ||
| 3951 | +// down to the smallest size (lane-av1tx4). Extracted byte-exact from | ||
| 3952 | +// libaom's `token_cdfs.h` `TX_SIZES` idx0 (`TX_4X4`)/`PLANE_TYPES` idx0 | ||
| 3953 | +// (luma), the same indexing method that verified the `_LUMA_8`/`COEFF_BR_LUMA_8` | ||
| 3954 | +// families above. | ||
| 3955 | + | ||
| 3956 | +/// The full luma sub-range of spec `TXB_SKIP_CONTEXTS` (contexts 0..6) for a | ||
| 3957 | +/// resolved 4x4 luma transform, same convention as [`TXB_SKIP_LUMA_8_CTX`]. | ||
| 3958 | +pub const TXB_SKIP_LUMA_4_Q0_CTX: [[u16; 3]; 7] = [ | ||
| 3959 | + [31849, 32768, 0], | ||
| 3960 | + [5892, 32768, 0], | ||
| 3961 | + [12112, 32768, 0], | ||
| 3962 | + [21935, 32768, 0], | ||
| 3963 | + [20289, 32768, 0], | ||
| 3964 | + [27473, 32768, 0], | ||
| 3965 | + [32487, 32768, 0], | ||
| 3966 | +]; | ||
| 3967 | +pub const TXB_SKIP_LUMA_4_Q1_CTX: [[u16; 3]; 7] = [ | ||
| 3968 | + [30371, 32768, 0], | ||
| 3969 | + [7570, 32768, 0], | ||
| 3970 | + [13155, 32768, 0], | ||
| 3971 | + [20751, 32768, 0], | ||
| 3972 | + [20969, 32768, 0], | ||
| 3973 | + [27067, 32768, 0], | ||
| 3974 | + [32013, 32768, 0], | ||
| 3975 | +]; | ||
| 3976 | +pub const TXB_SKIP_LUMA_4_CTX: [[u16; 3]; 7] = [ | ||
| 3977 | + [29614, 32768, 0], | ||
| 3978 | + [9068, 32768, 0], | ||
| 3979 | + [12924, 32768, 0], | ||
| 3980 | + [19538, 32768, 0], | ||
| 3981 | + [17737, 32768, 0], | ||
| 3982 | + [24619, 32768, 0], | ||
| 3983 | + [30642, 32768, 0], | ||
| 3984 | +]; | ||
| 3985 | +pub const TXB_SKIP_LUMA_4_Q3_CTX: [[u16; 3]; 7] = [ | ||
| 3986 | + [26887, 32768, 0], | ||
| 3987 | + [6729, 32768, 0], | ||
| 3988 | + [10361, 32768, 0], | ||
| 3989 | + [17442, 32768, 0], | ||
| 3990 | + [15045, 32768, 0], | ||
| 3991 | + [22478, 32768, 0], | ||
| 3992 | + [29072, 32768, 0], | ||
| 3993 | +]; | ||
| 3994 | + | ||
| 3995 | +/// The end-of-block group of a 4x4 luma transform (`av1_default_eob_multi16_cdfs`, | ||
| 3996 | +/// `PLANE_TYPES` idx0 luma). | ||
| 3997 | +pub const EOB_PT_16_LUMA_Q0: [u16; 6] = [840, 1039, 1980, 4895, 32768, 0]; | ||
| 3998 | +pub const EOB_PT_16_LUMA_Q1: [u16; 6] = [2125, 2551, 5165, 8946, 32768, 0]; | ||
| 3999 | +pub const EOB_PT_16_LUMA: [u16; 6] = [4016, 4897, 8881, 14968, 32768, 0]; | ||
| 4000 | +pub const EOB_PT_16_LUMA_Q3: [u16; 6] = [6708, 8958, 14746, 22133, 32768, 0]; | ||
| 4001 | + | ||
| 4002 | +/// The `TX_CLASS_HORIZ`/`TX_CLASS_VERT` (non-2D-scan) sibling of | ||
| 4003 | +/// [`EOB_PT_16_LUMA`] (`av1_default_eob_multi16_cdfs[q][0][1]`) -- read | ||
| 4004 | +/// instead of the 2D table whenever a 4x4 luma TU's `tx_type` resolves to | ||
| 4005 | +/// `V_DCT`/`H_DCT` (lane-av1tx4 r5: the class dimension libaom always keeps, | ||
| 4006 | +/// this crate never carried at all until a real aomdec trace showed the | ||
| 4007 | +/// desync starting exactly at this read). | ||
| 4008 | +pub const EOB_PT_16_LUMA_CLASS1_Q0: [u16; 6] = [370, 671, 1883, 4471, 32768, 0]; | ||
| 4009 | +pub const EOB_PT_16_LUMA_CLASS1_Q1: [u16; 6] = [513, 765, 1859, 6339, 32768, 0]; | ||
| 4010 | +pub const EOB_PT_16_LUMA_CLASS1: [u16; 6] = [716, 1105, 2646, 10056, 32768, 0]; | ||
| 4011 | +pub const EOB_PT_16_LUMA_CLASS1_Q3: [u16; 6] = [1222, 2074, 4783, 15410, 32768, 0]; | ||
| 4012 | + | ||
| 4013 | +// EOB_EXTRA_LUMA_4 | ||
| 4014 | +pub const EOB_EXTRA_LUMA_4_Q0: [[u16; 3]; 9] = [ | ||
| 4015 | + [16961, 32768, 0], | ||
| 4016 | + [17223, 32768, 0], | ||
| 4017 | + [7621, 32768, 0], | ||
| 4018 | + [16384, 32768, 0], | ||
| 4019 | + [16384, 32768, 0], | ||
| 4020 | + [16384, 32768, 0], | ||
| 4021 | + [16384, 32768, 0], | ||
| 4022 | + [16384, 32768, 0], | ||
| 4023 | + [16384, 32768, 0], | ||
| 4024 | +]; | ||
| 4025 | + | ||
| 4026 | +pub const EOB_EXTRA_LUMA_4_Q1: [[u16; 3]; 9] = [ | ||
| 4027 | + [17471, 32768, 0], | ||
| 4028 | + [20223, 32768, 0], | ||
| 4029 | + [11357, 32768, 0], | ||
| 4030 | + [16384, 32768, 0], | ||
| 4031 | + [16384, 32768, 0], | ||
| 4032 | + [16384, 32768, 0], | ||
| 4033 | + [16384, 32768, 0], | ||
| 4034 | + [16384, 32768, 0], | ||
| 4035 | + [16384, 32768, 0], | ||
| 4036 | +]; | ||
| 4037 | + | ||
| 4038 | +pub const EOB_EXTRA_LUMA_4: [[u16; 3]; 9] = [ | ||
| 4039 | + [18983, 32768, 0], | ||
| 4040 | + [20512, 32768, 0], | ||
| 4041 | + [14885, 32768, 0], | ||
| 4042 | + [16384, 32768, 0], | ||
| 4043 | + [16384, 32768, 0], | ||
| 4044 | + [16384, 32768, 0], | ||
| 4045 | + [16384, 32768, 0], | ||
| 4046 | + [16384, 32768, 0], | ||
| 4047 | + [16384, 32768, 0], | ||
| 4048 | +]; | ||
| 4049 | + | ||
| 4050 | +pub const EOB_EXTRA_LUMA_4_Q3: [[u16; 3]; 9] = [ | ||
| 4051 | + [20177, 32768, 0], | ||
| 4052 | + [20789, 32768, 0], | ||
| 4053 | + [20262, 32768, 0], | ||
| 4054 | + [16384, 32768, 0], | ||
| 4055 | + [16384, 32768, 0], | ||
| 4056 | + [16384, 32768, 0], | ||
| 4057 | + [16384, 32768, 0], | ||
| 4058 | + [16384, 32768, 0], | ||
| 4059 | + [16384, 32768, 0], | ||
| 4060 | +]; | ||
| 4061 | + | ||
| 4062 | +// COEFF_BASE_LUMA_4 | ||
| 4063 | +pub const COEFF_BASE_LUMA_4_Q0: [[u16; 5]; 42] = [ | ||
| 4064 | + [4034, 8930, 12727, 32768, 0], | ||
| 4065 | + [18082, 29741, 31877, 32768, 0], | ||
| 4066 | + [12596, 26124, 30493, 32768, 0], | ||
| 4067 | + [9446, 21118, 27005, 32768, 0], | ||
| 4068 | + [6308, 15141, 21279, 32768, 0], | ||
| 4069 | + [2463, 6357, 9783, 32768, 0], | ||
| 4070 | + [20667, 30546, 31929, 32768, 0], | ||
| 4071 | + [13043, 26123, 30134, 32768, 0], | ||
| 4072 | + [8151, 18757, 24778, 32768, 0], | ||
| 4073 | + [5255, 12839, 18632, 32768, 0], | ||
| 4074 | + [2820, 7206, 11161, 32768, 0], | ||
| 4075 | + [8192, 16384, 24576, 32768, 0], | ||
| 4076 | + [8192, 16384, 24576, 32768, 0], | ||
| 4077 | + [8192, 16384, 24576, 32768, 0], | ||
| 4078 | + [8192, 16384, 24576, 32768, 0], | ||
| 4079 | + [8192, 16384, 24576, 32768, 0], | ||
| 4080 | + [8192, 16384, 24576, 32768, 0], | ||
| 4081 | + [8192, 16384, 24576, 32768, 0], | ||
| 4082 | + [8192, 16384, 24576, 32768, 0], | ||
| 4083 | + [8192, 16384, 24576, 32768, 0], | ||
| 4084 | + [8192, 16384, 24576, 32768, 0], | ||
| 4085 | + [15736, 27553, 30604, 32768, 0], | ||
| 4086 | + [11210, 23794, 28787, 32768, 0], | ||
| 4087 | + [5947, 13874, 19701, 32768, 0], | ||
| 4088 | + [4215, 9323, 13891, 32768, 0], | ||
| 4089 | + [2833, 6462, 10059, 32768, 0], | ||
| 4090 | + [19605, 30393, 31582, 32768, 0], | ||
| 4091 | + [13523, 26252, 30248, 32768, 0], | ||
| 4092 | + [8446, 18622, 24512, 32768, 0], | ||
| 4093 | + [3818, 10343, 15974, 32768, 0], | ||
| 4094 | + [1481, 4117, 6796, 32768, 0], | ||
| 4095 | + [22649, 31302, 32190, 32768, 0], | ||
| 4096 | + [14829, 27127, 30449, 32768, 0], | ||
| 4097 | + [8313, 17702, 23304, 32768, 0], | ||
| 4098 | + [3022, 8301, 12786, 32768, 0], | ||
| 4099 | + [1536, 4412, 7184, 32768, 0], | ||
| 4100 | + [22354, 29774, 31372, 32768, 0], | ||
| 4101 | + [14723, 25472, 29214, 32768, 0], | ||
| 4102 | + [6673, 13745, 18662, 32768, 0], | ||
| 4103 | + [2068, 5766, 9322, 32768, 0], | ||
| 4104 | + [8192, 16384, 24576, 32768, 0], | ||
| 4105 | + [8192, 16384, 24576, 32768, 0], | ||
| 4106 | +]; | ||
| 4107 | + | ||
| 4108 | +pub const COEFF_BASE_LUMA_4_Q1: [[u16; 5]; 42] = [ | ||
| 4109 | + [6041, 11854, 15927, 32768, 0], | ||
| 4110 | + [20326, 30905, 32251, 32768, 0], | ||
| 4111 | + [14164, 26831, 30725, 32768, 0], | ||
| 4112 | + [9760, 20647, 26585, 32768, 0], | ||
| 4113 | + [6416, 14953, 21219, 32768, 0], | ||
| 4114 | + [2966, 7151, 10891, 32768, 0], | ||
| 4115 | + [23567, 31374, 32254, 32768, 0], | ||
| 4116 | + [14978, 27416, 30946, 32768, 0], | ||
| 4117 | + [9434, 20225, 26254, 32768, 0], | ||
| 4118 | + [6658, 14558, 20535, 32768, 0], | ||
| 4119 | + [3916, 8677, 12989, 32768, 0], | ||
| 4120 | + [8192, 16384, 24576, 32768, 0], | ||
| 4121 | + [8192, 16384, 24576, 32768, 0], | ||
| 4122 | + [8192, 16384, 24576, 32768, 0], | ||
| 4123 | + [8192, 16384, 24576, 32768, 0], | ||
| 4124 | + [8192, 16384, 24576, 32768, 0], | ||
| 4125 | + [8192, 16384, 24576, 32768, 0], | ||
| 4126 | + [8192, 16384, 24576, 32768, 0], | ||
| 4127 | + [8192, 16384, 24576, 32768, 0], | ||
| 4128 | + [8192, 16384, 24576, 32768, 0], | ||
| 4129 | + [8192, 16384, 24576, 32768, 0], | ||
| 4130 | + [18088, 29545, 31587, 32768, 0], | ||
| 4131 | + [13062, 25843, 30073, 32768, 0], | ||
| 4132 | + [8940, 16827, 22251, 32768, 0], | ||
| 4133 | + [7654, 13220, 17973, 32768, 0], | ||
| 4134 | + [5733, 10316, 14456, 32768, 0], | ||
| 4135 | + [22879, 31388, 32114, 32768, 0], | ||
| 4136 | + [15215, 27993, 30955, 32768, 0], | ||
| 4137 | + [9397, 19445, 24978, 32768, 0], | ||
| 4138 | + [3442, 9813, 15344, 32768, 0], | ||
| 4139 | + [1368, 3936, 6532, 32768, 0], | ||
| 4140 | + [25494, 32033, 32406, 32768, 0], | ||
| 4141 | + [16772, 27963, 30718, 32768, 0], | ||
| 4142 | + [9419, 18165, 23260, 32768, 0], | ||
| 4143 | + [2677, 7501, 11797, 32768, 0], | ||
| 4144 | + [1516, 4344, 7170, 32768, 0], | ||
| 4145 | + [26556, 31454, 32101, 32768, 0], | ||
| 4146 | + [17128, 27035, 30108, 32768, 0], | ||
| 4147 | + [8324, 15344, 20249, 32768, 0], | ||
| 4148 | + [1903, 5696, 9469, 32768, 0], | ||
| 4149 | + [8192, 16384, 24576, 32768, 0], | ||
| 4150 | + [8192, 16384, 24576, 32768, 0], | ||
| 4151 | +]; | ||
| 4152 | + | ||
| 4153 | +pub const COEFF_BASE_LUMA_4: [[u16; 5]; 42] = [ | ||
| 4154 | + [8896, 16227, 20630, 32768, 0], | ||
| 4155 | + [23629, 31782, 32527, 32768, 0], | ||
| 4156 | + [15173, 27755, 31321, 32768, 0], | ||
| 4157 | + [10158, 21233, 27382, 32768, 0], | ||
| 4158 | + [6420, 14857, 21558, 32768, 0], | ||
| 4159 | + [3269, 8155, 12646, 32768, 0], | ||
| 4160 | + [24835, 32009, 32496, 32768, 0], | ||
| 4161 | + [16509, 28421, 31579, 32768, 0], | ||
| 4162 | + [10957, 21514, 27418, 32768, 0], | ||
| 4163 | + [7881, 15930, 22096, 32768, 0], | ||
| 4164 | + [5388, 10960, 15918, 32768, 0], | ||
| 4165 | + [8192, 16384, 24576, 32768, 0], | ||
| 4166 | + [8192, 16384, 24576, 32768, 0], | ||
| 4167 | + [8192, 16384, 24576, 32768, 0], | ||
| 4168 | + [8192, 16384, 24576, 32768, 0], | ||
| 4169 | + [8192, 16384, 24576, 32768, 0], | ||
| 4170 | + [8192, 16384, 24576, 32768, 0], | ||
| 4171 | + [8192, 16384, 24576, 32768, 0], | ||
| 4172 | + [8192, 16384, 24576, 32768, 0], | ||
| 4173 | + [8192, 16384, 24576, 32768, 0], | ||
| 4174 | + [8192, 16384, 24576, 32768, 0], | ||
| 4175 | + [20745, 30773, 32093, 32768, 0], | ||
| 4176 | + [15200, 27221, 30861, 32768, 0], | ||
| 4177 | + [13032, 20873, 25667, 32768, 0], | ||
| 4178 | + [12285, 18663, 23494, 32768, 0], | ||
| 4179 | + [11563, 17481, 21489, 32768, 0], | ||
| 4180 | + [26260, 31982, 32320, 32768, 0], | ||
| 4181 | + [15397, 28083, 31100, 32768, 0], | ||
| 4182 | + [9742, 19217, 24824, 32768, 0], | ||
| 4183 | + [3261, 9629, 15362, 32768, 0], | ||
| 4184 | + [1480, 4322, 7499, 32768, 0], | ||
| 4185 | + [27599, 32256, 32460, 32768, 0], | ||
| 4186 | + [16857, 27659, 30774, 32768, 0], | ||
| 4187 | + [9551, 18290, 23748, 32768, 0], | ||
| 4188 | + [3052, 8933, 14103, 32768, 0], | ||
| 4189 | + [2021, 5910, 9787, 32768, 0], | ||
| 4190 | + [29005, 32015, 32392, 32768, 0], | ||
| 4191 | + [17677, 27694, 30863, 32768, 0], | ||
| 4192 | + [9204, 17356, 23219, 32768, 0], | ||
| 4193 | + [2403, 7516, 12814, 32768, 0], | ||
| 4194 | + [8192, 16384, 24576, 32768, 0], | ||
| 4195 | + [8192, 16384, 24576, 32768, 0], | ||
| 4196 | +]; | ||
| 4197 | + | ||
| 4198 | +pub const COEFF_BASE_LUMA_4_Q3: [[u16; 5]; 42] = [ | ||
| 4199 | + [7062, 16472, 22319, 32768, 0], | ||
| 4200 | + [24538, 32261, 32674, 32768, 0], | ||
| 4201 | + [13675, 28041, 31779, 32768, 0], | ||
| 4202 | + [8590, 20674, 27631, 32768, 0], | ||
| 4203 | + [5685, 14675, 22013, 32768, 0], | ||
| 4204 | + [3655, 9898, 15731, 32768, 0], | ||
| 4205 | + [26493, 32418, 32658, 32768, 0], | ||
| 4206 | + [16376, 29342, 32090, 32768, 0], | ||
| 4207 | + [10594, 22649, 28970, 32768, 0], | ||
| 4208 | + [8176, 17170, 24303, 32768, 0], | ||
| 4209 | + [5605, 12694, 19139, 32768, 0], | ||
| 4210 | + [8192, 16384, 24576, 32768, 0], | ||
| 4211 | + [8192, 16384, 24576, 32768, 0], | ||
| 4212 | + [8192, 16384, 24576, 32768, 0], | ||
| 4213 | + [8192, 16384, 24576, 32768, 0], | ||
| 4214 | + [8192, 16384, 24576, 32768, 0], | ||
| 4215 | + [8192, 16384, 24576, 32768, 0], | ||
| 4216 | + [8192, 16384, 24576, 32768, 0], | ||
| 4217 | + [8192, 16384, 24576, 32768, 0], | ||
| 4218 | + [8192, 16384, 24576, 32768, 0], | ||
| 4219 | + [8192, 16384, 24576, 32768, 0], | ||
| 4220 | + [23888, 31902, 32542, 32768, 0], | ||
| 4221 | + [18612, 29687, 31987, 32768, 0], | ||
| 4222 | + [16245, 24852, 29249, 32768, 0], | ||
| 4223 | + [15765, 22608, 27559, 32768, 0], | ||
| 4224 | + [19895, 24699, 27510, 32768, 0], | ||
| 4225 | + [28401, 32212, 32457, 32768, 0], | ||
| 4226 | + [15274, 27825, 30980, 32768, 0], | ||
| 4227 | + [9364, 18128, 24332, 32768, 0], | ||
| 4228 | + [2283, 8193, 15082, 32768, 0], | ||
| 4229 | + [1228, 3972, 7881, 32768, 0], | ||
| 4230 | + [29455, 32469, 32620, 32768, 0], | ||
| 4231 | + [17981, 28245, 31388, 32768, 0], | ||
| 4232 | + [10921, 20098, 26240, 32768, 0], | ||
| 4233 | + [3743, 11829, 18657, 32768, 0], | ||
| 4234 | + [2374, 9593, 15715, 32768, 0], | ||
| 4235 | + [31068, 32466, 32635, 32768, 0], | ||
| 4236 | + [20321, 29572, 31971, 32768, 0], | ||
| 4237 | + [10771, 20255, 27119, 32768, 0], | ||
| 4238 | + [2795, 10410, 17361, 32768, 0], | ||
| 4239 | + [8192, 16384, 24576, 32768, 0], | ||
| 4240 | + [8192, 16384, 24576, 32768, 0], | ||
| 4241 | +]; | ||
| 4242 | + | ||
| 4243 | +// COEFF_BASE_EOB_LUMA_4 | ||
| 4244 | +pub const COEFF_BASE_EOB_LUMA_4_Q0: [[u16; 4]; 4] = [ | ||
| 4245 | + [17837, 29055, 32768, 0], | ||
| 4246 | + [29600, 31446, 32768, 0], | ||
| 4247 | + [30844, 31878, 32768, 0], | ||
| 4248 | + [24926, 28948, 32768, 0], | ||
| 4249 | +]; | ||
| 4250 | + | ||
| 4251 | +pub const COEFF_BASE_EOB_LUMA_4_Q1: [[u16; 4]; 4] = [ | ||
| 4252 | + [17560, 29888, 32768, 0], | ||
| 4253 | + [29671, 31549, 32768, 0], | ||
| 4254 | + [31007, 32056, 32768, 0], | ||
| 4255 | + [27286, 30006, 32768, 0], | ||
| 4256 | +]; | ||
| 4257 | + | ||
| 4258 | +pub const COEFF_BASE_EOB_LUMA_4: [[u16; 4]; 4] = [ | ||
| 4259 | + [20092, 30774, 32768, 0], | ||
| 4260 | + [30695, 32020, 32768, 0], | ||
| 4261 | + [31131, 32103, 32768, 0], | ||
| 4262 | + [28666, 30870, 32768, 0], | ||
| 4263 | +]; | ||
| 4264 | + | ||
| 4265 | +pub const COEFF_BASE_EOB_LUMA_4_Q3: [[u16; 4]; 4] = [ | ||
| 4266 | + [22497, 31198, 32768, 0], | ||
| 4267 | + [31715, 32495, 32768, 0], | ||
| 4268 | + [31606, 32337, 32768, 0], | ||
| 4269 | + [30388, 31990, 32768, 0], | ||
| 4270 | +]; | ||
| 4271 | + | ||
| 4272 | +// COEFF_BR_LUMA_4 | ||
| 4273 | +pub const COEFF_BR_LUMA_4_Q0: [[u16; 5]; 21] = [ | ||
| 4274 | + [14298, 20718, 24174, 32768, 0], | ||
| 4275 | + [12536, 19601, 23789, 32768, 0], | ||
| 4276 | + [8712, 15051, 19503, 32768, 0], | ||
| 4277 | + [6170, 11327, 15434, 32768, 0], | ||
| 4278 | + [4742, 8926, 12538, 32768, 0], | ||
| 4279 | + [3803, 7317, 10546, 32768, 0], | ||
| 4280 | + [1696, 3317, 4871, 32768, 0], | ||
| 4281 | + [14392, 19951, 22756, 32768, 0], | ||
| 4282 | + [15978, 23218, 26818, 32768, 0], | ||
| 4283 | + [12187, 19474, 23889, 32768, 0], | ||
| 4284 | + [9176, 15640, 20259, 32768, 0], | ||
| 4285 | + [7068, 12655, 17028, 32768, 0], | ||
| 4286 | + [5656, 10442, 14472, 32768, 0], | ||
| 4287 | + [2580, 4992, 7244, 32768, 0], | ||
| 4288 | + [12136, 18049, 21426, 32768, 0], | ||
| 4289 | + [13784, 20721, 24481, 32768, 0], | ||
| 4290 | + [10836, 17621, 21900, 32768, 0], | ||
| 4291 | + [8372, 14444, 18847, 32768, 0], | ||
| 4292 | + [6523, 11779, 16000, 32768, 0], | ||
| 4293 | + [5337, 9898, 13760, 32768, 0], | ||
| 4294 | + [3034, 5860, 8462, 32768, 0], | ||
| 4295 | +]; | ||
| 4296 | + | ||
| 4297 | +pub const COEFF_BR_LUMA_4_Q1: [[u16; 5]; 21] = [ | ||
| 4298 | + [14995, 21341, 24749, 32768, 0], | ||
| 4299 | + [13158, 20289, 24601, 32768, 0], | ||
| 4300 | + [8941, 15326, 19876, 32768, 0], | ||
| 4301 | + [6297, 11541, 15807, 32768, 0], | ||
| 4302 | + [4817, 9029, 12776, 32768, 0], | ||
| 4303 | + [3731, 7273, 10627, 32768, 0], | ||
| 4304 | + [1847, 3617, 5354, 32768, 0], | ||
| 4305 | + [14472, 19659, 22343, 32768, 0], | ||
| 4306 | + [16806, 24162, 27533, 32768, 0], | ||
| 4307 | + [12900, 20404, 24713, 32768, 0], | ||
| 4308 | + [9411, 16112, 20797, 32768, 0], | ||
| 4309 | + [7056, 12697, 17148, 32768, 0], | ||
| 4310 | + [5544, 10339, 14460, 32768, 0], | ||
| 4311 | + [2954, 5704, 8319, 32768, 0], | ||
| 4312 | + [12464, 18071, 21354, 32768, 0], | ||
| 4313 | + [15482, 22528, 26034, 32768, 0], | ||
| 4314 | + [12070, 19269, 23624, 32768, 0], | ||
| 4315 | + [8953, 15406, 20106, 32768, 0], | ||
| 4316 | + [7027, 12730, 17220, 32768, 0], | ||
| 4317 | + [5887, 10913, 15140, 32768, 0], | ||
| 4318 | + [3793, 7278, 10447, 32768, 0], | ||
| 4319 | +]; | ||
| 4320 | + | ||
| 4321 | +pub const COEFF_BR_LUMA_4: [[u16; 5]; 21] = [ | ||
| 4322 | + [16138, 22223, 25509, 32768, 0], | ||
| 4323 | + [15347, 22430, 26332, 32768, 0], | ||
| 4324 | + [9614, 16736, 21332, 32768, 0], | ||
| 4325 | + [6600, 12275, 16907, 32768, 0], | ||
| 4326 | + [4811, 9424, 13547, 32768, 0], | ||
| 4327 | + [3748, 7809, 11420, 32768, 0], | ||
| 4328 | + [2254, 4587, 6890, 32768, 0], | ||
| 4329 | + [15196, 20284, 23177, 32768, 0], | ||
| 4330 | + [18317, 25469, 28451, 32768, 0], | ||
| 4331 | + [13918, 21651, 25842, 32768, 0], | ||
| 4332 | + [10052, 17150, 21995, 32768, 0], | ||
| 4333 | + [7499, 13630, 18587, 32768, 0], | ||
| 4334 | + [6158, 11417, 16003, 32768, 0], | ||
| 4335 | + [4014, 7785, 11252, 32768, 0], | ||
| 4336 | + [15048, 21067, 24384, 32768, 0], | ||
| 4337 | + [18202, 25346, 28553, 32768, 0], | ||
| 4338 | + [14302, 22019, 26356, 32768, 0], | ||
| 4339 | + [10839, 18139, 23166, 32768, 0], | ||
| 4340 | + [8715, 15744, 20806, 32768, 0], | ||
| 4341 | + [7536, 13576, 18544, 32768, 0], | ||
| 4342 | + [5413, 10335, 14498, 32768, 0], | ||
| 4343 | +]; | ||
| 4344 | + | ||
| 4345 | +pub const COEFF_BR_LUMA_4_Q3: [[u16; 5]; 21] = [ | ||
| 4346 | + [18315, 24289, 27551, 32768, 0], | ||
| 4347 | + [16854, 24068, 27835, 32768, 0], | ||
| 4348 | + [10140, 17927, 23173, 32768, 0], | ||
| 4349 | + [6722, 12982, 18267, 32768, 0], | ||
| 4350 | + [4661, 9826, 14706, 32768, 0], | ||
| 4351 | + [3832, 8165, 12294, 32768, 0], | ||
| 4352 | + [2795, 6098, 9245, 32768, 0], | ||
| 4353 | + [17145, 23326, 26672, 32768, 0], | ||
| 4354 | + [20733, 27680, 30308, 32768, 0], | ||
| 4355 | + [16032, 24461, 28546, 32768, 0], | ||
| 4356 | + [11653, 20093, 25081, 32768, 0], | ||
| 4357 | + [9290, 16429, 22086, 32768, 0], | ||
| 4358 | + [7796, 14598, 19982, 32768, 0], | ||
| 4359 | + [6502, 12378, 17441, 32768, 0], | ||
| 4360 | + [21681, 27732, 30320, 32768, 0], | ||
| 4361 | + [22389, 29044, 31261, 32768, 0], | ||
| 4362 | + [19027, 26731, 30087, 32768, 0], | ||
| 4363 | + [14739, 23755, 28624, 32768, 0], | ||
| 4364 | + [11358, 20778, 25511, 32768, 0], | ||
| 4365 | + [10995, 18073, 24190, 32768, 0], | ||
| 4366 | + [9162, 14990, 20617, 32768, 0], | ||
| 4367 | +]; | ||
| 4368 | + | ||
| 4369 | +/// `Default_Intra_Ext_Tx_Cdf`'s `TX_SET_INTRA_1` row for `TX_4X4` (spec | ||
| 4370 | +/// 9.4): the transform type of an intra 4x4 transform when `reduced_tx_set` | ||
| 4371 | +/// is false. Same `Luma8`/`Luma8Set1` split as [`INTRA_TX_TYPE_SET1_8`], | ||
| 4372 | +/// kept named for the day a non-reduced path exists. | ||
| 4373 | +pub const INTRA_TX_TYPE_SET1_4: [[u16; 8]; 13] = [ | ||
| 4374 | + [1535, 8035, 9461, 12751, 23467, 27825, 32768, 0], | ||
| 4375 | + [564, 3335, 9709, 10870, 18143, 28094, 32768, 0], | ||
| 4376 | + [672, 3247, 3676, 11982, 19415, 23127, 32768, 0], | ||
| 4377 | + [5279, 13885, 15487, 18044, 23527, 30252, 32768, 0], | ||
| 4378 | + [4423, 6074, 7985, 10416, 25693, 29298, 32768, 0], | ||
| 4379 | + [1486, 4241, 9460, 10662, 16456, 27694, 32768, 0], | ||
| 4380 | + [439, 2838, 3522, 6737, 18058, 23754, 32768, 0], | ||
| 4381 | + [1190, 4233, 4855, 11670, 20281, 24377, 32768, 0], | ||
| 4382 | + [1045, 4312, 8647, 10159, 18644, 29335, 32768, 0], | ||
| 4383 | + [202, 3734, 4747, 7298, 17127, 24016, 32768, 0], | ||
| 4384 | + [447, 4312, 6819, 8884, 16010, 23858, 32768, 0], | ||
| 4385 | + [277, 4369, 5255, 8905, 16465, 22271, 32768, 0], | ||
| 4386 | + [3409, 5436, 10599, 15599, 19687, 24040, 32768, 0], | ||
| 4387 | +]; | ||
crates/ec-av1/src/cdf_state.rsmodified+143 -0
| @@ -55,6 +55,14 @@ pub(crate) enum TxbSet { | |||
| 55 | /// adapted table from the 16x16 and 32x32 sizes' own entries in the same | 55 | /// adapted table from the 16x16 and 32x32 sizes' own entries in the same |
| 56 | /// set, per `entropymode.c`). | 56 | /// set, per `entropymode.c`). |
| 57 | Luma8Inter, | 57 | Luma8Inter, |
| 58 | + /// The 4x4 luma transform of a `TxMode::Select` 8x8 leaf or 16x16 block | ||
| 59 | + /// whose `tx_depth` resolves all the way down (lane-av1tx4). An | ||
| 60 | + /// `is_inter` block has no writer path yet, so this crate has no | ||
| 61 | + /// `Luma4Inter` counterpart to [`Luma8Inter`](TxbSet::Luma8Inter). | ||
| 62 | + Luma4, | ||
| 63 | + /// [`Luma4`](TxbSet::Luma4)'s `reduced_tx_set: false` counterpart, same | ||
| 64 | + /// split as [`Luma8Set1`](TxbSet::Luma8Set1). | ||
| 65 | + Luma4Set1, | ||
| 58 | /// The 8x8 transform of a chroma plane of a 16x16 block. | 66 | /// The 8x8 transform of a chroma plane of a 16x16 block. |
| 59 | Chroma8, | 67 | Chroma8, |
| 60 | /// The 4x4 transform of a chroma plane of an 8x8 leaf (lane-av1-rect). | 68 | /// The 4x4 transform of a chroma plane of an 8x8 leaf (lane-av1-rect). |
| @@ -82,6 +90,11 @@ pub(crate) struct TxbTables<'a> { | |||
| 82 | pub txb_skip: &'a mut [[u16; 3]], | 90 | pub txb_skip: &'a mut [[u16; 3]], |
| 83 | /// The end-of-block group, whose alphabet the transform size sets. | 91 | /// The end-of-block group, whose alphabet the transform size sets. |
| 84 | pub eob_pt: &'a mut [u16], | 92 | pub eob_pt: &'a mut [u16], |
| 93 | + /// `eob_pt`'s `TX_CLASS_HORIZ`/`TX_CLASS_VERT` sibling table (r5): read | ||
| 94 | + /// instead of `eob_pt` once this TU's `tx_type` is known to be | ||
| 95 | + /// `V_DCT`/`H_DCT`. `None` for any size/set whose `tx_type` alphabet | ||
| 96 | + /// cannot produce those two symbols (chroma, and every inter set). | ||
| 97 | + pub eob_pt_class1: Option<&'a mut [u16]>, | ||
| 85 | /// The top bit of the offset inside that group. | 98 | /// The top bit of the offset inside that group. |
| 86 | pub eob_extra: &'a mut [[u16; 3]; 9], | 99 | pub eob_extra: &'a mut [[u16; 3]; 9], |
| 87 | /// A coefficient's base level. | 100 | /// A coefficient's base level. |
| @@ -128,6 +141,8 @@ pub(crate) struct Cdfs { | |||
| 128 | pub txb_skip_luma_16: [[u16; 3]; 7], | 141 | pub txb_skip_luma_16: [[u16; 3]; 7], |
| 129 | /// The same, for an 8x8 luma transform. | 142 | /// The same, for an 8x8 luma transform. |
| 130 | pub txb_skip_luma_8: [[u16; 3]; 7], | 143 | pub txb_skip_luma_8: [[u16; 3]; 7], |
| 144 | + /// The same, for a 4x4 luma transform (lane-av1tx4). | ||
| 145 | + pub txb_skip_luma_4: [[u16; 3]; 7], | ||
| 131 | /// The all-zero flag of an 8x8 chroma transform. | 146 | /// The all-zero flag of an 8x8 chroma transform. |
| 132 | pub txb_skip_chroma_8: [[u16; 3]; 3], | 147 | pub txb_skip_chroma_8: [[u16; 3]; 3], |
| 133 | /// The all-zero flag of a 4x4 chroma transform. | 148 | /// The all-zero flag of a 4x4 chroma transform. |
| @@ -140,10 +155,19 @@ pub(crate) struct Cdfs { | |||
| 140 | pub eob_pt_64_chroma: [u16; 8], | 155 | pub eob_pt_64_chroma: [u16; 8], |
| 141 | /// The end-of-block group of a 4x4 chroma transform. | 156 | /// The end-of-block group of a 4x4 chroma transform. |
| 142 | pub eob_pt_16_chroma: [u16; 6], | 157 | pub eob_pt_16_chroma: [u16; 6], |
| 158 | + /// The end-of-block group of a 4x4 luma transform (lane-av1tx4). | ||
| 159 | + pub eob_pt_16_luma: [u16; 6], | ||
| 160 | + /// `eob_pt_16_luma`'s `TX_CLASS_HORIZ`/`TX_CLASS_VERT` sibling, read | ||
| 161 | + /// instead whenever the TU's `tx_type` is `V_DCT`/`H_DCT` (r5). | ||
| 162 | + pub eob_pt_16_luma_class1: [u16; 6], | ||
| 163 | + /// `eob_pt_64_luma`'s class-1 sibling (r5), see `eob_pt_16_luma_class1`. | ||
| 164 | + pub eob_pt_64_luma_class1: [u16; 8], | ||
| 143 | /// The end-of-block offset bit of a 16x16 luma transform. | 165 | /// The end-of-block offset bit of a 16x16 luma transform. |
| 144 | pub eob_extra_luma_16: [[u16; 3]; 9], | 166 | pub eob_extra_luma_16: [[u16; 3]; 9], |
| 145 | /// The same, for an 8x8 luma transform. | 167 | /// The same, for an 8x8 luma transform. |
| 146 | pub eob_extra_luma_8: [[u16; 3]; 9], | 168 | pub eob_extra_luma_8: [[u16; 3]; 9], |
| 169 | + /// The same, for a 4x4 luma transform. | ||
| 170 | + pub eob_extra_luma_4: [[u16; 3]; 9], | ||
| 147 | /// The same, for an 8x8 chroma transform. | 171 | /// The same, for an 8x8 chroma transform. |
| 148 | pub eob_extra_chroma_8: [[u16; 3]; 9], | 172 | pub eob_extra_chroma_8: [[u16; 3]; 9], |
| 149 | /// The same, for a 4x4 chroma transform. | 173 | /// The same, for a 4x4 chroma transform. |
| @@ -152,6 +176,8 @@ pub(crate) struct Cdfs { | |||
| 152 | pub base_luma_16: [[u16; 5]; 42], | 176 | pub base_luma_16: [[u16; 5]; 42], |
| 153 | /// The base level of an 8x8 luma coefficient. | 177 | /// The base level of an 8x8 luma coefficient. |
| 154 | pub base_luma_8: [[u16; 5]; 42], | 178 | pub base_luma_8: [[u16; 5]; 42], |
| 179 | + /// The base level of a 4x4 luma coefficient. | ||
| 180 | + pub base_luma_4: [[u16; 5]; 42], | ||
| 155 | /// The base level of an 8x8 chroma coefficient. | 181 | /// The base level of an 8x8 chroma coefficient. |
| 156 | pub base_chroma_8: [[u16; 5]; 42], | 182 | pub base_chroma_8: [[u16; 5]; 42], |
| 157 | /// The base level of a 4x4 chroma coefficient. | 183 | /// The base level of a 4x4 chroma coefficient. |
| @@ -160,6 +186,8 @@ pub(crate) struct Cdfs { | |||
| 160 | pub base_eob_luma_16: [[u16; 4]; 4], | 186 | pub base_eob_luma_16: [[u16; 4]; 4], |
| 161 | /// The same, for an 8x8 luma transform. | 187 | /// The same, for an 8x8 luma transform. |
| 162 | pub base_eob_luma_8: [[u16; 4]; 4], | 188 | pub base_eob_luma_8: [[u16; 4]; 4], |
| 189 | + /// The same, for a 4x4 luma transform. | ||
| 190 | + pub base_eob_luma_4: [[u16; 4]; 4], | ||
| 163 | /// The same, for an 8x8 chroma transform. | 191 | /// The same, for an 8x8 chroma transform. |
| 164 | pub base_eob_chroma_8: [[u16; 4]; 4], | 192 | pub base_eob_chroma_8: [[u16; 4]; 4], |
| 165 | /// The same, for a 4x4 chroma transform. | 193 | /// The same, for a 4x4 chroma transform. |
| @@ -168,6 +196,8 @@ pub(crate) struct Cdfs { | |||
| 168 | pub br_luma_16: [[u16; 5]; 21], | 196 | pub br_luma_16: [[u16; 5]; 21], |
| 169 | /// The base-range tail of an 8x8 luma coefficient. | 197 | /// The base-range tail of an 8x8 luma coefficient. |
| 170 | pub br_luma_8: [[u16; 5]; 21], | 198 | pub br_luma_8: [[u16; 5]; 21], |
| 199 | + /// The base-range tail of a 4x4 luma coefficient. | ||
| 200 | + pub br_luma_4: [[u16; 5]; 21], | ||
| 171 | /// The base-range tail of an 8x8 chroma coefficient. | 201 | /// The base-range tail of an 8x8 chroma coefficient. |
| 172 | pub br_chroma_8: [[u16; 5]; 21], | 202 | pub br_chroma_8: [[u16; 5]; 21], |
| 173 | /// The base-range tail of a 4x4 chroma coefficient. | 203 | /// The base-range tail of a 4x4 chroma coefficient. |
| @@ -236,6 +266,15 @@ pub(crate) struct Cdfs { | |||
| 236 | /// `reduced_tx_set` off desyncs an 8x8 TU read against this row's | 266 | /// `reduced_tx_set` off desyncs an 8x8 TU read against this row's |
| 237 | /// wrong-length CDF). | 267 | /// wrong-length CDF). |
| 238 | pub intra_tx_type_8_set1: [[u16; 8]; 13], | 268 | pub intra_tx_type_8_set1: [[u16; 8]; 13], |
| 269 | + /// The transform type of a 4x4 intra luma transform, by luma mode | ||
| 270 | + /// (lane-av1tx4): the flat five-symbol `reduced_tx_set` row, byte- | ||
| 271 | + /// identical to [`Self::intra_tx_type_8`]'s own table | ||
| 272 | + /// ([`cdf::INTRA_TX_TYPE_SET2_8`]) -- libaom leaves `TX_4X4` at the same | ||
| 273 | + /// uniform default. | ||
| 274 | + pub intra_tx_type_4: [[u16; 6]; 13], | ||
| 275 | + /// [`Self::intra_tx_type_4`]'s `reduced_tx_set: false` counterpart, same | ||
| 276 | + /// split as [`Self::intra_tx_type_8_set1`]. | ||
| 277 | + pub intra_tx_type_4_set1: [[u16; 8]; 13], | ||
| 239 | /// The transform type of an `is_inter` 32x32 luma transform (spec | 278 | /// The transform type of an `is_inter` 32x32 luma transform (spec |
| 240 | /// `TX_SET_INTER_3`, `TX_32X32` row) -- unlike the intra 16x16 table, it | 279 | /// `TX_SET_INTER_3`, `TX_32X32` row) -- unlike the intra 16x16 table, it |
| 241 | /// is not indexed by mode. | 280 | /// is not indexed by mode. |
| @@ -395,26 +434,34 @@ impl Cdfs { | |||
| 395 | reset2(&mut self.angle_delta); | 434 | reset2(&mut self.angle_delta); |
| 396 | reset2(&mut self.txb_skip_luma_16); | 435 | reset2(&mut self.txb_skip_luma_16); |
| 397 | reset2(&mut self.txb_skip_luma_8); | 436 | reset2(&mut self.txb_skip_luma_8); |
| 437 | + reset2(&mut self.txb_skip_luma_4); | ||
| 398 | reset2(&mut self.txb_skip_chroma_8); | 438 | reset2(&mut self.txb_skip_chroma_8); |
| 399 | reset2(&mut self.txb_skip_chroma_4); | 439 | reset2(&mut self.txb_skip_chroma_4); |
| 400 | reset1(&mut self.eob_pt_256_luma); | 440 | reset1(&mut self.eob_pt_256_luma); |
| 401 | reset1(&mut self.eob_pt_64_luma); | 441 | reset1(&mut self.eob_pt_64_luma); |
| 402 | reset1(&mut self.eob_pt_64_chroma); | 442 | reset1(&mut self.eob_pt_64_chroma); |
| 403 | reset1(&mut self.eob_pt_16_chroma); | 443 | reset1(&mut self.eob_pt_16_chroma); |
| 444 | + reset1(&mut self.eob_pt_16_luma); | ||
| 445 | + reset1(&mut self.eob_pt_16_luma_class1); | ||
| 446 | + reset1(&mut self.eob_pt_64_luma_class1); | ||
| 404 | reset2(&mut self.eob_extra_luma_16); | 447 | reset2(&mut self.eob_extra_luma_16); |
| 405 | reset2(&mut self.eob_extra_luma_8); | 448 | reset2(&mut self.eob_extra_luma_8); |
| 449 | + reset2(&mut self.eob_extra_luma_4); | ||
| 406 | reset2(&mut self.eob_extra_chroma_8); | 450 | reset2(&mut self.eob_extra_chroma_8); |
| 407 | reset2(&mut self.eob_extra_chroma_4); | 451 | reset2(&mut self.eob_extra_chroma_4); |
| 408 | reset2(&mut self.base_luma_16); | 452 | reset2(&mut self.base_luma_16); |
| 409 | reset2(&mut self.base_luma_8); | 453 | reset2(&mut self.base_luma_8); |
| 454 | + reset2(&mut self.base_luma_4); | ||
| 410 | reset2(&mut self.base_chroma_8); | 455 | reset2(&mut self.base_chroma_8); |
| 411 | reset2(&mut self.base_chroma_4); | 456 | reset2(&mut self.base_chroma_4); |
| 412 | reset2(&mut self.base_eob_luma_16); | 457 | reset2(&mut self.base_eob_luma_16); |
| 413 | reset2(&mut self.base_eob_luma_8); | 458 | reset2(&mut self.base_eob_luma_8); |
| 459 | + reset2(&mut self.base_eob_luma_4); | ||
| 414 | reset2(&mut self.base_eob_chroma_8); | 460 | reset2(&mut self.base_eob_chroma_8); |
| 415 | reset2(&mut self.base_eob_chroma_4); | 461 | reset2(&mut self.base_eob_chroma_4); |
| 416 | reset2(&mut self.br_luma_16); | 462 | reset2(&mut self.br_luma_16); |
| 417 | reset2(&mut self.br_luma_8); | 463 | reset2(&mut self.br_luma_8); |
| 464 | + reset2(&mut self.br_luma_4); | ||
| 418 | reset2(&mut self.br_chroma_8); | 465 | reset2(&mut self.br_chroma_8); |
| 419 | reset2(&mut self.br_chroma_4); | 466 | reset2(&mut self.br_chroma_4); |
| 420 | reset2(&mut self.partition_w16); | 467 | reset2(&mut self.partition_w16); |
| @@ -445,6 +492,8 @@ impl Cdfs { | |||
| 445 | reset2(&mut self.intra_tx_type_16); | 492 | reset2(&mut self.intra_tx_type_16); |
| 446 | reset2(&mut self.intra_tx_type_8); | 493 | reset2(&mut self.intra_tx_type_8); |
| 447 | reset2(&mut self.intra_tx_type_8_set1); | 494 | reset2(&mut self.intra_tx_type_8_set1); |
| 495 | + reset2(&mut self.intra_tx_type_4); | ||
| 496 | + reset2(&mut self.intra_tx_type_4_set1); | ||
| 448 | reset1(&mut self.inter_tx_type_32); | 497 | reset1(&mut self.inter_tx_type_32); |
| 449 | reset1(&mut self.inter_tx_type_16); | 498 | reset1(&mut self.inter_tx_type_16); |
| 450 | reset1(&mut self.inter_tx_type_8); | 499 | reset1(&mut self.inter_tx_type_8); |
| @@ -497,6 +546,13 @@ impl Cdfs { | |||
| 497 | cdf::TXB_SKIP_LUMA_8_CTX, | 546 | cdf::TXB_SKIP_LUMA_8_CTX, |
| 498 | cdf::TXB_SKIP_LUMA_8_Q3_CTX, | 547 | cdf::TXB_SKIP_LUMA_8_Q3_CTX, |
| 499 | ), | 548 | ), |
| 549 | + txb_skip_luma_4: pick( | ||
| 550 | + q_ctx, | ||
| 551 | + cdf::TXB_SKIP_LUMA_4_Q0_CTX, | ||
| 552 | + cdf::TXB_SKIP_LUMA_4_Q1_CTX, | ||
| 553 | + cdf::TXB_SKIP_LUMA_4_CTX, | ||
| 554 | + cdf::TXB_SKIP_LUMA_4_Q3_CTX, | ||
| 555 | + ), | ||
| 500 | txb_skip_chroma_8: pick( | 556 | txb_skip_chroma_8: pick( |
| 501 | q_ctx, | 557 | q_ctx, |
| 502 | cdf::TXB_SKIP_CHROMA_8_Q0, | 558 | cdf::TXB_SKIP_CHROMA_8_Q0, |
| @@ -539,6 +595,27 @@ impl Cdfs { | |||
| 539 | cdf::EOB_PT_16_CHROMA, | 595 | cdf::EOB_PT_16_CHROMA, |
| 540 | cdf::EOB_PT_16_CHROMA_Q3, | 596 | cdf::EOB_PT_16_CHROMA_Q3, |
| 541 | ), | 597 | ), |
| 598 | + eob_pt_16_luma: pick( | ||
| 599 | + q_ctx, | ||
| 600 | + cdf::EOB_PT_16_LUMA_Q0, | ||
| 601 | + cdf::EOB_PT_16_LUMA_Q1, | ||
| 602 | + cdf::EOB_PT_16_LUMA, | ||
| 603 | + cdf::EOB_PT_16_LUMA_Q3, | ||
| 604 | + ), | ||
| 605 | + eob_pt_16_luma_class1: pick( | ||
| 606 | + q_ctx, | ||
| 607 | + cdf::EOB_PT_16_LUMA_CLASS1_Q0, | ||
| 608 | + cdf::EOB_PT_16_LUMA_CLASS1_Q1, | ||
| 609 | + cdf::EOB_PT_16_LUMA_CLASS1, | ||
| 610 | + cdf::EOB_PT_16_LUMA_CLASS1_Q3, | ||
| 611 | + ), | ||
| 612 | + eob_pt_64_luma_class1: pick( | ||
| 613 | + q_ctx, | ||
| 614 | + cdf::EOB_PT_64_LUMA_CLASS1_Q0, | ||
| 615 | + cdf::EOB_PT_64_LUMA_CLASS1_Q1, | ||
| 616 | + cdf::EOB_PT_64_LUMA_CLASS1, | ||
| 617 | + cdf::EOB_PT_64_LUMA_CLASS1_Q3, | ||
| 618 | + ), | ||
| 542 | eob_extra_luma_16: pick( | 619 | eob_extra_luma_16: pick( |
| 543 | q_ctx, | 620 | q_ctx, |
| 544 | cdf::EOB_EXTRA_LUMA_16_Q0, | 621 | cdf::EOB_EXTRA_LUMA_16_Q0, |
| @@ -553,6 +630,13 @@ impl Cdfs { | |||
| 553 | cdf::EOB_EXTRA_LUMA_8, | 630 | cdf::EOB_EXTRA_LUMA_8, |
| 554 | cdf::EOB_EXTRA_LUMA_8_Q3, | 631 | cdf::EOB_EXTRA_LUMA_8_Q3, |
| 555 | ), | 632 | ), |
| 633 | + eob_extra_luma_4: pick( | ||
| 634 | + q_ctx, | ||
| 635 | + cdf::EOB_EXTRA_LUMA_4_Q0, | ||
| 636 | + cdf::EOB_EXTRA_LUMA_4_Q1, | ||
| 637 | + cdf::EOB_EXTRA_LUMA_4, | ||
| 638 | + cdf::EOB_EXTRA_LUMA_4_Q3, | ||
| 639 | + ), | ||
| 556 | eob_extra_chroma_8: pick( | 640 | eob_extra_chroma_8: pick( |
| 557 | q_ctx, | 641 | q_ctx, |
| 558 | cdf::EOB_EXTRA_CHROMA_8_Q0, | 642 | cdf::EOB_EXTRA_CHROMA_8_Q0, |
| @@ -581,6 +665,13 @@ impl Cdfs { | |||
| 581 | cdf::COEFF_BASE_LUMA_8, | 665 | cdf::COEFF_BASE_LUMA_8, |
| 582 | cdf::COEFF_BASE_LUMA_8_Q3, | 666 | cdf::COEFF_BASE_LUMA_8_Q3, |
| 583 | ), | 667 | ), |
| 668 | + base_luma_4: pick( | ||
| 669 | + q_ctx, | ||
| 670 | + cdf::COEFF_BASE_LUMA_4_Q0, | ||
| 671 | + cdf::COEFF_BASE_LUMA_4_Q1, | ||
| 672 | + cdf::COEFF_BASE_LUMA_4, | ||
| 673 | + cdf::COEFF_BASE_LUMA_4_Q3, | ||
| 674 | + ), | ||
| 584 | base_chroma_8: pick( | 675 | base_chroma_8: pick( |
| 585 | q_ctx, | 676 | q_ctx, |
| 586 | cdf::COEFF_BASE_CHROMA_8_Q0, | 677 | cdf::COEFF_BASE_CHROMA_8_Q0, |
| @@ -609,6 +700,13 @@ impl Cdfs { | |||
| 609 | cdf::COEFF_BASE_EOB_LUMA_8, | 700 | cdf::COEFF_BASE_EOB_LUMA_8, |
| 610 | cdf::COEFF_BASE_EOB_LUMA_8_Q3, | 701 | cdf::COEFF_BASE_EOB_LUMA_8_Q3, |
| 611 | ), | 702 | ), |
| 703 | + base_eob_luma_4: pick( | ||
| 704 | + q_ctx, | ||
| 705 | + cdf::COEFF_BASE_EOB_LUMA_4_Q0, | ||
| 706 | + cdf::COEFF_BASE_EOB_LUMA_4_Q1, | ||
| 707 | + cdf::COEFF_BASE_EOB_LUMA_4, | ||
| 708 | + cdf::COEFF_BASE_EOB_LUMA_4_Q3, | ||
| 709 | + ), | ||
| 612 | base_eob_chroma_8: pick( | 710 | base_eob_chroma_8: pick( |
| 613 | q_ctx, | 711 | q_ctx, |
| 614 | cdf::COEFF_BASE_EOB_CHROMA_8_Q0, | 712 | cdf::COEFF_BASE_EOB_CHROMA_8_Q0, |
| @@ -637,6 +735,13 @@ impl Cdfs { | |||
| 637 | cdf::COEFF_BR_LUMA_8, | 735 | cdf::COEFF_BR_LUMA_8, |
| 638 | cdf::COEFF_BR_LUMA_8_Q3, | 736 | cdf::COEFF_BR_LUMA_8_Q3, |
| 639 | ), | 737 | ), |
| 738 | + br_luma_4: pick( | ||
| 739 | + q_ctx, | ||
| 740 | + cdf::COEFF_BR_LUMA_4_Q0, | ||
| 741 | + cdf::COEFF_BR_LUMA_4_Q1, | ||
| 742 | + cdf::COEFF_BR_LUMA_4, | ||
| 743 | + cdf::COEFF_BR_LUMA_4_Q3, | ||
| 744 | + ), | ||
| 640 | br_chroma_8: pick( | 745 | br_chroma_8: pick( |
| 641 | q_ctx, | 746 | q_ctx, |
| 642 | cdf::COEFF_BR_CHROMA_8_Q0, | 747 | cdf::COEFF_BR_CHROMA_8_Q0, |
| @@ -811,6 +916,8 @@ impl Cdfs { | |||
| 811 | intra_tx_type_16: cdf::INTRA_TX_TYPE_SET2_16, | 916 | intra_tx_type_16: cdf::INTRA_TX_TYPE_SET2_16, |
| 812 | intra_tx_type_8: cdf::INTRA_TX_TYPE_SET2_8, | 917 | intra_tx_type_8: cdf::INTRA_TX_TYPE_SET2_8, |
| 813 | intra_tx_type_8_set1: cdf::INTRA_TX_TYPE_SET1_8, | 918 | intra_tx_type_8_set1: cdf::INTRA_TX_TYPE_SET1_8, |
| 919 | + intra_tx_type_4: cdf::INTRA_TX_TYPE_SET2_8, | ||
| 920 | + intra_tx_type_4_set1: cdf::INTRA_TX_TYPE_SET1_4, | ||
| 814 | inter_tx_type_32: cdf::INTER_TX_TYPE_SET3_32, | 921 | inter_tx_type_32: cdf::INTER_TX_TYPE_SET3_32, |
| 815 | inter_tx_type_16: cdf::INTER_TX_TYPE_SET3_16, | 922 | inter_tx_type_16: cdf::INTER_TX_TYPE_SET3_16, |
| 816 | inter_tx_type_8: cdf::INTER_TX_TYPE_SET3_8, | 923 | inter_tx_type_8: cdf::INTER_TX_TYPE_SET3_8, |
| @@ -847,6 +954,7 @@ impl Cdfs { | |||
| 847 | br: &mut self.br_luma_32, | 954 | br: &mut self.br_luma_32, |
| 848 | dc_sign: &mut self.dc_sign_luma, | 955 | dc_sign: &mut self.dc_sign_luma, |
| 849 | tx_type: None, | 956 | tx_type: None, |
| 957 | + eob_pt_class1: None, | ||
| 850 | }, | 958 | }, |
| 851 | TxbSet::Luma32Inter => TxbTables { | 959 | TxbSet::Luma32Inter => TxbTables { |
| 852 | side: 32, | 960 | side: 32, |
| @@ -858,6 +966,7 @@ impl Cdfs { | |||
| 858 | br: &mut self.br_luma_32, | 966 | br: &mut self.br_luma_32, |
| 859 | dc_sign: &mut self.dc_sign_luma, | 967 | dc_sign: &mut self.dc_sign_luma, |
| 860 | tx_type: Some(self.inter_tx_type_32.as_mut_slice()), | 968 | tx_type: Some(self.inter_tx_type_32.as_mut_slice()), |
| 969 | + eob_pt_class1: None, | ||
| 861 | }, | 970 | }, |
| 862 | TxbSet::Luma64 => TxbTables { | 971 | TxbSet::Luma64 => TxbTables { |
| 863 | side: 32, | 972 | side: 32, |
| @@ -869,6 +978,7 @@ impl Cdfs { | |||
| 869 | br: &mut self.br_luma_32, | 978 | br: &mut self.br_luma_32, |
| 870 | dc_sign: &mut self.dc_sign_luma, | 979 | dc_sign: &mut self.dc_sign_luma, |
| 871 | tx_type: None, | 980 | tx_type: None, |
| 981 | + eob_pt_class1: None, | ||
| 872 | }, | 982 | }, |
| 873 | TxbSet::Luma16 => TxbTables { | 983 | TxbSet::Luma16 => TxbTables { |
| 874 | side: 16, | 984 | side: 16, |
| @@ -880,6 +990,7 @@ impl Cdfs { | |||
| 880 | br: &mut self.br_luma_16, | 990 | br: &mut self.br_luma_16, |
| 881 | dc_sign: &mut self.dc_sign_luma, | 991 | dc_sign: &mut self.dc_sign_luma, |
| 882 | tx_type: Some(self.intra_tx_type_16[mode].as_mut_slice()), | 992 | tx_type: Some(self.intra_tx_type_16[mode].as_mut_slice()), |
| 993 | + eob_pt_class1: None, | ||
| 883 | }, | 994 | }, |
| 884 | TxbSet::Luma16Inter => TxbTables { | 995 | TxbSet::Luma16Inter => TxbTables { |
| 885 | side: 16, | 996 | side: 16, |
| @@ -891,6 +1002,7 @@ impl Cdfs { | |||
| 891 | br: &mut self.br_luma_16, | 1002 | br: &mut self.br_luma_16, |
| 892 | dc_sign: &mut self.dc_sign_luma, | 1003 | dc_sign: &mut self.dc_sign_luma, |
| 893 | tx_type: Some(self.inter_tx_type_16.as_mut_slice()), | 1004 | tx_type: Some(self.inter_tx_type_16.as_mut_slice()), |
| 1005 | + eob_pt_class1: None, | ||
| 894 | }, | 1006 | }, |
| 895 | TxbSet::Luma8 => TxbTables { | 1007 | TxbSet::Luma8 => TxbTables { |
| 896 | side: 8, | 1008 | side: 8, |
| @@ -902,6 +1014,7 @@ impl Cdfs { | |||
| 902 | br: &mut self.br_luma_8, | 1014 | br: &mut self.br_luma_8, |
| 903 | dc_sign: &mut self.dc_sign_luma, | 1015 | dc_sign: &mut self.dc_sign_luma, |
| 904 | tx_type: Some(self.intra_tx_type_8[mode].as_mut_slice()), | 1016 | tx_type: Some(self.intra_tx_type_8[mode].as_mut_slice()), |
| 1017 | + eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), | ||
| 905 | }, | 1018 | }, |
| 906 | TxbSet::Luma8Set1 => TxbTables { | 1019 | TxbSet::Luma8Set1 => TxbTables { |
| 907 | side: 8, | 1020 | side: 8, |
| @@ -913,6 +1026,31 @@ impl Cdfs { | |||
| 913 | br: &mut self.br_luma_8, | 1026 | br: &mut self.br_luma_8, |
| 914 | dc_sign: &mut self.dc_sign_luma, | 1027 | dc_sign: &mut self.dc_sign_luma, |
| 915 | tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()), | 1028 | tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()), |
| 1029 | + eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), | ||
| 1030 | + }, | ||
| 1031 | + TxbSet::Luma4 => TxbTables { | ||
| 1032 | + side: 4, | ||
| 1033 | + txb_skip: &mut self.txb_skip_luma_4, | ||
| 1034 | + eob_pt: &mut self.eob_pt_16_luma, | ||
| 1035 | + eob_extra: &mut self.eob_extra_luma_4, | ||
| 1036 | + base: &mut self.base_luma_4, | ||
| 1037 | + base_eob: &mut self.base_eob_luma_4, | ||
| 1038 | + br: &mut self.br_luma_4, | ||
| 1039 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1040 | + tx_type: Some(self.intra_tx_type_4[mode].as_mut_slice()), | ||
| 1041 | + eob_pt_class1: Some(&mut self.eob_pt_16_luma_class1), | ||
| 1042 | + }, | ||
| 1043 | + TxbSet::Luma4Set1 => TxbTables { | ||
| 1044 | + side: 4, | ||
| 1045 | + txb_skip: &mut self.txb_skip_luma_4, | ||
| 1046 | + eob_pt: &mut self.eob_pt_16_luma, | ||
| 1047 | + eob_extra: &mut self.eob_extra_luma_4, | ||
| 1048 | + base: &mut self.base_luma_4, | ||
| 1049 | + base_eob: &mut self.base_eob_luma_4, | ||
| 1050 | + br: &mut self.br_luma_4, | ||
| 1051 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1052 | + tx_type: Some(self.intra_tx_type_4_set1[mode].as_mut_slice()), | ||
| 1053 | + eob_pt_class1: Some(&mut self.eob_pt_16_luma_class1), | ||
| 916 | }, | 1054 | }, |
| 917 | TxbSet::Luma8Inter => TxbTables { | 1055 | TxbSet::Luma8Inter => TxbTables { |
| 918 | side: 8, | 1056 | side: 8, |
| @@ -924,6 +1062,7 @@ impl Cdfs { | |||
| 924 | br: &mut self.br_luma_8, | 1062 | br: &mut self.br_luma_8, |
| 925 | dc_sign: &mut self.dc_sign_luma, | 1063 | dc_sign: &mut self.dc_sign_luma, |
| 926 | tx_type: Some(self.inter_tx_type_8.as_mut_slice()), | 1064 | tx_type: Some(self.inter_tx_type_8.as_mut_slice()), |
| 1065 | + eob_pt_class1: None, | ||
| 927 | }, | 1066 | }, |
| 928 | TxbSet::Chroma8 => TxbTables { | 1067 | TxbSet::Chroma8 => TxbTables { |
| 929 | side: 8, | 1068 | side: 8, |
| @@ -935,6 +1074,7 @@ impl Cdfs { | |||
| 935 | br: &mut self.br_chroma_8, | 1074 | br: &mut self.br_chroma_8, |
| 936 | dc_sign: &mut self.dc_sign_chroma, | 1075 | dc_sign: &mut self.dc_sign_chroma, |
| 937 | tx_type: None, | 1076 | tx_type: None, |
| 1077 | + eob_pt_class1: None, | ||
| 938 | }, | 1078 | }, |
| 939 | TxbSet::Chroma4 => TxbTables { | 1079 | TxbSet::Chroma4 => TxbTables { |
| 940 | side: 4, | 1080 | side: 4, |
| @@ -946,6 +1086,7 @@ impl Cdfs { | |||
| 946 | br: &mut self.br_chroma_4, | 1086 | br: &mut self.br_chroma_4, |
| 947 | dc_sign: &mut self.dc_sign_chroma, | 1087 | dc_sign: &mut self.dc_sign_chroma, |
| 948 | tx_type: None, | 1088 | tx_type: None, |
| 1089 | + eob_pt_class1: None, | ||
| 949 | }, | 1090 | }, |
| 950 | TxbSet::Chroma16 => TxbTables { | 1091 | TxbSet::Chroma16 => TxbTables { |
| 951 | side: 16, | 1092 | side: 16, |
| @@ -957,6 +1098,7 @@ impl Cdfs { | |||
| 957 | br: &mut self.br_chroma_16, | 1098 | br: &mut self.br_chroma_16, |
| 958 | dc_sign: &mut self.dc_sign_chroma, | 1099 | dc_sign: &mut self.dc_sign_chroma, |
| 959 | tx_type: None, | 1100 | tx_type: None, |
| 1101 | + eob_pt_class1: None, | ||
| 960 | }, | 1102 | }, |
| 961 | TxbSet::Chroma32 => TxbTables { | 1103 | TxbSet::Chroma32 => TxbTables { |
| 962 | side: 32, | 1104 | side: 32, |
| @@ -968,6 +1110,7 @@ impl Cdfs { | |||
| 968 | br: &mut self.br_chroma_32, | 1110 | br: &mut self.br_chroma_32, |
| 969 | dc_sign: &mut self.dc_sign_chroma, | 1111 | dc_sign: &mut self.dc_sign_chroma, |
| 970 | tx_type: None, | 1112 | tx_type: None, |
| 1113 | + eob_pt_class1: None, | ||
| 971 | }, | 1114 | }, |
| 972 | } | 1115 | } |
| 973 | } | 1116 | } |
crates/ec-av1/src/decode.rsmodified+308 -48
| @@ -74,6 +74,19 @@ static TX_DEPTH_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::Atomic | |||
| 74 | pub(crate) fn tx_depth_hits() -> usize { | 74 | pub(crate) fn tx_depth_hits() -> usize { |
| 75 | TX_DEPTH_HITS.load(std::sync::atomic::Ordering::Relaxed) | 75 | TX_DEPTH_HITS.load(std::sync::atomic::Ordering::Relaxed) |
| 76 | } | 76 | } |
| 77 | + | ||
| 78 | +/// How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D` | ||
| 79 | +/// (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every | ||
| 80 | +/// call in the process -- the same before/after counter pattern as | ||
| 81 | +/// [`TX_DEPTH_HITS`], proving a stream actually exercised the class-split | ||
| 82 | +/// `eob_pt`/1D-neighbour context path rather than every block coincidentally | ||
| 83 | +/// landing on `DCT_DCT`. | ||
| 84 | +static TX_CLASS1_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | ||
| 85 | + | ||
| 86 | +/// Current value of [`TX_CLASS1_HITS`]. | ||
| 87 | +pub(crate) fn tx_class1_hits() -> usize { | ||
| 88 | + TX_CLASS1_HITS.load(std::sync::atomic::Ordering::Relaxed) | ||
| 89 | +} | ||
| 77 | const SUB_MI: u32 = 4; | 90 | const SUB_MI: u32 = 4; |
| 78 | const MI: usize = 4; | 91 | const MI: usize = 4; |
| 79 | const SB: usize = 64; | 92 | const SB: usize = 64; |
| @@ -154,6 +167,26 @@ fn default_scan(side: usize) -> Vec<u16> { | |||
| 154 | scan | 167 | scan |
| 155 | } | 168 | } |
| 156 | 169 | ||
| 170 | +/// `Mrow_Scan`/`Mcol_Scan` (spec 8.4.2, libaom `scan.c`): the two | ||
| 171 | +/// class-specific scans a `V_DCT`/`H_DCT` transform block reads coefficients | ||
| 172 | +/// in, instead of the default zigzag. libaom's own tables are keyed by a | ||
| 173 | +/// *column-major* raster (`get_txb_bhl`'s `col = pos / height`) over its | ||
| 174 | +/// physically column-major level buffer, but they decompose to the exact | ||
| 175 | +/// same (row, col) walk as a flat row-major traversal of *our* row-major | ||
| 176 | +/// `grid`/`levels` (`pos = row * side + col`) once you read them that way: | ||
| 177 | +/// `Mrow_Scan` visits row 0 across every column, then row 1, ... — precisely | ||
| 178 | +/// `0..side*side` in our own indexing — and `Mcol_Scan` is that walk | ||
| 179 | +/// transposed (column 0 down every row, then column 1, ...). | ||
| 180 | +fn class_scan_table(side: usize, class: TxClass) -> Vec<u16> { | ||
| 181 | + match class { | ||
| 182 | + TxClass::Vert => (0..(side * side) as u16).collect(), | ||
| 183 | + TxClass::Horiz => (0..side) | ||
| 184 | + .flat_map(|col| (0..side).map(move |row| (row * side + col) as u16)) | ||
| 185 | + .collect(), | ||
| 186 | + TxClass::TwoD => unreachable!("class_scan is only for V_DCT/H_DCT"), | ||
| 187 | + } | ||
| 188 | +} | ||
| 189 | + | ||
| 157 | fn eob_coeff_ctx(scan_idx: usize, area: usize) -> usize { | 190 | fn eob_coeff_ctx(scan_idx: usize, area: usize) -> usize { |
| 158 | match scan_idx { | 191 | match scan_idx { |
| 159 | 0 => 0, | 192 | 0 => 0, |
| @@ -171,31 +204,87 @@ fn neighbour(grid: &[i32], side: usize, row: usize, col: usize) -> i32 { | |||
| 171 | } | 204 | } |
| 172 | } | 205 | } |
| 173 | 206 | ||
| 174 | -fn base_ctx(grid: &[i32], side: usize, row: usize, col: usize) -> usize { | 207 | +/// spec 5.11.39's three `TxClass`es (`tx_type_to_class`, libaom |
| 175 | - if row == 0 && col == 0 { | 208 | +/// `txb_common.h`): everything but the two lone-axis-identity types this |
| 209 | +/// decoder reads (`V_DCT`/`H_DCT`) is `TX_CLASS_2D`. | ||
| 210 | +#[derive(Clone, Copy, PartialEq, Eq)] | ||
| 211 | +enum TxClass { | ||
| 212 | + TwoD, | ||
| 213 | + Horiz, | ||
| 214 | + Vert, | ||
| 215 | +} | ||
| 216 | + | ||
| 217 | +impl TxClass { | ||
| 218 | + fn of(tx_type: TxType) -> Self { | ||
| 219 | + match tx_type { | ||
| 220 | + TxType::VDct => Self::Vert, | ||
| 221 | + TxType::HDct => Self::Horiz, | ||
| 222 | + _ => Self::TwoD, | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | +} | ||
| 226 | + | ||
| 227 | +/// `nz_map_ctx_offset_1d`: `TX_CLASS_HORIZ`/`TX_CLASS_VERT` share one 32-entry | ||
| 228 | +/// table (indexed by the position along the transform's *coded* axis -- | ||
| 229 | +/// `col` for horiz, `row` for vert) that places their contexts past the 2D | ||
| 230 | +/// table's own 26 rows (`SIG_COEF_CONTEXTS_2D`), 16 rows total | ||
| 231 | +/// (`SIG_COEF_CONTEXTS_1D`) split 26/31/36. | ||
| 232 | +fn nz_map_ctx_offset_1d(i: usize) -> usize { | ||
| 233 | + match i { | ||
| 234 | + 0 => 26, | ||
| 235 | + 1 => 31, | ||
| 236 | + _ => 36, | ||
| 237 | + } | ||
| 238 | +} | ||
| 239 | + | ||
| 240 | +fn base_ctx(grid: &[i32], side: usize, row: usize, col: usize, class: TxClass) -> usize { | ||
| 241 | + // libaom's `get_nz_map_ctx_from_stats` only special-cases the DC | ||
| 242 | + // coefficient to ctx 0 for `TX_CLASS_2D` (`(tx_class | coeff_idx) == 0`, | ||
| 243 | + // txb_common.h) -- `V_DCT`/`H_DCT` (class `Horiz`/`Vert`) still run the DC | ||
| 244 | + // position through the full 1D neighbour sum and offset table. Skipping | ||
| 245 | + // that for every class desynced the last (DC) coefficient of a | ||
| 246 | + // `TX_CLASS_HORIZ` block (lane-av1tx4 final round: real ctx 28 read as | ||
| 247 | + // 0, which then read one extra `BR` symbol at the max and forced a | ||
| 248 | + // spurious third Golomb call). | ||
| 249 | + if class == TxClass::TwoD && row == 0 && col == 0 { | ||
| 176 | return 0; | 250 | return 0; |
| 177 | } | 251 | } |
| 178 | - let mag: i32 = [(1, 0), (0, 1), (1, 1), (2, 0), (0, 2)] | 252 | + let offsets: [(usize, usize); 5] = match class { |
| 253 | + TxClass::TwoD => [(1, 0), (0, 1), (1, 1), (2, 0), (0, 2)], | ||
| 254 | + TxClass::Horiz => [(1, 0), (0, 1), (0, 2), (0, 3), (0, 4)], | ||
| 255 | + TxClass::Vert => [(1, 0), (0, 1), (2, 0), (3, 0), (4, 0)], | ||
| 256 | + }; | ||
| 257 | + let mag: i32 = offsets | ||
| 179 | .iter() | 258 | .iter() |
| 180 | .map(|&(dr, dc)| neighbour(grid, side, row + dr, col + dc).abs().min(3)) | 259 | .map(|&(dr, dc)| neighbour(grid, side, row + dr, col + dc).abs().min(3)) |
| 181 | .sum(); | 260 | .sum(); |
| 182 | - let offset = cdf::NZ_MAP_CTX_OFFSET_32[row.min(4)][col.min(4)] as usize; | 261 | + let ctx = ((mag + 1) >> 1).min(4) as usize; |
| 183 | - (((mag + 1) >> 1).min(4) as usize) + offset | 262 | + match class { |
| 263 | + TxClass::TwoD => ctx + cdf::NZ_MAP_CTX_OFFSET_32[row.min(4)][col.min(4)] as usize, | ||
| 264 | + TxClass::Horiz => ctx + nz_map_ctx_offset_1d(col.min(31)), | ||
| 265 | + TxClass::Vert => ctx + nz_map_ctx_offset_1d(row.min(31)), | ||
| 266 | + } | ||
| 184 | } | 267 | } |
| 185 | 268 | ||
| 186 | -fn br_ctx(grid: &[i32], side: usize, row: usize, col: usize) -> usize { | 269 | +fn br_ctx(grid: &[i32], side: usize, row: usize, col: usize, class: TxClass) -> usize { |
| 187 | - let mag: i32 = [(1, 0), (0, 1), (1, 1)] | 270 | + let extra = match class { |
| 188 | - .iter() | 271 | + TxClass::TwoD => neighbour(grid, side, row + 1, col + 1).abs(), |
| 189 | - .map(|&(dr, dc)| neighbour(grid, side, row + dr, col + dc).abs()) | 272 | + TxClass::Horiz => neighbour(grid, side, row, col + 2).abs(), |
| 190 | - .sum(); | 273 | + TxClass::Vert => neighbour(grid, side, row + 2, col).abs(), |
| 274 | + }; | ||
| 275 | + let mag = neighbour(grid, side, row + 1, col).abs() | ||
| 276 | + + neighbour(grid, side, row, col + 1).abs() | ||
| 277 | + + extra; | ||
| 191 | let mag = (((mag + 1) >> 1).min(6)) as usize; | 278 | let mag = (((mag + 1) >> 1).min(6)) as usize; |
| 192 | if row == 0 && col == 0 { | 279 | if row == 0 && col == 0 { |
| 193 | - mag | 280 | + return mag; |
| 194 | - } else if row < 2 && col < 2 { | ||
| 195 | - mag + 7 | ||
| 196 | - } else { | ||
| 197 | - mag + 14 | ||
| 198 | } | 281 | } |
| 282 | + let near_origin = match class { | ||
| 283 | + TxClass::TwoD => row < 2 && col < 2, | ||
| 284 | + TxClass::Horiz => col == 0, | ||
| 285 | + TxClass::Vert => row == 0, | ||
| 286 | + }; | ||
| 287 | + if near_origin { mag + 7 } else { mag + 14 } | ||
| 199 | } | 288 | } |
| 200 | 289 | ||
| 201 | fn dc_vote(dc: Option<bool>) -> i32 { | 290 | fn dc_vote(dc: Option<bool>) -> i32 { |
| @@ -234,12 +323,22 @@ fn read_golomb(dec: &mut SymbolDecoder) -> Result<u32> { | |||
| 234 | 323 | ||
| 235 | /// `decode_symbol`'s end-of-block position (spec 5.11.39): the inverse of | 324 | /// `decode_symbol`'s end-of-block position (spec 5.11.39): the inverse of |
| 236 | /// [`crate::tile`]'s `write_eob`. | 325 | /// [`crate::tile`]'s `write_eob`. |
| 237 | -fn read_eob(dec: &mut SymbolDecoder, coding: &mut TxbTables) -> usize { | 326 | +fn read_eob(dec: &mut SymbolDecoder, coding: &mut TxbTables, class: TxClass) -> usize { |
| 238 | const GROUP_START: [usize; 12] = [0, 1, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513]; | 327 | const GROUP_START: [usize; 12] = [0, 1, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513]; |
| 239 | const OFFSET_BITS: [u32; 12] = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | 328 | const OFFSET_BITS: [u32; 12] = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
| 240 | 329 | ||
| 241 | let trace = std::env::var_os("EC_AV1_TRACE").is_some(); | 330 | let trace = std::env::var_os("EC_AV1_TRACE").is_some(); |
| 242 | - let group = dec.symbol(coding.eob_pt) + 1; | 331 | + // libaom's `eob_flag_cdf*` tables carry a second dimension the 2D scan |
| 332 | + // never touches: `TX_CLASS_HORIZ`/`TX_CLASS_VERT` (`V_DCT`/`H_DCT`) adapt | ||
| 333 | + // a wholly separate CDF from every other tx_type (`decodetxb.c`'s | ||
| 334 | + // `eob_multi_ctx`). Missing that split desynced the very first | ||
| 335 | + // `V_DCT`/`H_DCT` TU this decoder ever produced (lane-av1tx4 r5, caught | ||
| 336 | + // against a real aomdec trace). | ||
| 337 | + let eob_pt: &mut [u16] = match (class, coding.eob_pt_class1.as_deref_mut()) { | ||
| 338 | + (TxClass::TwoD, _) | (_, None) => coding.eob_pt, | ||
| 339 | + (_, Some(class1)) => class1, | ||
| 340 | + }; | ||
| 341 | + let group = dec.symbol(eob_pt) + 1; | ||
| 243 | if trace { | 342 | if trace { |
| 244 | eprintln!("TRACE eob_pt value={group}"); | 343 | eprintln!("TRACE eob_pt value={group}"); |
| 245 | } | 344 | } |
| @@ -304,10 +403,21 @@ fn read_coeffs( | |||
| 304 | .ok_or_else(|| unsupported(format!("a tx_type symbol outside its CDF's own set: {t}")))?; | 403 | .ok_or_else(|| unsupported(format!("a tx_type symbol outside its CDF's own set: {t}")))?; |
| 305 | } | 404 | } |
| 306 | 405 | ||
| 307 | - let eob = read_eob(dec, coding); | 406 | + let class = TxClass::of(tx_type); |
| 407 | + if class != TxClass::TwoD { | ||
| 408 | + TX_CLASS1_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 409 | + } | ||
| 410 | + let eob = read_eob(dec, coding, class); | ||
| 308 | if trace { | 411 | if trace { |
| 309 | eprintln!("TRACE eob value={eob}"); | 412 | eprintln!("TRACE eob value={eob}"); |
| 310 | } | 413 | } |
| 414 | + let class_scan; | ||
| 415 | + let scan: &[u16] = if class == TxClass::TwoD { | ||
| 416 | + scan | ||
| 417 | + } else { | ||
| 418 | + class_scan = class_scan_table(side, class); | ||
| 419 | + &class_scan | ||
| 420 | + }; | ||
| 311 | let mut levels = vec![0i32; side * side]; | 421 | let mut levels = vec![0i32; side * side]; |
| 312 | for scan_idx in (0..eob).rev() { | 422 | for scan_idx in (0..eob).rev() { |
| 313 | let pos = scan[scan_idx] as usize; | 423 | let pos = scan[scan_idx] as usize; |
| @@ -322,7 +432,7 @@ fn read_coeffs( | |||
| 322 | } | 432 | } |
| 323 | v | 433 | v |
| 324 | } else { | 434 | } else { |
| 325 | - let ctx = base_ctx(&levels, side, row, col); | 435 | + let ctx = base_ctx(&levels, side, row, col, class); |
| 326 | let v = dec.symbol(&mut coding.base[ctx]) as i32; | 436 | let v = dec.symbol(&mut coding.base[ctx]) as i32; |
| 327 | if trace { | 437 | if trace { |
| 328 | eprintln!( | 438 | eprintln!( |
| @@ -332,7 +442,7 @@ fn read_coeffs( | |||
| 332 | v | 442 | v |
| 333 | }; | 443 | }; |
| 334 | let level = if level > NUM_BASE_LEVELS { | 444 | let level = if level > NUM_BASE_LEVELS { |
| 335 | - let ctx = br_ctx(&levels, side, row, col); | 445 | + let ctx = br_ctx(&levels, side, row, col, class); |
| 336 | let mut level = level; | 446 | let mut level = level; |
| 337 | let mut sent = 0; | 447 | let mut sent = 0; |
| 338 | loop { | 448 | loop { |
| @@ -1192,6 +1302,7 @@ fn decode_block( | |||
| 1192 | scan32: &[u16], | 1302 | scan32: &[u16], |
| 1193 | scan16: &[u16], | 1303 | scan16: &[u16], |
| 1194 | scan8: &[u16], | 1304 | scan8: &[u16], |
| 1305 | + scan4: &[u16], | ||
| 1195 | tx_select: bool, | 1306 | tx_select: bool, |
| 1196 | reduced_tx_set: bool, | 1307 | reduced_tx_set: bool, |
| 1197 | ) -> Result<()> { | 1308 | ) -> Result<()> { |
| @@ -1215,11 +1326,6 @@ fn decode_block( | |||
| 1215 | // which only differs from it at that one corner case. | 1326 | // which only differs from it at that one corner case. |
| 1216 | let (logical_tx, coeff_tx_side) = if tx_select { | 1327 | let (logical_tx, coeff_tx_side) = if tx_select { |
| 1217 | let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side); | 1328 | let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side); |
| 1218 | - if resolved == 4 { | ||
| 1219 | - return Err(unsupported( | ||
| 1220 | - "a resolved 4x4 luma transform (TxMode::Select depth exhausted; this decoder has no 4x4 luma coefficient tables)", | ||
| 1221 | - )); | ||
| 1222 | - } | ||
| 1223 | (resolved, if resolved == 64 { 32 } else { resolved }) | 1329 | (resolved, if resolved == 64 { 32 } else { resolved }) |
| 1224 | } else { | 1330 | } else { |
| 1225 | (side, luma_tx) | 1331 | (side, luma_tx) |
| @@ -1229,7 +1335,7 @@ fn decode_block( | |||
| 1229 | } else { | 1335 | } else { |
| 1230 | luma_set | 1336 | luma_set |
| 1231 | }; | 1337 | }; |
| 1232 | - let luma_scan = scan_for(coeff_tx_side, scan32, scan16, scan8); | 1338 | + let luma_scan = scan_for(coeff_tx_side, scan32, scan16, scan8, scan4); |
| 1233 | let reach = Reach::of(side, px, py, y.width, y.height); | 1339 | let reach = Reach::of(side, px, py, y.width, y.height); |
| 1234 | let (cpx, cpy) = (px / 2, py / 2); | 1340 | let (cpx, cpy) = (px / 2, py / 2); |
| 1235 | let chroma_side = side / 2; | 1341 | let chroma_side = side / 2; |
| @@ -1381,6 +1487,14 @@ fn decode_block( | |||
| 1381 | filter_intra, | 1487 | filter_intra, |
| 1382 | Some(tu_skip_ctx), | 1488 | Some(tu_skip_ctx), |
| 1383 | )?; | 1489 | )?; |
| 1490 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 1491 | + eprintln!( | ||
| 1492 | + "TRACE tu_bitpos mi=({},{}) tell={}", | ||
| 1493 | + tu_mi.0, | ||
| 1494 | + tu_mi.1, | ||
| 1495 | + dec.debug_bitpos() | ||
| 1496 | + ); | ||
| 1497 | + } | ||
| 1384 | neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); | 1498 | neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); |
| 1385 | } | 1499 | } |
| 1386 | } | 1500 | } |
| @@ -1487,18 +1601,15 @@ fn decode_leaf8( | |||
| 1487 | enable_filter_intra, | 1601 | enable_filter_intra, |
| 1488 | )?; | 1602 | )?; |
| 1489 | // `TxMode::Select`'s `tx_depth` at an 8x8 leaf (spec 5.11.16): the only | 1603 | // `TxMode::Select`'s `tx_depth` at an 8x8 leaf (spec 5.11.16): the only |
| 1490 | - // depths an 8x8 block offers are `TX8` (depth 0, this decoder's one | 1604 | + // depths an 8x8 block offers are `TX8` (depth 0) and `TX4` (depth 1, |
| 1491 | - // supported case) and `TX4` (depth 1, which this crate has no 4x4 luma | 1605 | + // which splits the leaf's own 8x8 prediction into a 2x2 grid of 4x4 |
| 1492 | - // coefficient tables for) -- read to stay in sync, then refuse rather | 1606 | + // transform units, same raster-order per-TU pattern `decode_block`'s |
| 1493 | - // than silently miscode. | 1607 | + // multi-TU branch runs). |
| 1494 | - if tx_select { | 1608 | + let resolved = if tx_select { |
| 1495 | - let resolved = read_tx_size(dec, cdfs, neighbours, leaf_mi, 8); | 1609 | + read_tx_size(dec, cdfs, neighbours, leaf_mi, 8) |
| 1496 | - if resolved == 4 { | 1610 | + } else { |
| 1497 | - return Err(unsupported( | 1611 | + 8 |
| 1498 | - "a resolved 4x4 luma transform (TxMode::Select depth exhausted; this decoder has no 4x4 luma coefficient tables)", | 1612 | + }; |
| 1499 | - )); | ||
| 1500 | - } | ||
| 1501 | - } | ||
| 1502 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); | 1613 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); |
| 1503 | let reach = Reach::of(8, px, py, y.width, y.height); | 1614 | let reach = Reach::of(8, px, py, y.width, y.height); |
| 1504 | let (cpx, cpy) = (px / 2, py / 2); | 1615 | let (cpx, cpy) = (px / 2, py / 2); |
| @@ -1529,7 +1640,7 @@ fn decode_leaf8( | |||
| 1529 | luma_grid = vec![0i32; 64]; | 1640 | luma_grid = vec![0i32; 64]; |
| 1530 | u_grid = vec![0i32; 16]; | 1641 | u_grid = vec![0i32; 16]; |
| 1531 | v_grid = vec![0i32; 16]; | 1642 | v_grid = vec![0i32; 16]; |
| 1532 | - } else { | 1643 | + } else if resolved != 4 { |
| 1533 | let around = neighbours.around_mi(leaf_mi, 8); | 1644 | let around = neighbours.around_mi(leaf_mi, 8); |
| 1534 | luma_grid = read_plane( | 1645 | luma_grid = read_plane( |
| 1535 | dec, | 1646 | dec, |
| @@ -1596,6 +1707,129 @@ fn decode_leaf8( | |||
| 1596 | None, | 1707 | None, |
| 1597 | None, | 1708 | None, |
| 1598 | )?; | 1709 | )?; |
| 1710 | + } else { | ||
| 1711 | + // `tx_depth` resolved this leaf's luma to `TX4`: a 2x2 raster-order | ||
| 1712 | + // grid of 4x4 transform units, each predicted from the leaf's own | ||
| 1713 | + // 8x8 `mode` and reading its own fresh context off the earlier | ||
| 1714 | + // units in this same leaf (the same per-TU pattern `decode_block`'s | ||
| 1715 | + // multi-TU branch runs at bigger blocks). | ||
| 1716 | + luma_grid = vec![0i32; 64]; | ||
| 1717 | + for tu_row in 0..2 { | ||
| 1718 | + for tu_col in 0..2 { | ||
| 1719 | + let tu_mi = (leaf_mi.0 + tu_row, leaf_mi.1 + tu_col); | ||
| 1720 | + let tu_px = px + tu_col * 4; | ||
| 1721 | + let tu_py = py + tu_row * 4; | ||
| 1722 | + let tu_around = neighbours.around_mi(tu_mi, 4)[0]; | ||
| 1723 | + let tu_reach = Reach::of(4, tu_px, tu_py, y.width, y.height); | ||
| 1724 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); | ||
| 1725 | + let tu_grid = read_plane( | ||
| 1726 | + dec, | ||
| 1727 | + cdfs, | ||
| 1728 | + if reduced_tx_set { | ||
| 1729 | + TxbSet::Luma4 | ||
| 1730 | + } else { | ||
| 1731 | + TxbSet::Luma4Set1 | ||
| 1732 | + }, | ||
| 1733 | + scans.1, | ||
| 1734 | + 0, | ||
| 1735 | + tu_around, | ||
| 1736 | + mode, | ||
| 1737 | + mode, | ||
| 1738 | + tu_reach, | ||
| 1739 | + y, | ||
| 1740 | + tu_px, | ||
| 1741 | + tu_py, | ||
| 1742 | + 4, | ||
| 1743 | + 4, | ||
| 1744 | + base_q_idx, | ||
| 1745 | + None, | ||
| 1746 | + filter_intra, | ||
| 1747 | + Some(tu_skip_ctx), | ||
| 1748 | + )?; | ||
| 1749 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 1750 | + eprintln!( | ||
| 1751 | + "TRACE tu_bitpos mi=({},{}) tell={}", | ||
| 1752 | + tu_mi.0, | ||
| 1753 | + tu_mi.1, | ||
| 1754 | + dec.debug_bitpos() | ||
| 1755 | + ); | ||
| 1756 | + } | ||
| 1757 | + neighbours.record_mi_luma(tu_mi, 4, &tu_grid); | ||
| 1758 | + } | ||
| 1759 | + } | ||
| 1760 | + let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8)); | ||
| 1761 | + let chroma_around = neighbours.around_mi(leaf_mi, 8); | ||
| 1762 | + u_grid = read_plane( | ||
| 1763 | + dec, | ||
| 1764 | + cdfs, | ||
| 1765 | + TxbSet::Chroma4, | ||
| 1766 | + scans.1, | ||
| 1767 | + 1, | ||
| 1768 | + chroma_around[1], | ||
| 1769 | + mode, | ||
| 1770 | + DC_PRED, | ||
| 1771 | + Reach::none(), | ||
| 1772 | + u, | ||
| 1773 | + cpx, | ||
| 1774 | + cpy, | ||
| 1775 | + 4, | ||
| 1776 | + TX4, | ||
| 1777 | + base_q_idx, | ||
| 1778 | + alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | ||
| 1779 | + None, | ||
| 1780 | + None, | ||
| 1781 | + )?; | ||
| 1782 | + v_grid = read_plane( | ||
| 1783 | + dec, | ||
| 1784 | + cdfs, | ||
| 1785 | + TxbSet::Chroma4, | ||
| 1786 | + scans.1, | ||
| 1787 | + 2, | ||
| 1788 | + chroma_around[2], | ||
| 1789 | + mode, | ||
| 1790 | + DC_PRED, | ||
| 1791 | + Reach::none(), | ||
| 1792 | + v, | ||
| 1793 | + cpx, | ||
| 1794 | + cpy, | ||
| 1795 | + 4, | ||
| 1796 | + TX4, | ||
| 1797 | + base_q_idx, | ||
| 1798 | + alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | ||
| 1799 | + None, | ||
| 1800 | + None, | ||
| 1801 | + )?; | ||
| 1802 | + // `record_split_luma` expects a `record`-style `(r, c)` position in | ||
| 1803 | + // `SUB`-grid units and rescales it by `SUB / MI`; `leaf_mi` is | ||
| 1804 | + // already in mi units, so calling it here double-scaled the | ||
| 1805 | + // position. Plane 0 is already correct per-TU from the | ||
| 1806 | + // `record_mi_luma` calls above; this inlines `record_mi`'s tail | ||
| 1807 | + // (spec `get_txb_ctx_general`'s neighbour-magnitude bookkeeping) for | ||
| 1808 | + // the two chroma planes only, at `leaf_mi` directly, side_mi=2 (this | ||
| 1809 | + // leaf's own 8x8 side over `MI`). | ||
| 1810 | + let side_mi = 2; | ||
| 1811 | + for cell in 0..side_mi { | ||
| 1812 | + neighbours.left_side_mi[leaf_mi.0 + cell] = 8; | ||
| 1813 | + neighbours.above_side_mi[leaf_mi.1 + cell] = 8; | ||
| 1814 | + } | ||
| 1815 | + let round_up_even = |n: usize| n.div_ceil(2) * 2; | ||
| 1816 | + let bound_h = round_up_even(neighbours.mi_rows); | ||
| 1817 | + let bound_w = round_up_even(neighbours.mi_cols); | ||
| 1818 | + let u_state = neighbour_state(&u_grid); | ||
| 1819 | + let v_state = neighbour_state(&v_grid); | ||
| 1820 | + for cell in 0..side_mi { | ||
| 1821 | + if cell < side_mi.min(bound_h.saturating_sub(leaf_mi.0)) { | ||
| 1822 | + neighbours.left[leaf_mi.0 + cell][1] = u_state; | ||
| 1823 | + neighbours.left[leaf_mi.0 + cell][2] = v_state; | ||
| 1824 | + } | ||
| 1825 | + if cell < side_mi.min(bound_w.saturating_sub(leaf_mi.1)) { | ||
| 1826 | + neighbours.above[leaf_mi.1 + cell][1] = u_state; | ||
| 1827 | + neighbours.above[leaf_mi.1 + cell][2] = v_state; | ||
| 1828 | + } | ||
| 1829 | + } | ||
| 1830 | + neighbours.fill_skip_grid(leaf_mi, 2, skip); | ||
| 1831 | + neighbours.fill_lf_grid(leaf_mi, 2, 4, false); | ||
| 1832 | + return Ok(mode); | ||
| 1599 | } | 1833 | } |
| 1600 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); | 1834 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); |
| 1601 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 1835 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| @@ -1875,14 +2109,21 @@ fn read_tx_size( | |||
| 1875 | side >> depth | 2109 | side >> depth |
| 1876 | } | 2110 | } |
| 1877 | 2111 | ||
| 1878 | -/// The luma coefficient scan table for a resolved transform side -- 32/16/8, | 2112 | +/// The luma coefficient scan table for a resolved transform side -- 32/16/8/4, |
| 1879 | -/// the only three sizes a `TxMode::Select` block's coded coefficient grid | 2113 | +/// the only four sizes a `TxMode::Select` block's coded coefficient grid |
| 1880 | /// ([`read_tx_size`]'s resolved side, or 32 at the 64x64 corner case) can be. | 2114 | /// ([`read_tx_size`]'s resolved side, or 32 at the 64x64 corner case) can be. |
| 1881 | -fn scan_for<'a>(tx_px: usize, scan32: &'a [u16], scan16: &'a [u16], scan8: &'a [u16]) -> &'a [u16] { | 2115 | +fn scan_for<'a>( |
| 2116 | + tx_px: usize, | ||
| 2117 | + scan32: &'a [u16], | ||
| 2118 | + scan16: &'a [u16], | ||
| 2119 | + scan8: &'a [u16], | ||
| 2120 | + scan4: &'a [u16], | ||
| 2121 | +) -> &'a [u16] { | ||
| 1882 | match tx_px { | 2122 | match tx_px { |
| 1883 | 32 => scan32, | 2123 | 32 => scan32, |
| 1884 | 16 => scan16, | 2124 | 16 => scan16, |
| 1885 | 8 => scan8, | 2125 | 8 => scan8, |
| 2126 | + 4 => scan4, | ||
| 1886 | _ => unreachable!("read_tx_size never resolves the coefficient grid to anything else"), | 2127 | _ => unreachable!("read_tx_size never resolves the coefficient grid to anything else"), |
| 1887 | } | 2128 | } |
| 1888 | } | 2129 | } |
| @@ -1891,11 +2132,11 @@ fn scan_for<'a>(tx_px: usize, scan32: &'a [u16], scan16: &'a [u16], scan8: &'a [ | |||
| 1891 | /// from -- 64 is only ever the 64x64-block, depth-0, corner-scanned case | 2132 | /// from -- 64 is only ever the 64x64-block, depth-0, corner-scanned case |
| 1892 | /// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching | 2133 | /// ([`TxbSet::Luma64`]); every other resolved side maps to its own matching |
| 1893 | /// set. `get_tx_set` (spec 5.11.48) only splits on `reduced_tx_set` at | 2134 | /// set. `get_tx_set` (spec 5.11.48) only splits on `reduced_tx_set` at |
| 1894 | -/// `TX_8X8`: an intra `TX_16X16` always reads `TX_SET_INTRA_2` regardless of | 2135 | +/// `TX_8X8`/`TX_4X4`: an intra `TX_16X16` always reads `TX_SET_INTRA_2` |
| 1895 | -/// the flag (`av1_get_ext_tx_set_type`'s `tx_size_sqr == TX_16X16` branch | 2136 | +/// regardless of the flag (`av1_get_ext_tx_set_type`'s |
| 1896 | -/// ignores `use_reduced_set` once it is past the `TX_32X32`/reduced-set | 2137 | +/// `tx_size_sqr == TX_16X16` branch ignores `use_reduced_set` once it is past |
| 1897 | -/// checks), so only the 8x8 case has a second table | 2138 | +/// the `TX_32X32`/reduced-set checks), so only the 8x8 and 4x4 cases have a |
| 1898 | -/// ([`TxbSet::Luma8Set1`]). | 2139 | +/// second table ([`TxbSet::Luma8Set1`]/[`TxbSet::Luma4Set1`]). |
| 1899 | fn txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { | 2140 | fn txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { |
| 1900 | match tx_px { | 2141 | match tx_px { |
| 1901 | 64 => TxbSet::Luma64, | 2142 | 64 => TxbSet::Luma64, |
| @@ -1903,6 +2144,8 @@ fn txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { | |||
| 1903 | 16 => TxbSet::Luma16, | 2144 | 16 => TxbSet::Luma16, |
| 1904 | 8 if reduced_tx_set => TxbSet::Luma8, | 2145 | 8 if reduced_tx_set => TxbSet::Luma8, |
| 1905 | 8 => TxbSet::Luma8Set1, | 2146 | 8 => TxbSet::Luma8Set1, |
| 2147 | + 4 if reduced_tx_set => TxbSet::Luma4, | ||
| 2148 | + 4 => TxbSet::Luma4Set1, | ||
| 1906 | _ => unreachable!("read_tx_size never resolves a block's own side to anything else"), | 2149 | _ => unreachable!("read_tx_size never resolves a block's own side to anything else"), |
| 1907 | } | 2150 | } |
| 1908 | } | 2151 | } |
| @@ -2596,6 +2839,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2596 | &scan32, | 2839 | &scan32, |
| 2597 | &scan16, | 2840 | &scan16, |
| 2598 | &scan8, | 2841 | &scan8, |
| 2842 | + &scan4, | ||
| 2599 | tx_select, | 2843 | tx_select, |
| 2600 | reduced_tx_set, | 2844 | reduced_tx_set, |
| 2601 | )?; | 2845 | )?; |
| @@ -2615,7 +2859,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2615 | let part32 = if has_cols32 && has_rows32 { | 2859 | let part32 = if has_cols32 && has_rows32 { |
| 2616 | let p = dec.symbol(&mut cdfs.partition_w32[ctx32]); | 2860 | let p = dec.symbol(&mut cdfs.partition_w32[ctx32]); |
| 2617 | if std::env::var_os("EC_AV1_TRACE").is_some() { | 2861 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 2618 | - eprintln!("TRACE partition_w32 ctx={ctx32} value={p}"); | 2862 | + eprintln!( |
| 2863 | + "TRACE partition_w32 mi=({},{}) ctx={ctx32} value={p}", | ||
| 2864 | + r32 * BLOCK_MI, | ||
| 2865 | + c32 * BLOCK_MI | ||
| 2866 | + ); | ||
| 2619 | } | 2867 | } |
| 2620 | p | 2868 | p |
| 2621 | } else { | 2869 | } else { |
| @@ -2658,6 +2906,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2658 | &scan32, | 2906 | &scan32, |
| 2659 | &scan16, | 2907 | &scan16, |
| 2660 | &scan8, | 2908 | &scan8, |
| 2909 | + &scan4, | ||
| 2661 | tx_select, | 2910 | tx_select, |
| 2662 | reduced_tx_set, | 2911 | reduced_tx_set, |
| 2663 | )?; | 2912 | )?; |
| @@ -2706,6 +2955,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2706 | &scan32, | 2955 | &scan32, |
| 2707 | &scan16, | 2956 | &scan16, |
| 2708 | &scan8, | 2957 | &scan8, |
| 2958 | + &scan4, | ||
| 2709 | tx_select, | 2959 | tx_select, |
| 2710 | reduced_tx_set, | 2960 | reduced_tx_set, |
| 2711 | )?; | 2961 | )?; |
| @@ -2733,6 +2983,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2733 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); | 2983 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); |
| 2734 | let part8 = | 2984 | let part8 = |
| 2735 | dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | 2985 | dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 2986 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 2987 | + eprintln!( | ||
| 2988 | + "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}" | ||
| 2989 | + ); | ||
| 2990 | + } | ||
| 2736 | if part8 != PARTITION_NONE { | 2991 | if part8 != PARTITION_NONE { |
| 2737 | return Err(unsupported( | 2992 | return Err(unsupported( |
| 2738 | "a partition below 8x8 (this encoder never writes one)", | 2993 | "a partition below 8x8 (this encoder never writes one)", |
| @@ -2797,6 +3052,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 2797 | let leaf_mi = (mr as usize, mc as usize); | 3052 | let leaf_mi = (mr as usize, mc as usize); |
| 2798 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); | 3053 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); |
| 2799 | let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | 3054 | let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 3055 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 3056 | + eprintln!( | ||
| 3057 | + "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}" | ||
| 3058 | + ); | ||
| 3059 | + } | ||
| 2800 | if part8 != PARTITION_NONE { | 3060 | if part8 != PARTITION_NONE { |
| 2801 | return Err(unsupported( | 3061 | return Err(unsupported( |
| 2802 | "a partition below 8x8 (this encoder never writes one)", | 3062 | "a partition below 8x8 (this encoder never writes one)", |
crates/ec-av1/src/encode.rsmodified+18 -4
| @@ -1015,9 +1015,21 @@ impl Reach { | |||
| 1015 | if col + 1 == per_side { | 1015 | if col + 1 == per_side { |
| 1016 | return false; | 1016 | return false; |
| 1017 | } | 1017 | } |
| 1018 | + // corner-cut: `HAS_TOP_RIGHT`/`HAS_BOTTOM_LEFT` only carry dedicated | ||
| 1019 | + // rows for side 8/16/32/64 (libaom's own `has_tr_8x8`/`has_tr_16x16` | ||
| 1020 | + // families); a `TxMode::Select` TX4 transform unit reaches here with | ||
| 1021 | + // side 4, whose real table (`has_tr_4x4`, 128 bytes) was never | ||
| 1022 | + // transcribed. Clamping into the 16/32 table's own bit range keeps | ||
| 1023 | + // this in-bounds and correct at every position that table already | ||
| 1024 | + // covers periodically -- wrong only at the small remainder past its | ||
| 1025 | + // length, a reach over-/under-estimate (extra or missing above-right | ||
| 1026 | + // reference pixels), never a stream desync (Reach never gates a | ||
| 1027 | + // symbol read). Ceiling: transcribe `has_tr_4x4`/`has_bl_4x4` | ||
| 1028 | + // verbatim and give TX4 its own `HAS_TOP_RIGHT`/`HAS_BOTTOM_LEFT` row. | ||
| 1029 | + let table = HAS_TOP_RIGHT[Self::table(side)]; | ||
| 1018 | Self::bit( | 1030 | Self::bit( |
| 1019 | - HAS_TOP_RIGHT[Self::table(side)], | 1031 | + table, |
| 1020 | - row * Self::table_stride(side) + col, | 1032 | + (row * Self::table_stride(side) + col) % (table.len() * 8), |
| 1021 | ) | 1033 | ) |
| 1022 | } | 1034 | } |
| 1023 | 1035 | ||
| @@ -1033,9 +1045,11 @@ impl Reach { | |||
| 1033 | if row + 1 == per_side { | 1045 | if row + 1 == per_side { |
| 1034 | return false; | 1046 | return false; |
| 1035 | } | 1047 | } |
| 1048 | + // corner-cut: see `top_right`'s note -- same clamp, same ceiling. | ||
| 1049 | + let table = HAS_BOTTOM_LEFT[Self::table(side)]; | ||
| 1036 | Self::bit( | 1050 | Self::bit( |
| 1037 | - HAS_BOTTOM_LEFT[Self::table(side)], | 1051 | + table, |
| 1038 | - row * Self::table_stride(side) + col, | 1052 | + (row * Self::table_stride(side) + col) % (table.len() * 8), |
| 1039 | ) | 1053 | ) |
| 1040 | } | 1054 | } |
| 1041 | 1055 | ||
crates/ec-av1/src/msac.rsmodified+7 -0
| @@ -337,6 +337,13 @@ impl<'a> SymbolDecoder<'a> { | |||
| 337 | symbol | 337 | symbol |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | + /// Debug-only: the current bit offset into `data`, for cross-checking | ||
| 341 | + /// against a reference decoder's own `aom_reader_tell()` while chasing a | ||
| 342 | + /// desync (see `EC_AV1_TRACE`). Not spec state, just `self.bit`. | ||
| 343 | + pub(crate) fn debug_bitpos(&self) -> usize { | ||
| 344 | + self.bit | ||
| 345 | + } | ||
| 346 | + | ||
| 340 | /// Reads `bits` raw bits, most significant first — the `L(n)` descriptor | 347 | /// Reads `bits` raw bits, most significant first — the `L(n)` descriptor |
| 341 | /// of spec 4.10.4. | 348 | /// of spec 4.10.4. |
| 342 | pub fn literal(&mut self, bits: u32) -> u32 { | 349 | pub fn literal(&mut self, bits: u32) -> u32 { |
crates/ec-av1/src/stream.rsmodified+156 -0
| @@ -1563,4 +1563,160 @@ mod tests { | |||
| 1563 | } | 1563 | } |
| 1564 | } | 1564 | } |
| 1565 | } | 1565 | } |
| 1566 | + | ||
| 1567 | + /// Final round of the TX4/tx-class lane's own gate: `--min-partition-size=8 | ||
| 1568 | + /// --max-partition-size=8` pins every leaf to exactly 8x8 (spec | ||
| 1569 | + /// 5.11.4's own boundary carve-out aside, which a multiple-of-8 frame | ||
| 1570 | + /// never triggers), so a real `aomenc` stream from this recipe can only | ||
| 1571 | + /// legitimately read `PARTITION_NONE` at every `bsize=3` node -- any | ||
| 1572 | + /// other value this decoder sees there is a genuine desync, not a | ||
| 1573 | + /// "partition below 8x8" the encoder actually wrote (traced live against | ||
| 1574 | + /// a debug `aomdec` 2026-08-27: the true bitstream's own 8x8 partition | ||
| 1575 | + /// reads are all `NONE`; the mismatch was `base_ctx`'s DC-position | ||
| 1576 | + /// short-circuit firing for `TX_CLASS_HORIZ`/`VERT` too, off by one | ||
| 1577 | + /// `BR` read into a spurious extra Golomb call). The sinusoidal-stripe | ||
| 1578 | + /// `geq` source (a smooth luma ramp, not the sharp two-tone stripes that | ||
| 1579 | + /// tripped `aomenc`'s screen-content-tools auto-detect) is what actually | ||
| 1580 | + /// resolves `V_DCT`/`H_DCT` (`TxClass::of`) on some 8x8 TUs at this | ||
| 1581 | + /// content's frequency; the attempt loop moves on from named refusals | ||
| 1582 | + /// (`allow_screen_content_tools`, angle-delta) same as every other | ||
| 1583 | + /// multi-seed recipe in this file, and only counts a run as a genuine | ||
| 1584 | + /// firing when [`decode::tx_class1_hits`] actually moved. | ||
| 1585 | + #[test] | ||
| 1586 | + fn a_real_aomenc_min8_stream_with_tx_class1_decodes_pixel_exact() { | ||
| 1587 | + if !have_ffmpeg() { | ||
| 1588 | + eprintln!( | ||
| 1589 | + "SKIP a_real_aomenc_min8_stream_with_tx_class1_decodes_pixel_exact: no ffmpeg" | ||
| 1590 | + ); | ||
| 1591 | + return; | ||
| 1592 | + } | ||
| 1593 | + if !have_aomenc() { | ||
| 1594 | + eprintln!( | ||
| 1595 | + "SKIP a_real_aomenc_min8_stream_with_tx_class1_decodes_pixel_exact: no aomenc at {}", | ||
| 1596 | + aomenc_path().display() | ||
| 1597 | + ); | ||
| 1598 | + return; | ||
| 1599 | + } | ||
| 1600 | + let (width, height) = (64usize, 64usize); | ||
| 1601 | + let mut refusals = Vec::new(); | ||
| 1602 | + let mut fired_runs = 0u32; | ||
| 1603 | + for attempt in 0..60u32 { | ||
| 1604 | + let cq = 20 + (attempt % 5) * 10; | ||
| 1605 | + let period = [4u32, 6, 8, 12, 16][(attempt as usize / 5) % 5]; | ||
| 1606 | + let y4m = Command::new("ffmpeg") | ||
| 1607 | + .args([ | ||
| 1608 | + "-v", | ||
| 1609 | + "error", | ||
| 1610 | + "-f", | ||
| 1611 | + "lavfi", | ||
| 1612 | + "-i", | ||
| 1613 | + "testsrc2=size=64x64:rate=25", | ||
| 1614 | + "-vf", | ||
| 1615 | + &format!( | ||
| 1616 | + "geq=lum='128+80*sin(2*PI*Y/{period})':cb=128:cr=128,noise=alls=6:allf=t" | ||
| 1617 | + ), | ||
| 1618 | + "-pix_fmt", | ||
| 1619 | + "yuv420p", | ||
| 1620 | + "-t", | ||
| 1621 | + "0.04", | ||
| 1622 | + "-f", | ||
| 1623 | + "yuv4mpegpipe", | ||
| 1624 | + "-", | ||
| 1625 | + ]) | ||
| 1626 | + .stdin(Stdio::null()) | ||
| 1627 | + .stdout(Stdio::piped()) | ||
| 1628 | + .stderr(Stdio::piped()) | ||
| 1629 | + .output() | ||
| 1630 | + .expect("ffmpeg failed to run"); | ||
| 1631 | + assert!( | ||
| 1632 | + y4m.status.success(), | ||
| 1633 | + "ffmpeg fixture: {}", | ||
| 1634 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 1635 | + ); | ||
| 1636 | + let mut child = Command::new(aomenc_path()) | ||
| 1637 | + .args([ | ||
| 1638 | + "--codec=av1", | ||
| 1639 | + "--passes=1", | ||
| 1640 | + "--end-usage=q", | ||
| 1641 | + &format!("--cq-level={cq}"), | ||
| 1642 | + "--cpu-used=0", | ||
| 1643 | + "--enable-directional-intra=0", | ||
| 1644 | + "--enable-smooth-intra=0", | ||
| 1645 | + "--enable-paeth-intra=0", | ||
| 1646 | + "--enable-rect-partitions=0", | ||
| 1647 | + "--enable-angle-delta=0", | ||
| 1648 | + "--enable-palette=0", | ||
| 1649 | + "--reduced-tx-type-set=0", | ||
| 1650 | + "--enable-restoration=0", | ||
| 1651 | + "--enable-cdef=0", | ||
| 1652 | + "--loopfilter-control=0", | ||
| 1653 | + "--min-partition-size=8", | ||
| 1654 | + "--max-partition-size=8", | ||
| 1655 | + "--enable-ab-partitions=0", | ||
| 1656 | + "--enable-1to4-partitions=0", | ||
| 1657 | + "--enable-filter-intra=0", | ||
| 1658 | + "--enable-intrabc=0", | ||
| 1659 | + "--enable-cfl-intra=0", | ||
| 1660 | + "--tune-content=default", | ||
| 1661 | + "--obu", | ||
| 1662 | + "-o", | ||
| 1663 | + "-", | ||
| 1664 | + "-", | ||
| 1665 | + ]) | ||
| 1666 | + .stdin(Stdio::piped()) | ||
| 1667 | + .stdout(Stdio::piped()) | ||
| 1668 | + .stderr(Stdio::piped()) | ||
| 1669 | + .spawn() | ||
| 1670 | + .expect("aomenc failed to start"); | ||
| 1671 | + child | ||
| 1672 | + .stdin | ||
| 1673 | + .take() | ||
| 1674 | + .expect("aomenc stdin") | ||
| 1675 | + .write_all(&y4m.stdout) | ||
| 1676 | + .expect("writing y4m to aomenc"); | ||
| 1677 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 1678 | + if !out.status.success() { | ||
| 1679 | + refusals.push(format!( | ||
| 1680 | + "cq={cq} period={period}: aomenc itself refused the fixture" | ||
| 1681 | + )); | ||
| 1682 | + continue; | ||
| 1683 | + } | ||
| 1684 | + let stream = out.stdout; | ||
| 1685 | + let before = decode::tx_class1_hits(); | ||
| 1686 | + let frames = match decode_stream(&stream) { | ||
| 1687 | + Ok(frames) => frames, | ||
| 1688 | + Err(e) => { | ||
| 1689 | + refusals.push(format!("cq={cq} period={period}: {e}")); | ||
| 1690 | + continue; | ||
| 1691 | + } | ||
| 1692 | + }; | ||
| 1693 | + if decode::tx_class1_hits() == before { | ||
| 1694 | + refusals.push(format!( | ||
| 1695 | + "cq={cq} period={period}: decoded, but no block read a V_DCT/H_DCT tx_type" | ||
| 1696 | + )); | ||
| 1697 | + continue; | ||
| 1698 | + } | ||
| 1699 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | ||
| 1700 | + assert_eq!( | ||
| 1701 | + frames[0].y, ffmpeg_frames[0].y, | ||
| 1702 | + "luma vs ffmpeg (cq={cq} period={period})" | ||
| 1703 | + ); | ||
| 1704 | + assert_eq!( | ||
| 1705 | + frames[0].u, ffmpeg_frames[0].u, | ||
| 1706 | + "U vs ffmpeg (cq={cq} period={period})" | ||
| 1707 | + ); | ||
| 1708 | + assert_eq!( | ||
| 1709 | + frames[0].v, ffmpeg_frames[0].v, | ||
| 1710 | + "V vs ffmpeg (cq={cq} period={period})" | ||
| 1711 | + ); | ||
| 1712 | + fired_runs += 1; | ||
| 1713 | + if fired_runs >= 4 { | ||
| 1714 | + return; | ||
| 1715 | + } | ||
| 1716 | + } | ||
| 1717 | + panic!( | ||
| 1718 | + "fewer than 4 firing+pixel-exact runs out of 60 attempts:\n{}", | ||
| 1719 | + refusals.join("\n") | ||
| 1720 | + ); | ||
| 1721 | + } | ||
| 1566 | } | 1722 | } |