1/* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18/*
19
20 Filename: get_sbr_stopfreq.c
21
22------------------------------------------------------------------------------
23 REVISION HISTORY
24
25
26 Who:                                   Date: MM/DD/YYYY
27 Description:
28
29------------------------------------------------------------------------------
30 INPUT AND OUTPUT DEFINITIONS
31
32
33
34------------------------------------------------------------------------------
35 FUNCTION DESCRIPTION
36
37
38------------------------------------------------------------------------------
39 REQUIREMENTS
40
41
42------------------------------------------------------------------------------
43 REFERENCES
44
45SC 29 Software Copyright Licencing Disclaimer:
46
47This software module was originally developed by
48  Coding Technologies
49
50and edited by
51  -
52
53in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
54standards for reference purposes and its performance may not have been
55optimized. This software module is an implementation of one or more tools as
56specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
57ISO/IEC gives users free license to this software module or modifications
58thereof for use in products claiming conformance to audiovisual and
59image-coding related ITU Recommendations and/or ISO/IEC International
60Standards. ISO/IEC gives users the same free license to this software module or
61modifications thereof for research purposes and further ISO/IEC standardisation.
62Those intending to use this software module in products are advised that its
63use may infringe existing patents. ISO/IEC have no liability for use of this
64software module or modifications thereof. Copyright is not released for
65products that do not conform to audiovisual and image-coding related ITU
66Recommendations and/or ISO/IEC International Standards.
67The original developer retains full right to modify and use the code for its
68own purpose, assign or donate the code to a third party and to inhibit third
69parties from using the code for products that do not conform to audiovisual and
70image-coding related ITU Recommendations and/or ISO/IEC International Standards.
71This copyright notice must be included in all copies or derivative works.
72Copyright (c) ISO/IEC 2002.
73
74------------------------------------------------------------------------------
75 PSEUDO-CODE
76
77     if(fs < 32000)
78     {
79         k1_min = (Int) ( ( (float) (6000 * 2 * 64) / fs ) + 0.5 );
80     }
81     else
82     {
83         if (fs < 64000)
84         {
85             k1_min = (Int) ( ( (float) (8000 * 2 * 64) / fs ) + 0.5 );
86         }
87         else
88         {
89             k1_min = (Int) ( ((float) (10000 * 2 * 64) / fs ) + 0.5);
90         }
91     }
92
93     return((Int)( k1_min * pow( 64.0 / k1_min,(stop_freq)/13.0) + 0.5));
94
95------------------------------------------------------------------------------
96*/
97
98
99/*----------------------------------------------------------------------------
100; INCLUDES
101----------------------------------------------------------------------------*/
102
103#ifdef AAC_PLUS
104
105#include    "get_sbr_stopfreq.h"
106/*----------------------------------------------------------------------------
107; MACROS
108; Define module specific macros here
109----------------------------------------------------------------------------*/
110
111
112/*----------------------------------------------------------------------------
113; DEFINES
114; Include all pre-processor statements here. Include conditional
115; compile variables also.
116----------------------------------------------------------------------------*/
117
118/*----------------------------------------------------------------------------
119; LOCAL FUNCTION DEFINITIONS
120; Function Prototype declaration
121----------------------------------------------------------------------------*/
122
123/*----------------------------------------------------------------------------
124; LOCAL STORE/BUFFER/POINTER DEFINITIONS
125; Variable declaration - defined here and used outside this module
126----------------------------------------------------------------------------*/
127
128/*----------------------------------------------------------------------------
129; EXTERNAL FUNCTION REFERENCES
130; Declare functions defined elsewhere and referenced in this module
131----------------------------------------------------------------------------*/
132
133/*----------------------------------------------------------------------------
134; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
135; Declare variables used in this module but defined elsewhere
136----------------------------------------------------------------------------*/
137
138/*----------------------------------------------------------------------------
139; FUNCTION CODE
140----------------------------------------------------------------------------*/
141
142const UChar sbr_stopfreq_tbl[6][13] =
143{
144
145    { 21, 23, 25, 27, 29, 32, 35, 38, 41, 45, 49, 54, 59},  /* 48000  */
146    { 23, 25, 27, 29, 31, 34, 37, 40, 43, 47, 51, 55, 59},  /* 44100  */
147    { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61},  /* 32000  and 24000 */
148    { 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 58, 61},  /* 22050  */
149    { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62}   /* 16000  */
150
151};
152
153Int get_sbr_stopfreq(const Int32 fs,
154                     const Int32 stop_freq)
155{
156
157    Int i;
158
159    switch (fs)
160    {
161        case 48000:
162            i = 0;
163            break;
164
165        case 32000:
166        case 24000:
167            i = 2;
168            break;
169
170        case 22050:
171            i = 3;
172            break;
173
174        case 16000:
175            i = 4;
176            break;
177
178        case 44100:
179        default:
180            i = 1;
181            break;
182    }
183
184    return((Int)sbr_stopfreq_tbl[i][stop_freq]);
185
186}
187
188
189
190#endif
191