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 PacketVideo Corp. 21 MP3 Decoder Library 22 23 Filename: pvmp3decoder_api.h 24 25 Date: 09/21/2007 26 27 ------------------------------------------------------------------------------ 28 REVISION HISTORY 29 30 Description: 31 32 ------------------------------------------------------------------------------ 33 INCLUDE DESCRIPTION 34 35 This include file defines the structure tPVMP3DecoderExternal 36 37 ------------------------------------------------------------------------------ 38 */ 39 40 /*---------------------------------------------------------------------------- 41 ; CONTINUE ONLY IF NOT ALREADY DEFINED 42 ----------------------------------------------------------------------------*/ 43 #ifndef PVMP3DECODER_API_H 44 #define PVMP3DECODER_API_H 45 46 /*---------------------------------------------------------------------------- 47 ; INCLUDES 48 ----------------------------------------------------------------------------*/ 49 50 #include "pvmp3_audio_type_defs.h" 51 52 /*---------------------------------------------------------------------------- 53 ; MACROS 54 ; Define module specific macros here 55 ----------------------------------------------------------------------------*/ 56 #ifdef __cplusplus 57 extern "C" 58 { 59 #endif 60 61 /*---------------------------------------------------------------------------- 62 ; DEFINES 63 ; Include all pre-processor statements here. 64 ----------------------------------------------------------------------------*/ 65 66 /*---------------------------------------------------------------------------- 67 ; EXTERNAL VARIABLES REFERENCES 68 ; Declare variables used in this module but defined elsewhere 69 ----------------------------------------------------------------------------*/ 70 71 /*---------------------------------------------------------------------------- 72 ; SIMPLE TYPEDEF'S 73 ----------------------------------------------------------------------------*/ 74 75 /*---------------------------------------------------------------------------- 76 ; ENUMERATED TYPEDEF'S 77 ----------------------------------------------------------------------------*/ 78 typedef enum 79 { 80 flat = 0, 81 bass_boost = 1, 82 rock = 2, 83 pop = 3, 84 jazz = 4, 85 classical = 5, 86 talk = 6, 87 flat_ = 7 88 89 } e_equalization; 90 91 92 93 typedef enum 94 { 95 MP3DEC_SUCCESS = 0, 96 MP3DEC_INVALID_FRAME = 1, 97 MP3DEC_INCOMPLETE_FRAME = 2, 98 MP3DEC_LOST_FRAME_SYNC = 4, 99 MP3DEC_OUTPUT_BUFFER_TOO_SMALL = 8 100 } tPVMP3DecoderErrorCode; 101 102 103 /*---------------------------------------------------------------------------- 104 ; STRUCTURES TYPEDEF'S 105 ----------------------------------------------------------------------------*/ 106 107 typedef struct 108 #ifdef __cplusplus 109 tPVMP3DecoderExternal 110 #endif 111 { 112 113 /* 114 * INPUT: 115 * Pointer to the input buffer that contains the encoded bistream data. 116 * The data is filled in such that the first bit transmitted is 117 * the most-significant bit (MSB) of the first array element. 118 * The buffer is accessed in a linear fashion for speed, and the number of 119 * bytes consumed varies frame to frame. 120 * The calling environment can change what is pointed to between calls to 121 * the decode function, library, as long as the inputBufferCurrentLength, 122 * and inputBufferUsedLength are updated too. Also, any remaining bits in 123 * the old buffer must be put at the beginning of the new buffer. 124 */ 125 uint8 *pInputBuffer; 126 127 /* 128 * INPUT: 129 * Number of valid bytes in the input buffer, set by the calling 130 * function. After decoding the bitstream the library checks to 131 * see if it when past this value; it would be to prohibitive to 132 * check after every read operation. This value is not modified by 133 * the MP3 library. 134 */ 135 int32 inputBufferCurrentLength; 136 137 /* 138 * INPUT/OUTPUT: 139 * Number of elements used by the library, initially set to zero by 140 * the function pvmp3_resetDecoder(), and modified by each 141 * call to pvmp3_framedecoder(). 142 */ 143 int32 inputBufferUsedLength; 144 145 /* 146 * OUTPUT: 147 * holds the predicted frame size. It used on the test console, for parsing 148 * purposes. 149 */ 150 uint32 CurrentFrameLength; 151 152 /* 153 * INPUT: 154 * This variable holds the type of equalization used 155 * 156 * 157 */ 158 e_equalization equalizerType; 159 160 161 /* 162 * INPUT: 163 * The actual size of the buffer. 164 * This variable is not used by the library, but is used by the 165 * console test application. This parameter could be deleted 166 * if this value was passed into these function. 167 */ 168 int32 inputBufferMaxLength; 169 170 /* 171 * OUTPUT: 172 * The number of channels decoded from the bitstream. 173 */ 174 int16 num_channels; 175 176 /* 177 * OUTPUT: 178 * The number of channels decoded from the bitstream. 179 */ 180 int16 version; 181 182 /* 183 * OUTPUT: 184 * The sampling rate decoded from the bitstream, in units of 185 * samples/second. 186 */ 187 int32 samplingRate; 188 189 /* 190 * OUTPUT: 191 * This value is the bitrate in units of bits/second. IT 192 * is calculated using the number of bits consumed for the current frame, 193 * and then multiplying by the sampling_rate, divided by points in a frame. 194 * This value can changes frame to frame. 195 */ 196 int32 bitRate; 197 198 /* 199 * INPUT/OUTPUT: 200 * In: Inform decoder how much more room is available in the output buffer in int16 samples 201 * Out: Size of the output frame in 16-bit words, This value depends on the mp3 version 202 */ 203 int32 outputFrameSize; 204 205 /* 206 * INPUT: 207 * Flag to enable/disable crc error checking 208 */ 209 int32 crcEnabled; 210 211 /* 212 * OUTPUT: 213 * This value is used to accumulate bit processed and compute an estimate of the 214 * bitrate. For debugging purposes only, as it will overflow for very long clips 215 */ 216 uint32 totalNumberOfBitsUsed; 217 218 219 /* 220 * INPUT: (but what is pointed to is an output) 221 * Pointer to the output buffer to hold the 16-bit PCM audio samples. 222 * If the output is stereo, both left and right channels will be stored 223 * in this one buffer. 224 */ 225 226 int16 *pOutputBuffer; 227 228 } tPVMP3DecoderExternal; 229 230 231 #ifdef __cplusplus 232 } 233 #endif 234 235 /*---------------------------------------------------------------------------- 236 ; END 237 ----------------------------------------------------------------------------*/ 238 239 #endif 240 241 242