edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB7cdaf34Tahinli3 months ago29 commits
| 1 | //! Opus decoding (RFC 6716, with the RFC 8251 corrections). |
| 2 | //! |
| 3 | //! Opus is two codecs behind one entropy coder: a linear-prediction layer |
| 4 | //! (SILK) for speech up to 8 kHz of bandwidth, and an MDCT layer (CELT) for |
| 5 | //! everything above that and for music. A packet's table-of-contents byte picks |
| 6 | //! one of them or both, and this crate decodes all three cases plus the |
| 7 | //! multistream framing that carries 5.1 and 7.1. |
| 8 | //! |
| 9 | //! Contracts worth knowing before implementing against this crate: |
| 10 | //! |
| 11 | //! - **The MDCT is the shared one.** CELT synthesis runs through |
| 12 | //! [`ec_dsp::Mdct`], never a direct-form DFT. An incumbent Opus decoder in |
| 13 | //! this product shipped its FFT behind a default-off feature and ran at 0.95x |
| 14 | //! realtime on 5.1; there is no such switch here, and no code path that could |
| 15 | //! answer to one. |
| 16 | //! - **Malformed input is an error, never a panic.** Framing rules [R1]..[R7] |
| 17 | //! are checked in [`packet`], and the range decoder feeds zeros past the end |
| 18 | //! of a truncated frame exactly as Section 4.1.2.1 requires. |
| 19 | //! - **Output is `f32`, interleaved, at the rate you asked for.** 48, 24, 16, |
| 20 | //! 12 and 8 kHz are supported; SILK's internal rate is resampled up and the |
| 21 | //! sum of the two layers is resampled down once, at the end. |
| 22 | //! |
| 23 | //! No unsafe, no allocation on the per-frame path beyond the decoder's own |
| 24 | //! buffers, no dependencies outside the family. |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | pub use CeltDecoder; |
| 34 | pub use ; |
| 35 | pub use RangeDecoder; |
| 36 | |
| 37 | use ; |
| 38 | |
| 39 | /// One Opus stream: mono or stereo, any mode, any frame size. |
| 40 | /// |
| 41 | /// Feed whole Opus packets to [`Decoder::decode_float`]; the decoder tracks the |
| 42 | /// inter-frame state (energy history, MDCT overlap, LPC memory) that Opus needs |
| 43 | /// across packets, so packets must be delivered in order. |
| 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 | |
| 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 |