X-Git-Url: https://git.nihav.org/?p=nihav.git;a=blobdiff_plain;f=nihav-duck%2Fsrc%2Fcodecs%2Fvp6.rs;h=6d971899b4a85ce8917585c9f95c6d431469a577;hp=15bd832452a40974383391912bc9514fef74c7d0;hb=92d9fb6993d2d3f6f7a016ee6796a98e6e989f21;hpb=bc23de6bedc2e151caea241b073a65d30f62c134 diff --git a/nihav-duck/src/codecs/vp6.rs b/nihav-duck/src/codecs/vp6.rs index 15bd832..6d97189 100644 --- a/nihav-duck/src/codecs/vp6.rs +++ b/nihav-duck/src/codecs/vp6.rs @@ -478,15 +478,17 @@ struct VP6Decoder { info: NACodecInfoRef, br: VP6BR, has_alpha: bool, + flipped: bool, } impl VP6Decoder { - fn new(has_alpha: bool) -> Self { + fn new(flipped: bool, has_alpha: bool) -> Self { Self { - dec: VP56Decoder::new(6, has_alpha, true), + dec: VP56Decoder::new(6, has_alpha, flipped), info: NACodecInfoRef::default(), br: VP6BR::new(), has_alpha, + flipped, } } } @@ -499,7 +501,15 @@ impl NADecoder for VP6Decoder { } else { VP_YUVA420_FORMAT }; - let myvinfo = NAVideoInfo::new(vinfo.get_width(), vinfo.get_height(), false, fmt); + let mut width = vinfo.get_width(); + let mut height = vinfo.get_height(); + if let (false, Some(edta)) = (self.flipped, info.get_extradata()) { + if (width & 0xF) == 0 && (height & 0xF) == 0 { + width -= usize::from(edta[0] >> 4); + height -= usize::from(edta[0] & 0xF); + } + } + let myvinfo = NAVideoInfo::new(width, height, self.flipped, fmt); let myinfo = NACodecTypeInfo::Video(myvinfo); self.info = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref(); self.dec.init(supp, myvinfo)?; @@ -530,11 +540,15 @@ impl NAOptionHandler for VP6Decoder { } pub fn get_decoder_vp6() -> Box { - Box::new(VP6Decoder::new(false)) + Box::new(VP6Decoder::new(true, false)) +} + +pub fn get_decoder_vp6f() -> Box { + Box::new(VP6Decoder::new(false, false)) } pub fn get_decoder_vp6_alpha() -> Box { - Box::new(VP6Decoder::new(true)) + Box::new(VP6Decoder::new(false, true)) } #[cfg(test)] @@ -605,6 +619,6 @@ mod test { [0xd3801a96, 0x1b5384ff, 0x422b228c, 0x9c4582c4], [0x8ddb0dfe, 0x302eb1ed, 0x10e64e22, 0x5a5a62b9], [0x79338328, 0x06113781, 0x8b116d18, 0xde56707e], - [0x671fa1b3, 0x0b3e41e9, 0xeb3a494c, 0xcdd24b1b]])); + [0xdb58433b, 0x1de4ce67, 0x15fcbcee, 0x1df9de61]])); } }