diff --git a/crates/ec-mpeg4/src/core.rs b/crates/ec-mpeg4/src/core.rs index ef153ec8..99fff951 100644 --- a/crates/ec-mpeg4/src/core.rs +++ b/crates/ec-mpeg4/src/core.rs @@ -159,7 +159,6 @@ pub struct Core { pub alternate_scan: bool, pub intra_dc_threshold: i32, pub top_field_first: bool, - pub partitioned: bool, pub y_dc_scale: i32, pub c_dc_scale: i32, // macroblock position / slice @@ -237,7 +236,6 @@ impl Core { alternate_scan: false, intra_dc_threshold: 0, top_field_first: false, - partitioned: false, y_dc_scale: 8, c_dc_scale: 8, mb_x: 0, diff --git a/crates/ec-mpeg4/src/frame.rs b/crates/ec-mpeg4/src/frame.rs index 0773c4f2..7158c5de 100644 --- a/crates/ec-mpeg4/src/frame.rs +++ b/crates/ec-mpeg4/src/frame.rs @@ -117,9 +117,6 @@ impl Core { Ok(()) } - fn update_workarounds(&mut self) { - self.finish_workaround_flags(); - } /// Decode one VOP from `data`. Returns the byte position reached. fn decode_one_vop(&mut self, data: &[u8], pts: Option) -> Result> { @@ -194,7 +191,6 @@ impl Core { self.f_code = vop.f_code; self.b_code = vop.b_code; self.set_qscale(vop.qscale); - self.partitioned = false; if self.vol.vo_type == 0 && !self.vol.vol_control_parameters && self.ident.divx_version == -1 @@ -209,7 +205,7 @@ impl Core { "static sprite (S-VOP without GMC)".to_string(), )); } - self.update_workarounds(); + self.finish_workaround_flags(); if pt != Pt::B && self.mb_num / 2 > br.left().max(0) as usize { return Err(Error::corrupt("MPEG-4: VOP too short")); } diff --git a/crates/ec-mpeg4/src/h263data.rs b/crates/ec-mpeg4/src/h263data.rs index 5a4317e7..d6e36712 100644 --- a/crates/ec-mpeg4/src/h263data.rs +++ b/crates/ec-mpeg4/src/h263data.rs @@ -22,9 +22,6 @@ pub const H263_INTER_MCBPC_BITS: [u8; 28] = [ 1, 4, 4, 6, 5, 8, 8, 7, 3, 7, 7, 9, 6, 9, 9, 9, 3, 7, 7, 8, 9, 0, 0, 0, 11, 13, 13, 13, ]; -/// CBPC for B- and EP-pictures, indexed by the coded block pattern (Table O.4/H.263). -pub const CBPC_B_TAB: [[u8; 2]; 4] = [[0, 1], [2, 2], [7, 3], [6, 3]]; - /// CBPY, indexed by the INTRA pattern value (12,34) read as four bits (Table 12/H.263); the INTER code is that of the complemented pattern. pub const H263_CBPY_TAB: [[u8; 2]; 16] = [ [3, 4], @@ -205,159 +202,6 @@ pub const INTER_RUN: [i8; 102] = [ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, ]; -/// INTRA TCOEF VLC for Advanced INTRA Coding, entries sorted by LAST, RUN, |LEVEL|, then ESCAPE (Table I.2/H.263). -pub const INTRA_VLC_AIC: [[u16; 2]; 103] = [ - [2, 2], - [6, 3], - [14, 4], - [12, 5], - [13, 5], - [16, 6], - [17, 6], - [18, 6], - [22, 7], - [27, 8], - [32, 9], - [33, 9], - [26, 9], - [27, 9], - [28, 9], - [29, 9], - [30, 9], - [31, 9], - [35, 11], - [34, 11], - [87, 12], - [86, 12], - [85, 12], - [84, 12], - [83, 12], - [15, 4], - [20, 6], - [20, 7], - [30, 8], - [15, 10], - [33, 11], - [80, 12], - [11, 5], - [21, 7], - [14, 10], - [9, 10], - [21, 6], - [29, 8], - [13, 10], - [81, 12], - [19, 6], - [35, 9], - [7, 11], - [23, 7], - [34, 9], - [82, 12], - [28, 8], - [12, 10], - [31, 8], - [11, 10], - [37, 9], - [10, 10], - [36, 9], - [6, 11], - [33, 10], - [32, 10], - [8, 10], - [32, 11], - [7, 4], - [12, 6], - [16, 7], - [19, 8], - [17, 9], - [18, 9], - [4, 10], - [39, 11], - [38, 11], - [95, 12], - [15, 6], - [19, 9], - [5, 10], - [37, 11], - [14, 6], - [20, 9], - [36, 11], - [13, 6], - [6, 10], - [94, 12], - [17, 7], - [7, 10], - [19, 7], - [93, 12], - [18, 7], - [92, 12], - [20, 8], - [91, 12], - [21, 8], - [26, 8], - [25, 8], - [24, 8], - [23, 8], - [22, 8], - [25, 9], - [21, 9], - [22, 9], - [24, 9], - [23, 9], - [4, 11], - [5, 11], - [88, 12], - [89, 12], - [90, 12], - [3, 7], -]; - -/// RUN of the entries of INTRA_VLC_AIC (Table I.2/H.263). -pub const INTRA_RUN_AIC: [i8; 102] = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 12, 13, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, -]; - -/// |LEVEL| of the entries of INTRA_VLC_AIC (Table I.2/H.263). -pub const INTRA_LEVEL_AIC: [i8; 102] = [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, - 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -]; - -/// Advanced INTRA Coding reconstruction scale 2 * QUANT (Annex I.3: RecC = 2 * QUANT * LEVEL, applied to INTRADC too). -pub const AIC_DC_SCALE_TABLE: [u8; 32] = [ - 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, -]; - -/// Modified Quantization: new QUANT for DQUANT = 10 (row 0) and 11 (row 1) by prior QUANT (Table T.1/H.263); slot 0 is unused. -pub const MODIFIED_QUANT_TAB: [[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, - ], -]; - -/// QUANT_C for chrominance in Modified Quantization mode (Table T.2/H.263); slot 0 is unused. -pub const H263_CHROMA_QSCALE_TABLE: [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, -]; - -/// Largest macroblock address per standard picture format, sub-QCIF to 2048x1152 (Table K.2/H.263). -pub const MBA_MAX: [u16; 6] = [47, 98, 395, 1583, 6335, 9215]; - -/// MBA field width in bits for the same formats (Table K.2/H.263); the last slot repeats the 14 bits of the largest format. -pub const MBA_LENGTH: [u8; 7] = [6, 7, 9, 11, 13, 14, 14]; - /// Zigzag scan: raster position (row * 8 + column) of each scan index (Figure 14/H.263). pub const ZIGZAG_DIRECT: [u8; 64] = [ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, @@ -414,8 +258,6 @@ pub const H263_PIXEL_ASPECT: [[u8; 2]; 16] = [ // Number of entries (without ESCAPE) and number of LAST = 0 entries of the TCOEF tables. pub const H263_RL_INTER_N: usize = 102; pub const H263_RL_INTER_LAST: usize = 58; -pub const RL_INTRA_AIC_N: usize = 102; -pub const RL_INTRA_AIC_LAST: usize = 58; #[cfg(test)] mod spec_tests { @@ -614,112 +456,6 @@ mod spec_tests { (1, 40, 1, "000001011111"), ]; const T16_ESC: &str = "0000011"; - /// Table I.2/H.263 rows in index order. - const TI2: [(u8, i8, i8, &str); 102] = [ - (0, 0, 1, "10"), - (0, 1, 1, "1111"), - (0, 3, 1, "010101"), - (0, 5, 1, "0010111"), - (0, 7, 1, "00011111"), - (0, 8, 1, "000100101"), - (0, 9, 1, "000100100"), - (0, 10, 1, "0000100001"), - (0, 11, 1, "0000100000"), - (0, 4, 3, "00000000111"), - (0, 9, 2, "00000000110"), - (0, 13, 1, "00000100000"), - (0, 0, 2, "110"), - (0, 1, 2, "010100"), - (0, 1, 4, "00011110"), - (0, 1, 5, "0000001111"), - (0, 1, 6, "00000100001"), - (0, 1, 7, "000001010000"), - (0, 0, 3, "1110"), - (0, 3, 2, "00011101"), - (0, 2, 3, "0000001110"), - (0, 3, 4, "000001010001"), - (0, 0, 5, "01101"), - (0, 4, 2, "000100011"), - (0, 3, 3, "0000001101"), - (0, 0, 4, "01100"), - (0, 5, 2, "000100010"), - (0, 5, 3, "000001010010"), - (0, 2, 1, "01011"), - (0, 6, 2, "0000001100"), - (0, 0, 25, "000001010011"), - (0, 4, 1, "010011"), - (0, 7, 2, "0000001011"), - (0, 0, 24, "000001010100"), - (0, 0, 8, "010010"), - (0, 8, 2, "0000001010"), - (0, 0, 7, "010001"), - (0, 2, 4, "0000001001"), - (0, 0, 6, "010000"), - (0, 12, 1, "0000001000"), - (0, 0, 9, "0010110"), - (0, 0, 23, "000001010101"), - (0, 2, 2, "0010101"), - (0, 1, 3, "0010100"), - (0, 6, 1, "00011100"), - (0, 0, 10, "00011011"), - (0, 0, 12, "000100001"), - (0, 0, 11, "000100000"), - (0, 0, 18, "000011111"), - (0, 0, 17, "000011110"), - (0, 0, 16, "000011101"), - (0, 0, 15, "000011100"), - (0, 0, 14, "000011011"), - (0, 0, 13, "000011010"), - (0, 0, 20, "00000100010"), - (0, 0, 19, "00000100011"), - (0, 0, 22, "000001010110"), - (0, 0, 21, "000001010111"), - (1, 0, 1, "0111"), - (1, 14, 1, "000011001"), - (1, 20, 1, "00000000101"), - (1, 1, 1, "001111"), - (1, 19, 1, "00000000100"), - (1, 2, 1, "001110"), - (1, 3, 1, "001101"), - (1, 0, 2, "001100"), - (1, 5, 1, "0010011"), - (1, 6, 1, "0010010"), - (1, 4, 1, "0010001"), - (1, 0, 3, "0010000"), - (1, 9, 1, "00011010"), - (1, 10, 1, "00011001"), - (1, 11, 1, "00011000"), - (1, 12, 1, "00010111"), - (1, 13, 1, "00010110"), - (1, 8, 1, "00010101"), - (1, 7, 1, "00010100"), - (1, 0, 4, "00010011"), - (1, 17, 1, "000011000"), - (1, 18, 1, "000010111"), - (1, 16, 1, "000010110"), - (1, 15, 1, "000010101"), - (1, 2, 2, "000010100"), - (1, 1, 2, "000010011"), - (1, 0, 6, "000010010"), - (1, 0, 5, "000010001"), - (1, 4, 2, "0000000111"), - (1, 3, 2, "0000000110"), - (1, 1, 3, "0000000101"), - (1, 0, 7, "0000000100"), - (1, 2, 3, "00000100100"), - (1, 1, 4, "00000100101"), - (1, 0, 9, "00000100110"), - (1, 0, 8, "00000100111"), - (1, 21, 1, "000001011000"), - (1, 22, 1, "000001011001"), - (1, 23, 1, "000001011010"), - (1, 7, 2, "000001011011"), - (1, 6, 2, "000001011100"), - (1, 5, 2, "000001011101"), - (1, 3, 3, "000001011110"), - (1, 0, 10, "000001011111"), - ]; - #[test] fn mcbpc_matches_tables_7_and_8() { for (i, r) in T7.iter().enumerate() { @@ -801,61 +537,10 @@ mod spec_tests { &INTER_LEVEL, H263_RL_INTER_LAST, ); - check_rl( - &TI2, - &INTRA_VLC_AIC, - &INTRA_RUN_AIC, - &INTRA_LEVEL_AIC, - RL_INTRA_AIC_LAST, - ); - // Table I.2 re-uses the codewords of Table 16 (I.3). - let mut a: Vec<_> = T16.iter().map(|r| r.3).collect(); - let mut b: Vec<_> = TI2.iter().map(|r| r.3).collect(); - a.sort(); - b.sort(); - assert_eq!(a, b); } #[test] fn small_tables_match_the_text() { - // Table O.4: 0, 10, 111, 110 for CBPC pattern 00, 01, 10, 11. - assert_eq!(CBPC_B_TAB, [[0, 1], [2, 2], [7, 3], [6, 3]]); - // Annex I.3: RecC = 2 * QUANT * LEVEL. - for q in 0..32 { - assert_eq!(AIC_DC_SCALE_TABLE[q] as usize, 2 * q); - } - // Table T.2. - for q in 1..32usize { - let c = match q { - 1..=6 => q, - 7..=9 => q - 1, - 10..=11 => 9, - 12..=13 => 10, - 14..=15 => 11, - 16..=18 => 12, - 19..=21 => 13, - 22..=26 => 14, - _ => 15, - }; - assert_eq!(H263_CHROMA_QSCALE_TABLE[q] as usize, c, "QUANT {q}"); - } - // Table T.1: change of QUANT for DQUANT = 10 / 11. - for q in 1..32i32 { - let (d10, d11) = match q { - 1 => (2, 1), - 2..=10 => (-1, 1), - 11..=20 => (-2, 2), - 21..=28 => (-3, 3), - 29 => (-3, 2), - 30 => (-3, 1), - _ => (-3, -5), - }; - assert_eq!(MODIFIED_QUANT_TAB[0][q as usize] as i32, q + d10); - assert_eq!(MODIFIED_QUANT_TAB[1][q as usize] as i32, q + d11); - } - // Table K.2. - assert_eq!(MBA_MAX, [47, 98, 395, 1583, 6335, 9215]); - assert_eq!(MBA_LENGTH, [6, 7, 9, 11, 13, 14, 14]); // Table 2 (formats) and Table 5 (PAR). assert_eq!(H263_FORMAT[1], [128, 96]); assert_eq!(H263_FORMAT[5], [1408, 1152]); diff --git a/crates/ec-mpeg4/src/lib.rs b/crates/ec-mpeg4/src/lib.rs index 8fa8fc2c..5b3302a9 100644 --- a/crates/ec-mpeg4/src/lib.rs +++ b/crates/ec-mpeg4/src/lib.rs @@ -19,8 +19,8 @@ mod msmpeg4; mod recon; mod vlc; -pub mod dsp; -pub mod tables; +mod dsp; +mod tables; pub use codec::Mpeg4Decoder; pub use core::PictureInfo; diff --git a/crates/ec-mpeg4/src/mb.rs b/crates/ec-mpeg4/src/mb.rs index 8faff442..cdd2e40b 100644 --- a/crates/ec-mpeg4/src/mb.rs +++ b/crates/ec-mpeg4/src/mb.rs @@ -602,7 +602,7 @@ impl Core { let mut v = br.peek(16); let ptn = pt_num(self.pt); while v <= 0xFF { - if self.pt == Pt::B || (v >> (8 - ptn)) != 1 || self.partitioned { + if self.pt == Pt::B || (v >> (8 - ptn)) != 1 { break; } br.skip((8 + ptn) as u32); diff --git a/crates/ec-mpeg4/src/tables.rs b/crates/ec-mpeg4/src/tables.rs index 252d967c..f9aee4a5 100644 --- a/crates/ec-mpeg4/src/tables.rs +++ b/crates/ec-mpeg4/src/tables.rs @@ -10,14 +10,13 @@ //! * `MPEG4_DCTAB_LUM`/`MPEG4_DCTAB_CHROM`: DC size VLCs. //! * `MPEG4_INTRA_VLC`/`_RUN`/`_LEVEL`: INTRA TCOEF. Its codewords are //! those of Table 16/H.263 but the RUN/LEVEL assignment is MPEG-4's own. -//! * `INTER_RVLC`, `INTRA_RVLC` with `_RUN`/`_LEVEL`: reversible VLCs. //! * `SPRITE_TRAJECTORY_LENS`: warping point displacement code lengths (dmv_length). //! * `MB_TYPE_B_TAB`: B-VOP macroblock type codes. //! * `MPEG4_DEFAULT_INTRA_MATRIX`/`MPEG4_DEFAULT_NON_INTRA_MATRIX`: default //! quantisation matrices. //! * `MPEG4_Y_DC_SCALE_TABLE`/`MPEG4_C_DC_SCALE_TABLE`: DC scaler. //! * `MPEG4_DC_THRESHOLD`: intra_dc_vlc_thr. -//! * `MPEG4_RL_INTRA_*`, `RVLC_RL_*`: entry counts of the tables above. +//! * `MPEG4_RL_INTRA_*`: entry counts of the tables above. pub use crate::h263data::*; @@ -173,389 +172,6 @@ pub const MPEG4_INTRA_RUN: [i8; 102] = [ 12, 13, 14, 15, 16, 17, 18, 19, 20, ]; -pub const INTER_RVLC: [[u16; 2]; 170] = [ - [6, 3], - [1, 4], - [4, 5], - [28, 7], - [60, 8], - [61, 8], - [124, 9], - [252, 10], - [253, 10], - [508, 11], - [509, 11], - [1020, 12], - [2044, 13], - [2045, 13], - [3068, 13], - [3069, 13], - [4092, 14], - [4093, 14], - [8188, 15], - [7, 3], - [12, 6], - [92, 8], - [125, 9], - [380, 10], - [764, 11], - [1021, 12], - [3580, 13], - [6140, 14], - [6141, 14], - [10, 4], - [29, 7], - [188, 9], - [765, 11], - [1532, 12], - [7164, 14], - [7165, 14], - [5, 5], - [93, 8], - [381, 10], - [1533, 12], - [3581, 13], - [7676, 14], - [8189, 15], - [8, 5], - [108, 8], - [892, 11], - [3836, 13], - [12284, 15], - [9, 5], - [189, 9], - [893, 11], - [3837, 13], - [13, 6], - [444, 10], - [1788, 12], - [7677, 14], - [20, 6], - [445, 10], - [1789, 12], - [12285, 15], - [21, 6], - [476, 10], - [3964, 13], - [44, 7], - [477, 10], - [7932, 14], - [45, 7], - [956, 11], - [52, 7], - [1916, 12], - [109, 8], - [3965, 13], - [116, 8], - [7933, 14], - [117, 8], - [8060, 14], - [220, 9], - [8061, 14], - [221, 9], - [8124, 14], - [236, 9], - [14332, 15], - [492, 10], - [493, 10], - [500, 10], - [957, 11], - [988, 11], - [989, 11], - [1004, 11], - [1005, 11], - [1012, 11], - [1917, 12], - [1980, 12], - [1981, 12], - [4028, 13], - [4029, 13], - [4060, 13], - [4061, 13], - [8125, 14], - [8156, 14], - [8157, 14], - [14333, 15], - [15356, 15], - [11, 4], - [120, 8], - [1013, 11], - [4076, 13], - [8172, 14], - [18, 5], - [237, 9], - [2012, 12], - [8173, 14], - [15357, 15], - [19, 5], - [1016, 11], - [15868, 15], - [24, 6], - [2013, 12], - [25, 6], - [2028, 12], - [34, 6], - [4077, 13], - [35, 6], - [4084, 13], - [53, 7], - [4085, 13], - [56, 7], - [4088, 13], - [57, 7], - [4089, 13], - [66, 7], - [8180, 14], - [67, 7], - [8181, 14], - [121, 8], - [8184, 14], - [130, 8], - [15869, 15], - [131, 8], - [244, 9], - [245, 9], - [248, 9], - [249, 9], - [258, 9], - [259, 9], - [501, 10], - [504, 10], - [505, 10], - [514, 10], - [515, 10], - [1017, 11], - [1026, 11], - [1027, 11], - [2029, 12], - [2036, 12], - [2037, 12], - [2040, 12], - [2041, 12], - [2050, 12], - [2051, 12], - [4098, 13], - [4099, 13], - [8185, 14], - [8194, 14], - [8195, 14], - [16124, 15], - [16125, 15], - [16252, 15], - [16253, 15], - [0, 4], -]; - -pub const INTER_RVLC_RUN: [i8; 169] = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, - 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, - 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, - 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, -]; - -pub const INTER_RVLC_LEVEL: [i8; 169] = [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, - 4, 1, 2, 3, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, - 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -]; - -pub const INTRA_RVLC: [[u16; 2]; 170] = [ - [6, 3], - [7, 3], - [10, 4], - [9, 5], - [20, 6], - [21, 6], - [52, 7], - [116, 8], - [117, 8], - [221, 9], - [236, 9], - [492, 10], - [493, 10], - [500, 10], - [1004, 11], - [1005, 11], - [1012, 11], - [1917, 12], - [1980, 12], - [4029, 13], - [4060, 13], - [1981, 12], - [4061, 13], - [8125, 14], - [8156, 14], - [8157, 14], - [8188, 15], - [1, 4], - [8, 5], - [45, 7], - [108, 8], - [109, 8], - [220, 9], - [477, 10], - [988, 11], - [989, 11], - [1916, 12], - [4028, 13], - [8061, 14], - [8124, 14], - [4, 5], - [44, 7], - [188, 9], - [476, 10], - [956, 11], - [957, 11], - [3837, 13], - [3964, 13], - [3965, 13], - [7933, 14], - [8060, 14], - [5, 5], - [92, 8], - [189, 9], - [893, 11], - [1788, 12], - [3836, 13], - [7677, 14], - [7932, 14], - [8189, 15], - [12, 6], - [93, 8], - [445, 10], - [1021, 12], - [1789, 12], - [7165, 14], - [13, 6], - [125, 9], - [764, 11], - [1532, 12], - [7164, 14], - [7676, 14], - [28, 7], - [380, 10], - [765, 11], - [1533, 12], - [12284, 15], - [29, 7], - [381, 10], - [892, 11], - [3581, 13], - [12285, 15], - [60, 8], - [444, 10], - [3069, 13], - [6141, 14], - [61, 8], - [509, 11], - [3580, 13], - [14332, 15], - [124, 9], - [1020, 12], - [252, 10], - [3068, 13], - [253, 10], - [14333, 15], - [508, 11], - [2044, 13], - [2045, 13], - [4092, 14], - [4093, 14], - [6140, 14], - [15356, 15], - [11, 4], - [120, 8], - [1013, 11], - [4076, 13], - [8172, 14], - [18, 5], - [237, 9], - [2012, 12], - [8173, 14], - [15357, 15], - [19, 5], - [1016, 11], - [15868, 15], - [24, 6], - [2013, 12], - [25, 6], - [2028, 12], - [34, 6], - [4077, 13], - [35, 6], - [4084, 13], - [53, 7], - [4085, 13], - [56, 7], - [4088, 13], - [57, 7], - [4089, 13], - [66, 7], - [8180, 14], - [67, 7], - [8181, 14], - [121, 8], - [8184, 14], - [130, 8], - [15869, 15], - [131, 8], - [244, 9], - [245, 9], - [248, 9], - [249, 9], - [258, 9], - [259, 9], - [501, 10], - [504, 10], - [505, 10], - [514, 10], - [515, 10], - [1017, 11], - [1026, 11], - [1027, 11], - [2029, 12], - [2036, 12], - [2037, 12], - [2040, 12], - [2041, 12], - [2050, 12], - [2051, 12], - [4098, 13], - [4099, 13], - [8185, 14], - [8194, 14], - [8195, 14], - [16124, 15], - [16125, 15], - [16252, 15], - [16253, 15], - [0, 4], -]; - -pub const INTRA_RVLC_RUN: [i8; 169] = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, - 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 11, 11, - 12, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, - 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, -]; - -pub const INTRA_RVLC_LEVEL: [i8; 169] = [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, - 2, 3, 4, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 1, 2, 1, - 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -]; - pub const SPRITE_TRAJECTORY_LENS: [u8; 15] = [2, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; pub const MB_TYPE_B_TAB: [[u8; 2]; 4] = [[1, 1], [1, 2], [1, 3], [1, 4]]; @@ -590,14 +206,6 @@ pub const MPEG4_RL_INTRA_N: usize = 102; pub const MPEG4_RL_INTRA_LAST: usize = 67; -pub const RVLC_RL_INTER_N: usize = 169; - -pub const RVLC_RL_INTER_LAST: usize = 103; - -pub const RVLC_RL_INTRA_N: usize = 169; - -pub const RVLC_RL_INTRA_LAST: usize = 103; - #[cfg(test)] mod tests { use super::*; @@ -629,10 +237,7 @@ mod tests { #[test] fn vlcs_prefix_free() { prefix_free("MPEG4_INTRA_VLC", &MPEG4_INTRA_VLC); - prefix_free("INTER_RVLC", &INTER_RVLC); - prefix_free("INTRA_RVLC", &INTRA_RVLC); prefix_free("INTER_VLC", &INTER_VLC); - prefix_free("INTRA_VLC_AIC", &INTRA_VLC_AIC); prefix_free("MVTAB", &to16(&MVTAB)); prefix_free("H263_CBPY_TAB", &to16(&H263_CBPY_TAB)); prefix_free("MPEG4_DCTAB_LUM", &to16(&MPEG4_DCTAB_LUM)); @@ -658,17 +263,4 @@ mod tests { is_perm(&ALTERNATE_HORIZONTAL_SCAN); is_perm(&ALTERNATE_VERTICAL_SCAN); } - #[test] - fn rl_lengths() { - assert_eq!(MPEG4_INTRA_RUN.len(), MPEG4_RL_INTRA_N); - assert_eq!(MPEG4_INTRA_LEVEL.len(), MPEG4_RL_INTRA_N); - assert_eq!(INTER_RUN.len(), H263_RL_INTER_N); - assert_eq!(INTER_LEVEL.len(), H263_RL_INTER_N); - assert_eq!(INTRA_RUN_AIC.len(), RL_INTRA_AIC_N); - assert_eq!(INTRA_LEVEL_AIC.len(), RL_INTRA_AIC_N); - assert_eq!(INTER_RVLC_RUN.len(), RVLC_RL_INTER_N); - assert_eq!(INTRA_RVLC_LEVEL.len(), RVLC_RL_INTRA_N); - assert_eq!(MPEG4_INTRA_VLC.len(), MPEG4_RL_INTRA_N + 1); - assert_eq!(INTER_RVLC.len(), RVLC_RL_INTER_N + 1); - } } diff --git a/crates/ec-mpeg4/src/vlc.rs b/crates/ec-mpeg4/src/vlc.rs index 65b1babe..ae0acd20 100644 --- a/crates/ec-mpeg4/src/vlc.rs +++ b/crates/ec-mpeg4/src/vlc.rs @@ -108,12 +108,6 @@ pub struct Vlcs { pub mb_type_b: Vlc, pub rl_intra: Rl, pub rl_inter: Rl, - #[allow(dead_code)] // kept with the RVLC tables for data partitioning - pub rl_intra_aic: Rl, - #[allow(dead_code)] - pub rvlc_intra: Rl, - #[allow(dead_code)] - pub rvlc_inter: Rl, pub sprite_traj: Vlc, } @@ -151,27 +145,6 @@ pub fn vlcs() -> &'static Vlcs { H263_RL_INTER_N, H263_RL_INTER_LAST, ), - rl_intra_aic: Rl::new( - &INTRA_VLC_AIC, - &INTRA_RUN_AIC, - &INTRA_LEVEL_AIC, - RL_INTRA_AIC_N, - RL_INTRA_AIC_LAST, - ), - rvlc_intra: Rl::new( - &INTRA_RVLC, - &INTRA_RVLC_RUN, - &INTRA_RVLC_LEVEL, - RVLC_RL_INTRA_N, - RVLC_RL_INTRA_LAST, - ), - rvlc_inter: Rl::new( - &INTER_RVLC, - &INTER_RVLC_RUN, - &INTER_RVLC_LEVEL, - RVLC_RL_INTER_N, - RVLC_RL_INTER_LAST, - ), sprite_traj: { let mut c = Vec::new(); let mut code = 0u32;