Home | History | Annotate | Download | only in aacdec
      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: sbr_code_book_envlevel.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 
     45 SC 29 Software Copyright Licencing Disclaimer:
     46 
     47 This software module was originally developed by
     48   Coding Technologies
     49 
     50 and edited by
     51   -
     52 
     53 in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
     54 standards for reference purposes and its performance may not have been
     55 optimized. This software module is an implementation of one or more tools as
     56 specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
     57 ISO/IEC gives users free license to this software module or modifications
     58 thereof for use in products claiming conformance to audiovisual and
     59 image-coding related ITU Recommendations and/or ISO/IEC International
     60 Standards. ISO/IEC gives users the same free license to this software module or
     61 modifications thereof for research purposes and further ISO/IEC standardisation.
     62 Those intending to use this software module in products are advised that its
     63 use may infringe existing patents. ISO/IEC have no liability for use of this
     64 software module or modifications thereof. Copyright is not released for
     65 products that do not conform to audiovisual and image-coding related ITU
     66 Recommendations and/or ISO/IEC International Standards.
     67 The original developer retains full right to modify and use the code for its
     68 own purpose, assign or donate the code to a third party and to inhibit third
     69 parties from using the code for products that do not conform to audiovisual and
     70 image-coding related ITU Recommendations and/or ISO/IEC International Standards.
     71 This copyright notice must be included in all copies or derivative works.
     72 Copyright (c) ISO/IEC 2002.
     73 
     74 ------------------------------------------------------------------------------
     75  PSEUDO-CODE
     76 
     77 ------------------------------------------------------------------------------
     78 */
     79 
     80 
     81 /*----------------------------------------------------------------------------
     82 ; INCLUDES
     83 ----------------------------------------------------------------------------*/
     84 
     85 #ifdef AAC_PLUS
     86 
     87 
     88 #include   "pv_audio_type_defs.h"
     89 /*----------------------------------------------------------------------------
     90 ; MACROS
     91 ; Define module specific macros here
     92 ----------------------------------------------------------------------------*/
     93 
     94 #ifdef __cplusplus
     95 extern "C"
     96 {
     97 #endif
     98 
     99     /*----------------------------------------------------------------------------
    100     ; DEFINES
    101     ; Include all pre-processor statements here. Include conditional
    102     ; compile variables also.
    103     ----------------------------------------------------------------------------*/
    104 
    105     /*----------------------------------------------------------------------------
    106     ; LOCAL FUNCTION DEFINITIONS
    107     ; Function Prototype declaration
    108     ----------------------------------------------------------------------------*/
    109 
    110     /*----------------------------------------------------------------------------
    111     ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
    112     ; Variable declaration - defined here and used outside this module
    113     ----------------------------------------------------------------------------*/
    114 
    115     /*----------------------------------------------------------------------------
    116     ; EXTERNAL FUNCTION REFERENCES
    117     ; Declare functions defined elsewhere and referenced in this module
    118     ----------------------------------------------------------------------------*/
    119 
    120     /*----------------------------------------------------------------------------
    121     ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
    122     ; Declare variables used in this module but defined elsewhere
    123     ----------------------------------------------------------------------------*/
    124     /*******************************************************************************/
    125     /* table       : envelope level, 1.5 dB                                        */
    126     /* theor range : [-58,58], CODE_BOOK_SCF_LAV   = 58                            */
    127     /* implem range: [-60,60], CODE_BOOK_SCF_LAV10 = 60                            */
    128     /* raw stats   : envelopeLevel_00 (yes, wrong suffix in name)  KK 01-03-09     */
    129     /*******************************************************************************/
    130 
    131     /* direction: time
    132        raw table: HuffCode3C2FIX.m/envelopeLevel_00T_cF.mat/m_hALC_cF
    133        built by : FH 01-07-05 */
    134 
    135     extern const Char bookSbrEnvLevel10T[120][2] =
    136     {
    137         {   1,   2 },    { -64, -65 },    {   3,   4 },    { -63, -66 },
    138         {   5,   6 },    { -62, -67 },    {   7,   8 },    { -61, -68 },
    139         {   9,  10 },    { -60, -69 },    {  11,  12 },    { -59, -70 },
    140         {  13,  14 },    { -58, -71 },    {  15,  16 },    { -57, -72 },
    141         {  17,  18 },    { -73, -56 },    {  19,  21 },    { -74,  20 },
    142         { -55, -75 },    {  22,  26 },    {  23,  24 },    { -54, -76 },
    143         { -77,  25 },    { -53, -78 },    {  27,  34 },    {  28,  29 },
    144         { -52, -79 },    {  30,  31 },    { -80, -51 },    {  32,  33 },
    145         { -83, -82 },    { -81, -50 },    {  35,  57 },    {  36,  40 },
    146         {  37,  38 },    { -88, -84 },    { -48,  39 },    { -90, -85 },
    147         {  41,  46 },    {  42,  43 },    { -49, -87 },    {  44,  45 },
    148         { -89, -86 },    { -124, -123 },    {  47,  50 },    {  48,  49 },
    149         { -122, -121 },    { -120, -119 },    {  51,  54 },    {  52,  53 },
    150         { -118, -117 },    { -116, -115 },    {  55,  56 },    { -114, -113 },
    151         { -112, -111 },    {  58,  89 },    {  59,  74 },    {  60,  67 },
    152         {  61,  64 },    {  62,  63 },    { -110, -109 },    { -108, -107 },
    153         {  65,  66 },    { -106, -105 },    { -104, -103 },    {  68,  71 },
    154         {  69,  70 },    { -102, -101 },    { -100, -99 },    {  72,  73 },
    155         { -98, -97 },    { -96, -95 },    {  75,  82 },    {  76,  79 },
    156         {  77,  78 },    { -94, -93 },    { -92, -91 },    {  80,  81 },
    157         { -47, -46 },    { -45, -44 },    {  83,  86 },    {  84,  85 },
    158         { -43, -42 },    { -41, -40 },    {  87,  88 },    { -39, -38 },
    159         { -37, -36 },    {  90, 105 },    {  91,  98 },    {  92,  95 },
    160         {  93,  94 },    { -35, -34 },    { -33, -32 },    {  96,  97 },
    161         { -31, -30 },    { -29, -28 },    {  99, 102 },    { 100, 101 },
    162         { -27, -26 },    { -25, -24 },    { 103, 104 },    { -23, -22 },
    163         { -21, -20 },    { 106, 113 },    { 107, 110 },    { 108, 109 },
    164         { -19, -18 },    { -17, -16 },    { 111, 112 },    { -15, -14 },
    165         { -13, -12 },    { 114, 117 },    { 115, 116 },    { -11, -10 },
    166         {  -9,  -8 },    { 118, 119 },    {  -7,  -6 },    {  -5,  -4 }
    167     };
    168 
    169     /* direction: freq
    170        raw table: HuffCode3C2FIX.m/envelopeLevel_00F_cF.mat/m_hALC_cF
    171        built by : FH 01-07-05 */
    172 
    173     extern const Char bookSbrEnvLevel10F[120][2] =
    174     {
    175         {   1,   2 },    { -64, -65 },    {   3,   4 },    { -63, -66 },
    176         {   5,   6 },    { -67, -62 },    {   7,   8 },    { -68, -61 },
    177         {   9,  10 },    { -69, -60 },    {  11,  13 },    { -70,  12 },
    178         { -59, -71 },    {  14,  16 },    { -58,  15 },    { -72, -57 },
    179         {  17,  19 },    { -73,  18 },    { -56, -74 },    {  20,  23 },
    180         {  21,  22 },    { -55, -75 },    { -54, -53 },    {  24,  27 },
    181         {  25,  26 },    { -76, -52 },    { -77, -51 },    {  28,  31 },
    182         {  29,  30 },    { -50, -78 },    { -79, -49 },    {  32,  36 },
    183         {  33,  34 },    { -48, -47 },    { -80,  35 },    { -81, -82 },
    184         {  37,  47 },    {  38,  41 },    {  39,  40 },    { -83, -46 },
    185         { -45, -84 },    {  42,  44 },    { -85,  43 },    { -44, -43 },
    186         {  45,  46 },    { -88, -87 },    { -86, -90 },    {  48,  66 },
    187         {  49,  56 },    {  50,  53 },    {  51,  52 },    { -92, -42 },
    188         { -41, -39 },    {  54,  55 },    { -105, -89 },    { -38, -37 },
    189         {  57,  60 },    {  58,  59 },    { -94, -91 },    { -40, -36 },
    190         {  61,  63 },    { -20,  62 },    { -115, -110 },    {  64,  65 },
    191         { -108, -107 },    { -101, -97 },    {  67,  89 },    {  68,  75 },
    192         {  69,  72 },    {  70,  71 },    { -95, -93 },    { -34, -27 },
    193         {  73,  74 },    { -22, -17 },    { -16, -124 },    {  76,  82 },
    194         {  77,  79 },    { -123,  78 },    { -122, -121 },    {  80,  81 },
    195         { -120, -119 },    { -118, -117 },    {  83,  86 },    {  84,  85 },
    196         { -116, -114 },    { -113, -112 },    {  87,  88 },    { -111, -109 },
    197         { -106, -104 },    {  90, 105 },    {  91,  98 },    {  92,  95 },
    198         {  93,  94 },    { -103, -102 },    { -100, -99 },    {  96,  97 },
    199         { -98, -96 },    { -35, -33 },    {  99, 102 },    { 100, 101 },
    200         { -32, -31 },    { -30, -29 },    { 103, 104 },    { -28, -26 },
    201         { -25, -24 },    { 106, 113 },    { 107, 110 },    { 108, 109 },
    202         { -23, -21 },    { -19, -18 },    { 111, 112 },    { -15, -14 },
    203         { -13, -12 },    { 114, 117 },    { 115, 116 },    { -11, -10 },
    204         {  -9,  -8 },    { 118, 119 },    {  -7,  -6 },    {  -5,  -4 }
    205     };
    206 
    207     /*******************************************************************************/
    208     /* table       : envelope balance, 1.5 dB                                      */
    209     /* theor range : [-48,48], CODE_BOOK_SCF_LAV = 48                              */
    210     /* implem range: same but mapped to [-24,24], CODE_BOOK_SCF_LAV_BALANCE10 = 24 */
    211     /* raw stats   : envelopePan_00 (yes, wrong suffix in name)  KK 01-03-09       */
    212     /*******************************************************************************/
    213 
    214     /* direction: time
    215        raw table: HuffCode3C.m/envelopePan_00T.mat/v_hALB
    216        built by : FH 01-05-15 */
    217 
    218     extern const Char bookSbrEnvBalance10T[48][2] =
    219     {
    220         { -64,   1 },    { -63,   2 },    { -65,   3 },    { -62,   4 },
    221         { -66,   5 },    { -61,   6 },    { -67,   7 },    { -60,   8 },
    222         { -68,   9 },    {  10,  11 },    { -69, -59 },    {  12,  13 },
    223         { -70, -58 },    {  14,  28 },    {  15,  21 },    {  16,  18 },
    224         { -57,  17 },    { -71, -56 },    {  19,  20 },    { -88, -87 },
    225         { -86, -85 },    {  22,  25 },    {  23,  24 },    { -84, -83 },
    226         { -82, -81 },    {  26,  27 },    { -80, -79 },    { -78, -77 },
    227         {  29,  36 },    {  30,  33 },    {  31,  32 },    { -76, -75 },
    228         { -74, -73 },    {  34,  35 },    { -72, -55 },    { -54, -53 },
    229         {  37,  41 },    {  38,  39 },    { -52, -51 },    { -50,  40 },
    230         { -49, -48 },    {  42,  45 },    {  43,  44 },    { -47, -46 },
    231         { -45, -44 },    {  46,  47 },    { -43, -42 },    { -41, -40 }
    232     };
    233 
    234     /* direction: freq
    235        raw table: HuffCode3C.m/envelopePan_00T.mat/v_hALB
    236        built by : FH 01-05-15 */
    237 
    238     extern const Char bookSbrEnvBalance10F[48][2] =
    239     {
    240         { -64,   1 },    { -65,   2 },    { -63,   3 },    { -66,   4 },
    241         { -62,   5 },    { -61,   6 },    { -67,   7 },    { -68,   8 },
    242         { -60,   9 },    {  10,  11 },    { -69, -59 },    { -70,  12 },
    243         { -58,  13 },    {  14,  17 },    { -71,  15 },    { -57,  16 },
    244         { -56, -73 },    {  18,  32 },    {  19,  25 },    {  20,  22 },
    245         { -72,  21 },    { -88, -87 },    {  23,  24 },    { -86, -85 },
    246         { -84, -83 },    {  26,  29 },    {  27,  28 },    { -82, -81 },
    247         { -80, -79 },    {  30,  31 },    { -78, -77 },    { -76, -75 },
    248         {  33,  40 },    {  34,  37 },    {  35,  36 },    { -74, -55 },
    249         { -54, -53 },    {  38,  39 },    { -52, -51 },    { -50, -49 },
    250         {  41,  44 },    {  42,  43 },    { -48, -47 },    { -46, -45 },
    251         {  45,  46 },    { -44, -43 },    { -42,  47 },    { -41, -40 }
    252     };
    253 
    254     /*******************************************************************************/
    255     /* table       : envelope level, 3.0 dB                                        */
    256     /* theor range : [-29,29], CODE_BOOK_SCF_LAV   = 29                            */
    257     /* implem range: [-31,31], CODE_BOOK_SCF_LAV11 = 31                            */
    258     /* raw stats   : envelopeLevel_11  KK 00-02-03                                 */
    259     /*******************************************************************************/
    260 
    261     /* direction: time
    262        raw table: HuffCode2.m
    263        built by : FH 00-02-04 */
    264 
    265     extern const Char bookSbrEnvLevel11T[62][2] =
    266     {
    267         { -64,   1 },    { -65,   2 },    { -63,   3 },    { -66,   4 },
    268         { -62,   5 },    { -67,   6 },    { -61,   7 },    { -68,   8 },
    269         { -60,   9 },    {  10,  11 },    { -69, -59 },    {  12,  14 },
    270         { -70,  13 },    { -71, -58 },    {  15,  18 },    {  16,  17 },
    271         { -72, -57 },    { -73, -74 },    {  19,  22 },    { -56,  20 },
    272         { -55,  21 },    { -54, -77 },    {  23,  31 },    {  24,  25 },
    273         { -75, -76 },    {  26,  27 },    { -78, -53 },    {  28,  29 },
    274         { -52, -95 },    { -94,  30 },    { -93, -92 },    {  32,  47 },
    275         {  33,  40 },    {  34,  37 },    {  35,  36 },    { -91, -90 },
    276         { -89, -88 },    {  38,  39 },    { -87, -86 },    { -85, -84 },
    277         {  41,  44 },    {  42,  43 },    { -83, -82 },    { -81, -80 },
    278         {  45,  46 },    { -79, -51 },    { -50, -49 },    {  48,  55 },
    279         {  49,  52 },    {  50,  51 },    { -48, -47 },    { -46, -45 },
    280         {  53,  54 },    { -44, -43 },    { -42, -41 },    {  56,  59 },
    281         {  57,  58 },    { -40, -39 },    { -38, -37 },    {  60,  61 },
    282         { -36, -35 },    { -34, -33 }
    283     };
    284 
    285     /* direction: freq
    286        raw table: HuffCode2.m
    287        built by : FH 00-02-04 */
    288 
    289     extern const Char bookSbrEnvLevel11F[62][2] =
    290     {
    291         { -64,   1 },    { -65,   2 },    { -63,   3 },    { -66,   4 },
    292         { -62,   5 },    { -67,   6 },    {   7,   8 },    { -61, -68 },
    293         {   9,  10 },    { -60, -69 },    {  11,  12 },    { -59, -70 },
    294         {  13,  14 },    { -58, -71 },    {  15,  16 },    { -57, -72 },
    295         {  17,  19 },    { -56,  18 },    { -55, -73 },    {  20,  24 },
    296         {  21,  22 },    { -74, -54 },    { -53,  23 },    { -75, -76 },
    297         {  25,  30 },    {  26,  27 },    { -52, -51 },    {  28,  29 },
    298         { -77, -79 },    { -50, -49 },    {  31,  39 },    {  32,  35 },
    299         {  33,  34 },    { -78, -46 },    { -82, -88 },    {  36,  37 },
    300         { -83, -48 },    { -47,  38 },    { -86, -85 },    {  40,  47 },
    301         {  41,  44 },    {  42,  43 },    { -80, -44 },    { -43, -42 },
    302         {  45,  46 },    { -39, -87 },    { -84, -40 },    {  48,  55 },
    303         {  49,  52 },    {  50,  51 },    { -95, -94 },    { -93, -92 },
    304         {  53,  54 },    { -91, -90 },    { -89, -81 },    {  56,  59 },
    305         {  57,  58 },    { -45, -41 },    { -38, -37 },    {  60,  61 },
    306         { -36, -35 },    { -34, -33 }
    307     };
    308 
    309     /*******************************************************************************/
    310     /* table       : envelope balance, 3.0 dB                                      */
    311     /* theor range : [-24,24], CODE_BOOK_SCF_LAV = 24                              */
    312     /* implem range: same but mapped to [-12,12], CODE_BOOK_SCF_LAV_BALANCE11 = 12 */
    313     /* raw stats   : envelopeBalance_11  KK 00-02-03                               */
    314     /*******************************************************************************/
    315 
    316     /* direction: time
    317        raw table: HuffCode3C.m/envelopeBalance_11T.mat/v_hALB
    318        built by : FH 01-05-15 */
    319 
    320     extern const Char bookSbrEnvBalance11T[24][2] =
    321     {
    322         { -64,   1 },    { -63,   2 },    { -65,   3 },    { -66,   4 },
    323         { -62,   5 },    { -61,   6 },    { -67,   7 },    { -68,   8 },
    324         { -60,   9 },    {  10,  16 },    {  11,  13 },    { -69,  12 },
    325         { -76, -75 },    {  14,  15 },    { -74, -73 },    { -72, -71 },
    326         {  17,  20 },    {  18,  19 },    { -70, -59 },    { -58, -57 },
    327         {  21,  22 },    { -56, -55 },    { -54,  23 },    { -53, -52 }
    328     };
    329 
    330     /* direction: time (?)
    331        raw table: HuffCode3C.m/envelopeBalance_11T.mat/v_hALB
    332        built by : FH 01-05-15 */
    333 
    334     extern const Char bookSbrEnvBalance11F[24][2] =
    335     {
    336         { -64,   1 },    { -65,   2 },    { -63,   3 },    { -66,   4 },
    337         { -62,   5 },    { -61,   6 },    { -67,   7 },    { -68,   8 },
    338         { -60,   9 },    {  10,  13 },    { -69,  11 },    { -59,  12 },
    339         { -58, -76 },    {  14,  17 },    {  15,  16 },    { -75, -74 },
    340         { -73, -72 },    {  18,  21 },    {  19,  20 },    { -71, -70 },
    341         { -57, -56 },    {  22,  23 },    { -55, -54 },    { -53, -52 }
    342     };
    343 
    344     /*******************************************************************************/
    345     /* table       : noise level, 3.0 dB                                           */
    346     /* theor range : [-29,29], CODE_BOOK_SCF_LAV   = 29                            */
    347     /* implem range: [-31,31], CODE_BOOK_SCF_LAV11 = 31                            */
    348     /* raw stats   : noiseLevel_11  KK 00-02-03                                    */
    349     /*******************************************************************************/
    350 
    351     /* direction: time
    352        raw table: HuffCode2.m
    353        built by : FH 00-02-04 */
    354 
    355     extern const Char bookSbrNoiseLevel11T[62][2] =
    356     {
    357         { -64,   1 },    { -63,   2 },    { -65,   3 },    { -66,   4 },
    358         { -62,   5 },    { -67,   6 },    {   7,   8 },    { -61, -68 },
    359         {   9,  30 },    {  10,  15 },    { -60,  11 },    { -69,  12 },
    360         {  13,  14 },    { -59, -53 },    { -95, -94 },    {  16,  23 },
    361         {  17,  20 },    {  18,  19 },    { -93, -92 },    { -91, -90 },
    362         {  21,  22 },    { -89, -88 },    { -87, -86 },    {  24,  27 },
    363         {  25,  26 },    { -85, -84 },    { -83, -82 },    {  28,  29 },
    364         { -81, -80 },    { -79, -78 },    {  31,  46 },    {  32,  39 },
    365         {  33,  36 },    {  34,  35 },    { -77, -76 },    { -75, -74 },
    366         {  37,  38 },    { -73, -72 },    { -71, -70 },    {  40,  43 },
    367         {  41,  42 },    { -58, -57 },    { -56, -55 },    {  44,  45 },
    368         { -54, -52 },    { -51, -50 },    {  47,  54 },    {  48,  51 },
    369         {  49,  50 },    { -49, -48 },    { -47, -46 },    {  52,  53 },
    370         { -45, -44 },    { -43, -42 },    {  55,  58 },    {  56,  57 },
    371         { -41, -40 },    { -39, -38 },    {  59,  60 },    { -37, -36 },
    372         { -35,  61 },    { -34, -33 }
    373     };
    374 
    375     /*******************************************************************************/
    376     /* table       : noise balance, 3.0 dB                                         */
    377     /* theor range : [-24,24], CODE_BOOK_SCF_LAV = 24                              */
    378     /* implem range: same but mapped to [-12,12], CODE_BOOK_SCF_LAV_BALANCE11 = 12 */
    379     /* raw stats   : noiseBalance_11  KK 00-02-03                                  */
    380     /*******************************************************************************/
    381 
    382     /* direction: time
    383        raw table: HuffCode3C.m/noiseBalance_11.mat/v_hALB
    384        built by : FH 01-05-15 */
    385 
    386     extern const Char bookSbrNoiseBalance11T[24][2] =
    387     {
    388         { -64,   1 },    { -65,   2 },    { -63,   3 },    {   4,   9 },
    389         { -66,   5 },    { -62,   6 },    {   7,   8 },    { -76, -75 },
    390         { -74, -73 },    {  10,  17 },    {  11,  14 },    {  12,  13 },
    391         { -72, -71 },    { -70, -69 },    {  15,  16 },    { -68, -67 },
    392         { -61, -60 },    {  18,  21 },    {  19,  20 },    { -59, -58 },
    393         { -57, -56 },    {  22,  23 },    { -55, -54 },    { -53, -52 }
    394     };
    395 
    396 #ifdef __cplusplus
    397 }
    398 #endif
    399 
    400 
    401 #endif
    402 
    403 
    404