edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB052d1d3Tahinli2 months ago3627 commits
| 1 | //! Native VP9 decoder: all four profiles, 8/10/12-bit, and every coded |
| 2 | //! subsampling (4:2:0, 4:2:2, 4:4:0, 4:4:4). |
| 3 | //! |
| 4 | //! The crate implements the VP9 bitstream specification directly |
| 5 | //! ([spec]); libvpx's output is used only as a test oracle |
| 6 | //! (sample-exactness witnesses against ffmpeg's libvpx-based decoder), |
| 7 | //! never as code linked at runtime. Every module documents the spec |
| 8 | //! section it implements. Inter frames decode through motion compensation, |
| 9 | //! residual reconstruction and the loop filter; intra-only frames and |
| 10 | //! scaled references are supported too. |
| 11 | //! |
| 12 | //! Planes are stored as `u16` for every depth ([`Sample`]); kernels take the |
| 13 | //! frame's `bd` and clamp with `clip_pixel_bd`, so one decode walk serves |
| 14 | //! every depth and subsampling. The only depth-dependent bitstream element is |
| 15 | //! the CAT6 coefficient token (14 bits/`vp9_cat6_prob` at 8-bit, 16 bits/ |
| 16 | //! `vp9_cat6_prob_high12 + 2` at 10-bit, 18 bits/`vp9_cat6_prob_high12` at |
| 17 | //! 12-bit). |
| 18 | //! |
| 19 | //! [spec]: https://www.webmproject.org/docs/vp9/ |
| 20 | //! |
| 21 | //! # Unsafe |
| 22 | //! |
| 23 | //! This crate contains no `unsafe` code. |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | pub |
| 32 | |
| 33 | |
| 34 | pub |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | pub use ; |
| 42 | |
| 43 | /// A reconstructed sample. Planes are stored as `u16` for EVERY bit depth |
| 44 | /// (8-bit values occupy the low byte), so profile-0 and profile-2 frames share |
| 45 | /// one representation and one decode walk; the kernels take the frame's |
| 46 | /// `bd` and clamp with [`clip_pixel_bd`]. |
| 47 | pub type Sample = u16; |
| 48 | |
| 49 | /// `clip_pixel_highbd` (`vpx_dsp/vpx_dsp_common.h`): clamp to `[0, (1<<bd)-1]`. |
| 50 | /// For `bd == 8` this is libvpx's `clip_pixel` exactly. |
| 51 | |
| 52 | pub |
| 53 | |
| 54 | |
| 55 | |
| 56 | /// `ROUND_POWER_OF_TWO(v, n)` (`vpx_dsp/txfm_common.h`, arithmetic shift). |
| 57 | |
| 58 | pub |
| 59 | |
| 60 | |
| 61 | |
| 62 | /// Whether `EC_VP9_TRACE` decision tracing is enabled, resolved once per |
| 63 | /// process. An `var_os` per bool read would lock std's ENV lock on every |
| 64 | /// coefficient; the hot path is a single relaxed atomic load. |
| 65 | pub |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | /// Cached `getenv` probe: `EC_VP9_*` gates are consulted per block, per MV |
| 80 | /// component and per switchable-interp read, and `std::env::var_os` locks std's |
| 81 | /// ENV lock, so each gate resolves once per process and the hot path is a |
| 82 | /// single relaxed atomic load (see `trace_enabled`). |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | // Per-block dump gate for the inter-syntax lane (scratch harnesses); |
| 102 | // a candidate-list dump (`mode == NEWMV` only); |
| 103 | // a search-position cell + grid-store dump; and a post-compressed-header |
| 104 | // MV probability table dump. (Plain comments: a doc comment on a macro |
| 105 | // invocation is an "unused doc comment" warning.) |
| 106 | cached_gate!; |
| 107 | cached_gate!; |
| 108 | cached_gate!; |
| 109 | cached_gate!; |
| 110 | // [scratch] per-transform-block token state (the inter pixel lane). |
| 111 | cached_gate!; |
| 112 | cached_gate!; |