1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef _ACM_LAB_VALUE_UNPACKER_H
22 #define _ACM_LAB_VALUE_UNPACKER_H
24 #include "DataStream.h"
26 class CValueUnpacker
{
28 // Parameters of ACM stream
29 int levels
, subblocks
;
33 unsigned int next_bits
; // new bits
34 int avail_bits
; // count of new bits
36 int sb_size
, block_size
;
37 short* amp_buffer
, * buff_middle
;
41 void prepare_bits(int bits
); // request bits
42 int get_bits(int bits
); // request and return next bits
44 // These functions are used to fill the buffer with the amplitude values
45 int return0(int pass
, int ind
);
46 int zero_fill(int pass
, int ind
);
47 int linear_fill(int pass
, int ind
);
49 int k1_3bits(int pass
, int ind
);
50 int k1_2bits(int pass
, int ind
);
51 int t1_5bits(int pass
, int ind
);
53 int k2_4bits(int pass
, int ind
);
54 int k2_3bits(int pass
, int ind
);
55 int t2_7bits(int pass
, int ind
);
57 int k3_5bits(int pass
, int ind
);
58 int k3_4bits(int pass
, int ind
);
60 int k4_5bits(int pass
, int ind
);
61 int k4_4bits(int pass
, int ind
);
63 int t3_7bits(int pass
, int ind
);
66 CValueUnpacker(int lev_cnt
, int sb_count
, DataStream
* stream
)
67 : levels( lev_cnt
), subblocks( sb_count
), next_bits( 0 ),
68 avail_bits( 0 ), sb_size( 1 << levels
),
69 block_size( sb_size
*subblocks
), amp_buffer( NULL
),
70 buff_middle( NULL
), block_ptr( NULL
)
72 this->stream
= stream
;
74 virtual ~CValueUnpacker()
83 int get_one_block(int* block
);
86 typedef int (CValueUnpacker::* FillerProc
) (int pass
, int ind
);