ScummVM API documentation
vlc.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #include "common/scummsys.h"
23 
24 /* VLC code
25  *
26  * Original copyright note: * Intel Indeo 4 (IV41, IV42, etc.) video decoder for ffmpeg
27  * written, produced, and directed by Alan Smithee
28  */
29 
30 #ifndef IMAGE_CODECS_INDEO_VLC_H
31 #define IMAGE_CODECS_INDEO_VLC_H
32 
33 #include "image/codecs/indeo/get_bits.h"
34 
35 namespace Image {
36 namespace Indeo {
37 
38 #define VLC_TYPE int16
39 
40 enum VLCFlag {
41  INIT_VLC_LE = 2,
42  INIT_VLC_USE_NEW_STATIC = 4
43 };
44 
45 struct VLCcode {
46  uint8 bits;
47  uint16 symbol;
48 
53  uint32 code;
54 };
55 
56 struct VLC {
57 private:
58  static int compareVlcSpec(const void *a, const void *b);
59 
67  static uint getData(const void *table, uint idx, uint wrap, uint size);
68 public:
69  int _bits;
70  VLC_TYPE (*_table)[2];
71  int _tableSize, _tableAllocated;
72 
73  VLC();
74 
75  /* Build VLC decoding tables suitable for use with get_vlc().
76 
77  'nbBits' sets the decoding table size (2^nbBits) entries. The
78  bigger it is, the faster is the decoding. But it should not be too
79  big to save memory and L1 cache. '9' is a good compromise.
80 
81  'nbCodes' : number of vlcs codes
82 
83  'bits' : table which gives the size (in bits) of each vlc code.
84 
85  'codes' : table which gives the bit pattern of of each vlc code.
86 
87  'symbols' : table which gives the values to be returned from get_vlc().
88 
89  'xxx_wrap' : give the number of bytes between each entry of the
90  'bits' or 'codes' tables.
91 
92  'xxx_size' : gives the number of bytes of each entry of the 'bits'
93  or 'codes' tables.
94 
95  'wrap' and 'size' make it possible to use any memory configuration and types
96  (byte/word/long) to store the 'bits', 'codes', and 'symbols' tables.
97 
98  'useStatic' should be set to 1 for tables, which should be freed
99  with av_free_static(), 0 if freeVlc() will be used.
100  */
101  int init_vlc(int nbBits, int nbCodes, const void *bits, int bitsWrap,
102  int bitsSize, const void *codes, int codesWrap, int codesSize,
103  const void *symbols, int symbolsWrap, int symbolsSize, int flags);
104 
105  int init_vlc(int nbBits, int nbCodes, const void *bits, int bitsWrap, int bitsSize,
106  const void *codes, int codesWrap, int codesSize, int flags);
107 
111  void freeVlc();
112 
113 
126  int buildTable(int tableNbBits, int nbCodes, VLCcode *codes, int flags);
127 
128  int allocTable(int size, int useStatic);
129 };
130 
131 } // End of namespace Indeo
132 } // End of namespace Image
133 
134 #endif
Definition: vlc.h:45
Definition: vlc.h:56
uint32 code
Definition: vlc.h:53
Definition: movie_decoder.h:32