From 64e8b9711a54641d4155d01f095053233c79a9bf Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 3 Jul 2019 18:05:11 +0200 Subject: [PATCH] move zigzag scan to common place --- nihav-commonfmt/src/codecs/clearvideo.rs | 11 ----------- nihav-core/src/codecs/h263/data.rs | 11 ----------- nihav-core/src/codecs/mod.rs | 11 +++++++++++ nihav-duck/src/codecs/vp3.rs | 11 ----------- nihav-indeo/src/codecs/indeo4.rs | 2 +- nihav-indeo/src/codecs/indeo5.rs | 2 +- nihav-indeo/src/codecs/intel263.rs | 2 +- nihav-indeo/src/codecs/ivi.rs | 10 ---------- nihav-realmedia/src/codecs/rv10.rs | 2 +- nihav-realmedia/src/codecs/rv20.rs | 2 +- 10 files changed, 16 insertions(+), 48 deletions(-) diff --git a/nihav-commonfmt/src/codecs/clearvideo.rs b/nihav-commonfmt/src/codecs/clearvideo.rs index 46cbb54..3e913a9 100644 --- a/nihav-commonfmt/src/codecs/clearvideo.rs +++ b/nihav-commonfmt/src/codecs/clearvideo.rs @@ -815,17 +815,6 @@ const CLV_AC_BITS: &[u8] = &[ const CLV_AC_ESCAPE: u16 = 0x1BFF; -const ZIGZAG: &[usize] = &[ - 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, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63 -]; - const CLV_BIAS_ESCAPE: u16 = 0x100; const CLV_MVY_0_BITS: &[u8] = &[ diff --git a/nihav-core/src/codecs/h263/data.rs b/nihav-core/src/codecs/h263/data.rs index 4f6a705..de827d4 100644 --- a/nihav-core/src/codecs/h263/data.rs +++ b/nihav-core/src/codecs/h263/data.rs @@ -8,17 +8,6 @@ pub const H263_SCALES: &[u8] = &[ 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, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 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, diff --git a/nihav-core/src/codecs/mod.rs b/nihav-core/src/codecs/mod.rs index 6cc8880..ee6f5cd 100644 --- a/nihav-core/src/codecs/mod.rs +++ b/nihav-core/src/codecs/mod.rs @@ -293,3 +293,14 @@ impl RegisteredDecoders { self.decs.iter() } } + +pub const ZIGZAG: [usize; 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, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63 +]; diff --git a/nihav-duck/src/codecs/vp3.rs b/nihav-duck/src/codecs/vp3.rs index 698d623..487c671 100644 --- a/nihav-duck/src/codecs/vp3.rs +++ b/nihav-duck/src/codecs/vp3.rs @@ -2048,17 +2048,6 @@ const VP3_QMAT_INTER: &[i16; 64] = &[ 40, 48, 64, 64, 64, 96, 128, 128 ]; -const ZIGZAG: [usize; 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, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63 -]; - const VP31_DC_CODES: [[u16; 32]; 16] = [ [ 0x002D, 0x0026, 0x0166, 0x004E, 0x02CE, 0x059E, 0x027D, 0x0008, diff --git a/nihav-indeo/src/codecs/indeo4.rs b/nihav-indeo/src/codecs/indeo4.rs index ce6bc35..15cae6d 100644 --- a/nihav-indeo/src/codecs/indeo4.rs +++ b/nihav-indeo/src/codecs/indeo4.rs @@ -506,7 +506,7 @@ const INDEO4_SCAN_4X4_VER: [usize; 16] = [ 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 1 const INDEO4_SCAN_4X4_HOR: [usize; 16] = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]; const INDEO4_SCANS_8X8: [&[usize; 64]; 5] = [ - &IVI_ZIGZAG, &INDEO4_SCAN_8X8_ALT, &IVI_SCAN_8X8_HOR, &IVI_SCAN_8X8_VER, &IVI_ZIGZAG + &ZIGZAG, &INDEO4_SCAN_8X8_ALT, &IVI_SCAN_8X8_HOR, &IVI_SCAN_8X8_VER, &ZIGZAG ]; const INDEO4_SCANS_4X4: [&[usize; 16]; 5] = [ &IVI_SCAN_4X4, &INDEO4_SCAN_4X4_ALT, &INDEO4_SCAN_4X4_VER, &INDEO4_SCAN_4X4_HOR, &IVI_SCAN_4X4 diff --git a/nihav-indeo/src/codecs/indeo5.rs b/nihav-indeo/src/codecs/indeo5.rs index aece25d..eec603a 100644 --- a/nihav-indeo/src/codecs/indeo5.rs +++ b/nihav-indeo/src/codecs/indeo5.rs @@ -662,7 +662,7 @@ const INDEO5_Q4_INTRA: &[u16; 16] = &INDEO5_QUANT4X4_INTRA; const INDEO5_Q4_INTER: &[u16; 16] = &INDEO5_QUANT4X4_INTER; const INDEO5_SCAN8X8: [&[usize; 64]; 4] = [ - &IVI_ZIGZAG, &IVI_SCAN_8X8_VER, &IVI_SCAN_8X8_HOR, &IVI_SCAN_8X8_HOR + &ZIGZAG, &IVI_SCAN_8X8_VER, &IVI_SCAN_8X8_HOR, &IVI_SCAN_8X8_HOR ]; const INDEO5_SCAN4X4: &[usize; 16] = &IVI_SCAN_4X4; diff --git a/nihav-indeo/src/codecs/intel263.rs b/nihav-indeo/src/codecs/intel263.rs index be28601..fb23bfc 100644 --- a/nihav-indeo/src/codecs/intel263.rs +++ b/nihav-indeo/src/codecs/intel263.rs @@ -92,7 +92,7 @@ impl<'a> Intel263BR<'a> { } idx += run; validate!(idx < 64); - let oidx = H263_ZIGZAG[idx as usize]; + let oidx = ZIGZAG[idx as usize]; blk[oidx] = level; idx += 1; if last { break; } diff --git a/nihav-indeo/src/codecs/ivi.rs b/nihav-indeo/src/codecs/ivi.rs index 612572a..ab1c91d 100644 --- a/nihav-indeo/src/codecs/ivi.rs +++ b/nihav-indeo/src/codecs/ivi.rs @@ -250,16 +250,6 @@ impl IVITile { } } -pub const IVI_ZIGZAG: [usize; 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, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63 -]; pub const IVI_SCAN_8X8_VER: [usize; 64] = [ 0, 8, 16, 24, 32, 40, 48, 56, 1, 9, 17, 25, 33, 41, 49, 57, diff --git a/nihav-realmedia/src/codecs/rv10.rs b/nihav-realmedia/src/codecs/rv10.rs index 4b75a40..d6d4dc6 100644 --- a/nihav-realmedia/src/codecs/rv10.rs +++ b/nihav-realmedia/src/codecs/rv10.rs @@ -185,7 +185,7 @@ impl<'a> RealVideo10BR<'a> { } idx += run; validate!(idx < 64); - let oidx = H263_ZIGZAG[idx as usize]; + let oidx = ZIGZAG[idx as usize]; blk[oidx] = level; idx += 1; if last { break; } diff --git a/nihav-realmedia/src/codecs/rv20.rs b/nihav-realmedia/src/codecs/rv20.rs index 66413b2..81556d8 100644 --- a/nihav-realmedia/src/codecs/rv20.rs +++ b/nihav-realmedia/src/codecs/rv20.rs @@ -126,7 +126,7 @@ impl<'a> RealVideo20BR<'a> { let scan = match acpred { ACPredMode::Hor => H263_SCAN_V, ACPredMode::Ver => H263_SCAN_H, - _ => H263_ZIGZAG, + _ => &ZIGZAG, }; let rl_cb = if sstate.is_iframe { &self.tables.aic_rl_cb } else { &self.tables.rl_cb }; -- 2.30.2