From 02e5316bbfdc87c1bf2a1059e8941c88bc20f029 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Thu, 21 Dec 2023 17:11:58 -0800 Subject: [PATCH] `struct {D,R}av1dITUTT35`: Skip `.update_rav1d()`ing it as we never read it. This also lets us remove the `{D => R}av1dITUTT35` conversion, which contains `unsafe`. --- include/dav1d/headers.rs | 19 ------------------- include/dav1d/picture.rs | 2 +- src/lib.rs | 9 +-------- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/include/dav1d/headers.rs b/include/dav1d/headers.rs index 9e18ddc74..6bfe17d4d 100644 --- a/include/dav1d/headers.rs +++ b/include/dav1d/headers.rs @@ -2,7 +2,6 @@ use crate::src::enum_map::EnumKey; use std::ffi::c_int; use std::ffi::c_uint; use std::ops::BitAnd; -use std::slice; use strum::EnumCount; use strum::FromRepr; @@ -509,24 +508,6 @@ pub(crate) struct Rav1dITUTT35 { pub payload: Box<[u8]>, } -impl From for Rav1dITUTT35 { - fn from(value: Dav1dITUTT35) -> Self { - let Dav1dITUTT35 { - country_code, - country_code_extension_byte, - payload_size, - payload, - } = value; - let payload = unsafe { slice::from_raw_parts_mut(payload, payload_size) }; - let payload = unsafe { Box::from_raw(payload) }; - Self { - country_code, - country_code_extension_byte, - payload, - } - } -} - impl From for Dav1dITUTT35 { fn from(value: Rav1dITUTT35) -> Self { let Rav1dITUTT35 { diff --git a/include/dav1d/picture.rs b/include/dav1d/picture.rs index a692cfd45..b692839b6 100644 --- a/include/dav1d/picture.rs +++ b/include/dav1d/picture.rs @@ -165,7 +165,7 @@ impl From for Rav1dPicture { content_light: content_light_ref.map(|raw| unsafe { Arc::from_raw(raw.as_ptr()) }), mastering_display: mastering_display_ref .map(|raw| unsafe { Arc::from_raw(raw.as_ptr()) }), - // `.update_rav1d()` happens in `#[no_mangle] extern "C"`/`DAV1D_API` calls + // We don't `.update_rav1d` [`Rav1dITUTT35`] because never read it. itut_t35: if itut_t35.is_null() { ptr::null_mut() } else { diff --git a/src/lib.rs b/src/lib.rs index 20223af72..d5210c2ea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,6 @@ use crate::include::dav1d::dav1d::RAV1D_DECODEFRAMETYPE_KEY; use crate::include::dav1d::dav1d::RAV1D_INLOOPFILTER_ALL; use crate::include::dav1d::headers::DRav1d; use crate::include::dav1d::headers::Dav1dFrameHeader; -use crate::include::dav1d::headers::Dav1dITUTT35; use crate::include::dav1d::headers::Dav1dSequenceHeader; use crate::include::dav1d::headers::Rav1dFilmGrainData; use crate::include::dav1d::headers::Rav1dFrameHeader; @@ -845,13 +844,7 @@ pub unsafe extern "C" fn dav1d_apply_grain( .cast::>()) .update_rav1d(); } - if let Some(mut itut_t35_ref) = NonNull::new(in_0.itut_t35_ref) { - (*itut_t35_ref - .as_mut() - .data - .cast::>()) - .update_rav1d(); - } + // Don't `.update_rav1d` [`Rav1dITUTT35`] because we never read it. let mut out_rust = MaybeUninit::zeroed().assume_init(); // TODO(kkysen) Temporary until we return it directly. let in_rust = in_0.into(); let result = rav1d_apply_grain(c, &mut out_rust, &in_rust);