From db63f876c1a23ab4b52629a485aab520101a6345 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 23 Jan 2019 17:56:52 +0100 Subject: [PATCH 1/1] codebook: make TableDescReader accept non-static tables --- nihav-core/src/io/codebook.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nihav-core/src/io/codebook.rs b/nihav-core/src/io/codebook.rs index 78ef5ae..285bedd 100644 --- a/nihav-core/src/io/codebook.rs +++ b/nihav-core/src/io/codebook.rs @@ -314,18 +314,18 @@ impl CodebookDescReader for ShortCodebookDescReader { fn len(&mut self) -> usize { self.data.len() } } -pub struct TableCodebookDescReader { - bits: &'static [u8], - codes: &'static [CodeType], +pub struct TableCodebookDescReader<'a, CodeType:'static, IndexType:'static> { + bits: &'a [u8], + codes: &'a [CodeType], idx_map: fn(usize) -> IndexType, } -impl<'a, CodeType, IndexType> TableCodebookDescReader { - pub fn new(codes: &'static [CodeType], bits: &'static [u8], idx_map: fn(usize) -> IndexType) -> Self { +impl<'a, CodeType, IndexType> TableCodebookDescReader<'a, CodeType, IndexType> { + pub fn new(codes: &'a [CodeType], bits: &'a [u8], idx_map: fn(usize) -> IndexType) -> Self { Self { bits, codes, idx_map } } } -impl, IndexType> CodebookDescReader for TableCodebookDescReader +impl<'a, CodeType: Copy+Into, IndexType> CodebookDescReader for TableCodebookDescReader<'a, CodeType, IndexType> { fn bits(&mut self, idx: usize) -> u8 { self.bits[idx] } fn code(&mut self, idx: usize) -> u32 { self.codes[idx].into() } -- 2.39.5