1
Fork 0

remove unused in decoder

This commit is contained in:
Andy Killorin 2025-07-19 18:01:46 -05:00
parent a38fa94304
commit 7b08c2d61a
Signed by: ank
GPG key ID: 23F9463ECB67FE8C
3 changed files with 11 additions and 147 deletions

122
decoder/Cargo.lock generated
View file

@ -44,29 +44,12 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "bytemuck"
version = "1.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3"
[[package]]
name = "bytes"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b"
[[package]]
name = "cc"
version = "1.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333"
dependencies = [
"jobserver",
"libc",
"shlex",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -77,7 +60,6 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
name = "decoder"
version = "0.1.0"
dependencies = [
"openh264",
"tokio",
"zune-jpeg",
]
@ -88,15 +70,6 @@ version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]]
name = "jobserver"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
dependencies = [
"libc",
]
[[package]]
name = "libc"
version = "0.2.169"
@ -136,15 +109,9 @@ checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd"
dependencies = [
"libc",
"wasi",
"windows-sys 0.52.0",
"windows-sys",
]
[[package]]
name = "nasm-rs"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12fcfa1bd49e0342ec1d07ed2be83b59963e7acbeb9310e1bb2c07b69dadd959"
[[package]]
name = "object"
version = "0.36.7"
@ -154,27 +121,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "openh264"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c1af3a4d35290ba7a46d1ce69cb13ae740a2d72cc2ee00abee3c84bed3dbe5d"
dependencies = [
"openh264-sys2",
"wide",
]
[[package]]
name = "openh264-sys2"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a77c1e18503537113d77b1b1d05274e81fa9f44843c06be2d735adb19f7c9d"
dependencies = [
"cc",
"nasm-rs",
"walkdir",
]
[[package]]
name = "parking_lot"
version = "0.12.3"
@ -237,36 +183,12 @@ version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
[[package]]
name = "safe_arch"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96b02de82ddbe1b636e6170c21be622223aea188ef2e139be0a5b219ec215323"
dependencies = [
"bytemuck",
]
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "signal-hook-registry"
version = "1.4.2"
@ -289,7 +211,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys",
]
[[package]]
@ -318,7 +240,7 @@ dependencies = [
"signal-hook-registry",
"socket2",
"tokio-macros",
"windows-sys 0.52.0",
"windows-sys",
]
[[package]]
@ -338,41 +260,12 @@ version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
[[package]]
name = "walkdir"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
dependencies = [
"same-file",
"winapi-util",
]
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wide"
version = "0.7.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58e6db2670d2be78525979e9a5f9c69d296fd7d670549fe9ebf70f8708cb5019"
dependencies = [
"bytemuck",
"safe_arch",
]
[[package]]
name = "winapi-util"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
@ -382,15 +275,6 @@ dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"

View file

@ -4,7 +4,6 @@ version = "0.1.0"
edition = "2021"
[dependencies]
openh264 = "0.6.6"
tokio = { version = "1.42.0", features = ["full"] }
zune-jpeg = "0.4.14"

View file

@ -1,10 +1,9 @@
use std::{mem::transmute, net::{self, SocketAddr}, slice, sync::{Mutex, OnceLock}};
use std::{mem::transmute, slice};
use openh264::{decoder::Decoder, formats::YUVSource};
use zune_jpeg::{zune_core::{colorspace::ColorSpace, options::DecoderOptions}, JpegDecoder};
#[no_mangle]
pub extern fn add(a: u64, b: u64) -> u64 {
pub extern "C" fn add(a: u64, b: u64) -> u64 {
a + b
}
@ -12,14 +11,16 @@ pub extern fn add(a: u64, b: u64) -> u64 {
/// decode jpeg image of given length
///
/// image format is 0RGB
pub extern fn decode(image: &mut u32, packet: &u8, length: u32) -> u64 {
pub extern "C" fn decode(image: &mut u32, packet: &u8, length: u32) -> u64 {
let packet = unsafe {slice::from_raw_parts(packet, length as usize)};
let image: &mut [u8; 4*320*240] = unsafe{transmute(image)};
let options = DecoderOptions::new_fast().jpeg_set_out_colorspace(ColorSpace::RGB);
let mut frame = JpegDecoder::new_with_options(packet, options).decode().unwrap();
let Ok(mut frame) = JpegDecoder::new_with_options(packet, options).decode() else {
return 1; // decoder failure
};
// 0RGB conversion, easier than shifting and zeroing A
// convert from RGB to 0RGB (and swap endianness)
for (buffer, image) in frame.chunks_exact_mut(3).zip(image.chunks_exact_mut(4)) {
image[0] = buffer[2];
image[1] = buffer[1];
@ -27,25 +28,5 @@ pub extern fn decode(image: &mut u32, packet: &u8, length: u32) -> u64 {
image[3] = 0;
}
0
}
#[no_mangle]
pub extern fn blit_pattern(arr: &mut u32) -> u64 {
let arr: &mut [u32; 320*240] = unsafe{transmute(arr)};
let arr: &mut [[u32; 320];240] = unsafe{transmute(arr)};
for x in 0..320 {
for y in 0..240 {
let color = y%256
+ (x%256) * 256;
//*i = 0x00FF0000;
arr[y][x] = color as u32;
}
}
0
}
#[cfg(test)]
mod tests {
0 // success
}