Skip to content

Commit

Permalink
change fields of Rav1dFrameHeader to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Mar 6, 2024
1 parent 5e16328 commit 6fa550a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
18 changes: 9 additions & 9 deletions include/dav1d/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2266,8 +2266,8 @@ pub struct Rav1dFrameHeader {
pub showable_frame: c_int,
pub error_resilient_mode: c_int,
pub disable_cdf_update: c_int,
pub allow_screen_content_tools: c_int,
pub force_integer_mv: c_int,
pub allow_screen_content_tools: bool,
pub force_integer_mv: bool,
pub frame_size_override: c_int,
pub primary_ref_frame: c_int,
pub buffer_removal_time_present: c_int,
Expand All @@ -2276,7 +2276,7 @@ pub struct Rav1dFrameHeader {
pub allow_intrabc: c_int,
pub frame_ref_short_signaling: c_int,
pub refidx: [c_int; RAV1D_REFS_PER_FRAME],
pub hp: c_int,
pub hp: bool,
pub subpel_filter_mode: Rav1dFilterMode,
pub switchable_motion_mode: c_int,
pub use_ref_frame_mvs: c_int,
Expand Down Expand Up @@ -2373,8 +2373,8 @@ impl From<Dav1dFrameHeader> for Rav1dFrameHeader {
showable_frame,
error_resilient_mode,
disable_cdf_update,
allow_screen_content_tools,
force_integer_mv,
allow_screen_content_tools: allow_screen_content_tools != 0,
force_integer_mv: force_integer_mv != 0,
frame_size_override,
primary_ref_frame,
buffer_removal_time_present,
Expand All @@ -2383,7 +2383,7 @@ impl From<Dav1dFrameHeader> for Rav1dFrameHeader {
allow_intrabc,
frame_ref_short_signaling,
refidx,
hp,
hp: hp != 0,
subpel_filter_mode: subpel_filter_mode.try_into().unwrap(),
switchable_motion_mode,
use_ref_frame_mvs,
Expand Down Expand Up @@ -2486,8 +2486,8 @@ impl From<Rav1dFrameHeader> for Dav1dFrameHeader {
showable_frame,
error_resilient_mode,
disable_cdf_update,
allow_screen_content_tools,
force_integer_mv,
allow_screen_content_tools: allow_screen_content_tools.into(),
force_integer_mv: force_integer_mv.into(),
frame_size_override,
primary_ref_frame,
buffer_removal_time_present,
Expand All @@ -2500,7 +2500,7 @@ impl From<Rav1dFrameHeader> for Dav1dFrameHeader {
allow_intrabc,
frame_ref_short_signaling,
refidx,
hp,
hp: hp.into(),
subpel_filter_mode: subpel_filter_mode.into(),
switchable_motion_mode,
use_ref_frame_mvs,
Expand Down
16 changes: 8 additions & 8 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ unsafe fn read_mv_component_diff(
have_fp: bool,
) -> c_int {
let ts = &mut *t.ts;
let have_hp = f.frame_hdr.as_ref().unwrap().hp != 0;
let have_hp = f.frame_hdr.as_ref().unwrap().hp;
let sign = rav1d_msac_decode_bool_adapt(&mut ts.msac, &mut mv_comp.sign.0);
let cl = rav1d_msac_decode_symbol_adapt16(&mut ts.msac, &mut mv_comp.classes.0, 10);
let mut up;
Expand Down Expand Up @@ -2015,7 +2015,7 @@ unsafe fn decode_b_inner(
}

*b.pal_sz_mut() = [0, 0];
if frame_hdr.allow_screen_content_tools != 0 && cmp::max(bw4, bh4) <= 16 && bw4 + bh4 >= 4 {
if frame_hdr.allow_screen_content_tools && cmp::max(bw4, bh4) <= 16 && bw4 + bh4 >= 4 {
let sz_ctx = b_dim[2] + b_dim[3] - 2;
if b.y_mode() == DC_PRED {
let pal_ctx = ((*t.a).pal_sz.0[bx4 as usize] > 0) as usize
Expand Down Expand Up @@ -2657,7 +2657,7 @@ unsafe fn decode_b_inner(
f,
&mut b.mv_mut()[idx],
&mut ts.cdf.mv,
frame_hdr.force_integer_mv == 0,
!frame_hdr.force_integer_mv,
);
}
_ => {}
Expand Down Expand Up @@ -2948,7 +2948,7 @@ unsafe fn decode_b_inner(
f,
&mut *b.mv_mut().as_mut_ptr().offset(0),
&mut ts.cdf.mv,
frame_hdr.force_integer_mv == 0,
!frame_hdr.force_integer_mv,
);
if debug_block_info!(f, t) {
println!(
Expand Down Expand Up @@ -3008,7 +3008,7 @@ unsafe fn decode_b_inner(
&& b.interintra_type() == INTER_INTRA_NONE
&& cmp::min(bw4, bh4) >= 2
// is not warped global motion
&& !(frame_hdr.force_integer_mv == 0
&& !(!frame_hdr.force_integer_mv
&& b.inter_mode() == GLOBALMV
&& frame_hdr.gmv[b.r#ref()[0] as usize].r#type > RAV1D_WM_TYPE_TRANSLATION)
// has overlappable neighbours
Expand All @@ -3031,7 +3031,7 @@ unsafe fn decode_b_inner(
&mut mask,
);
let allow_warp = (f.svc[b.r#ref()[0] as usize][0].scale == 0
&& frame_hdr.force_integer_mv == 0
&& !frame_hdr.force_integer_mv
&& frame_hdr.warp_motion != 0
&& mask[0] | mask[1] != 0) as c_int;

Expand Down Expand Up @@ -4363,7 +4363,7 @@ pub(crate) unsafe fn rav1d_decode_frame_init(
// TODO: Fallible allocation
f.frame_thread.cf.resize(cf_sz as usize * 128 * 128 / 2, 0);

if frame_hdr.allow_screen_content_tools != 0 {
if frame_hdr.allow_screen_content_tools {
// TODO: Fallible allocation
f.frame_thread
.pal
Expand Down Expand Up @@ -5049,7 +5049,7 @@ pub unsafe fn rav1d_submit_frame(c: &mut Rav1dContext) -> Rav1dResult {
f.svc[i][0].scale = f.svc[i][1].scale;
}
f.gmv_warp_allowed[i] = (frame_hdr.gmv[i].r#type > RAV1D_WM_TYPE_TRANSLATION
&& frame_hdr.force_integer_mv == 0
&& !frame_hdr.force_integer_mv
&& !rav1d_get_shear_params(&frame_hdr.gmv[i])
&& f.svc[i][0].scale == 0) as u8;
}
Expand Down
14 changes: 7 additions & 7 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,9 @@ fn fix_int_mv_precision(mv: &mut mv) {

#[inline]
pub(crate) fn fix_mv_precision(hdr: &Rav1dFrameHeader, mv: &mut mv) {
if hdr.force_integer_mv != 0 {
if hdr.force_integer_mv {
fix_int_mv_precision(mv);
} else if (*hdr).hp == 0 {
} else if !(*hdr).hp {
mv.x = (mv.x - (mv.x >> 15)) & !1;
mv.y = (mv.y - (mv.y >> 15)) & !1;
}
Expand All @@ -671,7 +671,7 @@ pub(crate) fn get_gmv_2d(
y: (gmv.matrix[0] >> 13) as i16,
x: (gmv.matrix[1] >> 13) as i16,
};
if hdr.force_integer_mv != 0 {
if hdr.force_integer_mv {
fix_int_mv_precision(&mut res);
}
return res;
Expand All @@ -685,13 +685,13 @@ pub(crate) fn get_gmv_2d(
let y = by4 * 4 + bh4 * 2 - 1;
let xc = (gmv.matrix[2] - (1 << 16)) * x + gmv.matrix[3] * y + gmv.matrix[0];
let yc = (gmv.matrix[5] - (1 << 16)) * y + gmv.matrix[4] * x + gmv.matrix[1];
let shift = 16 - (3 - (hdr.hp == 0) as c_int);
let shift = 16 - (3 - !hdr.hp as c_int);
let round = 1 << shift >> 1;
let mut res = mv {
y: apply_sign(yc.abs() + round >> shift << (hdr.hp == 0) as c_int, yc) as i16,
x: apply_sign(xc.abs() + round >> shift << (hdr.hp == 0) as c_int, xc) as i16,
y: apply_sign(yc.abs() + round >> shift << !hdr.hp as c_int, yc) as i16,
x: apply_sign(xc.abs() + round >> shift << !hdr.hp as c_int, xc) as i16,
};
if hdr.force_integer_mv != 0 {
if hdr.force_integer_mv {
fix_int_mv_precision(&mut res);
}
return res;
Expand Down
6 changes: 3 additions & 3 deletions src/obu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2011,8 +2011,8 @@ unsafe fn parse_frame_hdr(
showable_frame,
error_resilient_mode,
disable_cdf_update,
allow_screen_content_tools: allow_screen_content_tools as c_int,
force_integer_mv: force_integer_mv as c_int,
allow_screen_content_tools,
force_integer_mv,
frame_size_override,
primary_ref_frame,
buffer_removal_time_present,
Expand All @@ -2021,7 +2021,7 @@ unsafe fn parse_frame_hdr(
allow_intrabc,
frame_ref_short_signaling,
refidx,
hp: hp as c_int,
hp,
subpel_filter_mode,
switchable_motion_mode,
use_ref_frame_mvs,
Expand Down

0 comments on commit 6fa550a

Please sign in to comment.