diff --git a/adder-codec-rs/src/framer/scale_intensity.rs b/adder-codec-rs/src/framer/scale_intensity.rs index 86209fef..d06f7f53 100644 --- a/adder-codec-rs/src/framer/scale_intensity.rs +++ b/adder-codec-rs/src/framer/scale_intensity.rs @@ -68,7 +68,7 @@ impl FrameValue for u8 { FramedViewMode::Intensity => { let intensity = event_to_intensity(event); match source_type { - SourceType::U8 => (intensity * tpf) as u8, + SourceType::U8 => ((intensity * tpf) - 1.0) as u8, SourceType::U16 => { (intensity / f64::from(u16::MAX) * tpf * f64::from(u8::MAX)) as u8 } diff --git a/adder-codec-rs/src/transcoder/event_pixel_tree.rs b/adder-codec-rs/src/transcoder/event_pixel_tree.rs index 98f85030..7fec9a86 100644 --- a/adder-codec-rs/src/transcoder/event_pixel_tree.rs +++ b/adder-codec-rs/src/transcoder/event_pixel_tree.rs @@ -56,7 +56,7 @@ pub struct PixelArena { pub last_fired_t: f32, pub(crate) running_t: f32, length: usize, - pub base_val: u8, + pub base_val: u16, pub need_to_pop_top: bool, pub arena: SmallVec<[PixelNode; 6]>, pub(crate) c_thresh: u8, diff --git a/adder-codec-rs/src/transcoder/source/prophesee.rs b/adder-codec-rs/src/transcoder/source/prophesee.rs index c1fb22e1..a9b36831 100644 --- a/adder-codec-rs/src/transcoder/source/prophesee.rs +++ b/adder-codec-rs/src/transcoder/source/prophesee.rs @@ -212,7 +212,7 @@ impl Source for Prophesee { let _ = integrate_for_px( px, &mut base_val, - last_val as u8, + last_val as u16, intensity_to_integrate as f32, time_spanned as f32, &mut events, @@ -250,7 +250,7 @@ impl Source for Prophesee { let _ = integrate_for_px( px, &mut base_val, - new_val as u8, + new_val as u16, intensity_to_integrate as f32, time_spanned as f32, &mut events, @@ -352,7 +352,7 @@ fn end_events(prophesee: &mut Prophesee< let _ = integrate_for_px( px, &mut base_val, - last_val as u8, + last_val as u16, intensity_to_integrate as f32, time_spanned as f32, &mut events, diff --git a/adder-codec-rs/src/transcoder/source/video.rs b/adder-codec-rs/src/transcoder/source/video.rs index 5f6470bf..b3ce638b 100644 --- a/adder-codec-rs/src/transcoder/source/video.rs +++ b/adder-codec-rs/src/transcoder/source/video.rs @@ -694,7 +694,7 @@ impl Video { integrate_for_px( px, base_val, - *input as u8, + *input as u16, *input, // In this case, frame val is the same as intensity to integrate time_spanned, &mut buffer, @@ -778,9 +778,9 @@ impl Video { ) .for_each(|(mut px, frame_chunk)| { for (px, frame_val) in px.iter_mut().zip(frame_chunk.iter()) { - let d_start = f32::from(*frame_val).log2().floor() as D; + let d_start = (f32::from(*frame_val) + 1.0).log2().floor() as D; px.arena[0].set_d(d_start); - px.base_val = *frame_val; + px.base_val = *frame_val as u16 + 1; } }); } @@ -1278,14 +1278,17 @@ impl Video { #[inline(always)] pub fn integrate_for_px( px: &mut PixelArena, - base_val: &mut u8, - frame_val: u8, - intensity: Intensity32, + base_val: &mut u16, + mut frame_val: u16, + mut intensity: Intensity32, time_spanned: f32, buffer: &mut Vec, params: &VideoStateParams, parameters: &CrfParameters, ) -> bool { + frame_val += 1; + intensity += 1.0; + let _start_len = buffer.len(); let mut grew_buffer = false; if px.need_to_pop_top { @@ -1295,8 +1298,8 @@ pub fn integrate_for_px( *base_val = px.base_val; - if frame_val < base_val.saturating_sub(px.c_thresh) - || frame_val > base_val.saturating_add(px.c_thresh) + if frame_val < base_val.saturating_sub(px.c_thresh as u16) + || frame_val > base_val.saturating_add(px.c_thresh as u16) { let _tmp = buffer.len(); px.pop_best_events(