edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB00c1b3fTahinli2 months ago1999 commits
| 1 | //! AV1 spec 7.16 upscaling process (`av1_upscale_normative_rows` in |
| 2 | //! libaom's `av1/common/resize.c`) -- the horizontal-only linear-filter |
| 3 | //! upscale that runs on the decoded frame after deblocking and CDEF (and, |
| 4 | //! once this crate supports loop restoration, BEFORE it -- libaom's |
| 5 | //! `decodeframe.c` calls `superres_post_decode()` between `av1_cdef_frame` |
| 6 | //! and `av1_loop_restoration_filter_frame`, not after LR; the charter's |
| 7 | //! anchor note that superres runs "after loop restoration" does not match |
| 8 | //! the source and is corrected here). |
| 9 | //! |
| 10 | //! Every constant and the 64x8 `av1_resize_filter_normative` coefficient |
| 11 | //! table below is copied verbatim from libaom `aom_dsp/aom_filter.h` and |
| 12 | //! `av1/common/resize.c` (`AOM_VERSION=v3.13.3`, `~/.cache/aom-oracle`). |
| 13 | |
| 14 | /// `RS_SUBPEL_BITS`. |
| 15 | const RS_SUBPEL_BITS: u32 = 6; |
| 16 | /// `RS_SCALE_SUBPEL_BITS`. |
| 17 | const RS_SCALE_SUBPEL_BITS: u32 = 14; |
| 18 | /// `RS_SCALE_SUBPEL_MASK`. |
| 19 | const RS_SCALE_SUBPEL_MASK: i64 = - 1; |
| 20 | /// `RS_SCALE_EXTRA_BITS`. |
| 21 | const RS_SCALE_EXTRA_BITS: u32 = RS_SCALE_SUBPEL_BITS - RS_SUBPEL_BITS; |
| 22 | /// `RS_SCALE_EXTRA_OFF`. |
| 23 | const RS_SCALE_EXTRA_OFF: i64 = 1i64 << ; |
| 24 | /// `UPSCALE_NORMATIVE_TAPS`. |
| 25 | const UPSCALE_NORMATIVE_TAPS: usize = 8; |
| 26 | /// `FILTER_BITS`. |
| 27 | const FILTER_BITS: u32 = 7; |
| 28 | |
| 29 | /// `av1_resize_filter_normative`, libaom `av1/common/resize.c`. 64 subpel |
| 30 | /// phases x 8 taps. |
| 31 | |
| 32 | const RESIZE_FILTER_NORMATIVE: = |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | ; |
| 66 | |
| 67 | /// `av1_get_upscale_convolve_step` (`resize.c`). |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | /// `get_upscale_convolve_x0` (`resize.c`, static there). |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | /// `av1_convolve_horiz_rs_c` (`convolve.c`): `clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS))`. |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | /// One row of the spec 7.16 horizontal upscale (`upscale_normative_rect` + |
| 88 | /// `av1_convolve_horiz_rs_c`, single-tile case: `pad_left`/`pad_right` both |
| 89 | /// true, replicating the row's own edge pixels rather than sampling a |
| 90 | /// neighbour tile). `in_width` and `out_width` must both be positive; |
| 91 | /// `row.len() == in_width` and `out.len() == out_width`. |
| 92 | /// `bit_depth` only picks the output clamp (`clip_pixel`/`clip_pixel_highbd` |
| 93 | /// in libaom's `av1_convolve_horiz_rs_c`); the filter, its `Round2` and the |
| 94 | /// edge padding are bit-depth independent (spec 7.16). |
| 95 | pub |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | /// Spec 7.16, applied to a whole plane: `av1_upscale_normative_rows` |
| 149 | /// widened to every row (`height2 == height`, no vertical scaling -- the |
| 150 | /// spec only widens columns). `rows` is the plane's row-major byte buffer |
| 151 | /// at `in_width`; returns a new buffer at `out_width`. |
| 152 | pub |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | thread_local! |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | /// Current value of [`SUPERRES_HITS`]. |
| 183 | pub |
| 184 | |
| 185 | |
| 186 | |
| 187 | /// A whole [`crate::encode::Picture`]'s Y/U/V planes, upscaled from |
| 188 | /// `frame_width`/`frame_height` (4:2:0 chroma) to `upscaled_width` at the |
| 189 | /// same height -- spec 7.16 is horizontal-only. Increments |
| 190 | /// [`SUPERRES_HITS`] once per call. `margin`, when set (r3, from |
| 191 | /// `decode::take_last_frame_wide_margin`), is the real decoded pixels |
| 192 | /// beyond `picture`'s own width out to the mi-aligned `true_width` -- see |
| 193 | /// [`upscale_row`]'s doc for why the right-edge padding needs it. |
| 194 | pub |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 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 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 |