edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 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 | use cratehit; |
| 14 | |
| 15 | /// `RS_SUBPEL_BITS`. |
| 16 | const RS_SUBPEL_BITS: u32 = 6; |
| 17 | /// `RS_SCALE_SUBPEL_BITS`. |
| 18 | const RS_SCALE_SUBPEL_BITS: u32 = 14; |
| 19 | /// `RS_SCALE_SUBPEL_MASK`. |
| 20 | const RS_SCALE_SUBPEL_MASK: i64 = - 1; |
| 21 | /// `RS_SCALE_EXTRA_BITS`. |
| 22 | const RS_SCALE_EXTRA_BITS: u32 = RS_SCALE_SUBPEL_BITS - RS_SUBPEL_BITS; |
| 23 | /// `RS_SCALE_EXTRA_OFF`. |
| 24 | const RS_SCALE_EXTRA_OFF: i64 = 1i64 << ; |
| 25 | /// `UPSCALE_NORMATIVE_TAPS`. |
| 26 | const UPSCALE_NORMATIVE_TAPS: usize = 8; |
| 27 | /// `FILTER_BITS`. |
| 28 | const FILTER_BITS: u32 = 7; |
| 29 | |
| 30 | /// `av1_resize_filter_normative`, libaom `av1/common/resize.c`. 64 subpel |
| 31 | /// phases x 8 taps. |
| 32 | |
| 33 | const RESIZE_FILTER_NORMATIVE: = |
| 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 | |
| 68 | /// `av1_get_upscale_convolve_step` (`resize.c`). |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | /// `get_upscale_convolve_x0` (`resize.c`, static there). |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | /// `av1_convolve_horiz_rs_c` (`convolve.c`): `clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS))`. |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | /// One row of the spec 7.16 horizontal upscale (`upscale_normative_rect` + |
| 89 | /// `av1_convolve_horiz_rs_c`, single-tile case: `pad_left`/`pad_right` both |
| 90 | /// true, replicating the row's own edge pixels rather than sampling a |
| 91 | /// neighbour tile). `in_width` and `out_width` must both be positive; |
| 92 | /// `row.len() == in_width` and `out.len() == out_width`. |
| 93 | /// `bit_depth` only picks the output clamp (`clip_pixel`/`clip_pixel_highbd` |
| 94 | /// in libaom's `av1_convolve_horiz_rs_c`); the filter, its `Round2` and the |
| 95 | /// edge padding are bit-depth independent (spec 7.16). |
| 96 | pub |
| 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 | |
| 149 | /// Every row of one decoded plane, upscaled by spec 7.16 from `in_w` to |
| 150 | /// `out_w` (`av1_upscale_normative_rows`; the process is horizontal-only, |
| 151 | /// so the row count is unchanged). `data`/`stride` are the decoder's own |
| 152 | /// reconstruction buffer, whose columns `[in_w, true_w)` hold the real |
| 153 | /// decoded samples of the coding block straddling the frame edge -- libaom's |
| 154 | /// border extension replicates from that last real column, so they are |
| 155 | /// handed to [`upscale_row`] as its right margin (see its doc). |
| 156 | pub |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | thread_local! |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | /// Current value of [`SUPERRES_HITS`]. |
| 181 | |
| 182 | pub |
| 183 | |
| 184 | |
| 185 | |
| 186 | /// Counts one whole upscaled picture (all three planes) for [`SUPERRES_HITS`]. |
| 187 | pub |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 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 |