edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! Macroblock-adaptive frame/field decoding (MBAFF): macroblock pair |
| 2 | //! addressing and the neighbour derivation of clause 6.4.12.2 (Table 6-4). |
| 3 | //! |
| 4 | //! Layout. A frame picture with `MbaffFrameFlag` 1 codes macroblock *pairs*: |
| 5 | //! macroblock address `2 * pair + b` (b = 0 top, 1 bottom) of pair |
| 6 | //! `(px, pr)`. Every per-macroblock and per-4x4-block array of the |
| 7 | //! [`Picture`] is indexed by *slot*: the pair's top macroblock lives at slot |
| 8 | //! row `2 * pr` and its bottom macroblock at `2 * pr + 1`, whether the pair is |
| 9 | //! a frame pair or a field pair. A macroblock's own blocks are therefore |
| 10 | //! addressed exactly as in a progressive picture (block coordinates |
| 11 | //! `(4 * px + i, 4 * slot_y + j)`), and everything that reads *neighbouring* |
| 12 | //! data goes through [`locate`], the single implementation of Table 6-4. |
| 13 | //! |
| 14 | //! Samples are different: they live at their true picture position. A frame |
| 15 | //! macroblock covers 16 consecutive rows of its pair; a field macroblock |
| 16 | //! covers every second row of the 32-row pair, starting at row 0 (top) or 1 |
| 17 | //! (bottom), which a stride of two rows and a first-row offset express. |
| 18 | |
| 19 | use cratePicture; |
| 20 | use crateSample; |
| 21 | |
| 22 | /// Where the macroblock being decoded sits in an MBAFF frame. |
| 23 | |
| 24 | pub |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | /// A neighbouring luma (or chroma) location resolved by Table 6-4. |
| 47 | |
| 48 | pub |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | /// Which macroblock of the left pair a frame macroblock at the bottom of its |
| 59 | /// pair takes as its upper-left neighbour when the left pair is a field pair. |
| 60 | /// Table 6-4 reads `mbAddrA` (the top field macroblock) with |
| 61 | /// `yM = (yN + maxH) >> 1`. |
| 62 | const D_FRAME_BOTTOM_FIELD_LEFT_BOTTOM: bool = true; |
| 63 | |
| 64 | /// Clause 6.4.12.2: the macroblock and the position in it that cover the luma |
| 65 | /// (`maxw = maxh = 16`) or chroma (`8`) location `(xn, yn)` relative to the |
| 66 | /// current macroblock, or `None` when it is unavailable. |
| 67 | pub |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 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 | |
| 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 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 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 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | /// The 4x4 luma block left of (`left`) or above (`!left`) the block at global |
| 224 | /// block coordinates `(bx, by)` of the current macroblock, as global block |
| 225 | /// coordinates plus the neighbouring macroblock's field flag. |
| 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 | /// The same for a chroma 4x4 block of the `(mb_w * 2) x (mb_h * cbh)` grid, |
| 257 | /// where `cbh` is the number of chroma 4x4 block rows per macroblock (2 for |
| 258 | /// 4:2:0, 4 for 4:2:2; the chroma macroblock is `8` wide and `4 * cbh` high). |
| 259 | pub |
| 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 | /// Slot of the macroblock containing the neighbouring location, for the |
| 290 | /// macroblock-level neighbours A (`(-1, 0)`) and B (`(0, -1)`) of 6.4.9. |
| 291 | pub |
| 292 | |
| 293 | |
| 294 | |
| 295 | /// See [`mb_a`]. |
| 296 | pub |
| 297 | |
| 298 | |
| 299 | |
| 300 | /// 7.4.4 inference of `mb_field_decoding_flag` for a pair that does not code |
| 301 | /// it: the left pair of the same slice, else the pair above, else frame. |
| 302 | pub |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 |