From 5bfebd12e8fec8fad445cd970d26feb4252984e3 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Sat, 30 Sep 2023 23:39:02 -0700 Subject: [PATCH] `struct {D,R}av1dContentLightLevel`: Make the same type, as the `Dav1d*` version will be fully Rustified after #505 is fixed. --- include/dav1d/headers.rs | 34 ++-------------------------------- include/dav1d/picture.rs | 6 +++--- src/internal.rs | 4 ++-- src/lib.rs | 4 ++-- src/obu.rs | 10 +++++----- src/picture.rs | 4 ++-- 6 files changed, 16 insertions(+), 46 deletions(-) diff --git a/include/dav1d/headers.rs b/include/dav1d/headers.rs index 24a50d502..e5aadb685 100644 --- a/include/dav1d/headers.rs +++ b/include/dav1d/headers.rs @@ -337,42 +337,12 @@ pub const DAV1D_MAX_SEGMENTS: u8 = 8; pub(crate) const RAV1D_MAX_SEGMENTS: u8 = DAV1D_MAX_SEGMENTS; #[repr(C)] -pub struct Dav1dContentLightLevel { +pub struct Rav1dContentLightLevel { pub max_content_light_level: c_int, pub max_frame_average_light_level: c_int, } -#[repr(C)] -pub(crate) struct Rav1dContentLightLevel { - pub max_content_light_level: c_int, - pub max_frame_average_light_level: c_int, -} - -impl From for Rav1dContentLightLevel { - fn from(value: Dav1dContentLightLevel) -> Self { - let Dav1dContentLightLevel { - max_content_light_level, - max_frame_average_light_level, - } = value; - Self { - max_content_light_level, - max_frame_average_light_level, - } - } -} - -impl From for Dav1dContentLightLevel { - fn from(value: Rav1dContentLightLevel) -> Self { - let Rav1dContentLightLevel { - max_content_light_level, - max_frame_average_light_level, - } = value; - Self { - max_content_light_level, - max_frame_average_light_level, - } - } -} +pub type Dav1dContentLightLevel = Rav1dContentLightLevel; #[repr(C)] pub struct Dav1dMasteringDisplay { diff --git a/include/dav1d/picture.rs b/include/dav1d/picture.rs index 7185011a8..a237758b6 100644 --- a/include/dav1d/picture.rs +++ b/include/dav1d/picture.rs @@ -2,12 +2,12 @@ use crate::include::dav1d::common::Dav1dDataProps; use crate::include::dav1d::common::Rav1dDataProps; use crate::include::dav1d::dav1d::Dav1dRef; use crate::include::dav1d::headers::DRav1d; -use crate::include::dav1d::headers::Dav1dContentLightLevel; 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::Rav1dSequenceHeader; @@ -60,7 +60,7 @@ pub struct Dav1dPicture { pub stride: [ptrdiff_t; 2], pub p: Dav1dPictureParameters, pub m: Dav1dDataProps, - pub content_light: *mut Dav1dContentLightLevel, + pub content_light: *mut Rav1dContentLightLevel, pub mastering_display: *mut Dav1dMasteringDisplay, pub itut_t35: *mut Dav1dITUTT35, pub reserved: [uintptr_t; 4], @@ -83,7 +83,7 @@ pub(crate) struct Rav1dPicture { pub stride: [ptrdiff_t; 2], pub p: Rav1dPictureParameters, pub m: Rav1dDataProps, - pub content_light: *mut Dav1dContentLightLevel, // TODO(kkysen) make Rav1d + pub content_light: *mut Rav1dContentLightLevel, pub mastering_display: *mut Dav1dMasteringDisplay, // TODO(kkysen) make Rav1d pub itut_t35: *mut Rav1dITUTT35, pub reserved: [uintptr_t; 4], diff --git a/src/internal.rs b/src/internal.rs index 3469843a8..985dc5632 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -6,8 +6,8 @@ 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::Dav1dContentLightLevel; 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::Rav1dSequenceHeader; @@ -176,7 +176,7 @@ pub struct Rav1dContext { pub(crate) frame_hdr_ref: *mut Rav1dRef, pub(crate) frame_hdr: *mut Rav1dFrameHeader, pub(crate) content_light_ref: *mut Rav1dRef, - pub(crate) content_light: *mut Dav1dContentLightLevel, // TODO(kkysen) make Rav1d + 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) itut_t35_ref: *mut Rav1dRef, diff --git a/src/lib.rs b/src/lib.rs index 47b98b113..3f67ae85f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,12 +16,12 @@ use crate::include::dav1d::dav1d::RAV1D_DECODEFRAMETYPE_KEY; use crate::include::dav1d::dav1d::RAV1D_INLOOPFILTER_ALL; use crate::include::dav1d::dav1d::RAV1D_INLOOPFILTER_NONE; use crate::include::dav1d::headers::DRav1d; -use crate::include::dav1d::headers::Dav1dContentLightLevel; 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::Rav1dSequenceHeader; @@ -1198,7 +1198,7 @@ pub(crate) unsafe fn rav1d_flush(c: *mut Rav1dContext) { (*c).seq_hdr = 0 as *mut Rav1dSequenceHeader; rav1d_ref_dec(&mut (*c).seq_hdr_ref); (*c).mastering_display = 0 as *mut Dav1dMasteringDisplay; - (*c).content_light = 0 as *mut Dav1dContentLightLevel; + (*c).content_light = 0 as *mut Rav1dContentLightLevel; (*c).itut_t35 = 0 as *mut Rav1dITUTT35; rav1d_ref_dec(&mut (*c).mastering_display_ref); rav1d_ref_dec(&mut (*c).content_light_ref); diff --git a/src/obu.rs b/src/obu.rs index de0f3b0ec..33db716f8 100644 --- a/src/obu.rs +++ b/src/obu.rs @@ -8,7 +8,6 @@ use crate::include::dav1d::headers::DRav1d; use crate::include::dav1d::headers::Dav1dAdaptiveBoolean; use crate::include::dav1d::headers::Dav1dChromaSamplePosition; use crate::include::dav1d::headers::Dav1dColorPrimaries; -use crate::include::dav1d::headers::Dav1dContentLightLevel; use crate::include::dav1d::headers::Dav1dFilmGrainData; use crate::include::dav1d::headers::Dav1dFilterMode; use crate::include::dav1d::headers::Dav1dFrameHeader; @@ -23,6 +22,7 @@ use crate::include::dav1d::headers::Dav1dSequenceHeaderOperatingParameterInfo; use crate::include::dav1d::headers::Dav1dTransferCharacteristics; use crate::include::dav1d::headers::Dav1dTxfmMode; use crate::include::dav1d::headers::Dav1dWarpedMotionType; +use crate::include::dav1d::headers::Rav1dContentLightLevel; use crate::include::dav1d::headers::Rav1dFrameHeader; use crate::include::dav1d::headers::Rav1dFrameHeaderOperatingPoint; use crate::include::dav1d::headers::Rav1dITUTT35; @@ -1731,7 +1731,7 @@ pub(crate) unsafe fn rav1d_parse_obus( { (*c).frame_hdr = 0 as *mut Rav1dFrameHeader; (*c).mastering_display = 0 as *mut Dav1dMasteringDisplay; - (*c).content_light = 0 as *mut Dav1dContentLightLevel; + (*c).content_light = 0 as *mut Rav1dContentLightLevel; rav1d_ref_dec(&mut (*c).mastering_display_ref); rav1d_ref_dec(&mut (*c).content_light_ref); let mut i = 0; @@ -1787,12 +1787,12 @@ pub(crate) unsafe fn rav1d_parse_obus( match meta_type as c_uint { OBU_META_HDR_CLL => { let mut ref_1: *mut Rav1dRef = - rav1d_ref_create(::core::mem::size_of::()); + rav1d_ref_create(::core::mem::size_of::()); if ref_1.is_null() { return -(12 as c_int); } - let content_light: *mut Dav1dContentLightLevel = - (*ref_1).data as *mut Dav1dContentLightLevel; + let content_light: *mut Rav1dContentLightLevel = + (*ref_1).data as *mut Rav1dContentLightLevel; (*content_light).max_content_light_level = rav1d_get_bits(&mut gb, 16 as c_int) as c_int; (*content_light).max_frame_average_light_level = diff --git a/src/picture.rs b/src/picture.rs index 7d8f04470..606d5d40f 100644 --- a/src/picture.rs +++ b/src/picture.rs @@ -4,8 +4,8 @@ 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::Dav1dContentLightLevel; 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::Rav1dSequenceHeader; @@ -142,7 +142,7 @@ unsafe extern "C" fn picture_alloc_with_edges( seq_hdr_ref: *mut Rav1dRef, frame_hdr: *mut Rav1dFrameHeader, frame_hdr_ref: *mut Rav1dRef, - content_light: *mut Dav1dContentLightLevel, + content_light: *mut Rav1dContentLightLevel, content_light_ref: *mut Rav1dRef, mastering_display: *mut Dav1dMasteringDisplay, mastering_display_ref: *mut Rav1dRef,