Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
// Ogg decoder and encoder written in Rust
//
// Copyright (c) 2016 est31 <MTest31@outlook.com>
// and contributors. All rights reserved.
// Licensed under MIT license, or Apache 2 license,
// at your option. Please see the LICENSE file
// attached to this source distribution for details.
fn main() {
print_crc32_table();
}
fn get_tbl_elem(idx :u32) -> u32 {
let mut r :u32 = idx << 24;
for _ in 0..8 {
r = (r << 1) ^ (-(((r >> 31) & 1) as i32) as u32 & 0x04c11db7);
}
return r;
}
fn print_crc32_table() {
let mut lup_arr :[u32; 0x100] = [0; 0x100];
for i in 0..0x100 {
lup_arr[i] = get_tbl_elem(i as u32);
}
print_slice("CRC_LOOKUP_ARRAY", &lup_arr);
}
fn print_slice(name :&str, arr :&[u32]) {
assert!(arr.len() > 4);
println!("static {} : &[u32] = &[", name);
let mut i :usize = 0;
while i * 4 < arr.len() - 4 {
println!("\t0x{:08x}, 0x{:08x}, 0x{:08x}, 0x{:08x},",
arr[i * 4], arr[i * 4 + 1], arr[i * 4 + 2], arr[i * 4 + 3]);
i += 1;
}
match arr.len() as i64 - i as i64 * 4 {
1 => println!("\t0x{:08x}];", arr[i * 4]),
2 => println!("\t0x{:08x}, 0x{:08x}];", arr[i * 4], arr[i * 4 + 1]),
3 => println!("\t0x{:08x}, 0x{:08x}, 0x{:08x}];",
arr[i * 4], arr[i * 4 + 1], arr[i * 4 + 2]),
4 => println!("\t0x{:08x}, 0x{:08x}, 0x{:08x}, 0x{:08x}];",
arr[i * 4], arr[i * 4 + 1], arr[i * 4 + 2], arr[i * 4 + 3]),
de => panic!("impossible value {}", de),
}
}

87
vendor/ogg/examples/dump-all.rs vendored Normal file
View File

@@ -0,0 +1,87 @@
// Ogg decoder and encoder written in Rust
//
// Copyright (c) 2018 est31 <MTest31@outlook.com>
// and contributors. All rights reserved.
// Licensed under MIT license, or Apache 2 license,
// at your option. Please see the LICENSE file
// attached to this source distribution for details.
extern crate ogg;
use std::env;
use ogg::{PacketReader, Packet};
use std::fs::File;
fn main() {
match run() {
Ok(_) =>(),
Err(err) => println!("Error: {}", err),
}
}
#[allow(dead_code)]
fn print_u8_slice(arr :&[u8]) {
if arr.len() <= 4 {
for a in arr {
print!("0x{:02x} ", a);
}
println!("");
return;
}
println!("[");
let mut i :usize = 0;
while i * 4 < arr.len() - 4 {
println!("\t0x{:02x}, 0x{:02x}, 0x{:02x}, 0x{:02x},",
arr[i * 4], arr[i * 4 + 1], arr[i * 4 + 2], arr[i * 4 + 3]);
i += 1;
}
match arr.len() as i64 - i as i64 * 4 {
1 => println!("\t0x{:02x}];", arr[i * 4]),
2 => println!("\t0x{:02x}, 0x{:02x}];", arr[i * 4], arr[i * 4 + 1]),
3 => println!("\t0x{:02x}, 0x{:02x}, 0x{:02x}];",
arr[i * 4], arr[i * 4 + 1], arr[i * 4 + 2]),
4 => println!("\t0x{:02x}, 0x{:02x}, 0x{:02x}, 0x{:02x}];",
arr[i * 4], arr[i * 4 + 1], arr[i * 4 + 2], arr[i * 4 + 3]),
de => panic!("impossible value {}", de),
}
}
fn dump_pck_info(p :&Packet, ctr :usize) {
println!("Packet: serial 0x{:08x}, data {:08} large, first {: >5}, last {: >5}, absgp 0x{:016x} nth {}",
p.stream_serial(), p.data.len(), p.first_in_page(), p.last_in_page(),
p.absgp_page(), ctr);
print_u8_slice(&p.data);
}
fn run() -> Result<(), std::io::Error> {
let file_path = env::args().nth(1).expect("No arg found. Please specify a file to open.");
println!("Opening file: {}", file_path);
let mut f = try!(File::open(file_path));
let mut pck_rdr = PacketReader::new(&mut f);
let mut ctr = 0;
loop {
let r = pck_rdr.read_packet();
match r {
Ok(Some(p)) => {
dump_pck_info(&p, ctr);
// Why do we not check p.last_packet here, and break the loop if false?
// Well, first, this is only an example.
// Second, the codecs may end streams in the middle of the file,
// while still continuing other streams.
// Therefore, don't do a probably too-early break.
// Applications which know the codec may know after which
// ended stream to stop decoding the file and thus not
// encounter an error.
},
// End of stream
Ok(None) => break,
Err(e) => {
println!("Encountered Error: {:?}", e);
break;
}
}
ctr+=1;
}
Ok(())
}

