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: get_ele_list.c 21 22 ------------------------------------------------------------------------------ 23 REVISION HISTORY 24 25 Description: Modified from original shareware code 26 27 Description: Modified to pass variables by reference to eliminate use 28 of global variables. 29 30 Description: Change to PacketVideo standard, rename variables. 31 32 Description: Add own header file, make pInputStream second param for speed. 33 34 Description: Changes per code review: 35 1) Include header file 36 2) Convert to count down 37 3) Add return (not in review) 38 39 Description: 40 (1) Updated copyright header 41 (2) Replaced include of "interface.h" with "e_ProgConfig.h" 42 43 Description: Replace some instances of getbits to get9_n_lessbits 44 when the number of bits read is 9 or less and get1bits 45 when only 1 bit is read. 46 47 Who: Date: 48 Description: 49 ------------------------------------------------------------------------------ 50 INPUT AND OUTPUT DEFINITIONS 51 52 Inputs: 53 pElementList = pointer to an EleList structure - only the field num_ele 54 needs to be set. Data type pointer to EleList. 55 56 pInputStream = pointer to a BITS structure, used by the function getbits 57 to provide data. Data type pointer to BITS 58 59 enableCPE = boolean value indicating the area to be read contains 60 a channel pair element field. Data type Bool 61 62 63 Local Stores/Buffers/Pointers Needed: None 64 65 Global Stores/Buffers/Pointers Needed: None 66 67 Outputs: None 68 69 Pointers and Buffers Modified: 70 pElementList contents are updated with information pertaining to channel 71 configuration. 72 73 pInputBuffer contents are updated to the next location to be read from 74 the input stream. 75 76 Local Stores Modified: None 77 78 Global Stores Modified: None 79 80 ------------------------------------------------------------------------------ 81 FUNCTION DESCRIPTION 82 83 This function is called several times by get_prog_config() to read in part of 84 the program configuration data related to channel setup. 85 86 ------------------------------------------------------------------------------ 87 REQUIREMENTS 88 89 This function shall not have static or global variables. 90 91 ------------------------------------------------------------------------------ 92 REFERENCES 93 94 (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding 95 of moving pictures and associated audio information - Part 7: Advanced 96 Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(), 97 page 16, and section 8.5 "Program Config Element (PCE)", page 30. 98 99 (2) MPEG-2 NBC Audio Decoder 100 "This software module was originally developed by AT&T, Dolby 101 Laboratories, Fraunhofer Gesellschaft IIS in the course of development 102 of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and 103 3. This software module is an implementation of a part of one or more 104 MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 105 Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio 106 standards free license to this software module or modifications thereof 107 for use in hardware or software products claiming conformance to the 108 MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software 109 module in hardware or software products are advised that this use may 110 infringe existing patents. The original developer of this software 111 module and his/her company, the subsequent editors and their companies, 112 and ISO/IEC have no liability for use of this software module or 113 modifications thereof in an implementation. Copyright is not released 114 for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original 115 developer retains full right to use the code for his/her own purpose, 116 assign or donate the code to a third party and to inhibit third party 117 from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. 118 This copyright notice must be included in all copies or derivative 119 works." 120 Copyright(c)1996. 121 122 123 ------------------------------------------------------------------------------ 124 PSEUDO-CODE 125 126 elementCount = pElementList->num_ele; 127 128 FOR (index = 0; index < elementCount; index++) 129 IF (enableCPE != FALSE) THEN 130 pElementList->ele_is_cpe[index] = 131 getbits(LEN_ELE_IS_CPE, pInputStream); 132 ELSE 133 pElementList->ele_is_cpe[index] = 0; 134 END IF 135 136 pElementList->ele_tag[index] = getbits(LEN_TAG, pInputStream); 137 138 END FOR 139 140 RETURNS nothing 141 142 ------------------------------------------------------------------------------ 143 RESOURCES USED 144 When the code is written for a specific target processor the 145 the resources used should be documented below. 146 147 STACK USAGE: [stack count for this module] + [variable to represent 148 stack usage for each subroutine called] 149 150 where: [stack usage variable] = stack usage for [subroutine 151 name] (see [filename].ext) 152 153 DATA MEMORY USED: x words 154 155 PROGRAM MEMORY USED: x words 156 157 CLOCK CYCLES: [cycle count equation for this module] + [variable 158 used to represent cycle count for each subroutine 159 called] 160 161 where: [cycle count variable] = cycle count for [subroutine 162 name] (see [filename].ext) 163 164 ------------------------------------------------------------------------------ 165 */ 166 167 168 169 /*---------------------------------------------------------------------------- 170 ; INCLUDES 171 ----------------------------------------------------------------------------*/ 172 #include "pv_audio_type_defs.h" 173 #include "s_elelist.h" 174 #include "s_bits.h" 175 #include "e_progconfigconst.h" 176 #include "ibstream.h" 177 #include "get_ele_list.h" 178 179 /*---------------------------------------------------------------------------- 180 ; MACROS 181 ; Define module specific macros here 182 ----------------------------------------------------------------------------*/ 183 184 /*---------------------------------------------------------------------------- 185 ; DEFINES 186 ; Include all pre-processor statements here. Include conditional 187 ; compile variables also. 188 ----------------------------------------------------------------------------*/ 189 190 /*---------------------------------------------------------------------------- 191 ; LOCAL FUNCTION DEFINITIONS 192 ; Function Prototype declaration 193 ----------------------------------------------------------------------------*/ 194 195 /*---------------------------------------------------------------------------- 196 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS 197 ; Variable declaration - defined here and used outside this module 198 ----------------------------------------------------------------------------*/ 199 200 /*---------------------------------------------------------------------------- 201 ; EXTERNAL FUNCTION REFERENCES 202 ; Declare functions defined elsewhere and referenced in this module 203 ----------------------------------------------------------------------------*/ 204 205 /*---------------------------------------------------------------------------- 206 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 207 ; Declare variables used in this module but defined elsewhere 208 ----------------------------------------------------------------------------*/ 209 210 /*---------------------------------------------------------------------------- 211 ; FUNCTION CODE 212 ----------------------------------------------------------------------------*/ 213 void get_ele_list( 214 EleList *pElementList, 215 BITS *pInputStream, 216 const Bool enableCPE) 217 { 218 Int index; 219 Int *pEleIsCPE; 220 Int *pEleTag; 221 222 pEleIsCPE = &pElementList->ele_is_cpe[0]; 223 pEleTag = &pElementList->ele_tag[0]; 224 225 for (index = pElementList->num_ele; index > 0; index--) 226 { 227 if (enableCPE != FALSE) 228 { 229 *pEleIsCPE++ = get1bits(/*LEN_ELE_IS_CPE, */pInputStream); 230 } 231 else 232 { 233 *pEleIsCPE++ = FALSE; 234 } 235 236 *pEleTag++ = get9_n_lessbits(LEN_TAG, pInputStream); 237 238 } /* end for (index) */ 239 240 return; 241 242 } /* end get_ele_list */ 243 244