annotate libfaad2/sbr_fbt.c @ 12107:bc89ddda34b8

Developers should subscribe to mplayer-cvslog, mention mplayer-docs.
author diego
date Fri, 02 Apr 2004 23:36:06 +0000
parents 3185f64f6350
children 4a370c80fe5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
4 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
6 ** it under the terms of the GNU General Public License as published by
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
8 ** (at your option) any later version.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
9 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
10 ** This program is distributed in the hope that it will be useful,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
13 ** GNU General Public License for more details.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
14 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
16 ** along with this program; if not, write to the Free Software
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
18 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
19 ** Any non-GPL usage of this software or parts of this software is strictly
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
20 ** forbidden.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
21 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
22 ** Commercial non-GPL licensing of this software is possible.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
24 **
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
25 ** $Id: sbr_fbt.c,v 1.3 2003/09/09 18:37:32 menno Exp $
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
26 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
27
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 /* Calculate frequency band tables */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include "sbr_syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include "sbr_fbt.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 /* calculate the start QMF channel for the master frequency band table */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 /* parameter is also called k0 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
42 uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode,
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43 uint32_t sample_rate)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
45 static const uint8_t startMinTable[12] = { 7, 7, 10, 11, 12, 16, 16,
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
46 17, 24, 32, 35, 48 };
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
47 static const uint8_t offsetIndexTable[12] = { 5, 5, 4, 4, 4, 3, 2, 1, 0,
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
48 6, 6, 6 };
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
49 static const int8_t offset[7][16] = {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 { -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7 },
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51 { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13 },
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 { -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 },
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53 { -6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 },
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54 { -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20 },
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 { -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24 },
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56 { 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24, 28, 33 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 };
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
58 uint8_t startMin = startMinTable[get_sr_index(sample_rate)];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
59 uint8_t offsetIndex = offsetIndexTable[get_sr_index(sample_rate)];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
61 #if 0 /* replaced with table (startMinTable) */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62 if (sample_rate >= 64000)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 startMin = (uint8_t)((5000.*128.)/(float)sample_rate + 0.5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65 } else if (sample_rate < 32000) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 startMin = (uint8_t)((3000.*128.)/(float)sample_rate + 0.5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 startMin = (uint8_t)((4000.*128.)/(float)sample_rate + 0.5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
70 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 if (bs_samplerate_mode)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
74 return startMin + offset[offsetIndex][bs_start_freq];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
75
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
76 #if 0 /* replaced by offsetIndexTable */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 switch (sample_rate)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 case 16000:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 return startMin + offset[0][bs_start_freq];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 case 22050:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 return startMin + offset[1][bs_start_freq];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 case 24000:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 return startMin + offset[2][bs_start_freq];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 case 32000:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 return startMin + offset[3][bs_start_freq];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 default:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88 if (sample_rate > 64000)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 return startMin + offset[5][bs_start_freq];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 } else { /* 44100 <= sample_rate <= 64000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92 return startMin + offset[4][bs_start_freq];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
95 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 return startMin + offset[6][bs_start_freq];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 static int32_t longcmp(const void *a, const void *b)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 return ((int32_t)(*(int32_t*)a - *(int32_t*)b));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 /* calculate the stop QMF channel for the master frequency band table */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 /* parameter is also called k2 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
108 uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate,
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
109 uint8_t k0)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 if (bs_stop_freq == 15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 return min(64, k0 * 3);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
114 } else if (bs_stop_freq == 14) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115 return min(64, k0 * 2);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 } else {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
117 static const uint8_t stopMinTable[12] = { 13, 15, 20, 21, 23,
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
118 32, 32, 35, 48, 64, 70, 96 };
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
119 static const int8_t offset[12][14] = {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
120 { 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 37, 44, 51 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
121 { 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 36, 42, 49 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
122 { 0, 2, 4, 6, 8, 11, 14, 17, 21, 25, 29, 34, 39, 44 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
123 { 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 33, 38, 43 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
124 { 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 32, 36, 41 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
125 { 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
126 { 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
127 { 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 20, 23, 26, 29 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
128 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
129 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
130 { 0, -1, -2, -3, -4, -5, -6, -6, -6, -6, -6, -6, -6, -6 },
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
131 { 0, -3, -6, -9, -12, -15, -18, -20, -22, -24, -26, -28, -30, -32 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
132 };
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
133 #if 0
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 int32_t stopDk[13], stopDk_t[14], k2;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
136 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
137 uint8_t stopMin = stopMinTable[get_sr_index(sample_rate)];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
139 #if 0 /* replaced by table lookup */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 if (sample_rate >= 64000)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 stopMin = (uint8_t)((10000.*128.)/(float)sample_rate + 0.5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 } else if (sample_rate < 32000) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144 stopMin = (uint8_t)((6000.*128.)/(float)sample_rate + 0.5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146 stopMin = (uint8_t)((8000.*128.)/(float)sample_rate + 0.5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
148 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
150 #if 0 /* replaced by table lookup */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
151 /* diverging power series */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152 for (i = 0; i <= 13; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154 stopDk_t[i] = (int32_t)(stopMin*pow(64.0/stopMin, i/13.0) + 0.5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156 for (i = 0; i < 13; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 stopDk[i] = stopDk_t[i+1] - stopDk_t[i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
161 /* needed? */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162 qsort(stopDk, 13, sizeof(stopDk[0]), longcmp);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
163
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
164 k2 = stopMin;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
165 for (i = 0; i < bs_stop_freq; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
166 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167 k2 += stopDk[i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
168 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169 return min(64, k2);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
170 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
171 /* bs_stop_freq <= 13 */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
172 return min(64, stopMin + offset[get_sr_index(sample_rate)][min(bs_stop_freq, 13)]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
173 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
174
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
175 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
176 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
177
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178 /* calculate the master frequency table from k0, k2, bs_freq_scale
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 and bs_alter_scale
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
180
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181 version for bs_freq_scale = 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
182 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
183 void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184 uint8_t bs_alter_scale)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 int8_t incr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187 uint8_t k;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 uint8_t dk;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189 uint32_t nrBands, k2Achieved;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190 int32_t k2Diff, vDk[64];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192 memset(vDk, 0, 64*sizeof(int32_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
194 /* mft only defined for k2 > k0 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
195 if (k2 <= k0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197 sbr->N_master = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
198 return;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
200
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 dk = bs_alter_scale ? 2 : 1;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
202
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
203 #if 0 /* replaced by float-less design */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
204 nrBands = 2 * (int32_t)((float)(k2-k0)/(dk*2) + (-1+dk)/2.0f);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
205 #else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
206 if (bs_alter_scale)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
207 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
208 nrBands = (((k2-k0+2)>>2)<<1);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
209 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
210 nrBands = (((k2-k0)>>1)<<1);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
211 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
212 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
213 nrBands = min(nrBands, 63);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
215 k2Achieved = k0 + nrBands * dk;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216 k2Diff = k2 - k2Achieved;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 for (k = 0; k < nrBands; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
218 vDk[k] = dk;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
220 if (k2Diff)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
221 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
222 incr = (k2Diff > 0) ? -1 : 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
223 k = (k2Diff > 0) ? (nrBands-1) : 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
224
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
225 while (k2Diff != 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
226 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
227 vDk[k] -= incr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
228 k += incr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229 k2Diff += incr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
233 sbr->f_master[0] = k0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
234 for (k = 1; k <= nrBands; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
235 sbr->f_master[k] = sbr->f_master[k-1] + vDk[k-1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
236
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
237 sbr->N_master = nrBands;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
238 sbr->N_master = min(sbr->N_master, 64);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
239
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
240 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
241 printf("f_master[%d]: ", nrBands);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
242 for (k = 0; k <= nrBands; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
243 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
244 printf("%d ", sbr->f_master[k]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
246 printf("\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
247 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
248 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
249
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
250
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
251 /*
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
252 This function finds the number of bands using this formula:
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
253 bands * log(a1/a0)/log(2.0) + 0.5
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
254 */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
255 static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
256 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
257 real_t div = (real_t)log(2.0);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
258 if (warp) div *= (real_t)1.3;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
259
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
260 return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
261 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
262
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
263
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265 version for bs_freq_scale > 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
266 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
267 void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
268 uint8_t bs_freq_scale, uint8_t bs_alter_scale)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
269 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
270 uint8_t k, bands, twoRegions;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
271 uint8_t k1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
272 uint32_t nrBand0, nrBand1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
273 int32_t vDk0[64], vDk1[64];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
274 int32_t vk0[64], vk1[64];
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
275 uint8_t temp1[] = { 6, 5, 4 };
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
276
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
277 /* without memset code enters infinite loop,
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
278 so there must be some wrong table access */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
279 memset(vDk0, 0, 64*sizeof(int32_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
280 memset(vDk1, 0, 64*sizeof(int32_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
281 memset(vk0, 0, 64*sizeof(int32_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
282 memset(vk1, 0, 64*sizeof(int32_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
283
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
284 /* mft only defined for k2 > k0 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
285 if (k2 <= k0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
286 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
287 sbr->N_master = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
288 return;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
289 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
290
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
291 bands = temp1[bs_freq_scale-1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
292
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
293 if ((float)k2/(float)k0 > 2.2449)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
294 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
295 twoRegions = 1;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
296 k1 = k0 << 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
297 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
298 twoRegions = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
299 k1 = k2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
300 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
301
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
302 nrBand0 = 2 * find_bands(0, bands, k0, k1);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
303 nrBand0 = min(nrBand0, 63);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
304
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
305 for (k = 0; k <= nrBand0; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
306 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
307 /* diverging power series */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
308 vDk0[k] = (int32_t)(k0 * pow((float)k1/(float)k0, (k+1)/(float)nrBand0)+0.5) -
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
309 (int32_t)(k0 * pow((float)k1/(float)k0, k/(float)nrBand0)+0.5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
310 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
311
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
312 /* needed? */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
313 qsort(vDk0, nrBand0, sizeof(vDk0[0]), longcmp);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
314
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
315 vk0[0] = k0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
316 for (k = 1; k <= nrBand0; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
317 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
318 vk0[k] = vk0[k-1] + vDk0[k-1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
319 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
320
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
321 if (!twoRegions)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
322 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
323 for (k = 0; k <= nrBand0; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
324 sbr->f_master[k] = vk0[k];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
325
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
326 sbr->N_master = nrBand0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
327 sbr->N_master = min(sbr->N_master, 64);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
328 return;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
329 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
330
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
331 nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
332 nrBand1 = min(nrBand1, 63);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
333
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
334 for (k = 0; k <= nrBand1 - 1; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
335 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
336 vDk1[k] = (int32_t)(k1 * pow((float)k2/(float)k1, (k+1)/(float)nrBand1)+0.5) -
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
337 (int32_t)(k1 * pow((float)k2/(float)k1, k/(float)nrBand1)+0.5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
338 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
339
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
340 if (vDk1[0] < vDk0[nrBand0 - 1])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
341 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
342 int32_t change;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
343
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
344 /* needed? */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
345 qsort(vDk1, nrBand1 + 1, sizeof(vDk1[0]), longcmp);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
346 change = vDk0[nrBand0 - 1] - vDk1[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
347 vDk1[0] = vDk0[nrBand0 - 1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
348 vDk1[nrBand1 - 1] = vDk1[nrBand1 - 1] - change;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
349 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
350
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
351 /* needed? */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
352 qsort(vDk1, nrBand1, sizeof(vDk1[0]), longcmp);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
353 vk1[0] = k1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
354 for (k = 1; k <= nrBand1; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
355 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
356 vk1[k] = vk1[k-1] + vDk1[k-1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
357 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
358
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
359 sbr->N_master = nrBand0 + nrBand1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
360 sbr->N_master = min(sbr->N_master, 64);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
361 for (k = 0; k <= nrBand0; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
362 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
363 sbr->f_master[k] = vk0[k];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
364 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
365 for (k = nrBand0 + 1; k <= sbr->N_master; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
366 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
367 sbr->f_master[k] = vk1[k - nrBand0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
368 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
369
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
370 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
371 printf("f_master[%d]: ", sbr->N_master);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
372 for (k = 0; k <= sbr->N_master; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
373 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
374 printf("%d ", sbr->f_master[k]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
375 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
376 printf("\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
377 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
378 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
379
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
380 /* calculate the derived frequency border tables from f_master */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
381 uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
382 uint8_t k2)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
383 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
384 uint8_t k, i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
385 uint32_t minus;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
386
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
387 /* The following relation shall be satisfied: bs_xover_band < N_Master */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
388 if (sbr->N_master <= bs_xover_band)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
389 return 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
390
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
391 sbr->N_high = sbr->N_master - bs_xover_band;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
392 sbr->N_low = (sbr->N_high>>1) + (sbr->N_high - ((sbr->N_high>>1)<<1));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
393
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
394 sbr->n[0] = sbr->N_low;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
395 sbr->n[1] = sbr->N_high;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
396
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
397 for (k = 0; k <= sbr->N_high; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
398 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
399 sbr->f_table_res[HI_RES][k] = sbr->f_master[k + bs_xover_band];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
400 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
401
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
402 sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
403 sbr->kx = sbr->f_table_res[HI_RES][0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
404
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
405 minus = (sbr->N_high & 1) ? 1 : 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
406
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
407 for (k = 0; k <= sbr->N_low; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
408 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
409 if (k == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
410 i = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
411 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
412 i = 2*k - minus;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
413 sbr->f_table_res[LO_RES][k] = sbr->f_table_res[HI_RES][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
414 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
415
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
416 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
417 printf("f_table_res[HI_RES][%d]: ", sbr->N_high);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
418 for (k = 0; k <= sbr->N_high; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
419 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
420 printf("%d ", sbr->f_table_res[HI_RES][k]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
421 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
422 printf("\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
423 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
424 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
425 printf("f_table_res[LO_RES][%d]: ", sbr->N_low);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
426 for (k = 0; k <= sbr->N_low; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
427 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
428 printf("%d ", sbr->f_table_res[LO_RES][k]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
429 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
430 printf("\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
431 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
432
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
433 sbr->N_Q = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
434 if (sbr->bs_noise_bands == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
435 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
436 sbr->N_Q = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
437 } else {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
438 #if 0
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
439 sbr->N_Q = max(1, (int32_t)(sbr->bs_noise_bands*(log(k2/(float)sbr->kx)/log(2.0)) + 0.5));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
440 #else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
441 sbr->N_Q = max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
442 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
443 sbr->N_Q = min(5, sbr->N_Q);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
444 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
445
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
446 for (k = 0; k <= sbr->N_Q; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
447 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
448 if (k == 0)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
449 {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
450 i = 0;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
451 } else { /* is this accurate? */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
452 //i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
453 i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
454 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
455 sbr->f_table_noise[k] = sbr->f_table_res[LO_RES][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
456 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
457
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
458 /* build table for mapping k to g in hf patching */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
459 for (k = 0; k < 64; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
460 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
461 uint8_t g;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
462 for (g = 0; g < sbr->N_Q; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
463 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
464 if ((sbr->f_table_noise[g] <= k) &&
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
465 (k < sbr->f_table_noise[g+1]))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
466 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
467 sbr->table_map_k_to_g[k] = g;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
468 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
469 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
470 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
471 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
472
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
473 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
474 printf("f_table_noise[%d]: ", sbr->N_Q);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
475 for (k = 0; k <= sbr->N_Q; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
476 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
477 printf("%d ", sbr->f_table_noise[k]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
478 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
479 printf("\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
480 #endif
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
481
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
482 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
483 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
484
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
485 /* TODO: blegh, ugly */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
486 /* Modified to calculate for all possible bs_limiter_bands always
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
487 * This reduces the number calls to this functions needed (now only on
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
488 * header reset)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
489 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
490 void limiter_frequency_table(sbr_info *sbr)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
491 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
492 #if 0
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
493 static const real_t limiterBandsPerOctave[] = { REAL_CONST(1.2),
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
494 REAL_CONST(2), REAL_CONST(3) };
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
495 #else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
496 static const real_t limiterBandsCompare[] = { REAL_CONST(1.328125),
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
497 REAL_CONST(1.1875), REAL_CONST(1.125) };
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
498 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
499 uint8_t k, s;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
500 int8_t nrLim;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
501 int32_t limTable[100 /*TODO*/];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
502 uint8_t patchBorders[64/*??*/];
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
503 #if 0
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
504 real_t limBands;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
505 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
506
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
507 sbr->f_table_lim[0][0] = sbr->f_table_res[LO_RES][0] - sbr->kx;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
508 sbr->f_table_lim[0][1] = sbr->f_table_res[LO_RES][sbr->N_low] - sbr->kx;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
509 sbr->N_L[0] = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
510
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
511 for (s = 1; s < 4; s++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
512 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
513 memset(limTable, 0, 100*sizeof(int32_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
514
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
515 #if 0
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
516 limBands = limiterBandsPerOctave[s - 1];
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
517 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
518
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
519 patchBorders[0] = sbr->kx;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
520 for (k = 1; k <= sbr->noPatches; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
521 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
522 patchBorders[k] = patchBorders[k-1] + sbr->patchNoSubbands[k-1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
523 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
524
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
525 for (k = 0; k <= sbr->N_low; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
526 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
527 limTable[k] = sbr->f_table_res[LO_RES][k];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
528 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
529 for (k = 1; k < sbr->noPatches; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
530 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
531 limTable[k+sbr->N_low] = patchBorders[k];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
532 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
533
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
534 /* needed */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
535 qsort(limTable, sbr->noPatches + sbr->N_low, sizeof(limTable[0]), longcmp);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
536 k = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
537 nrLim = sbr->noPatches + sbr->N_low - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
538
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
539 if (nrLim < 0) // TODO: BIG FAT PROBLEM
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
540 return;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
541
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
542 restart:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
543 if (k <= nrLim)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
544 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
545 real_t nOctaves;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
546
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
547 if (limTable[k-1] != 0)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
548 #if 0
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
549 nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
550 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
551 nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
552 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
553 nOctaves = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
554
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
555 #if 0
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
556 if ((MUL(nOctaves,limBands)) < REAL_CONST(0.49))
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
557 #else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
558 if (nOctaves < limiterBandsCompare[s - 1])
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
559 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
560 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
561 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
562 if (limTable[k] != limTable[k-1])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
563 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
564 uint8_t found = 0, found2 = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
565 for (i = 0; i <= sbr->noPatches; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
566 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
567 if (limTable[k] == patchBorders[i])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
568 found = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
569 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
570 if (found)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
571 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
572 found2 = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
573 for (i = 0; i <= sbr->noPatches; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
574 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
575 if (limTable[k-1] == patchBorders[i])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
576 found2 = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
577 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
578 if (found2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
579 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
580 k++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
581 goto restart;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
582 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
583 /* remove (k-1)th element */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
584 limTable[k-1] = sbr->f_table_res[LO_RES][sbr->N_low];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
585 qsort(limTable, sbr->noPatches + sbr->N_low, sizeof(limTable[0]), longcmp);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
586 nrLim--;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
587 goto restart;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
588 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
589 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
590 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
591 /* remove kth element */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
592 limTable[k] = sbr->f_table_res[LO_RES][sbr->N_low];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
593 qsort(limTable, nrLim, sizeof(limTable[0]), longcmp);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
594 nrLim--;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
595 goto restart;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
596 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
597 k++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
598 goto restart;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
599 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
600 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
601
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
602 sbr->N_L[s] = nrLim;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
603 for (k = 0; k <= nrLim; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
604 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
605 sbr->f_table_lim[s][k] = limTable[k] - sbr->kx;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
606 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
607
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
608 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
609 printf("f_table_lim[%d][%d]: ", s, sbr->N_L[s]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
610 for (k = 0; k <= sbr->N_L[s]; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
611 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
612 printf("%d ", sbr->f_table_lim[s][k]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
613 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
614 printf("\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
615 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
616 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
617 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
618
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
619 #endif