68
vendor/ogg/examples/format-info.rs vendored Normal file
View File

@@ -0,0 +1,68 @@
// Ogg decoder and encoder written in Rust
//
// Copyright (c) 2016 est31 <MTest31@outlook.com>
// and contributors. All rights reserved.
// Licensed under MIT license, or Apache 2 license,
// at your option. Please see the LICENSE file
// attached to this source distribution for details.
extern crate ogg;
use std::env;
use ogg::{PacketReader, Packet};
use std::fs::File;
use std::time::Instant;
fn main() {
match run() {
Ok(_) =>(),
Err(err) => println!("Error: {}", err),
}
}
fn dump_pck_info(p :&Packet) {
println!("Packet: serial 0x{:08x}, data {:08} large, first {: >5}, last {: >5}, absgp 0x{:016x}",
p.stream_serial(), p.data.len(), p.first_in_page(), p.last_in_page(),
p.absgp_page());
}
fn run() -> Result<(), std::io::Error> {
let file_path = env::args().nth(1).expect("No arg found. Please specify a file to open.");
println!("Opening file: {}", file_path);
let mut f = try!(File::open(file_path));
let mut pck_rdr = PacketReader::new(&mut f);
let mut byte_ctr :u64 = 0;
let begin = Instant::now();
loop {
let r = pck_rdr.read_packet();
match r {
Ok(Some(p)) => {
byte_ctr += p.data.len() as u64;
dump_pck_info(&p);
let elapsed = begin.elapsed();
let elapsed_ms = 1000.0 * elapsed.as_secs() as f64 +
elapsed.subsec_nanos() as f64 / 1000_000.0;
println!("speed: {:.3} kb per ms ({} read)",
byte_ctr as f64 / elapsed_ms / 1000.0,
byte_ctr);
// Why do we not check p.last_packet here, and break the loop if false?
// Well, first, this is only an example.
// Second, the codecs may end streams in the middle of the file,
// while still continuing other streams.
// Therefore, don't do a probably too-early break.
// Applications which know the codec may know after which
// ended stream to stop decoding the file and thus not
// encounter an error.
},
// End of stream
Ok(None) => break,
Err(e) => {
println!("Encountered Error: {:?}", e);
break;
}
}
}
Ok(())
}

75
vendor/ogg/examples/repack.rs vendored Normal file
View File

@@ -0,0 +1,75 @@
// Ogg decoder and encoder written in Rust
//
// Copyright (c) 2018 est31 <MTest31@outlook.com>
// and contributors. All rights reserved.
// Licensed under MIT license, or Apache 2 license,
// at your option. Please see the LICENSE file
// attached to this source distribution for details.
extern crate ogg;
use std::env;
use ogg::{PacketReader, PacketWriter};
use ogg::writing::PacketWriteEndInfo;
use std::fs::File;
fn main() {
match run() {
Ok(_) =>(),
Err(err) => println!("Error: {}", err),
}
}
macro_rules! btry {
($e:expr) => {
match $e {
Ok(v) => v,
Err(e) => {
println!("Encountered Error: {:?}", e);
break;
},
}
};
}
fn run() -> Result<(), std::io::Error> {
let input_path = env::args().nth(1).expect("No arg for input path found. Please specify a file to open.");
let output_path = env::args().nth(2).expect("No arg for output path found. Please specify a file to save to.");
println!("Opening file: {}", input_path);
println!("Writing to: {}", output_path);
let mut f_i = try!(File::open(input_path));
let mut f_o = try!(File::create(output_path));
let mut pck_rdr = PacketReader::new(&mut f_i);
// This call doesn't discard anything as nothing has
// been stored yet, but it does set bits that
// make reading logic a bit more tolerant towards
// errors.
pck_rdr.delete_unread_packets();
let mut pck_wtr = PacketWriter::new(&mut f_o);
loop {
let r = btry!(pck_rdr.read_packet());
match r {
Some(pck) => {
let inf = if pck.last_in_stream() {
PacketWriteEndInfo::EndStream
} else if pck.last_in_page() {
PacketWriteEndInfo::EndPage
} else {
PacketWriteEndInfo::NormalPacket
};
let stream_serial = pck.stream_serial();
let absgp_page = pck.absgp_page();
btry!(pck_wtr.write_packet(pck.data.into_boxed_slice(),
stream_serial,
inf,
absgp_page));
},
// End of stream
None => break,
}
}
Ok(())
}