Fix cargo fmt formatting

This commit is contained in:
MattJackson
2026-04-16 17:51:45 +00:00
parent 24ca03a0ea
commit 58566c8910
8 changed files with 60 additions and 36 deletions
-3
View File
@@ -326,13 +326,11 @@ fn read_disc_key(drive: &mut Drive, agid: u8, bus_key: &[u8; 5]) -> Result<[u8;
// Disc key block starts at offset 4 (skip 4-byte header)
let disc_key_block = &mut buf[4..4 + 2048];
// XOR with reversed bus key (per libdvdcss)
for (i, byte) in disc_key_block.iter_mut().enumerate() {
*byte ^= bus_key[4 - (i % 5)];
}
// Try each player key against each of 408 disc key entries.
// Each entry in the block is the disc key encrypted with a specific player key.
// We try all known player keys and verify by checking that two different
@@ -421,7 +419,6 @@ fn read_title_key(
);
tk_result.map_err(|_| Error::CssAuthFailed)?;
// Title key at bytes 5..10, byte-reversed
let mut title_key = [0u8; 5];
for i in 0..5 {
+6 -2
View File
@@ -204,7 +204,9 @@ pub fn crack_title_key(sector: &[u8]) -> Option<[u8; 5]> {
// Padding stream (0xBE): payload is 0xFF bytes, various lengths
for len_hi in 0u8..8 {
for len_lo_top in [0x00u8, 0x80, 0xFF] {
patterns.push([0x00, 0x00, 0x01, 0xBE, len_hi, len_lo_top, 0xFF, 0xFF, 0xFF, 0xFF]);
patterns.push([
0x00, 0x00, 0x01, 0xBE, len_hi, len_lo_top, 0xFF, 0xFF, 0xFF, 0xFF,
]);
}
}
@@ -216,7 +218,9 @@ pub fn crack_title_key(sector: &[u8]) -> Option<[u8; 5]> {
let pts0 = if flags2 & 0x80 != 0 { 0x21u8 } else { 0x00 };
// Try with several PES lengths
for &len_hi in &[0x00u8, 0x07] {
patterns.push([0x00, 0x00, 0x01, sid, len_hi, 0x00, flags1, flags2, hdr_len, pts0]);
patterns.push([
0x00, 0x00, 0x01, sid, len_hi, 0x00, flags1, flags2, hdr_len, pts0,
]);
}
}
}
+8 -11
View File
@@ -958,18 +958,15 @@ impl Disc {
&& disc.content_format == ContentFormat::MpegPs
&& !disc.titles.is_empty()
{
let lba = disc.titles[0]
.extents
.iter()
.find_map(|ext| {
let mut buf = vec![0u8; 2048];
if session.read_sectors(ext.start_lba, 1, &mut buf).is_ok() {
if crate::css::is_scrambled(&buf) {
return Some(ext.start_lba);
}
let lba = disc.titles[0].extents.iter().find_map(|ext| {
let mut buf = vec![0u8; 2048];
if session.read_sectors(ext.start_lba, 1, &mut buf).is_ok() {
if crate::css::is_scrambled(&buf) {
return Some(ext.start_lba);
}
None
});
}
None
});
if let Some(lba) = lba {
if let Ok(title_key) =
+10 -3
View File
@@ -62,7 +62,10 @@ impl Default for Mpeg2Parser {
impl Mpeg2Parser {
pub fn new() -> Self {
Self { seq_header: None, has_extension: false }
Self {
seq_header: None,
has_extension: false,
}
}
/// Extract resolution from a captured sequence header.
@@ -137,14 +140,18 @@ impl CodecParser for Mpeg2Parser {
} else {
let mut bits = 63u32; // bits consumed so far
let intra = (data[sc + 11] & 0x02) != 0;
if intra { bits += 64 * 8; }
if intra {
bits += 64 * 8;
}
// Non-intra flag is at current bit position
let byte_pos = (bits / 8) as usize;
let bit_pos = 7 - (bits % 8) as u8;
if sc + 4 + byte_pos < data.len() {
let non_intra = (data[sc + 4 + byte_pos] >> bit_pos) & 1 != 0;
bits += 1;
if non_intra { bits += 64 * 8; }
if non_intra {
bits += 64 * 8;
}
}
let total_bytes = 4 + ((bits + 7) / 8) as usize;
(sc + total_bytes).min(data.len())
+4 -8
View File
@@ -285,8 +285,7 @@ impl crate::pes::Stream for DiscStream {
dts: ps.dts.map(|d| d as i64),
data: ps.data.clone(),
};
if let Some((_, parser)) =
self.parsers.iter_mut().find(|(p, _)| *p == pid)
if let Some((_, parser)) = self.parsers.iter_mut().find(|(p, _)| *p == pid)
{
for frame in parser.parse(&pes) {
self.pending_frames.push_back(
@@ -354,13 +353,10 @@ impl crate::pes::Stream for DiscStream {
data: ps.data.clone(),
};
if let Some((_, parser)) =
self.parsers.iter_mut().find(|(p, _)| *p == pid)
{
if let Some((_, parser)) = self.parsers.iter_mut().find(|(p, _)| *p == pid) {
for frame in parser.parse(&pes) {
self.pending_frames.push_back(
crate::pes::PesFrame::from_codec_frame(track, frame),
);
self.pending_frames
.push_back(crate::pes::PesFrame::from_codec_frame(track, frame));
}
}
}
+1 -1
View File
@@ -100,7 +100,7 @@ impl PesAssembler {
pub struct TsDemuxer {
assemblers: Vec<PesAssembler>,
pid_index: Vec<i16>, // PID → index into assemblers, -1 = not tracked
remainder: Vec<u8>, // leftover bytes from previous feed() call
remainder: Vec<u8>, // leftover bytes from previous feed() call
}
impl TsDemuxer {