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: ps_hybrid_synthesis.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         Hybrid synthesis
     38 
     39      _______                                              ________
     40     |       |                                  _______   |        |
     41   ->|Hybrid | LF ----                         |       |->| Hybrid |-->
     42     | Anal. |        |                        |       |  | Synth  |   QMF -> L
     43      -------         o----------------------->|       |   --------    Synth
     44 QMF                  |                s_k(n)  |Stereo |-------------->
     45 Anal.              -------------------------->|       |
     46      _______       | |                        |       |   ________
     47     |       | HF --o |   -----------          |Process|  |        |
     48   ->| Delay |      |  ->|           |-------->|       |->| Hybrid |-->
     49      -------       |    |decorrelate| d_k(n)  |       |  | Synth  |   QMF -> R
     50                    ---->|           |-------->|       |   --------    Synth
     51                          -----------          |_______|-------------->
     52 
     53 
     54 ------------------------------------------------------------------------------
     55  REQUIREMENTS
     56 
     57 
     58 ------------------------------------------------------------------------------
     59  REFERENCES
     60 
     61 SC 29 Software Copyright Licencing Disclaimer:
     62 
     63 This software module was originally developed by
     64   Coding Technologies
     65 
     66 and edited by
     67   -
     68 
     69 in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
     70 standards for reference purposes and its performance may not have been
     71 optimized. This software module is an implementation of one or more tools as
     72 specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
     73 ISO/IEC gives users free license to this software module or modifications
     74 thereof for use in products claiming conformance to audiovisual and
     75 image-coding related ITU Recommendations and/or ISO/IEC International
     76 Standards. ISO/IEC gives users the same free license to this software module or
     77 modifications thereof for research purposes and further ISO/IEC standardisation.
     78 Those intending to use this software module in products are advised that its
     79 use may infringe existing patents. ISO/IEC have no liability for use of this
     80 software module or modifications thereof. Copyright is not released for
     81 products that do not conform to audiovisual and image-coding related ITU
     82 Recommendations and/or ISO/IEC International Standards.
     83 The original developer retains full right to modify and use the code for its
     84 own purpose, assign or donate the code to a third party and to inhibit third
     85 parties from using the code for products that do not conform to audiovisual and
     86 image-coding related ITU Recommendations and/or ISO/IEC International Standards.
     87 This copyright notice must be included in all copies or derivative works.
     88 Copyright (c) ISO/IEC 2003.
     89 
     90 ------------------------------------------------------------------------------
     91  PSEUDO-CODE
     92 
     93 ------------------------------------------------------------------------------
     94 */
     95 
     96 
     97 /*----------------------------------------------------------------------------
     98 ; INCLUDES
     99 ----------------------------------------------------------------------------*/
    100 
    101 #ifdef AAC_PLUS
    102 
    103 #ifdef PARAMETRICSTEREO
    104 
    105 #include "s_hybrid.h"
    106 #include "ps_hybrid_synthesis.h"
    107 
    108 /*----------------------------------------------------------------------------
    109 ; MACROS
    110 ; Define module specific macros here
    111 ----------------------------------------------------------------------------*/
    112 
    113 
    114 /*----------------------------------------------------------------------------
    115 ; DEFINES
    116 ; Include all pre-processor statements here. Include conditional
    117 ; compile variables also.
    118 ----------------------------------------------------------------------------*/
    119 #ifndef min
    120 #define min(a, b) ((a) < (b) ? (a) : (b))
    121 #endif
    122 
    123 /*----------------------------------------------------------------------------
    124 ; LOCAL FUNCTION DEFINITIONS
    125 ; Function Prototype declaration
    126 ----------------------------------------------------------------------------*/
    127 
    128 /*----------------------------------------------------------------------------
    129 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
    130 ; Variable declaration - defined here and used outside this module
    131 ----------------------------------------------------------------------------*/
    132 
    133 
    134 /*----------------------------------------------------------------------------
    135 ; EXTERNAL FUNCTION REFERENCES
    136 ; Declare functions defined elsewhere and referenced in this module
    137 ----------------------------------------------------------------------------*/
    138 
    139 
    140 /*----------------------------------------------------------------------------
    141 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
    142 ; Declare variables used in this module but defined elsewhere
    143 ----------------------------------------------------------------------------*/
    144 
    145 
    146 /*----------------------------------------------------------------------------
    147 ; FUNCTION CODE
    148 ----------------------------------------------------------------------------*/
    149 void ps_hybrid_synthesis(const Int32 *mHybridReal,
    150                          const Int32 *mHybridImag,
    151                          Int32 *mQmfReal,
    152                          Int32 *mQmfImag,
    153                          HYBRID *hHybrid)
    154 {
    155     Int32  k;
    156     Int32  band;
    157     HYBRID_RES hybridRes;
    158 
    159     Int32 real;
    160     Int32 imag;
    161     Int32 *ptr_mQmfReal = mQmfReal;
    162     Int32 *ptr_mQmfImag = mQmfImag;
    163     const Int32 *ptr_mHybrid_Re = mHybridReal;
    164     const Int32 *ptr_mHybrid_Im = mHybridImag;
    165 
    166     for (band = 0; band < hHybrid->nQmfBands; band++)
    167     {
    168         hybridRes = (HYBRID_RES)(min(hHybrid->pResolution[band], 6) - 2);
    169 
    170         real  = *(ptr_mHybrid_Re++);
    171         real += *(ptr_mHybrid_Re++);
    172         imag  = *(ptr_mHybrid_Im++);
    173         imag += *(ptr_mHybrid_Im++);
    174 
    175         for (k = (hybridRes >> 1); k != 0; k--)    /*  hybridRes = { 2,4,6 }  */
    176         {
    177             real += *(ptr_mHybrid_Re++);
    178             real += *(ptr_mHybrid_Re++);
    179             imag += *(ptr_mHybrid_Im++);
    180             imag += *(ptr_mHybrid_Im++);
    181         }
    182 
    183         *(ptr_mQmfReal++) = real;
    184         *(ptr_mQmfImag++) = imag;
    185     }
    186 }
    187 
    188 #endif
    189 
    190 
    191 #endif
    192 
    193