edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | // Copyright 2022 The ChromiumOS Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | use Borrow; |
| 6 | use PhantomData; |
| 7 | use Rc; |
| 8 | |
| 9 | use cratebindings; |
| 10 | use crateBuffer; |
| 11 | use crateContext; |
| 12 | use crateSurface; |
| 13 | use crateva_check; |
| 14 | use crateImage; |
| 15 | use crateSurfaceMemoryDescriptor; |
| 16 | use crateVaError; |
| 17 | |
| 18 | // Use the sealed trait pattern to make sure that new states are not created in caller code. More |
| 19 | // information about the sealed trait pattern can be found at |
| 20 | // <https://rust-lang.github.io/api-guidelines/future-proofing.html#sealed-traits-protect-against-downstream-implementations-c-sealed> |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | /// A `Picture` will only have valid YUV data after a sequence of operations are performed in a |
| 26 | /// particular order. This order correspond to the following VA-API calls: `vaBeginPicture`, |
| 27 | /// `vaRenderPicture`, `vaEndPicture` and `vaSyncSurface`. This trait enforces this ordering by |
| 28 | /// implementing the Typestate pattern to constrain what operations are available in what particular |
| 29 | /// states. |
| 30 | /// |
| 31 | /// The states for the state machine are: |
| 32 | /// |
| 33 | /// * PictureNew -> PictureBegin |
| 34 | /// * PictureBegin -> PictureRender |
| 35 | /// * PictureRender ->PictureEnd |
| 36 | /// * PictureEnd -> PictureSync |
| 37 | /// |
| 38 | /// Where the surface can be reclaimed in both `PictureNew` and `PictureSync`, as either no |
| 39 | /// operation took place (as in `PictureNew`), or it is guaranteed that the operation has already |
| 40 | /// completed (as in `PictureSync`). |
| 41 | /// |
| 42 | /// More information about the Typestate pattern can be found at |
| 43 | /// <http://cliffle.com/blog/rust-typestate/> |
| 44 | |
| 45 | |
| 46 | /// Represents a `Picture` that has just been created. |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | /// Represents a `Picture` after `vaBeginPicture` has been called. |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | /// Represents a `Picture` after `vaRenderPicture` has been called. |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | /// Represents a `Picture` after `vaEndPicture` has been called. |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | /// Represents a `Picture` after `vaSyncSurface` has been called on the underlying surface. |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | /// Represents a state where one can reclaim the underlying `Surface` for this `Picture`. This is |
| 72 | /// true when either no decoding has been initiated or, alternatively, when the decoding operation |
| 73 | /// has completed for the underlying `vaSurface` |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | /// Inner type for [`Picture`], that is, the part that exists in all states. |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | /// A `Surface` that is being rendered into. |
| 92 | /// |
| 93 | /// This struct abstracts the decoding flow using `vaBeginPicture`, `vaRenderPicture`, |
| 94 | /// `vaEndPicture` and `vaSyncSurface` in a type-safe way. |
| 95 | /// |
| 96 | /// The surface will have valid picture data after all the stages of decoding are called. |
| 97 | /// |
| 98 | /// The `T` generic parameter must be `Borrow<Surface<_>>`, i.e. it can be [`Surface`] directly or |
| 99 | /// some other type that contains one. |
| 100 | /// |
| 101 | /// No constraint on `T` is specified in this declaration because specifying it here would force us |
| 102 | /// to add the generic argument of [`Surface`] to this type as well, turning it into a type with 3 |
| 103 | /// generics, one of which is redundant. To avoid that we leave `T` unconstrained and instead |
| 104 | /// constrain the methods that require to act on it as a [`Surface`]. |
| 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 | |
| 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 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 |