Skip to content

Commit 9237745

Browse files
committed
rustfmt
1 parent 3f8618a commit 9237745

File tree

4 files changed

+54
-49
lines changed

4 files changed

+54
-49
lines changed

src/nal/slice/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -677,20 +677,20 @@ impl SliceHeader {
677677
slice_beta_offset_div2 = Some(r.read_se("slice_beta_offset_div2")?);
678678
}
679679
}
680-
let slice_group_change_cycle =
681-
if let Some(pps::SliceGroup::Changing {
682-
slice_group_change_rate_minus1,
683-
..
684-
}) = &pps.slice_groups
685-
{
686-
let pic_size = sps.pic_size_in_map_units();
687-
let change_rate = slice_group_change_rate_minus1 + 1;
688-
let bits =
689-
(f64::from(pic_size) / f64::from(change_rate) + 1.0).log2().ceil() as u32;
690-
Some(r.read::<u32>(bits, "slice_group_change_cycle")?)
691-
} else {
692-
None
693-
};
680+
let slice_group_change_cycle = if let Some(pps::SliceGroup::Changing {
681+
slice_group_change_rate_minus1,
682+
..
683+
}) = &pps.slice_groups
684+
{
685+
let pic_size = sps.pic_size_in_map_units();
686+
let change_rate = slice_group_change_rate_minus1 + 1;
687+
let bits = (f64::from(pic_size) / f64::from(change_rate) + 1.0)
688+
.log2()
689+
.ceil() as u32;
690+
Some(r.read::<u32>(bits, "slice_group_change_cycle")?)
691+
} else {
692+
None
693+
};
694694
if !r.has_more_rbsp_data("slice_header")? {
695695
return Err(SliceHeaderError::RbspError(BitReaderError::ReaderErrorFor(
696696
"slice_header",

src/nal/sps.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,12 @@ pub enum Profile {
8888
}
8989

9090
impl Profile {
91-
pub fn from_profile_idc(
92-
profile_idc: ProfileIdc,
93-
constraint_flags: ConstraintFlags,
94-
) -> Profile {
91+
pub fn from_profile_idc(profile_idc: ProfileIdc, constraint_flags: ConstraintFlags) -> Profile {
9592
match profile_idc.0 {
9693
66 if constraint_flags.flag1() => Profile::ConstrainedBaseline,
9794
66 => Profile::Baseline,
9895
77 => Profile::Main,
99-
100 if constraint_flags.flag4() && constraint_flags.flag5() => {
100-
Profile::ConstrainedHigh
101-
}
96+
100 if constraint_flags.flag4() && constraint_flags.flag5() => Profile::ConstrainedHigh,
10297
100 if constraint_flags.flag4() => Profile::ProgressiveHigh,
10398
100 => Profile::High,
10499
110 if constraint_flags.flag3() => Profile::High10Intra,
@@ -133,7 +128,8 @@ impl Profile {
133128
Profile::High444 | Profile::High444Intra => 244,
134129
Profile::Extended => 88,
135130
Profile::ScalableBase | Profile::ScalableConstrainedBaseline => 83,
136-
Profile::ScalableHigh | Profile::ScalableConstrainedHigh
131+
Profile::ScalableHigh
132+
| Profile::ScalableConstrainedHigh
137133
| Profile::ScalableHighIntra => 86,
138134
Profile::MultiviewHigh => 118,
139135
Profile::StereoHigh => 128,

src/nal/sps_extension.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ pub struct SeqParameterSetExtension {
2323

2424
impl SeqParameterSetExtension {
2525
pub fn from_bits<R: BitRead>(mut r: R) -> Result<SeqParameterSetExtension, SpsError> {
26-
let seq_parameter_set_id =
27-
SeqParamSetId::from_u32(r.read_ue("seq_parameter_set_id")?)
28-
.map_err(SpsError::BadSeqParamSetId)?;
26+
let seq_parameter_set_id = SeqParamSetId::from_u32(r.read_ue("seq_parameter_set_id")?)
27+
.map_err(SpsError::BadSeqParamSetId)?;
2928
let aux_format_idc = r.read_ue("aux_format_idc")?;
3029
let aux_format_info = if aux_format_idc != 0 {
3130
let bit_depth_aux_minus8 = r.read_ue("bit_depth_aux_minus8")?;
@@ -71,7 +70,10 @@ mod test {
7170
// bits: 1 1 0 1 0000 = 0xD0
7271
let data = [0xD0u8];
7372
let ext = SeqParameterSetExtension::from_bits(BitReader::new(&data[..])).unwrap();
74-
assert_eq!(ext.seq_parameter_set_id, SeqParamSetId::from_u32(0).unwrap());
73+
assert_eq!(
74+
ext.seq_parameter_set_id,
75+
SeqParamSetId::from_u32(0).unwrap()
76+
);
7577
assert_eq!(ext.aux_format_idc, 0);
7678
assert!(ext.aux_format_info.is_none());
7779
assert!(!ext.additional_extension_flag);
@@ -95,7 +97,10 @@ mod test {
9597
// byte 3: 0100_0000 = 0x40
9698
let data = [0xABu8, 0xFE, 0x00, 0x40];
9799
let ext = SeqParameterSetExtension::from_bits(BitReader::new(&data[..])).unwrap();
98-
assert_eq!(ext.seq_parameter_set_id, SeqParamSetId::from_u32(0).unwrap());
100+
assert_eq!(
101+
ext.seq_parameter_set_id,
102+
SeqParamSetId::from_u32(0).unwrap()
103+
);
99104
assert_eq!(ext.aux_format_idc, 1);
100105
let info = ext.aux_format_info.as_ref().unwrap();
101106
assert_eq!(info.bit_depth_aux_minus8, 0);

src/nal/subset_sps.rs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ pub struct SubsetSps {
8383
}
8484

8585
/// Read a ue value and validate it fits in u16 with given max.
86-
fn read_ue_bounded<R: BitRead>(
87-
r: &mut R,
88-
name: &'static str,
89-
max: u32,
90-
) -> Result<u16, SpsError> {
86+
fn read_ue_bounded<R: BitRead>(r: &mut R, name: &'static str, max: u32) -> Result<u16, SpsError> {
9187
let val = r.read_ue(name)?;
9288
if val > max {
9389
return Err(SpsError::FieldValueTooLarge { name, value: val });
@@ -167,7 +163,11 @@ fn read_svc_extension<R: BitRead>(
167163
r.read(2, "chroma_phase_y_plus1")?
168164
} else {
169165
// Default: 0 for Monochrome, 1 for YUV422/444
170-
if chroma_array_type == 0 { 0 } else { 1 }
166+
if chroma_array_type == 0 {
167+
0
168+
} else {
169+
1
170+
}
171171
};
172172

173173
let (
@@ -186,7 +186,11 @@ fn read_svc_extension<R: BitRead>(
186186
let ref_phase_y = if chroma_array_type == 1 {
187187
r.read(2, "seq_ref_layer_chroma_phase_y_plus1")?
188188
} else {
189-
if chroma_array_type == 0 { 0 } else { 1 }
189+
if chroma_array_type == 0 {
190+
0
191+
} else {
192+
1
193+
}
190194
};
191195
(
192196
ref_phase_x,
@@ -197,19 +201,24 @@ fn read_svc_extension<R: BitRead>(
197201
r.read_se("seq_scaled_ref_layer_bottom_offset")?,
198202
)
199203
} else {
200-
(false, if chroma_array_type == 0 { 0 } else { 1 }, 0, 0, 0, 0)
204+
(
205+
false,
206+
if chroma_array_type == 0 { 0 } else { 1 },
207+
0,
208+
0,
209+
0,
210+
0,
211+
)
201212
};
202213

203-
let seq_tcoeff_level_prediction_flag =
204-
r.read_bool("seq_tcoeff_level_prediction_flag")?;
214+
let seq_tcoeff_level_prediction_flag = r.read_bool("seq_tcoeff_level_prediction_flag")?;
205215
let adaptive_tcoeff_level_prediction_flag = if seq_tcoeff_level_prediction_flag {
206216
r.read_bool("adaptive_tcoeff_level_prediction_flag")?
207217
} else {
208218
false
209219
};
210220
let slice_header_restriction_flag = r.read_bool("slice_header_restriction_flag")?;
211-
let svc_vui_parameters_present_flag =
212-
r.read_bool("svc_vui_parameters_present_flag")?;
221+
let svc_vui_parameters_present_flag = r.read_bool("svc_vui_parameters_present_flag")?;
213222

214223
Ok(SvcSpsExtension {
215224
inter_layer_deblocking_filter_control_present_flag,
@@ -315,8 +324,7 @@ fn read_mvc_extension<R: BitRead>(r: &mut R) -> Result<MvcSpsExtension, SpsError
315324
});
316325
}
317326

318-
let mut level_values =
319-
Vec::with_capacity(num_level_values_signalled_minus1 as usize + 1);
327+
let mut level_values = Vec::with_capacity(num_level_values_signalled_minus1 as usize + 1);
320328
for _ in 0..=num_level_values_signalled_minus1 {
321329
let level_idc: u8 = r.read(8, "level_idc")?;
322330
let num_applicable_ops_minus1 = r.read_ue("num_applicable_ops_minus1")?;
@@ -326,20 +334,16 @@ fn read_mvc_extension<R: BitRead>(r: &mut R) -> Result<MvcSpsExtension, SpsError
326334
value: num_applicable_ops_minus1,
327335
});
328336
}
329-
let mut applicable_ops =
330-
Vec::with_capacity(num_applicable_ops_minus1 as usize + 1);
337+
let mut applicable_ops = Vec::with_capacity(num_applicable_ops_minus1 as usize + 1);
331338
for _ in 0..=num_applicable_ops_minus1 {
332339
let temporal_id: u8 = r.read(3, "applicable_op_temporal_id")?;
333340
let num_target_views_minus1 =
334341
read_ue_bounded(r, "applicable_op_num_target_views_minus1", 1023)?;
335-
let mut target_view_ids =
336-
Vec::with_capacity(num_target_views_minus1 as usize + 1);
342+
let mut target_view_ids = Vec::with_capacity(num_target_views_minus1 as usize + 1);
337343
for _ in 0..=num_target_views_minus1 {
338-
target_view_ids
339-
.push(read_ue_bounded(r, "applicable_op_target_view_id", 1023)?);
344+
target_view_ids.push(read_ue_bounded(r, "applicable_op_target_view_id", 1023)?);
340345
}
341-
let num_views_minus1 =
342-
read_ue_bounded(r, "applicable_op_num_views_minus1", 1023)?;
346+
let num_views_minus1 = read_ue_bounded(r, "applicable_op_num_views_minus1", 1023)?;
343347
applicable_ops.push(MvcApplicableOp {
344348
temporal_id,
345349
num_target_views_minus1,

0 commit comments

Comments
 (0)