Mercurial > libavcodec.hg
annotate ac3dec.c @ 5330:37de2d864f03 libavcodec
use random number generator from libavutil
author | jbr |
---|---|
date | Sat, 14 Jul 2007 23:57:05 +0000 |
parents | 06e7dda51f65 |
children | b24bcdd0ae86 |
rev | line source |
---|---|
5328 | 1 /* |
2 * AC-3 Audio Decoder | |
5316
a09b700fcfca
AC-3 decoder, soc revision 56, Aug 17 14:21:58 2006 UTC by cloud9
jbr
parents:
5315
diff
changeset
|
3 * This code is developed as part of Google Summer of Code 2006 Program. |
a09b700fcfca
AC-3 decoder, soc revision 56, Aug 17 14:21:58 2006 UTC by cloud9
jbr
parents:
5315
diff
changeset
|
4 * |
5328 | 5 * Copyright (c) 2006 Kartikey Mahendra BHATT (bhattkm at gmail dot com). |
5316
a09b700fcfca
AC-3 decoder, soc revision 56, Aug 17 14:21:58 2006 UTC by cloud9
jbr
parents:
5315
diff
changeset
|
6 * |
5323
4ba6d8132f36
AC-3 decoder, soc revision 109, Sep 22 22:42:54 2006 UTC by banan
jbr
parents:
5322
diff
changeset
|
7 * For exponent decoding the code is inspired by the code in liba52 by |
4ba6d8132f36
AC-3 decoder, soc revision 109, Sep 22 22:42:54 2006 UTC by banan
jbr
parents:
5322
diff
changeset
|
8 * Michel Lespinasse and Aaron Holtzman. |
5316
a09b700fcfca
AC-3 decoder, soc revision 56, Aug 17 14:21:58 2006 UTC by cloud9
jbr
parents:
5315
diff
changeset
|
9 * http://liba52.sourceforge.net |
a09b700fcfca
AC-3 decoder, soc revision 56, Aug 17 14:21:58 2006 UTC by cloud9
jbr
parents:
5315
diff
changeset
|
10 * |
5328 | 11 * This file is part of FFmpeg. |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
12 * |
5328 | 13 * FFmpeg is free software; you can redistribute it and/or |
5329 | 14 * modify it under the terms of the GNU General Public |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
15 * License as published by the Free Software Foundation; either |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
16 * version 2 of the License, or (at your option) any later version. |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
17 * |
5328 | 18 * FFmpeg is distributed in the hope that it will be useful, |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5326 | 21 * General Public License for more details. |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
22 * |
5326 | 23 * You should have received a copy of the GNU General Public |
5328 | 24 * License along with FFmpeg; if not, write to the Free Software |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
26 */ |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
27 |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
28 #include <stdio.h> |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
29 #include <stddef.h> |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
30 #include <math.h> |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
31 #include <string.h> |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
32 |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
33 #define ALT_BITSTREAM_READER |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
34 |
5315
31033309ebc9
AC-3 decoder, soc revision 55, Aug 17 12:25:24 2006 UTC by cloud9
jbr
parents:
5314
diff
changeset
|
35 #include "avcodec.h" |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
36 #include "ac3tab.h" |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
37 #include "bitstream.h" |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
38 #include "dsputil.h" |
5330 | 39 #include "random.h" |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
40 |
5325
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
41 static const int nfchans_tbl[8] = { 2, 1, 2, 3, 3, 4, 4, 5 }; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
42 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
43 /* table for exponent to scale_factor mapping |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
44 * scale_factor[i] = 2 ^ -(i + 15) |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
45 */ |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
46 static float scale_factors[25]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
47 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
48 static int16_t psdtab[25]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
49 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
50 static int8_t exp_1[128]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
51 static int8_t exp_2[128]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
52 static int8_t exp_3[128]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
53 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
54 static int16_t l3_quantizers_1[32]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
55 static int16_t l3_quantizers_2[32]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
56 static int16_t l3_quantizers_3[32]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
57 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
58 static int16_t l5_quantizers_1[128]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
59 static int16_t l5_quantizers_2[128]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
60 static int16_t l5_quantizers_3[128]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
61 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
62 static int16_t l7_quantizers[7]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
63 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
64 static int16_t l11_quantizers_1[128]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
65 static int16_t l11_quantizers_2[128]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
66 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
67 static int16_t l15_quantizers[15]; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
68 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
69 static const uint8_t qntztab[16] = { 0, 5, 7, 3, 7, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16 }; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
70 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
71 /* Adjustmens in dB gain */ |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
72 #define LEVEL_MINUS_3DB 0.7071067811865476 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
73 #define LEVEL_MINUS_4POINT5DB 0.5946035575013605 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
74 #define LEVEL_MINUS_6DB 0.5000000000000000 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
75 #define LEVEL_PLUS_3DB 1.4142135623730951 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
76 #define LEVEL_PLUS_6DB 2.0000000000000000 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
77 #define LEVEL_ZERO 0.0000000000000000 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
78 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
79 static const float clevs[4] = { LEVEL_MINUS_3DB, LEVEL_MINUS_4POINT5DB, |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
80 LEVEL_MINUS_6DB, LEVEL_MINUS_4POINT5DB }; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
81 |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
82 static const float slevs[4] = { LEVEL_MINUS_3DB, LEVEL_MINUS_6DB, LEVEL_ZERO, LEVEL_MINUS_6DB }; |
0d963101e0d7
AC-3 decoder, soc revision 402, Jul 14 13:45:14 2007 UTC by jbr
jbr
parents:
5324
diff
changeset
|
83 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
84 #define N 512 /* constant for IMDCT Block size */ |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
85 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
86 #define MAX_CHANNELS 6 |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
87 #define BLOCK_SIZE 256 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
88 #define AUDIO_BLOCKS 6 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
89 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
90 /* Exponent strategies. */ |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
91 #define AC3_EXPSTR_D15 0x01 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
92 #define AC3_EXPSTR_D25 0x02 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
93 #define AC3_EXPSTR_D45 0x03 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
94 #define AC3_EXPSTR_REUSE 0x00 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
95 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
96 /* Bit allocation strategies. */ |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
97 #define AC3_DBASTR_NEW 0x01 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
98 #define AC3_DBASTR_NONE 0x02 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
99 #define AC3_DBASTR_RESERVED 0x03 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
100 #define AC3_DBASTR_REUSE 0x00 |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
101 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
102 /* Output and input configurations. */ |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
103 #define AC3_OUTPUT_UNMODIFIED 0x01 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
104 #define AC3_OUTPUT_MONO 0x02 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
105 #define AC3_OUTPUT_STEREO 0x04 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
106 #define AC3_OUTPUT_DOLBY 0x08 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
107 #define AC3_OUTPUT_LFEON 0x10 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
108 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
109 #define AC3_INPUT_DUALMONO 0x00 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
110 #define AC3_INPUT_MONO 0x01 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
111 #define AC3_INPUT_STEREO 0x02 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
112 #define AC3_INPUT_3F 0x03 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
113 #define AC3_INPUT_2F_1R 0x04 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
114 #define AC3_INPUT_3F_1R 0x05 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
115 #define AC3_INPUT_2F_2R 0x06 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
116 #define AC3_INPUT_3F_2R 0x07 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
117 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
118 typedef struct { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
119 uint16_t crc1; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
120 uint8_t fscod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
121 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
122 uint8_t acmod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
123 uint8_t cmixlev; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
124 uint8_t surmixlev; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
125 uint8_t dsurmod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
126 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
127 uint8_t blksw; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
128 uint8_t dithflag; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
129 uint8_t cplinu; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
130 uint8_t chincpl; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
131 uint8_t phsflginu; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
132 uint8_t cplbegf; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
133 uint8_t cplendf; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
134 uint8_t cplcoe; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
135 uint32_t cplbndstrc; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
136 uint8_t rematstr; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
137 uint8_t rematflg; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
138 uint8_t cplexpstr; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
139 uint8_t lfeexpstr; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
140 uint8_t chexpstr[5]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
141 uint8_t sdcycod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
142 uint8_t fdcycod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
143 uint8_t sgaincod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
144 uint8_t dbpbcod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
145 uint8_t floorcod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
146 uint8_t csnroffst; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
147 uint8_t cplfsnroffst; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
148 uint8_t cplfgaincod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
149 uint8_t fsnroffst[5]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
150 uint8_t fgaincod[5]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
151 uint8_t lfefsnroffst; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
152 uint8_t lfefgaincod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
153 uint8_t cplfleak; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
154 uint8_t cplsleak; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
155 uint8_t cpldeltbae; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
156 uint8_t deltbae[5]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
157 uint8_t cpldeltnseg; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
158 uint8_t cpldeltoffst[8]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
159 uint8_t cpldeltlen[8]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
160 uint8_t cpldeltba[8]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
161 uint8_t deltnseg[5]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
162 uint8_t deltoffst[5][8]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
163 uint8_t deltlen[5][8]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
164 uint8_t deltba[5][8]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
165 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
166 /* Derived Attributes. */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
167 int sampling_rate; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
168 int bit_rate; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
169 int frame_size; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
170 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
171 int nfchans; //number of channels |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
172 int lfeon; //lfe channel in use |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
173 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
174 float dynrng; //dynamic range gain |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
175 float dynrng2; //dynamic range gain for 1+1 mode |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
176 float chcoeffs[6]; //normalized channel coefficients |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
177 float cplco[5][18]; //coupling coordinates |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
178 int ncplbnd; //number of coupling bands |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
179 int ncplsubnd; //number of coupling sub bands |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
180 int cplstrtmant; //coupling start mantissa |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
181 int cplendmant; //coupling end mantissa |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
182 int endmant[5]; //channel end mantissas |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
183 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
184 uint8_t dcplexps[256]; //decoded coupling exponents |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
185 uint8_t dexps[5][256]; //decoded fbw channel exponents |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
186 uint8_t dlfeexps[256]; //decoded lfe channel exponents |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
187 uint8_t cplbap[256]; //coupling bit allocation pointers |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
188 uint8_t bap[5][256]; //fbw channel bit allocation pointers |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
189 uint8_t lfebap[256]; //lfe channel bit allocation pointers |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
190 |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
191 int blkoutput; //output configuration for block |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
192 |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
193 DECLARE_ALIGNED_16(float, transform_coeffs[MAX_CHANNELS][BLOCK_SIZE]); //transform coefficients |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
194 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
195 /* For IMDCT. */ |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
196 MDCTContext imdct_512; //for 512 sample imdct transform |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
197 MDCTContext imdct_256; //for 256 sample imdct transform |
5317
6d81881f257f
AC-3 decoder, soc revision 57, Aug 19 12:44:38 2006 UTC by cloud9
jbr
parents:
5316
diff
changeset
|
198 DSPContext dsp; //for optimization |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
199 |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
200 DECLARE_ALIGNED_16(float, output[MAX_CHANNELS][BLOCK_SIZE]); //output after imdct transform and windowing |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
201 DECLARE_ALIGNED_16(float, delay[MAX_CHANNELS][BLOCK_SIZE]); //delay - added to the next block |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
202 DECLARE_ALIGNED_16(float, tmp_imdct[BLOCK_SIZE]); //temporary storage for imdct transform |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
203 DECLARE_ALIGNED_16(float, tmp_output[BLOCK_SIZE * 2]); //temporary storage for output before windowing |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
204 DECLARE_ALIGNED_16(float, window[BLOCK_SIZE]); //window coefficients |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
205 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
206 /* Miscellaneous. */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
207 GetBitContext gb; |
5330 | 208 AVRandomState dith_state; //for dither generation |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
209 } AC3DecodeContext; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
210 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
211 /*********** BEGIN INIT HELPER FUNCTIONS ***********/ |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
212 /** |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
213 * Generate a Kaiser-Bessel Derived Window. |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
214 */ |
5320
3348a76efb67
AC-3 decoder, soc revision 70, Aug 31 18:04:23 2006 UTC by banan
jbr
parents:
5319
diff
changeset
|
215 static void ac3_window_init(float *window) |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
216 { |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
217 int i, j; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
218 double sum = 0.0, bessel, tmp; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
219 double local_window[256]; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
220 double alpha2 = (5.0 * M_PI / 256.0) * (5.0 * M_PI / 256.0); |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
221 |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
222 for (i = 0; i < 256; i++) { |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
223 tmp = i * (256 - i) * alpha2; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
224 bessel = 1.0; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
225 for (j = 100; j > 0; j--) /* defaul to 100 iterations */ |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
226 bessel = bessel * tmp / (j * j) + 1; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
227 sum += bessel; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
228 local_window[i] = sum; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
229 } |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
230 |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
231 sum++; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
232 for (i = 0; i < 256; i++) |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
233 window[i] = sqrt(local_window[i] / sum); |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
234 } |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
235 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
236 /* |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
237 * Generate quantizer tables. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
238 */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
239 static void generate_quantizers_table(int16_t quantizers[], int level, int length) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
240 { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
241 int i; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
242 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
243 for (i = 0; i < length; i++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
244 quantizers[i] = ((2 * i - level + 1) << 15) / level; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
245 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
246 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
247 static void generate_quantizers_table_1(int16_t quantizers[], int level, int length1, int length2, int size) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
248 { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
249 int i, j; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
250 int16_t v; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
251 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
252 for (i = 0; i < length1; i++) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
253 v = ((2 * i - level + 1) << 15) / level; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
254 for (j = 0; j < length2; j++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
255 quantizers[i * length2 + j] = v; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
256 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
257 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
258 for (i = length1 * length2; i < size; i++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
259 quantizers[i] = 0; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
260 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
261 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
262 static void generate_quantizers_table_2(int16_t quantizers[], int level, int length1, int length2, int size) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
263 { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
264 int i, j; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
265 int16_t v; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
266 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
267 for (i = 0; i < length1; i++) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
268 v = ((2 * (i % level) - level + 1) << 15) / level; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
269 for (j = 0; j < length2; j++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
270 quantizers[i * length2 + j] = v; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
271 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
272 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
273 for (i = length1 * length2; i < size; i++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
274 quantizers[i] = 0; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
275 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
276 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
277 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
278 static void generate_quantizers_table_3(int16_t quantizers[], int level, int length1, int length2, int size) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
279 { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
280 int i, j; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
281 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
282 for (i = 0; i < length1; i++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
283 for (j = 0; j < length2; j++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
284 quantizers[i * length2 + j] = ((2 * (j % level) - level + 1) << 15) / level; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
285 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
286 for (i = length1 * length2; i < size; i++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
287 quantizers[i] = 0; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
288 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
289 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
290 /* |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
291 * Initialize tables at runtime. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
292 */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
293 static void ac3_tables_init(void) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
294 { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
295 int i, j, k, l, v; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
296 /* compute bndtab and masktab from bandsz */ |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
297 k = 0; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
298 l = 0; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
299 for(i=0;i<50;i++) { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
300 bndtab[i] = l; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
301 v = bndsz[i]; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
302 for(j=0;j<v;j++) masktab[k++]=i; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
303 l += v; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
304 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
305 masktab[253] = masktab[254] = masktab[255] = 0; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
306 bndtab[50] = 0; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
307 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
308 /* PSD Table For Mapping Exponents To PSD. */ |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
309 for (i = 0; i < 25; i++) |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
310 psdtab[i] = 3072 - (i << 7); |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
311 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
312 /* Exponent Decoding Tables */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
313 for (i = 0; i < 5; i++) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
314 v = i - 2; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
315 for (j = 0; j < 25; j++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
316 exp_1[i * 25 + j] = v; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
317 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
318 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
319 for (i = 0; i < 25; i++) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
320 v = (i % 5) - 2; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
321 for (j = 0; j < 5; j++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
322 exp_2[i * 5 + j] = v; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
323 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
324 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
325 for (i = 0; i < 25; i++) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
326 v = -2; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
327 for (j = 0; j < 5; j++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
328 exp_3[i * 5 + j] = v++; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
329 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
330 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
331 for (i = 125; i < 128; i++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
332 exp_1[i] = exp_2[i] = exp_3[i] = 25; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
333 /* End Exponent Decoding Tables */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
334 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
335 /* Quantizer ungrouping tables. */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
336 // for level-3 quantizers |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
337 generate_quantizers_table_1(l3_quantizers_1, 3, 3, 9, 32); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
338 generate_quantizers_table_2(l3_quantizers_2, 3, 9, 3, 32); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
339 generate_quantizers_table_3(l3_quantizers_3, 3, 9, 3, 32); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
340 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
341 //for level-5 quantizers |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
342 generate_quantizers_table_1(l5_quantizers_1, 5, 5, 25, 128); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
343 generate_quantizers_table_2(l5_quantizers_2, 5, 25, 5, 128); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
344 generate_quantizers_table_3(l5_quantizers_3, 5, 25, 5, 128); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
345 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
346 //for level-7 quantizers |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
347 generate_quantizers_table(l7_quantizers, 7, 7); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
348 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
349 //for level-4 quantizers |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
350 generate_quantizers_table_2(l11_quantizers_1, 11, 11, 11, 128); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
351 generate_quantizers_table_3(l11_quantizers_2, 11, 11, 11, 128); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
352 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
353 //for level-15 quantizers |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
354 generate_quantizers_table(l15_quantizers, 15, 15); |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
355 /* End Quantizer ungrouping tables. */ |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
356 |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
357 //generate scale factors |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
358 for (i = 0; i < 25; i++) |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
359 scale_factors[i] = pow(2.0, -(i + 15)); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
360 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
361 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
362 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
363 static int ac3_decode_init(AVCodecContext *avctx) |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
364 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
365 AC3DecodeContext *ctx = avctx->priv_data; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
366 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
367 ac3_tables_init(); |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
368 ff_mdct_init(&ctx->imdct_256, 8, 1); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
369 ff_mdct_init(&ctx->imdct_512, 9, 1); |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
370 ac3_window_init(ctx->window); |
5317
6d81881f257f
AC-3 decoder, soc revision 57, Aug 19 12:44:38 2006 UTC by cloud9
jbr
parents:
5316
diff
changeset
|
371 dsputil_init(&ctx->dsp, avctx); |
5330 | 372 av_init_random(0, &ctx->dith_state); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
373 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
374 return 0; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
375 } |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
376 /*********** END INIT FUNCTIONS ***********/ |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
377 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
378 /* Synchronize to ac3 bitstream. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
379 * This function searches for the syncword '0xb77'. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
380 * |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
381 * @param buf Pointer to "probable" ac3 bitstream buffer |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
382 * @param buf_size Size of buffer |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
383 * @return Returns the position where syncword is found, -1 if no syncword is found |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
384 */ |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
385 static int ac3_synchronize(uint8_t *buf, int buf_size) |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
386 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
387 int i; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
388 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
389 for (i = 0; i < buf_size - 1; i++) |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
390 if (buf[i] == 0x0b && buf[i + 1] == 0x77) |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
391 return i; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
392 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
393 return -1; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
394 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
395 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
396 /* Parse the 'sync_info' from the ac3 bitstream. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
397 * This function extracts the sync_info from ac3 bitstream. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
398 * GetBitContext within AC3DecodeContext must point to |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
399 * start of the synchronized ac3 bitstream. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
400 * |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
401 * @param ctx AC3DecodeContext |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
402 * @return Returns framesize, returns 0 if fscod, frmsizecod or bsid is not valid |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
403 */ |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
404 static int ac3_parse_sync_info(AC3DecodeContext *ctx) |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
405 { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
406 GetBitContext *gb = &ctx->gb; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
407 int frmsizecod, bsid; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
408 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
409 skip_bits(gb, 16); //skip the sync_word, sync_info->sync_word = get_bits(gb, 16); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
410 ctx->crc1 = get_bits(gb, 16); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
411 ctx->fscod = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
412 if (ctx->fscod == 0x03) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
413 return 0; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
414 frmsizecod = get_bits(gb, 6); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
415 if (frmsizecod >= 38) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
416 return 0; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
417 ctx->sampling_rate = ac3_freqs[ctx->fscod]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
418 ctx->bit_rate = ac3_bitratetab[frmsizecod >> 1]; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
419 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
420 /* we include it here in order to determine validity of ac3 frame */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
421 bsid = get_bits(gb, 5); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
422 if (bsid > 0x08) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
423 return 0; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
424 skip_bits(gb, 3); //skip the bsmod, bsi->bsmod = get_bits(gb, 3); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
425 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
426 switch (ctx->fscod) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
427 case 0x00: |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
428 ctx->frame_size = 4 * ctx->bit_rate; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
429 return ctx->frame_size; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
430 case 0x01: |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
431 ctx->frame_size = 2 * (320 * ctx->bit_rate / 147 + (frmsizecod & 1)); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
432 return ctx->frame_size; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
433 case 0x02: |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
434 ctx->frame_size = 6 * ctx->bit_rate; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
435 return ctx->frame_size; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
436 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
437 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
438 /* never reached */ |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
439 return 0; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
440 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
441 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
442 /* Parse bsi from ac3 bitstream. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
443 * This function extracts the bitstream information (bsi) from ac3 bitstream. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
444 * |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
445 * @param ctx AC3DecodeContext after processed by ac3_parse_sync_info |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
446 */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
447 static void ac3_parse_bsi(AC3DecodeContext *ctx) |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
448 { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
449 GetBitContext *gb = &ctx->gb; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
450 int i; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
451 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
452 ctx->cmixlev = 0; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
453 ctx->surmixlev = 0; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
454 ctx->dsurmod = 0; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
455 ctx->nfchans = 0; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
456 ctx->cpldeltbae = AC3_DBASTR_NONE; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
457 ctx->cpldeltnseg = 0; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
458 for (i = 0; i < 5; i++) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
459 ctx->deltbae[i] = AC3_DBASTR_NONE; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
460 ctx->deltnseg[i] = 0; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
461 } |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
462 ctx->dynrng = 1.0; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
463 ctx->dynrng2 = 1.0; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
464 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
465 ctx->acmod = get_bits(gb, 3); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
466 ctx->nfchans = nfchans_tbl[ctx->acmod]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
467 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
468 if (ctx->acmod & 0x01 && ctx->acmod != 0x01) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
469 ctx->cmixlev = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
470 if (ctx->acmod & 0x04) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
471 ctx->surmixlev = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
472 if (ctx->acmod == 0x02) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
473 ctx->dsurmod = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
474 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
475 ctx->lfeon = get_bits1(gb); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
476 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
477 i = !(ctx->acmod); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
478 do { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
479 skip_bits(gb, 5); //skip dialog normalization |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
480 if (get_bits1(gb)) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
481 skip_bits(gb, 8); //skip compression |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
482 if (get_bits1(gb)) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
483 skip_bits(gb, 8); //skip language code |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
484 if (get_bits1(gb)) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
485 skip_bits(gb, 7); //skip audio production information |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
486 } while (i--); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
487 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
488 skip_bits(gb, 2); //skip copyright bit and original bitstream bit |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
489 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
490 if (get_bits1(gb)) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
491 skip_bits(gb, 14); //skip timecode1 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
492 if (get_bits1(gb)) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
493 skip_bits(gb, 14); //skip timecode2 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
494 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
495 if (get_bits1(gb)) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
496 i = get_bits(gb, 6); //additional bsi length |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
497 do { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
498 skip_bits(gb, 8); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
499 } while(i--); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
500 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
501 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
502 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
503 /* Decodes the grouped exponents. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
504 * This function decodes the coded exponents according to exponent strategy |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
505 * and stores them in the decoded exponents buffer. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
506 * |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
507 * @param gb GetBitContext which points to start of coded exponents |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
508 * @param expstr Exponent coding strategy |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
509 * @param ngrps Number of grouped exponetns |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
510 * @param absexp Absolute exponent |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
511 * @param dexps Decoded exponents are stored in dexps |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
512 * @return Returns 0 if exponents are decoded successfully, -1 if error occurs |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
513 */ |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
514 static int decode_exponents(GetBitContext *gb, int expstr, int ngrps, uint8_t absexp, uint8_t *dexps) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
515 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
516 int exps; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
517 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
518 while (ngrps--) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
519 exps = get_bits(gb, 7); |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
520 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
521 absexp += exp_1[exps]; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
522 if (absexp > 24) { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
523 av_log(NULL, AV_LOG_ERROR, "Absolute Exponent > 24, ngrp = %d\n", ngrps); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
524 return -ngrps; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
525 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
526 switch (expstr) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
527 case AC3_EXPSTR_D45: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
528 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
529 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
530 case AC3_EXPSTR_D25: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
531 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
532 case AC3_EXPSTR_D15: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
533 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
534 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
535 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
536 absexp += exp_2[exps]; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
537 if (absexp > 24) { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
538 av_log(NULL, AV_LOG_ERROR, "Absolute Exponent > 24, ngrp = %d\n", ngrps); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
539 return -ngrps; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
540 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
541 switch (expstr) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
542 case AC3_EXPSTR_D45: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
543 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
544 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
545 case AC3_EXPSTR_D25: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
546 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
547 case AC3_EXPSTR_D15: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
548 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
549 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
550 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
551 absexp += exp_3[exps]; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
552 if (absexp > 24) { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
553 av_log(NULL, AV_LOG_ERROR, "Absolute Exponent > 24, ngrp = %d\n", ngrps); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
554 return -ngrps; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
555 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
556 switch (expstr) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
557 case AC3_EXPSTR_D45: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
558 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
559 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
560 case AC3_EXPSTR_D25: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
561 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
562 case AC3_EXPSTR_D15: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
563 *(dexps++) = absexp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
564 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
565 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
566 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
567 return 0; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
568 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
569 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
570 /*********** HELPER FUNCTIONS FOR BIT ALLOCATION ***********/ |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
571 static inline int logadd(int a, int b) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
572 { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
573 int c = a - b; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
574 int address; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
575 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
576 address = FFMIN((ABS(c) >> 1), 255); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
577 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
578 if (c >= 0) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
579 return (a + latab[address]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
580 else |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
581 return (b + latab[address]); |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
582 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
583 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
584 static inline int calc_lowcomp(int a, int b0, int b1, int bin) |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
585 { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
586 if (bin < 7) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
587 if ((b0 + 256) == b1) |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
588 a = 384; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
589 else if (b0 > b1) |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
590 a = FFMAX(0, (a - 64)); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
591 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
592 else if (bin < 20) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
593 if ((b0 + 256) == b1) |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
594 a = 320; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
595 else if (b0 > b1) |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
596 a = FFMAX(0, (a - 64)); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
597 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
598 else |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
599 a = FFMAX(0, (a - 128)); |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
600 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
601 return a; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
602 } |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
603 /*********** END HELPER FUNCTIONS FOR BIT ALLOCATION ***********/ |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
604 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
605 /* Performs bit allocation. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
606 * This function performs bit allocation for the requested chanenl. |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
607 */ |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
608 static void do_bit_allocation(AC3DecodeContext *ctx, int chnl) |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
609 { |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
610 int16_t psd[256], bndpsd[50], excite[50], mask[50], delta; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
611 int sdecay, fdecay, sgain, dbknee, floor; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
612 int lowcomp = 0, fgain = 0, snroffset = 0, fastleak = 0, slowleak = 0, do_delta = 0; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
613 int start = 0, end = 0, bin = 0, i = 0, j = 0, k = 0, lastbin = 0, bndstrt = 0; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
614 int bndend = 0, begin = 0, deltnseg = 0, band = 0, seg = 0, address = 0; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
615 int fscod = ctx->fscod; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
616 uint8_t *deltoffst = 0, *deltlen = 0, *deltba = 0; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
617 uint8_t *exps = 0, *bap = 0; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
618 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
619 /* initialization */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
620 sdecay = sdecaytab[ctx->sdcycod]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
621 fdecay = fdecaytab[ctx->fdcycod]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
622 sgain = sgaintab[ctx->sgaincod]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
623 dbknee = dbkneetab[ctx->dbpbcod]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
624 floor = floortab[ctx->floorcod]; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
625 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
626 if (chnl == 5) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
627 start = ctx->cplstrtmant; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
628 end = ctx->cplendmant; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
629 fgain = fgaintab[ctx->cplfgaincod]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
630 snroffset = (((ctx->csnroffst - 15) << 4) + ctx->cplfsnroffst) << 2; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
631 fastleak = (ctx->cplfleak << 8) + 768; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
632 slowleak = (ctx->cplsleak << 8) + 768; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
633 exps = ctx->dcplexps; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
634 bap = ctx->cplbap; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
635 if (ctx->cpldeltbae == AC3_DBASTR_NEW || ctx->deltbae == AC3_DBASTR_REUSE) { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
636 do_delta = 1; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
637 deltnseg = ctx->cpldeltnseg; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
638 deltoffst = ctx->cpldeltoffst; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
639 deltlen = ctx->cpldeltlen; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
640 deltba = ctx->cpldeltba; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
641 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
642 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
643 else if (chnl == 6) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
644 start = 0; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
645 end = 7; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
646 lowcomp = 0; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
647 fastleak = 0; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
648 slowleak = 0; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
649 fgain = fgaintab[ctx->lfefgaincod]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
650 snroffset = (((ctx->csnroffst - 15) << 4) + ctx->lfefsnroffst) << 2; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
651 exps = ctx->dlfeexps; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
652 bap = ctx->lfebap; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
653 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
654 else { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
655 start = 0; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
656 end = ctx->endmant[chnl]; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
657 lowcomp = 0; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
658 fastleak = 0; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
659 slowleak = 0; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
660 fgain = fgaintab[ctx->fgaincod[chnl]]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
661 snroffset = (((ctx->csnroffst - 15) << 4) + ctx->fsnroffst[chnl]) << 2; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
662 exps = ctx->dexps[chnl]; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
663 bap = ctx->bap[chnl]; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
664 if (ctx->deltbae[chnl] == AC3_DBASTR_NEW || ctx->deltbae[chnl] == AC3_DBASTR_REUSE) { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
665 do_delta = 1; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
666 deltnseg = ctx->deltnseg[chnl]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
667 deltoffst = ctx->deltoffst[chnl]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
668 deltlen = ctx->deltlen[chnl]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
669 deltba = ctx->deltba[chnl]; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
670 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
671 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
672 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
673 for (bin = start; bin < end; bin++) /* exponent mapping into psd */ |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
674 psd[bin] = psdtab[exps[bin]]; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
675 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
676 /* psd integration */ |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
677 j = start; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
678 k = masktab[start]; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
679 do { |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
680 lastbin = FFMIN((bndtab[k] + bndsz[k]), end); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
681 bndpsd[k] = psd[j]; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
682 j++; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
683 for (i = j; i < lastbin; i++) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
684 bndpsd[k] = logadd(bndpsd[k], psd[j]); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
685 j++; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
686 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
687 k++; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
688 } while (end > lastbin); |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
689 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
690 /* compute the excite function */ |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
691 bndstrt = masktab[start]; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
692 bndend = masktab[end - 1] + 1; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
693 if (bndstrt == 0) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
694 lowcomp = calc_lowcomp(lowcomp, bndpsd[0], bndpsd[1], 0); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
695 excite[0] = bndpsd[0] - fgain - lowcomp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
696 lowcomp = calc_lowcomp(lowcomp, bndpsd[1], bndpsd[2], 1); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
697 excite[1] = bndpsd[1] - fgain - lowcomp; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
698 begin = 7; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
699 for (bin = 2; bin < 7; bin++) { |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
700 if ((bndend != 7) || (bin != 6)) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
701 lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin + 1], bin); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
702 fastleak = bndpsd[bin] - fgain; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
703 slowleak = bndpsd[bin] - sgain; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
704 excite[bin] = fastleak - lowcomp; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
705 if ((bndend != 7) || (bin != 6)) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
706 if (bndpsd[bin] <= bndpsd[bin + 1]) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
707 begin = bin + 1; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
708 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
709 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
710 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
711 for (bin = begin; bin < FFMIN(bndend, 22); bin++) { |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
712 if ((bndend != 7) || (bin != 6)) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
713 lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin + 1], bin); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
714 fastleak -= fdecay; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
715 fastleak = FFMAX(fastleak, (bndpsd[bin] - fgain)); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
716 slowleak -= sdecay; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
717 slowleak = FFMAX(slowleak, (bndpsd[bin] - sgain)); |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
718 excite[bin] = FFMAX((fastleak - lowcomp), slowleak); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
719 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
720 begin = 22; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
721 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
722 else { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
723 begin = bndstrt; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
724 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
725 for (bin = begin; bin < bndend; bin++) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
726 fastleak -= fdecay; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
727 fastleak = FFMAX(fastleak, (bndpsd[bin] - fgain)); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
728 slowleak -= sdecay; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
729 slowleak = FFMAX(slowleak, (bndpsd[bin] - sgain)); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
730 excite[bin] = FFMAX(fastleak, slowleak); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
731 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
732 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
733 /* compute the masking curve */ |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
734 for (bin = bndstrt; bin < bndend; bin++) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
735 if (bndpsd[bin] < dbknee) |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
736 excite[bin] += ((dbknee - bndpsd[bin]) >> 2); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
737 mask[bin] = FFMAX(excite[bin], hth[bin][fscod]); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
738 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
739 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
740 /* apply the delta bit allocation */ |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
741 if (do_delta) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
742 band = 0; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
743 for (seg = 0; seg < deltnseg + 1; seg++) { |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
744 band += deltoffst[seg]; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
745 if (deltba[seg] >= 4) |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
746 delta = (deltba[seg] - 3) << 7; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
747 else |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
748 delta = (deltba[seg] - 4) << 7; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
749 for (k = 0; k < deltlen[seg]; k++) { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
750 mask[band] += delta; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
751 band++; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
752 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
753 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
754 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
755 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
756 /*compute the bit allocation */ |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
757 i = start; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
758 j = masktab[start]; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
759 do { |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
760 lastbin = FFMIN((bndtab[j] + bndsz[j]), end); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
761 mask[j] -= snroffset; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
762 mask[j] -= floor; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
763 if (mask[j] < 0) |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
764 mask[j] = 0; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
765 mask[j] &= 0x1fe0; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
766 mask[j] += floor; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
767 for (k = i; k < lastbin; k++) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
768 address = (psd[i] - mask[j]) >> 5; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
769 address = FFMIN(63, (FFMAX(0, address))); |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
770 bap[i] = baptab[address]; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
771 i++; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
772 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
773 j++; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
774 } while (end > lastbin); |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
775 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
776 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
777 /* Check if snroffsets are zero. */ |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
778 static int is_snr_offsets_zero(AC3DecodeContext *ctx) |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
779 { |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
780 int i; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
781 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
782 if ((ctx->csnroffst) || (ctx->cplinu && ctx->cplfsnroffst) || |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
783 (ctx->lfeon && ctx->lfefsnroffst)) |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
784 return 0; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
785 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
786 for (i = 0; i < ctx->nfchans; i++) |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
787 if (ctx->fsnroffst[i]) |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
788 return 0; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
789 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
790 return 1; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
791 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
792 |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
793 typedef struct { /* grouped mantissas for 3-level 5-leve and 11-level quantization */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
794 int16_t l3_quantizers[3]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
795 int16_t l5_quantizers[3]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
796 int16_t l11_quantizers[2]; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
797 int l3ptr; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
798 int l5ptr; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
799 int l11ptr; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
800 } mant_groups; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
801 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
802 #define TRANSFORM_COEFF(tc, m, e, f) (tc) = (m) * (f)[(e)] |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
803 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
804 /* Get the transform coefficients for coupling channel and uncouple channels. |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
805 * The coupling transform coefficients starts at the the cplstrtmant, which is |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
806 * equal to endmant[ch] for fbw channels. Hence we can uncouple channels before |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
807 * getting transform coefficients for the channel. |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
808 */ |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
809 static int get_transform_coeffs_cpling(AC3DecodeContext *ctx, mant_groups *m) |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
810 { |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
811 GetBitContext *gb = &ctx->gb; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
812 int ch, start, end, cplbndstrc, bnd, gcode, tbap; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
813 float cplcos[5], cplcoeff; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
814 uint8_t *exps = ctx->dcplexps; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
815 uint8_t *bap = ctx->cplbap; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
816 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
817 cplbndstrc = ctx->cplbndstrc; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
818 start = ctx->cplstrtmant; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
819 bnd = 0; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
820 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
821 while (start < ctx->cplendmant) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
822 end = start + 12; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
823 while (cplbndstrc & 1) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
824 end += 12; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
825 cplbndstrc >>= 1; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
826 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
827 cplbndstrc >>= 1; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
828 for (ch = 0; ch < ctx->nfchans; ch++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
829 cplcos[ch] = ctx->chcoeffs[ch] * ctx->cplco[ch][bnd]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
830 bnd++; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
831 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
832 while (start < end) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
833 tbap = bap[start]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
834 switch(tbap) { |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
835 case 0: |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
836 for (ch = 0; ch < ctx->nfchans; ch++) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
837 if (((ctx->chincpl) >> ch) & 1) { |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
838 if ((ctx->dithflag >> ch) & 1) { |
5330 | 839 TRANSFORM_COEFF(cplcoeff, av_random(&ctx->dith_state) & 0xFFFF, exps[start], scale_factors); |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
840 ctx->transform_coeffs[ch + 1][start] = cplcoeff * cplcos[ch] * LEVEL_MINUS_3DB; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
841 } else |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
842 ctx->transform_coeffs[ch + 1][start] = 0; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
843 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
844 start++; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
845 continue; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
846 case 1: |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
847 if (m->l3ptr > 2) { |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
848 gcode = get_bits(gb, 5); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
849 m->l3_quantizers[0] = l3_quantizers_1[gcode]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
850 m->l3_quantizers[1] = l3_quantizers_2[gcode]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
851 m->l3_quantizers[2] = l3_quantizers_3[gcode]; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
852 m->l3ptr = 0; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
853 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
854 TRANSFORM_COEFF(cplcoeff, m->l3_quantizers[m->l3ptr++], exps[start], scale_factors); |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
855 break; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
856 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
857 case 2: |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
858 if (m->l5ptr > 2) { |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
859 gcode = get_bits(gb, 7); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
860 m->l5_quantizers[0] = l5_quantizers_1[gcode]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
861 m->l5_quantizers[1] = l5_quantizers_2[gcode]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
862 m->l5_quantizers[2] = l5_quantizers_3[gcode]; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
863 m->l5ptr = 0; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
864 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
865 TRANSFORM_COEFF(cplcoeff, m->l5_quantizers[m->l5ptr++], exps[start], scale_factors); |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
866 break; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
867 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
868 case 3: |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
869 TRANSFORM_COEFF(cplcoeff, l7_quantizers[get_bits(gb, 3)], exps[start], scale_factors); |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
870 break; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
871 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
872 case 4: |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
873 if (m->l11ptr > 1) { |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
874 gcode = get_bits(gb, 7); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
875 m->l11_quantizers[0] = l11_quantizers_1[gcode]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
876 m->l11_quantizers[1] = l11_quantizers_2[gcode]; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
877 m->l11ptr = 0; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
878 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
879 TRANSFORM_COEFF(cplcoeff, m->l11_quantizers[m->l11ptr++], exps[start], scale_factors); |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
880 break; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
881 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
882 case 5: |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
883 TRANSFORM_COEFF(cplcoeff, l15_quantizers[get_bits(gb, 4)], exps[start], scale_factors); |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
884 break; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
885 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
886 default: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
887 TRANSFORM_COEFF(cplcoeff, get_sbits(gb, qntztab[tbap]) << (16 - qntztab[tbap]), |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
888 exps[start], scale_factors); |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
889 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
890 for (ch = 0; ch < ctx->nfchans; ch++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
891 if ((ctx->chincpl >> ch) & 1) |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
892 ctx->transform_coeffs[ch + 1][start] = cplcoeff * cplcos[ch]; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
893 start++; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
894 } |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
895 } |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
896 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
897 return 0; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
898 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
899 |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
900 /* Get the transform coefficients for particular channel */ |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
901 static int get_transform_coeffs_ch(AC3DecodeContext *ctx, int ch_index, mant_groups *m) |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
902 { |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
903 GetBitContext *gb = &ctx->gb; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
904 int i, gcode, tbap, dithflag, end; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
905 uint8_t *exps; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
906 uint8_t *bap; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
907 float *coeffs; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
908 float factors[25]; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
909 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
910 for (i = 0; i < 25; i++) |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
911 factors[i] = scale_factors[i] * ctx->chcoeffs[ch_index]; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
912 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
913 if (ch_index != -1) { /* fbw channels */ |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
914 dithflag = (ctx->dithflag >> ch_index) & 1; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
915 exps = ctx->dexps[ch_index]; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
916 bap = ctx->bap[ch_index]; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
917 coeffs = ctx->transform_coeffs[ch_index + 1]; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
918 end = ctx->endmant[ch_index]; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
919 } else if (ch_index == -1) { |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
920 dithflag = 0; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
921 exps = ctx->dlfeexps; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
922 bap = ctx->lfebap; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
923 coeffs = ctx->transform_coeffs[0]; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
924 end = 7; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
925 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
926 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
927 |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
928 for (i = 0; i < end; i++) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
929 tbap = bap[i]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
930 switch (tbap) { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
931 case 0: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
932 if (!dithflag) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
933 coeffs[i] = 0; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
934 continue; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
935 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
936 else { |
5330 | 937 TRANSFORM_COEFF(coeffs[i], av_random(&ctx->dith_state) & 0xFFFF, exps[i], factors); |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
938 coeffs[i] *= LEVEL_MINUS_3DB; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
939 continue; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
940 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
941 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
942 case 1: |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
943 if (m->l3ptr > 2) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
944 gcode = get_bits(gb, 5); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
945 m->l3_quantizers[0] = l3_quantizers_1[gcode]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
946 m->l3_quantizers[1] = l3_quantizers_2[gcode]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
947 m->l3_quantizers[2] = l3_quantizers_3[gcode]; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
948 m->l3ptr = 0; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
949 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
950 TRANSFORM_COEFF(coeffs[i], m->l3_quantizers[m->l3ptr++], exps[i], factors); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
951 continue; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
952 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
953 case 2: |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
954 if (m->l5ptr > 2) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
955 gcode = get_bits(gb, 7); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
956 m->l5_quantizers[0] = l5_quantizers_1[gcode]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
957 m->l5_quantizers[1] = l5_quantizers_2[gcode]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
958 m->l5_quantizers[2] = l5_quantizers_3[gcode]; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
959 m->l5ptr = 0; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
960 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
961 TRANSFORM_COEFF(coeffs[i], m->l5_quantizers[m->l5ptr++], exps[i], factors); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
962 continue; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
963 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
964 case 3: |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
965 TRANSFORM_COEFF(coeffs[i], l7_quantizers[get_bits(gb, 3)], exps[i], factors); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
966 continue; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
967 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
968 case 4: |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
969 if (m->l11ptr > 1) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
970 gcode = get_bits(gb, 7); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
971 m->l11_quantizers[0] = l11_quantizers_1[gcode]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
972 m->l11_quantizers[1] = l11_quantizers_2[gcode]; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
973 m->l11ptr = 0; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
974 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
975 TRANSFORM_COEFF(coeffs[i], m->l11_quantizers[m->l11ptr++], exps[i], factors); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
976 continue; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
977 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
978 case 5: |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
979 TRANSFORM_COEFF(coeffs[i], l15_quantizers[get_bits(gb, 4)], exps[i], factors); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
980 continue; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
981 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
982 default: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
983 TRANSFORM_COEFF(coeffs[i], get_sbits(gb, qntztab[tbap]) << (16 - qntztab[tbap]), exps[i], factors); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
984 continue; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
985 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
986 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
987 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
988 return 0; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
989 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
990 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
991 /* Get the transform coefficients. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
992 * This function extracts the tranform coefficients form the ac3 bitstream. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
993 * This function is called after bit allocation is performed. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
994 */ |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
995 static int get_transform_coeffs(AC3DecodeContext * ctx) |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
996 { |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
997 int i, end; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
998 int got_cplchan = 0; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
999 mant_groups m; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1000 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1001 m.l3ptr = m.l5ptr = m.l11ptr = 3; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1002 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1003 for (i = 0; i < ctx->nfchans; i++) { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1004 /* transform coefficients for individual channel */ |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1005 if (get_transform_coeffs_ch(ctx, i, &m)) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1006 return -1; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1007 /* tranform coefficients for coupling channels */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1008 if ((ctx->chincpl >> i) & 1) { |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1009 if (!got_cplchan) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1010 if (get_transform_coeffs_cpling(ctx, &m)) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1011 av_log(NULL, AV_LOG_ERROR, "error in decoupling channels\n"); |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1012 return -1; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1013 } |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1014 got_cplchan = 1; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1015 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1016 end = ctx->cplendmant; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1017 } else |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1018 end = ctx->endmant[i]; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1019 do |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1020 ctx->transform_coeffs[i + 1][end] = 0; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1021 while(++end < 256); |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1022 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1023 if (ctx->lfeon) { |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1024 if (get_transform_coeffs_ch(ctx, -1, &m)) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1025 return -1; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1026 for (i = 7; i < 256; i++) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1027 ctx->transform_coeffs[0][i] = 0; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1028 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1029 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1030 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1031 return 0; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1032 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1033 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1034 /* Rematrixing routines. */ |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1035 static void do_rematrixing1(AC3DecodeContext *ctx, int start, int end) |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1036 { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1037 float tmp0, tmp1; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1038 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1039 while (start < end) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1040 tmp0 = ctx->transform_coeffs[1][start]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1041 tmp1 = ctx->transform_coeffs[2][start]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1042 ctx->transform_coeffs[1][start] = tmp0 + tmp1; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1043 ctx->transform_coeffs[2][start] = tmp0 - tmp1; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1044 start++; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1045 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1046 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1047 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1048 static void do_rematrixing(AC3DecodeContext *ctx) |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1049 { |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1050 int bnd1 = 13, bnd2 = 25, bnd3 = 37, bnd4 = 61; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1051 int end, bndend; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1052 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1053 end = FFMIN(ctx->endmant[0], ctx->endmant[1]); |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1054 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1055 if (ctx->rematflg & 1) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1056 do_rematrixing1(ctx, bnd1, bnd2); |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1057 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1058 if (ctx->rematflg & 2) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1059 do_rematrixing1(ctx, bnd2, bnd3); |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1060 |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1061 bndend = bnd4; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1062 if (bndend > end) { |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1063 bndend = end; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1064 if (ctx->rematflg & 4) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1065 do_rematrixing1(ctx, bnd3, bndend); |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1066 } else { |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1067 if (ctx->rematflg & 4) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1068 do_rematrixing1(ctx, bnd3, bnd4); |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1069 if (ctx->rematflg & 8) |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1070 do_rematrixing1(ctx, bnd4, end); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1071 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1072 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1073 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1074 /* This function sets the normalized channel coefficients. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1075 * Transform coefficients are multipllied by the channel |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1076 * coefficients to get normalized transform coefficients. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1077 */ |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1078 static void get_downmix_coeffs(AC3DecodeContext *ctx) |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1079 { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1080 int from = ctx->acmod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1081 int to = ctx->blkoutput; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1082 float clev = clevs[ctx->cmixlev]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1083 float slev = slevs[ctx->surmixlev]; |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1084 float nf = 1.0; //normalization factor for downmix coeffs |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1085 int i; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1086 |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1087 if (!ctx->acmod) { |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1088 ctx->chcoeffs[0] = 2 * ctx->dynrng; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1089 ctx->chcoeffs[1] = 2 * ctx->dynrng2; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1090 } else { |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1091 for (i = 0; i < ctx->nfchans; i++) |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1092 ctx->chcoeffs[i] = 2 * ctx->dynrng; |
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1093 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1094 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1095 if (to == AC3_OUTPUT_UNMODIFIED) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1096 return; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1097 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1098 switch (from) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1099 case AC3_INPUT_DUALMONO: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1100 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1101 case AC3_OUTPUT_MONO: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1102 case AC3_OUTPUT_STEREO: /* We Assume that sum of both mono channels is requested */ |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1103 nf = 0.5; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1104 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1105 ctx->chcoeffs[1] *= nf; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1106 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1107 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1108 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1109 case AC3_INPUT_MONO: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1110 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1111 case AC3_OUTPUT_STEREO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1112 nf = LEVEL_MINUS_3DB; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1113 ctx->chcoeffs[0] *= nf; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1114 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1115 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1116 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1117 case AC3_INPUT_STEREO: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1118 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1119 case AC3_OUTPUT_MONO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1120 nf = LEVEL_MINUS_3DB; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1121 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1122 ctx->chcoeffs[1] *= nf; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1123 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1124 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1125 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1126 case AC3_INPUT_3F: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1127 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1128 case AC3_OUTPUT_MONO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1129 nf = LEVEL_MINUS_3DB / (1.0 + clev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1130 ctx->chcoeffs[0] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1131 ctx->chcoeffs[2] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1132 ctx->chcoeffs[1] *= ((nf * clev * LEVEL_MINUS_3DB) / 2.0); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1133 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1134 case AC3_OUTPUT_STEREO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1135 nf = 1.0 / (1.0 + clev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1136 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1137 ctx->chcoeffs[2] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1138 ctx->chcoeffs[1] *= (nf * clev); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1139 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1140 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1141 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1142 case AC3_INPUT_2F_1R: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1143 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1144 case AC3_OUTPUT_MONO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1145 nf = 2.0 * LEVEL_MINUS_3DB / (2.0 + slev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1146 ctx->chcoeffs[0] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1147 ctx->chcoeffs[1] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1148 ctx->chcoeffs[2] *= (nf * slev * LEVEL_MINUS_3DB); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1149 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1150 case AC3_OUTPUT_STEREO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1151 nf = 1.0 / (1.0 + (slev * LEVEL_MINUS_3DB)); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1152 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1153 ctx->chcoeffs[1] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1154 ctx->chcoeffs[2] *= (nf * slev * LEVEL_MINUS_3DB); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1155 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1156 case AC3_OUTPUT_DOLBY: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1157 nf = 1.0 / (1.0 + LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1158 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1159 ctx->chcoeffs[1] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1160 ctx->chcoeffs[2] *= (nf * LEVEL_MINUS_3DB); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1161 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1162 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1163 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1164 case AC3_INPUT_3F_1R: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1165 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1166 case AC3_OUTPUT_MONO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1167 nf = LEVEL_MINUS_3DB / (1.0 + clev + (slev / 2.0)); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1168 ctx->chcoeffs[0] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1169 ctx->chcoeffs[2] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1170 ctx->chcoeffs[1] *= (nf * clev * LEVEL_PLUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1171 ctx->chcoeffs[3] *= (nf * slev * LEVEL_MINUS_3DB); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1172 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1173 case AC3_OUTPUT_STEREO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1174 nf = 1.0 / (1.0 + clev + (slev * LEVEL_MINUS_3DB)); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1175 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1176 ctx->chcoeffs[2] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1177 ctx->chcoeffs[1] *= (nf * clev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1178 ctx->chcoeffs[3] *= (nf * slev * LEVEL_MINUS_3DB); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1179 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1180 case AC3_OUTPUT_DOLBY: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1181 nf = 1.0 / (1.0 + (2.0 * LEVEL_MINUS_3DB)); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1182 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1183 ctx->chcoeffs[1] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1184 ctx->chcoeffs[1] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1185 ctx->chcoeffs[3] *= (nf * LEVEL_MINUS_3DB); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1186 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1187 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1188 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1189 case AC3_INPUT_2F_2R: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1190 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1191 case AC3_OUTPUT_MONO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1192 nf = LEVEL_MINUS_3DB / (1.0 + slev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1193 ctx->chcoeffs[0] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1194 ctx->chcoeffs[1] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1195 ctx->chcoeffs[2] *= (nf * slev * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1196 ctx->chcoeffs[3] *= (nf * slev * LEVEL_MINUS_3DB); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1197 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1198 case AC3_OUTPUT_STEREO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1199 nf = 1.0 / (1.0 + slev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1200 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1201 ctx->chcoeffs[1] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1202 ctx->chcoeffs[2] *= (nf * slev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1203 ctx->chcoeffs[3] *= (nf * slev); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1204 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1205 case AC3_OUTPUT_DOLBY: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1206 nf = 1.0 / (1.0 + (2.0 * LEVEL_MINUS_3DB)); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1207 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1208 ctx->chcoeffs[1] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1209 ctx->chcoeffs[2] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1210 ctx->chcoeffs[3] *= (nf * LEVEL_MINUS_3DB); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1211 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1212 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1213 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1214 case AC3_INPUT_3F_2R: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1215 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1216 case AC3_OUTPUT_MONO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1217 nf = LEVEL_MINUS_3DB / (1.0 + clev + slev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1218 ctx->chcoeffs[0] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1219 ctx->chcoeffs[2] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1220 ctx->chcoeffs[1] *= (nf * clev * LEVEL_PLUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1221 ctx->chcoeffs[3] *= (nf * slev * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1222 ctx->chcoeffs[4] *= (nf * slev * LEVEL_MINUS_3DB); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1223 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1224 case AC3_OUTPUT_STEREO: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1225 nf = 1.0 / (1.0 + clev + slev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1226 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1227 ctx->chcoeffs[2] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1228 ctx->chcoeffs[1] *= (nf * clev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1229 ctx->chcoeffs[3] *= (nf * slev); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1230 ctx->chcoeffs[4] *= (nf * slev); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1231 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1232 case AC3_OUTPUT_DOLBY: |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1233 nf = 1.0 / (1.0 + (3.0 * LEVEL_MINUS_3DB)); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1234 ctx->chcoeffs[0] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1235 ctx->chcoeffs[1] *= nf; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1236 ctx->chcoeffs[1] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1237 ctx->chcoeffs[3] *= (nf * LEVEL_MINUS_3DB); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1238 ctx->chcoeffs[4] *= (nf * LEVEL_MINUS_3DB); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1239 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1240 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1241 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1242 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1243 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1244 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1245 /*********** BEGIN DOWNMIX FUNCTIONS ***********/ |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1246 static inline void mix_dualmono_to_mono(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1247 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1248 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1249 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1250 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1251 for (i = 0; i < 256; i++) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1252 output[1][i] += output[2][i]; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1253 memset(output[2], 0, sizeof(output[2])); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1254 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1255 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1256 static inline void mix_dualmono_to_stereo(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1257 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1258 int i; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1259 float tmp; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1260 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1261 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1262 for (i = 0; i < 256; i++) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1263 tmp = output[1][i] + output[2][i]; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1264 output[1][i] = output[2][i] = tmp; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1265 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1266 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1267 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1268 static inline void upmix_mono_to_stereo(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1269 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1270 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1271 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1272 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1273 for (i = 0; i < 256; i++) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1274 output[2][i] = output[1][i]; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1275 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1276 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1277 static inline void mix_stereo_to_mono(AC3DecodeContext *ctx) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1278 { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1279 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1280 float (*output)[BLOCK_SIZE] = ctx->output; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1281 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1282 for (i = 0; i < 256; i++) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1283 output[1][i] += output[2][i]; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1284 memset(output[2], 0, sizeof(output[2])); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1285 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1286 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1287 static inline void mix_3f_to_mono(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1288 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1289 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1290 float (*output)[BLOCK_SIZE] = ctx->output; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1291 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1292 for (i = 0; i < 256; i++) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1293 output[1][i] += (output[2][i] + output[3][i]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1294 memset(output[2], 0, sizeof(output[2])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1295 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1296 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1297 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1298 static inline void mix_3f_to_stereo(AC3DecodeContext *ctx) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1299 { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1300 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1301 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1302 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1303 for (i = 0; i < 256; i++) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1304 output[1][i] += output[2][i]; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1305 output[2][i] += output[3][i]; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1306 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1307 memset(output[3], 0, sizeof(output[3])); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1308 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1309 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1310 static inline void mix_2f_1r_to_mono(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1311 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1312 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1313 float (*output)[BLOCK_SIZE] = ctx->output; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1314 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1315 for (i = 0; i < 256; i++) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1316 output[1][i] += (output[2][i] + output[3][i]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1317 memset(output[2], 0, sizeof(output[2])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1318 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1319 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1320 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1321 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1322 static inline void mix_2f_1r_to_stereo(AC3DecodeContext *ctx) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1323 { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1324 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1325 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1326 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1327 for (i = 0; i < 256; i++) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1328 output[1][i] += output[2][i]; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1329 output[2][i] += output[3][i]; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1330 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1331 memset(output[3], 0, sizeof(output[3])); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1332 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1333 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1334 static inline void mix_2f_1r_to_dolby(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1335 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1336 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1337 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1338 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1339 for (i = 0; i < 256; i++) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1340 output[1][i] -= output[3][i]; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1341 output[2][i] += output[3][i]; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1342 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1343 memset(output[3], 0, sizeof(output[3])); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1344 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1345 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1346 static inline void mix_3f_1r_to_mono(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1347 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1348 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1349 float (*output)[BLOCK_SIZE] = ctx->output; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1350 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1351 for (i = 0; i < 256; i++) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1352 output[1][i] = (output[2][i] + output[3][i] + output[4][i]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1353 memset(output[2], 0, sizeof(output[2])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1354 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1355 memset(output[4], 0, sizeof(output[4])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1356 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1357 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1358 static inline void mix_3f_1r_to_stereo(AC3DecodeContext *ctx) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1359 { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1360 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1361 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1362 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1363 for (i = 0; i < 256; i++) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1364 output[1][i] += (output[2][i] + output[4][i]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1365 output[2][i] += (output[3][i] + output[4][i]); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1366 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1367 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1368 memset(output[4], 0, sizeof(output[4])); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1369 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1370 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1371 static inline void mix_3f_1r_to_dolby(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1372 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1373 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1374 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1375 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1376 for (i = 0; i < 256; i++) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1377 output[1][i] += (output[2][i] - output[4][i]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1378 output[2][i] += (output[3][i] + output[4][i]); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1379 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1380 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1381 memset(output[4], 0, sizeof(output[4])); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1382 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1383 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1384 static inline void mix_2f_2r_to_mono(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1385 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1386 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1387 float (*output)[BLOCK_SIZE] = ctx->output; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1388 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1389 for (i = 0; i < 256; i++) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1390 output[1][i] = (output[2][i] + output[3][i] + output[4][i]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1391 memset(output[2], 0, sizeof(output[2])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1392 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1393 memset(output[4], 0, sizeof(output[4])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1394 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1395 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1396 static inline void mix_2f_2r_to_stereo(AC3DecodeContext *ctx) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1397 { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1398 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1399 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1400 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1401 for (i = 0; i < 256; i++) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1402 output[1][i] += output[3][i]; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1403 output[2][i] += output[4][i]; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1404 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1405 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1406 memset(output[4], 0, sizeof(output[4])); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1407 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1408 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1409 static inline void mix_2f_2r_to_dolby(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1410 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1411 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1412 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1413 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1414 for (i = 0; i < 256; i++) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1415 output[1][i] -= output[3][i]; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1416 output[2][i] += output[4][i]; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1417 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1418 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1419 memset(output[4], 0, sizeof(output[4])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1420 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1421 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1422 static inline void mix_3f_2r_to_mono(AC3DecodeContext *ctx) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1423 { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1424 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1425 float (*output)[BLOCK_SIZE] = ctx->output; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1426 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1427 for (i = 0; i < 256; i++) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1428 output[1][i] += (output[2][i] + output[3][i] + output[4][i] + output[5][i]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1429 memset(output[2], 0, sizeof(output[2])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1430 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1431 memset(output[4], 0, sizeof(output[4])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1432 memset(output[5], 0, sizeof(output[5])); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1433 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1434 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1435 static inline void mix_3f_2r_to_stereo(AC3DecodeContext *ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1436 { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1437 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1438 float (*output)[BLOCK_SIZE] = ctx->output; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1439 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1440 for (i = 0; i < 256; i++) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1441 output[1][i] += (output[2][i] + output[4][i]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1442 output[2][i] += (output[3][i] + output[5][i]); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1443 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1444 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1445 memset(output[4], 0, sizeof(output[4])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1446 memset(output[5], 0, sizeof(output[5])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1447 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1448 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1449 static inline void mix_3f_2r_to_dolby(AC3DecodeContext *ctx) |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1450 { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1451 int i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1452 float (*output)[BLOCK_SIZE] = ctx->output; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1453 |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1454 for (i = 0; i < 256; i++) { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1455 output[1][i] += (output[2][i] - output[4][i] - output[5][i]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1456 output[2][i] += (output[3][i] + output[4][i] + output[5][i]); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1457 } |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1458 memset(output[3], 0, sizeof(output[3])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1459 memset(output[4], 0, sizeof(output[4])); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1460 memset(output[5], 0, sizeof(output[5])); |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1461 } |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1462 /*********** END DOWNMIX FUNCTIONS ***********/ |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1463 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1464 /* Downmix the output. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1465 * This function downmixes the output when the number of input |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1466 * channels is not equal to the number of output channels requested. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1467 */ |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1468 static void do_downmix(AC3DecodeContext *ctx) |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1469 { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1470 int from = ctx->acmod; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1471 int to = ctx->blkoutput; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1472 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1473 if (to == AC3_OUTPUT_UNMODIFIED) |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1474 return; |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1475 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1476 switch (from) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1477 case AC3_INPUT_DUALMONO: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1478 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1479 case AC3_OUTPUT_MONO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1480 mix_dualmono_to_mono(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1481 break; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1482 case AC3_OUTPUT_STEREO: /* We assume that sum of both mono channels is requested */ |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1483 mix_dualmono_to_stereo(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1484 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1485 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1486 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1487 case AC3_INPUT_MONO: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1488 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1489 case AC3_OUTPUT_STEREO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1490 upmix_mono_to_stereo(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1491 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1492 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1493 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1494 case AC3_INPUT_STEREO: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1495 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1496 case AC3_OUTPUT_MONO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1497 mix_stereo_to_mono(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1498 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1499 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1500 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1501 case AC3_INPUT_3F: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1502 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1503 case AC3_OUTPUT_MONO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1504 mix_3f_to_mono(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1505 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1506 case AC3_OUTPUT_STEREO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1507 mix_3f_to_stereo(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1508 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1509 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1510 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1511 case AC3_INPUT_2F_1R: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1512 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1513 case AC3_OUTPUT_MONO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1514 mix_2f_1r_to_mono(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1515 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1516 case AC3_OUTPUT_STEREO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1517 mix_2f_1r_to_stereo(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1518 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1519 case AC3_OUTPUT_DOLBY: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1520 mix_2f_1r_to_dolby(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1521 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1522 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1523 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1524 case AC3_INPUT_3F_1R: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1525 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1526 case AC3_OUTPUT_MONO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1527 mix_3f_1r_to_mono(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1528 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1529 case AC3_OUTPUT_STEREO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1530 mix_3f_1r_to_stereo(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1531 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1532 case AC3_OUTPUT_DOLBY: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1533 mix_3f_1r_to_dolby(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1534 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1535 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1536 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1537 case AC3_INPUT_2F_2R: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1538 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1539 case AC3_OUTPUT_MONO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1540 mix_2f_2r_to_mono(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1541 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1542 case AC3_OUTPUT_STEREO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1543 mix_2f_2r_to_stereo(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1544 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1545 case AC3_OUTPUT_DOLBY: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1546 mix_2f_2r_to_dolby(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1547 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1548 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1549 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1550 case AC3_INPUT_3F_2R: |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1551 switch (to) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1552 case AC3_OUTPUT_MONO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1553 mix_3f_2r_to_mono(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1554 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1555 case AC3_OUTPUT_STEREO: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1556 mix_3f_2r_to_stereo(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1557 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1558 case AC3_OUTPUT_DOLBY: |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1559 mix_3f_2r_to_dolby(ctx); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1560 break; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1561 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1562 break; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1563 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1564 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1565 |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1566 static void dump_floats(const char *name, int prec, const float *tab, int n) |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1567 { |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1568 int i; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1569 |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1570 av_log(NULL, AV_LOG_INFO, "%s[%d]:\n", name, n); |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1571 for(i=0;i<n;i++) { |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1572 if ((i & 7) == 0) |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1573 av_log(NULL, AV_LOG_INFO, "%4d: ", i); |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1574 av_log(NULL, AV_LOG_INFO, " %8.*f", prec, tab[i]); |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1575 if ((i & 7) == 7) |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1576 av_log(NULL, AV_LOG_INFO, "\n"); |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1577 } |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1578 if ((i & 7) != 0) |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1579 av_log(NULL, AV_LOG_INFO, "\n"); |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1580 } |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1581 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1582 /* This function performs the imdct on 256 sample transform |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1583 * coefficients. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1584 */ |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1585 static void do_imdct_256(AC3DecodeContext *ctx, int chindex) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1586 { |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1587 int k; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1588 float x1[128], x2[128]; |
5322
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1589 float *o_ptr, *d_ptr, *w; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1590 FFTComplex *ptr1, *ptr2; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1591 |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1592 for (k = 0; k < N / 4; k++) { |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1593 x1[k] = ctx->transform_coeffs[chindex][2 * k]; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1594 x2[k] = ctx->transform_coeffs[chindex][2 * k + 1]; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1595 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1596 |
5324
33e13333dc4d
AC-3 decoder, soc revision 148, Sep 28 18:38:27 2006 UTC by banan
jbr
parents:
5323
diff
changeset
|
1597 ctx->imdct_256.fft.imdct_calc(&ctx->imdct_256, ctx->tmp_output, x1, ctx->tmp_imdct); |
33e13333dc4d
AC-3 decoder, soc revision 148, Sep 28 18:38:27 2006 UTC by banan
jbr
parents:
5323
diff
changeset
|
1598 ctx->imdct_256.fft.imdct_calc(&ctx->imdct_256, ctx->tmp_output + 256, x2, ctx->tmp_imdct); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1599 |
5322
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1600 o_ptr = ctx->output[chindex]; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1601 d_ptr = ctx->delay[chindex]; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1602 ptr1 = (FFTComplex *)ctx->tmp_output; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1603 ptr2 = (FFTComplex *)ctx->tmp_output + 256; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1604 w = ctx->window; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1605 |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1606 for (k = 0; k < N / 8; k++) |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1607 { |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1608 o_ptr[2 * k] = -ptr1[k].im * w[2 * k] + d_ptr[2 * k] + 384.0; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1609 o_ptr[2 * k + 1] = ptr1[N / 8 - k - 1].re * w[2 * k + 1] + 384.0; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1610 o_ptr[N / 4 + 2 * k] = -ptr1[k].re * w[N / 4 + 2 * k] + d_ptr[N / 4 + 2 * k] + 384.0; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1611 o_ptr[N / 4 + 2 * k + 1] = ptr1[N / 8 - k - 1].im * w[N / 4 + 2 * k + 1] + d_ptr[N / 4 + 2 * k + 1] + 384.0; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1612 d_ptr[2 * k] = ptr2[k].re * w[k / 2 - 2 * k - 1]; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1613 d_ptr[2 * k + 1] = -ptr2[N / 8 - k - 1].im * w[N / 2 - 2 * k - 2]; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1614 d_ptr[N / 4 + 2 * k] = ptr2[k].im * w[N / 4 - 2 * k - 1]; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1615 d_ptr[N / 4 + 2 * k + 1] = -ptr2[N / 8 - k - 1].re * w[N / 4 - 2 * k - 2]; |
b55b8c792066
AC-3 decoder, soc revision 72, Sep 7 04:20:00 2006 UTC by cloud9
jbr
parents:
5321
diff
changeset
|
1616 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1617 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1618 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1619 /* This function performs the imdct on 512 sample transform |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1620 * coefficients. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1621 */ |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1622 static void do_imdct_512(AC3DecodeContext *ctx, int chindex) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1623 { |
5317
6d81881f257f
AC-3 decoder, soc revision 57, Aug 19 12:44:38 2006 UTC by cloud9
jbr
parents:
5316
diff
changeset
|
1624 float *ptr; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1625 |
5324
33e13333dc4d
AC-3 decoder, soc revision 148, Sep 28 18:38:27 2006 UTC by banan
jbr
parents:
5323
diff
changeset
|
1626 ctx->imdct_512.fft.imdct_calc(&ctx->imdct_512, ctx->tmp_output, |
33e13333dc4d
AC-3 decoder, soc revision 148, Sep 28 18:38:27 2006 UTC by banan
jbr
parents:
5323
diff
changeset
|
1627 ctx->transform_coeffs[chindex], ctx->tmp_imdct); |
5317
6d81881f257f
AC-3 decoder, soc revision 57, Aug 19 12:44:38 2006 UTC by cloud9
jbr
parents:
5316
diff
changeset
|
1628 ptr = ctx->output[chindex]; |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1629 ctx->dsp.vector_fmul_add_add(ptr, ctx->tmp_output, ctx->window, ctx->delay[chindex], 384, BLOCK_SIZE, 1); |
5317
6d81881f257f
AC-3 decoder, soc revision 57, Aug 19 12:44:38 2006 UTC by cloud9
jbr
parents:
5316
diff
changeset
|
1630 ptr = ctx->delay[chindex]; |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1631 ctx->dsp.vector_fmul_reverse(ptr, ctx->tmp_output + 256, ctx->window, BLOCK_SIZE); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1632 } |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1633 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1634 /* IMDCT Transform. */ |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1635 static inline void do_imdct(AC3DecodeContext *ctx) |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1636 { |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1637 int i; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1638 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1639 if (ctx->blkoutput & AC3_OUTPUT_LFEON) { |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1640 do_imdct_512(ctx, 0); |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1641 } |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1642 for (i = 0; i < ctx->nfchans; i++) { |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1643 if ((ctx->blksw >> i) & 1) |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1644 do_imdct_256(ctx, i + 1); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1645 else |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1646 do_imdct_512(ctx, i + 1); |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1647 } |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1648 } |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1649 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1650 /* Parse the audio block from ac3 bitstream. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1651 * This function extract the audio block from the ac3 bitstream |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1652 * and produces the output for the block. This function must |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1653 * be called for each of the six audio block in the ac3 bitstream. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1654 */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1655 static int ac3_parse_audio_block(AC3DecodeContext * ctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1656 { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1657 int nfchans = ctx->nfchans; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1658 int acmod = ctx->acmod; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1659 int i, bnd, rbnd, seg, grpsize; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1660 GetBitContext *gb = &ctx->gb; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1661 int bit_alloc_flags = 0; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1662 uint8_t *dexps; |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1663 int mstrcplco, cplcoexp, cplcomant; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1664 int dynrng, chbwcod, ngrps, cplabsexp, skipl; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1665 |
5312
2c875e6274d5
AC-3 decoder, soc revision 52, Aug 16 22:45:07 2006 UTC by cloud9
jbr
parents:
5311
diff
changeset
|
1666 ctx->blksw = 0; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1667 for (i = 0; i < nfchans; i++) /*block switch flag */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1668 ctx->blksw |= get_bits1(gb) << i; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1669 |
5312
2c875e6274d5
AC-3 decoder, soc revision 52, Aug 16 22:45:07 2006 UTC by cloud9
jbr
parents:
5311
diff
changeset
|
1670 ctx->dithflag = 0; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1671 for (i = 0; i < nfchans; i++) /* dithering flag */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1672 ctx->dithflag |= get_bits1(gb) << i; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1673 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1674 if (get_bits1(gb)) { /* dynamic range */ |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1675 dynrng = get_sbits(gb, 8); |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1676 ctx->dynrng = ((((dynrng & 0x1f) | 0x20) << 13) * scale_factors[3 - (dynrng >> 5)]); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1677 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1678 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1679 if (acmod == 0x00 && get_bits1(gb)) { /* dynamic range 1+1 mode */ |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1680 dynrng = get_sbits(gb, 8); |
5319
40af705cef7e
AC-3 decoder, soc revision 69, Aug 31 07:12:56 2006 UTC by cloud9
jbr
parents:
5318
diff
changeset
|
1681 ctx->dynrng2 = ((((dynrng & 0x1f) | 0x20) << 13) * scale_factors[3 - (dynrng >> 5)]); |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1682 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1683 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1684 get_downmix_coeffs(ctx); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1685 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1686 if (get_bits1(gb)) { /* coupling strategy */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1687 ctx->cplinu = get_bits1(gb); |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1688 ctx->cplbndstrc = 0; |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1689 ctx->chincpl = 0; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1690 if (ctx->cplinu) { /* coupling in use */ |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1691 for (i = 0; i < nfchans; i++) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1692 ctx->chincpl |= get_bits1(gb) << i; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1693 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1694 if (acmod == 0x02) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1695 ctx->phsflginu = get_bits1(gb); //phase flag in use |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1696 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1697 ctx->cplbegf = get_bits(gb, 4); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1698 ctx->cplendf = get_bits(gb, 4); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1699 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1700 if (3 + ctx->cplendf - ctx->cplbegf < 0) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1701 av_log(NULL, AV_LOG_ERROR, "cplendf = %d < cplbegf = %d\n", ctx->cplendf, ctx->cplbegf); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1702 return -1; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1703 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1704 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1705 ctx->ncplbnd = ctx->ncplsubnd = 3 + ctx->cplendf - ctx->cplbegf; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1706 ctx->cplstrtmant = ctx->cplbegf * 12 + 37; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1707 ctx->cplendmant = ctx->cplendf * 12 + 73; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1708 for (i = 0; i < ctx->ncplsubnd - 1; i++) /* coupling band structure */ |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1709 if (get_bits1(gb)) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1710 ctx->cplbndstrc |= 1 << i; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1711 ctx->ncplbnd--; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1712 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1713 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1714 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1715 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1716 if (ctx->cplinu) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1717 ctx->cplcoe = 0; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1718 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1719 for (i = 0; i < nfchans; i++) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1720 if ((ctx->chincpl) >> i & 1) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1721 if (get_bits1(gb)) { /* coupling co-ordinates */ |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1722 ctx->cplcoe |= 1 << i; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1723 mstrcplco = 3 * get_bits(gb, 2); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1724 for (bnd = 0; bnd < ctx->ncplbnd; bnd++) { |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1725 cplcoexp = get_bits(gb, 4); |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1726 cplcomant = get_bits(gb, 4); |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1727 if (cplcoexp == 15) |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1728 cplcomant <<= 14; |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1729 else |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1730 cplcomant = (cplcomant | 0x10) << 13; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1731 ctx->cplco[i][bnd] = cplcomant * scale_factors[cplcoexp + mstrcplco]; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1732 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1733 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1734 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1735 if (acmod == 0x02 && ctx->phsflginu && (ctx->cplcoe & 1 || ctx->cplcoe & 2)) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1736 for (bnd = 0; bnd < ctx->ncplbnd; bnd++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1737 if (get_bits1(gb)) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1738 ctx->cplco[1][bnd] = -ctx->cplco[1][bnd]; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1739 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1740 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1741 if (acmod == 0x02) {/* rematrixing */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1742 ctx->rematstr = get_bits1(gb); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1743 if (ctx->rematstr) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1744 ctx->rematflg = 0; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1745 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1746 if (!(ctx->cplinu) || ctx->cplbegf > 2) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1747 for (rbnd = 0; rbnd < 4; rbnd++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1748 ctx->rematflg |= get_bits1(gb) << rbnd; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1749 if (ctx->cplbegf > 0 && ctx->cplbegf <= 2 && ctx->cplinu) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1750 for (rbnd = 0; rbnd < 3; rbnd++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1751 ctx->rematflg |= get_bits1(gb) << rbnd; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1752 if (ctx->cplbegf == 0 && ctx->cplinu) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1753 for (rbnd = 0; rbnd < 2; rbnd++) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1754 ctx->rematflg |= get_bits1(gb) << rbnd; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1755 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1756 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1757 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1758 ctx->cplexpstr = AC3_EXPSTR_REUSE; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1759 ctx->lfeexpstr = AC3_EXPSTR_REUSE; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1760 if (ctx->cplinu) /* coupling exponent strategy */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1761 ctx->cplexpstr = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1762 for (i = 0; i < nfchans; i++) /* channel exponent strategy */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1763 ctx->chexpstr[i] = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1764 if (ctx->lfeon) /* lfe exponent strategy */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1765 ctx->lfeexpstr = get_bits1(gb); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1766 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1767 for (i = 0; i < nfchans; i++) /* channel bandwidth code */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1768 if (ctx->chexpstr[i] != AC3_EXPSTR_REUSE) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1769 if ((ctx->chincpl >> i) & 1) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1770 ctx->endmant[i] = ctx->cplstrtmant; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1771 else { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1772 chbwcod = get_bits(gb, 6); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1773 if (chbwcod > 60) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1774 av_log(NULL, AV_LOG_ERROR, "chbwcod = %d > 60", chbwcod); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1775 return -1; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1776 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1777 ctx->endmant[i] = chbwcod * 3 + 73; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1778 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1779 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1780 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1781 if (ctx->cplexpstr != AC3_EXPSTR_REUSE) {/* coupling exponents */ |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1782 bit_alloc_flags = 64; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1783 cplabsexp = get_bits(gb, 4) << 1; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1784 ngrps = (ctx->cplendmant - ctx->cplstrtmant) / (3 << (ctx->cplexpstr - 1)); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1785 if (decode_exponents(gb, ctx->cplexpstr, ngrps, cplabsexp, ctx->dcplexps + ctx->cplstrtmant)) { |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1786 av_log(NULL, AV_LOG_ERROR, "error decoding coupling exponents\n"); |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1787 return -1; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1788 } |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1789 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1790 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1791 for (i = 0; i < nfchans; i++) /* fbw channel exponents */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1792 if (ctx->chexpstr[i] != AC3_EXPSTR_REUSE) { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1793 bit_alloc_flags |= 1 << i; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1794 grpsize = 3 << (ctx->chexpstr[i] - 1); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1795 ngrps = (ctx->endmant[i] + grpsize - 4) / grpsize; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1796 dexps = ctx->dexps[i]; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1797 dexps[0] = get_bits(gb, 4); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1798 if (decode_exponents(gb, ctx->chexpstr[i], ngrps, dexps[0], dexps + 1)) { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1799 av_log(NULL, AV_LOG_ERROR, "error decoding channel %d exponents\n", i); |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1800 return -1; |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1801 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1802 skip_bits(gb, 2); /* skip gainrng */ |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1803 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1804 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1805 if (ctx->lfeexpstr != AC3_EXPSTR_REUSE) { /* lfe exponents */ |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1806 bit_alloc_flags |= 32; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1807 ctx->dlfeexps[0] = get_bits(gb, 4); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1808 if (decode_exponents(gb, ctx->lfeexpstr, 2, ctx->dlfeexps[0], ctx->dlfeexps + 1)) { |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1809 av_log(NULL, AV_LOG_ERROR, "error decoding lfe exponents\n"); |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1810 return -1; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1811 } |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1812 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1813 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1814 if (get_bits1(gb)) { /* bit allocation information */ |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1815 bit_alloc_flags = 127; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1816 ctx->sdcycod = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1817 ctx->fdcycod = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1818 ctx->sgaincod = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1819 ctx->dbpbcod = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1820 ctx->floorcod = get_bits(gb, 3); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1821 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1822 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1823 if (get_bits1(gb)) { /* snroffset */ |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1824 bit_alloc_flags = 127; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1825 ctx->csnroffst = get_bits(gb, 6); |
5323
4ba6d8132f36
AC-3 decoder, soc revision 109, Sep 22 22:42:54 2006 UTC by banan
jbr
parents:
5322
diff
changeset
|
1826 if (ctx->cplinu) { /* coupling fine snr offset and fast gain code */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1827 ctx->cplfsnroffst = get_bits(gb, 4); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1828 ctx->cplfgaincod = get_bits(gb, 3); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1829 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1830 for (i = 0; i < nfchans; i++) { /* channel fine snr offset and fast gain code */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1831 ctx->fsnroffst[i] = get_bits(gb, 4); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1832 ctx->fgaincod[i] = get_bits(gb, 3); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1833 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1834 if (ctx->lfeon) { /* lfe fine snr offset and fast gain code */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1835 ctx->lfefsnroffst = get_bits(gb, 4); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1836 ctx->lfefgaincod = get_bits(gb, 3); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1837 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1838 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1839 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1840 if (ctx->cplinu && get_bits1(gb)) { /* coupling leak information */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1841 bit_alloc_flags |= 64; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1842 ctx->cplfleak = get_bits(gb, 3); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1843 ctx->cplsleak = get_bits(gb, 3); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1844 } |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1845 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1846 if (get_bits1(gb)) { /* delta bit allocation information */ |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1847 bit_alloc_flags = 127; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1848 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1849 if (ctx->cplinu) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1850 ctx->cpldeltbae = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1851 if (ctx->cpldeltbae == AC3_DBASTR_RESERVED) { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1852 av_log(NULL, AV_LOG_ERROR, "coupling delta bit allocation strategy reserved\n"); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1853 return -1; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1854 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1855 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1856 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1857 for (i = 0; i < nfchans; i++) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1858 ctx->deltbae[i] = get_bits(gb, 2); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1859 if (ctx->deltbae[i] == AC3_DBASTR_RESERVED) { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1860 av_log(NULL, AV_LOG_ERROR, "delta bit allocation strategy reserved\n"); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1861 return -1; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1862 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1863 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1864 |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1865 if (ctx->cplinu) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1866 if (ctx->cpldeltbae == AC3_DBASTR_NEW) { /*coupling delta offset, len and bit allocation */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1867 ctx->cpldeltnseg = get_bits(gb, 3); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1868 for (seg = 0; seg <= ctx->cpldeltnseg; seg++) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1869 ctx->cpldeltoffst[seg] = get_bits(gb, 5); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1870 ctx->cpldeltlen[seg] = get_bits(gb, 4); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1871 ctx->cpldeltba[seg] = get_bits(gb, 3); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1872 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1873 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1874 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1875 for (i = 0; i < nfchans; i++) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1876 if (ctx->deltbae[i] == AC3_DBASTR_NEW) {/*channel delta offset, len and bit allocation */ |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1877 ctx->deltnseg[i] = get_bits(gb, 3); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1878 for (seg = 0; seg <= ctx->deltnseg[i]; seg++) { |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1879 ctx->deltoffst[i][seg] = get_bits(gb, 5); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1880 ctx->deltlen[i][seg] = get_bits(gb, 4); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1881 ctx->deltba[i][seg] = get_bits(gb, 3); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1882 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1883 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1884 } |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1885 |
5310
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1886 if (bit_alloc_flags) { |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1887 if (is_snr_offsets_zero(ctx)) { |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1888 memset(ctx->cplbap, 0, sizeof (ctx->cplbap)); |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1889 memset(ctx->lfebap, 0, sizeof (ctx->lfebap)); |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1890 for (i = 0; i < nfchans; i++) |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1891 memset(ctx->bap[i], 0, sizeof(ctx->bap[i])); |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1892 } else { |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1893 if (ctx->chincpl && (bit_alloc_flags & 64)) |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1894 do_bit_allocation(ctx, 5); |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1895 for (i = 0; i < nfchans; i++) |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1896 if ((bit_alloc_flags >> i) & 1) |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1897 do_bit_allocation(ctx, i); |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1898 if (ctx->lfeon && (bit_alloc_flags & 32)) |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1899 do_bit_allocation(ctx, 6); |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1900 } |
9aa9197034d7
AC-3 decoder, soc revision 40, Aug 9 00:10:14 2006 UTC by cloud9
jbr
parents:
5309
diff
changeset
|
1901 } |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1902 |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1903 if (get_bits1(gb)) { /* unused dummy data */ |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1904 skipl = get_bits(gb, 9); |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1905 while(skipl--) |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1906 skip_bits(gb, 8); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1907 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1908 /* unpack the transform coefficients |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1909 * * this also uncouples channels if coupling is in use. |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1910 */ |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1911 if (get_transform_coeffs(ctx)) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1912 av_log(NULL, AV_LOG_ERROR, "Error in routine get_transform_coeffs\n"); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1913 return -1; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1914 } |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1915 /*for (i = 0; i < nfchans; i++) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1916 dump_floats("channel transform coefficients", 10, ctx->transform_coeffs[i + 1], BLOCK_SIZE);*/ |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1917 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1918 /* recover coefficients if rematrixing is in use */ |
5312
2c875e6274d5
AC-3 decoder, soc revision 52, Aug 16 22:45:07 2006 UTC by cloud9
jbr
parents:
5311
diff
changeset
|
1919 if (ctx->rematflg) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1920 do_rematrixing(ctx); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1921 |
5318
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1922 do_downmix(ctx); |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1923 |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1924 do_imdct(ctx); |
5307
1bcccd2de20d
AC-3 decoder, soc revision 33, Jul 17 12:13:40 2006 UTC by cloud9
jbr
parents:
5306
diff
changeset
|
1925 /*for(i = 0; i < nfchans; i++) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1926 dump_floats("channel output", 10, ctx->output[i + 1], BLOCK_SIZE);*/ |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1927 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1928 return 0; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1929 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1930 |
5318
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1931 static inline int16_t convert(int32_t i) |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1932 { |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1933 if (i > 0x43c07fff) |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1934 return 32767; |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1935 else if (i <= 0x43bf8000) |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1936 return -32768; |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1937 else |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1938 return (i - 0x43c00000); |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1939 } |
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1940 |
5308
82b41f5a86ef
AC-3 decoder, soc revision 34, Jul 18 14:27:54 2006 UTC by cloud9
jbr
parents:
5307
diff
changeset
|
1941 static int frame_count = 0; |
82b41f5a86ef
AC-3 decoder, soc revision 34, Jul 18 14:27:54 2006 UTC by cloud9
jbr
parents:
5307
diff
changeset
|
1942 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1943 /* Decode ac3 frame. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1944 * |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1945 * @param avctx Pointer to AVCodecContext |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1946 * @param data Pointer to pcm smaples |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1947 * @param data_size Set to number of pcm samples produced by decoding |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1948 * @param buf Data to be decoded |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1949 * @param buf_size Size of the buffer |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
1950 */ |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1951 static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t *buf, int buf_size) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1952 { |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1953 AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1954 int frame_start; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1955 int16_t *out_samples = (int16_t *)data; |
5318
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1956 int i, j, k, start; |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1957 int32_t *int_ptr[6]; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1958 |
5318
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1959 for (i = 0; i < 6; i++) |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1960 int_ptr[i] = (int32_t *)(&ctx->output[i]); |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1961 |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
1962 //av_log(NULL, AV_LOG_INFO, "decoding frame %d buf_size = %d\n", frame_count++, buf_size); |
5308
82b41f5a86ef
AC-3 decoder, soc revision 34, Jul 18 14:27:54 2006 UTC by cloud9
jbr
parents:
5307
diff
changeset
|
1963 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1964 //Synchronize the frame. |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1965 frame_start = ac3_synchronize(buf, buf_size); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1966 if (frame_start == -1) { |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1967 av_log(avctx, AV_LOG_ERROR, "frame is not synchronized\n"); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1968 *data_size = 0; |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1969 return buf_size; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1970 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1971 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1972 //Initialize the GetBitContext with the start of valid AC3 Frame. |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1973 init_get_bits(&(ctx->gb), buf + frame_start, (buf_size - frame_start) * 8); |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1974 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1975 //Parse the syncinfo. |
5305
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1976 //If 'fscod' or 'bsid' is not valid the decoder shall mute as per the standard. |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1977 if (!ac3_parse_sync_info(ctx)) { |
5892b4a6380b
AC-3 decoder, soc revision 31, Jul 14 23:53:28 2006 UTC by cloud9
jbr
parents:
5304
diff
changeset
|
1978 av_log(avctx, AV_LOG_ERROR, "\n"); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1979 *data_size = 0; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1980 return buf_size; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1981 } |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1982 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1983 //Parse the BSI. |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1984 //If 'bsid' is not valid decoder shall not decode the audio as per the standard. |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
1985 ac3_parse_bsi(ctx); |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
1986 |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1987 avctx->sample_rate = ctx->sampling_rate; |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1988 avctx->bit_rate = ctx->bit_rate; |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1989 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
1990 if (avctx->channels == 0) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1991 ctx->blkoutput |= AC3_OUTPUT_UNMODIFIED; |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1992 if (ctx->lfeon) |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1993 ctx->blkoutput |= AC3_OUTPUT_LFEON; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1994 avctx->channels = ctx->nfchans + ctx->lfeon; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1995 } |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1996 else if (avctx->channels == 1) |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1997 ctx->blkoutput |= AC3_OUTPUT_MONO; |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
1998 else if (avctx->channels == 2) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
1999 if (ctx->dsurmod == 0x02) |
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
2000 ctx->blkoutput |= AC3_OUTPUT_DOLBY; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2001 else |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
2002 ctx->blkoutput |= AC3_OUTPUT_STEREO; |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
2003 } |
5311
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
2004 else { |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
2005 if (avctx->channels < (ctx->nfchans + ctx->lfeon)) |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
2006 av_log(avctx, AV_LOG_INFO, "ac3_decoder: AC3 Source Channels Are Less Then Specified %d: Output to %d Channels\n",avctx->channels, ctx->nfchans + ctx->lfeon); |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
2007 ctx->blkoutput |= AC3_OUTPUT_UNMODIFIED; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
2008 if (ctx->lfeon) |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
2009 ctx->blkoutput |= AC3_OUTPUT_LFEON; |
7742d5411c9d
AC-3 decoder, soc revision 48, Aug 16 11:27:49 2006 UTC by cloud9
jbr
parents:
5310
diff
changeset
|
2010 avctx->channels = ctx->nfchans + ctx->lfeon; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
2011 } |
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
2012 |
5318
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
2013 //av_log(avctx, AV_LOG_INFO, "channels = %d \t bit rate = %d \t sampling rate = %d \n", avctx->channels, avctx->bit_rate * 1000, avctx->sample_rate); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2014 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2015 //Parse the Audio Blocks. |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
2016 for (i = 0; i < AUDIO_BLOCKS; i++) { |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
2017 if (ac3_parse_audio_block(ctx)) { |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2018 av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n"); |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2019 *data_size = 0; |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
2020 return ctx->frame_size; |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2021 } |
5318
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
2022 start = (ctx->blkoutput & AC3_OUTPUT_LFEON) ? 0 : 1; |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
2023 for (k = 0; k < BLOCK_SIZE; k++) |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
2024 for (j = start; j <= avctx->channels; j++) |
ef4ef249ca72
AC-3 decoder, soc revision 58, Aug 19 14:20:45 2006 UTC by cloud9
jbr
parents:
5317
diff
changeset
|
2025 *(out_samples++) = convert(int_ptr[j][k]); |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2026 } |
5306
abc5c130b448
AC-3 decoder, soc revision 32, Jul 17 09:37:32 2006 UTC by cloud9
jbr
parents:
5305
diff
changeset
|
2027 *data_size = AUDIO_BLOCKS * BLOCK_SIZE * avctx->channels * sizeof (int16_t); |
5309
0662a270aab7
AC-3 decoder, soc revision 38, Aug 7 00:03:00 2006 UTC by cloud9
jbr
parents:
5308
diff
changeset
|
2028 return ctx->frame_size; |
5303
b8821ff5c30d
AC-3 decoder, soc revision 9, Jun 14 03:52:02 2006 UTC by cloud9
jbr
parents:
diff
changeset
|
2029 } |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2030 |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
2031 /* Uninitialize ac3 decoder. |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
2032 */ |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
2033 static int ac3_decode_end(AVCodecContext *avctx) |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2034 { |
5321
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
2035 AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data; |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
2036 ff_mdct_end(&ctx->imdct_512); |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
2037 ff_mdct_end(&ctx->imdct_256); |
fcb2a52c88fe
AC-3 decoder, soc revision 71, Sep 4 09:47:12 2006 UTC by cloud9
jbr
parents:
5320
diff
changeset
|
2038 |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2039 return 0; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2040 } |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2041 |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2042 AVCodec lgpl_ac3_decoder = { |
5315
31033309ebc9
AC-3 decoder, soc revision 55, Aug 17 12:25:24 2006 UTC by cloud9
jbr
parents:
5314
diff
changeset
|
2043 .name = "ac3", |
31033309ebc9
AC-3 decoder, soc revision 55, Aug 17 12:25:24 2006 UTC by cloud9
jbr
parents:
5314
diff
changeset
|
2044 .type = CODEC_TYPE_AUDIO, |
31033309ebc9
AC-3 decoder, soc revision 55, Aug 17 12:25:24 2006 UTC by cloud9
jbr
parents:
5314
diff
changeset
|
2045 .id = CODEC_ID_AC3, |
31033309ebc9
AC-3 decoder, soc revision 55, Aug 17 12:25:24 2006 UTC by cloud9
jbr
parents:
5314
diff
changeset
|
2046 .priv_data_size = sizeof (AC3DecodeContext), |
31033309ebc9
AC-3 decoder, soc revision 55, Aug 17 12:25:24 2006 UTC by cloud9
jbr
parents:
5314
diff
changeset
|
2047 .init = ac3_decode_init, |
31033309ebc9
AC-3 decoder, soc revision 55, Aug 17 12:25:24 2006 UTC by cloud9
jbr
parents:
5314
diff
changeset
|
2048 .close = ac3_decode_end, |
31033309ebc9
AC-3 decoder, soc revision 55, Aug 17 12:25:24 2006 UTC by cloud9
jbr
parents:
5314
diff
changeset
|
2049 .decode = ac3_decode_frame, |
5304
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2050 }; |
eff51058fe13
AC-3 decoder, soc revision 26, Jul 5 04:55:15 2006 UTC by cloud9
jbr
parents:
5303
diff
changeset
|
2051 |