REVISION
Definition in file DECODER__mp3.c.
#include "../SYSTEM/sys_hardware.h"
#include "../MESSAGE/message.h"
#include "../codec/codec.h"
#include "../coder/coder.h"
#include "decoder.h"
Include dependency graph for DECODER__mp3.c:

Go to the source code of this file.
Defines | |
| #define | FRWD_FSYNC_STEP (80) |
| Number of frame syncs for one time of fwd/rwd. | |
Functions | |
| BOOL | DECODER__mp3 (void) |
| Function serves as the mp3 decoder task handle. | |
Variables | |
| int | _mp3DummyPad [1024] |
| This global is used to fill the gap between subbandWorkspace1 and subbandWorkspace2, because subbandWorkspace1 and subbandWorkspace2 must be aligned 2048 boundary. | |
|
|
Function serves as the mp3 decoder task handle.
Definition at line 69 of file DECODER__mp3.c. References Audio, st_DECODER::averageWordRate, st_DECODER::decode, st_DECODER::decodeBitstrm, Decoder, st_DECODER::decrypt, st_DECODER::firstPacketOffset, st_DECODER::flag, GEN_zeroOut(), st_DECODER::inputBitstrm, st_AUDIO::offset, st_DECODER::pipe, PIPE_writeNext(), st_AUDIO::playtime, st_PCM::sampleRate, SAUDIOTIME_UPDT, and st_DECODER::status. Referenced by DECODER__mp3first(). 00070 {
00071 PIPE_Obj * pipe = &Decoder.pipe;
00072 int error = DECODE_NO_ERROR;
00073 int dataLength, newDataLength;
00074 BOOL ret = TRUE;
00075 unsigned long tmpUL = Audio.playtime;
00076
00077 // Try to decode as long as output pipe is open.
00078 while( PIPE_writeFrameNum(pipe) )
00079 {
00080 BITSTRM_pack(Decoder.decodeBitstrm);
00081 dataLength = BITSTRM_numDataWords(Decoder.decodeBitstrm);
00082
00083 // is there enough data to be decoded?
00084 if( dataLength < INPUT_BUFFER_SIZE - READ_THRESHOLD ) ret = FALSE;
00085
00086 if( dataLength < (Decoder.status.frameSize + VBR_RESERVED_FORSAFE) )
00087 {
00088 // NO. data not enough yet, bring up media task.
00089 return ret;
00090 }
00091
00092 // YES. valid data detected, prepare to decode.
00093 if ( Decoder.flag & (DEC_FFWD|DEC_FRWD|DEC_MEDIASEEK) )
00094 {
00095 //BITSTRM_remove(Decoder.decodeBitstrm, dataLength);
00096 //BITSTRM_pack(Decoder.decodeBitstrm);
00097 BITSTRM_reset(Decoder.decodeBitstrm);
00098 if(Decoder.flag & DEC_MEDIASEEK)
00099 {
00100 mp3ReadPtr = Audio.offset;
00101 DECODE_reset(Decoder.decode);
00102 Decoder.flag &= ~DEC_MEDIASEEK;
00103 }
00104 else
00105 {
00106 if(Decoder.flag & DEC_FFWD) mp3ReadPtr += mp3FastFwdLen;
00107 else if(mp3ReadPtr>mp3FastFwdLen+Decoder.firstPacketOffset)
00108 mp3ReadPtr -= mp3FastFwdLen;
00109 else
00110 {
00111 // Send silence to get rid of the noise.
00112 mp3Silence = 8;
00113 mp3ReadPtr = Decoder.firstPacketOffset;
00114 }
00115 }
00116 mp3EndOfReadPtr = mp3ReadPtr;
00117 Decoder.flag &= ~(DEC_FFWD|DEC_FRWD);
00118 ret = FALSE;
00119
00120 tmpUL = 0;
00121 if(mp3ReadPtr > Decoder.firstPacketOffset)
00122 tmpUL = (mp3ReadPtr-Decoder.firstPacketOffset)/Decoder.averageWordRate;
00123
00124 mp3FrameIdx = (tmpUL*(Decoder.status.sampleRate/36))>>4;
00125 break;
00126 }
00127 else
00128 {
00129 if(mp3Silence)
00130 {
00131 GEN_zeroOut((UINT16*)pipe->WrFrame.Frame, MP3_PIPE_FRAMELEN);
00132 mp3Silence--;
00133 }
00134 else
00135 {
00136 // decode the bitstream
00137 error = DECODE_decode( Decoder.decode,
00138 Decoder.decodeBitstrm,
00139 (Int *)pipe->WrFrame.Frame);
00140
00141 BITSTRM_pack(Decoder.decodeBitstrm);
00142 newDataLength = BITSTRM_numDataWords(Decoder.decodeBitstrm);
00143 mp3ReadPtr += dataLength-newDataLength;
00144
00145 if (error == DECODE_NO_ERROR)
00146 {
00147 // Get decode status, which will be checked in codec data
00148 // feed routine.
00149 DECODE_getStatus(Decoder.decode, &Decoder.status);
00150 if(Decoder.status.isValid)
00151 {
00152 unsigned long sampleRate = Decoder.status.sampleRate;
00153 Pcm.sampleRate = sampleRate;
00154 PCM_samplerateChanged();
00155 mp3FastFwdLen = 5L*Decoder.status.bitRate>>4;
00156
00157 mp3FrameIdx++;
00158 tmpUL = (mp3FrameIdx<<4)/(sampleRate/36);
00159 }
00160 }
00161 }
00162 }
00163
00164 // Any error detected?
00165 if (error == DECODE_NO_ERROR) PIPE_writeNext(pipe);
00166 else if(error == DECODE_ERROR)
00167 {
00168 // Error, resync on the next call. Note that the output
00169 // pipe frame is kept for next decoding attempt.
00170 SCRYPT_reset(Decoder.decrypt);
00171 DECODE_reset(Decoder.decode);
00172 BITSTRM_reset(Decoder.inputBitstrm);
00173 }
00174 //else if (error == DECODE_NO_DATA){}
00175 }
00176
00177 // Check to update time.
00178 if ( Audio.playtime != tmpUL )
00179 {
00180 Audio.playtime = tmpUL;
00181 mMSG_send(sysMsgQ, SYS_MSG_ID, SAUDIOTIME_UPDT, DONTCARE, 0);
00182 }
00183
00184 return ret;
00185 }
|
Here is the call graph for this function:

1.3.9.1