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_open.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------------------------------------------------------------------------------ 78*/ 79 80 81/*---------------------------------------------------------------------------- 82; INCLUDES 83----------------------------------------------------------------------------*/ 84 85#ifdef AAC_PLUS 86 87 88#include "sbr_open.h" 89#include "s_sbr_header_data.h" 90#include "init_sbr_dec.h" 91#include "e_sbr_error.h" 92#include "aac_mem_funcs.h" 93 94 95/*---------------------------------------------------------------------------- 96; MACROS 97; Define module specific macros here 98----------------------------------------------------------------------------*/ 99 100 101/*---------------------------------------------------------------------------- 102; DEFINES 103; Include all pre-processor statements here. Include conditional 104; compile variables also. 105----------------------------------------------------------------------------*/ 106 107/*---------------------------------------------------------------------------- 108; LOCAL FUNCTION DEFINITIONS 109; Function Prototype declaration 110----------------------------------------------------------------------------*/ 111 112/*---------------------------------------------------------------------------- 113; LOCAL STORE/BUFFER/POINTER DEFINITIONS 114; Variable declaration - defined here and used outside this module 115----------------------------------------------------------------------------*/ 116const SBR_HEADER_DATA defaultHeader = 117{ 118 HEADER_NOT_INITIALIZED, /* status */ 119 MASTER_RESET, /* masterStatus */ 120 0, /* crcEnable */ 121 UP_BY_2, /* sampleRateMode */ 122 SBR_AMP_RES_3_0, /* ampResolution */ 123 5, /* startFreq */ 124 0, /* stopFreq */ 125 0, /* xover_band */ 126 SBR_FREQ_SCALE_DEFAULT, /* freqScale */ 127 SBR_ALTER_SCALE_DEFAULT, /* alterScale */ 128 SBR_NOISE_BANDS_DEFAULT, /* noise_bands */ 129 0, /* noNoiseBands */ 130 SBR_LIMITER_BANDS_DEFAULT, 131 SBR_LIMITER_GAINS_DEFAULT, 132 SBR_INTERPOL_FREQ_DEFAULT, 133 SBR_SMOOTHING_LENGTH_DEFAULT 134}; 135 136/*---------------------------------------------------------------------------- 137; EXTERNAL FUNCTION REFERENCES 138; Declare functions defined elsewhere and referenced in this module 139----------------------------------------------------------------------------*/ 140 141/*---------------------------------------------------------------------------- 142; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 143; Declare variables used in this module but defined elsewhere 144----------------------------------------------------------------------------*/ 145 146/*---------------------------------------------------------------------------- 147; FUNCTION CODE 148----------------------------------------------------------------------------*/ 149 150void sbr_open(Int32 sampleRate, 151 SBR_DEC *sbrDec, 152 SBRDECODER_DATA * self, 153 bool bDownSampledSbr) 154 155{ 156 Int16 i ; 157 158 SBR_CHANNEL *SbrChannel; 159 160 161 SbrChannel = self->SbrChannel; 162 163 for (i = 0; i < MAX_NUM_CHANNELS; i++) 164 { 165 pv_memset((void *)&(SbrChannel[i]), 166 0, 167 sizeof(SBR_CHANNEL)); 168 169 /* init a default header such that we can at least do upsampling later */ 170 171 pv_memcpy(&(SbrChannel[i].frameData.sbr_header), 172 &defaultHeader, 173 sizeof(SBR_HEADER_DATA)); 174 175 /* should be handled by sample rate mode bit */ 176 if (sampleRate > 24000 || bDownSampledSbr) 177 { 178 SbrChannel[i].frameData.sbr_header.sampleRateMode = SINGLE_RATE; 179 } 180 181 182 SbrChannel[i].outFrameSize = 183 init_sbr_dec(sampleRate, 184 self->SbrChannel[0].frameData.sbr_header.sampleRateMode, 185 sbrDec, 186 &(SbrChannel[i].frameData)); 187 188 SbrChannel[i].syncState = UPSAMPLING; 189 190 SbrChannel[i].frameData.sUp = 1; /* reset mode */ 191 } 192} 193 194#endif 195 196