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/set_mc_info.c 21 22 ------------------------------------------------------------------------------ 23 REVISION HISTORY 24 25 Description: Modified per review comments 26 27 Description: Change audioObjectType from Int to enum types 28 29 Who: Date: 30 Description: 31 32 ------------------------------------------------------------------------------ 33 INPUT AND OUTPUT DEFINITIONS 34 35 Inputs: 36 pMC_Info = pointer to structure MC_Info that holds information of 37 multiple channels' configurations 38 Data type pointer to MC_Info 39 40 objectType = variable that holds the Audio Object Type of current 41 file/bitstream. 42 Data type Int 43 44 sampling_rate_idx = variable that indicates the sampling rate of the 45 source file being encoded 46 Data Type Int 47 48 tag = variable that stores the element instance tag of the 49 first (front) channel element. 50 Data type Int 51 52 is_cpe = variable that indicates if a Channel Pair Element (CPE) 53 or a Single Channel Element (SCE) is used. 54 Data type Int (maybe Boolean) 55 56 pWinSeqInfo = array of pointers that points to structures holding 57 frame information of long and short window sequences. 58 Data type FrameInfo 59 60 pSfbwidth128 = array that will store the scalefactor bandwidth of 61 short window sequence frame. 62 Data type Int array 63 64 Local Stores/Buffers/Pointers Needed: 65 None 66 67 Global Stores/Buffers/Pointers Needed: 68 None 69 70 Outputs: 71 return SUCCESS 72 73 Pointers and Buffers Modified: 74 pMC_Info->nch contains the number of channels depending 75 upon if CPE or SCE is used 76 pMC_Info->objectType contents updated with the decoded Audio 77 Object Type 78 79 pMC_Info->ch_info.tag contents updated with the value of decoded 80 channel element tag 81 82 PMC_Info->ch_info.cpe contents updated depending upon if CPE or 83 SCE is used 84 85 pWinSeqInfo contents updated by calling infoinit if 86 sampling_rate_idx is different from 87 previous value 88 89 pSfbWidth128 contents updated by calling infoinit if 90 sampling_rate_idx is different from 91 previous value 92 93 Local Stores Modified: 94 None 95 96 Global Stores Modified: 97 None 98 99 ------------------------------------------------------------------------------ 100 FUNCTION DESCRIPTION 101 102 This function initializes the channel configuration information. The 103 structure MC_Info stores the number of channels, channel element tag. 104 If sampling rate index is different from the previous value, 105 The frame information will be updated by calling infoinit.c 106 107 ------------------------------------------------------------------------------ 108 REQUIREMENTS 109 110 This function shall update the relevant information on channel configs 111 112 ------------------------------------------------------------------------------ 113 REFERENCES 114 115 (1) MPEG-2 NBC Audio Decoder 116 "This software module was originally developed by AT&T, Dolby 117 Laboratories, Fraunhofer Gesellschaft IIS in the course of development 118 of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and 119 3. This software module is an implementation of a part of one or more 120 MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 121 Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio 122 standards free license to this software module or modifications thereof 123 for use in hardware or software products claiming conformance to the 124 MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software 125 module in hardware or software products are advised that this use may 126 infringe existing patents. The original developer of this software 127 module and his/her company, the subsequent editors and their companies, 128 and ISO/IEC have no liability for use of this software module or 129 modifications thereof in an implementation. Copyright is not released 130 for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original 131 developer retains full right to use the code for his/her own purpose, 132 assign or donate the code to a third party and to inhibit third party 133 from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. 134 This copyright notice must be included in all copies or derivative 135 works." 136 Copyright(c)1996. 137 138 (2) ISO/IEC 14496-3: 1999(E) 139 Subpart 1 p20 Table 1.6.3 140 Subpart 4 p30 5.1.2.1 141 Subpart 4 p31 4.5.2.1.1 142 143 ------------------------------------------------------------------------------ 144 PSEUDO-CODE 145 146 pMC_Info->nch = 0; 147 148 pMC_Info->profile = objectType; 149 150 IF (pMC_Info->sampling_rate_idx != sampling_rate_idx) 151 THEN 152 pMC_Info->sampling_rate_idx = sampling_rate_idx; 153 154 CALL infoinit( 155 samp_rate_idx = sampling_rate_idx 156 ppWin_seq_info= pWinSeqInfo 157 pSfbwidth128 = pSfbwidth128) 158 MODIFYING(pWinSeqInfo, pSfbwidth128) 159 RETURNING(None) 160 ENDIF 161 162 pCh_Info = &pMC_Info->ch_info[0]; 163 pCh_Info->tag = tag; 164 165 IF (is_cpe == FALSE) 166 THEN 167 pCh_Info->cpe = FALSE; 168 169 pMC_Info->nch = 1; 170 171 ELSE 172 pCh_Info->cpe = TRUE; 173 pCh_Info = &pMC_Info->ch_info[1]; 174 pCh_Info->tag = tag; 175 pCh_Info->cpe = TRUE; 176 177 pMC_Info->nch = 2; 178 179 ENDIF 180 181 RETURN(SUCCESS) 182 183 ------------------------------------------------------------------------------ 184 RESOURCES USED 185 When the code is written for a specific target processor the 186 the resources used should be documented below. 187 188 STACK USAGE: [stack count for this module] + [variable to represent 189 stack usage for each subroutine called] 190 191 where: [stack usage variable] = stack usage for [subroutine 192 name] (see [filename].ext) 193 194 DATA MEMORY USED: x words 195 196 PROGRAM MEMORY USED: x words 197 198 CLOCK CYCLES: [cycle count equation for this module] + [variable 199 used to represent cycle count for each subroutine 200 called] 201 202 where: [cycle count variable] = cycle count for [subroutine 203 name] (see [filename].ext) 204 205 ------------------------------------------------------------------------------ 206 */ 207 208 209 /*---------------------------------------------------------------------------- 210 ; INCLUDES 211 ----------------------------------------------------------------------------*/ 212 #include "pv_audio_type_defs.h" 213 #include "set_mc_info.h" 214 #include "huffman.h" 215 #include "s_ch_info.h" 216 217 /*---------------------------------------------------------------------------- 218 ; MACROS 219 ; Define module specific macros here 220 ----------------------------------------------------------------------------*/ 221 222 223 /*---------------------------------------------------------------------------- 224 ; DEFINES 225 ; Include all pre-processor statements here. Include conditional 226 ; compile variables also. 227 ----------------------------------------------------------------------------*/ 228 229 /*---------------------------------------------------------------------------- 230 ; LOCAL FUNCTION DEFINITIONS 231 ; Function Prototype declaration 232 ----------------------------------------------------------------------------*/ 233 234 /*---------------------------------------------------------------------------- 235 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS 236 ; Variable declaration - defined here and used outside this module 237 ----------------------------------------------------------------------------*/ 238 239 /*---------------------------------------------------------------------------- 240 ; EXTERNAL FUNCTION REFERENCES 241 ; Declare functions defined elsewhere and referenced in this module 242 ----------------------------------------------------------------------------*/ 243 244 /*---------------------------------------------------------------------------- 245 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 246 ; Declare variables used in this module but defined elsewhere 247 ----------------------------------------------------------------------------*/ 248 249 /*---------------------------------------------------------------------------- 250 ; FUNCTION CODE 251 ----------------------------------------------------------------------------*/ 252 Int set_mc_info( 253 MC_Info *pMC_Info, 254 const tMP4AudioObjectType audioObjectType, /* used to be profile */ 255 const Int sampling_rate_idx, 256 const Int tag, /* always pass-in last element's value */ 257 const Int is_cpe, 258 FrameInfo *pWinSeqInfo[], 259 Int sfbwidth128[] 260 ) 261 { 262 Ch_Info *pCh_Info; /*optional task: eliminate this structure */ 263 264 /* 265 * audioObjectType and sampling rate 266 * re-configure if new sampling rate 267 * 268 */ 269 pMC_Info->audioObjectType = audioObjectType; 270 271 if (pMC_Info->sampling_rate_idx != sampling_rate_idx) 272 { 273 pMC_Info->sampling_rate_idx = sampling_rate_idx; 274 275 Int status; 276 status = infoinit(sampling_rate_idx, 277 pWinSeqInfo, 278 sfbwidth128); 279 if (SUCCESS != status) 280 { 281 return 1; 282 } 283 } 284 285 /* 286 * first setup values for mono config, Single Channel Element (SCE) 287 * then if stereo, go inside if(is_cpe != FALSE) branch to setup 288 * values for stereo. 289 * set the channel counts 290 * save tag for left channel 291 */ 292 pMC_Info->nch = 1 + is_cpe; 293 294 pCh_Info = &pMC_Info->ch_info[0]; 295 pCh_Info->tag = tag; 296 pCh_Info->cpe = is_cpe; 297 298 /* This if branch maybe deleted in the future */ 299 if (is_cpe != FALSE) 300 { 301 /* Channel Pair Element (CPE) */ 302 /* right channel*/ 303 pCh_Info = &pMC_Info->ch_info[1]; 304 pCh_Info->cpe = TRUE; 305 306 } 307 308 return(SUCCESS); /* possible future error checkings */ 309 } 310