From: Kostya Shishkov Date: Sun, 2 Feb 2020 10:26:50 +0000 (+0100) Subject: duck/vp56: select proper format for VP6 alpha X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=93bbc2b0582d4199cef6642924dca7c95bfe135a;p=nihav.git duck/vp56: select proper format for VP6 alpha --- diff --git a/nihav-duck/src/codecs/vp56.rs b/nihav-duck/src/codecs/vp56.rs index ff98982..3a691ed 100644 --- a/nihav-duck/src/codecs/vp56.rs +++ b/nihav-duck/src/codecs/vp56.rs @@ -423,7 +423,7 @@ pub fn expand_token_bc(bc: &mut BoolCoder, val_probs: &[u8; 11], token: u8, vers impl VP56Decoder { pub fn new(version: u8, has_alpha: bool, flip: bool) -> Self { - let vt = alloc_video_buffer(NAVideoInfo::new(24, 24, false, YUV420_FORMAT), 4).unwrap(); + let vt = alloc_video_buffer(NAVideoInfo::new(24, 24, false, VP_YUVA420_FORMAT), 4).unwrap(); let mc_buf = vt.get_vbuf().unwrap(); Self { version, has_alpha, flip, @@ -486,7 +486,12 @@ impl VP56Decoder { if hdr.mb_w != 0 { self.set_dimensions((hdr.mb_w as usize) * 16, (hdr.mb_h as usize) * 16); } - let vinfo = NAVideoInfo::new(self.width, self.height, self.flip, YUV420_FORMAT); + let fmt = if !self.has_alpha { + YUV420_FORMAT + } else { + VP_YUVA420_FORMAT + }; + let vinfo = NAVideoInfo::new(self.width, self.height, self.flip, fmt); let ret = supp.pool_u8.get_free(); if ret.is_none() { return Err(DecoderError::AllocError); diff --git a/nihav-duck/src/codecs/vp6.rs b/nihav-duck/src/codecs/vp6.rs index 9d72d1f..9798634 100644 --- a/nihav-duck/src/codecs/vp6.rs +++ b/nihav-duck/src/codecs/vp6.rs @@ -688,13 +688,7 @@ impl NADecoder for VP6Decoder { let fmt = if !self.has_alpha { YUV420_FORMAT } else { - NAPixelFormaton::new(ColorModel::YUV(YUVSubmodel::YUVJ), - Some(NAPixelChromaton::new(0, 0, false, 8, 0, 0, 1)), - Some(NAPixelChromaton::new(1, 1, false, 8, 0, 1, 1)), - Some(NAPixelChromaton::new(1, 1, false, 8, 0, 2, 1)), - Some(NAPixelChromaton::new(0, 0, false, 8, 0, 3, 1)), - None, - 0, 4) + VP_YUVA420_FORMAT }; let myvinfo = NAVideoInfo::new(vinfo.get_width(), vinfo.get_height(), false, fmt); let myinfo = NACodecTypeInfo::Video(myvinfo.clone()); diff --git a/nihav-duck/src/codecs/vpcommon.rs b/nihav-duck/src/codecs/vpcommon.rs index 6991091..9c99b2f 100644 --- a/nihav-duck/src/codecs/vpcommon.rs +++ b/nihav-duck/src/codecs/vpcommon.rs @@ -1,6 +1,21 @@ use nihav_core::codecs::*; use nihav_core::codecs::blockdsp::*; +pub const VP_YUVA420_FORMAT: NAPixelFormaton = NAPixelFormaton{ + model: ColorModel::YUV(YUVSubmodel::YUVJ), + components: 4, + comp_info: [ + Some(NAPixelChromaton{ h_ss: 0, v_ss: 0, packed: false, depth: 8, shift: 0, comp_offs: 0, next_elem: 1}), + Some(NAPixelChromaton{ h_ss: 1, v_ss: 1, packed: false, depth: 8, shift: 0, comp_offs: 1, next_elem: 1}), + Some(NAPixelChromaton{ h_ss: 1, v_ss: 1, packed: false, depth: 8, shift: 0, comp_offs: 2, next_elem: 1}), + Some(NAPixelChromaton{ h_ss: 0, v_ss: 0, packed: false, depth: 8, shift: 0, comp_offs: 3, next_elem: 1}), + None ], + elem_size: 0, + be: false, + alpha: true, + palette: false + }; + #[derive(Clone,Copy,Debug,PartialEq)] #[allow(dead_code)] pub enum VPMBType {