diff options
author | metamuffin <metamuffin@disroot.org> | 2025-05-07 18:22:05 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-05-07 18:22:05 +0200 |
commit | 5a50400de98ddc84b1f0cc3dd1b319a0ee789ef6 (patch) | |
tree | c6f85cfc88bf3073fc03832e564facf5cac593b3 | |
parent | f8df7f3ff8028164f45953e3491e943e0ce7f642 (diff) | |
download | video-codec-experiments-5a50400de98ddc84b1f0cc3dd1b319a0ee789ef6.tar video-codec-experiments-5a50400de98ddc84b1f0cc3dd1b319a0ee789ef6.tar.bz2 video-codec-experiments-5a50400de98ddc84b1f0cc3dd1b319a0ee789ef6.tar.zst |
works
-rw-r--r-- | test2/src/encode.rs | 16 | ||||
-rw-r--r-- | test2/src/main.rs | 7 |
2 files changed, 10 insertions, 13 deletions
diff --git a/test2/src/encode.rs b/test2/src/encode.rs index c120e79..b024c17 100644 --- a/test2/src/encode.rs +++ b/test2/src/encode.rs @@ -25,8 +25,8 @@ impl BitstreamFilter for Enc { }; let mut out = Vec::new(); - let mut oldblock = Vec::new(); - let mut newblock = Vec::new(); + let mut savblock = Vec::new(); + let mut refblock = Vec::new(); for by in 0..frame.res.y / BLOCK_SIZE { for bx in 0..frame.res.x / BLOCK_SIZE { @@ -61,20 +61,18 @@ impl BitstreamFilter for Enc { } } - oldblock.clear(); - frame.export_block(boff, &mut oldblock); + savblock.clear(); + frame.export_block(boff, &mut savblock); - Frame::copy_block(&self.last, &mut frame, best_off, boff); - - newblock.clear(); - frame.export_block(boff, &mut newblock); + refblock.clear(); + self.last.export_block(best_off, &mut refblock); let reloff = best_off - boff; out.push((reloff.x + 127) as u8); out.push((reloff.y + 127) as u8); for i in 0..(BLOCK_SIZE * BLOCK_SIZE + BLOCK_SIZE * BLOCK_SIZE / 2) { - out.push(newblock[i as usize] - oldblock[i as usize] + 127) + out.push(savblock[i as usize] - refblock[i as usize]) } } } diff --git a/test2/src/main.rs b/test2/src/main.rs index 0b69026..aca978e 100644 --- a/test2/src/main.rs +++ b/test2/src/main.rs @@ -43,6 +43,7 @@ impl Frame { buf.extend(&self.data[y_off as usize..(y_off + BLOCK_SIZE) as usize]); } } + #[allow(unused)] fn import_block(&mut self, off: IVec2, buf: &[u8]) -> usize { let mut p = 0; // Luma @@ -68,8 +69,7 @@ impl Frame { let y_off = off.x + (y + off.y) * self.res.x; let i = y * BLOCK_SIZE; for x in 0..BLOCK_SIZE { - self.data[(y_off + x) as usize] = self.data[(y_off + x) as usize] - .saturating_add_signed(buf[(i + x) as usize] as i8 - 127); + self.data[(y_off + x) as usize] += buf[(i + x) as usize] as u8; } } // Chroma @@ -78,8 +78,7 @@ impl Frame { let y_off = uvplane_off + (off.x & !1) + (y + off.y / 2) * self.res.x; let i = BLOCK_SIZE * BLOCK_SIZE + y * BLOCK_SIZE; for x in 0..BLOCK_SIZE { - self.data[(y_off + x) as usize] = self.data[(y_off + x) as usize] - .saturating_add_signed(buf[(i + x) as usize] as i8 - 127); + self.data[(y_off + x) as usize] += buf[(i + x) as usize] as u8; } } (BLOCK_SIZE * BLOCK_SIZE + BLOCK_SIZE * BLOCK_SIZE / 2) as usize |