From 39ffad66f2e0d92680774e32bbe063262904c5a0 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 1 Oct 2025 18:45:51 +0200 Subject: [PATCH] binkvid: allow decoding from inter frame The old behaviour may still be enabled with strict_mode option. --- nihav-rad/src/codecs/binkvid.rs | 35 ++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/nihav-rad/src/codecs/binkvid.rs b/nihav-rad/src/codecs/binkvid.rs index 2694b8d..9e0f238 100644 --- a/nihav-rad/src/codecs/binkvid.rs +++ b/nihav-rad/src/codecs/binkvid.rs @@ -469,6 +469,8 @@ struct BinkDecoder { trees: BinkTrees, qmat_b: QuantMats, + + strict_mode: bool, } fn calc_len(size: usize) -> u8 { @@ -598,6 +600,13 @@ impl BinkDecoder { poff += pstride; } Ok(()) + } else if !self.strict_mode { + for line in dst[off..].chunks_mut(stride).take(8) { + for pix in line[..8].iter_mut() { + *pix = 0x80; + } + } + Ok(()) } else { Err(DecoderError::MissingReference) } @@ -1205,10 +1214,30 @@ impl NADecoder for BinkDecoder { } } +const STRICT_MODE_OPTION: &str = "strict_mode"; + +const BINK_OPTS: &[NAOptionDefinition] = &[ + NAOptionDefinition { + name: STRICT_MODE_OPTION, description: "Error out on recoverable errors", + opt_type: NAOptionDefinitionType::Bool }, +]; + impl NAOptionHandler for BinkDecoder { - fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } - fn set_options(&mut self, _options: &[NAOption]) { } - fn query_option_value(&self, _name: &str) -> Option { None } + fn get_supported_options(&self) -> &[NAOptionDefinition] { BINK_OPTS } + fn set_options(&mut self, options: &[NAOption]) { + for option in options.iter() { + if let NAOption { name: STRICT_MODE_OPTION, value: NAValue::Bool(ref bval) } = option { + self.strict_mode = *bval; + } + } + } + fn query_option_value(&self, name: &str) -> Option { + if name == STRICT_MODE_OPTION { + Some(NAValue::Bool(self.strict_mode)) + } else { + None + } + } } pub fn get_decoder() -> Box { -- 2.39.5