Skip to content

Commit

Permalink
fn Rav1dFilmGrainData::has_grain: Extract safe fn from `fn Rav1dP…
Browse files Browse the repository at this point in the history
…icture::has_grain`.
  • Loading branch information
kkysen committed Oct 30, 2023
1 parent e062dfb commit 3b275e2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::include::dav1d::headers::Dav1dFrameHeader;
use crate::include::dav1d::headers::Dav1dITUTT35;
use crate::include::dav1d::headers::Dav1dSequenceHeader;
use crate::include::dav1d::headers::Rav1dContentLightLevel;
use crate::include::dav1d::headers::Rav1dFilmGrainData;
use crate::include::dav1d::headers::Rav1dFrameHeader;
use crate::include::dav1d::headers::Rav1dITUTT35;
use crate::include::dav1d::headers::Rav1dMasteringDisplay;
Expand Down Expand Up @@ -587,13 +588,18 @@ pub unsafe extern "C" fn dav1d_parse_sequence_header(
.into()
}

impl Rav1dFilmGrainData {
fn has_grain(&self) -> bool {
self.num_y_points != 0
|| self.num_uv_points[0] != 0
|| self.num_uv_points[1] != 0
|| self.clip_to_restricted_range && self.chroma_scaling_from_luma
}
}

impl Rav1dPicture {
unsafe fn has_grain(&self) -> bool {
let fgdata = &(*self.frame_hdr).film_grain.data;
fgdata.num_y_points != 0
|| fgdata.num_uv_points[0] != 0
|| fgdata.num_uv_points[1] != 0
|| fgdata.clip_to_restricted_range && fgdata.chroma_scaling_from_luma
(*self.frame_hdr).film_grain.data.has_grain()
}
}

Expand Down

0 comments on commit 3b275e2

Please sign in to comment.