X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-registry%2Fsrc%2Fdetect.rs;h=92bb920e0e36555840d067f7c20a22242b2a62dc;hb=4b56e8c9d1b60914c154720561ba759a343d5bbf;hp=44b6e54c919b074646c167cf9bc94890ff8d6a77;hpb=32f7cbe538d71574f7ac05aa51599d2678f5db3f;p=nihav.git diff --git a/nihav-registry/src/detect.rs b/nihav-registry/src/detect.rs index 44b6e54..92bb920 100644 --- a/nihav-registry/src/detect.rs +++ b/nihav-registry/src/detect.rs @@ -198,6 +198,28 @@ const DETECTORS: &[DetectConditions] = &[ &CC::Str(b"ON2fLIST")) }, ] }, + DetectConditions { + demux_name: "wav", + extensions: ".wav", + conditions: &[CheckItem{offs: 0, cond: &CC::Str(b"RIFF") }, + CheckItem{offs: 8, cond: &CC::Str(b"WAVEfmt ") } + ] + }, + DetectConditions { + demux_name: "mov", + extensions: ".mov", + conditions: &[CheckItem{offs: 4, cond: &CC::Or(&CC::Or(&CC::Str(b"mdat"), + &CC::Str(b"moov")), + &CC::Str(b"ftyp")) }], + }, + DetectConditions { + demux_name: "mov", + extensions: ".mov", + conditions: &[CheckItem{offs: 0, cond: &CC::Str(b"\x00\x00\x00\x08wide") }, + CheckItem{offs: 12, cond: &CC::Or(&CC::Or(&CC::Str(b"mdat"), + &CC::Str(b"moov")), + &CC::Str(b"ftyp")) }], + }, DetectConditions { demux_name: "gdv", extensions: ".gdv", @@ -222,8 +244,8 @@ const DETECTORS: &[DetectConditions] = &[ DetectConditions { demux_name: "bink", extensions: ".bik,.bk2", - conditions: &[CheckItem{offs: 0, cond: &CC::Or(&CC::In(Arg::U32BE(0x32494B62), // BIKb - Arg::U32BE(0x32494B7B)), // BIKz + conditions: &[CheckItem{offs: 0, cond: &CC::Or(&CC::In(Arg::U32BE(0x42494B62), // BIKb + Arg::U32BE(0x42494B7B)), // BIKz &CC::In(Arg::U32BE(0x4B423261), // KB2a Arg::U32BE(0x4B42327B)))}], // KB2z }, @@ -232,6 +254,18 @@ const DETECTORS: &[DetectConditions] = &[ extensions: ".smk", conditions: &[CheckItem{offs: 0, cond: &CC::Or(&CC::Str(b"SMK2"), &CC::Str(b"SMK4"))}], }, + DetectConditions { + demux_name: "vivo", + extensions: ".viv", + conditions: &[CheckItem{offs: 0, cond: &CC::In(Arg::U16BE(1), Arg::U16BE(0xFF))}, + CheckItem{offs: 2, cond: &CC::Str(b"\x0D\x0AVersion:Vivo/")}], + }, + DetectConditions { + demux_name: "vivo", + extensions: ".viv", + conditions: &[CheckItem{offs: 0, cond: &CC::In(Arg::U16BE(1), Arg::U16BE(0xFF))}, + CheckItem{offs: 3, cond: &CC::Str(b"\x0D\x0AVersion:Vivo/")}], + }, DetectConditions { demux_name: "bmv", extensions: ".bmv", @@ -298,6 +332,22 @@ pub fn detect_format(name: &str, src: &mut ByteReader) -> Option<(&'static str, result } +/// Tries to detect container format for provided file name. +pub fn detect_format_by_name(name: &str) -> Option<(&'static str)> { + if name.is_empty() { + return None; + } + let lname = name.to_lowercase(); + for detector in DETECTORS { + for ext in detector.extensions.split(',') { + if lname.ends_with(ext) { + return Some(detector.demux_name); + } + } + } + None +} + #[cfg(test)] mod test { use super::*;