summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/libwmapro/types.h8
-rw-r--r--apps/codecs/libwmapro/wmapro_math.h19
-rw-r--r--apps/codecs/libwmapro/wmaprodec.c57
3 files changed, 37 insertions, 47 deletions
diff --git a/apps/codecs/libwmapro/types.h b/apps/codecs/libwmapro/types.h
deleted file mode 100644
index 01359fc1b1..0000000000
--- a/apps/codecs/libwmapro/types.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef _TYPES_H_
2#define _TYPES_H_
3
4#include <inttypes.h>
5
6#define FIXED int32_t
7
8#endif
diff --git a/apps/codecs/libwmapro/wmapro_math.h b/apps/codecs/libwmapro/wmapro_math.h
index 4614bcbe56..823c002c09 100644
--- a/apps/codecs/libwmapro/wmapro_math.h
+++ b/apps/codecs/libwmapro/wmapro_math.h
@@ -2,14 +2,13 @@
2#define _WMAPRO_MATH_H_ 2#define _WMAPRO_MATH_H_
3 3
4#include <inttypes.h> 4#include <inttypes.h>
5#include "types.h"
6 5
7#define fixtof16(x) (float)((float)(x) / (float)(1 << 16)) 6#define fixtof16(x) (float)((float)(x) / (float)(1 << 16))
8#define fixtof31(x) (float)((float)(x) / (float)(1 << 31)) 7#define fixtof31(x) (float)((float)(x) / (float)(1 << 31))
9#define ftofix16(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5:0.5))) 8#define ftofix16(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5:0.5)))
10#define ftofix31(x) ((int32_t)((x) * (float)(1 << 31) + ((x) < 0 ? -0.5:0.5))) 9#define ftofix31(x) ((int32_t)((x) * (float)(1 << 31) + ((x) < 0 ? -0.5:0.5)))
11 10
12static inline FIXED fixmulshift(FIXED x, FIXED y, int shamt) 11static inline int32_t fixmulshift(int32_t x, int32_t y, int shamt)
13{ 12{
14 int64_t temp; 13 int64_t temp;
15 temp = x; 14 temp = x;
@@ -21,26 +20,26 @@ static inline FIXED fixmulshift(FIXED x, FIXED y, int shamt)
21} 20}
22 21
23 22
24static inline void vector_fixmul_window(FIXED *dst, const FIXED *src0, 23static inline void vector_fixmul_window(int32_t *dst, const int32_t *src0,
25 const FIXED *src1, const FIXED *win, 24 const int32_t *src1, const int32_t *win,
26 FIXED add_bias, int len) 25 int32_t add_bias, int len)
27{ 26{
28 int i, j; 27 int i, j;
29 dst += len; 28 dst += len;
30 win += len; 29 win += len;
31 src0+= len; 30 src0+= len;
32 for(i=-len, j=len-1; i<0; i++, j--) { 31 for(i=-len, j=len-1; i<0; i++, j--) {
33 FIXED s0 = src0[i]; 32 int32_t s0 = src0[i];
34 FIXED s1 = src1[j]; 33 int32_t s1 = src1[j];
35 FIXED wi = win[i]; 34 int32_t wi = win[i];
36 FIXED wj = win[j]; 35 int32_t wj = win[j];
37 dst[i] = fixmulshift(s0,-1*wj,31) - fixmulshift(s1,-1*wi,31) + (add_bias<<16); 36 dst[i] = fixmulshift(s0,-1*wj,31) - fixmulshift(s1,-1*wi,31) + (add_bias<<16);
38 dst[j] = fixmulshift(s0,-1*wi,31) + fixmulshift(s1,-1*wj,31) + (add_bias<<16); 37 dst[j] = fixmulshift(s0,-1*wi,31) + fixmulshift(s1,-1*wj,31) + (add_bias<<16);
39 } 38 }
40 39
41} 40}
42 41
43static inline void vector_fixmul_scalar(FIXED *dst, const FIXED *src, FIXED mul, 42static inline void vector_fixmul_scalar(int32_t *dst, const int32_t *src, int32_t mul,
44 int len, int shift) 43 int len, int shift)
45{ 44{
46 int i; 45 int i;
diff --git a/apps/codecs/libwmapro/wmaprodec.c b/apps/codecs/libwmapro/wmaprodec.c
index ea4cbe3a44..8b2043a682 100644
--- a/apps/codecs/libwmapro/wmaprodec.c
+++ b/apps/codecs/libwmapro/wmaprodec.c
@@ -94,7 +94,6 @@
94#include "wmapro_mdct.h" 94#include "wmapro_mdct.h"
95#include "mdct_tables.h" 95#include "mdct_tables.h"
96#include "quant.h" 96#include "quant.h"
97#include "types.h"
98#include "wmapro_math.h" 97#include "wmapro_math.h"
99#include "codecs.h" 98#include "codecs.h"
100#include "codeclib.h" 99#include "codeclib.h"
@@ -172,8 +171,8 @@ typedef struct {
172 int8_t scale_factor_idx; ///< index for the transmitted scale factor values (used for resampling) 171 int8_t scale_factor_idx; ///< index for the transmitted scale factor values (used for resampling)
173 int* scale_factors; ///< pointer to the scale factor values used for decoding 172 int* scale_factors; ///< pointer to the scale factor values used for decoding
174 uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block 173 uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block
175 FIXED* coeffs; ///< pointer to the subframe decode buffer 174 int32_t* coeffs; ///< pointer to the subframe decode buffer
176 DECLARE_ALIGNED(16, FIXED, out)[WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE / 2]; ///< output buffer 175 DECLARE_ALIGNED(16, int32_t, out)[WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE / 2]; ///< output buffer
177} WMAProChannelCtx; 176} WMAProChannelCtx;
178 177
179/** 178/**
@@ -184,8 +183,8 @@ typedef struct {
184 int8_t transform; ///< transform on / off 183 int8_t transform; ///< transform on / off
185 int8_t transform_band[MAX_BANDS]; ///< controls if the transform is enabled for a certain band 184 int8_t transform_band[MAX_BANDS]; ///< controls if the transform is enabled for a certain band
186 //float decorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; 185 //float decorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS];
187 FIXED* channel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients 186 int32_t* channel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients
188 FIXED fixdecorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; 187 int32_t fixdecorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS];
189} WMAProChannelGrp; 188} WMAProChannelGrp;
190 189
191/** 190/**
@@ -196,7 +195,7 @@ typedef struct WMAProDecodeCtx {
196 uint8_t frame_data[MAX_FRAMESIZE + 195 uint8_t frame_data[MAX_FRAMESIZE +
197 FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data 196 FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data
198 PutBitContext pb; ///< context for filling the frame_data buffer 197 PutBitContext pb; ///< context for filling the frame_data buffer
199 DECLARE_ALIGNED(16, FIXED, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT input buffer 198 DECLARE_ALIGNED(16, int32_t, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT input buffer
200 199
201 /* frame size dependent frame information (set during initialization) */ 200 /* frame size dependent frame information (set during initialization) */
202 uint32_t decode_flags; ///< used compression features 201 uint32_t decode_flags; ///< used compression features
@@ -230,8 +229,8 @@ typedef struct WMAProDecodeCtx {
230 uint32_t frame_num; ///< current frame number 229 uint32_t frame_num; ///< current frame number
231 GetBitContext gb; ///< bitstream reader context 230 GetBitContext gb; ///< bitstream reader context
232 int buf_bit_size; ///< buffer size in bits 231 int buf_bit_size; ///< buffer size in bits
233 FIXED* samples; 232 int32_t* samples;
234 FIXED* samples_end; ///< maximum samplebuffer pointer 233 int32_t* samples_end; ///< maximum samplebuffer pointer
235 uint8_t drc_gain; ///< gain for the DRC tool 234 uint8_t drc_gain; ///< gain for the DRC tool
236 int8_t skip_frame; ///< skip output step 235 int8_t skip_frame; ///< skip output step
237 int8_t parsed_all_subframes; ///< all subframes decoded? 236 int8_t parsed_all_subframes; ///< all subframes decoded?
@@ -629,13 +628,13 @@ static void decode_decorrelation_matrix(WMAProDecodeCtx *s,
629 for (y = 0; y < i + 1; y++) { 628 for (y = 0; y < i + 1; y++) {
630 float v1 = chgroup->decorrelation_matrix[x * chgroup->num_channels + y]; 629 float v1 = chgroup->decorrelation_matrix[x * chgroup->num_channels + y];
631 float v2 = chgroup->decorrelation_matrix[i * chgroup->num_channels + y]; 630 float v2 = chgroup->decorrelation_matrix[i * chgroup->num_channels + y];
632 FIXED f1 = chgroup->fixdecorrelation_matrix[x * chgroup->num_channels + y]; 631 int32_t f1 = chgroup->fixdecorrelation_matrix[x * chgroup->num_channels + y];
633 FIXED f2 = chgroup->fixdecorrelation_matrix[i * chgroup->num_channels + y]; 632 int32_t f2 = chgroup->fixdecorrelation_matrix[i * chgroup->num_channels + y];
634 int n = rotation_offset[offset + x]; 633 int n = rotation_offset[offset + x];
635 float sinv; 634 float sinv;
636 float cosv; 635 float cosv;
637 FIXED fixsinv; 636 int32_t fixsinv;
638 FIXED fixcosv; 637 int32_t fixcosv;
639 638
640 if (n < 32) { 639 if (n < 32) {
641 sinv = sin64[n]; 640 sinv = sin64[n];
@@ -691,7 +690,7 @@ static int decode_channel_transform(WMAProDecodeCtx* s)
691 for (s->num_chgroups = 0; remaining_channels && 690 for (s->num_chgroups = 0; remaining_channels &&
692 s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) { 691 s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) {
693 WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups]; 692 WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups];
694 FIXED** channel_data = chgroup->channel_data; 693 int32_t** channel_data = chgroup->channel_data;
695 chgroup->num_channels = 0; 694 chgroup->num_channels = 0;
696 chgroup->transform = 0; 695 chgroup->transform = 0;
697 696
@@ -794,7 +793,7 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c)
794 int cur_coeff = 0; 793 int cur_coeff = 0;
795 int num_zeros = 0; 794 int num_zeros = 0;
796 const uint16_t* run; 795 const uint16_t* run;
797 const FIXED* level; 796 const int32_t* level;
798 797
799 DEBUGF("decode coefficients for channel %i\n", c); 798 DEBUGF("decode coefficients for channel %i\n", c);
800 799
@@ -980,9 +979,9 @@ static void inverse_channel_transform(WMAProDecodeCtx *s)
980 for (i = 0; i < s->num_chgroups; i++) { 979 for (i = 0; i < s->num_chgroups; i++) {
981 if (s->chgroup[i].transform) { 980 if (s->chgroup[i].transform) {
982 const int num_channels = s->chgroup[i].num_channels; 981 const int num_channels = s->chgroup[i].num_channels;
983 FIXED data[WMAPRO_MAX_CHANNELS]; 982 int32_t data[WMAPRO_MAX_CHANNELS];
984 FIXED** ch_data = s->chgroup[i].channel_data; 983 int32_t** ch_data = s->chgroup[i].channel_data;
985 FIXED** ch_end = ch_data + num_channels; 984 int32_t** ch_end = ch_data + num_channels;
986 const int8_t* tb = s->chgroup[i].transform_band; 985 const int8_t* tb = s->chgroup[i].transform_band;
987 int16_t* sfb; 986 int16_t* sfb;
988 987
@@ -993,16 +992,16 @@ static void inverse_channel_transform(WMAProDecodeCtx *s)
993 if (*tb++ == 1) { 992 if (*tb++ == 1) {
994 /** multiply values with the decorrelation_matrix */ 993 /** multiply values with the decorrelation_matrix */
995 for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len); y++) { 994 for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len); y++) {
996 const FIXED* mat = s->chgroup[i].fixdecorrelation_matrix; 995 const int32_t* mat = s->chgroup[i].fixdecorrelation_matrix;
997 const FIXED* data_end = data + num_channels; 996 const int32_t* data_end = data + num_channels;
998 FIXED* data_ptr = data; 997 int32_t* data_ptr = data;
999 FIXED** ch; 998 int32_t** ch;
1000 999
1001 for (ch = ch_data; ch < ch_end; ch++) 1000 for (ch = ch_data; ch < ch_end; ch++)
1002 *data_ptr++ = (*ch)[y]; 1001 *data_ptr++ = (*ch)[y];
1003 1002
1004 for (ch = ch_data; ch < ch_end; ch++) { 1003 for (ch = ch_data; ch < ch_end; ch++) {
1005 FIXED sum = 0; 1004 int32_t sum = 0;
1006 data_ptr = data; 1005 data_ptr = data;
1007 1006
1008 while (data_ptr < data_end) 1007 while (data_ptr < data_end)
@@ -1037,9 +1036,9 @@ static void wmapro_window(WMAProDecodeCtx *s)
1037 1036
1038 for (i = 0; i < s->channels_for_cur_subframe; i++) { 1037 for (i = 0; i < s->channels_for_cur_subframe; i++) {
1039 int c = s->channel_indexes_for_cur_subframe[i]; 1038 int c = s->channel_indexes_for_cur_subframe[i];
1040 const FIXED* window; 1039 const int32_t* window;
1041 int winlen = s->channel[c].prev_block_len; 1040 int winlen = s->channel[c].prev_block_len;
1042 FIXED *xstart= s->channel[c].coeffs - (winlen >> 1); 1041 int32_t *xstart= s->channel[c].coeffs - (winlen >> 1);
1043 1042
1044 if (s->subframe_len < winlen) { 1043 if (s->subframe_len < winlen) {
1045 xstart += (winlen - s->subframe_len) >> 1; 1044 xstart += (winlen - s->subframe_len) >> 1;
@@ -1253,7 +1252,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
1253 DEBUGF("in wmaprodec.c : unhandled value for exp, please report sample.\n"); 1252 DEBUGF("in wmaprodec.c : unhandled value for exp, please report sample.\n");
1254 return -1; 1253 return -1;
1255 } 1254 }
1256 const FIXED quant = QUANT(exp); 1255 const int32_t quant = QUANT(exp);
1257 int start = s->cur_sfb_offsets[b]; 1256 int start = s->cur_sfb_offsets[b];
1258 1257
1259 vector_fixmul_scalar(s->tmp+start, 1258 vector_fixmul_scalar(s->tmp+start,
@@ -1372,10 +1371,10 @@ static int decode_frame(WMAProDecodeCtx *s)
1372 1371
1373 /** interleave samples and write them to the output buffer */ 1372 /** interleave samples and write them to the output buffer */
1374 for (i = 0; i < s->num_channels; i++) { 1373 for (i = 0; i < s->num_channels; i++) {
1375 FIXED* ptr = s->samples + i; 1374 int32_t* ptr = s->samples + i;
1376 int incr = s->num_channels; 1375 int incr = s->num_channels;
1377 FIXED* iptr = s->channel[i].out; 1376 int32_t* iptr = s->channel[i].out;
1378 FIXED* iend = iptr + s->samples_per_frame; 1377 int32_t* iend = iptr + s->samples_per_frame;
1379 1378
1380 while (iptr < iend) { 1379 while (iptr < iend) {
1381 *ptr = *iptr++ << 1; 1380 *ptr = *iptr++ << 1;
@@ -1493,7 +1492,7 @@ int decode_packet(asf_waveformatex_t *wfx, void *data, int *data_size,
1493 int packet_sequence_number; 1492 int packet_sequence_number;
1494 1493
1495 s->samples = data; 1494 s->samples = data;
1496 s->samples_end = (FIXED*)((int8_t*)data + *data_size); 1495 s->samples_end = (int32_t*)((int8_t*)data + *data_size);
1497 *data_size = 0; 1496 *data_size = 0;
1498 1497
1499 if (s->packet_done || s->packet_loss) { 1498 if (s->packet_done || s->packet_loss) {