1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
//! HEVC DPB "RPS application" eviction (ITU-T H.265 § 8.3.2) and
//! `RefPicList`/`RefPicSetStCurrBefore`/`RefPicSetStCurrAfter` construction for
//! `DXVA_PicParams_HEVC`. Pure, sans-io logic — no D3D12/hardware involved.
//!
//! **No port available** — `crate::vulkan::decoder_hevc.rs` never reaches this problem
//! (its own decode path is IDR-only end-to-end, so it never builds a real reference list),
//! per ADR-0004 § File layout plan. Structurally different from `h264_refs.rs`'s
//! `FrameNumWrap` sliding window: HEVC's DPB eviction is driven by whether a slot's POC
//! appears anywhere in the current picture's own signaled RPS, not a frame-count window.
//!
//! **`RefPicSetStCurrBefore`/`After` index semantics — not independently confirmed from a
//! primary source** (ADR-0004 § `RefPicList`/... semantics, its own Open Question #3):
//! believed to be byte-indices into `RefPicList[15]` (`0..15`, `0xFF` unused), not raw DPB
//! slot numbers, matching every other DXVA struct's `used_for_reference_flags`-style
//! indirection in this family. **First thing to confirm against `libavcodec/dxva2_hevc.c`
//! before any real hardware attempt** — this module implements the *believed* semantics,
//! not a hardware-verified one.
use crateDecodeError;
use SmallVec;
/// Per-reference metadata this module needs to place a DPB slot in a reference list.
/// Stored by [`super::dpb::DpbPool`] alongside each occupied, `is_reference` slot.
pub
/// Which currently-held DPB references (`refs`) the RPS "application" process (ITU-T
/// H.265 § 8.3.2) must evict before the current picture can be decoded: any reference
/// whose POC is not named anywhere in `all_rps_poc` (both `used_by_curr_pic` and "foll"
/// entries — see `hevc_slice::ShortTermRefPicSet::all_poc`'s doc for why the full set,
/// not just the "used by current picture" subset, is the right input here).
///
/// Returns DPB slot indices, not references — [`super::dpb::SlotTable::evict`] is the
/// caller's job (this function has no D3D12/DPB-pool dependency, kept unit-testable).
pub
/// Constructed `RefPicList[15]`/`PicOrderCntValList[15]`/`RefPicSetStCurrBefore[8]`/
/// `RefPicSetStCurrAfter[8]` inputs for [`super::hevc_pic_params::build_pic_params`] —
/// DPB-slot-agnostic (holds slot indices as plain `u32`, no `ID3D12Resource`).
pub
/// Build [`HevcRefLists`] from the DPB's active references (`refs`, **after** this
/// picture's own eviction pass — see [`slots_to_evict`]) and the current picture's
/// `RefPicSetStCurrBefore`/`After` POC values (`hevc_slice::ShortTermRefPicSet::
/// curr_before_after_poc`'s output).
///
/// # Errors
///
/// [`DecodeError::InvalidInput`] when a `before_poc`/`after_poc` value has no matching
/// entry in `refs` — an internally-inconsistent stream (the picture it names is not
/// actually held in the DPB).
pub