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  Pathname: ./src/digit_reversal_tables.c
     21  Funtions:
     22 
     23 ------------------------------------------------------------------------------
     24  REVISION HISTORY
     25 
     26  Who:                       Date:
     27  Description:
     28 
     29   ------------------------------------------------------------------------------
     30  MODULE DESCRIPTION
     31 
     32   Tables for digit reverse operation
     33 
     34 ------------------------------------------------------------------------------
     35 */
     36 
     37 
     38 /*----------------------------------------------------------------------------
     39 ; INCLUDES
     40 ----------------------------------------------------------------------------*/
     41 
     42 #include "digit_reversal_tables.h"
     43 #include "imdct_fxp.h"
     44 
     45 /*----------------------------------------------------------------------------
     46 ; MACROS
     47 ; Define module specific macros here
     48 ----------------------------------------------------------------------------*/
     49 
     50 /*----------------------------------------------------------------------------
     51 ; DEFINES
     52 ; Include all pre-processor statements here. Include conditional
     53 ; compile variables also.
     54 ----------------------------------------------------------------------------*/
     55 
     56 /*----------------------------------------------------------------------------
     57 ; LOCAL FUNCTION DEFINITIONS
     58 ; Function Prototype declaration
     59 ----------------------------------------------------------------------------*/
     60 
     61 /*----------------------------------------------------------------------------
     62 ; LOCAL VARIABLE DEFINITIONS
     63 ; Variable declaration - defined here and used outside this module
     64 ----------------------------------------------------------------------------*/
     65 
     66 
     67 /*----------------------------------------------------------------------------
     68 ; EXTERNAL FUNCTION REFERENCES
     69 ; Declare functions defined elsewhere and referenced in this module
     70 ----------------------------------------------------------------------------*/
     71 
     72 /*----------------------------------------------------------------------------
     73 ; EXTERNAL VARIABLES REFERENCES
     74 ; Declare variables used in this module but defined elsewhere
     75 ----------------------------------------------------------------------------*/
     76 
     77 /*
     78 ------------------------------------------------------------------------------
     79  Digit Reverse tables
     80 ------------------------------------------------------------------------------
     81 */
     82 
     83 const Int16 digit_reverse_64[ 64] =
     84 {
     85     + 0,  + 32,  + 64,  + 96,
     86     + 8,  + 40,  + 72, + 104,
     87     + 16,  + 48,  + 80, + 112,
     88     + 24,  + 56,  + 88, + 120,
     89     + 2,  + 34,  + 66,  + 98,
     90     + 10,  + 42,  + 74, + 106,
     91     + 18,  + 50,  + 82, + 114,
     92     + 26,  + 58,  + 90, + 122,
     93     + 4,  + 36,  + 68, + 100,
     94     + 12,  + 44,  + 76, + 108,
     95     + 20,  + 52,  + 84, + 116,
     96     + 28,  + 60,  + 92, + 124,
     97     + 6,  + 38,  + 70, + 102,
     98     + 14,  + 46,  + 78, + 110,
     99     + 22,  + 54,  + 86, + 118,
    100     + 30,  + 62,  + 94, + 126
    101 };
    102 
    103 
    104 const Int16 digit_reverse_256[ 256] =
    105 {
    106     + 0, + 128, + 256, + 384,
    107     + 32, + 160, + 288, + 416,
    108     + 64, + 192, + 320, + 448,
    109     + 96, + 224, + 352, + 480,
    110     + 8, + 136, + 264, + 392,
    111     + 40, + 168, + 296, + 424,
    112     + 72, + 200, + 328, + 456,
    113     + 104, + 232, + 360, + 488,
    114     + 16, + 144, + 272, + 400,
    115     + 48, + 176, + 304, + 432,
    116     + 80, + 208, + 336, + 464,
    117     + 112, + 240, + 368, + 496,
    118     + 24, + 152, + 280, + 408,
    119     + 56, + 184, + 312, + 440,
    120     + 88, + 216, + 344, + 472,
    121     + 120, + 248, + 376, + 504,
    122     + 2, + 130, + 258, + 386,
    123     + 34, + 162, + 290, + 418,
    124     + 66, + 194, + 322, + 450,
    125     + 98, + 226, + 354, + 482,
    126     + 10, + 138, + 266, + 394,
    127     + 42, + 170, + 298, + 426,
    128     + 74, + 202, + 330, + 458,
    129     + 106, + 234, + 362, + 490,
    130     + 18, + 146, + 274, + 402,
    131     + 50, + 178, + 306, + 434,
    132     + 82, + 210, + 338, + 466,
    133     + 114, + 242, + 370, + 498,
    134     + 26, + 154, + 282, + 410,
    135     + 58, + 186, + 314, + 442,
    136     + 90, + 218, + 346, + 474,
    137     + 122, + 250, + 378, + 506,
    138     + 4, + 132, + 260, + 388,
    139     + 36, + 164, + 292, + 420,
    140     + 68, + 196, + 324, + 452,
    141     + 100, + 228, + 356, + 484,
    142     + 12, + 140, + 268, + 396,
    143     + 44, + 172, + 300, + 428,
    144     + 76, + 204, + 332, + 460,
    145     + 108, + 236, + 364, + 492,
    146     + 20, + 148, + 276, + 404,
    147     + 52, + 180, + 308, + 436,
    148     + 84, + 212, + 340, + 468,
    149     + 116, + 244, + 372, + 500,
    150     + 28, + 156, + 284, + 412,
    151     + 60, + 188, + 316, + 444,
    152     + 92, + 220, + 348, + 476,
    153     + 124, + 252, + 380, + 508,
    154     + 6, + 134, + 262, + 390,
    155     + 38, + 166, + 294, + 422,
    156     + 70, + 198, + 326, + 454,
    157     + 102, + 230, + 358, + 486,
    158     + 14, + 142, + 270, + 398,
    159     + 46, + 174, + 302, + 430,
    160     + 78, + 206, + 334, + 462,
    161     + 110, + 238, + 366, + 494,
    162     + 22, + 150, + 278, + 406,
    163     + 54, + 182, + 310, + 438,
    164     + 86, + 214, + 342, + 470,
    165     + 118, + 246, + 374, + 502,
    166     + 30, + 158, + 286, + 414,
    167     + 62, + 190, + 318, + 446,
    168     + 94, + 222, + 350, + 478,
    169     + 126, + 254, + 382, + 510
    170 };
    171 
    172 
    173 
    174 
    175 const Int16 digit_reverse_swap_256[ 241] =
    176 {
    177     + 2, + 128,   + 4, + 256,
    178     + 6, + 384,   + 8,  + 32,
    179     + 10, + 160,  + 12, + 288,
    180     + 14, + 416,  + 16,  + 64,
    181     + 18, + 192,  + 20, + 320,
    182     + 22, + 448,  + 24,  + 96,
    183     + 26, + 224,  + 28, + 352,
    184     + 30, + 480,  + 34, + 136,
    185     + 36, + 264,  + 38, + 392,
    186     + 42, + 168,  + 44, + 296,
    187     + 46, + 424,  + 48,  + 72,
    188     + 50, + 200,  + 52, + 328,
    189     + 54, + 456,  + 56, + 104,
    190     + 58, + 232,  + 60, + 360,
    191     + 62, + 488,  + 66, + 144,
    192     + 68, + 272,  + 70, + 400,
    193     + 74, + 176,  + 76, + 304,
    194     + 78, + 432,  + 82, + 208,
    195     + 84, + 336,  + 86, + 464,
    196     + 88, + 112,  + 90, + 240,
    197     + 92, + 368,  + 94, + 496,
    198     + 98, + 152, + 100, + 280,
    199     + 102, + 408, + 106, + 184,
    200     + 108, + 312, + 110, + 440,
    201     + 114, + 216, + 116, + 344,
    202     + 118, + 472, + 122, + 248,
    203     + 124, + 376, + 126, + 504,
    204     + 132, + 258, + 134, + 386,
    205     + 138, + 162, + 140, + 290,
    206     + 142, + 418, + 146, + 194,
    207     + 148, + 322, + 150, + 450,
    208     + 154, + 226, + 156, + 354,
    209     + 158, + 482, + 164, + 266,
    210     + 166, + 394, + 172, + 298,
    211     + 174, + 426, + 178, + 202,
    212     + 180, + 330, + 182, + 458,
    213     + 186, + 234, + 188, + 362,
    214     + 190, + 490, + 196, + 274,
    215     + 198, + 402, + 204, + 306,
    216     + 206, + 434, + 212, + 338,
    217     + 214, + 466, + 218, + 242,
    218     + 220, + 370, + 222, + 498,
    219     + 228, + 282, + 230, + 410,
    220     + 236, + 314, + 238, + 442,
    221     + 244, + 346, + 246, + 474,
    222     + 252, + 378, + 254, + 506,
    223     + 262, + 388, + 268, + 292,
    224     + 270, + 420, + 276, + 324,
    225     + 278, + 452, + 284, + 356,
    226     + 286, + 484, + 294, + 396,
    227     + 302, + 428, + 308, + 332,
    228     + 310, + 460, + 316, + 364,
    229     + 318, + 492, + 326, + 404,
    230     + 334, + 436, + 342, + 468,
    231     + 348, + 372, + 350, + 500,
    232     + 358, + 412, + 366, + 444,
    233     + 374, + 476, + 382, + 508,
    234     + 398, + 422, + 406, + 454,
    235     + 414, + 486, + 438, + 462,
    236     + 446, + 494, + 478, + 502
    237 };
    238 
    239 
    240 #ifdef __cplusplus
    241 extern "C"
    242 {
    243 #endif
    244 
    245     void digit_reversal_swapping(Int32 *y, Int32 *x);
    246 
    247 #ifdef __cplusplus
    248 }
    249 #endif
    250 
    251 void digit_reversal_swapping(Int32 *y, Int32 *x)
    252 {
    253     Int16 i, j;
    254     Int32 tmp[2];
    255     const Int16 *pTable;
    256 
    257     pTable = digit_reverse_swap_256;
    258 
    259     for (Int k = 120; k != 0; k--)
    260     {
    261         i = *pTable++;
    262         j = *pTable++;
    263         tmp[0] = y[i];
    264         tmp[1] = y[i+1];
    265         y[i]   = y[j];
    266         y[i+1] = y[j+1];
    267         y[j]   = tmp[0];
    268         y[j+1] = tmp[1];
    269 
    270         tmp[0] = x[j];
    271         tmp[1] = x[j+1];
    272         x[j]   = x[i];
    273         x[j+1] = x[i+1];
    274         x[i]   = tmp[0];
    275         x[i+1] = tmp[1];
    276 
    277     }
    278 
    279 }
    280