0
|
1 /*
|
|
2 * ac3.h
|
|
3 *
|
|
4 * Copyright (C) Aaron Holtzman - May 1999
|
|
5 *
|
|
6 * This file is part of ac3dec, a free Dolby AC-3 stream decoder.
|
|
7 *
|
|
8 * ac3dec is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2, or (at your option)
|
|
11 * any later version.
|
|
12 *
|
|
13 * ac3dec is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with GNU Make; see the file COPYING. If not, write to
|
|
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
21 *
|
|
22 *
|
|
23 */
|
|
24
|
|
25 typedef struct ac3_ba_s {
|
|
26 uint16_t fsnroffst; // fine SNR offset
|
|
27 uint16_t fgaincod; // fast gain
|
|
28 uint16_t deltbae; // delta bit allocation exists
|
|
29 int8_t deltba[50]; // per-band delta bit allocation
|
|
30 } ac3_ba_t;
|
|
31
|
|
32 typedef struct ac3_state_s {
|
|
33 uint8_t fscod; // sample rate
|
|
34 uint8_t halfrate; // halfrate factor
|
|
35 uint8_t acmod; // coded channels
|
|
36 float clev; // centre channel mix level
|
|
37 float slev; // surround channels mix level
|
|
38 uint8_t lfeon; // coded lfe channel
|
|
39
|
|
40 int output; // type of output
|
|
41 float level; // output level
|
|
42 float bias; // output bias
|
|
43
|
|
44 uint16_t cplinu; // coupling in use
|
|
45 uint16_t chincpl[5]; // channel coupled
|
|
46 uint16_t phsflginu; // phase flags in use (stereo only)
|
|
47 uint16_t cplbndstrc[18]; // coupling band structure
|
|
48 uint16_t cplstrtmant; // coupling channel start mantissa
|
|
49 uint16_t cplendmant; // coupling channel end mantissa
|
|
50 float cplco[5][18]; // coupling coordinates
|
|
51
|
|
52 // derived information
|
|
53 uint16_t cplstrtbnd; // coupling start band (for bit allocation)
|
|
54 uint16_t ncplbnd; // number of coupling bands
|
|
55
|
|
56 uint16_t rematflg[4]; // stereo rematrixing
|
|
57
|
|
58 uint16_t endmant[5]; // channel end mantissa
|
|
59
|
|
60 uint8_t cpl_exp[256]; // decoded coupling channel exponents
|
|
61 uint8_t fbw_exp[5][256]; // decoded channel exponents
|
|
62 uint8_t lfe_exp[7]; // decoded lfe channel exponents
|
|
63
|
|
64 uint16_t sdcycod; // slow decay
|
|
65 uint16_t fdcycod; // fast decay
|
|
66 uint16_t sgaincod; // slow gain
|
|
67 uint16_t dbpbcod; // dB per bit - encodes the dbknee value
|
|
68 uint16_t floorcod; // masking floor
|
|
69
|
|
70 uint16_t csnroffst; // coarse SNR offset
|
|
71 ac3_ba_t cplba; // coupling bit allocation parameters
|
|
72 ac3_ba_t ba[5]; // channel bit allocation parameters
|
|
73 ac3_ba_t lfeba; // lfe bit allocation parameters
|
|
74
|
|
75 uint16_t cplfleak; // coupling fast leak init
|
|
76 uint16_t cplsleak; // coupling slow leak init
|
|
77
|
|
78 // derived bit allocation information
|
|
79 int8_t fbw_bap[5][256];
|
|
80 int8_t cpl_bap[256];
|
|
81 int8_t lfe_bap[7];
|
|
82 } ac3_state_t;
|
|
83
|
|
84 /* samples work structure */
|
|
85 typedef float stream_samples_t[6][256];
|
|
86
|
|
87 #define AC3_CHANNEL 0
|
|
88 #define AC3_MONO 1
|
|
89 #define AC3_STEREO 2
|
|
90 #define AC3_3F 3
|
|
91 #define AC3_2F1R 4
|
|
92 #define AC3_3F1R 5
|
|
93 #define AC3_2F2R 6
|
|
94 #define AC3_3F2R 7
|
|
95 #define AC3_CHANNEL1 8
|
|
96 #define AC3_CHANNEL2 9
|
|
97 #define AC3_DOLBY 10
|
|
98 #define AC3_CHANNEL_MASK 15
|
|
99
|
|
100 #define AC3_LFE 16
|
|
101 #define AC3_ADJUST_LEVEL 32
|
|
102
|
|
103 void ac3_init (void);
|
|
104 int ac3_syncinfo (uint8_t * buf, int * flags,
|
|
105 int * sample_rate, int * bit_rate);
|
|
106 int ac3_frame (ac3_state_t * state, uint8_t * buf, int * flags,
|
|
107 float * level, float bias);
|
|
108 int ac3_block (ac3_state_t * state);
|