forked from len0rd/rockbox
libwmapro : Rename all FIXED occurrances to int32_t and remove types.h
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27454 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0f94710410
commit
b339963567
3 changed files with 37 additions and 47 deletions
|
|
@ -1,8 +0,0 @@
|
||||||
#ifndef _TYPES_H_
|
|
||||||
#define _TYPES_H_
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
#define FIXED int32_t
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -2,14 +2,13 @@
|
||||||
#define _WMAPRO_MATH_H_
|
#define _WMAPRO_MATH_H_
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
#define fixtof16(x) (float)((float)(x) / (float)(1 << 16))
|
#define fixtof16(x) (float)((float)(x) / (float)(1 << 16))
|
||||||
#define fixtof31(x) (float)((float)(x) / (float)(1 << 31))
|
#define fixtof31(x) (float)((float)(x) / (float)(1 << 31))
|
||||||
#define ftofix16(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5:0.5)))
|
#define ftofix16(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5:0.5)))
|
||||||
#define ftofix31(x) ((int32_t)((x) * (float)(1 << 31) + ((x) < 0 ? -0.5:0.5)))
|
#define ftofix31(x) ((int32_t)((x) * (float)(1 << 31) + ((x) < 0 ? -0.5:0.5)))
|
||||||
|
|
||||||
static inline FIXED fixmulshift(FIXED x, FIXED y, int shamt)
|
static inline int32_t fixmulshift(int32_t x, int32_t y, int shamt)
|
||||||
{
|
{
|
||||||
int64_t temp;
|
int64_t temp;
|
||||||
temp = x;
|
temp = x;
|
||||||
|
|
@ -21,26 +20,26 @@ static inline FIXED fixmulshift(FIXED x, FIXED y, int shamt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void vector_fixmul_window(FIXED *dst, const FIXED *src0,
|
static inline void vector_fixmul_window(int32_t *dst, const int32_t *src0,
|
||||||
const FIXED *src1, const FIXED *win,
|
const int32_t *src1, const int32_t *win,
|
||||||
FIXED add_bias, int len)
|
int32_t add_bias, int len)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
dst += len;
|
dst += len;
|
||||||
win += len;
|
win += len;
|
||||||
src0+= len;
|
src0+= len;
|
||||||
for(i=-len, j=len-1; i<0; i++, j--) {
|
for(i=-len, j=len-1; i<0; i++, j--) {
|
||||||
FIXED s0 = src0[i];
|
int32_t s0 = src0[i];
|
||||||
FIXED s1 = src1[j];
|
int32_t s1 = src1[j];
|
||||||
FIXED wi = win[i];
|
int32_t wi = win[i];
|
||||||
FIXED wj = win[j];
|
int32_t wj = win[j];
|
||||||
dst[i] = fixmulshift(s0,-1*wj,31) - fixmulshift(s1,-1*wi,31) + (add_bias<<16);
|
dst[i] = fixmulshift(s0,-1*wj,31) - fixmulshift(s1,-1*wi,31) + (add_bias<<16);
|
||||||
dst[j] = fixmulshift(s0,-1*wi,31) + fixmulshift(s1,-1*wj,31) + (add_bias<<16);
|
dst[j] = fixmulshift(s0,-1*wi,31) + fixmulshift(s1,-1*wj,31) + (add_bias<<16);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void vector_fixmul_scalar(FIXED *dst, const FIXED *src, FIXED mul,
|
static inline void vector_fixmul_scalar(int32_t *dst, const int32_t *src, int32_t mul,
|
||||||
int len, int shift)
|
int len, int shift)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@
|
||||||
#include "wmapro_mdct.h"
|
#include "wmapro_mdct.h"
|
||||||
#include "mdct_tables.h"
|
#include "mdct_tables.h"
|
||||||
#include "quant.h"
|
#include "quant.h"
|
||||||
#include "types.h"
|
|
||||||
#include "wmapro_math.h"
|
#include "wmapro_math.h"
|
||||||
#include "codecs.h"
|
#include "codecs.h"
|
||||||
#include "codeclib.h"
|
#include "codeclib.h"
|
||||||
|
|
@ -172,8 +171,8 @@ typedef struct {
|
||||||
int8_t scale_factor_idx; ///< index for the transmitted scale factor values (used for resampling)
|
int8_t scale_factor_idx; ///< index for the transmitted scale factor values (used for resampling)
|
||||||
int* scale_factors; ///< pointer to the scale factor values used for decoding
|
int* scale_factors; ///< pointer to the scale factor values used for decoding
|
||||||
uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block
|
uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block
|
||||||
FIXED* coeffs; ///< pointer to the subframe decode buffer
|
int32_t* coeffs; ///< pointer to the subframe decode buffer
|
||||||
DECLARE_ALIGNED(16, FIXED, out)[WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE / 2]; ///< output buffer
|
DECLARE_ALIGNED(16, int32_t, out)[WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE / 2]; ///< output buffer
|
||||||
} WMAProChannelCtx;
|
} WMAProChannelCtx;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -184,8 +183,8 @@ typedef struct {
|
||||||
int8_t transform; ///< transform on / off
|
int8_t transform; ///< transform on / off
|
||||||
int8_t transform_band[MAX_BANDS]; ///< controls if the transform is enabled for a certain band
|
int8_t transform_band[MAX_BANDS]; ///< controls if the transform is enabled for a certain band
|
||||||
//float decorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS];
|
//float decorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS];
|
||||||
FIXED* channel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients
|
int32_t* channel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients
|
||||||
FIXED fixdecorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS];
|
int32_t fixdecorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS];
|
||||||
} WMAProChannelGrp;
|
} WMAProChannelGrp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -196,7 +195,7 @@ typedef struct WMAProDecodeCtx {
|
||||||
uint8_t frame_data[MAX_FRAMESIZE +
|
uint8_t frame_data[MAX_FRAMESIZE +
|
||||||
FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data
|
FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data
|
||||||
PutBitContext pb; ///< context for filling the frame_data buffer
|
PutBitContext pb; ///< context for filling the frame_data buffer
|
||||||
DECLARE_ALIGNED(16, FIXED, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT input buffer
|
DECLARE_ALIGNED(16, int32_t, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT input buffer
|
||||||
|
|
||||||
/* frame size dependent frame information (set during initialization) */
|
/* frame size dependent frame information (set during initialization) */
|
||||||
uint32_t decode_flags; ///< used compression features
|
uint32_t decode_flags; ///< used compression features
|
||||||
|
|
@ -230,8 +229,8 @@ typedef struct WMAProDecodeCtx {
|
||||||
uint32_t frame_num; ///< current frame number
|
uint32_t frame_num; ///< current frame number
|
||||||
GetBitContext gb; ///< bitstream reader context
|
GetBitContext gb; ///< bitstream reader context
|
||||||
int buf_bit_size; ///< buffer size in bits
|
int buf_bit_size; ///< buffer size in bits
|
||||||
FIXED* samples;
|
int32_t* samples;
|
||||||
FIXED* samples_end; ///< maximum samplebuffer pointer
|
int32_t* samples_end; ///< maximum samplebuffer pointer
|
||||||
uint8_t drc_gain; ///< gain for the DRC tool
|
uint8_t drc_gain; ///< gain for the DRC tool
|
||||||
int8_t skip_frame; ///< skip output step
|
int8_t skip_frame; ///< skip output step
|
||||||
int8_t parsed_all_subframes; ///< all subframes decoded?
|
int8_t parsed_all_subframes; ///< all subframes decoded?
|
||||||
|
|
@ -629,13 +628,13 @@ static void decode_decorrelation_matrix(WMAProDecodeCtx *s,
|
||||||
for (y = 0; y < i + 1; y++) {
|
for (y = 0; y < i + 1; y++) {
|
||||||
float v1 = chgroup->decorrelation_matrix[x * chgroup->num_channels + y];
|
float v1 = chgroup->decorrelation_matrix[x * chgroup->num_channels + y];
|
||||||
float v2 = chgroup->decorrelation_matrix[i * chgroup->num_channels + y];
|
float v2 = chgroup->decorrelation_matrix[i * chgroup->num_channels + y];
|
||||||
FIXED f1 = chgroup->fixdecorrelation_matrix[x * chgroup->num_channels + y];
|
int32_t f1 = chgroup->fixdecorrelation_matrix[x * chgroup->num_channels + y];
|
||||||
FIXED f2 = chgroup->fixdecorrelation_matrix[i * chgroup->num_channels + y];
|
int32_t f2 = chgroup->fixdecorrelation_matrix[i * chgroup->num_channels + y];
|
||||||
int n = rotation_offset[offset + x];
|
int n = rotation_offset[offset + x];
|
||||||
float sinv;
|
float sinv;
|
||||||
float cosv;
|
float cosv;
|
||||||
FIXED fixsinv;
|
int32_t fixsinv;
|
||||||
FIXED fixcosv;
|
int32_t fixcosv;
|
||||||
|
|
||||||
if (n < 32) {
|
if (n < 32) {
|
||||||
sinv = sin64[n];
|
sinv = sin64[n];
|
||||||
|
|
@ -691,7 +690,7 @@ static int decode_channel_transform(WMAProDecodeCtx* s)
|
||||||
for (s->num_chgroups = 0; remaining_channels &&
|
for (s->num_chgroups = 0; remaining_channels &&
|
||||||
s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) {
|
s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) {
|
||||||
WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups];
|
WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups];
|
||||||
FIXED** channel_data = chgroup->channel_data;
|
int32_t** channel_data = chgroup->channel_data;
|
||||||
chgroup->num_channels = 0;
|
chgroup->num_channels = 0;
|
||||||
chgroup->transform = 0;
|
chgroup->transform = 0;
|
||||||
|
|
||||||
|
|
@ -794,7 +793,7 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c)
|
||||||
int cur_coeff = 0;
|
int cur_coeff = 0;
|
||||||
int num_zeros = 0;
|
int num_zeros = 0;
|
||||||
const uint16_t* run;
|
const uint16_t* run;
|
||||||
const FIXED* level;
|
const int32_t* level;
|
||||||
|
|
||||||
DEBUGF("decode coefficients for channel %i\n", c);
|
DEBUGF("decode coefficients for channel %i\n", c);
|
||||||
|
|
||||||
|
|
@ -980,9 +979,9 @@ static void inverse_channel_transform(WMAProDecodeCtx *s)
|
||||||
for (i = 0; i < s->num_chgroups; i++) {
|
for (i = 0; i < s->num_chgroups; i++) {
|
||||||
if (s->chgroup[i].transform) {
|
if (s->chgroup[i].transform) {
|
||||||
const int num_channels = s->chgroup[i].num_channels;
|
const int num_channels = s->chgroup[i].num_channels;
|
||||||
FIXED data[WMAPRO_MAX_CHANNELS];
|
int32_t data[WMAPRO_MAX_CHANNELS];
|
||||||
FIXED** ch_data = s->chgroup[i].channel_data;
|
int32_t** ch_data = s->chgroup[i].channel_data;
|
||||||
FIXED** ch_end = ch_data + num_channels;
|
int32_t** ch_end = ch_data + num_channels;
|
||||||
const int8_t* tb = s->chgroup[i].transform_band;
|
const int8_t* tb = s->chgroup[i].transform_band;
|
||||||
int16_t* sfb;
|
int16_t* sfb;
|
||||||
|
|
||||||
|
|
@ -993,16 +992,16 @@ static void inverse_channel_transform(WMAProDecodeCtx *s)
|
||||||
if (*tb++ == 1) {
|
if (*tb++ == 1) {
|
||||||
/** multiply values with the decorrelation_matrix */
|
/** multiply values with the decorrelation_matrix */
|
||||||
for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len); y++) {
|
for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len); y++) {
|
||||||
const FIXED* mat = s->chgroup[i].fixdecorrelation_matrix;
|
const int32_t* mat = s->chgroup[i].fixdecorrelation_matrix;
|
||||||
const FIXED* data_end = data + num_channels;
|
const int32_t* data_end = data + num_channels;
|
||||||
FIXED* data_ptr = data;
|
int32_t* data_ptr = data;
|
||||||
FIXED** ch;
|
int32_t** ch;
|
||||||
|
|
||||||
for (ch = ch_data; ch < ch_end; ch++)
|
for (ch = ch_data; ch < ch_end; ch++)
|
||||||
*data_ptr++ = (*ch)[y];
|
*data_ptr++ = (*ch)[y];
|
||||||
|
|
||||||
for (ch = ch_data; ch < ch_end; ch++) {
|
for (ch = ch_data; ch < ch_end; ch++) {
|
||||||
FIXED sum = 0;
|
int32_t sum = 0;
|
||||||
data_ptr = data;
|
data_ptr = data;
|
||||||
|
|
||||||
while (data_ptr < data_end)
|
while (data_ptr < data_end)
|
||||||
|
|
@ -1037,9 +1036,9 @@ static void wmapro_window(WMAProDecodeCtx *s)
|
||||||
|
|
||||||
for (i = 0; i < s->channels_for_cur_subframe; i++) {
|
for (i = 0; i < s->channels_for_cur_subframe; i++) {
|
||||||
int c = s->channel_indexes_for_cur_subframe[i];
|
int c = s->channel_indexes_for_cur_subframe[i];
|
||||||
const FIXED* window;
|
const int32_t* window;
|
||||||
int winlen = s->channel[c].prev_block_len;
|
int winlen = s->channel[c].prev_block_len;
|
||||||
FIXED *xstart= s->channel[c].coeffs - (winlen >> 1);
|
int32_t *xstart= s->channel[c].coeffs - (winlen >> 1);
|
||||||
|
|
||||||
if (s->subframe_len < winlen) {
|
if (s->subframe_len < winlen) {
|
||||||
xstart += (winlen - s->subframe_len) >> 1;
|
xstart += (winlen - s->subframe_len) >> 1;
|
||||||
|
|
@ -1253,7 +1252,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
|
||||||
DEBUGF("in wmaprodec.c : unhandled value for exp, please report sample.\n");
|
DEBUGF("in wmaprodec.c : unhandled value for exp, please report sample.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const FIXED quant = QUANT(exp);
|
const int32_t quant = QUANT(exp);
|
||||||
int start = s->cur_sfb_offsets[b];
|
int start = s->cur_sfb_offsets[b];
|
||||||
|
|
||||||
vector_fixmul_scalar(s->tmp+start,
|
vector_fixmul_scalar(s->tmp+start,
|
||||||
|
|
@ -1372,10 +1371,10 @@ static int decode_frame(WMAProDecodeCtx *s)
|
||||||
|
|
||||||
/** interleave samples and write them to the output buffer */
|
/** interleave samples and write them to the output buffer */
|
||||||
for (i = 0; i < s->num_channels; i++) {
|
for (i = 0; i < s->num_channels; i++) {
|
||||||
FIXED* ptr = s->samples + i;
|
int32_t* ptr = s->samples + i;
|
||||||
int incr = s->num_channels;
|
int incr = s->num_channels;
|
||||||
FIXED* iptr = s->channel[i].out;
|
int32_t* iptr = s->channel[i].out;
|
||||||
FIXED* iend = iptr + s->samples_per_frame;
|
int32_t* iend = iptr + s->samples_per_frame;
|
||||||
|
|
||||||
while (iptr < iend) {
|
while (iptr < iend) {
|
||||||
*ptr = *iptr++ << 1;
|
*ptr = *iptr++ << 1;
|
||||||
|
|
@ -1493,7 +1492,7 @@ int decode_packet(asf_waveformatex_t *wfx, void *data, int *data_size,
|
||||||
int packet_sequence_number;
|
int packet_sequence_number;
|
||||||
|
|
||||||
s->samples = data;
|
s->samples = data;
|
||||||
s->samples_end = (FIXED*)((int8_t*)data + *data_size);
|
s->samples_end = (int32_t*)((int8_t*)data + *data_size);
|
||||||
*data_size = 0;
|
*data_size = 0;
|
||||||
|
|
||||||
if (s->packet_done || s->packet_loss) {
|
if (s->packet_done || s->packet_loss) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue