euv_core/media/video/struct.rs
1use super::*;
2
3/// Color space, transfer curve, matrix coefficients, range, and HDR mastering metadata preserved across decode and presentation.
4#[derive(Clone, Copy, Data, Debug, Deserialize, Eq, Hash, New, PartialEq, Serialize)]
5pub struct VideoColorInfo {
6 /// Color primaries gamut (`BT.709`, `BT.2020`, `DisplayP3`, `BT.601`).
7 #[get(type(copy))]
8 pub(crate) primaries: ColorPrimaries,
9 /// Electro-optical transfer function (`BT.709`, `sRGB`, `PQ ST.2084`, `HLG`).
10 #[get(type(copy))]
11 pub(crate) transfer: TransferCharacteristics,
12 /// YCbCr-to-RGB matrix coefficients.
13 #[get(type(copy))]
14 pub(crate) matrix: MatrixCoefficients,
15 /// Signal quantization range (`Limited` or `Full`).
16 #[get(type(copy))]
17 pub(crate) range: ColorRange,
18 /// Bits per color component (`8`, `10`, or `12`).
19 #[get(type(copy))]
20 pub(crate) bit_depth: u8,
21 /// Maximum Content Light Level (`MaxCLL`) in nits (`0` when unspecified).
22 #[get(type(copy))]
23 pub(crate) max_cll_nits: u16,
24 /// Maximum Frame-Average Light Level (`MaxFALL`) in nits (`0` when unspecified).
25 #[get(type(copy))]
26 pub(crate) max_fall_nits: u16,
27}
28
29/// Capability report advertised by a hardware or software video decoder backend.
30#[derive(Clone, Copy, Data, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
31pub struct HardwareDecoderCapabilities {
32 /// Decoder backend kind.
33 #[get(type(copy))]
34 pub(crate) kind: HardwareDecoderKind,
35 /// `true` when decoded surfaces map directly to GPU textures without CPU readback.
36 #[get(type(copy))]
37 pub(crate) zero_copy_gpu_interop: bool,
38 /// Whether H.264/AVC decoding is supported.
39 #[get(type(copy))]
40 pub(crate) supports_h264: bool,
41 /// Whether H.265/HEVC decoding is supported.
42 #[get(type(copy))]
43 pub(crate) supports_h265: bool,
44 /// Whether VP9 decoding is supported.
45 #[get(type(copy))]
46 pub(crate) supports_vp9: bool,
47 /// Whether AV1 decoding is supported.
48 #[get(type(copy))]
49 pub(crate) supports_av1: bool,
50 /// Whether 10-bit PQ/HLG HDR pipelines are supported.
51 #[get(type(copy))]
52 pub(crate) supports_hdr10: bool,
53 /// Maximum supported coded width in pixels.
54 #[get(type(copy))]
55 pub(crate) max_width: u32,
56 /// Maximum supported coded height in pixels.
57 #[get(type(copy))]
58 pub(crate) max_height: u32,
59}
60
61/// Stateless platform probe identifying the target OS hardware decode backend and host fallback capabilities.
62#[derive(Clone, Copy, Debug, Default)]
63pub struct HardwareDecoderProbe;
64
65/// Zero-copy GPU texture/surface interop handle for hardware-decoded video frames (`CVPixelBuffer`, `AHardwareBuffer`, `DMA-BUF`, `ID3D11Texture2D`, `VideoFrame`).
66#[derive(Clone, Copy, Data, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
67pub struct VideoGpuSurfaceHandle {
68 /// Backend-opaque surface or texture handle identifier.
69 #[get(type(copy))]
70 pub(crate) surface_id: u64,
71 /// Target GPU device identifier.
72 #[get(type(copy))]
73 pub(crate) device_id: u64,
74 /// Generation counter preventing stale handle reuse across seeks or device loss.
75 #[get(type(copy))]
76 pub(crate) generation: u64,
77 /// Frame width in pixels.
78 #[get(type(copy))]
79 pub(crate) width: u32,
80 /// Frame height in pixels.
81 #[get(type(copy))]
82 pub(crate) height: u32,
83 /// Hardware surface pixel layout (`Nv12`, `P010`, `Bgra8`, `Rgba8`).
84 #[get(type(copy))]
85 pub(crate) pixel_format: VideoPixelFormat,
86 /// Color space and HDR metadata bound to this GPU surface.
87 #[get(type(copy))]
88 pub(crate) color_info: VideoColorInfo,
89 /// Synchronization fence value signaled when GPU decode writes complete.
90 #[get(type(copy))]
91 pub(crate) fence_value: u64,
92 /// `true` when the surface is sampled directly by the compositor without CPU readback.
93 #[get(type(copy))]
94 pub(crate) zero_copy: bool,
95 /// Hardware backend that produced this surface.
96 #[get(type(copy))]
97 pub(crate) backend: HardwareDecoderKind,
98}
99
100/// Pooled CPU RGBA8 video frame buffer checked out from a bounded `VideoFramePool`.
101#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
102pub struct PooledVideoFrame {
103 /// Originating pool slot identifier for telemetry and debugging.
104 #[get(type(copy))]
105 pub(crate) slot_id: usize,
106 /// Frame width in pixels.
107 #[get(type(copy))]
108 pub(crate) width: u32,
109 /// Frame height in pixels.
110 #[get(type(copy))]
111 pub(crate) height: u32,
112 /// Reusable packed RGBA8 pixel storage (`width * height * 4`).
113 pub(crate) pixels: Vec<u8>,
114}
115
116/// Telemetry snapshot summarizing `VideoFramePool` capacity, reuse hits, allocations, and copy volume.
117#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
118pub struct VideoFramePoolStats {
119 /// Maximum bounded slot capacity of the pool.
120 #[get(type(copy))]
121 pub(crate) capacity: usize,
122 /// Number of pooled buffers currently checked out.
123 #[get(type(copy))]
124 pub(crate) in_use: usize,
125 /// Number of free reusable buffers parked inside the pool.
126 #[get(type(copy))]
127 pub(crate) available: usize,
128 /// Total cold heap allocations performed since pool creation.
129 #[get(type(copy))]
130 pub(crate) allocations: u64,
131 /// Total steady-state buffer checkouts satisfied via reuse without reallocation.
132 #[get(type(copy))]
133 pub(crate) reuse_hits: u64,
134 /// Total checkout attempts rejected due to bounded pool exhaustion.
135 #[get(type(copy))]
136 pub(crate) backpressure_rejects: u64,
137 /// Total recycled frames returned into the pool.
138 #[get(type(copy))]
139 pub(crate) recycled_count: u64,
140}
141
142/// Internal state protected by synchronization primitives inside `VideoFramePool`.
143#[derive(Clone, Data, Debug, Default)]
144pub(crate) struct VideoFramePoolState {
145 /// Maximum bounded number of buffers owned or checked out simultaneously.
146 #[get(type(copy))]
147 pub(crate) capacity: usize,
148 /// Number of buffers currently checked out by decoders or queues.
149 #[get(type(copy))]
150 pub(crate) in_use: usize,
151 /// Next unique slot identifier assigned to newly allocated buffers.
152 #[get(type(copy))]
153 pub(crate) next_slot_id: usize,
154 /// Free buffers parked for zero-allocation steady-state reuse.
155 pub(crate) free_buffers: Vec<PooledVideoFrame>,
156 /// Cumulative cold heap allocations performed.
157 #[get(type(copy))]
158 pub(crate) allocations: u64,
159 /// Cumulative reuse hits satisfied from `free_buffers`.
160 #[get(type(copy))]
161 pub(crate) reuse_hits: u64,
162 /// Cumulative bounded backpressure rejections.
163 #[get(type(copy))]
164 pub(crate) backpressure_rejects: u64,
165 /// Cumulative returned buffers.
166 #[get(type(copy))]
167 pub(crate) recycled_count: u64,
168}
169
170/// Thread-safe (native) or single-threaded (wasm32) bounded reusable CPU RGBA8 video frame pool.
171#[derive(Clone, CustomDebug)]
172pub struct VideoFramePool {
173 /// Synchronized internal pool state on native targets.
174 #[cfg(not(target_arch = "wasm32"))]
175 pub(crate) inner: Arc<Mutex<VideoFramePoolState>>,
176 /// Interior-mutable internal pool state on WebAssembly targets.
177 #[cfg(target_arch = "wasm32")]
178 pub(crate) inner: Rc<RefCell<VideoFramePoolState>>,
179}
180
181/// Single parsed MP4/ISOBMFF sample table record with exact DTS, PTS (including `ctts`), byte range, and keyframe flag.
182#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
183pub struct Mp4Sample {
184 /// Zero-based sample index in decode order.
185 #[get(type(copy))]
186 pub(crate) index: usize,
187 /// Decoding timestamp in microseconds.
188 #[get(type(copy))]
189 pub(crate) dts_us: i64,
190 /// Presentation timestamp in microseconds (`dts_us + composition_offset_us`).
191 #[get(type(copy))]
192 pub(crate) pts_us: i64,
193 /// Sample display duration in microseconds.
194 #[get(type(copy))]
195 pub(crate) duration_us: u64,
196 /// Byte offset inside the MP4 container buffer.
197 #[get(type(copy))]
198 pub(crate) byte_offset: u64,
199 /// Encoded sample byte size.
200 #[get(type(copy))]
201 pub(crate) byte_size: u32,
202 /// `true` when this sample is a random-access sync keyframe (`stss`).
203 #[get(type(copy))]
204 pub(crate) is_keyframe: bool,
205}
206
207/// Metadata extracted for an MP4/ISOBMFF video or audio track.
208#[derive(Clone, Data, Debug, Default, PartialEq)]
209pub struct Mp4TrackInfo {
210 /// ISOBMFF track identifier from `tkhd`.
211 #[get(type(copy))]
212 pub(crate) track_id: u32,
213 /// True for a `vide` track, false for a `soun` track.
214 #[get(type(copy))]
215 pub(crate) is_video: bool,
216 /// Detected video codec when `is_video == true`.
217 #[get(type(copy))]
218 pub(crate) video_codec: VideoCodec,
219 /// Detected audio codec when `is_video == false`.
220 #[get(type(copy))]
221 pub(crate) audio_codec: AudioCodec,
222 /// FourCC codec box tag (e.g. `"avc1"`, `"hvc1"`, `"rawv"`, `"mp4a"`).
223 pub(crate) codec_fourcc: String,
224 /// Coded or display pixel width (`0` for audio tracks).
225 #[get(type(copy))]
226 pub(crate) width: u32,
227 /// Coded or display pixel height (`0` for audio tracks).
228 #[get(type(copy))]
229 pub(crate) height: u32,
230 /// Media timescale in ticks per second from `mdhd`.
231 #[get(type(copy))]
232 pub(crate) timescale: u32,
233 /// Track duration in microseconds.
234 #[get(type(copy))]
235 pub(crate) duration_us: u64,
236 /// Audio sample rate in Hz (`0` for video tracks).
237 #[get(type(copy))]
238 pub(crate) sample_rate_hz: u32,
239 /// Audio channel count (`0` for video tracks).
240 #[get(type(copy))]
241 pub(crate) channels: u16,
242 /// Color primaries, transfer function, matrix, and HDR metadata parsed from `colr`/`nclx`.
243 #[get(type(copy))]
244 pub(crate) color_info: VideoColorInfo,
245 /// Complete ordered sample index built from `stts`, `ctts`, `stss`, `stsc`, `stsz`, and `stco`/`co64`.
246 pub(crate) samples: Vec<Mp4Sample>,
247}
248
249/// Parsed pure-Rust MP4/ISOBMFF container demuxer supporting random-access keyframe seek and packet extraction.
250#[derive(Clone, Data, Debug, Default, PartialEq)]
251pub struct Mp4Demuxer {
252 /// Shared zero-copy backing MP4 container bytes.
253 #[get(skip)]
254 #[get_mut(skip)]
255 #[set(skip)]
256 pub(crate) bytes: Arc<[u8]>,
257 /// Major brand FourCC parsed from `ftyp` (e.g. `"isom"`, `"mp42"`).
258 pub(crate) major_brand: String,
259 /// Compatible brands listed in `ftyp`.
260 pub(crate) compatible_brands: Vec<String>,
261 /// Movie-level timescale from `mvhd`.
262 #[get(type(copy))]
263 pub(crate) movie_timescale: u32,
264 /// Movie-level total duration in microseconds from `mvhd`.
265 #[get(type(copy))]
266 pub(crate) movie_duration_us: u64,
267 /// Primary parsed video track metadata and sample table.
268 pub(crate) video_track: Mp4TrackInfo,
269 /// Optional parsed audio track metadata and sample table.
270 #[get(skip)]
271 pub(crate) audio_track: Option<Mp4TrackInfo>,
272}
273
274/// Input sample specification consumed by `Mp4ContainerBuilder` to emit valid ISOBMFF MP4 files.
275#[derive(Clone, Data, Debug, Default, PartialEq)]
276pub struct Mp4BuilderSample {
277 /// Sample duration in track timescale ticks (`stts`).
278 #[get(type(copy))]
279 pub(crate) duration_ticks: u32,
280 /// Composition time offset in track timescale ticks (`ctts`, added to DTS to obtain PTS).
281 #[get(type(copy))]
282 pub(crate) composition_offset_ticks: i32,
283 /// Whether this sample is a keyframe listed in `stss`.
284 #[get(type(copy))]
285 pub(crate) is_keyframe: bool,
286 /// Encoded sample payload bytes stored in `mdat`.
287 pub(crate) payload: Vec<u8>,
288}
289
290/// Stateless pure-Rust ISOBMFF MP4 container builder producing spec-compliant `ftyp`/`moov`/`mdat` byte streams.
291#[derive(Clone, Copy, Debug, Default)]
292pub struct Mp4ContainerBuilder;
293
294/// Decoder initialization descriptor derived from an MP4 video track.
295#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
296pub struct VideoDecoderConfig {
297 /// Target video codec.
298 #[get(type(copy))]
299 pub(crate) codec: VideoCodec,
300 /// Coded frame width in pixels.
301 #[get(type(copy))]
302 pub(crate) width: u32,
303 /// Coded frame height in pixels.
304 #[get(type(copy))]
305 pub(crate) height: u32,
306 /// Track color primaries, transfer curve, matrix, range, and HDR metadata.
307 #[get(type(copy))]
308 pub(crate) color_info: VideoColorInfo,
309}
310
311/// Demuxed video packet submitted to a `VideoDecoderBackend`.
312#[derive(Clone, Data, Debug, Default)]
313pub struct EncodedVideoPacket {
314 /// Zero-based sample index inside the track.
315 #[get(type(copy))]
316 pub(crate) sample_index: usize,
317 /// Seek/pipeline generation tag preventing stale pre-seek packets from rendering.
318 #[get(type(copy))]
319 pub(crate) generation: u64,
320 /// Decoding timestamp in microseconds.
321 #[get(type(copy))]
322 pub(crate) dts_us: i64,
323 /// Presentation timestamp in microseconds.
324 #[get(type(copy))]
325 pub(crate) pts_us: i64,
326 /// Frame duration in microseconds.
327 #[get(type(copy))]
328 pub(crate) duration_us: u64,
329 /// `true` when this packet is an intra keyframe.
330 #[get(type(copy))]
331 pub(crate) is_keyframe: bool,
332 /// Zero-copy shared backing buffer containing encoded packet bytes.
333 #[get(skip)]
334 #[get_mut(skip)]
335 #[set(skip)]
336 pub(crate) source: Arc<[u8]>,
337 /// Inclusive byte offset where this packet starts inside `source`.
338 #[get(type(copy))]
339 pub(crate) byte_start: usize,
340 /// Exclusive byte offset where this packet ends inside `source`.
341 #[get(type(copy))]
342 pub(crate) byte_end: usize,
343}
344
345/// Decoded video frame ordered by presentation timestamp (`pts_us`) with color/HDR metadata and GPU or pooled CPU backing.
346#[derive(Clone, Data, Debug, PartialEq)]
347pub struct DecodedVideoFrame {
348 /// Zero-based source sample index.
349 #[get(type(copy))]
350 pub(crate) sample_index: usize,
351 /// Seek/pipeline generation tag verifying freshness after seeks.
352 #[get(type(copy))]
353 pub(crate) generation: u64,
354 /// Decoding timestamp in microseconds.
355 #[get(type(copy))]
356 pub(crate) dts_us: i64,
357 /// Presentation timestamp in microseconds.
358 #[get(type(copy))]
359 pub(crate) pts_us: i64,
360 /// Frame display duration in microseconds.
361 #[get(type(copy))]
362 pub(crate) duration_us: u64,
363 /// Decoded pixel width.
364 #[get(type(copy))]
365 pub(crate) width: u32,
366 /// Decoded pixel height.
367 #[get(type(copy))]
368 pub(crate) height: u32,
369 /// Color primaries, transfer curve, matrix, and HDR metadata.
370 #[get(type(copy))]
371 pub(crate) color_info: VideoColorInfo,
372 /// Frame pixel backing (`GpuSurface` zero-copy handle or `CpuPooled` buffer).
373 pub(crate) backing: VideoFrameBacking,
374}
375
376/// Pure-Rust software fallback decoder handling intra RGBA8, intra YUV420P (with full CICP color matrix math), and P-frame XOR delta packets.
377#[derive(Clone, Data, Debug, Default)]
378pub struct SoftwareVideoDecoder {
379 /// Active configured track metadata.
380 #[get(type(copy))]
381 pub(crate) config: VideoDecoderConfig,
382 /// Last decoded RGBA8 reference frame retained for P-frame delta reconstruction.
383 #[get(skip)]
384 #[get_mut(skip)]
385 #[set(skip)]
386 pub(crate) reference_rgba: Vec<u8>,
387 /// Whether `reference_rgba` currently holds a valid decoded frame since the last flush.
388 #[get(type(copy))]
389 pub(crate) has_reference: bool,
390 /// Total frames decoded by this software decoder instance.
391 #[get(type(copy))]
392 pub(crate) decoded_frames: u64,
393}
394
395/// Zero-copy GPU interop hardware decoder adapter producing `VideoGpuSurfaceHandle` frames without CPU readback.
396#[derive(Clone, Data, Debug, Default)]
397pub struct HardwareZeroCopyDecoder {
398 /// Target platform hardware backend kind (`VideoToolbox`, `MediaCodec`, `Vaapi`, `Dxva`, `WebCodecs`).
399 #[get(type(copy))]
400 pub(crate) kind: HardwareDecoderKind,
401 /// Target GPU device identifier.
402 #[get(type(copy))]
403 pub(crate) device_id: u64,
404 /// Preferred GPU hardware surface pixel layout (`Nv12` for SDR, `P010` for HDR10).
405 #[get(type(copy))]
406 pub(crate) pixel_format: VideoPixelFormat,
407 /// Active configured video track metadata.
408 #[get(type(copy))]
409 pub(crate) config: VideoDecoderConfig,
410 /// Monotonic GPU surface handle counter.
411 #[get(type(copy))]
412 pub(crate) next_surface_id: u64,
413 /// Monotonic GPU synchronization fence value.
414 #[get(type(copy))]
415 pub(crate) next_fence_value: u64,
416}
417
418/// Bounded presentation-timestamp-ordered decoded frame queue supporting B-frame reordering and generation-tagged seek draining.
419#[derive(Clone, Data, Debug, Default)]
420pub struct PtsFrameQueue {
421 /// Maximum frames retained simultaneously in the queue.
422 #[get(type(copy))]
423 pub(crate) capacity: usize,
424 /// Frames maintained in strictly non-decreasing `pts_us` order for O(1) front pop and in-place retention.
425 pub(crate) frames: VecDeque<DecodedVideoFrame>,
426 /// Total frames discarded because their `generation` was older than an active seek.
427 #[get(type(copy))]
428 pub(crate) stale_generation_drops: u64,
429}
430
431/// Audio-master / monotonic-clock A/V synchronization scheduler that preserves source video cadence without forging frames on high-refresh displays.
432#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
433pub struct AvSyncScheduler {
434 /// Active synchronization clock source (`AudioMaster` or `MonotonicFallback`).
435 #[get(type(copy))]
436 pub(crate) clock_source: AvSyncClockSource,
437 /// Active playback clock position in microseconds.
438 #[get(type(copy))]
439 pub(crate) clock_pts_us: i64,
440 /// Playback speed multiplier (`0.25..=4.0`).
441 #[get(type(copy))]
442 pub(crate) playback_rate: f32,
443 /// Maximum frame lateness threshold in microseconds before dropping stale frames.
444 #[get(type(copy))]
445 pub(crate) max_late_us: i64,
446 /// PTS of the most recently presented frame (`None` before first frame or after seek).
447 #[get(skip)]
448 pub(crate) last_presented_pts_us: Option<i64>,
449 /// Count of distinct video frames newly presented to the display.
450 #[get(type(copy))]
451 pub(crate) frames_presented: u64,
452 /// Count of VSync ticks that held the existing frame because the next PTS was not yet due.
453 #[get(type(copy))]
454 pub(crate) frames_held_vsync: u64,
455 /// Count of overdue queued frames dropped to recover A/V sync.
456 #[get(type(copy))]
457 pub(crate) frames_dropped_late: u64,
458}
459
460/// Shared worker coordination state between the UI thread and the background decode worker thread.
461#[cfg(not(target_arch = "wasm32"))]
462#[derive(CustomDebug, Data)]
463pub(crate) struct VideoWorkerShared {
464 /// Bounded PTS-ordered decoded frame queue filled by the worker thread.
465 pub(crate) queue: PtsFrameQueue,
466 /// Active seek generation counter; increments invalidate in-flight older frames.
467 #[get(type(copy))]
468 pub(crate) active_generation: u64,
469 /// Next demux sample index queued for decode.
470 #[get(type(copy))]
471 pub(crate) next_sample_index: usize,
472 /// Target presentation timestamp after a seek; frames earlier than this during keyframe preroll are discarded.
473 #[get(type(copy))]
474 pub(crate) seek_preroll_target_us: i64,
475 /// Pending seek request `(new_generation, keyframe_index, target_pts_us)` consumed by the worker.
476 #[get(skip)]
477 pub(crate) pending_seek: Option<(u64, usize, i64)>,
478 /// Whether the pipeline is actively decoding.
479 #[get(type(copy))]
480 pub(crate) playing: bool,
481 /// Whether the worker reached the end of the demuxed sample stream for the active generation.
482 #[get(type(copy))]
483 pub(crate) reached_eos: bool,
484 /// Whether the worker thread should exit cleanly.
485 #[get(type(copy))]
486 pub(crate) shutdown: bool,
487 /// Total packets decoded by the background worker.
488 #[get(type(copy))]
489 pub(crate) packets_decoded: u64,
490 /// Total preroll frames decoded and discarded before reaching `seek_preroll_target_us`.
491 #[get(type(copy))]
492 pub(crate) seek_preroll_frames_discarded: u64,
493 /// Last decode error string reported by the worker, if any.
494 #[get(skip)]
495 pub(crate) last_error: Option<String>,
496}
497
498/// Asynchronous multi-threaded (native) / deterministic pumpable (wasm32) structured video playback pipeline.
499#[derive(CustomDebug)]
500pub struct VideoPlaybackPipeline {
501 /// Shared parsed MP4/ISOBMFF demuxer providing metadata and zero-copy random-access sample lookup.
502 pub(crate) demuxer: Arc<Mp4Demuxer>,
503 /// Bounded reusable CPU RGBA8 pixel buffer pool.
504 pub(crate) pool: VideoFramePool,
505 /// Audio-master / monotonic A/V synchronization scheduler.
506 pub(crate) scheduler: AvSyncScheduler,
507 /// Active hardware or software decoder backend kind.
508 pub(crate) backend_kind: HardwareDecoderKind,
509 /// Track color primaries, transfer curve, matrix, and HDR metadata.
510 pub(crate) color_info: VideoColorInfo,
511 /// Active playback transport state (`Idle`, `Playing`, `Paused`, `Ended`, `Error`).
512 pub(crate) state: PlaybackState,
513 /// Currently displayed decoded video frame held across intermediate VSync ticks.
514 pub(crate) current_frame: Option<DecodedVideoFrame>,
515 /// Active seek generation counter mirrored on the controller thread.
516 pub(crate) active_generation: u64,
517 /// Shared synchronization tuple `(state, condvar, fast_hold_hint_pts_us)` coordinating the background decode worker on native targets.
518 #[cfg(not(target_arch = "wasm32"))]
519 #[debug(skip)]
520 pub(crate) worker_shared: Arc<(Mutex<VideoWorkerShared>, Condvar, AtomicU64)>,
521 /// Owned background decode thread handle joined cleanly on `Drop`.
522 #[cfg(not(target_arch = "wasm32"))]
523 #[debug(skip)]
524 pub(crate) worker_handle: Option<JoinHandle<()>>,
525 /// Single-threaded decoder instance used on WebAssembly targets.
526 #[cfg(target_arch = "wasm32")]
527 #[debug(skip)]
528 pub(crate) wasm_decoder: Box<dyn VideoDecoderBackend>,
529 /// Bounded PTS queue used on WebAssembly targets.
530 #[cfg(target_arch = "wasm32")]
531 pub(crate) wasm_queue: PtsFrameQueue,
532 /// Next demux sample index on WebAssembly targets.
533 #[cfg(target_arch = "wasm32")]
534 pub(crate) wasm_next_sample: usize,
535 /// Seek preroll target timestamp on WebAssembly targets.
536 #[cfg(target_arch = "wasm32")]
537 pub(crate) wasm_preroll_target_us: i64,
538 /// End-of-stream flag on WebAssembly targets.
539 #[cfg(target_arch = "wasm32")]
540 pub(crate) wasm_eos: bool,
541 /// Total packets decoded on WebAssembly targets.
542 #[cfg(target_arch = "wasm32")]
543 pub(crate) wasm_packets_decoded: u64,
544 /// Total preroll frames discarded during seek on WebAssembly targets.
545 #[cfg(target_arch = "wasm32")]
546 pub(crate) wasm_preroll_discarded: u64,
547 /// Last decode error on WebAssembly targets.
548 #[cfg(target_arch = "wasm32")]
549 pub(crate) wasm_last_error: Option<String>,
550}
551
552/// Internal accumulator populated while parsing an ISOBMFF `stbl` box hierarchy.
553#[derive(Clone, Data, Debug, Default)]
554pub(crate) struct Mp4SampleTableRaw {
555 /// `(sample_count, sample_delta_ticks)` pairs parsed from `stts`.
556 pub(crate) stts: Vec<(u32, u32)>,
557 /// `(sample_count, composition_offset_ticks)` pairs parsed from `ctts`.
558 pub(crate) ctts: Vec<(u32, i32)>,
559 /// 1-based sync keyframe sample numbers parsed from `stss`.
560 pub(crate) stss: Vec<u32>,
561 /// `(first_chunk, samples_per_chunk)` pairs parsed from `stsc`.
562 pub(crate) stsc: Vec<(u32, u32)>,
563 /// Constant sample size from `stsz` (`0` when per-sample sizes are present).
564 #[get(type(copy))]
565 pub(crate) default_sample_size: u32,
566 /// Declared total sample count from `stsz`.
567 #[get(type(copy))]
568 pub(crate) sample_count: u32,
569 /// Per-sample byte sizes parsed from `stsz`.
570 pub(crate) sample_sizes: Vec<u32>,
571 /// Chunk byte offsets parsed from `stco` or `co64`.
572 pub(crate) chunk_offsets: Vec<u64>,
573}