Major optimization of atrac3 codec for Coldfire targets. Moving several number crunch...
[kugel-rb.git] / apps / codecs / libatrac / atrac3.h
blob5bed9c60bfd0e78992e022ddb11fcd8d3d520dcf
1 #include "ffmpeg_bitstream.h"
2 #include "../librm/rm.h"
4 #if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250)
5 /* PP5022/24 and MCF5250 have larger IRAM */
6 #define IBSS_ATTR_LARGE_IRAM IBSS_ATTR
7 #define ICODE_ATTR_LARGE_IRAM ICODE_ATTR
8 #else
9 /* other CPUs IRAM is not large enough */
10 #define IBSS_ATTR_LARGE_IRAM
11 #define ICODE_ATTR_LARGE_IRAM
12 #endif
14 /* These structures are needed to store the parsed gain control data. */
15 typedef struct {
16 int num_gain_data;
17 int levcode[8];
18 int loccode[8];
19 } gain_info;
21 typedef struct {
22 gain_info gBlock[4];
23 } gain_block;
25 typedef struct {
26 int pos;
27 int numCoefs;
28 int32_t coef[8];
29 } tonal_component;
31 typedef struct {
32 int bandsCoded;
33 int numComponents;
34 tonal_component components[64];
35 int32_t *prevFrame;
36 int gcBlkSwitch;
37 gain_block gainBlock[2];
39 int32_t *spectrum;
40 int32_t *IMDCT_buf;
42 int32_t delayBuf1[46]; ///<qmf delay buffers
43 int32_t delayBuf2[46];
44 int32_t delayBuf3[46];
45 } channel_unit;
47 typedef struct {
48 GetBitContext gb;
49 //@{
50 /** stream data */
51 int channels;
52 int codingMode;
53 int bit_rate;
54 int sample_rate;
55 int samples_per_channel;
56 int samples_per_frame;
58 int bits_per_frame;
59 int bytes_per_frame;
60 int pBs;
61 channel_unit* pUnits;
62 //@}
63 //@{
64 /** joint-stereo related variables */
65 int matrix_coeff_index_prev[4];
66 int matrix_coeff_index_now[4];
67 int matrix_coeff_index_next[4];
68 int weighting_delay[6];
69 //@}
70 //@{
71 /** data buffers */
72 int32_t outSamples[2048];
73 uint8_t decoded_bytes_buffer[1024];
74 int32_t tempBuf[1070];
75 //@}
76 //@{
77 /** extradata */
78 int atrac3version;
79 int delay;
80 int scrambled_stream;
81 int frame_factor;
82 //@}
83 } ATRAC3Context;
85 int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx);
87 int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q,
88 int *data_size, const uint8_t *buf, int buf_size);