3 * Copyright (C) 2000-2001 Michel Lespinasse <walken@zoy.org>
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
6 * This file is part of a52dec, a free ATSC A-52 stream decoder.
7 * See http://liba52.sourceforge.net/ for updates.
9 * Modified for use with MPlayer, changes contained in liba52_changes.diff.
10 * detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
13 * a52dec is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * a52dec is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 typedef float sample_t
;
34 typedef double sample_t
;
37 typedef struct a52_ba_s
{
38 uint16_t fsnroffst
; /* fine SNR offset */
39 uint16_t fgaincod
; /* fast gain */
40 uint16_t deltbae
; /* delta bit allocation exists */
41 int8_t deltba
[50]; /* per-band delta bit allocation */
44 typedef struct a52_state_s
{
45 uint8_t fscod
; /* sample rate */
46 uint8_t halfrate
; /* halfrate factor */
47 uint8_t acmod
; /* coded channels */
48 sample_t clev
; /* centre channel mix level */
49 sample_t slev
; /* surround channels mix level */
50 uint8_t lfeon
; /* coded lfe channel */
52 int output
; /* type of output */
53 sample_t level
; /* output level */
54 sample_t bias
; /* output bias */
56 int dynrnge
; /* apply dynamic range */
57 sample_t dynrng
; /* dynamic range */
58 void * dynrngdata
; /* dynamic range callback funtion and data */
59 sample_t (* dynrngcall
) (sample_t range
, void * dynrngdata
);
61 uint16_t cplinu
; /* coupling in use */
62 uint16_t chincpl
[5]; /* channel coupled */
63 uint16_t phsflginu
; /* phase flags in use (stereo only) */
64 uint16_t cplbndstrc
[18]; /* coupling band structure */
65 uint16_t cplstrtmant
; /* coupling channel start mantissa */
66 uint16_t cplendmant
; /* coupling channel end mantissa */
67 sample_t cplco
[5][18]; /* coupling coordinates */
69 /* derived information */
70 uint16_t cplstrtbnd
; /* coupling start band (for bit allocation) */
71 uint16_t ncplbnd
; /* number of coupling bands */
73 uint16_t rematflg
[4]; /* stereo rematrixing */
75 uint16_t endmant
[5]; /* channel end mantissa */
77 uint8_t cpl_exp
[256]; /* decoded coupling channel exponents */
78 uint8_t fbw_exp
[5][256]; /* decoded channel exponents */
79 uint8_t lfe_exp
[7]; /* decoded lfe channel exponents */
81 uint16_t sdcycod
; /* slow decay */
82 uint16_t fdcycod
; /* fast decay */
83 uint16_t sgaincod
; /* slow gain */
84 uint16_t dbpbcod
; /* dB per bit - encodes the dbknee value */
85 uint16_t floorcod
; /* masking floor */
87 uint16_t csnroffst
; /* coarse SNR offset */
88 a52_ba_t cplba
; /* coupling bit allocation parameters */
89 a52_ba_t ba
[5]; /* channel bit allocation parameters */
90 a52_ba_t lfeba
; /* lfe bit allocation parameters */
92 uint16_t cplfleak
; /* coupling fast leak init */
93 uint16_t cplsleak
; /* coupling slow leak init */
95 /* derived bit allocation information */
96 int8_t fbw_bap
[5][256];
101 #define A52_CHANNEL 0
109 #define A52_CHANNEL1 8
110 #define A52_CHANNEL2 9
112 #define A52_CHANNEL_MASK 15
115 #define A52_ADJUST_LEVEL 32
117 sample_t
* a52_init (uint32_t mm_accel
);
118 int a52_syncinfo (uint8_t * buf
, int * flags
,
119 int * sample_rate
, int * bit_rate
);
120 int a52_frame (a52_state_t
* state
, uint8_t * buf
, int * flags
,
121 sample_t
* level
, sample_t bias
);
122 void a52_dynrng (a52_state_t
* state
,
123 sample_t (* call
) (sample_t
, void *), void * data
);
124 int a52_block (a52_state_t
* state
, sample_t
* samples
);
126 void* a52_resample_init(uint32_t mm_accel
,int flags
,int chans
);
127 extern int (* a52_resample
) (float * _f
, int16_t * s16
);
129 uint16_t crc16_block(uint8_t *data
,uint32_t num_bytes
);