mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-25 22:07:34 +00:00
Mohawk : Improved code formatting conventions compliance.
svn-id: r46965
This commit is contained in:
parent
ed06df7a25
commit
ae9cf4d51e
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "graphics/jpeg.h"
|
#include "graphics/jpeg.h"
|
||||||
#include "graphics/pixelformat.h"
|
#include "graphics/pixelformat.h"
|
||||||
|
|
||||||
namespace Mohawk {
|
namespace Mohawk {
|
||||||
|
|
||||||
// Myst JPEG Decoder
|
// Myst JPEG Decoder
|
||||||
|
@ -59,7 +59,7 @@ bool MystSaveLoad::loadGame(Common::String filename) {
|
|||||||
|| (size != 664 && (_vm->getFeatures() & GF_ME))
|
|| (size != 664 && (_vm->getFeatures() & GF_ME))
|
||||||
|| (size != 601 && !(_vm->getFeatures() & GF_ME))) {
|
|| (size != 601 && !(_vm->getFeatures() & GF_ME))) {
|
||||||
warning ("Incompatible saved game version");
|
warning ("Incompatible saved game version");
|
||||||
// FIXME - Add Support to load original game saves in ME and vice versa
|
// FIXME - Add Support to load original game saves in ME and vice versa
|
||||||
delete loadFile;
|
delete loadFile;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -174,8 +174,8 @@ struct MystVariables {
|
|||||||
*/
|
*/
|
||||||
uint16 dunny_vars[1];
|
uint16 dunny_vars[1];
|
||||||
|
|
||||||
// The values in these regions seem to be lists of resource IDs
|
// The values in these regions seem to be lists of resource IDs
|
||||||
// which correspond to VIEW resources i.e. cards
|
// which correspond to VIEW resources i.e. cards
|
||||||
uint16 unknown_myst[31];
|
uint16 unknown_myst[31];
|
||||||
|
|
||||||
uint16 unknown_channelwood[37];
|
uint16 unknown_channelwood[37];
|
||||||
|
@ -159,7 +159,7 @@ void CinepakDecoder::loadCodebook(Common::SeekableReadStream *stream, uint16 str
|
|||||||
for (uint16 i = 0; i < 256; i++) {
|
for (uint16 i = 0; i < 256; i++) {
|
||||||
if ((chunkID & 0x01) && !(mask >>= 1)) {
|
if ((chunkID & 0x01) && !(mask >>= 1)) {
|
||||||
if ((stream->pos() - startPos + 4) > (int32)chunkSize)
|
if ((stream->pos() - startPos + 4) > (int32)chunkSize)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
flag = stream->readUint32BE();
|
flag = stream->readUint32BE();
|
||||||
mask = 0x80000000;
|
mask = 0x80000000;
|
||||||
@ -209,14 +209,14 @@ void CinepakDecoder::decodeVectors(Common::SeekableReadStream *stream, uint16 st
|
|||||||
mask = 0x80000000;
|
mask = 0x80000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(chunkID & 0x01) || (flag & mask)) {
|
if (!(chunkID & 0x01) || (flag & mask)) {
|
||||||
if (!(chunkID & 0x02) && !(mask >>= 1)) {
|
if (!(chunkID & 0x02) && !(mask >>= 1)) {
|
||||||
if ((stream->pos() - startPos + 4) > (int32)chunkSize)
|
if ((stream->pos() - startPos + 4) > (int32)chunkSize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
flag = stream->readUint32BE();
|
flag = stream->readUint32BE();
|
||||||
mask = 0x80000000;
|
mask = 0x80000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((chunkID & 0x02) || (~flag & mask)) {
|
if ((chunkID & 0x02) || (~flag & mask)) {
|
||||||
if ((stream->pos() - startPos + 1) > (int32)chunkSize)
|
if ((stream->pos() - startPos + 1) > (int32)chunkSize)
|
||||||
|
@ -34,496 +34,496 @@ namespace Mohawk {
|
|||||||
|
|
||||||
// values in this table range from -1..23; adjust retrieved value by -1
|
// values in this table range from -1..23; adjust retrieved value by -1
|
||||||
static const uint16 vlc_tab_level_huffcodes[24] = {
|
static const uint16 vlc_tab_level_huffcodes[24] = {
|
||||||
0x037c, 0x0004, 0x003c, 0x004c, 0x003a, 0x002c, 0x001c, 0x001a,
|
0x037c, 0x0004, 0x003c, 0x004c, 0x003a, 0x002c, 0x001c, 0x001a,
|
||||||
0x0024, 0x0014, 0x0001, 0x0002, 0x0000, 0x0003, 0x0007, 0x0005,
|
0x0024, 0x0014, 0x0001, 0x0002, 0x0000, 0x0003, 0x0007, 0x0005,
|
||||||
0x0006, 0x0008, 0x0009, 0x000a, 0x000c, 0x00fc, 0x007c, 0x017c
|
0x0006, 0x0008, 0x0009, 0x000a, 0x000c, 0x00fc, 0x007c, 0x017c
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_level_huffbits[24] = {
|
static const byte vlc_tab_level_huffbits[24] = {
|
||||||
10, 6, 7, 7, 6, 6, 6, 6, 6, 5, 4, 4, 4, 3, 3, 3, 3, 4, 4, 5, 7, 8, 9, 10
|
10, 6, 7, 7, 6, 6, 6, 6, 6, 5, 4, 4, 4, 3, 3, 3, 3, 4, 4, 5, 7, 8, 9, 10
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..36; adjust retrieved value by -1
|
// values in this table range from -1..36; adjust retrieved value by -1
|
||||||
static const uint16 vlc_tab_diff_huffcodes[37] = {
|
static const uint16 vlc_tab_diff_huffcodes[37] = {
|
||||||
0x1c57, 0x0004, 0x0000, 0x0001, 0x0003, 0x0002, 0x000f, 0x000e,
|
0x1c57, 0x0004, 0x0000, 0x0001, 0x0003, 0x0002, 0x000f, 0x000e,
|
||||||
0x0007, 0x0016, 0x0037, 0x0027, 0x0026, 0x0066, 0x0006, 0x0097,
|
0x0007, 0x0016, 0x0037, 0x0027, 0x0026, 0x0066, 0x0006, 0x0097,
|
||||||
0x0046, 0x01c6, 0x0017, 0x0786, 0x0086, 0x0257, 0x00d7, 0x0357,
|
0x0046, 0x01c6, 0x0017, 0x0786, 0x0086, 0x0257, 0x00d7, 0x0357,
|
||||||
0x00c6, 0x0386, 0x0186, 0x0000, 0x0157, 0x0c57, 0x0057, 0x0000,
|
0x00c6, 0x0386, 0x0186, 0x0000, 0x0157, 0x0c57, 0x0057, 0x0000,
|
||||||
0x0b86, 0x0000, 0x1457, 0x0000, 0x0457
|
0x0b86, 0x0000, 0x1457, 0x0000, 0x0457
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_diff_huffbits[37] = {
|
static const byte vlc_tab_diff_huffbits[37] = {
|
||||||
13, 3, 3, 2, 3, 3, 4, 4, 6, 5, 6, 6, 7, 7, 8, 8,
|
13, 3, 3, 2, 3, 3, 4, 4, 6, 5, 6, 6, 7, 7, 8, 8,
|
||||||
8, 9, 8, 11, 9, 10, 8, 10, 9, 12, 10, 0, 10, 13, 11, 0,
|
8, 9, 8, 11, 9, 10, 8, 10, 9, 12, 10, 0, 10, 13, 11, 0,
|
||||||
12, 0, 13, 0, 13
|
12, 0, 13, 0, 13
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..5; adjust retrieved value by -1
|
// values in this table range from -1..5; adjust retrieved value by -1
|
||||||
static const byte vlc_tab_run_huffcodes[6] = {
|
static const byte vlc_tab_run_huffcodes[6] = {
|
||||||
0x1f, 0x00, 0x01, 0x03, 0x07, 0x0f
|
0x1f, 0x00, 0x01, 0x03, 0x07, 0x0f
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_run_huffbits[6] = {
|
static const byte vlc_tab_run_huffbits[6] = {
|
||||||
5, 1, 2, 3, 4, 5
|
5, 1, 2, 3, 4, 5
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..19; adjust retrieved value by -1
|
// values in this table range from -1..19; adjust retrieved value by -1
|
||||||
static const uint16 vlc_tab_tone_level_idx_hi1_huffcodes[20] = {
|
static const uint16 vlc_tab_tone_level_idx_hi1_huffcodes[20] = {
|
||||||
0x5714, 0x000c, 0x0002, 0x0001, 0x0000, 0x0004, 0x0034, 0x0054,
|
0x5714, 0x000c, 0x0002, 0x0001, 0x0000, 0x0004, 0x0034, 0x0054,
|
||||||
0x0094, 0x0014, 0x0114, 0x0214, 0x0314, 0x0614, 0x0e14, 0x0f14,
|
0x0094, 0x0014, 0x0114, 0x0214, 0x0314, 0x0614, 0x0e14, 0x0f14,
|
||||||
0x2714, 0x0714, 0x1714, 0x3714
|
0x2714, 0x0714, 0x1714, 0x3714
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_tone_level_idx_hi1_huffbits[20] = {
|
static const byte vlc_tab_tone_level_idx_hi1_huffbits[20] = {
|
||||||
15, 4, 2, 1, 3, 5, 6, 7, 8, 10, 10, 11, 11, 12, 12, 12, 14, 14, 15, 14
|
15, 4, 2, 1, 3, 5, 6, 7, 8, 10, 10, 11, 11, 12, 12, 12, 14, 14, 15, 14
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..23; adjust retrieved value by -1
|
// values in this table range from -1..23; adjust retrieved value by -1
|
||||||
static const uint16 vlc_tab_tone_level_idx_mid_huffcodes[24] = {
|
static const uint16 vlc_tab_tone_level_idx_mid_huffcodes[24] = {
|
||||||
0x0fea, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0fea, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x03ea, 0x00ea, 0x002a, 0x001a,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x03ea, 0x00ea, 0x002a, 0x001a,
|
||||||
0x0006, 0x0001, 0x0000, 0x0002, 0x000a, 0x006a, 0x01ea, 0x07ea
|
0x0006, 0x0001, 0x0000, 0x0002, 0x000a, 0x006a, 0x01ea, 0x07ea
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_tone_level_idx_mid_huffbits[24] = {
|
static const byte vlc_tab_tone_level_idx_mid_huffbits[24] = {
|
||||||
12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12
|
12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..23; adjust retrieved value by -1
|
// values in this table range from -1..23; adjust retrieved value by -1
|
||||||
static const uint16 vlc_tab_tone_level_idx_hi2_huffcodes[24] = {
|
static const uint16 vlc_tab_tone_level_idx_hi2_huffcodes[24] = {
|
||||||
0x0664, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0064, 0x00e4,
|
0x0664, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0064, 0x00e4,
|
||||||
0x00a4, 0x0068, 0x0004, 0x0008, 0x0014, 0x0018, 0x0000, 0x0001,
|
0x00a4, 0x0068, 0x0004, 0x0008, 0x0014, 0x0018, 0x0000, 0x0001,
|
||||||
0x0002, 0x0003, 0x000c, 0x0028, 0x0024, 0x0164, 0x0000, 0x0264
|
0x0002, 0x0003, 0x000c, 0x0028, 0x0024, 0x0164, 0x0000, 0x0264
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_tone_level_idx_hi2_huffbits[24] = {
|
static const byte vlc_tab_tone_level_idx_hi2_huffbits[24] = {
|
||||||
11, 0, 0, 0, 0, 0, 10, 8, 8, 7, 6, 6, 5, 5, 4, 2, 2, 2, 4, 7, 8, 9, 0, 11
|
11, 0, 0, 0, 0, 0, 10, 8, 8, 7, 6, 6, 5, 5, 4, 2, 2, 2, 4, 7, 8, 9, 0, 11
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..8; adjust retrieved value by -1
|
// values in this table range from -1..8; adjust retrieved value by -1
|
||||||
static const byte vlc_tab_type30_huffcodes[9] = {
|
static const byte vlc_tab_type30_huffcodes[9] = {
|
||||||
0x3c, 0x06, 0x00, 0x01, 0x03, 0x02, 0x04, 0x0c, 0x1c
|
0x3c, 0x06, 0x00, 0x01, 0x03, 0x02, 0x04, 0x0c, 0x1c
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_type30_huffbits[9] = {
|
static const byte vlc_tab_type30_huffbits[9] = {
|
||||||
6, 3, 3, 2, 2, 3, 4, 5, 6
|
6, 3, 3, 2, 2, 3, 4, 5, 6
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..9; adjust retrieved value by -1
|
// values in this table range from -1..9; adjust retrieved value by -1
|
||||||
static const byte vlc_tab_type34_huffcodes[10] = {
|
static const byte vlc_tab_type34_huffcodes[10] = {
|
||||||
0x18, 0x00, 0x01, 0x04, 0x05, 0x07, 0x03, 0x02, 0x06, 0x08
|
0x18, 0x00, 0x01, 0x04, 0x05, 0x07, 0x03, 0x02, 0x06, 0x08
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_type34_huffbits[10] = {
|
static const byte vlc_tab_type34_huffbits[10] = {
|
||||||
5, 4, 3, 3, 3, 3, 3, 3, 3, 5
|
5, 4, 3, 3, 3, 3, 3, 3, 3, 5
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..22; adjust retrieved value by -1
|
// values in this table range from -1..22; adjust retrieved value by -1
|
||||||
static const uint16 vlc_tab_fft_tone_offset_0_huffcodes[23] = {
|
static const uint16 vlc_tab_fft_tone_offset_0_huffcodes[23] = {
|
||||||
0x038e, 0x0001, 0x0000, 0x0022, 0x000a, 0x0006, 0x0012, 0x0002,
|
0x038e, 0x0001, 0x0000, 0x0022, 0x000a, 0x0006, 0x0012, 0x0002,
|
||||||
0x001e, 0x003e, 0x0056, 0x0016, 0x000e, 0x0032, 0x0072, 0x0042,
|
0x001e, 0x003e, 0x0056, 0x0016, 0x000e, 0x0032, 0x0072, 0x0042,
|
||||||
0x008e, 0x004e, 0x00f2, 0x002e, 0x0036, 0x00c2, 0x018e
|
0x008e, 0x004e, 0x00f2, 0x002e, 0x0036, 0x00c2, 0x018e
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_fft_tone_offset_0_huffbits[23] = {
|
static const byte vlc_tab_fft_tone_offset_0_huffbits[23] = {
|
||||||
10, 1, 2, 6, 4, 5, 6, 7, 6, 6, 7, 7, 8, 7, 8, 8, 9, 7, 8, 6, 6, 8, 10
|
10, 1, 2, 6, 4, 5, 6, 7, 6, 6, 7, 7, 8, 7, 8, 8, 9, 7, 8, 6, 6, 8, 10
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..27; adjust retrieved value by -1
|
// values in this table range from -1..27; adjust retrieved value by -1
|
||||||
static const uint16 vlc_tab_fft_tone_offset_1_huffcodes[28] = {
|
static const uint16 vlc_tab_fft_tone_offset_1_huffcodes[28] = {
|
||||||
0x07a4, 0x0001, 0x0020, 0x0012, 0x001c, 0x0008, 0x0006, 0x0010,
|
0x07a4, 0x0001, 0x0020, 0x0012, 0x001c, 0x0008, 0x0006, 0x0010,
|
||||||
0x0000, 0x0014, 0x0004, 0x0032, 0x0070, 0x000c, 0x0002, 0x003a,
|
0x0000, 0x0014, 0x0004, 0x0032, 0x0070, 0x000c, 0x0002, 0x003a,
|
||||||
0x001a, 0x002c, 0x002a, 0x0022, 0x0024, 0x000a, 0x0064, 0x0030,
|
0x001a, 0x002c, 0x002a, 0x0022, 0x0024, 0x000a, 0x0064, 0x0030,
|
||||||
0x0062, 0x00a4, 0x01a4, 0x03a4
|
0x0062, 0x00a4, 0x01a4, 0x03a4
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_fft_tone_offset_1_huffbits[28] = {
|
static const byte vlc_tab_fft_tone_offset_1_huffbits[28] = {
|
||||||
11, 1, 6, 6, 5, 4, 3, 6, 6, 5, 6, 6, 7, 6, 6, 6,
|
11, 1, 6, 6, 5, 4, 3, 6, 6, 5, 6, 6, 7, 6, 6, 6,
|
||||||
6, 6, 6, 7, 8, 6, 7, 7, 7, 9, 10, 11
|
6, 6, 6, 7, 8, 6, 7, 7, 7, 9, 10, 11
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..31; adjust retrieved value by -1
|
// values in this table range from -1..31; adjust retrieved value by -1
|
||||||
static const uint16 vlc_tab_fft_tone_offset_2_huffcodes[32] = {
|
static const uint16 vlc_tab_fft_tone_offset_2_huffcodes[32] = {
|
||||||
0x1760, 0x0001, 0x0000, 0x0082, 0x000c, 0x0006, 0x0003, 0x0007,
|
0x1760, 0x0001, 0x0000, 0x0082, 0x000c, 0x0006, 0x0003, 0x0007,
|
||||||
0x0008, 0x0004, 0x0010, 0x0012, 0x0022, 0x001a, 0x0000, 0x0020,
|
0x0008, 0x0004, 0x0010, 0x0012, 0x0022, 0x001a, 0x0000, 0x0020,
|
||||||
0x000a, 0x0040, 0x004a, 0x006a, 0x002a, 0x0042, 0x0002, 0x0060,
|
0x000a, 0x0040, 0x004a, 0x006a, 0x002a, 0x0042, 0x0002, 0x0060,
|
||||||
0x00aa, 0x00e0, 0x00c2, 0x01c2, 0x0160, 0x0360, 0x0760, 0x0f60
|
0x00aa, 0x00e0, 0x00c2, 0x01c2, 0x0160, 0x0360, 0x0760, 0x0f60
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_fft_tone_offset_2_huffbits[32] = {
|
static const byte vlc_tab_fft_tone_offset_2_huffbits[32] = {
|
||||||
13, 2, 0, 8, 4, 3, 3, 3, 4, 4, 5, 5, 6, 5, 7, 7,
|
13, 2, 0, 8, 4, 3, 3, 3, 4, 4, 5, 5, 6, 5, 7, 7,
|
||||||
7, 7, 7, 7, 8, 8, 8, 9, 8, 8, 9, 9, 10, 11, 13, 12
|
7, 7, 7, 7, 8, 8, 8, 9, 8, 8, 9, 9, 10, 11, 13, 12
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..34; adjust retrieved value by -1
|
// values in this table range from -1..34; adjust retrieved value by -1
|
||||||
static const uint16 vlc_tab_fft_tone_offset_3_huffcodes[35] = {
|
static const uint16 vlc_tab_fft_tone_offset_3_huffcodes[35] = {
|
||||||
0x33ea, 0x0005, 0x0000, 0x000c, 0x0000, 0x0006, 0x0003, 0x0008,
|
0x33ea, 0x0005, 0x0000, 0x000c, 0x0000, 0x0006, 0x0003, 0x0008,
|
||||||
0x0002, 0x0001, 0x0004, 0x0007, 0x001a, 0x000f, 0x001c, 0x002c,
|
0x0002, 0x0001, 0x0004, 0x0007, 0x001a, 0x000f, 0x001c, 0x002c,
|
||||||
0x000a, 0x001d, 0x002d, 0x002a, 0x000d, 0x004c, 0x008c, 0x006a,
|
0x000a, 0x001d, 0x002d, 0x002a, 0x000d, 0x004c, 0x008c, 0x006a,
|
||||||
0x00cd, 0x004d, 0x00ea, 0x020c, 0x030c, 0x010c, 0x01ea, 0x07ea,
|
0x00cd, 0x004d, 0x00ea, 0x020c, 0x030c, 0x010c, 0x01ea, 0x07ea,
|
||||||
0x0bea, 0x03ea, 0x13ea
|
0x0bea, 0x03ea, 0x13ea
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_fft_tone_offset_3_huffbits[35] = {
|
static const byte vlc_tab_fft_tone_offset_3_huffbits[35] = {
|
||||||
14, 4, 0, 10, 4, 3, 3, 4, 4, 3, 4, 4, 5, 4, 5, 6,
|
14, 4, 0, 10, 4, 3, 3, 4, 4, 3, 4, 4, 5, 4, 5, 6,
|
||||||
6, 5, 6, 7, 7, 7, 8, 8, 8, 8, 9, 10, 10, 10, 10, 11,
|
6, 5, 6, 7, 7, 7, 8, 8, 8, 8, 9, 10, 10, 10, 10, 11,
|
||||||
12, 13, 14
|
12, 13, 14
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..37; adjust retrieved value by -1
|
// values in this table range from -1..37; adjust retrieved value by -1
|
||||||
static const uint16 vlc_tab_fft_tone_offset_4_huffcodes[38] = {
|
static const uint16 vlc_tab_fft_tone_offset_4_huffcodes[38] = {
|
||||||
0x5282, 0x0016, 0x0000, 0x0136, 0x0004, 0x0000, 0x0007, 0x000a,
|
0x5282, 0x0016, 0x0000, 0x0136, 0x0004, 0x0000, 0x0007, 0x000a,
|
||||||
0x000e, 0x0003, 0x0001, 0x000d, 0x0006, 0x0009, 0x0012, 0x0005,
|
0x000e, 0x0003, 0x0001, 0x000d, 0x0006, 0x0009, 0x0012, 0x0005,
|
||||||
0x0025, 0x0022, 0x0015, 0x0002, 0x0076, 0x0035, 0x0042, 0x00c2,
|
0x0025, 0x0022, 0x0015, 0x0002, 0x0076, 0x0035, 0x0042, 0x00c2,
|
||||||
0x0182, 0x00b6, 0x0036, 0x03c2, 0x0482, 0x01c2, 0x0682, 0x0882,
|
0x0182, 0x00b6, 0x0036, 0x03c2, 0x0482, 0x01c2, 0x0682, 0x0882,
|
||||||
0x0a82, 0x0082, 0x0282, 0x1282, 0x3282, 0x2282
|
0x0a82, 0x0082, 0x0282, 0x1282, 0x3282, 0x2282
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte vlc_tab_fft_tone_offset_4_huffbits[38] = {
|
static const byte vlc_tab_fft_tone_offset_4_huffbits[38] = {
|
||||||
15, 6, 0, 9, 3, 3, 3, 4, 4, 3, 4, 4, 5, 4, 5, 6,
|
15, 6, 0, 9, 3, 3, 3, 4, 4, 3, 4, 4, 5, 4, 5, 6,
|
||||||
6, 6, 6, 8, 7, 6, 8, 9, 9, 8, 9, 10, 11, 10, 11, 12,
|
6, 6, 6, 8, 7, 6, 8, 9, 9, 8, 9, 10, 11, 10, 11, 12,
|
||||||
12, 12, 14, 15, 14, 14
|
12, 12, 14, 15, 14, 14
|
||||||
};
|
};
|
||||||
|
|
||||||
/// FFT TABLES
|
/// FFT TABLES
|
||||||
|
|
||||||
// values in this table range from -1..27; adjust retrieved value by -1
|
// values in this table range from -1..27; adjust retrieved value by -1
|
||||||
static const uint16 fft_level_exp_alt_huffcodes[28] = {
|
static const uint16 fft_level_exp_alt_huffcodes[28] = {
|
||||||
0x1ec6, 0x0006, 0x00c2, 0x0142, 0x0242, 0x0246, 0x00c6, 0x0046,
|
0x1ec6, 0x0006, 0x00c2, 0x0142, 0x0242, 0x0246, 0x00c6, 0x0046,
|
||||||
0x0042, 0x0146, 0x00a2, 0x0062, 0x0026, 0x0016, 0x000e, 0x0005,
|
0x0042, 0x0146, 0x00a2, 0x0062, 0x0026, 0x0016, 0x000e, 0x0005,
|
||||||
0x0004, 0x0003, 0x0000, 0x0001, 0x000a, 0x0012, 0x0002, 0x0022,
|
0x0004, 0x0003, 0x0000, 0x0001, 0x000a, 0x0012, 0x0002, 0x0022,
|
||||||
0x01c6, 0x02c6, 0x06c6, 0x0ec6
|
0x01c6, 0x02c6, 0x06c6, 0x0ec6
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte fft_level_exp_alt_huffbits[28] = {
|
static const byte fft_level_exp_alt_huffbits[28] = {
|
||||||
13, 7, 8, 9, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3,
|
13, 7, 8, 9, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3,
|
||||||
3, 2, 3, 3, 4, 5, 7, 8, 9, 11, 12, 13
|
3, 2, 3, 3, 4, 5, 7, 8, 9, 11, 12, 13
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..19; adjust retrieved value by -1
|
// values in this table range from -1..19; adjust retrieved value by -1
|
||||||
static const uint16 fft_level_exp_huffcodes[20] = {
|
static const uint16 fft_level_exp_huffcodes[20] = {
|
||||||
0x0f24, 0x0001, 0x0002, 0x0000, 0x0006, 0x0005, 0x0007, 0x000c,
|
0x0f24, 0x0001, 0x0002, 0x0000, 0x0006, 0x0005, 0x0007, 0x000c,
|
||||||
0x000b, 0x0014, 0x0013, 0x0004, 0x0003, 0x0023, 0x0064, 0x00a4,
|
0x000b, 0x0014, 0x0013, 0x0004, 0x0003, 0x0023, 0x0064, 0x00a4,
|
||||||
0x0024, 0x0124, 0x0324, 0x0724
|
0x0024, 0x0124, 0x0324, 0x0724
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte fft_level_exp_huffbits[20] = {
|
static const byte fft_level_exp_huffbits[20] = {
|
||||||
12, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 8, 9, 10, 11, 12
|
12, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 8, 9, 10, 11, 12
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..6; adjust retrieved value by -1
|
// values in this table range from -1..6; adjust retrieved value by -1
|
||||||
static const byte fft_stereo_exp_huffcodes[7] = {
|
static const byte fft_stereo_exp_huffcodes[7] = {
|
||||||
0x3e, 0x01, 0x00, 0x02, 0x06, 0x0e, 0x1e
|
0x3e, 0x01, 0x00, 0x02, 0x06, 0x0e, 0x1e
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte fft_stereo_exp_huffbits[7] = {
|
static const byte fft_stereo_exp_huffbits[7] = {
|
||||||
6, 1, 2, 3, 4, 5, 6
|
6, 1, 2, 3, 4, 5, 6
|
||||||
};
|
};
|
||||||
|
|
||||||
// values in this table range from -1..8; adjust retrieved value by -1
|
// values in this table range from -1..8; adjust retrieved value by -1
|
||||||
static const byte fft_stereo_phase_huffcodes[9] = {
|
static const byte fft_stereo_phase_huffcodes[9] = {
|
||||||
0x35, 0x02, 0x00, 0x01, 0x0d, 0x15, 0x05, 0x09, 0x03
|
0x35, 0x02, 0x00, 0x01, 0x0d, 0x15, 0x05, 0x09, 0x03
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte fft_stereo_phase_huffbits[9] = {
|
static const byte fft_stereo_phase_huffbits[9] = {
|
||||||
6, 2, 2, 4, 4, 6, 5, 4, 2
|
6, 2, 2, 4, 4, 6, 5, 4, 2
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int fft_cutoff_index_table[4][2] = {
|
static const int fft_cutoff_index_table[4][2] = {
|
||||||
{ 1, 2 }, {-1, 0 }, {-1,-2 }, { 0, 0 }
|
{ 1, 2 }, {-1, 0 }, {-1,-2 }, { 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int16 fft_level_index_table[256] = {
|
static const int16 fft_level_index_table[256] = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte last_coeff[3] = {
|
static const byte last_coeff[3] = {
|
||||||
4, 7, 10
|
4, 7, 10
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte coeff_per_sb_for_avg[3][30] = {
|
static const byte coeff_per_sb_for_avg[3][30] = {
|
||||||
{ 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
|
{ 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
|
||||||
{ 0, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
|
{ 0, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
|
||||||
{ 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9 }
|
{ 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint32 dequant_table[3][10][30] = {
|
static const uint32 dequant_table[3][10][30] = {
|
||||||
{ { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 256, 256, 205, 154, 102, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 256, 256, 205, 154, 102, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 51, 102, 154, 205, 256, 238, 219, 201, 183, 165, 146, 128, 110, 91, 73, 55, 37, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 51, 102, 154, 205, 256, 238, 219, 201, 183, 165, 146, 128, 110, 91, 73, 55, 37, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 18, 37, 55, 73, 91, 110, 128, 146, 165, 183, 201, 219, 238, 256, 228, 199, 171, 142, 114, 85, 57, 28 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 18, 37, 55, 73, 91, 110, 128, 146, 165, 183, 201, 219, 238, 256, 228, 199, 171, 142, 114, 85, 57, 28 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
|
||||||
{ { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 85, 171, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 85, 171, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 85, 171, 256, 219, 183, 146, 110, 73, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 85, 171, 256, 219, 183, 146, 110, 73, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 73, 110, 146, 183, 219, 256, 228, 199, 171, 142, 114, 85, 57, 28, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 73, 110, 146, 183, 219, 256, 228, 199, 171, 142, 114, 85, 57, 28, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 57, 85, 114, 142, 171, 199, 228, 256, 213, 171, 128, 85, 43 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 57, 85, 114, 142, 171, 199, 228, 256, 213, 171, 128, 85, 43 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
|
||||||
{ { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 256, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 256, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 85, 171, 256, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 85, 171, 256, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 192, 256, 205, 154, 102, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 192, 256, 205, 154, 102, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 102, 154, 205, 256, 213, 171, 128, 85, 43, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 102, 154, 205, 256, 213, 171, 128, 85, 43, 0, 0, 0, 0, 0, 0 },
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 85, 128, 171, 213, 256, 213, 171, 128, 85, 43 } }
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 85, 128, 171, 213, 256, 213, 171, 128, 85, 43 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte coeff_per_sb_for_dequant[3][30] = {
|
static const byte coeff_per_sb_for_dequant[3][30] = {
|
||||||
{ 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
|
{ 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
|
||||||
{ 0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 },
|
{ 0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 },
|
||||||
{ 0, 1, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9 }
|
{ 0, 1, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9 }
|
||||||
};
|
};
|
||||||
|
|
||||||
// first index is subband, 2nd index is 0, 1 or 3 (2 is unused)
|
// first index is subband, 2nd index is 0, 1 or 3 (2 is unused)
|
||||||
static const int8 tone_level_idx_offset_table[30][4] = {
|
static const int8 tone_level_idx_offset_table[30][4] = {
|
||||||
{ -50, -50, 0, -50 },
|
{ -50, -50, 0, -50 },
|
||||||
{ -50, -50, 0, -50 },
|
{ -50, -50, 0, -50 },
|
||||||
{ -50, -9, 0, -19 },
|
{ -50, -9, 0, -19 },
|
||||||
{ -16, -6, 0, -12 },
|
{ -16, -6, 0, -12 },
|
||||||
{ -11, -4, 0, -8 },
|
{ -11, -4, 0, -8 },
|
||||||
{ -8, -3, 0, -6 },
|
{ -8, -3, 0, -6 },
|
||||||
{ -7, -3, 0, -5 },
|
{ -7, -3, 0, -5 },
|
||||||
{ -6, -2, 0, -4 },
|
{ -6, -2, 0, -4 },
|
||||||
{ -5, -2, 0, -3 },
|
{ -5, -2, 0, -3 },
|
||||||
{ -4, -1, 0, -3 },
|
{ -4, -1, 0, -3 },
|
||||||
{ -4, -1, 0, -2 },
|
{ -4, -1, 0, -2 },
|
||||||
{ -3, -1, 0, -2 },
|
{ -3, -1, 0, -2 },
|
||||||
{ -3, -1, 0, -2 },
|
{ -3, -1, 0, -2 },
|
||||||
{ -3, -1, 0, -2 },
|
{ -3, -1, 0, -2 },
|
||||||
{ -2, -1, 0, -1 },
|
{ -2, -1, 0, -1 },
|
||||||
{ -2, -1, 0, -1 },
|
{ -2, -1, 0, -1 },
|
||||||
{ -2, -1, 0, -1 },
|
{ -2, -1, 0, -1 },
|
||||||
{ -2, 0, 0, -1 },
|
{ -2, 0, 0, -1 },
|
||||||
{ -2, 0, 0, -1 },
|
{ -2, 0, 0, -1 },
|
||||||
{ -1, 0, 0, -1 },
|
{ -1, 0, 0, -1 },
|
||||||
{ -1, 0, 0, -1 },
|
{ -1, 0, 0, -1 },
|
||||||
{ -1, 0, 0, -1 },
|
{ -1, 0, 0, -1 },
|
||||||
{ -1, 0, 0, -1 },
|
{ -1, 0, 0, -1 },
|
||||||
{ -1, 0, 0, -1 },
|
{ -1, 0, 0, -1 },
|
||||||
{ -1, 0, 0, -1 },
|
{ -1, 0, 0, -1 },
|
||||||
{ -1, 0, 0, -1 },
|
{ -1, 0, 0, -1 },
|
||||||
{ -1, 0, 0, 0 },
|
{ -1, 0, 0, 0 },
|
||||||
{ -1, 0, 0, 0 },
|
{ -1, 0, 0, 0 },
|
||||||
{ -1, 0, 0, 0 },
|
{ -1, 0, 0, 0 },
|
||||||
{ -1, 0, 0, 0 }
|
{ -1, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* all my samples have 1st index 0 or 1 */
|
/* all my samples have 1st index 0 or 1 */
|
||||||
/* second index is subband, only indexes 0-29 seem to be used */
|
/* second index is subband, only indexes 0-29 seem to be used */
|
||||||
static const int8 coding_method_table[5][30] = {
|
static const int8 coding_method_table[5][30] = {
|
||||||
{ 34, 30, 24, 24, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10,
|
{ 34, 30, 24, 24, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10,
|
||||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
|
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
|
||||||
},
|
},
|
||||||
{ 34, 30, 24, 24, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10,
|
{ 34, 30, 24, 24, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10,
|
||||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
|
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
|
||||||
},
|
},
|
||||||
{ 34, 30, 30, 30, 24, 24, 16, 16, 16, 16, 16, 16, 10, 10, 10,
|
{ 34, 30, 30, 30, 24, 24, 16, 16, 16, 16, 16, 16, 10, 10, 10,
|
||||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
|
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
|
||||||
},
|
},
|
||||||
{ 34, 34, 30, 30, 24, 24, 24, 24, 16, 16, 16, 16, 16, 16, 16,
|
{ 34, 34, 30, 30, 24, 24, 24, 24, 16, 16, 16, 16, 16, 16, 16,
|
||||||
16, 16, 16, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10, 10
|
16, 16, 16, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10, 10
|
||||||
},
|
},
|
||||||
{ 34, 34, 30, 30, 30, 30, 30, 30, 24, 24, 24, 24, 24, 24, 24,
|
{ 34, 34, 30, 30, 30, 30, 30, 30, 24, 24, 24, 24, 24, 24, 24,
|
||||||
24, 24, 24, 24, 24, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
|
24, 24, 24, 24, 24, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int vlc_stage3_values[60] = {
|
static const int vlc_stage3_values[60] = {
|
||||||
0, 1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 24,
|
0, 1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 24,
|
||||||
28, 36, 44, 52, 60, 76, 92, 108, 124, 156, 188, 220,
|
28, 36, 44, 52, 60, 76, 92, 108, 124, 156, 188, 220,
|
||||||
252, 316, 380, 444, 508, 636, 764, 892, 1020, 1276, 1532, 1788,
|
252, 316, 380, 444, 508, 636, 764, 892, 1020, 1276, 1532, 1788,
|
||||||
2044, 2556, 3068, 3580, 4092, 5116, 6140, 7164, 8188, 10236, 12284, 14332,
|
2044, 2556, 3068, 3580, 4092, 5116, 6140, 7164, 8188, 10236, 12284, 14332,
|
||||||
16380, 20476, 24572, 28668, 32764, 40956, 49148, 57340, 65532, 81916, 98300,114684
|
16380, 20476, 24572, 28668, 32764, 40956, 49148, 57340, 65532, 81916, 98300,114684
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float fft_tone_sample_table[4][16][5] = {
|
static const float fft_tone_sample_table[4][16][5] = {
|
||||||
{ { .0100000000f,-.0037037037f,-.0020000000f,-.0069444444f,-.0018416207f },
|
{ { .0100000000f,-.0037037037f,-.0020000000f,-.0069444444f,-.0018416207f },
|
||||||
{ .0416666667f, .0000000000f, .0000000000f,-.0208333333f,-.0123456791f },
|
{ .0416666667f, .0000000000f, .0000000000f,-.0208333333f,-.0123456791f },
|
||||||
{ .1250000000f, .0558035709f, .0330687836f,-.0164473690f,-.0097465888f },
|
{ .1250000000f, .0558035709f, .0330687836f,-.0164473690f,-.0097465888f },
|
||||||
{ .1562500000f, .0625000000f, .0370370370f,-.0062500000f,-.0037037037f },
|
{ .1562500000f, .0625000000f, .0370370370f,-.0062500000f,-.0037037037f },
|
||||||
{ .1996007860f, .0781250000f, .0462962948f, .0022727272f, .0013468013f },
|
{ .1996007860f, .0781250000f, .0462962948f, .0022727272f, .0013468013f },
|
||||||
{ .2000000000f, .0625000000f, .0370370373f, .0208333333f, .0074074073f },
|
{ .2000000000f, .0625000000f, .0370370373f, .0208333333f, .0074074073f },
|
||||||
{ .2127659619f, .0555555556f, .0329218097f, .0208333333f, .0123456791f },
|
{ .2127659619f, .0555555556f, .0329218097f, .0208333333f, .0123456791f },
|
||||||
{ .2173913121f, .0473484844f, .0280583613f, .0347222239f, .0205761325f },
|
{ .2173913121f, .0473484844f, .0280583613f, .0347222239f, .0205761325f },
|
||||||
{ .2173913121f, .0347222239f, .0205761325f, .0473484844f, .0280583613f },
|
{ .2173913121f, .0347222239f, .0205761325f, .0473484844f, .0280583613f },
|
||||||
{ .2127659619f, .0208333333f, .0123456791f, .0555555556f, .0329218097f },
|
{ .2127659619f, .0208333333f, .0123456791f, .0555555556f, .0329218097f },
|
||||||
{ .2000000000f, .0208333333f, .0074074073f, .0625000000f, .0370370370f },
|
{ .2000000000f, .0208333333f, .0074074073f, .0625000000f, .0370370370f },
|
||||||
{ .1996007860f, .0022727272f, .0013468013f, .0781250000f, .0462962948f },
|
{ .1996007860f, .0022727272f, .0013468013f, .0781250000f, .0462962948f },
|
||||||
{ .1562500000f,-.0062500000f,-.0037037037f, .0625000000f, .0370370370f },
|
{ .1562500000f,-.0062500000f,-.0037037037f, .0625000000f, .0370370370f },
|
||||||
{ .1250000000f,-.0164473690f,-.0097465888f, .0558035709f, .0330687836f },
|
{ .1250000000f,-.0164473690f,-.0097465888f, .0558035709f, .0330687836f },
|
||||||
{ .0416666667f,-.0208333333f,-.0123456791f, .0000000000f, .0000000000f },
|
{ .0416666667f,-.0208333333f,-.0123456791f, .0000000000f, .0000000000f },
|
||||||
{ .0100000000f,-.0069444444f,-.0018416207f,-.0037037037f,-.0020000000f } },
|
{ .0100000000f,-.0069444444f,-.0018416207f,-.0037037037f,-.0020000000f } },
|
||||||
|
|
||||||
{ { .0050000000f,-.0200000000f, .0125000000f,-.3030303030f, .0020000000f },
|
{ { .0050000000f,-.0200000000f, .0125000000f,-.3030303030f, .0020000000f },
|
||||||
{ .1041666642f, .0400000000f,-.0250000000f, .0333333333f,-.0200000000f },
|
{ .1041666642f, .0400000000f,-.0250000000f, .0333333333f,-.0200000000f },
|
||||||
{ .1250000000f, .0100000000f, .0142857144f,-.0500000007f,-.0200000000f },
|
{ .1250000000f, .0100000000f, .0142857144f,-.0500000007f,-.0200000000f },
|
||||||
{ .1562500000f,-.0006250000f,-.00049382716f,-.000625000f,-.00049382716f },
|
{ .1562500000f,-.0006250000f,-.00049382716f,-.000625000f,-.00049382716f },
|
||||||
{ .1562500000f,-.0006250000f,-.00049382716f,-.000625000f,-.00049382716f },
|
{ .1562500000f,-.0006250000f,-.00049382716f,-.000625000f,-.00049382716f },
|
||||||
{ .1250000000f,-.0500000000f,-.0200000000f, .0100000000f, .0142857144f },
|
{ .1250000000f,-.0500000000f,-.0200000000f, .0100000000f, .0142857144f },
|
||||||
{ .1041666667f, .0333333333f,-.0200000000f, .0400000000f,-.0250000000f },
|
{ .1041666667f, .0333333333f,-.0200000000f, .0400000000f,-.0250000000f },
|
||||||
{ .0050000000f,-.3030303030f, .0020000001f,-.0200000000f, .0125000000f },
|
{ .0050000000f,-.3030303030f, .0020000001f,-.0200000000f, .0125000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } },
|
||||||
|
|
||||||
{ { .1428571492f, .1250000000f,-.0285714287f,-.0357142873f, .0208333333f },
|
{ { .1428571492f, .1250000000f,-.0285714287f,-.0357142873f, .0208333333f },
|
||||||
{ .1818181818f, .0588235296f, .0333333333f, .0212765951f, .0100000000f },
|
{ .1818181818f, .0588235296f, .0333333333f, .0212765951f, .0100000000f },
|
||||||
{ .1818181818f, .0212765951f, .0100000000f, .0588235296f, .0333333333f },
|
{ .1818181818f, .0212765951f, .0100000000f, .0588235296f, .0333333333f },
|
||||||
{ .1428571492f,-.0357142873f, .0208333333f, .1250000000f,-.0285714287f },
|
{ .1428571492f,-.0357142873f, .0208333333f, .1250000000f,-.0285714287f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } },
|
||||||
|
|
||||||
{ { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
|
||||||
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } }
|
{ .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float fft_tone_level_table[2][64] = { {
|
static const float fft_tone_level_table[2][64] = { {
|
||||||
// pow ~ (i > 46) ? 0 : (((((i & 1) ? 431 : 304) << (i >> 1))) / 1024.0);
|
// pow ~ (i > 46) ? 0 : (((((i & 1) ? 431 : 304) << (i >> 1))) / 1024.0);
|
||||||
0.17677669f, 0.42677650f, 0.60355347f, 0.85355347f,
|
0.17677669f, 0.42677650f, 0.60355347f, 0.85355347f,
|
||||||
1.20710683f, 1.68359375f, 2.37500000f, 3.36718750f,
|
1.20710683f, 1.68359375f, 2.37500000f, 3.36718750f,
|
||||||
4.75000000f, 6.73437500f, 9.50000000f, 13.4687500f,
|
4.75000000f, 6.73437500f, 9.50000000f, 13.4687500f,
|
||||||
19.0000000f, 26.9375000f, 38.0000000f, 53.8750000f,
|
19.0000000f, 26.9375000f, 38.0000000f, 53.8750000f,
|
||||||
76.0000000f, 107.750000f, 152.000000f, 215.500000f,
|
76.0000000f, 107.750000f, 152.000000f, 215.500000f,
|
||||||
304.000000f, 431.000000f, 608.000000f, 862.000000f,
|
304.000000f, 431.000000f, 608.000000f, 862.000000f,
|
||||||
1216.00000f, 1724.00000f, 2432.00000f, 3448.00000f,
|
1216.00000f, 1724.00000f, 2432.00000f, 3448.00000f,
|
||||||
4864.00000f, 6896.00000f, 9728.00000f, 13792.0000f,
|
4864.00000f, 6896.00000f, 9728.00000f, 13792.0000f,
|
||||||
19456.0000f, 27584.0000f, 38912.0000f, 55168.0000f,
|
19456.0000f, 27584.0000f, 38912.0000f, 55168.0000f,
|
||||||
77824.0000f, 110336.000f, 155648.000f, 220672.000f,
|
77824.0000f, 110336.000f, 155648.000f, 220672.000f,
|
||||||
311296.000f, 441344.000f, 622592.000f, 882688.000f,
|
311296.000f, 441344.000f, 622592.000f, 882688.000f,
|
||||||
1245184.00f, 1765376.00f, 2490368.00f, 0.00000000f,
|
1245184.00f, 1765376.00f, 2490368.00f, 0.00000000f,
|
||||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||||
}, {
|
}, {
|
||||||
// pow = (i > 45) ? 0 : ((((i & 1) ? 431 : 304) << (i >> 1)) / 512.0);
|
// pow = (i > 45) ? 0 : ((((i & 1) ? 431 : 304) << (i >> 1)) / 512.0);
|
||||||
0.59375000f, 0.84179688f, 1.18750000f, 1.68359375f,
|
0.59375000f, 0.84179688f, 1.18750000f, 1.68359375f,
|
||||||
2.37500000f, 3.36718750f, 4.75000000f, 6.73437500f,
|
2.37500000f, 3.36718750f, 4.75000000f, 6.73437500f,
|
||||||
9.50000000f, 13.4687500f, 19.0000000f, 26.9375000f,
|
9.50000000f, 13.4687500f, 19.0000000f, 26.9375000f,
|
||||||
38.0000000f, 53.8750000f, 76.0000000f, 107.750000f,
|
38.0000000f, 53.8750000f, 76.0000000f, 107.750000f,
|
||||||
152.000000f, 215.500000f, 304.000000f, 431.000000f,
|
152.000000f, 215.500000f, 304.000000f, 431.000000f,
|
||||||
608.000000f, 862.000000f, 1216.00000f, 1724.00000f,
|
608.000000f, 862.000000f, 1216.00000f, 1724.00000f,
|
||||||
2432.00000f, 3448.00000f, 4864.00000f, 6896.00000f,
|
2432.00000f, 3448.00000f, 4864.00000f, 6896.00000f,
|
||||||
9728.00000f, 13792.0000f, 19456.0000f, 27584.0000f,
|
9728.00000f, 13792.0000f, 19456.0000f, 27584.0000f,
|
||||||
38912.0000f, 55168.0000f, 77824.0000f, 110336.000f,
|
38912.0000f, 55168.0000f, 77824.0000f, 110336.000f,
|
||||||
155648.000f, 220672.000f, 311296.000f, 441344.000f,
|
155648.000f, 220672.000f, 311296.000f, 441344.000f,
|
||||||
622592.000f, 882688.000f, 1245184.00f, 1765376.00f,
|
622592.000f, 882688.000f, 1245184.00f, 1765376.00f,
|
||||||
2490368.00f, 3530752.00f, 0.00000000f, 0.00000000f,
|
2490368.00f, 3530752.00f, 0.00000000f, 0.00000000f,
|
||||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f
|
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f
|
||||||
} };
|
} };
|
||||||
|
|
||||||
static const float fft_tone_envelope_table[4][31] = {
|
static const float fft_tone_envelope_table[4][31] = {
|
||||||
{ .009607375f, .038060248f, .084265202f, .146446645f, .222214907f, .308658302f,
|
{ .009607375f, .038060248f, .084265202f, .146446645f, .222214907f, .308658302f,
|
||||||
.402454883f, .500000060f, .597545207f, .691341758f, .777785182f, .853553414f,
|
.402454883f, .500000060f, .597545207f, .691341758f, .777785182f, .853553414f,
|
||||||
.915734828f, .961939812f, .990392685f, 1.00000000f, .990392625f, .961939752f,
|
.915734828f, .961939812f, .990392685f, 1.00000000f, .990392625f, .961939752f,
|
||||||
.915734768f, .853553295f, .777785063f, .691341639f, .597545087f, .500000000f,
|
.915734768f, .853553295f, .777785063f, .691341639f, .597545087f, .500000000f,
|
||||||
.402454853f, .308658272f, .222214878f, .146446615f, .084265172f, .038060218f,
|
.402454853f, .308658272f, .222214878f, .146446615f, .084265172f, .038060218f,
|
||||||
.009607345f },
|
.009607345f },
|
||||||
{ .038060248f, .146446645f, .308658302f, .500000060f, .691341758f, .853553414f,
|
{ .038060248f, .146446645f, .308658302f, .500000060f, .691341758f, .853553414f,
|
||||||
.961939812f, 1.00000000f, .961939752f, .853553295f, .691341639f, .500000000f,
|
.961939812f, 1.00000000f, .961939752f, .853553295f, .691341639f, .500000000f,
|
||||||
.308658272f, .146446615f, .038060218f, .000000000f, .000000000f, .000000000f,
|
.308658272f, .146446615f, .038060218f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f },
|
.000000000f },
|
||||||
{ .146446645f, .500000060f, .853553414f, 1.00000000f, .853553295f, .500000000f,
|
{ .146446645f, .500000060f, .853553414f, 1.00000000f, .853553295f, .500000000f,
|
||||||
.146446615f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
.146446615f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f },
|
.000000000f },
|
||||||
{ .500000060f, 1.00000000f, .500000000f, .000000000f, .000000000f, .000000000f,
|
{ .500000060f, 1.00000000f, .500000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
.000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
|
||||||
.000000000f }
|
.000000000f }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float sb_noise_attenuation[32] = {
|
static const float sb_noise_attenuation[32] = {
|
||||||
0.0f, 0.0f, 0.3f, 0.4f, 0.5f, 0.7f, 1.0f, 1.0f,
|
0.0f, 0.0f, 0.3f, 0.4f, 0.5f, 0.7f, 1.0f, 1.0f,
|
||||||
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
|
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
|
||||||
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
|
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
|
||||||
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
|
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const byte fft_subpackets[32] = {
|
static const byte fft_subpackets[32] = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// first index is joined_stereo, second index is 0 or 2 (1 is unused)
|
// first index is joined_stereo, second index is 0 or 2 (1 is unused)
|
||||||
static const float dequant_1bit[2][3] = {
|
static const float dequant_1bit[2][3] = {
|
||||||
{-0.920000f, 0.000000f, 0.920000f },
|
{-0.920000f, 0.000000f, 0.920000f },
|
||||||
{-0.890000f, 0.000000f, 0.890000f }
|
{-0.890000f, 0.000000f, 0.890000f }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float type30_dequant[8] = {
|
static const float type30_dequant[8] = {
|
||||||
-1.0f,-0.625f,-0.291666656732559f,0.0f,
|
-1.0f,-0.625f,-0.291666656732559f,0.0f,
|
||||||
0.25f,0.5f,0.75f,1.0f,
|
0.25f,0.5f,0.75f,1.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float type34_delta[10] = { // FIXME: covers 8 entries..
|
static const float type34_delta[10] = { // FIXME: covers 8 entries..
|
||||||
-1.0f,-0.60947573184967f,-0.333333343267441f,-0.138071194291115f,0.0f,
|
-1.0f,-0.60947573184967f,-0.333333343267441f,-0.138071194291115f,0.0f,
|
||||||
0.138071194291115f,0.333333343267441f,0.60947573184967f,1.0f,0.0f,
|
0.138071194291115f,0.333333343267441f,0.60947573184967f,1.0f,0.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Mohawk
|
} // End of namespace Mohawk
|
||||||
|
@ -64,323 +64,323 @@ QTRLEDecoder::QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) : Gra
|
|||||||
} \
|
} \
|
||||||
|
|
||||||
void QTRLEDecoder::decode1(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
|
void QTRLEDecoder::decode1(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
|
||||||
uint32 pixelPtr = 0;
|
uint32 pixelPtr = 0;
|
||||||
byte *rgb = (byte *)_surface->pixels;
|
byte *rgb = (byte *)_surface->pixels;
|
||||||
|
|
||||||
while (linesToChange) {
|
while (linesToChange) {
|
||||||
CHECK_STREAM_PTR(2);
|
CHECK_STREAM_PTR(2);
|
||||||
byte skip = stream->readByte();
|
byte skip = stream->readByte();
|
||||||
int8 rleCode = stream->readSByte();
|
int8 rleCode = stream->readSByte();
|
||||||
|
|
||||||
if (rleCode == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (skip & 0x80) {
|
|
||||||
linesToChange--;
|
|
||||||
rowPtr += _surface->w;
|
|
||||||
pixelPtr = rowPtr + 2 * (skip & 0x7f);
|
|
||||||
} else
|
|
||||||
pixelPtr += 2 * skip;
|
|
||||||
|
|
||||||
if (rleCode < 0) {
|
if (rleCode == 0)
|
||||||
// decode the run length code
|
break;
|
||||||
rleCode = -rleCode;
|
|
||||||
// get the next 2 bytes from the stream, treat them as groups of 8 pixels, and output them rleCode times */
|
if (skip & 0x80) {
|
||||||
CHECK_STREAM_PTR(2);
|
linesToChange--;
|
||||||
byte pi0 = stream->readByte();
|
rowPtr += _surface->w;
|
||||||
|
pixelPtr = rowPtr + 2 * (skip & 0x7f);
|
||||||
|
} else
|
||||||
|
pixelPtr += 2 * skip;
|
||||||
|
|
||||||
|
if (rleCode < 0) {
|
||||||
|
// decode the run length code
|
||||||
|
rleCode = -rleCode;
|
||||||
|
// get the next 2 bytes from the stream, treat them as groups of 8 pixels, and output them rleCode times */
|
||||||
|
CHECK_STREAM_PTR(2);
|
||||||
|
byte pi0 = stream->readByte();
|
||||||
byte pi1 = stream->readByte();
|
byte pi1 = stream->readByte();
|
||||||
CHECK_PIXEL_PTR(rleCode * 2);
|
CHECK_PIXEL_PTR(rleCode * 2);
|
||||||
|
|
||||||
while (rleCode--) {
|
while (rleCode--) {
|
||||||
rgb[pixelPtr++] = pi0;
|
rgb[pixelPtr++] = pi0;
|
||||||
rgb[pixelPtr++] = pi1;
|
rgb[pixelPtr++] = pi1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// copy the same pixel directly to output 2 times
|
// copy the same pixel directly to output 2 times
|
||||||
rleCode *= 2;
|
rleCode *= 2;
|
||||||
CHECK_STREAM_PTR(rleCode);
|
CHECK_STREAM_PTR(rleCode);
|
||||||
CHECK_PIXEL_PTR(rleCode);
|
CHECK_PIXEL_PTR(rleCode);
|
||||||
|
|
||||||
while (rleCode--)
|
while (rleCode--)
|
||||||
rgb[pixelPtr++] = stream->readByte();
|
rgb[pixelPtr++] = stream->readByte();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTRLEDecoder::decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange, byte bpp) {
|
void QTRLEDecoder::decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange, byte bpp) {
|
||||||
uint32 pixelPtr = 0;
|
uint32 pixelPtr = 0;
|
||||||
byte *rgb = (byte *)_surface->pixels;
|
byte *rgb = (byte *)_surface->pixels;
|
||||||
byte numPixels = (bpp == 4) ? 8 : 16;
|
byte numPixels = (bpp == 4) ? 8 : 16;
|
||||||
|
|
||||||
while (linesToChange--) {
|
while (linesToChange--) {
|
||||||
CHECK_STREAM_PTR(2);
|
CHECK_STREAM_PTR(2);
|
||||||
pixelPtr = rowPtr + (numPixels * (stream->readByte() - 1));
|
pixelPtr = rowPtr + (numPixels * (stream->readByte() - 1));
|
||||||
|
|
||||||
for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) {
|
for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) {
|
||||||
if (rleCode == 0) {
|
if (rleCode == 0) {
|
||||||
// there's another skip code in the stream
|
// there's another skip code in the stream
|
||||||
CHECK_STREAM_PTR(1);
|
CHECK_STREAM_PTR(1);
|
||||||
pixelPtr += (numPixels * (stream->readByte() - 1));
|
pixelPtr += (numPixels * (stream->readByte() - 1));
|
||||||
} else if (rleCode < 0) {
|
} else if (rleCode < 0) {
|
||||||
// decode the run length code
|
// decode the run length code
|
||||||
rleCode = -rleCode;
|
rleCode = -rleCode;
|
||||||
|
|
||||||
// get the next 4 bytes from the stream, treat them as palette indices, and output them rleCode times */
|
// get the next 4 bytes from the stream, treat them as palette indices, and output them rleCode times */
|
||||||
CHECK_STREAM_PTR(4);
|
CHECK_STREAM_PTR(4);
|
||||||
|
|
||||||
byte pi[16]; // 16 palette indices
|
byte pi[16]; // 16 palette indices
|
||||||
|
|
||||||
for (int8 i = numPixels - 1; i >= 0; i--) {
|
for (int8 i = numPixels - 1; i >= 0; i--) {
|
||||||
pi[numPixels - 1 - i] = (stream->readByte() >> ((i * bpp) & 0x07)) & ((1 << bpp) - 1);
|
pi[numPixels - 1 - i] = (stream->readByte() >> ((i * bpp) & 0x07)) & ((1 << bpp) - 1);
|
||||||
|
|
||||||
// FIXME: Is this right?
|
// FIXME: Is this right?
|
||||||
//stream_ptr += ((i & ((num_pixels>>2)-1)) == 0);
|
//stream_ptr += ((i & ((num_pixels>>2)-1)) == 0);
|
||||||
if ((i & ((numPixels >> 2) - 1)) == 0)
|
if ((i & ((numPixels >> 2) - 1)) == 0)
|
||||||
stream->readByte();
|
stream->readByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_PIXEL_PTR(rleCode * numPixels);
|
CHECK_PIXEL_PTR(rleCode * numPixels);
|
||||||
|
|
||||||
while (rleCode--)
|
while (rleCode--)
|
||||||
for (byte i = 0; i < numPixels; i++)
|
for (byte i = 0; i < numPixels; i++)
|
||||||
rgb[pixelPtr++] = pi[i];
|
rgb[pixelPtr++] = pi[i];
|
||||||
} else {
|
} else {
|
||||||
// copy the same pixel directly to output 4 times
|
// copy the same pixel directly to output 4 times
|
||||||
rleCode *= 4;
|
rleCode *= 4;
|
||||||
CHECK_STREAM_PTR(rleCode);
|
CHECK_STREAM_PTR(rleCode);
|
||||||
CHECK_PIXEL_PTR(rleCode * (numPixels >> 2));
|
CHECK_PIXEL_PTR(rleCode * (numPixels >> 2));
|
||||||
|
|
||||||
while (rleCode--) {
|
while (rleCode--) {
|
||||||
byte temp = stream->readByte();
|
byte temp = stream->readByte();
|
||||||
if (bpp == 4) {
|
if (bpp == 4) {
|
||||||
rgb[pixelPtr++] = (temp >> 4) & 0x0f;
|
rgb[pixelPtr++] = (temp >> 4) & 0x0f;
|
||||||
rgb[pixelPtr++] = temp & 0x0f;
|
rgb[pixelPtr++] = temp & 0x0f;
|
||||||
} else {
|
} else {
|
||||||
rgb[pixelPtr++] = (temp >> 6) & 0x03;
|
rgb[pixelPtr++] = (temp >> 6) & 0x03;
|
||||||
rgb[pixelPtr++] = (temp >> 4) & 0x03;
|
rgb[pixelPtr++] = (temp >> 4) & 0x03;
|
||||||
rgb[pixelPtr++] = (temp >> 2) & 0x03;
|
rgb[pixelPtr++] = (temp >> 2) & 0x03;
|
||||||
rgb[pixelPtr++] = temp & 0x03;
|
rgb[pixelPtr++] = temp & 0x03;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rowPtr += _surface->w;
|
rowPtr += _surface->w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTRLEDecoder::decode8(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
|
void QTRLEDecoder::decode8(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
|
||||||
uint32 pixelPtr = 0;
|
uint32 pixelPtr = 0;
|
||||||
byte *rgb = (byte *)_surface->pixels;
|
byte *rgb = (byte *)_surface->pixels;
|
||||||
|
|
||||||
while (linesToChange--) {
|
while (linesToChange--) {
|
||||||
CHECK_STREAM_PTR(2);
|
CHECK_STREAM_PTR(2);
|
||||||
pixelPtr = rowPtr + 4 * (stream->readByte() - 1);
|
pixelPtr = rowPtr + 4 * (stream->readByte() - 1);
|
||||||
|
|
||||||
|
for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) {
|
||||||
|
if (rleCode == 0) {
|
||||||
|
// there's another skip code in the stream
|
||||||
|
CHECK_STREAM_PTR(1);
|
||||||
|
pixelPtr += 4 * (stream->readByte() - 1);
|
||||||
|
} else if (rleCode < 0) {
|
||||||
|
// decode the run length code
|
||||||
|
rleCode = -rleCode;
|
||||||
|
|
||||||
|
// get the next 4 bytes from the stream, treat them as palette indices, and output them rleCode times
|
||||||
|
CHECK_STREAM_PTR(4);
|
||||||
|
|
||||||
for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) {
|
|
||||||
if (rleCode == 0) {
|
|
||||||
// there's another skip code in the stream
|
|
||||||
CHECK_STREAM_PTR(1);
|
|
||||||
pixelPtr += 4 * (stream->readByte() - 1);
|
|
||||||
} else if (rleCode < 0) {
|
|
||||||
// decode the run length code
|
|
||||||
rleCode = -rleCode;
|
|
||||||
|
|
||||||
// get the next 4 bytes from the stream, treat them as palette indices, and output them rleCode times
|
|
||||||
CHECK_STREAM_PTR(4);
|
|
||||||
|
|
||||||
byte pi[4]; // 4 palette indexes
|
byte pi[4]; // 4 palette indexes
|
||||||
|
|
||||||
for (byte i = 0; i < 4; i++)
|
for (byte i = 0; i < 4; i++)
|
||||||
pi[i] = stream->readByte();
|
pi[i] = stream->readByte();
|
||||||
|
|
||||||
CHECK_PIXEL_PTR(rleCode * 4);
|
CHECK_PIXEL_PTR(rleCode * 4);
|
||||||
|
|
||||||
while (rleCode--)
|
while (rleCode--)
|
||||||
for (byte i = 0; i < 4; i++)
|
for (byte i = 0; i < 4; i++)
|
||||||
rgb[pixelPtr++] = pi[i];
|
rgb[pixelPtr++] = pi[i];
|
||||||
} else {
|
} else {
|
||||||
// copy the same pixel directly to output 4 times
|
// copy the same pixel directly to output 4 times
|
||||||
rleCode *= 4;
|
rleCode *= 4;
|
||||||
CHECK_STREAM_PTR(rleCode);
|
CHECK_STREAM_PTR(rleCode);
|
||||||
CHECK_PIXEL_PTR(rleCode);
|
CHECK_PIXEL_PTR(rleCode);
|
||||||
|
|
||||||
while (rleCode--)
|
while (rleCode--)
|
||||||
rgb[pixelPtr++] = stream->readByte();
|
rgb[pixelPtr++] = stream->readByte();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rowPtr += _surface->w;
|
rowPtr += _surface->w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
|
void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
|
||||||
uint32 pixelPtr = 0;
|
uint32 pixelPtr = 0;
|
||||||
OverlayColor *rgb = (OverlayColor *)_surface->pixels;
|
OverlayColor *rgb = (OverlayColor *)_surface->pixels;
|
||||||
|
|
||||||
while (linesToChange--) {
|
while (linesToChange--) {
|
||||||
CHECK_STREAM_PTR(2);
|
CHECK_STREAM_PTR(2);
|
||||||
pixelPtr = rowPtr + stream->readByte() - 1;
|
pixelPtr = rowPtr + stream->readByte() - 1;
|
||||||
|
|
||||||
for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) {
|
for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) {
|
||||||
if (rleCode == 0) {
|
if (rleCode == 0) {
|
||||||
// there's another skip code in the stream
|
// there's another skip code in the stream
|
||||||
CHECK_STREAM_PTR(1);
|
CHECK_STREAM_PTR(1);
|
||||||
pixelPtr += stream->readByte() - 1;
|
pixelPtr += stream->readByte() - 1;
|
||||||
} else if (rleCode < 0) {
|
} else if (rleCode < 0) {
|
||||||
// decode the run length code
|
// decode the run length code
|
||||||
rleCode = -rleCode;
|
rleCode = -rleCode;
|
||||||
CHECK_STREAM_PTR(2);
|
CHECK_STREAM_PTR(2);
|
||||||
|
|
||||||
uint16 rgb16 = stream->readUint16BE();
|
|
||||||
|
|
||||||
CHECK_PIXEL_PTR(rleCode);
|
uint16 rgb16 = stream->readUint16BE();
|
||||||
|
|
||||||
while (rleCode--) {
|
CHECK_PIXEL_PTR(rleCode);
|
||||||
|
|
||||||
|
while (rleCode--) {
|
||||||
// Convert from RGB555 to the format specified by the Overlay
|
// Convert from RGB555 to the format specified by the Overlay
|
||||||
byte r = 0, g = 0, b = 0;
|
byte r = 0, g = 0, b = 0;
|
||||||
Graphics::colorToRGB<Graphics::ColorMasks<555> >(rgb16, r, g, b);
|
Graphics::colorToRGB<Graphics::ColorMasks<555> >(rgb16, r, g, b);
|
||||||
rgb[pixelPtr++] = _pixelFormat.RGBToColor(r, g, b);
|
rgb[pixelPtr++] = _pixelFormat.RGBToColor(r, g, b);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CHECK_STREAM_PTR(rleCode * 2);
|
CHECK_STREAM_PTR(rleCode * 2);
|
||||||
CHECK_PIXEL_PTR(rleCode);
|
CHECK_PIXEL_PTR(rleCode);
|
||||||
|
|
||||||
|
// copy pixels directly to output
|
||||||
|
while (rleCode--) {
|
||||||
|
uint16 rgb16 = stream->readUint16BE();
|
||||||
|
|
||||||
// copy pixels directly to output
|
|
||||||
while (rleCode--) {
|
|
||||||
uint16 rgb16 = stream->readUint16BE();
|
|
||||||
|
|
||||||
// Convert from RGB555 to the format specified by the Overlay
|
// Convert from RGB555 to the format specified by the Overlay
|
||||||
byte r = 0, g = 0, b = 0;
|
byte r = 0, g = 0, b = 0;
|
||||||
Graphics::colorToRGB<Graphics::ColorMasks<555> >(rgb16, r, g, b);
|
Graphics::colorToRGB<Graphics::ColorMasks<555> >(rgb16, r, g, b);
|
||||||
rgb[pixelPtr++] = _pixelFormat.RGBToColor(r, g, b);
|
rgb[pixelPtr++] = _pixelFormat.RGBToColor(r, g, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rowPtr += _surface->w;
|
rowPtr += _surface->w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTRLEDecoder::decode24(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
|
void QTRLEDecoder::decode24(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
|
||||||
uint32 pixelPtr = 0;
|
uint32 pixelPtr = 0;
|
||||||
OverlayColor *rgb = (OverlayColor *)_surface->pixels;
|
OverlayColor *rgb = (OverlayColor *)_surface->pixels;
|
||||||
|
|
||||||
while (linesToChange--) {
|
while (linesToChange--) {
|
||||||
CHECK_STREAM_PTR(2);
|
CHECK_STREAM_PTR(2);
|
||||||
pixelPtr = rowPtr + stream->readByte() - 1;
|
pixelPtr = rowPtr + stream->readByte() - 1;
|
||||||
|
|
||||||
for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) {
|
for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) {
|
||||||
if (rleCode == 0) {
|
if (rleCode == 0) {
|
||||||
// there's another skip code in the stream
|
// there's another skip code in the stream
|
||||||
CHECK_STREAM_PTR(1);
|
CHECK_STREAM_PTR(1);
|
||||||
pixelPtr += stream->readByte() - 1;
|
pixelPtr += stream->readByte() - 1;
|
||||||
} else if (rleCode < 0) {
|
} else if (rleCode < 0) {
|
||||||
// decode the run length code
|
// decode the run length code
|
||||||
rleCode = -rleCode;
|
rleCode = -rleCode;
|
||||||
|
|
||||||
CHECK_STREAM_PTR(3);
|
|
||||||
|
|
||||||
byte r = stream->readByte();
|
|
||||||
byte g = stream->readByte();
|
|
||||||
byte b = stream->readByte();
|
|
||||||
|
|
||||||
CHECK_PIXEL_PTR(rleCode);
|
CHECK_STREAM_PTR(3);
|
||||||
|
|
||||||
while (rleCode--)
|
byte r = stream->readByte();
|
||||||
|
byte g = stream->readByte();
|
||||||
|
byte b = stream->readByte();
|
||||||
|
|
||||||
|
CHECK_PIXEL_PTR(rleCode);
|
||||||
|
|
||||||
|
while (rleCode--)
|
||||||
rgb[pixelPtr++] = _pixelFormat.RGBToColor(r, g, b);
|
rgb[pixelPtr++] = _pixelFormat.RGBToColor(r, g, b);
|
||||||
} else {
|
} else {
|
||||||
CHECK_STREAM_PTR(rleCode * 3);
|
CHECK_STREAM_PTR(rleCode * 3);
|
||||||
CHECK_PIXEL_PTR(rleCode);
|
CHECK_PIXEL_PTR(rleCode);
|
||||||
|
|
||||||
// copy pixels directly to output
|
// copy pixels directly to output
|
||||||
while (rleCode--) {
|
while (rleCode--) {
|
||||||
byte r = stream->readByte();
|
byte r = stream->readByte();
|
||||||
byte g = stream->readByte();
|
byte g = stream->readByte();
|
||||||
byte b = stream->readByte();
|
byte b = stream->readByte();
|
||||||
rgb[pixelPtr++] = _pixelFormat.RGBToColor(r, g, b);
|
rgb[pixelPtr++] = _pixelFormat.RGBToColor(r, g, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rowPtr += _surface->w;
|
rowPtr += _surface->w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTRLEDecoder::decode32(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
|
void QTRLEDecoder::decode32(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
|
||||||
uint32 pixelPtr = 0;
|
uint32 pixelPtr = 0;
|
||||||
OverlayColor *rgb = (OverlayColor *)_surface->pixels;
|
OverlayColor *rgb = (OverlayColor *)_surface->pixels;
|
||||||
|
|
||||||
while (linesToChange--) {
|
while (linesToChange--) {
|
||||||
CHECK_STREAM_PTR(2);
|
CHECK_STREAM_PTR(2);
|
||||||
pixelPtr = rowPtr + stream->readByte() - 1;
|
pixelPtr = rowPtr + stream->readByte() - 1;
|
||||||
|
|
||||||
for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) {
|
for (int8 rleCode = stream->readSByte(); rleCode != -1; rleCode = stream->readSByte()) {
|
||||||
if (rleCode == 0) {
|
if (rleCode == 0) {
|
||||||
// there's another skip code in the stream
|
// there's another skip code in the stream
|
||||||
CHECK_STREAM_PTR(1);
|
CHECK_STREAM_PTR(1);
|
||||||
pixelPtr += stream->readByte() - 1;
|
pixelPtr += stream->readByte() - 1;
|
||||||
} else if (rleCode < 0) {
|
} else if (rleCode < 0) {
|
||||||
// decode the run length code
|
// decode the run length code
|
||||||
rleCode = -rleCode;
|
rleCode = -rleCode;
|
||||||
|
|
||||||
CHECK_STREAM_PTR(4);
|
|
||||||
|
|
||||||
byte a = stream->readByte();
|
|
||||||
byte r = stream->readByte();
|
|
||||||
byte g = stream->readByte();
|
|
||||||
byte b = stream->readByte();
|
|
||||||
|
|
||||||
CHECK_PIXEL_PTR(rleCode);
|
CHECK_STREAM_PTR(4);
|
||||||
|
|
||||||
while (rleCode--)
|
byte a = stream->readByte();
|
||||||
|
byte r = stream->readByte();
|
||||||
|
byte g = stream->readByte();
|
||||||
|
byte b = stream->readByte();
|
||||||
|
|
||||||
|
CHECK_PIXEL_PTR(rleCode);
|
||||||
|
|
||||||
|
while (rleCode--)
|
||||||
rgb[pixelPtr++] = _pixelFormat.ARGBToColor(a, r, g, b);
|
rgb[pixelPtr++] = _pixelFormat.ARGBToColor(a, r, g, b);
|
||||||
} else {
|
} else {
|
||||||
CHECK_STREAM_PTR(rleCode * 4);
|
CHECK_STREAM_PTR(rleCode * 4);
|
||||||
CHECK_PIXEL_PTR(rleCode);
|
CHECK_PIXEL_PTR(rleCode);
|
||||||
|
|
||||||
// copy pixels directly to output
|
// copy pixels directly to output
|
||||||
while (rleCode--) {
|
while (rleCode--) {
|
||||||
byte a = stream->readByte();
|
byte a = stream->readByte();
|
||||||
byte r = stream->readByte();
|
byte r = stream->readByte();
|
||||||
byte g = stream->readByte();
|
byte g = stream->readByte();
|
||||||
byte b = stream->readByte();
|
byte b = stream->readByte();
|
||||||
rgb[pixelPtr++] = _pixelFormat.ARGBToColor(a, r, g, b);
|
rgb[pixelPtr++] = _pixelFormat.ARGBToColor(a, r, g, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rowPtr += _surface->w;
|
rowPtr += _surface->w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics::Surface *QTRLEDecoder::decodeImage(Common::SeekableReadStream *stream) {
|
Graphics::Surface *QTRLEDecoder::decodeImage(Common::SeekableReadStream *stream) {
|
||||||
uint16 start_line = 0;
|
uint16 start_line = 0;
|
||||||
uint16 height = _surface->h;
|
uint16 height = _surface->h;
|
||||||
|
|
||||||
// check if this frame is even supposed to change
|
// check if this frame is even supposed to change
|
||||||
if (stream->size() < 8)
|
if (stream->size() < 8)
|
||||||
return _surface;
|
return _surface;
|
||||||
|
|
||||||
// start after the chunk size
|
// start after the chunk size
|
||||||
stream->readUint32BE();
|
stream->readUint32BE();
|
||||||
|
|
||||||
// fetch the header
|
// fetch the header
|
||||||
uint16 header = stream->readUint16BE();
|
uint16 header = stream->readUint16BE();
|
||||||
|
|
||||||
// if a header is present, fetch additional decoding parameters
|
// if a header is present, fetch additional decoding parameters
|
||||||
if (header & 8) {
|
if (header & 8) {
|
||||||
if(stream->size() < 14)
|
if(stream->size() < 14)
|
||||||
return _surface;
|
return _surface;
|
||||||
start_line = stream->readUint16BE();
|
start_line = stream->readUint16BE();
|
||||||
stream->readUint16BE(); // Unknown
|
stream->readUint16BE(); // Unknown
|
||||||
height = stream->readUint16BE();
|
height = stream->readUint16BE();
|
||||||
stream->readUint16BE(); // Unknown
|
stream->readUint16BE(); // Unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 row_ptr = _surface->w * start_line;
|
|
||||||
|
|
||||||
switch (_bitsPerPixel) {
|
uint32 row_ptr = _surface->w * start_line;
|
||||||
|
|
||||||
|
switch (_bitsPerPixel) {
|
||||||
case 1:
|
case 1:
|
||||||
case 33:
|
case 33:
|
||||||
decode1(stream, row_ptr, height);
|
decode1(stream, row_ptr, height);
|
||||||
@ -408,9 +408,9 @@ Graphics::Surface *QTRLEDecoder::decodeImage(Common::SeekableReadStream *stream)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error ("Unsupported bits per pixel %d", _bitsPerPixel);
|
error ("Unsupported bits per pixel %d", _bitsPerPixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _surface;
|
return _surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTRLEDecoder::~QTRLEDecoder() {
|
QTRLEDecoder::~QTRLEDecoder() {
|
||||||
|
@ -28,9 +28,9 @@
|
|||||||
|
|
||||||
#include "graphics/pixelformat.h"
|
#include "graphics/pixelformat.h"
|
||||||
#include "graphics/video/codecs/codec.h"
|
#include "graphics/video/codecs/codec.h"
|
||||||
|
|
||||||
namespace Mohawk {
|
namespace Mohawk {
|
||||||
|
|
||||||
class QTRLEDecoder : public Graphics::Codec {
|
class QTRLEDecoder : public Graphics::Codec {
|
||||||
public:
|
public:
|
||||||
QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel);
|
QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel);
|
||||||
|
@ -47,14 +47,14 @@ RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Graphics::Codec() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define ADVANCE_BLOCK() \
|
#define ADVANCE_BLOCK() \
|
||||||
pixelPtr += 4; \
|
pixelPtr += 4; \
|
||||||
if (pixelPtr >= _surface->w) { \
|
if (pixelPtr >= _surface->w) { \
|
||||||
pixelPtr = 0; \
|
pixelPtr = 0; \
|
||||||
rowPtr += _surface->w * 4; \
|
rowPtr += _surface->w * 4; \
|
||||||
} \
|
} \
|
||||||
totalBlocks--; \
|
totalBlocks--; \
|
||||||
if (totalBlocks < 0) \
|
if (totalBlocks < 0) \
|
||||||
error("block counter just went negative (this should not happen)") \
|
error("block counter just went negative (this should not happen)") \
|
||||||
|
|
||||||
// Convert from RGB555 to the format specified by the screen
|
// Convert from RGB555 to the format specified by the screen
|
||||||
#define PUT_PIXEL(color) \
|
#define PUT_PIXEL(color) \
|
||||||
@ -69,139 +69,139 @@ RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Graphics::Codec() {
|
|||||||
blockPtr++
|
blockPtr++
|
||||||
|
|
||||||
Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *stream) {
|
Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *stream) {
|
||||||
uint16 colorA = 0, colorB = 0;
|
uint16 colorA = 0, colorB = 0;
|
||||||
uint16 color4[4];
|
uint16 color4[4];
|
||||||
|
|
||||||
uint32 rowPtr = 0;
|
uint32 rowPtr = 0;
|
||||||
uint32 pixelPtr = 0;
|
uint32 pixelPtr = 0;
|
||||||
uint32 blockPtr = 0;
|
uint32 blockPtr = 0;
|
||||||
uint32 rowInc = _surface->w - 4;
|
uint32 rowInc = _surface->w - 4;
|
||||||
uint16 ta;
|
uint16 ta;
|
||||||
uint16 tb;
|
uint16 tb;
|
||||||
|
|
||||||
// First byte is always 0xe1. Warn if it's different
|
// First byte is always 0xe1. Warn if it's different
|
||||||
byte firstByte = stream->readByte();
|
byte firstByte = stream->readByte();
|
||||||
if (firstByte != 0xe1)
|
if (firstByte != 0xe1)
|
||||||
warning("First RPZA chunk byte is 0x%02x instead of 0xe1", firstByte);
|
warning("First RPZA chunk byte is 0x%02x instead of 0xe1", firstByte);
|
||||||
|
|
||||||
// Get chunk size, ingnoring first byte
|
// Get chunk size, ingnoring first byte
|
||||||
uint32 chunkSize = stream->readUint16BE() << 8;
|
uint32 chunkSize = stream->readUint16BE() << 8;
|
||||||
chunkSize += stream->readByte();
|
chunkSize += stream->readByte();
|
||||||
|
|
||||||
// If length mismatch use size from MOV file and try to decode anyway
|
// If length mismatch use size from MOV file and try to decode anyway
|
||||||
if (chunkSize != (uint32)stream->size()) {
|
if (chunkSize != (uint32)stream->size()) {
|
||||||
warning("MOV chunk size != encoded chunk size; using MOV chunk size");
|
warning("MOV chunk size != encoded chunk size; using MOV chunk size");
|
||||||
chunkSize = stream->size();
|
chunkSize = stream->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number of 4x4 blocks in frame
|
// Number of 4x4 blocks in frame
|
||||||
int32 totalBlocks = ((_surface->w + 3) / 4) * ((_surface->h + 3) / 4);
|
int32 totalBlocks = ((_surface->w + 3) / 4) * ((_surface->h + 3) / 4);
|
||||||
|
|
||||||
// Process chunk data
|
// Process chunk data
|
||||||
while ((uint32)stream->pos() < chunkSize) {
|
while ((uint32)stream->pos() < chunkSize) {
|
||||||
byte opcode = stream->readByte(); // Get opcode
|
byte opcode = stream->readByte(); // Get opcode
|
||||||
byte numBlocks = (opcode & 0x1f) + 1; // Extract block counter from opcode
|
byte numBlocks = (opcode & 0x1f) + 1; // Extract block counter from opcode
|
||||||
|
|
||||||
// If opcode MSbit is 0, we need more data to decide what to do
|
// If opcode MSbit is 0, we need more data to decide what to do
|
||||||
if ((opcode & 0x80) == 0) {
|
if ((opcode & 0x80) == 0) {
|
||||||
colorA = (opcode << 8) | stream->readByte();
|
colorA = (opcode << 8) | stream->readByte();
|
||||||
opcode = 0;
|
opcode = 0;
|
||||||
if (stream->readByte() & 0x80) {
|
if (stream->readByte() & 0x80) {
|
||||||
// Must behave as opcode 110xxxxx, using colorA computed
|
// Must behave as opcode 110xxxxx, using colorA computed
|
||||||
// above. Use fake opcode 0x20 to enter switch block at
|
// above. Use fake opcode 0x20 to enter switch block at
|
||||||
// the right place
|
// the right place
|
||||||
opcode = 0x20;
|
opcode = 0x20;
|
||||||
numBlocks = 1;
|
numBlocks = 1;
|
||||||
}
|
}
|
||||||
stream->seek(-1, SEEK_CUR);
|
stream->seek(-1, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (opcode & 0xe0) {
|
switch (opcode & 0xe0) {
|
||||||
case 0x80: // Skip blocks
|
case 0x80: // Skip blocks
|
||||||
while (numBlocks--) {
|
while (numBlocks--) {
|
||||||
ADVANCE_BLOCK();
|
ADVANCE_BLOCK();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0xa0: // Fill blocks with one color
|
case 0xa0: // Fill blocks with one color
|
||||||
colorA = stream->readUint16BE();
|
colorA = stream->readUint16BE();
|
||||||
while (numBlocks--) {
|
while (numBlocks--) {
|
||||||
blockPtr = rowPtr + pixelPtr;
|
blockPtr = rowPtr + pixelPtr;
|
||||||
for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
|
for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
|
||||||
for (byte pixel_x = 0; pixel_x < 4; pixel_x++) {
|
for (byte pixel_x = 0; pixel_x < 4; pixel_x++) {
|
||||||
PUT_PIXEL(colorA);
|
PUT_PIXEL(colorA);
|
||||||
}
|
}
|
||||||
blockPtr += rowInc;
|
blockPtr += rowInc;
|
||||||
}
|
}
|
||||||
ADVANCE_BLOCK();
|
ADVANCE_BLOCK();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Fill blocks with 4 colors
|
// Fill blocks with 4 colors
|
||||||
case 0xc0:
|
case 0xc0:
|
||||||
colorA = stream->readUint16BE();
|
colorA = stream->readUint16BE();
|
||||||
case 0x20:
|
case 0x20:
|
||||||
colorB = stream->readUint16BE();
|
colorB = stream->readUint16BE();
|
||||||
|
|
||||||
// Sort out the colors
|
// Sort out the colors
|
||||||
color4[0] = colorB;
|
color4[0] = colorB;
|
||||||
color4[1] = 0;
|
color4[1] = 0;
|
||||||
color4[2] = 0;
|
color4[2] = 0;
|
||||||
color4[3] = colorA;
|
color4[3] = colorA;
|
||||||
|
|
||||||
// Red components
|
// Red components
|
||||||
ta = (colorA >> 10) & 0x1F;
|
ta = (colorA >> 10) & 0x1F;
|
||||||
tb = (colorB >> 10) & 0x1F;
|
tb = (colorB >> 10) & 0x1F;
|
||||||
color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
|
color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
|
||||||
color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
|
color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
|
||||||
|
|
||||||
// Green components
|
// Green components
|
||||||
ta = (colorA >> 5) & 0x1F;
|
ta = (colorA >> 5) & 0x1F;
|
||||||
tb = (colorB >> 5) & 0x1F;
|
tb = (colorB >> 5) & 0x1F;
|
||||||
color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
|
color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
|
||||||
color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
|
color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
|
||||||
|
|
||||||
// Blue components
|
// Blue components
|
||||||
ta = colorA & 0x1F;
|
ta = colorA & 0x1F;
|
||||||
tb = colorB & 0x1F;
|
tb = colorB & 0x1F;
|
||||||
color4[1] |= ((11 * ta + 21 * tb) >> 5);
|
color4[1] |= ((11 * ta + 21 * tb) >> 5);
|
||||||
color4[2] |= ((21 * ta + 11 * tb) >> 5);
|
color4[2] |= ((21 * ta + 11 * tb) >> 5);
|
||||||
|
|
||||||
while (numBlocks--) {
|
while (numBlocks--) {
|
||||||
blockPtr = rowPtr + pixelPtr;
|
blockPtr = rowPtr + pixelPtr;
|
||||||
for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
|
for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
|
||||||
byte index = stream->readByte();
|
byte index = stream->readByte();
|
||||||
for (byte pixel_x = 0; pixel_x < 4; pixel_x++){
|
for (byte pixel_x = 0; pixel_x < 4; pixel_x++){
|
||||||
byte idx = (index >> (2 * (3 - pixel_x))) & 0x03;
|
byte idx = (index >> (2 * (3 - pixel_x))) & 0x03;
|
||||||
PUT_PIXEL(color4[idx]);
|
PUT_PIXEL(color4[idx]);
|
||||||
}
|
}
|
||||||
blockPtr += rowInc;
|
blockPtr += rowInc;
|
||||||
}
|
}
|
||||||
ADVANCE_BLOCK();
|
ADVANCE_BLOCK();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Fill block with 16 colors
|
// Fill block with 16 colors
|
||||||
case 0x00:
|
case 0x00:
|
||||||
blockPtr = rowPtr + pixelPtr;
|
blockPtr = rowPtr + pixelPtr;
|
||||||
for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
|
for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
|
||||||
for (byte pixel_x = 0; pixel_x < 4; pixel_x++){
|
for (byte pixel_x = 0; pixel_x < 4; pixel_x++){
|
||||||
// We already have color of upper left pixel
|
// We already have color of upper left pixel
|
||||||
if (pixel_y != 0 || pixel_x != 0)
|
if (pixel_y != 0 || pixel_x != 0)
|
||||||
colorA = stream->readUint16BE();
|
colorA = stream->readUint16BE();
|
||||||
|
|
||||||
PUT_PIXEL(colorA);
|
PUT_PIXEL(colorA);
|
||||||
}
|
}
|
||||||
blockPtr += rowInc;
|
blockPtr += rowInc;
|
||||||
}
|
}
|
||||||
ADVANCE_BLOCK();
|
ADVANCE_BLOCK();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Unknown opcode
|
// Unknown opcode
|
||||||
default:
|
default:
|
||||||
error("Unknown opcode %02x in rpza chunk", opcode);
|
error("Unknown opcode %02x in rpza chunk", opcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _surface;
|
return _surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,15 +22,15 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MOHAWK_RPZA_H
|
#ifndef MOHAWK_RPZA_H
|
||||||
#define MOHAWK_RPZA_H
|
#define MOHAWK_RPZA_H
|
||||||
|
|
||||||
#include "graphics/pixelformat.h"
|
#include "graphics/pixelformat.h"
|
||||||
#include "graphics/video/codecs/codec.h"
|
#include "graphics/video/codecs/codec.h"
|
||||||
|
|
||||||
namespace Mohawk {
|
namespace Mohawk {
|
||||||
|
|
||||||
class RPZADecoder : public Graphics::Codec {
|
class RPZADecoder : public Graphics::Codec {
|
||||||
public:
|
public:
|
||||||
RPZADecoder(uint16 width, uint16 height);
|
RPZADecoder(uint16 width, uint16 height);
|
||||||
|
@ -34,16 +34,16 @@ namespace Mohawk {
|
|||||||
|
|
||||||
#define ADVANCE_BLOCK() \
|
#define ADVANCE_BLOCK() \
|
||||||
{ \
|
{ \
|
||||||
pixelPtr += 4; \
|
pixelPtr += 4; \
|
||||||
if (pixelPtr >= _surface->w) { \
|
if (pixelPtr >= _surface->w) { \
|
||||||
pixelPtr = 0; \
|
pixelPtr = 0; \
|
||||||
rowPtr += _surface->w * 4; \
|
rowPtr += _surface->w * 4; \
|
||||||
} \
|
} \
|
||||||
totalBlocks--; \
|
totalBlocks--; \
|
||||||
if (totalBlocks < 0) { \
|
if (totalBlocks < 0) { \
|
||||||
warning("block counter just went negative (this should not happen)"); \
|
warning("block counter just went negative (this should not happen)"); \
|
||||||
return _surface; \
|
return _surface; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
SMCDecoder::SMCDecoder(uint16 width, uint16 height) {
|
SMCDecoder::SMCDecoder(uint16 width, uint16 height) {
|
||||||
@ -52,333 +52,333 @@ SMCDecoder::SMCDecoder(uint16 width, uint16 height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *stream) {
|
Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *stream) {
|
||||||
byte *pixels = (byte *)_surface->pixels;
|
byte *pixels = (byte *)_surface->pixels;
|
||||||
|
|
||||||
uint32 numBlocks = 0;
|
uint32 numBlocks = 0;
|
||||||
uint32 colorFlags = 0;
|
uint32 colorFlags = 0;
|
||||||
uint32 colorFlagsA = 0;
|
uint32 colorFlagsA = 0;
|
||||||
uint32 colorFlagsB = 0;
|
uint32 colorFlagsB = 0;
|
||||||
|
|
||||||
const uint16 rowInc = _surface->w - 4;
|
const uint16 rowInc = _surface->w - 4;
|
||||||
int32 rowPtr = 0;
|
int32 rowPtr = 0;
|
||||||
int32 pixelPtr = 0;
|
int32 pixelPtr = 0;
|
||||||
uint32 blockPtr = 0;
|
uint32 blockPtr = 0;
|
||||||
uint32 prevBlockPtr = 0;
|
uint32 prevBlockPtr = 0;
|
||||||
uint32 prevBlockPtr1 = 0, prevBlockPtr2 = 0;
|
uint32 prevBlockPtr1 = 0, prevBlockPtr2 = 0;
|
||||||
byte prevBlockFlag = false;
|
byte prevBlockFlag = false;
|
||||||
byte pixel = 0;
|
byte pixel = 0;
|
||||||
|
|
||||||
uint32 colorPairIndex = 0;
|
uint32 colorPairIndex = 0;
|
||||||
uint32 colorQuadIndex = 0;
|
uint32 colorQuadIndex = 0;
|
||||||
uint32 colorOctetIndex = 0;
|
uint32 colorOctetIndex = 0;
|
||||||
uint32 colorTableIndex = 0; // indices to color pair, quad, or octet tables
|
uint32 colorTableIndex = 0; // indices to color pair, quad, or octet tables
|
||||||
|
|
||||||
int32 chunkSize = stream->readUint32BE() & 0x00FFFFFF;
|
int32 chunkSize = stream->readUint32BE() & 0x00FFFFFF;
|
||||||
if (chunkSize != stream->size())
|
if (chunkSize != stream->size())
|
||||||
warning("MOV chunk size != SMC chunk size (%d != %d); ignoring SMC chunk size", chunkSize, stream->size());
|
warning("MOV chunk size != SMC chunk size (%d != %d); ignoring SMC chunk size", chunkSize, stream->size());
|
||||||
|
|
||||||
int32 totalBlocks = ((_surface->w + 3) / 4) * ((_surface->h + 3) / 4);
|
int32 totalBlocks = ((_surface->w + 3) / 4) * ((_surface->h + 3) / 4);
|
||||||
|
|
||||||
// traverse through the blocks
|
// traverse through the blocks
|
||||||
while (totalBlocks != 0) {
|
while (totalBlocks != 0) {
|
||||||
// sanity checks
|
// sanity checks
|
||||||
|
|
||||||
// make sure stream ptr hasn't gone out of bounds
|
// make sure stream ptr hasn't gone out of bounds
|
||||||
if (stream->pos() > stream->size()) {
|
if (stream->pos() > stream->size()) {
|
||||||
warning("SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)", stream->pos(), stream->size());
|
warning("SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)", stream->pos(), stream->size());
|
||||||
return _surface;
|
return _surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure the row pointer hasn't gone wild
|
// make sure the row pointer hasn't gone wild
|
||||||
if (rowPtr >= _surface->w * _surface->h) {
|
if (rowPtr >= _surface->w * _surface->h) {
|
||||||
warning("SMC decoder just went out of bounds (row ptr = %d, size = %d)", rowPtr, _surface->w * _surface->h);
|
warning("SMC decoder just went out of bounds (row ptr = %d, size = %d)", rowPtr, _surface->w * _surface->h);
|
||||||
return _surface;
|
return _surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte opcode = stream->readByte();
|
byte opcode = stream->readByte();
|
||||||
|
|
||||||
switch (opcode & 0xF0) {
|
switch (opcode & 0xF0) {
|
||||||
// skip n blocks
|
// skip n blocks
|
||||||
case 0x00:
|
case 0x00:
|
||||||
case 0x10:
|
case 0x10:
|
||||||
numBlocks = GET_BLOCK_COUNT();
|
numBlocks = GET_BLOCK_COUNT();
|
||||||
while (numBlocks--) {
|
while (numBlocks--) {
|
||||||
ADVANCE_BLOCK();
|
ADVANCE_BLOCK();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// repeat last block n times
|
// repeat last block n times
|
||||||
case 0x20:
|
case 0x20:
|
||||||
case 0x30:
|
case 0x30:
|
||||||
numBlocks = GET_BLOCK_COUNT();
|
numBlocks = GET_BLOCK_COUNT();
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if (rowPtr == 0 && pixelPtr == 0) {
|
if (rowPtr == 0 && pixelPtr == 0) {
|
||||||
warning("encountered repeat block opcode (%02X) but no blocks rendered yet", opcode & 0xF0);
|
warning("encountered repeat block opcode (%02X) but no blocks rendered yet", opcode & 0xF0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// figure out where the previous block started
|
// figure out where the previous block started
|
||||||
if (pixelPtr == 0)
|
if (pixelPtr == 0)
|
||||||
prevBlockPtr1 = (rowPtr - _surface->w * 4) + _surface->w - 4;
|
prevBlockPtr1 = (rowPtr - _surface->w * 4) + _surface->w - 4;
|
||||||
else
|
else
|
||||||
prevBlockPtr1 = rowPtr + pixelPtr - 4;
|
prevBlockPtr1 = rowPtr + pixelPtr - 4;
|
||||||
|
|
||||||
while (numBlocks--) {
|
while (numBlocks--) {
|
||||||
blockPtr = rowPtr + pixelPtr;
|
blockPtr = rowPtr + pixelPtr;
|
||||||
prevBlockPtr = prevBlockPtr1;
|
prevBlockPtr = prevBlockPtr1;
|
||||||
for (byte y = 0; y < 4; y++) {
|
for (byte y = 0; y < 4; y++) {
|
||||||
for (byte x = 0; x < 4; x++)
|
for (byte x = 0; x < 4; x++)
|
||||||
pixels[blockPtr++] = pixels[prevBlockPtr++];
|
pixels[blockPtr++] = pixels[prevBlockPtr++];
|
||||||
blockPtr += rowInc;
|
blockPtr += rowInc;
|
||||||
prevBlockPtr += rowInc;
|
prevBlockPtr += rowInc;
|
||||||
}
|
}
|
||||||
ADVANCE_BLOCK();
|
ADVANCE_BLOCK();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// repeat previous pair of blocks n times
|
// repeat previous pair of blocks n times
|
||||||
case 0x40:
|
case 0x40:
|
||||||
case 0x50:
|
case 0x50:
|
||||||
numBlocks = GET_BLOCK_COUNT();
|
numBlocks = GET_BLOCK_COUNT();
|
||||||
numBlocks *= 2;
|
numBlocks *= 2;
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if (rowPtr == 0 && pixelPtr < 2 * 4) {
|
if (rowPtr == 0 && pixelPtr < 2 * 4) {
|
||||||
warning("encountered repeat block opcode (%02X) but not enough blocks rendered yet", opcode & 0xF0);
|
warning("encountered repeat block opcode (%02X) but not enough blocks rendered yet", opcode & 0xF0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// figure out where the previous 2 blocks started
|
// figure out where the previous 2 blocks started
|
||||||
if (pixelPtr == 0)
|
if (pixelPtr == 0)
|
||||||
prevBlockPtr1 = (rowPtr - _surface->w * 4) + _surface->w - 4 * 2;
|
prevBlockPtr1 = (rowPtr - _surface->w * 4) + _surface->w - 4 * 2;
|
||||||
else if (pixelPtr == 4)
|
else if (pixelPtr == 4)
|
||||||
prevBlockPtr1 = (rowPtr - _surface->w * 4) + rowInc;
|
prevBlockPtr1 = (rowPtr - _surface->w * 4) + rowInc;
|
||||||
else
|
else
|
||||||
prevBlockPtr1 = rowPtr + pixelPtr - 4 * 2;
|
prevBlockPtr1 = rowPtr + pixelPtr - 4 * 2;
|
||||||
|
|
||||||
if (pixelPtr == 0)
|
if (pixelPtr == 0)
|
||||||
prevBlockPtr2 = (rowPtr - _surface->w * 4) + rowInc;
|
prevBlockPtr2 = (rowPtr - _surface->w * 4) + rowInc;
|
||||||
else
|
else
|
||||||
prevBlockPtr2 = rowPtr + pixelPtr - 4;
|
prevBlockPtr2 = rowPtr + pixelPtr - 4;
|
||||||
|
|
||||||
prevBlockFlag = 0;
|
prevBlockFlag = 0;
|
||||||
while (numBlocks--) {
|
while (numBlocks--) {
|
||||||
blockPtr = rowPtr + pixelPtr;
|
blockPtr = rowPtr + pixelPtr;
|
||||||
|
|
||||||
if (prevBlockFlag)
|
if (prevBlockFlag)
|
||||||
prevBlockPtr = prevBlockPtr2;
|
prevBlockPtr = prevBlockPtr2;
|
||||||
else
|
else
|
||||||
prevBlockPtr = prevBlockPtr1;
|
prevBlockPtr = prevBlockPtr1;
|
||||||
|
|
||||||
prevBlockFlag = !prevBlockFlag;
|
prevBlockFlag = !prevBlockFlag;
|
||||||
|
|
||||||
for (byte y = 0; y < 4; y++) {
|
for (byte y = 0; y < 4; y++) {
|
||||||
for (byte x = 0; x < 4; x++)
|
for (byte x = 0; x < 4; x++)
|
||||||
pixels[blockPtr++] = pixels[prevBlockPtr++];
|
pixels[blockPtr++] = pixels[prevBlockPtr++];
|
||||||
|
|
||||||
blockPtr += rowInc;
|
blockPtr += rowInc;
|
||||||
prevBlockPtr += rowInc;
|
prevBlockPtr += rowInc;
|
||||||
}
|
}
|
||||||
ADVANCE_BLOCK();
|
ADVANCE_BLOCK();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 1-color block encoding
|
// 1-color block encoding
|
||||||
case 0x60:
|
case 0x60:
|
||||||
case 0x70:
|
case 0x70:
|
||||||
numBlocks = GET_BLOCK_COUNT();
|
numBlocks = GET_BLOCK_COUNT();
|
||||||
pixel = stream->readByte();
|
pixel = stream->readByte();
|
||||||
|
|
||||||
while (numBlocks--) {
|
while (numBlocks--) {
|
||||||
blockPtr = rowPtr + pixelPtr;
|
blockPtr = rowPtr + pixelPtr;
|
||||||
for (byte y = 0; y < 4; y++) {
|
for (byte y = 0; y < 4; y++) {
|
||||||
for (byte x = 0; x < 4; x++)
|
for (byte x = 0; x < 4; x++)
|
||||||
pixels[blockPtr++] = pixel;
|
pixels[blockPtr++] = pixel;
|
||||||
|
|
||||||
blockPtr += rowInc;
|
blockPtr += rowInc;
|
||||||
}
|
}
|
||||||
ADVANCE_BLOCK();
|
ADVANCE_BLOCK();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 2-color block encoding
|
// 2-color block encoding
|
||||||
case 0x80:
|
case 0x80:
|
||||||
case 0x90:
|
case 0x90:
|
||||||
numBlocks = (opcode & 0x0F) + 1;
|
numBlocks = (opcode & 0x0F) + 1;
|
||||||
|
|
||||||
// figure out which color pair to use to paint the 2-color block
|
// figure out which color pair to use to paint the 2-color block
|
||||||
if ((opcode & 0xF0) == 0x80) {
|
if ((opcode & 0xF0) == 0x80) {
|
||||||
// fetch the next 2 colors from bytestream and store in next
|
// fetch the next 2 colors from bytestream and store in next
|
||||||
// available entry in the color pair table
|
// available entry in the color pair table
|
||||||
for (byte i = 0; i < CPAIR; i++) {
|
for (byte i = 0; i < CPAIR; i++) {
|
||||||
pixel = stream->readByte();
|
pixel = stream->readByte();
|
||||||
colorTableIndex = CPAIR * colorPairIndex + i;
|
colorTableIndex = CPAIR * colorPairIndex + i;
|
||||||
_colorPairs[colorTableIndex] = pixel;
|
_colorPairs[colorTableIndex] = pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is the base index to use for this block
|
// this is the base index to use for this block
|
||||||
colorTableIndex = CPAIR * colorPairIndex;
|
colorTableIndex = CPAIR * colorPairIndex;
|
||||||
colorPairIndex++;
|
colorPairIndex++;
|
||||||
|
|
||||||
// wraparound
|
// wraparound
|
||||||
if (colorPairIndex == COLORS_PER_TABLE)
|
if (colorPairIndex == COLORS_PER_TABLE)
|
||||||
colorPairIndex = 0;
|
colorPairIndex = 0;
|
||||||
} else
|
} else
|
||||||
colorTableIndex = CPAIR * stream->readByte();
|
colorTableIndex = CPAIR * stream->readByte();
|
||||||
|
|
||||||
while (numBlocks--) {
|
while (numBlocks--) {
|
||||||
colorFlags = stream->readUint16BE();
|
colorFlags = stream->readUint16BE();
|
||||||
uint16 flagMask = 0x8000;
|
uint16 flagMask = 0x8000;
|
||||||
blockPtr = rowPtr + pixelPtr;
|
blockPtr = rowPtr + pixelPtr;
|
||||||
for (byte y = 0; y < 4; y++) {
|
for (byte y = 0; y < 4; y++) {
|
||||||
for (byte x = 0; x < 4; x++) {
|
for (byte x = 0; x < 4; x++) {
|
||||||
if (colorFlags & flagMask)
|
if (colorFlags & flagMask)
|
||||||
pixel = colorTableIndex + 1;
|
pixel = colorTableIndex + 1;
|
||||||
else
|
else
|
||||||
pixel = colorTableIndex;
|
pixel = colorTableIndex;
|
||||||
|
|
||||||
flagMask >>= 1;
|
flagMask >>= 1;
|
||||||
pixels[blockPtr++] = _colorPairs[pixel];
|
pixels[blockPtr++] = _colorPairs[pixel];
|
||||||
}
|
}
|
||||||
|
|
||||||
blockPtr += rowInc;
|
blockPtr += rowInc;
|
||||||
}
|
}
|
||||||
ADVANCE_BLOCK();
|
ADVANCE_BLOCK();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 4-color block encoding
|
// 4-color block encoding
|
||||||
case 0xA0:
|
case 0xA0:
|
||||||
case 0xB0:
|
case 0xB0:
|
||||||
numBlocks = (opcode & 0x0F) + 1;
|
numBlocks = (opcode & 0x0F) + 1;
|
||||||
|
|
||||||
// figure out which color quad to use to paint the 4-color block
|
// figure out which color quad to use to paint the 4-color block
|
||||||
if ((opcode & 0xF0) == 0xA0) {
|
if ((opcode & 0xF0) == 0xA0) {
|
||||||
// fetch the next 4 colors from bytestream and store in next
|
// fetch the next 4 colors from bytestream and store in next
|
||||||
// available entry in the color quad table
|
// available entry in the color quad table
|
||||||
for (byte i = 0; i < CQUAD; i++) {
|
for (byte i = 0; i < CQUAD; i++) {
|
||||||
pixel = stream->readByte();
|
pixel = stream->readByte();
|
||||||
colorTableIndex = CQUAD * colorQuadIndex + i;
|
colorTableIndex = CQUAD * colorQuadIndex + i;
|
||||||
_colorQuads[colorTableIndex] = pixel;
|
_colorQuads[colorTableIndex] = pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is the base index to use for this block
|
// this is the base index to use for this block
|
||||||
colorTableIndex = CQUAD * colorQuadIndex;
|
colorTableIndex = CQUAD * colorQuadIndex;
|
||||||
colorQuadIndex++;
|
colorQuadIndex++;
|
||||||
|
|
||||||
// wraparound
|
// wraparound
|
||||||
if (colorQuadIndex == COLORS_PER_TABLE)
|
if (colorQuadIndex == COLORS_PER_TABLE)
|
||||||
colorQuadIndex = 0;
|
colorQuadIndex = 0;
|
||||||
} else
|
} else
|
||||||
colorTableIndex = CQUAD * stream->readByte();
|
colorTableIndex = CQUAD * stream->readByte();
|
||||||
|
|
||||||
while (numBlocks--) {
|
while (numBlocks--) {
|
||||||
colorFlags = stream->readUint32BE();
|
colorFlags = stream->readUint32BE();
|
||||||
|
|
||||||
// flag mask actually acts as a bit shift count here
|
// flag mask actually acts as a bit shift count here
|
||||||
byte flagMask = 30;
|
byte flagMask = 30;
|
||||||
blockPtr = rowPtr + pixelPtr;
|
blockPtr = rowPtr + pixelPtr;
|
||||||
|
|
||||||
for (byte y = 0; y < 4; y++) {
|
for (byte y = 0; y < 4; y++) {
|
||||||
for (byte x = 0; x < 4; x++) {
|
for (byte x = 0; x < 4; x++) {
|
||||||
pixel = colorTableIndex + ((colorFlags >> flagMask) & 0x03);
|
pixel = colorTableIndex + ((colorFlags >> flagMask) & 0x03);
|
||||||
flagMask -= 2;
|
flagMask -= 2;
|
||||||
pixels[blockPtr++] = _colorQuads[pixel];
|
pixels[blockPtr++] = _colorQuads[pixel];
|
||||||
}
|
}
|
||||||
blockPtr += rowInc;
|
blockPtr += rowInc;
|
||||||
}
|
}
|
||||||
ADVANCE_BLOCK();
|
ADVANCE_BLOCK();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 8-color block encoding
|
// 8-color block encoding
|
||||||
case 0xC0:
|
case 0xC0:
|
||||||
case 0xD0:
|
case 0xD0:
|
||||||
numBlocks = (opcode & 0x0F) + 1;
|
numBlocks = (opcode & 0x0F) + 1;
|
||||||
|
|
||||||
// figure out which color octet to use to paint the 8-color block
|
// figure out which color octet to use to paint the 8-color block
|
||||||
if ((opcode & 0xF0) == 0xC0) {
|
if ((opcode & 0xF0) == 0xC0) {
|
||||||
// fetch the next 8 colors from bytestream and store in next
|
// fetch the next 8 colors from bytestream and store in next
|
||||||
// available entry in the color octet table
|
// available entry in the color octet table
|
||||||
for (byte i = 0; i < COCTET; i++) {
|
for (byte i = 0; i < COCTET; i++) {
|
||||||
pixel = stream->readByte();
|
pixel = stream->readByte();
|
||||||
colorTableIndex = COCTET * colorOctetIndex + i;
|
colorTableIndex = COCTET * colorOctetIndex + i;
|
||||||
_colorOctets[colorTableIndex] = pixel;
|
_colorOctets[colorTableIndex] = pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is the base index to use for this block
|
// this is the base index to use for this block
|
||||||
colorTableIndex = COCTET * colorOctetIndex;
|
colorTableIndex = COCTET * colorOctetIndex;
|
||||||
colorOctetIndex++;
|
colorOctetIndex++;
|
||||||
|
|
||||||
// wraparound
|
// wraparound
|
||||||
if (colorOctetIndex == COLORS_PER_TABLE)
|
if (colorOctetIndex == COLORS_PER_TABLE)
|
||||||
colorOctetIndex = 0;
|
colorOctetIndex = 0;
|
||||||
} else
|
} else
|
||||||
colorTableIndex = COCTET * stream->readByte();
|
colorTableIndex = COCTET * stream->readByte();
|
||||||
|
|
||||||
while (numBlocks--) {
|
while (numBlocks--) {
|
||||||
/*
|
/*
|
||||||
For this input of 6 hex bytes:
|
For this input of 6 hex bytes:
|
||||||
01 23 45 67 89 AB
|
01 23 45 67 89 AB
|
||||||
Mangle it to this output:
|
Mangle it to this output:
|
||||||
flags_a = xx012456, flags_b = xx89A37B
|
flags_a = xx012456, flags_b = xx89A37B
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// build the color flags
|
// build the color flags
|
||||||
byte flagData[6];
|
byte flagData[6];
|
||||||
stream->read(flagData, 6);
|
stream->read(flagData, 6);
|
||||||
|
|
||||||
colorFlagsA = ((READ_BE_UINT16(flagData) & 0xFFF0) << 8) | (READ_BE_UINT16(flagData + 2) >> 4);
|
colorFlagsA = ((READ_BE_UINT16(flagData) & 0xFFF0) << 8) | (READ_BE_UINT16(flagData + 2) >> 4);
|
||||||
colorFlagsB = ((READ_BE_UINT16(flagData + 4) & 0xFFF0) << 8) | ((flagData[1] & 0xF) << 8) |
|
colorFlagsB = ((READ_BE_UINT16(flagData + 4) & 0xFFF0) << 8) | ((flagData[1] & 0xF) << 8) |
|
||||||
((flagData[3] & 0xF) << 4) | (flagData[5] & 0xf);
|
((flagData[3] & 0xF) << 4) | (flagData[5] & 0xf);
|
||||||
|
|
||||||
colorFlags = colorFlagsA;
|
colorFlags = colorFlagsA;
|
||||||
|
|
||||||
// flag mask actually acts as a bit shift count here
|
// flag mask actually acts as a bit shift count here
|
||||||
byte flagMask = 21;
|
byte flagMask = 21;
|
||||||
blockPtr = rowPtr + pixelPtr;
|
blockPtr = rowPtr + pixelPtr;
|
||||||
for (byte y = 0; y < 4; y++) {
|
for (byte y = 0; y < 4; y++) {
|
||||||
// reload flags at third row (iteration y == 2)
|
// reload flags at third row (iteration y == 2)
|
||||||
if (y == 2) {
|
if (y == 2) {
|
||||||
colorFlags = colorFlagsB;
|
colorFlags = colorFlagsB;
|
||||||
flagMask = 21;
|
flagMask = 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (byte x = 0; x < 4; x++) {
|
|
||||||
pixel = colorTableIndex + ((colorFlags >> flagMask) & 0x07);
|
|
||||||
flagMask -= 3;
|
|
||||||
pixels[blockPtr++] = _colorOctets[pixel];
|
|
||||||
}
|
|
||||||
|
|
||||||
blockPtr += rowInc;
|
for (byte x = 0; x < 4; x++) {
|
||||||
}
|
pixel = colorTableIndex + ((colorFlags >> flagMask) & 0x07);
|
||||||
ADVANCE_BLOCK();
|
flagMask -= 3;
|
||||||
}
|
pixels[blockPtr++] = _colorOctets[pixel];
|
||||||
break;
|
}
|
||||||
|
|
||||||
// 16-color block encoding (every pixel is a different color)
|
blockPtr += rowInc;
|
||||||
case 0xE0:
|
}
|
||||||
numBlocks = (opcode & 0x0F) + 1;
|
ADVANCE_BLOCK();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
while (numBlocks--) {
|
// 16-color block encoding (every pixel is a different color)
|
||||||
blockPtr = rowPtr + pixelPtr;
|
case 0xE0:
|
||||||
for (byte y = 0; y < 4; y++) {
|
numBlocks = (opcode & 0x0F) + 1;
|
||||||
for (byte x = 0; x < 4; x++)
|
|
||||||
pixels[blockPtr++] = stream->readByte();
|
|
||||||
|
|
||||||
blockPtr += rowInc;
|
while (numBlocks--) {
|
||||||
}
|
blockPtr = rowPtr + pixelPtr;
|
||||||
ADVANCE_BLOCK();
|
for (byte y = 0; y < 4; y++) {
|
||||||
}
|
for (byte x = 0; x < 4; x++)
|
||||||
break;
|
pixels[blockPtr++] = stream->readByte();
|
||||||
|
|
||||||
|
blockPtr += rowInc;
|
||||||
|
}
|
||||||
|
ADVANCE_BLOCK();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xF0:
|
||||||
|
warning("0xF0 opcode seen in SMC chunk (contact the developers)");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 0xF0:
|
|
||||||
warning("0xF0 opcode seen in SMC chunk (contact the developers)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _surface;
|
return _surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MOHAWK_VIDEO_SMC_H
|
#ifndef MOHAWK_VIDEO_SMC_H
|
||||||
#define MOHAWK_VIDEO_SMC_H
|
#define MOHAWK_VIDEO_SMC_H
|
||||||
|
|
||||||
#include "graphics/video/codecs/codec.h"
|
#include "graphics/video/codecs/codec.h"
|
||||||
|
|
||||||
namespace Mohawk {
|
namespace Mohawk {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -36,7 +36,7 @@ enum {
|
|||||||
COCTET = 8,
|
COCTET = 8,
|
||||||
COLORS_PER_TABLE = 256
|
COLORS_PER_TABLE = 256
|
||||||
};
|
};
|
||||||
|
|
||||||
class SMCDecoder : public Graphics::Codec {
|
class SMCDecoder : public Graphics::Codec {
|
||||||
public:
|
public:
|
||||||
SMCDecoder(uint16 width, uint16 height);
|
SMCDecoder(uint16 width, uint16 height);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user