edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! CDEF constants and filter kernels. //! av1split: moved out of `decode/mod.rs`; the items are unchanged apart from visibility. (D14) |
| 2 | |
| 3 | use SimdToken; |
| 4 | use *; |
| 5 | |
| 6 | /// Spec 7.15.3's `Cdef_Directions`: `(row, col)` offsets for the two primary |
| 7 | /// taps of each of the eight directions; the secondary taps at `dir+2`/`dir-2` |
| 8 | /// (mod 8) reuse the same table. |
| 9 | pub const CDEF_DIRECTIONS: = |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | ; |
| 19 | /// A neighbour tap outside the frame's true extent -- `constrain` reads this |
| 20 | /// as "so far away it never contributes" (spec/libaom `CDEF_VERY_LARGE`). |
| 21 | pub const CDEF_VERY_LARGE: i32 = 0x4000; |
| 22 | pub const CDEF_PRI_TAPS: = ; |
| 23 | pub const CDEF_SEC_TAPS: = ; |
| 24 | /// lane-av1422filter: libaom `av1_cdef_filter_fb` (cdef_block.c) remaps the |
| 25 | /// luma direction before filtering CHROMA whenever `xdec != ydec` — the |
| 26 | /// direction grid lives on the subsampled chroma grid, so a direction found |
| 27 | /// on the 8x8 luma block means a different line there. `conv422` applies |
| 28 | /// under 4:2:2 (`xdec` set), `conv440` under its mirror (not expressible in |
| 29 | /// the profiles this decoder accepts, kept for fidelity). 4:2:0 and 4:4:4 |
| 30 | /// (`xdec == ydec`) take no remap, exactly as before this lane. |
| 31 | pub const CDEF_DIR_CONV422: = ; |
| 32 | pub const CDEF_DIR_CONV440: = ; |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | /// Spec 7.15.3's `constrain`: how much of a neighbour's difference from the |
| 39 | /// centre sample a filter tap is allowed to contribute. |
| 40 | // read only from the `#[cfg(test)]` gates |
| 41 | pub |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | /// `constrain`'s damping shift: a function of the block's threshold and |
| 49 | /// damping alone, so the filter loop computes it once per block instead of |
| 50 | /// the `leading_zeros` + branch it used to do twice per tap read. |
| 51 | pub |
| 52 | |
| 53 | |
| 54 | |
| 55 | /// [`cdef_constrain`]'s body with the shift already resolved; `threshold` is |
| 56 | /// non-zero on every call (the caller only filters when its strength is). |
| 57 | pub |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | /// The widest `CDEF_DIRECTIONS` offset in either axis: every tap a block reads |
| 63 | /// lies inside its own samples grown by this much. |
| 64 | pub const CDEF_BORDER: usize = 2; |
| 65 | |
| 66 | /// Copies one block's whole CDEF footprint -- its `bh` x `bw` samples plus the |
| 67 | /// [`CDEF_BORDER`] tap ring -- out of the *unfiltered* plane into `buf` (row |
| 68 | /// stride `bw + 2 * CDEF_BORDER`), so the direction search and the tap loops |
| 69 | /// index a small contiguous window instead of re-deriving the frame-bounds |
| 70 | /// test on every one of a pixel's ~17 tap reads. Out-of-frame positions get |
| 71 | /// `CDEF_VERY_LARGE`, exactly as the per-sample closure did. |
| 72 | // Signature mirrors the spec's per-call inputs; a parameter struct would only move them. |
| 73 | |
| 74 | pub |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | /// libaom `cdef_find_dir_c`'s eight partial-sum arrays, row at a time: each |
| 119 | /// array takes the row, its reverse, its pairwise sums or its total added |
| 120 | /// into consecutive slots, so the 512 scalar read-modify-writes on i64 the |
| 121 | /// per-sample form did become a handful of lane-wide adds per row. i32 is |
| 122 | /// exact here: every partial is a sum of at most eight values in -128..127, |
| 123 | /// and slot 15 exists only so an eight-lane store at offset 7 fits. |
| 124 | pub |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | /// Spec 7.15.3's direction search (libaom `cdef_find_dir_c`): the dominant |
| 154 | /// direction of an 8x8 luma window and the variance gap between it and its |
| 155 | /// orthogonal, reading [`cdef_gather`]'s window (row stride `bstride`, the |
| 156 | /// block's own samples starting at `CDEF_BORDER, CDEF_BORDER`). |
| 157 | /// Runtime dispatch of the direction search's partial sums: the AVX2 clone |
| 158 | /// runs [`cdef_simd::find_dir_partials_avx2`], the baseline clone the scalar |
| 159 | /// form. Both read the same eight rows of eight samples. |
| 160 | pub |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | pub |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | /// Spec 7.15.2's per-8x8 strength adjustment: a strongly directional 8x8 |
| 208 | /// (high variance gap) gets more deringing than a flat or non-directional |
| 209 | /// one, only ever applied to the luma primary strength. |
| 210 | pub |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | /// Spec 7.15.3's `cdef_filter_block`: filters one block (8x8 luma, 4x4 4:2:0 |
| 223 | /// chroma) in place, `sample(row, col)` reading the *unfiltered* frame (a |
| 224 | /// previously-filtered neighbour must never feed this block's own sum). |
| 225 | |
| 226 | pub |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | /// [`cdef_filter_block`]'s scalar reference: spec 7.15.3 sample by sample, |
| 293 | /// the form every non-AVX2 build decodes through and the one |
| 294 | /// `cdef_simd_kernel_matches_the_scalar_filter` checks the kernel against. |
| 295 | |
| 296 | pub |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 |