annotate liba52/a52_internal.h @ 2351:35b1d0c69edd libavcodec

plane predicted non-interlacd rgb decodeing fix
author michael
date Sun, 14 Nov 2004 15:46:34 +0000
parents 6a6dbba3da95
children 0b546eab515d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
1 /*
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
2 * a52_internal.h
1072
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
5 *
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
6 * This file is part of a52dec, a free ATSC A-52 stream decoder.
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
7 * See http://liba52.sourceforge.net/ for updates.
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
8 *
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
9 * a52dec is free software; you can redistribute it and/or modify
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
12 * (at your option) any later version.
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
13 *
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
14 * a52dec is distributed in the hope that it will be useful,
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
17 * GNU General Public License for more details.
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
18 *
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
22 */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
23
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
24 typedef struct {
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
25 uint8_t bai; /* fine SNR offset, fast gain */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
26 uint8_t deltbae; /* delta bit allocation exists */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
27 int8_t deltba[50]; /* per-band delta bit allocation */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
28 } ba_t;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
29
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
30 typedef struct {
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
31 uint8_t exp[256]; /* decoded channel exponents */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
32 int8_t bap[256]; /* derived channel bit allocation */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
33 } expbap_t;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
34
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
35 struct a52_state_s {
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
36 uint8_t fscod; /* sample rate */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
37 uint8_t halfrate; /* halfrate factor */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
38 uint8_t acmod; /* coded channels */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
39 uint8_t lfeon; /* coded lfe channel */
1072
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
40 level_t clev; /* centre channel mix level */
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
41 level_t slev; /* surround channels mix level */
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
42
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
43 int output; /* type of output */
1072
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
44 level_t level; /* output level */
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
45 sample_t bias; /* output bias */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
46
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
47 int dynrnge; /* apply dynamic range */
1072
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
48 level_t dynrng; /* dynamic range */
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
49 void * dynrngdata; /* dynamic range callback funtion and data */
1072
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
50 level_t (* dynrngcall) (level_t range, void * dynrngdata);
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
51
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
52 uint8_t chincpl; /* channel coupled */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
53 uint8_t phsflginu; /* phase flags in use (stereo only) */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
54 uint8_t cplstrtmant; /* coupling channel start mantissa */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
55 uint8_t cplendmant; /* coupling channel end mantissa */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
56 uint32_t cplbndstrc; /* coupling band structure */
1072
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
57 level_t cplco[5][18]; /* coupling coordinates */
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
58
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
59 /* derived information */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
60 uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
61 uint8_t ncplbnd; /* number of coupling bands */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
62
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
63 uint8_t rematflg; /* stereo rematrixing */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
64
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
65 uint8_t endmant[5]; /* channel end mantissa */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
66
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
67 uint16_t bai; /* bit allocation information */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
68
1072
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
69 uint32_t * buffer_start;
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
70 uint16_t lfsr_state; /* dither state */
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
71 uint32_t bits_left;
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
72 uint32_t current_word;
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
73
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
74 uint8_t csnroffst; /* coarse SNR offset */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
75 ba_t cplba; /* coupling bit allocation parameters */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
76 ba_t ba[5]; /* channel bit allocation parameters */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
77 ba_t lfeba; /* lfe bit allocation parameters */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
78
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
79 uint8_t cplfleak; /* coupling fast leak init */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
80 uint8_t cplsleak; /* coupling slow leak init */
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
81
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
82 expbap_t cpl_expbap;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
83 expbap_t fbw_expbap[5];
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
84 expbap_t lfe_expbap;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
85
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
86 sample_t * samples;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
87 int downmixed;
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
88 };
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
89
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
90 #define LEVEL_PLUS6DB 2.0
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
91 #define LEVEL_PLUS3DB 1.4142135623730951
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
92 #define LEVEL_3DB 0.7071067811865476
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
93 #define LEVEL_45DB 0.5946035575013605
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
94 #define LEVEL_6DB 0.5
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
95
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
96 #define EXP_REUSE (0)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
97 #define EXP_D15 (1)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
98 #define EXP_D25 (2)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
99 #define EXP_D45 (3)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
100
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
101 #define DELTA_BIT_REUSE (0)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
102 #define DELTA_BIT_NEW (1)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
103 #define DELTA_BIT_NONE (2)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
104 #define DELTA_BIT_RESERVED (3)
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
105
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
106 void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
107 int start, int end, int fastleak, int slowleak,
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
108 expbap_t * expbap);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
109
1072
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
110 int a52_downmix_init (int input, int flags, level_t * level,
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
111 level_t clev, level_t slev);
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
112 int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
113 level_t clev, level_t slev);
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
114 void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
1072
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
115 level_t clev, level_t slev);
332
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
116 void a52_upmix (sample_t * samples, int acmod, int output);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
117
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
118 void a52_imdct_init (uint32_t mm_accel);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
119 void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias);
207cc56d18f8 * add support for liba52
kabi
parents:
diff changeset
120 void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias);
1193
6a6dbba3da95 Utility functions (CRC calc & float->int converters)
arpi_esp
parents: 1072
diff changeset
121 //extern void (* a52_imdct_256) (sample_t data[], sample_t delay[], sample_t bias);
6a6dbba3da95 Utility functions (CRC calc & float->int converters)
arpi_esp
parents: 1072
diff changeset
122 //extern void (* a52_imdct_512) (sample_t data[], sample_t delay[], sample_t bias);
1072
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
123
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
124 #define ROUND(x) ((int)((x) + ((x) > 0 ? 0.5 : -0.5)))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
125
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
126 #ifndef LIBA52_FIXED
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
127
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
128 typedef sample_t quantizer_t;
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
129 #define SAMPLE(x) (x)
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
130 #define LEVEL(x) (x)
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
131 #define MUL(a,b) ((a) * (b))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
132 #define MUL_L(a,b) ((a) * (b))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
133 #define MUL_C(a,b) ((a) * (b))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
134 #define DIV(a,b) ((a) / (b))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
135 #define BIAS(x) ((x) + bias)
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
136
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
137 #else /* LIBA52_FIXED */
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
138
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
139 typedef int16_t quantizer_t;
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
140 #define SAMPLE(x) (sample_t)((x) * (1 << 30))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
141 #define LEVEL(x) (level_t)((x) * (1 << 26))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
142
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
143 #if 0
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
144 #define MUL(a,b) ((int)(((int64_t)(a) * (b) + (1 << 29)) >> 30))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
145 #define MUL_L(a,b) ((int)(((int64_t)(a) * (b) + (1 << 25)) >> 26))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
146 #elif 1
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
147 #define MUL(a,b) \
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
148 ({ int32_t _ta=(a), _tb=(b), _tc; \
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
149 _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)(((_tc >> 14))+ (((_ta >> 16)*(_tb >> 16)) << 2 )); })
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
150 #define MUL_L(a,b) \
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
151 ({ int32_t _ta=(a), _tb=(b), _tc; \
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
152 _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)((_tc >> 10) + (((_ta >> 16)*(_tb >> 16)) << 6)); })
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
153 #else
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
154 #define MUL(a,b) (((a) >> 15) * ((b) >> 15))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
155 #define MUL_L(a,b) (((a) >> 13) * ((b) >> 13))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
156 #endif
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
157
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
158 #define MUL_C(a,b) MUL_L (a, LEVEL (b))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
159 #define DIV(a,b) ((((int64_t)LEVEL (a)) << 26) / (b))
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
160 #define BIAS(x) (x)
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
161
68d0a38bd802 * sync with main liba52 sources
kabi
parents: 332
diff changeset
162 #endif