Skip to content

Commit

Permalink
struct {D,R}av1dContentLightLevel: Make the same type, as the `Dav1…
Browse files Browse the repository at this point in the history
…d*` version will be fully Rustified after #505 is fixed.
  • Loading branch information
kkysen committed Oct 1, 2023
1 parent e8290e2 commit 5bfebd1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 46 deletions.
34 changes: 2 additions & 32 deletions include/dav1d/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dav1dContentLightLevel> 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<Rav1dContentLightLevel> 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 {
Expand Down
6 changes: 3 additions & 3 deletions include/dav1d/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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],
Expand All @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/obu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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::<Dav1dContentLightLevel>());
rav1d_ref_create(::core::mem::size_of::<Rav1dContentLightLevel>());
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 =
Expand Down
4 changes: 2 additions & 2 deletions src/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5bfebd1

Please sign in to comment.