File: mpadec_internal.h

package info (click to toggle)
csound 1%3A6.18.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 63,220 kB
  • sloc: ansic: 192,643; cpp: 14,149; javascript: 9,654; objc: 9,181; python: 3,376; java: 3,337; sh: 1,840; yacc: 1,255; xml: 985; perl: 635; lisp: 411; tcl: 341; lex: 217; makefile: 128
file content (215 lines) | stat: -rw-r--r-- 5,177 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
 *  mpadec - MPEG audio decoder
 *  Copyright (C) 2002-2004 Dmitriy Startsev (dstartsev@rambler.ru)
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

/* $Id: mpadec_internal.h,v 1.1.1.1 2004/07/27 02:57:55 metal_man Exp $ */

#ifndef __MPADEC_INTERNAL_H
#define __MPADEC_INTERNAL_H

#include "mpadec_config.h"
#include "mpadec.h"

#define MPADEC_STATE_UNDEFINED 0
#define MPADEC_STATE_START     1
#define MPADEC_STATE_DECODE    2

#define MPG_MD_STEREO       0
#define MPG_MD_JOINT_STEREO 1
#define MPG_MD_DUAL_CHANNEL 2
#define MPG_MD_MONO         3

#define SBLIMIT     32
#define SSLIMIT     18
#define SCALE_BLOCK 12

typedef struct {
  FLOAT decwin[512 + 32];
  FLOAT muls[27][64];
  FLOAT gainpow2[256 + 122];
  FLOAT ispow[8207];
  FLOAT win[2][4][36];
  FLOAT *istabs[3][2][2];
  FLOAT tan1_1[16];
  FLOAT tan2_1[16];
  FLOAT tan1_2[16];
  FLOAT tan2_2[16];
  FLOAT pow1_1[2][16];
  FLOAT pow2_1[2][16];
  FLOAT pow1_2[2][16];
  FLOAT pow2_2[2][16];
  int32_t long_limit[9][23];
  int32_t short_limit[9][14];
  int32_t n_slen2[512];
  int32_t i_slen2[256];
  int32_t mapbuf0[9][152];
  int32_t mapbuf1[9][156];
  int32_t mapbuf2[9][44];
  int32_t *map[9][3];
  int32_t *mapend[9][3];
  uint8_t *mp2tables[10];
  uint8_t grp3tab[32*3];
  uint8_t grp5tab[128*3];
  uint8_t grp9tab[1024*3];
} mpadec_tables_t;

typedef struct {
  uint16_t bits;
  int16_t d;
} alloc_table_t;

typedef struct {
  uint32_t linbits;
  int16_t *table;
} newhuff_t;

typedef struct {
  int16_t long_idx[23];
  int16_t long_diff[22];
  int16_t short_idx[14];
  int16_t short_diff[13];
} bandinfo_t;

typedef struct {
  uint8_t layer;
  uint8_t mode;
  uint8_t channels;
  uint8_t decoded_channels;
  uint8_t LSF;
  uint8_t MPEG25;
  uint8_t CRC;
  uint8_t extension;
  uint8_t mode_ext;
  uint8_t copyright;
  uint8_t original;
  uint8_t emphasis;
  uint8_t jsbound;
  uint8_t sblimit;
  uint8_t downsample;
  uint8_t downsample_sblimit;
  uint16_t crc;
  uint16_t rsvd;
  uint32_t padding;
  uint32_t bitrate_index;
  uint32_t frequency_index;
  uint32_t bitrate;
  uint32_t frequency;
  uint32_t frame_size;
  uint32_t frame_samples;
  uint32_t decoded_frequency;
  uint32_t decoded_samples;
  uint32_t decoded_size;
  alloc_table_t *alloc_table;
} frameinfo_t;

typedef struct {
  int32_t scfsi;
  uint32_t part2_3_length;
  uint32_t big_values;
  uint32_t scalefac_compress;
  uint8_t block_type;
  uint8_t mixed_block_flag;
  uint8_t preflag;
  uint8_t scalefac_scale;
  uint32_t table_select[3];
  uint32_t subblock_gain[3];
  uint32_t maxband[3];
  uint32_t maxbandl;
  uint32_t maxb;
  uint32_t region1start;
  uint32_t region2start;
  uint32_t count1table_select;
  FLOAT *full_gain[3];
  FLOAT *pow2gain;
} grinfo_t;

typedef struct {
  uint32_t main_data_begin;
  uint32_t private_bits;
  struct {
    grinfo_t gr[2];
  } ch[2];
} sideinfo_t;

struct mpadec_t {
  uint32_t size;
  uint32_t state;
  uint8_t *next_byte;
  uint32_t bytes_left;
  uint32_t bit_buffer;
  uint8_t bits_left;
  uint8_t error;
  uint8_t free_format;
  uint8_t pad1;
  uint32_t sample_size;
  uint32_t prev_frame_size;
  uint32_t header;
  uint32_t hsize;
  uint32_t ssize;
  uint32_t dsize;
  uint16_t crc;
  uint16_t pad2;
  uint32_t skip_samples;
  uint32_t padding_samples;
  uint32_t padding_start;
  uint32_t decoded_frames;
  uint32_t decoded_samples;
  mp3tag_info_t tag_info;
  uint32_t synth_size;
  FLOAT replay_gain;
  void (*synth_func)(void *mpadec, FLOAT block[SBLIMIT],
                     int channel, uint8_t *buffer);
  uint32_t reservoir_size;
  uint8_t reservoir[2048];
  frameinfo_t frame;
  sideinfo_t sideinfo;
  mpadec_config_t config;
  mpadec_tables_t tables;
  uint32_t synth_bufoffs;
  uint8_t hybrid_block[4];
  FLOAT hybrid_in[2][SBLIMIT][SSLIMIT];
  FLOAT hybrid_out[2][SSLIMIT][SBLIMIT];
  FLOAT hybrid_buffers[2][2][SBLIMIT*SSLIMIT];
  FLOAT synth_buffers[2][2][0x110];
};

struct mpabuffer_t {
  uint32_t size;
  uint32_t offset;
  uint32_t used;
  uint8_t *buffer;
  struct mpabuffer_t *next;
};

struct mpadec2_t {
  uint32_t size;
  mpadec_t mpadec;
  struct mpabuffer_t *buffers;
  uint32_t in_buffer_offset;
  uint32_t in_buffer_used;
  uint32_t out_buffer_offset;
  uint32_t out_buffer_used;
  uint8_t in_buffer[0x10000];
  uint8_t out_buffer[8*1152];
};

#define GETBITS(n) ((mpa->bits_left >= (uint8_t)(n)) \
                    ? ((mpa->bit_buffer >> (mpa->bits_left -= \
                       (uint8_t)(n))) & bitmask[n]) : mpa_getbits(mpa, n))

#endif