]> git.nihav.org Git - nihav.git/blobdiff - src/codecs/h263/data.rs
Rust2018: use new addressing scheme
[nihav.git] / src / codecs / h263 / data.rs
index 76c3c434d95828a37a64511d6db45c54f608d813..029c5bbecf8160b6946d0bae8a4b12ec2419d93a 100644 (file)
@@ -1,9 +1,13 @@
-use io::codebook::CodebookDescReader;
+use crate::io::codebook::CodebookDescReader;
 
 #[allow(dead_code)]
 pub const H263_SCALES: &[u8] = &[
     0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15 ];
 
+#[allow(dead_code)]
+pub const H263_DC_SCALES: &[u8] = &[
+    0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62 ];
+
 pub const H263_ZIGZAG: &[usize] = &[
     0,   1,  8, 16,  9,  2,  3, 10,
     17, 24, 32, 25, 18, 11,  4,  5,
@@ -15,6 +19,28 @@ pub const H263_ZIGZAG: &[usize] = &[
     53, 60, 61, 54, 47, 55, 62, 63
 ];
 
+pub const H263_SCAN_H: &[usize] = &[
+    0,   1,  2,  3,  8,  9, 16, 17,
+    10, 11,  4,  5,  6,  7, 15, 14,
+    13, 12, 19, 18, 24, 25, 32, 33,
+    26, 27, 20, 21, 22, 23, 28, 29,
+    30, 31, 34, 35, 40, 41, 48, 49,
+    42, 43, 36, 37, 38, 39, 44, 45,
+    46, 47, 50, 51, 56, 57, 58, 59,
+    52, 53, 54, 55, 60, 61, 62, 63
+];
+
+pub const H263_SCAN_V: &[usize] = &[
+    0,   8, 16, 24,  1,  9,  2, 10,
+    17, 25, 32, 40, 48, 56, 57, 49,
+    41, 33, 26, 18,  3, 11,  4, 12,
+    19, 27, 34, 42, 50, 58, 35, 43,
+    51, 59, 20, 28,  5, 13,  6, 14,
+    21, 29, 36, 44, 52, 60, 37, 45,
+    53, 61, 22, 30,  7, 15, 23, 31,
+    38, 46, 54, 62, 39, 47, 55, 63
+];
+
 pub const H263_SIZES: &[(usize, usize)] = &[
     (0, 0), (128, 96), (176, 144), (352, 288), (704, 576), (1408, 1152)
 ];
@@ -43,8 +69,48 @@ pub const H263_MV: &[(u8, u8)] = &[
     ( 2, 12)
 ];
 
+pub const H263_MBTYPE_B: &[(u8, u8)] = &[
+    (1,  1), (3,  3), (1,  5), (4,  4), (5,  4), (6,  6), (2,  4), (3,  4),
+    (7,  6), (4,  6), (5,  6), (1,  6), (1,  7), (1,  8), (1, 10)
+];
+
+// 0x1 - direct, 0x2 - has quant, 0x4 - has CBP, 0x8 - has dquant, 0x10 - has fwd, 0x20 - has bwd, 0x40 - intra
+
+pub const H263_MBB_CAP_CODED:    u8 = 0x2;
+pub const H263_MBB_CAP_DQUANT:   u8 = 0x4;
+pub const H263_MBB_CAP_FORWARD:  u8 = 0x10;
+pub const H263_MBB_CAP_BACKWARD: u8 = 0x20;
+pub const H263_MBB_CAP_INTRA:    u8 = 0x80;
+
+pub const H263_MBTYPE_B_CAPS: &[u8] = &[
+    0x00, 0x02, 0x06, // skipped, direct, direct+dq
+    0x10, 0x12, 0x16, // forward, coded forward, forward+dq
+    0x20, 0x22, 0x26, // backward, coded backward, backward+dq
+    0x30, 0x32, 0x36, // bidir, coded bidir, bidir+dq
+          0x82, 0x86  // intra, intra+dq
+];
+
+pub const H263_CBPC_B: &[(u8, u8)] = &[
+    (0, 1), (2, 2), (7, 3), (6, 3)
+];
+
 pub const H263_DQUANT_TAB: &[i8] = &[-1, -2, 1, 2];
 
+pub const H263_MODIFIED_QUANT: [[u8; 32]; 2] = [
+  [
+     0,  3,  1,  2,  3,  4,  5,  6,  7,  8,  9,  9, 10, 11, 12, 13,
+    14, 15, 16, 17, 18, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
+  ], [
+     0,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 13, 14, 15, 16, 17,
+    18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 31, 31, 26
+  ]
+];
+
+pub const H263_CHROMA_QUANT: [u8; 32] = [
+     0,  1,  2,  3,  4,  5,  6,  6,  7,  8,  9,  9, 10, 10, 11, 11,
+    12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15
+];
+
 pub struct H263ShortCodeReader { tab: &'static [(u8, u8)] }
 
 impl H263ShortCodeReader {