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
107
108
109
110
111
112
113
114
115
116
117
118
119
//! Slice segment header writer for a single first-slice IDR I-slice.
//!
//! Field order/conditions mirror `SliceHeader::parse` in
//! `bpg-hevc-decode::hevc::slice`, specialized to the parameter sets written
//! by `params.rs`:
//! - `first_slice_segment_in_pic_flag = 1` (single slice per picture), so
//! `dependent_slice_segment_flag`/`slice_segment_address` are absent.
//! - `pps.num_extra_slice_header_bits == 0`, `pps.output_flag_present_flag
//! == false`, `sps.separate_colour_plane_flag == false`.
//! - NAL type is IDR (`IdrWRadl`/`IdrNLp`), so POC LSB and ref-pic-set
//! syntax are absent.
//! - `sps.sample_adaptive_offset_enabled_flag` follows `config.sao` (see
//! `params.rs`): with `SaoMode::Off` (default),
//! `slice_sao_luma_flag`/`slice_sao_chroma_flag` are absent; with
//! `SaoMode::On` both are present and written as 1 (per-CTU SAO syntax —
//! see `crate::sao` — then determines whether SAO is actually applied).
//! - `pps.pps_slice_chroma_qp_offsets_present_flag == false` and
//! `pps.deblocking_filter_override_enabled_flag == false`, so the chroma
//! QP offset and deblocking-override fields are absent.
//! - `pps.pps_loop_filter_across_slices_enabled_flag == true`. With
//! `config.deblock == DeblockMode::On`, `pps_deblocking_filter_disabled_flag
//! == false`, so `slice_loop_filter_across_slices_enabled_flag` IS present
//! (written as 1). With `DeblockMode::Off` (default),
//! `pps_deblocking_filter_disabled_flag == true`, so the presence condition
//! `slice_sao_* || !slice_deblocking_filter_disabled` reduces to
//! `slice_sao_*` — present (and written as 1) iff `config.sao !=
//! SaoMode::Off`.
//! - `num_entry_point_offsets` is present when tiles or WPP are enabled.
//! - `pps.slice_segment_header_extension_present_flag == false`.
//!
//! After these fields comes `byte_alignment()`: `alignment_bit_equal_to_one`
//! (1) followed by zero `alignment_bit_equal_to_zero`s up to the next byte
//! boundary, after which `slice_data()` (the CABAC-coded CTU data) begins.
use crateBitWriter;
use crate::;
/// `slice_segment_header()` (H.265 7.3.6.1) for a single first-slice IDR
/// I-slice, ending with `byte_alignment()`. The returned bytes are the
/// header only; CABAC-coded slice data (not yet implemented) follows.