mirror of
https://github.com/cberner/raptorq.git
synced 2024-06-28 09:41:41 +00:00
Implement Deg function
This commit is contained in:
parent
44f8a2e75e
commit
12ac0988d9
17
src/base.rs
17
src/base.rs
@ -1,3 +1,5 @@
|
||||
use std::cmp::min;
|
||||
|
||||
// As defined in section 3.2
|
||||
pub struct PayloadId {
|
||||
pub source_block_number: u8,
|
||||
@ -23,3 +25,18 @@ pub struct EncodingPacket {
|
||||
pub symbol: Vec<u8>
|
||||
}
|
||||
|
||||
// Deg[v] as defined in section 5.3.5.2
|
||||
pub fn deg(v: u32, lt_symbols: u32) -> u32 {
|
||||
assert!(v < 1048576);
|
||||
let f: [u32; 31] = [
|
||||
0, 5243, 529531, 704294, 791675, 844104, 879057, 904023, 922747, 937311, 948962,
|
||||
958494, 966438, 973160, 978921, 983914, 988283, 992138, 995565, 998631, 1001391,
|
||||
1003887, 1006157, 1008229, 1010129, 1011876, 1013490, 1014983, 1016370, 1017662, 1048576];
|
||||
|
||||
for d in 1..f.len() {
|
||||
if v < f[d] {
|
||||
return min(d as u32, lt_symbols - 2);
|
||||
}
|
||||
}
|
||||
panic!();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user