forge
Explore
Log in

Don't you dare go Hollow

U14: ec-mpeg4 delete RVLC and Advanced INTRA Coding tables, dead Rl fields, partitioned flag and the update_workarounds wrapper; make dsp and tables private, rustc-flagged constants removed

Browse files at this commit

c93fdfbc6eab1ccadf601e1d572ec1ea1e345299Ahmet Kaan GümüşParent: 41510f0
crates/ec-mpeg4/src/core.rsmodified+0 -2
@@ -159,7 +159,6 @@ pub struct Core {
159159 pub alternate_scan: bool,
160160 pub intra_dc_threshold: i32,
161161 pub top_field_first: bool,
162- pub partitioned: bool,
163162 pub y_dc_scale: i32,
164163 pub c_dc_scale: i32,
165164 // macroblock position / slice
@@ -237,7 +236,6 @@ impl Core {
237236 alternate_scan: false,
238237 intra_dc_threshold: 0,
239238 top_field_first: false,
240- partitioned: false,
241239 y_dc_scale: 8,
242240 c_dc_scale: 8,
243241 mb_x: 0,
crates/ec-mpeg4/src/frame.rsmodified+1 -5
@@ -117,9 +117,6 @@ impl Core {
117117 Ok(())
118118 }
119119
120- fn update_workarounds(&mut self) {
121- self.finish_workaround_flags();
122- }
123120
124121 /// Decode one VOP from `data`. Returns the byte position reached.
125122 fn decode_one_vop(&mut self, data: &[u8], pts: Option<Timestamp>) -> Result<Option<usize>> {
@@ -194,7 +191,6 @@ impl Core {
194191 self.f_code = vop.f_code;
195192 self.b_code = vop.b_code;
196193 self.set_qscale(vop.qscale);
197- self.partitioned = false;
198194 if self.vol.vo_type == 0
199195 && !self.vol.vol_control_parameters
200196 && self.ident.divx_version == -1
@@ -209,7 +205,7 @@ impl Core {
209205 "static sprite (S-VOP without GMC)".to_string(),
210206 ));
211207 }
212- self.update_workarounds();
208+ self.finish_workaround_flags();
213209 if pt != Pt::B && self.mb_num / 2 > br.left().max(0) as usize {
214210 return Err(Error::corrupt("MPEG-4: VOP too short"));
215211 }
crates/ec-mpeg4/src/h263data.rsmodified+0 -315
@@ -22,9 +22,6 @@ pub const H263_INTER_MCBPC_BITS: [u8; 28] = [
2222 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,
2323 ];
2424
25-/// CBPC for B- and EP-pictures, indexed by the coded block pattern (Table O.4/H.263).
26-pub const CBPC_B_TAB: [[u8; 2]; 4] = [[0, 1], [2, 2], [7, 3], [6, 3]];
27-
2825 /// 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.
2926 pub const H263_CBPY_TAB: [[u8; 2]; 16] = [
3027 [3, 4],
@@ -205,159 +202,6 @@ pub const INTER_RUN: [i8; 102] = [
205202 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
206203 ];
207204
208-/// INTRA TCOEF VLC for Advanced INTRA Coding, entries sorted by LAST, RUN, |LEVEL|, then ESCAPE (Table I.2/H.263).
209-pub const INTRA_VLC_AIC: [[u16; 2]; 103] = [
210- [2, 2],
211- [6, 3],
212- [14, 4],
213- [12, 5],
214- [13, 5],
215- [16, 6],
216- [17, 6],
217- [18, 6],
218- [22, 7],
219- [27, 8],
220- [32, 9],
221- [33, 9],
222- [26, 9],
223- [27, 9],
224- [28, 9],
225- [29, 9],
226- [30, 9],
227- [31, 9],
228- [35, 11],
229- [34, 11],
230- [87, 12],
231- [86, 12],
232- [85, 12],
233- [84, 12],
234- [83, 12],
235- [15, 4],
236- [20, 6],
237- [20, 7],
238- [30, 8],
239- [15, 10],
240- [33, 11],
241- [80, 12],
242- [11, 5],
243- [21, 7],
244- [14, 10],
245- [9, 10],
246- [21, 6],
247- [29, 8],
248- [13, 10],
249- [81, 12],
250- [19, 6],
251- [35, 9],
252- [7, 11],
253- [23, 7],
254- [34, 9],
255- [82, 12],
256- [28, 8],
257- [12, 10],
258- [31, 8],
259- [11, 10],
260- [37, 9],
261- [10, 10],
262- [36, 9],
263- [6, 11],
264- [33, 10],
265- [32, 10],
266- [8, 10],
267- [32, 11],
268- [7, 4],
269- [12, 6],
270- [16, 7],
271- [19, 8],
272- [17, 9],
273- [18, 9],
274- [4, 10],
275- [39, 11],
276- [38, 11],
277- [95, 12],
278- [15, 6],
279- [19, 9],
280- [5, 10],
281- [37, 11],
282- [14, 6],
283- [20, 9],
284- [36, 11],
285- [13, 6],
286- [6, 10],
287- [94, 12],
288- [17, 7],
289- [7, 10],
290- [19, 7],
291- [93, 12],
292- [18, 7],
293- [92, 12],
294- [20, 8],
295- [91, 12],
296- [21, 8],
297- [26, 8],
298- [25, 8],
299- [24, 8],
300- [23, 8],
301- [22, 8],
302- [25, 9],
303- [21, 9],
304- [22, 9],
305- [24, 9],
306- [23, 9],
307- [4, 11],
308- [5, 11],
309- [88, 12],
310- [89, 12],
311- [90, 12],
312- [3, 7],
313-];
314-
315-/// RUN of the entries of INTRA_VLC_AIC (Table I.2/H.263).
316-pub const INTRA_RUN_AIC: [i8; 102] = [
317- 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,
318- 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,
319- 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,
320- 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
321-];
322-
323-/// |LEVEL| of the entries of INTRA_VLC_AIC (Table I.2/H.263).
324-pub const INTRA_LEVEL_AIC: [i8; 102] = [
325- 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,
326- 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,
327- 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,
328- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
329-];
330-
331-/// Advanced INTRA Coding reconstruction scale 2 * QUANT (Annex I.3: RecC = 2 * QUANT * LEVEL, applied to INTRADC too).
332-pub const AIC_DC_SCALE_TABLE: [u8; 32] = [
333- 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,
334- 50, 52, 54, 56, 58, 60, 62,
335-];
336-
337-/// 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.
338-pub const MODIFIED_QUANT_TAB: [[u8; 32]; 2] = [
339- [
340- 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,
341- 23, 24, 25, 26, 27, 28,
342- ],
343- [
344- 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,
345- 28, 29, 30, 31, 31, 31, 26,
346- ],
347-];
348-
349-/// QUANT_C for chrominance in Modified Quantization mode (Table T.2/H.263); slot 0 is unused.
350-pub const H263_CHROMA_QSCALE_TABLE: [u8; 32] = [
351- 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,
352- 15, 15, 15, 15, 15,
353-];
354-
355-/// Largest macroblock address per standard picture format, sub-QCIF to 2048x1152 (Table K.2/H.263).
356-pub const MBA_MAX: [u16; 6] = [47, 98, 395, 1583, 6335, 9215];
357-
358-/// 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.
359-pub const MBA_LENGTH: [u8; 7] = [6, 7, 9, 11, 13, 14, 14];
360-
361205 /// Zigzag scan: raster position (row * 8 + column) of each scan index (Figure 14/H.263).
362206 pub const ZIGZAG_DIRECT: [u8; 64] = [
363207 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] = [
414258 // Number of entries (without ESCAPE) and number of LAST = 0 entries of the TCOEF tables.
415259 pub const H263_RL_INTER_N: usize = 102;
416260 pub const H263_RL_INTER_LAST: usize = 58;
417-pub const RL_INTRA_AIC_N: usize = 102;
418-pub const RL_INTRA_AIC_LAST: usize = 58;
419261
420262 #[cfg(test)]
421263 mod spec_tests {
@@ -614,112 +456,6 @@ mod spec_tests {
614456 (1, 40, 1, "000001011111"),
615457 ];
616458 const T16_ESC: &str = "0000011";
617- /// Table I.2/H.263 rows in index order.
618- const TI2: [(u8, i8, i8, &str); 102] = [
619- (0, 0, 1, "10"),
620- (0, 1, 1, "1111"),
621- (0, 3, 1, "010101"),
622- (0, 5, 1, "0010111"),
623- (0, 7, 1, "00011111"),
624- (0, 8, 1, "000100101"),
625- (0, 9, 1, "000100100"),
626- (0, 10, 1, "0000100001"),
627- (0, 11, 1, "0000100000"),
628- (0, 4, 3, "00000000111"),
629- (0, 9, 2, "00000000110"),
630- (0, 13, 1, "00000100000"),
631- (0, 0, 2, "110"),
632- (0, 1, 2, "010100"),
633- (0, 1, 4, "00011110"),
634- (0, 1, 5, "0000001111"),
635- (0, 1, 6, "00000100001"),
636- (0, 1, 7, "000001010000"),
637- (0, 0, 3, "1110"),
638- (0, 3, 2, "00011101"),
639- (0, 2, 3, "0000001110"),
640- (0, 3, 4, "000001010001"),
641- (0, 0, 5, "01101"),
642- (0, 4, 2, "000100011"),
643- (0, 3, 3, "0000001101"),
644- (0, 0, 4, "01100"),
645- (0, 5, 2, "000100010"),
646- (0, 5, 3, "000001010010"),
647- (0, 2, 1, "01011"),
648- (0, 6, 2, "0000001100"),
649- (0, 0, 25, "000001010011"),
650- (0, 4, 1, "010011"),
651- (0, 7, 2, "0000001011"),
652- (0, 0, 24, "000001010100"),
653- (0, 0, 8, "010010"),
654- (0, 8, 2, "0000001010"),
655- (0, 0, 7, "010001"),
656- (0, 2, 4, "0000001001"),
657- (0, 0, 6, "010000"),
658- (0, 12, 1, "0000001000"),
659- (0, 0, 9, "0010110"),
660- (0, 0, 23, "000001010101"),
661- (0, 2, 2, "0010101"),
662- (0, 1, 3, "0010100"),
663- (0, 6, 1, "00011100"),
664- (0, 0, 10, "00011011"),
665- (0, 0, 12, "000100001"),
666- (0, 0, 11, "000100000"),
667- (0, 0, 18, "000011111"),
668- (0, 0, 17, "000011110"),
669- (0, 0, 16, "000011101"),
670- (0, 0, 15, "000011100"),
671- (0, 0, 14, "000011011"),
672- (0, 0, 13, "000011010"),
673- (0, 0, 20, "00000100010"),
674- (0, 0, 19, "00000100011"),
675- (0, 0, 22, "000001010110"),
676- (0, 0, 21, "000001010111"),
677- (1, 0, 1, "0111"),
678- (1, 14, 1, "000011001"),
679- (1, 20, 1, "00000000101"),
680- (1, 1, 1, "001111"),
681- (1, 19, 1, "00000000100"),
682- (1, 2, 1, "001110"),
683- (1, 3, 1, "001101"),
684- (1, 0, 2, "001100"),
685- (1, 5, 1, "0010011"),
686- (1, 6, 1, "0010010"),
687- (1, 4, 1, "0010001"),
688- (1, 0, 3, "0010000"),
689- (1, 9, 1, "00011010"),
690- (1, 10, 1, "00011001"),
691- (1, 11, 1, "00011000"),
692- (1, 12, 1, "00010111"),
693- (1, 13, 1, "00010110"),
694- (1, 8, 1, "00010101"),
695- (1, 7, 1, "00010100"),
696- (1, 0, 4, "00010011"),
697- (1, 17, 1, "000011000"),
698- (1, 18, 1, "000010111"),
699- (1, 16, 1, "000010110"),
700- (1, 15, 1, "000010101"),
701- (1, 2, 2, "000010100"),
702- (1, 1, 2, "000010011"),
703- (1, 0, 6, "000010010"),
704- (1, 0, 5, "000010001"),
705- (1, 4, 2, "0000000111"),
706- (1, 3, 2, "0000000110"),
707- (1, 1, 3, "0000000101"),
708- (1, 0, 7, "0000000100"),
709- (1, 2, 3, "00000100100"),
710- (1, 1, 4, "00000100101"),
711- (1, 0, 9, "00000100110"),
712- (1, 0, 8, "00000100111"),
713- (1, 21, 1, "000001011000"),
714- (1, 22, 1, "000001011001"),
715- (1, 23, 1, "000001011010"),
716- (1, 7, 2, "000001011011"),
717- (1, 6, 2, "000001011100"),
718- (1, 5, 2, "000001011101"),
719- (1, 3, 3, "000001011110"),
720- (1, 0, 10, "000001011111"),
721- ];
722-
723459 #[test]
724460 fn mcbpc_matches_tables_7_and_8() {
725461 for (i, r) in T7.iter().enumerate() {
@@ -801,61 +537,10 @@ mod spec_tests {
801537 &INTER_LEVEL,
802538 H263_RL_INTER_LAST,
803539 );
804- check_rl(
805- &TI2,
806- &INTRA_VLC_AIC,
807- &INTRA_RUN_AIC,
808- &INTRA_LEVEL_AIC,
809- RL_INTRA_AIC_LAST,
810- );
811- // Table I.2 re-uses the codewords of Table 16 (I.3).
812- let mut a: Vec<_> = T16.iter().map(|r| r.3).collect();
813- let mut b: Vec<_> = TI2.iter().map(|r| r.3).collect();
814- a.sort();
815- b.sort();
816- assert_eq!(a, b);
817540 }
818541
819542 #[test]
820543 fn small_tables_match_the_text() {
821- // Table O.4: 0, 10, 111, 110 for CBPC pattern 00, 01, 10, 11.
822- assert_eq!(CBPC_B_TAB, [[0, 1], [2, 2], [7, 3], [6, 3]]);
823- // Annex I.3: RecC = 2 * QUANT * LEVEL.
824- for q in 0..32 {
825- assert_eq!(AIC_DC_SCALE_TABLE[q] as usize, 2 * q);
826- }
827- // Table T.2.
828- for q in 1..32usize {
829- let c = match q {
830- 1..=6 => q,
831- 7..=9 => q - 1,
832- 10..=11 => 9,
833- 12..=13 => 10,
834- 14..=15 => 11,
835- 16..=18 => 12,
836- 19..=21 => 13,
837- 22..=26 => 14,
838- _ => 15,
839- };
840- assert_eq!(H263_CHROMA_QSCALE_TABLE[q] as usize, c, "QUANT {q}");
841- }
842- // Table T.1: change of QUANT for DQUANT = 10 / 11.
843- for q in 1..32i32 {
844- let (d10, d11) = match q {
845- 1 => (2, 1),
846- 2..=10 => (-1, 1),
847- 11..=20 => (-2, 2),
848- 21..=28 => (-3, 3),
849- 29 => (-3, 2),
850- 30 => (-3, 1),
851- _ => (-3, -5),
852- };
853- assert_eq!(MODIFIED_QUANT_TAB[0][q as usize] as i32, q + d10);
854- assert_eq!(MODIFIED_QUANT_TAB[1][q as usize] as i32, q + d11);
855- }
856- // Table K.2.
857- assert_eq!(MBA_MAX, [47, 98, 395, 1583, 6335, 9215]);
858- assert_eq!(MBA_LENGTH, [6, 7, 9, 11, 13, 14, 14]);
859544 // Table 2 (formats) and Table 5 (PAR).
860545 assert_eq!(H263_FORMAT[1], [128, 96]);
861546 assert_eq!(H263_FORMAT[5], [1408, 1152]);
crates/ec-mpeg4/src/lib.rsmodified+2 -2
@@ -19,8 +19,8 @@ mod msmpeg4;
1919 mod recon;
2020 mod vlc;
2121
22-pub mod dsp;
23-pub mod tables;
22+mod dsp;
23+mod tables;
2424
2525 pub use codec::Mpeg4Decoder;
2626 pub use core::PictureInfo;
crates/ec-mpeg4/src/mb.rsmodified+1 -1
@@ -602,7 +602,7 @@ impl Core {
602602 let mut v = br.peek(16);
603603 let ptn = pt_num(self.pt);
604604 while v <= 0xFF {
605- if self.pt == Pt::B || (v >> (8 - ptn)) != 1 || self.partitioned {
605+ if self.pt == Pt::B || (v >> (8 - ptn)) != 1 {
606606 break;
607607 }
608608 br.skip((8 + ptn) as u32);
crates/ec-mpeg4/src/tables.rsmodified+1 -409
@@ -10,14 +10,13 @@
1010 //! * `MPEG4_DCTAB_LUM`/`MPEG4_DCTAB_CHROM`: DC size VLCs.
1111 //! * `MPEG4_INTRA_VLC`/`_RUN`/`_LEVEL`: INTRA TCOEF. Its codewords are
1212 //! those of Table 16/H.263 but the RUN/LEVEL assignment is MPEG-4's own.
13-//! * `INTER_RVLC`, `INTRA_RVLC` with `_RUN`/`_LEVEL`: reversible VLCs.
1413 //! * `SPRITE_TRAJECTORY_LENS`: warping point displacement code lengths (dmv_length).
1514 //! * `MB_TYPE_B_TAB`: B-VOP macroblock type codes.
1615 //! * `MPEG4_DEFAULT_INTRA_MATRIX`/`MPEG4_DEFAULT_NON_INTRA_MATRIX`: default
1716 //! quantisation matrices.
1817 //! * `MPEG4_Y_DC_SCALE_TABLE`/`MPEG4_C_DC_SCALE_TABLE`: DC scaler.
1918 //! * `MPEG4_DC_THRESHOLD`: intra_dc_vlc_thr.
20-//! * `MPEG4_RL_INTRA_*`, `RVLC_RL_*`: entry counts of the tables above.
19+//! * `MPEG4_RL_INTRA_*`: entry counts of the tables above.
2120
2221 pub use crate::h263data::*;
2322
@@ -173,389 +172,6 @@ pub const MPEG4_INTRA_RUN: [i8; 102] = [
173172 12, 13, 14, 15, 16, 17, 18, 19, 20,
174173 ];
175174
176-pub const INTER_RVLC: [[u16; 2]; 170] = [
177- [6, 3],
178- [1, 4],
179- [4, 5],
180- [28, 7],
181- [60, 8],
182- [61, 8],
183- [124, 9],
184- [252, 10],
185- [253, 10],
186- [508, 11],
187- [509, 11],
188- [1020, 12],
189- [2044, 13],
190- [2045, 13],
191- [3068, 13],
192- [3069, 13],
193- [4092, 14],
194- [4093, 14],
195- [8188, 15],
196- [7, 3],
197- [12, 6],
198- [92, 8],
199- [125, 9],
200- [380, 10],
201- [764, 11],
202- [1021, 12],
203- [3580, 13],
204- [6140, 14],
205- [6141, 14],
206- [10, 4],
207- [29, 7],
208- [188, 9],
209- [765, 11],
210- [1532, 12],
211- [7164, 14],
212- [7165, 14],
213- [5, 5],
214- [93, 8],
215- [381, 10],
216- [1533, 12],
217- [3581, 13],
218- [7676, 14],
219- [8189, 15],
220- [8, 5],
221- [108, 8],
222- [892, 11],
223- [3836, 13],
224- [12284, 15],
225- [9, 5],
226- [189, 9],
227- [893, 11],
228- [3837, 13],
229- [13, 6],
230- [444, 10],
231- [1788, 12],
232- [7677, 14],
233- [20, 6],
234- [445, 10],
235- [1789, 12],
236- [12285, 15],
237- [21, 6],
238- [476, 10],
239- [3964, 13],
240- [44, 7],
241- [477, 10],
242- [7932, 14],
243- [45, 7],
244- [956, 11],
245- [52, 7],
246- [1916, 12],
247- [109, 8],
248- [3965, 13],
249- [116, 8],
250- [7933, 14],
251- [117, 8],
252- [8060, 14],
253- [220, 9],
254- [8061, 14],
255- [221, 9],
256- [8124, 14],
257- [236, 9],
258- [14332, 15],
259- [492, 10],
260- [493, 10],
261- [500, 10],
262- [957, 11],
263- [988, 11],
264- [989, 11],
265- [1004, 11],
266- [1005, 11],
267- [1012, 11],
268- [1917, 12],
269- [1980, 12],
270- [1981, 12],
271- [4028, 13],
272- [4029, 13],
273- [4060, 13],
274- [4061, 13],
275- [8125, 14],
276- [8156, 14],
277- [8157, 14],
278- [14333, 15],
279- [15356, 15],
280- [11, 4],
281- [120, 8],
282- [1013, 11],
283- [4076, 13],
284- [8172, 14],
285- [18, 5],
286- [237, 9],
287- [2012, 12],
288- [8173, 14],
289- [15357, 15],
290- [19, 5],
291- [1016, 11],
292- [15868, 15],
293- [24, 6],
294- [2013, 12],
295- [25, 6],
296- [2028, 12],
297- [34, 6],
298- [4077, 13],
299- [35, 6],
300- [4084, 13],
301- [53, 7],
302- [4085, 13],
303- [56, 7],
304- [4088, 13],
305- [57, 7],
306- [4089, 13],
307- [66, 7],
308- [8180, 14],
309- [67, 7],
310- [8181, 14],
311- [121, 8],
312- [8184, 14],
313- [130, 8],
314- [15869, 15],
315- [131, 8],
316- [244, 9],
317- [245, 9],
318- [248, 9],
319- [249, 9],
320- [258, 9],
321- [259, 9],
322- [501, 10],
323- [504, 10],
324- [505, 10],
325- [514, 10],
326- [515, 10],
327- [1017, 11],
328- [1026, 11],
329- [1027, 11],
330- [2029, 12],
331- [2036, 12],
332- [2037, 12],
333- [2040, 12],
334- [2041, 12],
335- [2050, 12],
336- [2051, 12],
337- [4098, 13],
338- [4099, 13],
339- [8185, 14],
340- [8194, 14],
341- [8195, 14],
342- [16124, 15],
343- [16125, 15],
344- [16252, 15],
345- [16253, 15],
346- [0, 4],
347-];
348-
349-pub const INTER_RVLC_RUN: [i8; 169] = [
350- 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,
351- 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,
352- 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 19, 20, 21, 22, 23,
353- 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,
354- 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,
355- 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
356- 42, 43, 44,
357-];
358-
359-pub const INTER_RVLC_LEVEL: [i8; 169] = [
360- 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,
361- 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,
362- 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,
363- 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,
364- 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,
365- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
366-];
367-
368-pub const INTRA_RVLC: [[u16; 2]; 170] = [
369- [6, 3],
370- [7, 3],
371- [10, 4],
372- [9, 5],
373- [20, 6],
374- [21, 6],
375- [52, 7],
376- [116, 8],
377- [117, 8],
378- [221, 9],
379- [236, 9],
380- [492, 10],
381- [493, 10],
382- [500, 10],
383- [1004, 11],
384- [1005, 11],
385- [1012, 11],
386- [1917, 12],
387- [1980, 12],
388- [4029, 13],
389- [4060, 13],
390- [1981, 12],
391- [4061, 13],
392- [8125, 14],
393- [8156, 14],
394- [8157, 14],
395- [8188, 15],
396- [1, 4],
397- [8, 5],
398- [45, 7],
399- [108, 8],
400- [109, 8],
401- [220, 9],
402- [477, 10],
403- [988, 11],
404- [989, 11],
405- [1916, 12],
406- [4028, 13],
407- [8061, 14],
408- [8124, 14],
409- [4, 5],
410- [44, 7],
411- [188, 9],
412- [476, 10],
413- [956, 11],
414- [957, 11],
415- [3837, 13],
416- [3964, 13],
417- [3965, 13],
418- [7933, 14],
419- [8060, 14],
420- [5, 5],
421- [92, 8],
422- [189, 9],
423- [893, 11],
424- [1788, 12],
425- [3836, 13],
426- [7677, 14],
427- [7932, 14],
428- [8189, 15],
429- [12, 6],
430- [93, 8],
431- [445, 10],
432- [1021, 12],
433- [1789, 12],
434- [7165, 14],
435- [13, 6],
436- [125, 9],
437- [764, 11],
438- [1532, 12],
439- [7164, 14],
440- [7676, 14],
441- [28, 7],
442- [380, 10],
443- [765, 11],
444- [1533, 12],
445- [12284, 15],
446- [29, 7],
447- [381, 10],
448- [892, 11],
449- [3581, 13],
450- [12285, 15],
451- [60, 8],
452- [444, 10],
453- [3069, 13],
454- [6141, 14],
455- [61, 8],
456- [509, 11],
457- [3580, 13],
458- [14332, 15],
459- [124, 9],
460- [1020, 12],
461- [252, 10],
462- [3068, 13],
463- [253, 10],
464- [14333, 15],
465- [508, 11],
466- [2044, 13],
467- [2045, 13],
468- [4092, 14],
469- [4093, 14],
470- [6140, 14],
471- [15356, 15],
472- [11, 4],
473- [120, 8],
474- [1013, 11],
475- [4076, 13],
476- [8172, 14],
477- [18, 5],
478- [237, 9],
479- [2012, 12],
480- [8173, 14],
481- [15357, 15],
482- [19, 5],
483- [1016, 11],
484- [15868, 15],
485- [24, 6],
486- [2013, 12],
487- [25, 6],
488- [2028, 12],
489- [34, 6],
490- [4077, 13],
491- [35, 6],
492- [4084, 13],
493- [53, 7],
494- [4085, 13],
495- [56, 7],
496- [4088, 13],
497- [57, 7],
498- [4089, 13],
499- [66, 7],
500- [8180, 14],
501- [67, 7],
502- [8181, 14],
503- [121, 8],
504- [8184, 14],
505- [130, 8],
506- [15869, 15],
507- [131, 8],
508- [244, 9],
509- [245, 9],
510- [248, 9],
511- [249, 9],
512- [258, 9],
513- [259, 9],
514- [501, 10],
515- [504, 10],
516- [505, 10],
517- [514, 10],
518- [515, 10],
519- [1017, 11],
520- [1026, 11],
521- [1027, 11],
522- [2029, 12],
523- [2036, 12],
524- [2037, 12],
525- [2040, 12],
526- [2041, 12],
527- [2050, 12],
528- [2051, 12],
529- [4098, 13],
530- [4099, 13],
531- [8185, 14],
532- [8194, 14],
533- [8195, 14],
534- [16124, 15],
535- [16125, 15],
536- [16252, 15],
537- [16253, 15],
538- [0, 4],
539-];
540-
541-pub const INTRA_RVLC_RUN: [i8; 169] = [
542- 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,
543- 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,
544- 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,
545- 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,
546- 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,
547- 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
548-];
549-
550-pub const INTRA_RVLC_LEVEL: [i8; 169] = [
551- 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,
552- 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,
553- 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,
554- 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,
555- 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,
556- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
557-];
558-
559175 pub const SPRITE_TRAJECTORY_LENS: [u8; 15] = [2, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
560176
561177 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;
590206
591207 pub const MPEG4_RL_INTRA_LAST: usize = 67;
592208
593-pub const RVLC_RL_INTER_N: usize = 169;
594-
595-pub const RVLC_RL_INTER_LAST: usize = 103;
596-
597-pub const RVLC_RL_INTRA_N: usize = 169;
598-
599-pub const RVLC_RL_INTRA_LAST: usize = 103;
600-
601209 #[cfg(test)]
602210 mod tests {
603211 use super::*;
@@ -629,10 +237,7 @@ mod tests {
629237 #[test]
630238 fn vlcs_prefix_free() {
631239 prefix_free("MPEG4_INTRA_VLC", &MPEG4_INTRA_VLC);
632- prefix_free("INTER_RVLC", &INTER_RVLC);
633- prefix_free("INTRA_RVLC", &INTRA_RVLC);
634240 prefix_free("INTER_VLC", &INTER_VLC);
635- prefix_free("INTRA_VLC_AIC", &INTRA_VLC_AIC);
636241 prefix_free("MVTAB", &to16(&MVTAB));
637242 prefix_free("H263_CBPY_TAB", &to16(&H263_CBPY_TAB));
638243 prefix_free("MPEG4_DCTAB_LUM", &to16(&MPEG4_DCTAB_LUM));
@@ -658,17 +263,4 @@ mod tests {
658263 is_perm(&ALTERNATE_HORIZONTAL_SCAN);
659264 is_perm(&ALTERNATE_VERTICAL_SCAN);
660265 }
661- #[test]
662- fn rl_lengths() {
663- assert_eq!(MPEG4_INTRA_RUN.len(), MPEG4_RL_INTRA_N);
664- assert_eq!(MPEG4_INTRA_LEVEL.len(), MPEG4_RL_INTRA_N);
665- assert_eq!(INTER_RUN.len(), H263_RL_INTER_N);
666- assert_eq!(INTER_LEVEL.len(), H263_RL_INTER_N);
667- assert_eq!(INTRA_RUN_AIC.len(), RL_INTRA_AIC_N);
668- assert_eq!(INTRA_LEVEL_AIC.len(), RL_INTRA_AIC_N);
669- assert_eq!(INTER_RVLC_RUN.len(), RVLC_RL_INTER_N);
670- assert_eq!(INTRA_RVLC_LEVEL.len(), RVLC_RL_INTRA_N);
671- assert_eq!(MPEG4_INTRA_VLC.len(), MPEG4_RL_INTRA_N + 1);
672- assert_eq!(INTER_RVLC.len(), RVLC_RL_INTER_N + 1);
673- }
674266 }
crates/ec-mpeg4/src/vlc.rsmodified+0 -27
@@ -108,12 +108,6 @@ pub struct Vlcs {
108108 pub mb_type_b: Vlc,
109109 pub rl_intra: Rl,
110110 pub rl_inter: Rl,
111- #[allow(dead_code)] // kept with the RVLC tables for data partitioning
112- pub rl_intra_aic: Rl,
113- #[allow(dead_code)]
114- pub rvlc_intra: Rl,
115- #[allow(dead_code)]
116- pub rvlc_inter: Rl,
117111 pub sprite_traj: Vlc,
118112 }
119113
@@ -151,27 +145,6 @@ pub fn vlcs() -> &'static Vlcs {
151145 H263_RL_INTER_N,
152146 H263_RL_INTER_LAST,
153147 ),
154- rl_intra_aic: Rl::new(
155- &INTRA_VLC_AIC,
156- &INTRA_RUN_AIC,
157- &INTRA_LEVEL_AIC,
158- RL_INTRA_AIC_N,
159- RL_INTRA_AIC_LAST,
160- ),
161- rvlc_intra: Rl::new(
162- &INTRA_RVLC,
163- &INTRA_RVLC_RUN,
164- &INTRA_RVLC_LEVEL,
165- RVLC_RL_INTRA_N,
166- RVLC_RL_INTRA_LAST,
167- ),
168- rvlc_inter: Rl::new(
169- &INTER_RVLC,
170- &INTER_RVLC_RUN,
171- &INTER_RVLC_LEVEL,
172- RVLC_RL_INTER_N,
173- RVLC_RL_INTER_LAST,
174- ),
175148 sprite_traj: {
176149 let mut c = Vec::new();
177150 let mut code = 0u32;