dcmjpls/libcharls/lokuptbl.h

00001 //
00002 // (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use.
00003 //
00004 
00005 
00006 #ifndef CHARLS_LOOKUPTABLE
00007 #define CHARLS_LOOKUPTABLE
00008 
00009 // Tables for fast decoding of short Golomb Codes.
00010 
00011 struct Code
00012 {
00013     Code()
00014     {
00015     }
00016 
00017     Code(LONG value, LONG length)   :
00018         _value(value),
00019         _length(length)
00020     {
00021     }
00022 
00023     LONG GetValue() const
00024         { return _value; }
00025     LONG GetLength() const
00026         { return _length; }
00027 
00028     LONG _value;
00029     LONG _length;
00030 };
00031 
00032 
00033 
00034 class CTable
00035 {
00036 public:
00037 
00038     enum { cbit = 8 } ;
00039 
00040     CTable()
00041     {
00042         ::memset(rgtype, 0, sizeof(rgtype));
00043     }
00044 
00045     void AddEntry(BYTE bvalue, Code c);
00046 
00047     inlinehint const Code& Get(LONG value)
00048         { return rgtype[value]; }
00049 private:
00050     Code rgtype[1 << cbit];
00051 };
00052 
00053 
00054 //
00055 // AddEntry
00056 //
00057 void CTable::AddEntry(BYTE bvalue, Code c)
00058 {
00059     LONG length = c.GetLength();
00060     ASSERT(length <= cbit);
00061 
00062     for (LONG i = 0; i < LONG(1) << (cbit - length); ++i)
00063     {
00064         ASSERT(rgtype[(bvalue << (cbit - length)) + i].GetLength() == 0);
00065         rgtype[(bvalue << (cbit - length)) + i] = c;
00066     }
00067 }
00068 
00069 #endif


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1