X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-core%2Fsrc%2Fio%2Fcodebook.rs;h=285beddea95d9d8e0060433dc107490debdead11;hb=db63f876c1a23ab4b52629a485aab520101a6345;hp=78ef5ae0d142164106696f478916905da2514477;hpb=5641dccfbf2a70d589cf094a0d4ed5a10f919f00;p=nihav.git 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() }