duck/vpcommon: vp_tree! does not need to be exported
[nihav.git] / nihav-duck / src / codecs / vpcommon.rs
index d4fdea5fc8a267bea315443dc82b06d8f246d3f9..8dbe16184a555889867bfd0b2fe7f48ea15d315f 100644 (file)
@@ -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 {
@@ -182,7 +197,6 @@ pub fn rescale_prob(prob: u8, weights: &[i16; 2], maxval: i32) -> u8 {
     ((((prob as i32) * (weights[0] as i32) + 128) >> 8) + (weights[1] as i32)).min(maxval).max(1) as u8
 }
 
-#[macro_export]
 macro_rules! vp_tree {
     ($bc: expr, $prob: expr, $node1: expr, $node2: expr) => {
         if !$bc.read_prob($prob) {
@@ -380,17 +394,18 @@ pub fn vp_copy_block(dst: &mut NASimpleVideoFrame<u8>, src: NAVideoBufferRef<u8>
     let src_x = sx - (pre as isize);
     let src_y = sy - (pre as isize);
     {
-        let mut tmp_buf = NASimpleVideoFrame::from_video_buf(&mut mc_buf).unwrap();
-        copy_block(&mut tmp_buf, src, comp, 0, 0, src_x as i16, src_y as i16,
-                   bsize, bsize, 0, 0, 0, interp);
-        if ((sx & 7) != 0) || (mode != 0) {
+        let tmp_buf = NASimpleVideoFrame::from_video_buf(&mut mc_buf).unwrap();
+        edge_emu(src.as_ref(), src_x, src_y, bsize, bsize, &mut tmp_buf.data[tmp_buf.offset[comp]..], tmp_buf.stride[comp], comp);
+//        copy_block(&mut tmp_buf, src, comp, 0, 0, src_x as i16, src_y as i16,
+//                   bsize, bsize, 0, 0, 0, interp);
+        if (sx & 7) != 0 {
             let foff = (8 - (sx & 7)) as usize;
-            let off = pre + foff;
+            let off = pre + foff + tmp_buf.offset[comp];
             vp31_loop_filter(tmp_buf.data, off, 1, tmp_buf.stride[comp], bsize, loop_str);
         }
-        if ((sy & 7) != 0) || (mode != 0) {
+        if (sy & 7) != 0 {
             let foff = (8 - (sy & 7)) as usize;
-            let off = (pre + foff) * tmp_buf.stride[comp];
+            let off = (pre + foff) * tmp_buf.stride[comp] + tmp_buf.offset[comp];
             vp31_loop_filter(tmp_buf.data, off, tmp_buf.stride[comp], 1, bsize, loop_str);
         }
     }