Skip to content

Commit 3cb6cb3

Browse files
authored
Add arithmetic-coding dependency (with modifications) locally (#68)
* Add arithmetic-coding locally * add artih license * Clippy fixes * Clippy fixes * Set arithmetic dependency by path * Set arithmetic dependency by path * Update rust_action_test_and_docs.yml * Update rust_action_test_and_docs.yml * Update rust_action_test_and_docs.yml
1 parent 5847c9a commit 3cb6cb3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+16220
-103
lines changed

.github/workflows/rust_action_test_and_docs.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,25 @@ jobs:
3838
run: sudo apt-get install -y portaudio19-dev build-essential libpulse-dev libdbus-1-dev pkg-config libx11-dev libatk1.0-dev libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libwayland-dev libxkbcommon-dev
3939

4040
- name: Check project
41-
run: cargo check
41+
run: cargo check -p adder-codec-core -p adder-codec-rs -p adder-info -p adder-to-dvs -p adder-viz
4242

4343
- name: Build binaries for testing
4444
run: cargo build -p adder-info
4545

4646
- name: Test project
47-
run: cargo test -vv
47+
run: cargo test -vv -p adder-codec-core -p adder-codec-rs -p adder-info -p adder-to-dvs -p adder-viz
4848

49-
- name: Install cargo-llvm-cov
50-
uses: taiki-e/install-action@cargo-llvm-cov
51-
- uses: Swatinem/rust-cache@v2
52-
- name: run llvm-cov test
53-
# should test with --all-features if gpu support.
54-
run: cargo llvm-cov --workspace --lcov --output-path lcov.info
55-
- name: Upload coverage to Codecov
56-
uses: codecov/codecov-action@v3
57-
with:
58-
files: lcov.info
59-
fail_ci_if_error: false
49+
# - name: Install cargo-llvm-cov
50+
# uses: taiki-e/install-action@cargo-llvm-cov
51+
# - uses: Swatinem/rust-cache@v2
52+
# - name: run llvm-cov test
53+
# # should test with --all-features if gpu support.
54+
# run: cargo llvm-cov -p adder-codec-core -p adder-codec-rs -p adder-info -p adder-to-dvs -p adder-viz --lcov --output-path lcov.info
55+
# - name: Upload coverage to Codecov
56+
# uses: codecov/codecov-action@v3
57+
# with:
58+
# files: lcov.info
59+
# fail_ci_if_error: false
6060
- name: Run a documentation generation test
6161
run: cargo doc -vv -p adder-codec-rs --features=docs-only
6262
check_windows:
@@ -100,5 +100,5 @@ jobs:
100100
export OPENCV_LINK_PATHS="/C/tools/opencv/build/x64/vc15/lib"
101101
export OPENCV_LINK_LIBS="opencv_world${OPENCV_VERSION//./}"
102102
export OPENCV_INCLUDE_PATHS="/C/tools/opencv/build/include"
103-
cargo test -vv
103+
cargo test -vv -p adder-codec-core -p adder-codec-rs -p adder-info -p adder-to-dvs -p adder-viz
104104
shell: bash

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ members = [
55
"adder-info",
66
"adder-to-dvs",
77
"adder-viz",
8+
"arithmetic-coding",
9+
"arithmetic-coding/arithmetic-coding-core",
10+
"arithmetic-coding/fenwick-model",
811
]
912

1013
[profile.release]

adder-codec-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ default = []
1818
compression = ["dep:arithmetic-coding"]
1919

2020
[dependencies]
21-
arithmetic-coding = { git = "https://github.com/ac-freeman/arithmetic-coding.git", optional = true }
21+
arithmetic-coding = { path = "../arithmetic-coding", version = "0.3.1", optional = true }
2222
bincode = "1.3.3"
2323
bitstream-io = "1.6.0"
2424
itertools = "0.10.5"

adder-codec-core/src/codec/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ mod tests {
240240
use crate::codec::{CodecMetadata, LATEST_CODEC_VERSION};
241241

242242
use crate::{Coord, PlaneSize};
243-
use bitstream_io::{BigEndian, BitWriter};
243+
244244
use std::io::BufWriter;
245245

246246
#[test]

adder-codec-core/src/codec/raw/stream.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use crate::codec::compressed::adu::frame::Adu;
33
use crate::codec::header::{Magic, MAGIC_RAW};
44
use crate::codec::{CodecError, CodecMetadata, ReadCompression, WriteCompression};
5-
use crate::{Coord, DeltaT, Event, EventSingle, EOF_PX_ADDRESS};
5+
use crate::{Coord, Event, EventSingle, EOF_PX_ADDRESS};
66
use bincode::config::{FixintEncoding, WithOtherEndian, WithOtherIntEncoding};
77
use bincode::{DefaultOptions, Options};
88
use bitstream_io::{BigEndian, BitRead, BitReader};
@@ -98,7 +98,7 @@ impl<W: Write> WriteCompression<W> for RawOutput<W> {
9898
};
9999
self.bincode.serialize_into(self.stream(), &eof).unwrap();
100100
self.flush_writer().unwrap();
101-
std::mem::replace(&mut self.stream, None)
101+
self.stream.take()
102102
}
103103

104104
fn flush_writer(&mut self) -> std::io::Result<()> {
@@ -209,7 +209,7 @@ impl<W: Write> WriteCompression<W> for RawOutputInterleaved<W> {
209209
};
210210
self.bincode.serialize_into(self.stream(), &eof).unwrap();
211211
self.flush_writer().unwrap();
212-
std::mem::replace(&mut self.stream, None)
212+
self.stream.take()
213213
}
214214

215215
fn flush_writer(&mut self) -> std::io::Result<()> {
@@ -256,6 +256,12 @@ impl<W: Write> WriteCompression<W> for RawOutputInterleaved<W> {
256256
}
257257
}
258258

259+
impl<R: Read + Seek> Default for RawInput<R> {
260+
fn default() -> Self {
261+
Self::new()
262+
}
263+
}
264+
259265
impl<R: Read + Seek> RawInput<R> {
260266
/// Create a new raw input stream.
261267
pub fn new() -> Self

adder-codec-core/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod codec;
1111
mod codec_old;
1212
pub use bitstream_io;
1313
use bitstream_io::{BigEndian, BitReader};
14-
use std::cmp::{max, min, Ordering};
14+
use std::cmp::{Ordering};
1515
use std::fs::File;
1616
use std::io::BufReader;
1717
use std::ops::Add;
@@ -54,7 +54,7 @@ use crate::codec::compressed::blocks::{DeltaTResidual, EventResidual};
5454
use crate::codec::compressed::stream::CompressedInput;
5555
use crate::codec::decoder::Decoder;
5656
use crate::codec::raw::stream::RawInput;
57-
use crate::codec::{CodecError, ReadCompression};
57+
use crate::codec::{CodecError};
5858
use serde::{Deserialize, Serialize};
5959

6060
/// The type of time used in the ADΔER representation
@@ -535,7 +535,7 @@ pub fn open_file_decoder(
535535
),
536536
CodecError,
537537
> {
538-
let mut bufreader = BufReader::new(File::open(file_path)?);
538+
let bufreader = BufReader::new(File::open(file_path)?);
539539
let compression = RawInput::new();
540540
let mut bitreader = BitReader::endian(bufreader, BigEndian);
541541

adder-codec-rs/src/framer/scale_intensity.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl FrameValue for u8 {
9292
}
9393
FramedViewMode::SAE => {
9494
// Convert deltaT to absolute time
95-
((delta_t_max / 255 as u32) - (delta_t_max as f64 / sae_time_since) as u32) as u8
95+
((delta_t_max / 255_u32) - (delta_t_max as f64 / sae_time_since) as u32) as u8
9696
// We assume that the dt component is an absolute_t in this case
9797
}
9898
}
@@ -113,7 +113,7 @@ impl FrameValue for u16 {
113113
practical_d_max: f32,
114114
delta_t_max: DeltaT,
115115
view_mode: FramedViewMode,
116-
sae_time_since: f64,
116+
_sae_time_since: f64,
117117
) -> Self::Output {
118118
match view_mode {
119119
FramedViewMode::Intensity => {
@@ -166,7 +166,7 @@ impl FrameValue for u32 {
166166
practical_d_max: f32,
167167
delta_t_max: DeltaT,
168168
view_mode: FramedViewMode,
169-
sae_time_since: f64,
169+
_sae_time_since: f64,
170170
) -> Self::Output {
171171
match view_mode {
172172
FramedViewMode::Intensity => {
@@ -217,7 +217,7 @@ impl FrameValue for u64 {
217217
practical_d_max: f32,
218218
delta_t_max: DeltaT,
219219
view_mode: FramedViewMode,
220-
sae_time_since: f64,
220+
_sae_time_since: f64,
221221
) -> Self::Output {
222222
match view_mode {
223223
FramedViewMode::Intensity => {

adder-codec-rs/src/transcoder/source/davis.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ impl<W: Write + 'static> Integration<W> {
415415

416416
let db = match video.instantaneous_frame.data_bytes_mut() {
417417
Ok(db) => db,
418-
Err(e) => return Err(CodecError::MalformedEncoder), // TODO: Wrong type of error
418+
Err(_e) => return Err(CodecError::MalformedEncoder), // TODO: Wrong type of error
419419
};
420420

421421
// TODO: split off into separate function
@@ -843,7 +843,7 @@ impl<W: Write + 'static + std::marker::Send> Source<W> for Davis<W> {
843843
// };
844844
self.integration.dvs_events_last_after = self.integration.dvs_events_after.clone();
845845
self.integration.end_of_last_frame_timestamp =
846-
self.integration.end_of_frame_timestamp.clone();
846+
self.integration.end_of_frame_timestamp;
847847

848848
self.integration.dvs_last_timestamps.par_map_inplace(|ts| {
849849
debug_assert!(*ts < end_of_frame_timestamp);
@@ -889,7 +889,7 @@ impl<W: Write + 'static + std::marker::Send> Source<W> for Davis<W> {
889889
}
890890

891891
impl<W: Write + 'static> VideoBuilder<W> for Davis<W> {
892-
fn contrast_thresholds(mut self, c_thresh_pos: u8, c_thresh_neg: u8) -> Self {
892+
fn contrast_thresholds(mut self, c_thresh_pos: u8, _c_thresh_neg: u8) -> Self {
893893
self.video = self.video.c_thresh_pos(c_thresh_pos);
894894
// self.video = self.video.c_thresh_neg(c_thresh_neg);
895895
self
@@ -900,7 +900,7 @@ impl<W: Write + 'static> VideoBuilder<W> for Davis<W> {
900900
self
901901
}
902902

903-
fn c_thresh_neg(mut self, c_thresh_neg: u8) -> Self {
903+
fn c_thresh_neg(self, _c_thresh_neg: u8) -> Self {
904904
// self.video = self.video.c_thresh_neg(c_thresh_neg);
905905
self
906906
}

adder-codec-rs/src/transcoder/source/framed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<W: Write + 'static> Source<W> for Framed<W> {
184184
}
185185

186186
impl<W: Write + 'static> VideoBuilder<W> for Framed<W> {
187-
fn contrast_thresholds(mut self, c_thresh_pos: u8, c_thresh_neg: u8) -> Self {
187+
fn contrast_thresholds(mut self, c_thresh_pos: u8, _c_thresh_neg: u8) -> Self {
188188
self.video = self.video.c_thresh_pos(c_thresh_pos);
189189
// self.video = self.video.c_thresh_neg(c_thresh_neg);
190190
self

0 commit comments

Comments
 (0)