From: Kostya Shishkov Date: Thu, 21 Aug 2025 16:06:29 +0000 (+0200) Subject: mpeg4asp: improve check for XviD-specific format X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=119bd247fdbc64fdc527970b6c7d3a590642d892;p=nihav.git mpeg4asp: improve check for XviD-specific format Apparently it is better not to enable XviD-specific DCT on older files. --- diff --git a/nihav-mpeg/src/codecs/mpeg4asp/bitstream.rs b/nihav-mpeg/src/codecs/mpeg4asp/bitstream.rs index 8d91973..5dcbc4a 100644 --- a/nihav-mpeg/src/codecs/mpeg4asp/bitstream.rs +++ b/nihav-mpeg/src/codecs/mpeg4asp/bitstream.rs @@ -51,7 +51,19 @@ pub fn scan_start_codes(src: &[u8]) -> DecoderResult> { } pub fn check_xvid_user_data(src: &[u8]) -> bool { - src.len() > 7 && &src[1..5] == b"XviD" + let is_xvid = src.len() > 7 && &src[1..5] == b"XviD"; + if is_xvid { // check for version + let mut ver = 0; + for &c in src[6..].iter() { + if !c.is_ascii_digit() { break; } + ver = ver * 10 + u32::from(c - b'0'); + if ver > 1048576 { return false; } + } + if ver < 50 { // these ones apparently use non-special DCT + return false; + } + } + is_xvid } fn read_var_len(br: &mut BitReader) -> DecoderResult {