Magic-number/taxonomy pass: central wire-format + sector + unit consts
- libfreemkv::consts: coding_type::* (ES coding-type bytes), pes_stream_id::* + PAYLOAD_RANGE, SECTOR_BYTES (usize) + SECTOR_BYTES_U64 (offset math) - replace bare wire-code/sector literals across disc, mpls, clpi, labels, m2ts_mux, ps, tsmux, file_sector_source, extract - remove two unreachable secondary-stream match arms in mpls parse_stream_entry
This commit is contained in:
+3
-3
@@ -24,7 +24,7 @@ use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use crate::consts::SECTOR_BYTES;
|
||||
use crate::consts::{SECTOR_BYTES, SECTOR_BYTES_U64};
|
||||
/// AACS aligned unit = 3 sectors / 6144 bytes. Content reads are issued in
|
||||
/// multiples of this so the decrypt step always sees whole units.
|
||||
const AACS_UNIT_SECTORS: u32 = 3;
|
||||
@@ -282,7 +282,7 @@ impl Disc {
|
||||
for &(abs_lba, byte_len) in &pf.extents {
|
||||
extents.push(crate::disc::Extent {
|
||||
start_lba: abs_lba,
|
||||
sector_count: (byte_len as u64).div_ceil(SECTOR_BYTES as u64) as u32,
|
||||
sector_count: (byte_len as u64).div_ceil(SECTOR_BYTES_U64) as u32,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -467,7 +467,7 @@ fn extract_one_file<S: SectorSource>(
|
||||
// the per-extent re-anchoring in the mux read paths
|
||||
// (`mux/disc.rs`, `sector/prefetched.rs`). No-op for CSS / None.
|
||||
dec.set_unit_base(abs_lba);
|
||||
let sectors = (byte_len as u64).div_ceil(SECTOR_BYTES as u64) as u32;
|
||||
let sectors = (byte_len as u64).div_ceil(SECTOR_BYTES_U64) as u32;
|
||||
let mut sector_off: u32 = 0;
|
||||
while sector_off < sectors {
|
||||
let mut batch = (sectors - sector_off).min(READ_BATCH_SECTORS);
|
||||
|
||||
+24
-23
@@ -627,28 +627,29 @@ impl Codec {
|
||||
];
|
||||
|
||||
pub(crate) fn from_coding_type(ct: u8) -> Self {
|
||||
use crate::consts::coding_type as c;
|
||||
match ct {
|
||||
0x24 => Codec::Hevc,
|
||||
0x1B => Codec::H264,
|
||||
0xEA => Codec::Vc1,
|
||||
0x02 => Codec::Mpeg2,
|
||||
0x83 => Codec::TrueHd,
|
||||
0x86 => Codec::DtsHdMa,
|
||||
0x85 => Codec::DtsHdHr,
|
||||
0x82 => Codec::Dts,
|
||||
0x81 => Codec::Ac3,
|
||||
0x84 | 0xA1 => Codec::Ac3Plus,
|
||||
0x80 => Codec::Lpcm,
|
||||
// 0x86 (primary) / 0xA2 (secondary) are the DTS-HD MA
|
||||
// lossless pair, parallel to 0x81/0xA1 for AC-3. 0xA2 is
|
||||
// lossless MA, not lossy HR.
|
||||
0xA2 => Codec::DtsHdMa,
|
||||
// 0x90 = Presentation Graphics (PG / subtitles). 0x91 = Interactive
|
||||
// Graphics (IG / menus) and 0x92 = Text subtitles are distinct HDMV
|
||||
// coding types and are NOT PG subtitle streams; only 0x90 maps to
|
||||
// Pgs. IG (0x91) falls through to Unknown so the PMT/STN walker drops
|
||||
// it rather than surfacing a bogus PGS subtitle track for a menu ES.
|
||||
0x90 => Codec::Pgs,
|
||||
c::HEVC => Codec::Hevc,
|
||||
c::H264 => Codec::H264,
|
||||
c::VC1 => Codec::Vc1,
|
||||
c::MPEG2_VIDEO => Codec::Mpeg2,
|
||||
c::TRUEHD => Codec::TrueHd,
|
||||
c::DTS_HD_MA => Codec::DtsHdMa,
|
||||
c::DTS_HD_HR => Codec::DtsHdHr,
|
||||
c::DTS => Codec::Dts,
|
||||
c::AC3 => Codec::Ac3,
|
||||
c::AC3_PLUS | c::AC3_PLUS_SECONDARY => Codec::Ac3Plus,
|
||||
c::LPCM => Codec::Lpcm,
|
||||
// DTS_HD_MA (primary 0x86) / DTS_HD_SECONDARY (0xA2) are the
|
||||
// DTS-HD MA lossless pair, parallel to AC3/AC3_PLUS_SECONDARY for
|
||||
// AC-3. The secondary code is lossless MA, not lossy HR.
|
||||
c::DTS_HD_SECONDARY => Codec::DtsHdMa,
|
||||
// PG (0x90) = Presentation Graphics (subtitles). IG (0x91, menus)
|
||||
// and TEXT_SUBTITLE (0x92) are distinct HDMV coding types and are
|
||||
// NOT PG subtitle streams; only PG maps to Pgs. IG falls through to
|
||||
// Unknown so the PMT/STN walker drops it rather than surfacing a
|
||||
// bogus PGS subtitle track for a menu ES.
|
||||
c::PG => Codec::Pgs,
|
||||
ct => Codec::Unknown(ct),
|
||||
}
|
||||
}
|
||||
@@ -5068,8 +5069,8 @@ mod tests {
|
||||
let mf = Mapfile::load(&disc.mapfile_for(&iso_path)).expect("load mapfile");
|
||||
let good = mf.ranges_with(&[SectorStatus::Finished]);
|
||||
let bad_ranges = mf.ranges_with(&[SectorStatus::NonTrimmed]);
|
||||
let disc_bytes = sectors as u64 * 2048;
|
||||
const SEC: u64 = crate::consts::SECTOR_BYTES as u64;
|
||||
const SEC: u64 = crate::consts::SECTOR_BYTES_U64;
|
||||
let disc_bytes = sectors as u64 * SEC;
|
||||
|
||||
// The first failing batch starts at LBA 320; everything before it read
|
||||
// cleanly and must be Finished.
|
||||
|
||||
Reference in New Issue
Block a user