diff --git a/src/coding/coding.h b/src/coding/coding.h index 7b68f745..b1440626 100644 --- a/src/coding/coding.h +++ b/src/coding/coding.h @@ -259,10 +259,10 @@ long mpeg_bytes_to_samples(long bytes, const mpeg_codec_data *data); #ifdef VGM_USE_G7221 /* g7221_decoder */ -g7221_codec_data *init_g7221(int channel_count, int frame_size); -void decode_g7221(VGMSTREAM *vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel); -void reset_g7221(VGMSTREAM *vgmstream); -void free_g7221(VGMSTREAM *vgmstream); +g7221_codec_data* init_g7221(int channel_count, int frame_size); +void decode_g7221(VGMSTREAM* vgmstream, sample_t* outbuf, int channelspacing, int32_t samples_to_do, int channel); +void reset_g7221(g7221_codec_data* data); +void free_g7221(g7221_codec_data* data); #endif #ifdef VGM_USE_G719 diff --git a/src/coding/g7221_decoder.c b/src/coding/g7221_decoder.c index 4c08d0cf..a0c3e96b 100644 --- a/src/coding/g7221_decoder.c +++ b/src/coding/g7221_decoder.c @@ -2,54 +2,59 @@ #include "g7221_decoder_lib.h" #ifdef VGM_USE_G7221 -#define G7221_MAX_FRAME_SIZE 0x78 /* max frame 0x78 uint8s = 960/8 */ +#define G7221_MAX_FRAME_SIZE 0x78 /* 960/8 */ +#define G7221_MAX_FRAME_SAMPLES 640 /* 32000/50 */ struct g7221_codec_data { - sample_t buffer[640]; - g7221_handle *handle; + int channels; + int frame_size; + struct g7221_channel_data { + sample_t buffer[G7221_MAX_FRAME_SAMPLES]; + g7221_handle* handle; + } *ch; }; -g7221_codec_data* init_g7221(int channel_count, int frame_size) { +g7221_codec_data* init_g7221(int channels, int frame_size) { int i; g7221_codec_data* data = NULL; if (frame_size > G7221_MAX_FRAME_SIZE) goto fail; - data = calloc(channel_count, sizeof(g7221_codec_data)); /* one decoder per channel */ + data = calloc(1, sizeof(g7221_codec_data)); if (!data) goto fail; - for (i = 0; i < channel_count; i++) { - data[i].handle = g7221_init(frame_size, 14000); /* Siren 14 == 14khz bandwidth */ - if (!data[i].handle) goto fail; + data->channels = channels; + data->frame_size = frame_size; + + data->ch = calloc(channels, sizeof(struct g7221_channel_data)); + if (!data->ch) goto fail; + + for (i = 0; i < data->channels; i++) { + data->ch[i].handle = g7221_init(frame_size); + if (!data->ch[i].handle) goto fail; } return data; fail: - if (data) { - for (i = 0; i < channel_count; i++) { - g7221_free(data[i].handle); - } - } - free(data); - + free_g7221(data); return NULL; } -void decode_g7221(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel) { - VGMSTREAMCHANNEL *ch = &vgmstream->ch[channel]; - g7221_codec_data *data = vgmstream->codec_data; - g7221_codec_data *ch_data = &data[channel]; +void decode_g7221(VGMSTREAM* vgmstream, sample_t* outbuf, int channelspacing, int32_t samples_to_do, int channel) { + VGMSTREAMCHANNEL* ch = &vgmstream->ch[channel]; + g7221_codec_data* data = vgmstream->codec_data; + struct g7221_channel_data* ch_data = &data->ch[channel]; int i; if (0 == vgmstream->samples_into_block) { uint8_t buf[G7221_MAX_FRAME_SIZE]; size_t bytes; - size_t read = vgmstream->interleave_block_size; + size_t read = data->frame_size; - bytes = vgmstream->ch[channel].streamfile->read(ch->streamfile, buf, ch->offset, read); + bytes = read_streamfile(buf, ch->offset, read, ch->streamfile); if (bytes != read) { //g7221_decode_empty(ch_data->handle, ch_data->buffer); memset(ch_data->buffer, 0, sizeof(ch_data->buffer)); @@ -66,24 +71,23 @@ void decode_g7221(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, in } -void reset_g7221(VGMSTREAM *vgmstream) { - g7221_codec_data *data = vgmstream->codec_data; +void reset_g7221(g7221_codec_data* data) { int i; if (!data) return; - for (i = 0; i < vgmstream->channels; i++) { - g7221_reset(data[i].handle); + for (i = 0; i < data->channels; i++) { + g7221_reset(data->ch[i].handle); } } -void free_g7221(VGMSTREAM *vgmstream) { - g7221_codec_data *data = (g7221_codec_data *) vgmstream->codec_data; +void free_g7221(g7221_codec_data* data) { int i; if (!data) return; - for (i = 0; i < vgmstream->channels; i++) { - g7221_free(data[i].handle); + for (i = 0; i < data->channels; i++) { + g7221_free(data->ch[i].handle); } + free(data->ch); free(data); } diff --git a/src/coding/g7221_decoder_lib.c b/src/coding/g7221_decoder_lib.c index c6400f3b..96fbfabc 100644 --- a/src/coding/g7221_decoder_lib.c +++ b/src/coding/g7221_decoder_lib.c @@ -35,7 +35,7 @@ * - very minor change in bit unpacking (minor output diffs) * - modified DCT-IV optimizations, scaling and window functions (minor output diffs) * - internally PCM16 bufs, but converts to float (sample/32768.0) afterwards if the platform needs it - * - less error control + * - less error control (on error decoder is supposed to repeat last coefs) * - can't decode Siren7, and given output diffs it's not actually ITU-compliant * - minor optimizations here and there but otherwise very similar * This decoder generally uses Polycom's terminology, and while some parts like the bitreader could be @@ -93,13 +93,14 @@ static int imlt_window(int16_t* new_samples, int16_t* old_samples, int16_t* out_ old_ptr = old_samples + 0; new_ptr = new_samples + 320; - for (i = 320; i > 0; --i) { - *old_ptr++ = *new_ptr++; + for (i = 0; i < 320; i++) { + old_ptr[i] = new_ptr[i]; } return 0; } +/* "dct4_x640_int" */ static int imlt_dct4(int16_t* mlt_coefs, int16_t* new_samples, int mag_shift) { int i, j, k, n; const uint8_t *set1_ptr; @@ -186,55 +187,55 @@ static int imlt_dct4(int16_t* mlt_coefs, int16_t* new_samples, int mag_shift) { { int cos_val, sin_val; const uint16_t *cos_ptr, *sin_ptr, *cos_ptr_lo, *sin_ptr_lo; - int16_t C_in_val_lo, C_in_val_hi, C_in_val_mlo, C_in_val_mhi; - int16_t *C_in_ptr, *C_in_ptr_lo, *C_in_ptr_hi, *C_in_ptr_mlo, *C_in_ptr_mhi; + int16_t mlt_val_lo, mlt_val_hi, mlt_val_mlo, mlt_val_mhi; + int16_t *mlt_ptr, *mlt_ptr_lo, *mlt_ptr_hi, *mlt_ptr_mlo, *mlt_ptr_mhi; cos_ptr = &imlt_cos_tables[320+160]; /* cos_table_16 > 8 > 4 > 2 */ sin_ptr = &imlt_sin_tables[320+160]; /* sin_table_16 > 8 > 4 > 2 */ for (n = 160; n >= 20; n /= 2) { - C_in_ptr = mlt_coefs + 0; - while (C_in_ptr < mlt_coefs + 640) { + mlt_ptr = mlt_coefs + 0; + while (mlt_ptr < mlt_coefs + 640) { for (j = *set1_ptr; j > 0; --j) { - C_in_ptr_lo = C_in_ptr + 0; - C_in_ptr_hi = C_in_ptr + n; - C_in_ptr_mlo = C_in_ptr + (n / 2); - C_in_ptr_mhi = C_in_ptr + (n / 2); + mlt_ptr_lo = mlt_ptr + 0; + mlt_ptr_hi = mlt_ptr + n; + mlt_ptr_mlo = mlt_ptr + (n / 2); + mlt_ptr_mhi = mlt_ptr + (n / 2); for (k = n / 4; k > 0; --k) { - C_in_val_lo = *C_in_ptr_lo; - C_in_val_hi = *--C_in_ptr_hi; - C_in_val_mhi = *--C_in_ptr_mhi; - C_in_val_mlo = *C_in_ptr_mlo; - *C_in_ptr_lo++ = C_in_val_lo + C_in_val_hi; - *C_in_ptr_mlo++ = C_in_val_lo - C_in_val_hi; - *C_in_ptr_mhi = C_in_val_mlo + C_in_val_mhi; - *C_in_ptr_hi = C_in_val_mhi - C_in_val_mlo; + mlt_val_lo = *mlt_ptr_lo; + mlt_val_hi = *--mlt_ptr_hi; + mlt_val_mhi = *--mlt_ptr_mhi; + mlt_val_mlo = *mlt_ptr_mlo; + *mlt_ptr_lo++ = mlt_val_lo + mlt_val_hi; + *mlt_ptr_mlo++ = mlt_val_lo - mlt_val_hi; + *mlt_ptr_mhi = mlt_val_mlo + mlt_val_mhi; + *mlt_ptr_hi = mlt_val_mhi - mlt_val_mlo; } - C_in_ptr += n; + mlt_ptr += n; } set1_ptr++; for (j = *set1_ptr; j > 0; --j) { - C_in_ptr_lo = C_in_ptr + 0; - C_in_ptr_hi = C_in_ptr + n; + mlt_ptr_lo = mlt_ptr + 0; + mlt_ptr_hi = mlt_ptr + n; cos_ptr_lo = cos_ptr + 0; sin_ptr_lo = sin_ptr + 0; for (k = n / 4; k > 0; --k) { cos_val = *cos_ptr_lo++; sin_val = *sin_ptr_lo++; - C_in_val_lo = *C_in_ptr_lo; - C_in_val_hi = *--C_in_ptr_hi; - *C_in_ptr_lo++ = (cos_val * C_in_val_lo + sin_val * C_in_val_hi + 32768) >> 16; - *C_in_ptr_hi = (sin_val * -C_in_val_lo + cos_val * C_in_val_hi + 32768) >> 16; + mlt_val_lo = *mlt_ptr_lo; + mlt_val_hi = *--mlt_ptr_hi; + *mlt_ptr_lo++ = (cos_val * mlt_val_lo + sin_val * mlt_val_hi + 32768) >> 16; + *mlt_ptr_hi = (sin_val * -mlt_val_lo + cos_val * mlt_val_hi + 32768) >> 16; cos_val = *cos_ptr_lo++; sin_val = *sin_ptr_lo++; - C_in_val_lo = *C_in_ptr_lo; - C_in_val_hi = *--C_in_ptr_hi; - *C_in_ptr_lo++ = (cos_val * C_in_val_lo + sin_val * C_in_val_hi + 32768) >> 16; - *C_in_ptr_hi = (sin_val * C_in_val_lo - cos_val * C_in_val_hi + 32768) >> 16; + mlt_val_lo = *mlt_ptr_lo; + mlt_val_hi = *--mlt_ptr_hi; + *mlt_ptr_lo++ = (cos_val * mlt_val_lo + sin_val * mlt_val_hi + 32768) >> 16; + *mlt_ptr_hi = (sin_val * mlt_val_lo - cos_val * mlt_val_hi + 32768) >> 16; } - C_in_ptr += n; + mlt_ptr += n; } set1_ptr++; } @@ -408,7 +409,7 @@ static int imlt_dct4(int16_t* mlt_coefs, int16_t* new_samples, int mag_shift) { new_ptr += 10; } - /* below is some three way swapping tmp ptrs change between mlt<>new */ + /* below is some three way swapping, tmp ptrs change between mlt<>new */ tmp0_ptr = mlt_coefs + 640; tmp1_ptr = new_samples + 640; for (n = 20; n <= 160; n *= 2) { @@ -532,20 +533,20 @@ static int imlt_dct4(int16_t* mlt_coefs, int16_t* new_samples, int mag_shift) { return 0; } -/* transform frequency domain MLT spectrum coefs to time domain PCM samples with reverse/inverse MLT */ +/* "inverse_MLT" */ static int rmlt_coefs_to_samples(int mag_shift, int16_t* mlt_coefs, int16_t* old_samples, int16_t* out_samples /*, int p_samples_done*/) { int res; int16_t new_samples[640]; - /* block transform coefs-to-samples using DCT-IV (inverse) */ + /* block transform MLT spectrum coefs to time domain PCM samples using DCT-IV (inverse) */ res = imlt_dct4(mlt_coefs, new_samples, mag_shift); - if (res) return res; + if (res < 0) return res; /* apply IMLT overlapped window filter function (640 samples) */ res = imlt_window(new_samples, old_samples, out_samples); - if (res) return res; + if (res < 0) return res; - //*p_samples_done = 640;/* in Namco's code but actually ignored */ + //*p_samples_done = 640; /* in Namco's code but actually ignored */ return 0; } @@ -802,7 +803,7 @@ static inline void index_to_array(int index, int* array_cv, int category) { } } -static int decode_vector_quantized_mlt_indices(uint32_t* data_u32, int bitpos, int bit_count, uint32_t* p_random_value, int* decoder_region_standard_deviation, int* power_categories, int16_t* mlt_coefs) { +static int decode_vector_quantized_mlt_indices(uint32_t* data_u32, int* p_bitpos, int bit_count, uint32_t* p_random_value, int* decoder_region_standard_deviation, int* power_categories, int16_t* mlt_coefs) { int16_t standard_deviation; int array_cv[MAX_VECTOR_DIMENSION]; int i, v, region, category, index; @@ -810,8 +811,8 @@ static int decode_vector_quantized_mlt_indices(uint32_t* data_u32, int bitpos, i uint32_t* ptr_u32; /* bitreading setup */ - ptr_u32 = &data_u32[(bitpos >> 5)]; - bitmask = 1 << (31 - (bitpos & 0x1F)); + ptr_u32 = &data_u32[(*p_bitpos >> 5)]; + bitmask = 1 << (31 - (*p_bitpos & 0x1F)); cur_u32 = *ptr_u32; ptr_u32++; @@ -832,6 +833,7 @@ static int decode_vector_quantized_mlt_indices(uint32_t* data_u32, int bitpos, i do { int bit = (bitmask & cur_u32) != 0; bitmask >>= 1; + (*p_bitpos)++; if (bitmask == 0) { bitmask = 0x80000000; cur_u32 = *ptr_u32; @@ -872,6 +874,7 @@ static int decode_vector_quantized_mlt_indices(uint32_t* data_u32, int bitpos, i negative = (bitmask & cur_u32) != 0; bitmask >>= 1; + (*p_bitpos)++; if (bitmask == 0) { bitmask = 0x80000000; cur_u32 = *ptr_u32; @@ -1015,7 +1018,7 @@ static int unpack_frame(int bit_rate, const uint8_t* data, int frame_size, /*int res = categorize( 8 * expected_frame_size - bitpos, absolute_region_power_index, power_categories, category_balances); - if (res) return res; + if (res < 0) return res; /* adjust power categories (rate_adjust_categories) */ { @@ -1060,16 +1063,44 @@ static int unpack_frame(int bit_rate, const uint8_t* data, int frame_size, /*int /* decode the quantized bits into MLT coefs */ res = decode_vector_quantized_mlt_indices( - data_u32, bitpos, 8 * expected_frame_size, + data_u32, &bitpos, 8 * expected_frame_size, p_random_value, decoder_region_standard_deviation, power_categories, mlt_coefs); - if (res) return res; + if (res < 0) return res; + + + /* test for errors (in refdec but not Namco's, useful to detect decryption) */ + { + int bits_left = 8 * expected_frame_size - bitpos; + int i; + + if (bits_left > 0) { + /* frame must be padded with 1s */ + for (i = 0; i < bits_left; i++) { + int bit = (data_u32[bitpos >> 5] >> (31 - (bitpos & 0x1F))) & 1; + bitpos++; + + if (bit == 0) + return -1; + } + } + else { + /* ? */ + if (categorization_control < NUM_CATEGORIZATION_CONTROL_BITS - 1 && bits_left < 0) + return -2; + } + + for (i = 0; i < NUMBER_OF_REGIONS; i++) { + if ((absolute_region_power_index[i] + ESF_ADJUSTMENT_TO_RMS_INDEX > 31) || + (absolute_region_power_index[i] + ESF_ADJUSTMENT_TO_RMS_INDEX < -8)) + return -4; + } + } return 0; } - /***************************************************************************** * API *****************************************************************************/ @@ -1084,7 +1115,7 @@ struct g7221_handle { uint32_t random_value; }; -g7221_handle* g7221_init(int bytes_per_frame, int flags) { +g7221_handle* g7221_init(int bytes_per_frame) { g7221_handle* handle = NULL; int bit_rate; @@ -1093,9 +1124,6 @@ g7221_handle* g7221_init(int bytes_per_frame, int flags) { if (bit_rate != 24000 && bit_rate != 32000 && bit_rate != 48000) goto fail; - //if (flags != 0) - // goto fail; - handle = calloc(1, sizeof(g7221_handle)); if (!handle) goto fail; @@ -1111,7 +1139,7 @@ fail: } -void g7221_decode_frame(g7221_handle* handle, uint8_t* data, int16_t* out_samples) { +int g7221_decode_frame(g7221_handle* handle, uint8_t* data, int16_t* out_samples) { int res; int mag_shift; @@ -1124,28 +1152,28 @@ void g7221_decode_frame(g7221_handle* handle, uint8_t* data, int16_t* out_sample } #endif - /* Namco's decoder is designed so that out_samples can be used in place of mlt_coefs, + /* Namco's decoder is designed so that out_samples can be set in place of mlt_coefs, * so we could avoid one extra buffer, but for clarity we'll leave as is */ /* unpack data into MLT spectrum coefs */ res = unpack_frame(handle->bit_rate, data, handle->frame_size, &mag_shift, handle->mlt_coefs, &handle->random_value); - if (res) goto fail; + if (res < 0) goto fail; /* convert coefs to samples using reverse (inverse) MLT */ res = rmlt_coefs_to_samples(mag_shift, handle->mlt_coefs, handle->old_samples, out_samples); - if (res) goto fail; + if (res < 0) goto fail; - /* Namco also gets number of codes/samples done from unpack_frame/rmlt (ptr arg), + /* Namco also sets number of codes/samples done from unpack_frame/rmlt (ptr arg), * but they seem unused */ - //todo return values - return; + return 1; fail: - return; + //;printf("S14: fail %i\n", res); + return 0; } #if 0 -void g7221_decode_empty(g7221_handle* handle, int16_t* out_samples) { +int g7221_decode_empty(g7221_handle* handle, int16_t* out_samples) { static const uint8_t empty_frame[0x3c] = { 0x1E,0x0B,0x89,0x40,0x02,0x4F,0x51,0x35, 0x10,0xA1,0xFE,0xDF,0x52,0x51,0x10,0x0B, 0xF0,0x69,0x7B,0xAE,0x18,0x17,0x00,0x52, 0x07,0x74,0xF4,0x65,0xA2,0x58,0xD8,0x3F, @@ -1155,8 +1183,8 @@ void g7221_decode_empty(g7221_handle* handle, int16_t* out_samples) { int res; int mag_shift; - /* This only seems to exist in older exes. Namco's samples don't seem to reach EOF, - * so this wouldn't need to be called. Doesn't seem to use encoder delay either. */ + /* This only seems to exist in older exes. Namco's samples don't reach EOF, so this + * wouldn't need to be called. Doesn't seem to use encoder delay either. */ res = unpack_frame(24000, empty_frame, 0x3c, &mag_shift, handle->mlt_coefs, &handle->random_value); if (res) goto fail; @@ -1165,9 +1193,9 @@ void g7221_decode_empty(g7221_handle* handle, int16_t* out_samples) { res = rmlt_coefs_to_samples(mag_shift, handle->mlt_coefs, handle->old_samples, out_samples); if (res) goto fail; - return; + return 1; fail: - return; + return 0; } #endif @@ -1183,6 +1211,9 @@ void g7221_reset(g7221_handle* handle) { * bnsf playing at the same time would get slightly different results */ } -void g7221_free(g7221_handle *handle) { +void g7221_free(g7221_handle* handle) { + if (!handle) + return; + free(handle); } diff --git a/src/coding/g7221_decoder_lib.h b/src/coding/g7221_decoder_lib.h index ccbacf5e..461a4810 100644 --- a/src/coding/g7221_decoder_lib.h +++ b/src/coding/g7221_decoder_lib.h @@ -10,14 +10,14 @@ typedef struct g7221_handle g7221_handle; /* return a handle for decoding on successful init, NULL on failure */ -g7221_handle* g7221_init(int bytes_per_frame, int flags); +g7221_handle* g7221_init(int bytes_per_frame); /* decode a frame, at code_words, into 16-bit PCM in sample_buffer */ -void g7221_decode_frame(g7221_handle* handle, uint8_t* data, int16_t* out_samples); +int g7221_decode_frame(g7221_handle* handle, uint8_t* data, int16_t* out_samples); #if 0 /* decodes an empty frame after no more data is found (may be used to "drain" window samples */ -void g7221_decode_empty(g7221_handle* handle, int16_t* out_samples); +int g7221_decode_empty(g7221_handle* handle, int16_t* out_samples); #endif /* reset the decoder to its initial state */ diff --git a/src/coding/g7221_decoder_lib_data.h b/src/coding/g7221_decoder_lib_data.h index 5bb60dbe..eace8184 100644 --- a/src/coding/g7221_decoder_lib_data.h +++ b/src/coding/g7221_decoder_lib_data.h @@ -17,7 +17,7 @@ * for (i = 0; i < 640; i++) * window[i] = floor(sin((PI/2.0) * (i + 0.5) / 640) * 32767.0) * while the original int refdec table uses an altered formula? (smaller values) */ -static const int16_t imlt_samples_window[MAX_DCT_LENGTH] = { +static const int16_t imlt_samples_window[MAX_DCT_LENGTH] = { /* "Out_Window"? */ 40, 120, 201, 281, 361, 442, 522, 603, 683, 763, 844, 924, 1005, 1085, 1165, 1246, 1326, 1406, 1487, 1567, 1647, 1728, 1808, 1888, 1969, 2049, 2129, 2209, 2290, 2370, @@ -204,7 +204,7 @@ static const uint16_t imlt_cos_tables[636] = { }; /* see cos table info */ -static const uint16_t imlt_sin_tables[636] = { +static const uint16_t imlt_sin_tables[636] = { /* "sin_table" */ /* imlt_sin_table_64[320] (640/2) */ 80, 241, 402, 562, 723, 884, 1045, 1206, 1367, 1527, 1688, 1849, 2010, 2171, 2331, 2492, @@ -326,7 +326,7 @@ static const uint16_t imlt_sin_tables[636] = { /* vs refdec: has region 0 (unused, all 0s) and regions>13 (repeats of region 13) so they were removed. * 2nd index only went to DIFF_REGION_POWER_LEVELS-1 and last was added (all 0s though so probably unused). */ -static const int16_t differential_region_power_decoder_tree[NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS][2] = { +static const int16_t differential_region_power_decoder_tree[NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS][2] = { /* "rms_table"? */ {{ 1, 2},{ 3, 4},{ 5, 6},{ 7, 8},{ 9, 10},{ 11,-12},{-11,-10},{ -8, -9},{ -7, -6},{-13, 12},{ -5, -4},{ 0, 13},{ -3,-14},{ -2, 14},{ -1, 15},{-15, 16},{-16, 17},{-17, 18},{ 19, 20},{ 21, 22},{-18,-19},{-20,-21},{-22,-23},{ 0, 0}}, {{ 1, 2},{ 3, 4},{ 5, 6},{ 7, 8},{-10, -9},{ -8,-11},{ -7, -6},{ 9, -5},{ 10,-12},{ -4, 11},{-13, -3},{ 12, -2},{ 13,-14},{ -1, 14},{ 15,-15},{ 0, 16},{-16, 17},{-17, 18},{-18, 19},{ 20, 21},{ 22,-19},{-20,-21},{-22,-23},{ 0, 0}}, {{ 1, 2},{ 3, 4},{ 5, 6},{ 7, 8},{ 9, 10},{-12, 11},{-11,-13},{-10, -9},{ 12,-14},{ -8, -7},{-15, -6},{ 13, -5},{-16, -4},{ 14,-17},{ 15, -3},{ 16,-18},{ -2, 17},{ 18,-19},{ -1, 19},{-20, 20},{ 0, 21},{ 22,-21},{-22,-23},{ 0, 0}}, @@ -343,7 +343,7 @@ static const int16_t differential_region_power_decoder_tree[NUMBER_OF_REGIONS][D }; /* vs refdec: same table */ -static const int16_t mlt_quant_centroid[NUM_CATEGORIES][NUM_BINS] = { +static const int16_t mlt_quant_centroid[NUM_CATEGORIES][NUM_BINS] = { /* "mlt_q" */ { 0, 1606, 3119, 4586, 6049, 7502, 8941,10406,11851,13292,14736,16146,17566,19351, 0, 0}, { 0, 2229, 4341, 6401, 8471,10531,12583,14588,16673,18924, 0, 0, 0, 0, 0, 0}, { 0, 3055, 5998, 8929,11806,14680,17680, 0, 0, 0, 0, 0, 0, 0, 0, 0}, @@ -361,7 +361,7 @@ static const int16_t expected_bits_table[NUM_CATEGORIES] = { /* vs refdec: Namco uses positive values *2 but I'm not sure what they are for (some index access) * so these are the refdec values */ -static const int16_t mlt_decoder_tree_category_0[180][2] = { +static const int16_t mlt_decoder_tree_category_0[180][2] = { /* "reasion_huffman_table"? */ { 1, 0},{ 2, 3},{ 4, 5},{ 6, 7},{ 8, 9},{ -1, -14},{ 10, 11},{ 12, 13}, { 14, 15},{ 16, 17},{ 18, 19},{ -15, 20},{ 21, 22},{ 23, -28},{ 24, -2},{ 25, 26}, { 27, 28},{ 29, 30},{ 31, 32},{ -29, 33},{ -16, 34},{ -3, 35},{ 36, 37},{ -42, 38}, @@ -541,7 +541,7 @@ static const int16_t *table_of_decoder_tables[NUM_CATEGORIES-1] = { /* vs refdec: same table */ -static const int16_t region_standard_deviation_table[REGION_POWER_TABLE_SIZE] = { +static const int16_t region_standard_deviation_table[REGION_POWER_TABLE_SIZE] = { /* "rnd_reg"? */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, @@ -559,17 +559,17 @@ static const int16_t number_of_vectors[NUM_CATEGORIES] = { 10, 10, 10, 5, 5, 4, 4, 0, }; /* vs refdec: same table but last index is 1 */ -static const int16_t vector_dimension[NUM_CATEGORIES] = { +static const int16_t vector_dimension[NUM_CATEGORIES] = { /* "vd_inv"? */ 2, 2, 2, 4, 4, 5, 5, 0, }; /* vs refdec: pre-adds one instead of in runtime and last index is 1 */ -static const int16_t max_bin_plus1[NUM_CATEGORIES] = { +static const int16_t max_bin_plus1[NUM_CATEGORIES] = { /* "kmax_p1" */ 14, 10, 7, 5, 4, 3, 2, 0, }; /* vs refdec: pre-scaled x2 (cat3 subs -1 and cat5/7 -2 too) */ -static const uint16_t max_bin_plus_one_inverse_scaled[8] = { +static const uint16_t max_bin_plus_one_inverse_scaled[8] = { /* "kmax_p1_inv" */ 4682, 6554, 9363, 13108, 16384, 21846, 32768, 0, };