Skip to main content

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    /// Backing MP4 container bytes.
253    pub(crate) bytes: Vec<u8>,
254    /// Major brand FourCC parsed from `ftyp` (e.g. `"isom"`, `"mp42"`).
255    pub(crate) major_brand: String,
256    /// Compatible brands listed in `ftyp`.
257    pub(crate) compatible_brands: Vec<String>,
258    /// Movie-level timescale from `mvhd`.
259    #[get(type(copy))]
260    pub(crate) movie_timescale: u32,
261    /// Movie-level total duration in microseconds from `mvhd`.
262    #[get(type(copy))]
263    pub(crate) movie_duration_us: u64,
264    /// Primary parsed video track metadata and sample table.
265    pub(crate) video_track: Mp4TrackInfo,
266    /// Optional parsed audio track metadata and sample table.
267    #[get(skip)]
268    pub(crate) audio_track: Option<Mp4TrackInfo>,
269}
270
271/// Input sample specification consumed by `Mp4ContainerBuilder` to emit valid ISOBMFF MP4 files.
272#[derive(Clone, Data, Debug, Default, PartialEq)]
273pub struct Mp4BuilderSample {
274    /// Sample duration in track timescale ticks (`stts`).
275    #[get(type(copy))]
276    pub(crate) duration_ticks: u32,
277    /// Composition time offset in track timescale ticks (`ctts`, added to DTS to obtain PTS).
278    #[get(type(copy))]
279    pub(crate) composition_offset_ticks: i32,
280    /// Whether this sample is a keyframe listed in `stss`.
281    #[get(type(copy))]
282    pub(crate) is_keyframe: bool,
283    /// Encoded sample payload bytes stored in `mdat`.
284    pub(crate) payload: Vec<u8>,
285}
286
287/// Stateless pure-Rust ISOBMFF MP4 container builder producing spec-compliant `ftyp`/`moov`/`mdat` byte streams.
288#[derive(Clone, Copy, Debug, Default)]
289pub struct Mp4ContainerBuilder;
290
291/// Decoder initialization descriptor derived from an MP4 video track.
292#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
293pub struct VideoDecoderConfig {
294    /// Target video codec.
295    #[get(type(copy))]
296    pub(crate) codec: VideoCodec,
297    /// Coded frame width in pixels.
298    #[get(type(copy))]
299    pub(crate) width: u32,
300    /// Coded frame height in pixels.
301    #[get(type(copy))]
302    pub(crate) height: u32,
303    /// Track color primaries, transfer curve, matrix, range, and HDR metadata.
304    #[get(type(copy))]
305    pub(crate) color_info: VideoColorInfo,
306}
307
308/// Demuxed video packet submitted to a `VideoDecoderBackend`.
309#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
310pub struct EncodedVideoPacket {
311    /// Zero-based sample index inside the track.
312    #[get(type(copy))]
313    pub(crate) sample_index: usize,
314    /// Seek/pipeline generation tag preventing stale pre-seek packets from rendering.
315    #[get(type(copy))]
316    pub(crate) generation: u64,
317    /// Decoding timestamp in microseconds.
318    #[get(type(copy))]
319    pub(crate) dts_us: i64,
320    /// Presentation timestamp in microseconds.
321    #[get(type(copy))]
322    pub(crate) pts_us: i64,
323    /// Frame duration in microseconds.
324    #[get(type(copy))]
325    pub(crate) duration_us: u64,
326    /// `true` when this packet is an intra keyframe.
327    #[get(type(copy))]
328    pub(crate) is_keyframe: bool,
329    /// Encoded packet bytes.
330    pub(crate) data: Vec<u8>,
331}
332
333/// Decoded video frame ordered by presentation timestamp (`pts_us`) with color/HDR metadata and GPU or pooled CPU backing.
334#[derive(Clone, Data, Debug, PartialEq)]
335pub struct DecodedVideoFrame {
336    /// Zero-based source sample index.
337    #[get(type(copy))]
338    pub(crate) sample_index: usize,
339    /// Seek/pipeline generation tag verifying freshness after seeks.
340    #[get(type(copy))]
341    pub(crate) generation: u64,
342    /// Decoding timestamp in microseconds.
343    #[get(type(copy))]
344    pub(crate) dts_us: i64,
345    /// Presentation timestamp in microseconds.
346    #[get(type(copy))]
347    pub(crate) pts_us: i64,
348    /// Frame display duration in microseconds.
349    #[get(type(copy))]
350    pub(crate) duration_us: u64,
351    /// Decoded pixel width.
352    #[get(type(copy))]
353    pub(crate) width: u32,
354    /// Decoded pixel height.
355    #[get(type(copy))]
356    pub(crate) height: u32,
357    /// Color primaries, transfer curve, matrix, and HDR metadata.
358    #[get(type(copy))]
359    pub(crate) color_info: VideoColorInfo,
360    /// Frame pixel backing (`GpuSurface` zero-copy handle or `CpuPooled` buffer).
361    pub(crate) backing: VideoFrameBacking,
362}
363
364/// Pure-Rust software fallback decoder handling intra RGBA8, intra YUV420P (with full CICP color matrix math), and P-frame XOR delta packets.
365#[derive(Clone, Data, Debug, Default)]
366pub struct SoftwareVideoDecoder {
367    /// Active configured track metadata.
368    #[get(type(copy))]
369    pub(crate) config: VideoDecoderConfig,
370    /// Last decoded RGBA8 reference frame retained for P-frame delta reconstruction.
371    #[get(skip)]
372    #[get_mut(skip)]
373    #[set(skip)]
374    pub(crate) reference_rgba: Vec<u8>,
375    /// Whether `reference_rgba` currently holds a valid decoded frame since the last flush.
376    #[get(type(copy))]
377    pub(crate) has_reference: bool,
378    /// Total frames decoded by this software decoder instance.
379    #[get(type(copy))]
380    pub(crate) decoded_frames: u64,
381}
382
383/// Zero-copy GPU interop hardware decoder adapter producing `VideoGpuSurfaceHandle` frames without CPU readback.
384#[derive(Clone, Data, Debug, Default)]
385pub struct HardwareZeroCopyDecoder {
386    /// Target platform hardware backend kind (`VideoToolbox`, `MediaCodec`, `Vaapi`, `Dxva`, `WebCodecs`).
387    #[get(type(copy))]
388    pub(crate) kind: HardwareDecoderKind,
389    /// Target GPU device identifier.
390    #[get(type(copy))]
391    pub(crate) device_id: u64,
392    /// Preferred GPU hardware surface pixel layout (`Nv12` for SDR, `P010` for HDR10).
393    #[get(type(copy))]
394    pub(crate) pixel_format: VideoPixelFormat,
395    /// Active configured video track metadata.
396    #[get(type(copy))]
397    pub(crate) config: VideoDecoderConfig,
398    /// Monotonic GPU surface handle counter.
399    #[get(type(copy))]
400    pub(crate) next_surface_id: u64,
401    /// Monotonic GPU synchronization fence value.
402    #[get(type(copy))]
403    pub(crate) next_fence_value: u64,
404}
405
406/// Bounded presentation-timestamp-ordered decoded frame queue supporting B-frame reordering and generation-tagged seek draining.
407#[derive(Clone, Data, Debug, Default)]
408pub struct PtsFrameQueue {
409    /// Maximum frames retained simultaneously in the queue.
410    #[get(type(copy))]
411    pub(crate) capacity: usize,
412    /// Frames maintained in strictly non-decreasing `pts_us` order.
413    pub(crate) frames: Vec<DecodedVideoFrame>,
414    /// Total frames discarded because their `generation` was older than an active seek.
415    #[get(type(copy))]
416    pub(crate) stale_generation_drops: u64,
417}
418
419/// Audio-master / monotonic-clock A/V synchronization scheduler that preserves source video cadence without forging frames on high-refresh displays.
420#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
421pub struct AvSyncScheduler {
422    /// Active synchronization clock source (`AudioMaster` or `MonotonicFallback`).
423    #[get(type(copy))]
424    pub(crate) clock_source: AvSyncClockSource,
425    /// Active playback clock position in microseconds.
426    #[get(type(copy))]
427    pub(crate) clock_pts_us: i64,
428    /// Playback speed multiplier (`0.25..=4.0`).
429    #[get(type(copy))]
430    pub(crate) playback_rate: f32,
431    /// Maximum frame lateness threshold in microseconds before dropping stale frames.
432    #[get(type(copy))]
433    pub(crate) max_late_us: i64,
434    /// PTS of the most recently presented frame (`None` before first frame or after seek).
435    #[get(skip)]
436    pub(crate) last_presented_pts_us: Option<i64>,
437    /// Count of distinct video frames newly presented to the display.
438    #[get(type(copy))]
439    pub(crate) frames_presented: u64,
440    /// Count of VSync ticks that held the existing frame because the next PTS was not yet due.
441    #[get(type(copy))]
442    pub(crate) frames_held_vsync: u64,
443    /// Count of overdue queued frames dropped to recover A/V sync.
444    #[get(type(copy))]
445    pub(crate) frames_dropped_late: u64,
446}
447
448/// Shared worker coordination state between the UI thread and the background decode worker thread.
449#[cfg(not(target_arch = "wasm32"))]
450#[derive(CustomDebug, Data)]
451pub(crate) struct VideoWorkerShared {
452    /// Bounded PTS-ordered decoded frame queue filled by the worker thread.
453    pub(crate) queue: PtsFrameQueue,
454    /// Active seek generation counter; increments invalidate in-flight older frames.
455    #[get(type(copy))]
456    pub(crate) active_generation: u64,
457    /// Next demux sample index queued for decode.
458    #[get(type(copy))]
459    pub(crate) next_sample_index: usize,
460    /// Target presentation timestamp after a seek; frames earlier than this during keyframe preroll are discarded.
461    #[get(type(copy))]
462    pub(crate) seek_preroll_target_us: i64,
463    /// Pending seek request `(new_generation, keyframe_index, target_pts_us)` consumed by the worker.
464    #[get(skip)]
465    pub(crate) pending_seek: Option<(u64, usize, i64)>,
466    /// Whether the pipeline is actively decoding.
467    #[get(type(copy))]
468    pub(crate) playing: bool,
469    /// Whether the worker reached the end of the demuxed sample stream for the active generation.
470    #[get(type(copy))]
471    pub(crate) reached_eos: bool,
472    /// Whether the worker thread should exit cleanly.
473    #[get(type(copy))]
474    pub(crate) shutdown: bool,
475    /// Total packets decoded by the background worker.
476    #[get(type(copy))]
477    pub(crate) packets_decoded: u64,
478    /// Total preroll frames decoded and discarded before reaching `seek_preroll_target_us`.
479    #[get(type(copy))]
480    pub(crate) seek_preroll_frames_discarded: u64,
481    /// Last decode error string reported by the worker, if any.
482    #[get(skip)]
483    pub(crate) last_error: Option<String>,
484}
485
486/// Asynchronous multi-threaded (native) / deterministic pumpable (wasm32) structured video playback pipeline.
487#[derive(CustomDebug)]
488pub struct VideoPlaybackPipeline {
489    /// Parsed MP4/ISOBMFF demuxer providing metadata and random-access sample lookup.
490    pub(crate) demuxer: Mp4Demuxer,
491    /// Bounded reusable CPU RGBA8 pixel buffer pool.
492    pub(crate) pool: VideoFramePool,
493    /// Audio-master / monotonic A/V synchronization scheduler.
494    pub(crate) scheduler: AvSyncScheduler,
495    /// Active hardware or software decoder backend kind.
496    pub(crate) backend_kind: HardwareDecoderKind,
497    /// Track color primaries, transfer curve, matrix, and HDR metadata.
498    pub(crate) color_info: VideoColorInfo,
499    /// Active playback transport state (`Idle`, `Playing`, `Paused`, `Ended`, `Error`).
500    pub(crate) state: PlaybackState,
501    /// Currently displayed decoded video frame held across intermediate VSync ticks.
502    pub(crate) current_frame: Option<DecodedVideoFrame>,
503    /// Active seek generation counter mirrored on the controller thread.
504    pub(crate) active_generation: u64,
505    /// Shared synchronization pair coordinating the background decode worker on native targets.
506    #[cfg(not(target_arch = "wasm32"))]
507    #[debug(skip)]
508    pub(crate) worker_shared: Arc<(Mutex<VideoWorkerShared>, Condvar)>,
509    /// Owned background decode thread handle joined cleanly on `Drop`.
510    #[cfg(not(target_arch = "wasm32"))]
511    #[debug(skip)]
512    pub(crate) worker_handle: Option<JoinHandle<()>>,
513    /// Single-threaded decoder instance used on WebAssembly targets.
514    #[cfg(target_arch = "wasm32")]
515    #[debug(skip)]
516    pub(crate) wasm_decoder: Box<dyn VideoDecoderBackend>,
517    /// Bounded PTS queue used on WebAssembly targets.
518    #[cfg(target_arch = "wasm32")]
519    pub(crate) wasm_queue: PtsFrameQueue,
520    /// Next demux sample index on WebAssembly targets.
521    #[cfg(target_arch = "wasm32")]
522    pub(crate) wasm_next_sample: usize,
523    /// Seek preroll target timestamp on WebAssembly targets.
524    #[cfg(target_arch = "wasm32")]
525    pub(crate) wasm_preroll_target_us: i64,
526    /// End-of-stream flag on WebAssembly targets.
527    #[cfg(target_arch = "wasm32")]
528    pub(crate) wasm_eos: bool,
529    /// Total packets decoded on WebAssembly targets.
530    #[cfg(target_arch = "wasm32")]
531    pub(crate) wasm_packets_decoded: u64,
532    /// Total preroll frames discarded during seek on WebAssembly targets.
533    #[cfg(target_arch = "wasm32")]
534    pub(crate) wasm_preroll_discarded: u64,
535    /// Last decode error on WebAssembly targets.
536    #[cfg(target_arch = "wasm32")]
537    pub(crate) wasm_last_error: Option<String>,
538}
539
540/// Internal accumulator populated while parsing an ISOBMFF `stbl` box hierarchy.
541#[derive(Clone, Data, Debug, Default)]
542pub(crate) struct Mp4SampleTableRaw {
543    /// `(sample_count, sample_delta_ticks)` pairs parsed from `stts`.
544    pub(crate) stts: Vec<(u32, u32)>,
545    /// `(sample_count, composition_offset_ticks)` pairs parsed from `ctts`.
546    pub(crate) ctts: Vec<(u32, i32)>,
547    /// 1-based sync keyframe sample numbers parsed from `stss`.
548    pub(crate) stss: Vec<u32>,
549    /// `(first_chunk, samples_per_chunk)` pairs parsed from `stsc`.
550    pub(crate) stsc: Vec<(u32, u32)>,
551    /// Constant sample size from `stsz` (`0` when per-sample sizes are present).
552    #[get(type(copy))]
553    pub(crate) default_sample_size: u32,
554    /// Declared total sample count from `stsz`.
555    #[get(type(copy))]
556    pub(crate) sample_count: u32,
557    /// Per-sample byte sizes parsed from `stsz`.
558    pub(crate) sample_sizes: Vec<u32>,
559    /// Chunk byte offsets parsed from `stco` or `co64`.
560    pub(crate) chunk_offsets: Vec<u64>,
561}