Skip to content

Commit

Permalink
struct {D,R}av1dMasteringDisplay: Make the same type, as the `Dav1d…
Browse files Browse the repository at this point in the history
…*` version is fully Rustified.
  • Loading branch information
kkysen committed Oct 1, 2023
1 parent 5bfebd1 commit 21998f9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 56 deletions.
44 changes: 2 additions & 42 deletions include/dav1d/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,54 +345,14 @@ pub struct Rav1dContentLightLevel {
pub type Dav1dContentLightLevel = Rav1dContentLightLevel;

#[repr(C)]
pub struct Dav1dMasteringDisplay {
pub struct Rav1dMasteringDisplay {
pub primaries: [[u16; 2]; 3],
pub white_point: [u16; 2],
pub max_luminance: u32,
pub min_luminance: u32,
}

#[repr(C)]
pub(crate) struct Rav1dMasteringDisplay {
pub primaries: [[u16; 2]; 3],
pub white_point: [u16; 2],
pub max_luminance: u32,
pub min_luminance: u32,
}

impl From<Dav1dMasteringDisplay> for Rav1dMasteringDisplay {
fn from(value: Dav1dMasteringDisplay) -> Self {
let Dav1dMasteringDisplay {
primaries,
white_point,
max_luminance,
min_luminance,
} = value;
Self {
primaries,
white_point,
max_luminance,
min_luminance,
}
}
}

impl From<Rav1dMasteringDisplay> for Dav1dMasteringDisplay {
fn from(value: Rav1dMasteringDisplay) -> Self {
let Rav1dMasteringDisplay {
primaries,
white_point,
max_luminance,
min_luminance,
} = value;
Self {
primaries,
white_point,
max_luminance,
min_luminance,
}
}
}
pub type Dav1dMasteringDisplay = Rav1dMasteringDisplay;

#[derive(Clone)]
#[repr(C)]
Expand Down
6 changes: 3 additions & 3 deletions include/dav1d/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use crate::include::dav1d::dav1d::Dav1dRef;
use crate::include::dav1d::headers::DRav1d;
use crate::include::dav1d::headers::Dav1dFrameHeader;
use crate::include::dav1d::headers::Dav1dITUTT35;
use crate::include::dav1d::headers::Dav1dMasteringDisplay;
use crate::include::dav1d::headers::Dav1dPixelLayout;
use crate::include::dav1d::headers::Dav1dSequenceHeader;
use crate::include::dav1d::headers::Rav1dContentLightLevel;
use crate::include::dav1d::headers::Rav1dFrameHeader;
use crate::include::dav1d::headers::Rav1dITUTT35;
use crate::include::dav1d::headers::Rav1dMasteringDisplay;
use crate::include::dav1d::headers::Rav1dSequenceHeader;
use crate::src::r#ref::Rav1dRef;
use libc::ptrdiff_t;
Expand Down Expand Up @@ -61,7 +61,7 @@ pub struct Dav1dPicture {
pub p: Dav1dPictureParameters,
pub m: Dav1dDataProps,
pub content_light: *mut Rav1dContentLightLevel,
pub mastering_display: *mut Dav1dMasteringDisplay,
pub mastering_display: *mut Rav1dMasteringDisplay,
pub itut_t35: *mut Dav1dITUTT35,
pub reserved: [uintptr_t; 4],
pub frame_hdr_ref: *mut Dav1dRef,
Expand All @@ -84,7 +84,7 @@ pub(crate) struct Rav1dPicture {
pub p: Rav1dPictureParameters,
pub m: Rav1dDataProps,
pub content_light: *mut Rav1dContentLightLevel,
pub mastering_display: *mut Dav1dMasteringDisplay, // TODO(kkysen) make Rav1d
pub mastering_display: *mut Rav1dMasteringDisplay,
pub itut_t35: *mut Rav1dITUTT35,
pub reserved: [uintptr_t; 4],
pub frame_hdr_ref: *mut Rav1dRef,
Expand Down
4 changes: 2 additions & 2 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use crate::include::dav1d::dav1d::Rav1dDecodeFrameType;
use crate::include::dav1d::dav1d::Rav1dEventFlags;
use crate::include::dav1d::dav1d::Rav1dInloopFilterType;
use crate::include::dav1d::dav1d::Rav1dLogger;
use crate::include::dav1d::headers::Dav1dMasteringDisplay;
use crate::include::dav1d::headers::Rav1dContentLightLevel;
use crate::include::dav1d::headers::Rav1dFrameHeader;
use crate::include::dav1d::headers::Rav1dITUTT35;
use crate::include::dav1d::headers::Rav1dMasteringDisplay;
use crate::include::dav1d::headers::Rav1dSequenceHeader;
use crate::include::dav1d::headers::Rav1dWarpedMotionParams;
use crate::include::dav1d::picture::Rav1dPicAllocator;
Expand Down Expand Up @@ -178,7 +178,7 @@ pub struct Rav1dContext {
pub(crate) content_light_ref: *mut Rav1dRef,
pub(crate) content_light: *mut Rav1dContentLightLevel,
pub(crate) mastering_display_ref: *mut Rav1dRef,
pub(crate) mastering_display: *mut Dav1dMasteringDisplay, // TODO(kkysen) make Rav1d
pub(crate) mastering_display: *mut Rav1dMasteringDisplay,
pub(crate) itut_t35_ref: *mut Rav1dRef,
pub(crate) itut_t35: *mut Rav1dITUTT35,
pub(crate) in_0: Rav1dData,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ use crate::include::dav1d::headers::DRav1d;
use crate::include::dav1d::headers::Dav1dFilmGrainData;
use crate::include::dav1d::headers::Dav1dFrameHeader;
use crate::include::dav1d::headers::Dav1dITUTT35;
use crate::include::dav1d::headers::Dav1dMasteringDisplay;
use crate::include::dav1d::headers::Dav1dSequenceHeader;
use crate::include::dav1d::headers::Rav1dContentLightLevel;
use crate::include::dav1d::headers::Rav1dFrameHeader;
use crate::include::dav1d::headers::Rav1dITUTT35;
use crate::include::dav1d::headers::Rav1dMasteringDisplay;
use crate::include::dav1d::headers::Rav1dSequenceHeader;
use crate::include::dav1d::picture::Dav1dPicture;
use crate::include::dav1d::picture::Rav1dPicAllocator;
Expand Down Expand Up @@ -1197,7 +1197,7 @@ pub(crate) unsafe fn rav1d_flush(c: *mut Rav1dContext) {
(*c).frame_hdr = 0 as *mut Rav1dFrameHeader;
(*c).seq_hdr = 0 as *mut Rav1dSequenceHeader;
rav1d_ref_dec(&mut (*c).seq_hdr_ref);
(*c).mastering_display = 0 as *mut Dav1dMasteringDisplay;
(*c).mastering_display = 0 as *mut Rav1dMasteringDisplay;
(*c).content_light = 0 as *mut Rav1dContentLightLevel;
(*c).itut_t35 = 0 as *mut Rav1dITUTT35;
rav1d_ref_dec(&mut (*c).mastering_display_ref);
Expand Down
10 changes: 5 additions & 5 deletions src/obu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use crate::include::dav1d::headers::Dav1dFilterMode;
use crate::include::dav1d::headers::Dav1dFrameHeader;
use crate::include::dav1d::headers::Dav1dFrameType;
use crate::include::dav1d::headers::Dav1dITUTT35;
use crate::include::dav1d::headers::Dav1dMasteringDisplay;
use crate::include::dav1d::headers::Dav1dMatrixCoefficients;
use crate::include::dav1d::headers::Dav1dPixelLayout;
use crate::include::dav1d::headers::Dav1dRestorationType;
Expand All @@ -27,6 +26,7 @@ use crate::include::dav1d::headers::Rav1dFrameHeader;
use crate::include::dav1d::headers::Rav1dFrameHeaderOperatingPoint;
use crate::include::dav1d::headers::Rav1dITUTT35;
use crate::include::dav1d::headers::Rav1dLoopfilterModeRefDeltas;
use crate::include::dav1d::headers::Rav1dMasteringDisplay;
use crate::include::dav1d::headers::Rav1dObuType;
use crate::include::dav1d::headers::Rav1dSegmentationData;
use crate::include::dav1d::headers::Rav1dSegmentationDataSet;
Expand Down Expand Up @@ -1730,7 +1730,7 @@ pub(crate) unsafe fn rav1d_parse_obus(
) != 0
{
(*c).frame_hdr = 0 as *mut Rav1dFrameHeader;
(*c).mastering_display = 0 as *mut Dav1dMasteringDisplay;
(*c).mastering_display = 0 as *mut Rav1dMasteringDisplay;
(*c).content_light = 0 as *mut Rav1dContentLightLevel;
rav1d_ref_dec(&mut (*c).mastering_display_ref);
rav1d_ref_dec(&mut (*c).content_light_ref);
Expand Down Expand Up @@ -1809,12 +1809,12 @@ pub(crate) unsafe fn rav1d_parse_obus(
}
OBU_META_HDR_MDCV => {
let mut ref_2: *mut Rav1dRef =
rav1d_ref_create(::core::mem::size_of::<Dav1dMasteringDisplay>());
rav1d_ref_create(::core::mem::size_of::<Rav1dMasteringDisplay>());
if ref_2.is_null() {
return -(12 as c_int);
}
let mastering_display: *mut Dav1dMasteringDisplay =
(*ref_2).data as *mut Dav1dMasteringDisplay;
let mastering_display: *mut Rav1dMasteringDisplay =
(*ref_2).data as *mut Rav1dMasteringDisplay;
let mut i_1 = 0;
while i_1 < 3 {
(*mastering_display).primaries[i_1 as usize][0] =
Expand Down
4 changes: 2 additions & 2 deletions src/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::include::dav1d::dav1d::Dav1dEventFlags;
use crate::include::dav1d::dav1d::Rav1dEventFlags;
use crate::include::dav1d::dav1d::RAV1D_EVENT_FLAG_NEW_OP_PARAMS_INFO;
use crate::include::dav1d::dav1d::RAV1D_EVENT_FLAG_NEW_SEQUENCE;
use crate::include::dav1d::headers::Dav1dMasteringDisplay;
use crate::include::dav1d::headers::Rav1dContentLightLevel;
use crate::include::dav1d::headers::Rav1dFrameHeader;
use crate::include::dav1d::headers::Rav1dITUTT35;
use crate::include::dav1d::headers::Rav1dMasteringDisplay;
use crate::include::dav1d::headers::Rav1dSequenceHeader;
use crate::include::dav1d::headers::RAV1D_PIXEL_LAYOUT_I400;
use crate::include::dav1d::headers::RAV1D_PIXEL_LAYOUT_I420;
Expand Down Expand Up @@ -144,7 +144,7 @@ unsafe extern "C" fn picture_alloc_with_edges(
frame_hdr_ref: *mut Rav1dRef,
content_light: *mut Rav1dContentLightLevel,
content_light_ref: *mut Rav1dRef,
mastering_display: *mut Dav1dMasteringDisplay,
mastering_display: *mut Rav1dMasteringDisplay,
mastering_display_ref: *mut Rav1dRef,
itut_t35: *mut Rav1dITUTT35,
itut_t35_ref: *mut Rav1dRef,
Expand Down

0 comments on commit 21998f9

Please sign in to comment.