Lines Matching refs:pState
49 static EAS_RESULT IMADecoderInit (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState);
50 static EAS_RESULT IMADecoderSample (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState);
51 static void IMADecoderADPCM (S_DECODER_STATE *pState, EAS_U8 nibble);
52 static EAS_RESULT IMADecoderLocate (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState, EAS_I32 time);
82 static EAS_RESULT IMADecoderInit (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState)
84 pState->decoderL.step = 0;
85 pState->decoderR.step = 0;
105 static EAS_RESULT IMADecoderSample (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState)
111 if (pState->hiNibble)
113 IMADecoderADPCM(&pState->decoderL, (EAS_U8)(pState->srcByte >> 4));
114 pState->hiNibble = EAS_FALSE;
121 if ((pState->bytesLeft == 0) && (pState->loopSamples != 0))
124 if ((result = EAS_HWFileSeek(pEASData->hwInstData, pState->fileHandle, (EAS_I32) (pState->startPos + pState->loopLocation))) != EAS_SUCCESS)
126 pState->bytesLeft = pState->byteCount = (EAS_I32) pState->bytesLeftLoop;
127 pState->blockCount = 0;
128 pState->flags &= ~PCM_FLAGS_EMPTY;
129 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "IMADecoderSample: Rewind file to %d, bytesLeft = %d\n", pState->startPos, pState->bytesLeft); */ }
133 if ((pState->blockSize != 0) && (pState->blockCount == 0) && (pState->bytesLeft != 0))
137 if ((result = EAS_HWGetWord(pEASData->hwInstData, pState->fileHandle, &sTemp, EAS_FALSE)) != EAS_SUCCESS)
140 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "Predictor: Was %d, now %d\n", pState->decoderL.acc, sTemp); */ }
142 pState->decoderL.acc = pState->decoderL.x1 = sTemp;
145 if ((result = EAS_HWGetWord(pEASData->hwInstData, pState->fileHandle, &sTemp, EAS_FALSE)) != EAS_SUCCESS)
148 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "Step: Was %d, now %d\n", pState->decoderL.step, sTemp); */ }
150 pState->decoderL.step = sTemp & 0xff;
152 if (pState->flags & PCM_FLAGS_STEREO)
155 if ((result = EAS_HWGetWord(pEASData->hwInstData, pState->fileHandle, &sTemp, EAS_FALSE)) != EAS_SUCCESS)
157 pState->decoderR.acc = pState->decoderR.x1 = sTemp;
160 if ((result = EAS_HWGetWord(pEASData->hwInstData, pState->fileHandle, &sTemp, EAS_FALSE)) != EAS_SUCCESS)
163 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "Step: Was %d, now %d\n", pState->decoderR.step, sTemp); */ }
165 pState->decoderR.step = sTemp & 0xff;
167 pState->blockCount = pState->blockSize - 8;
168 pState->bytesLeft -= 8;
172 pState->blockCount = pState->blockSize - 4;
173 pState->bytesLeft -= 4;
180 if (pState->bytesLeft)
183 if ((result = EAS_HWGetByte(pEASData->hwInstData, pState->fileHandle, &pState->srcByte)) != EAS_SUCCESS)
187 pState->bytesLeft--;
188 pState->blockCount--;
189 IMADecoderADPCM(&pState->decoderL, (EAS_U8)(pState->srcByte & 0x0f));
191 if (pState->flags & PCM_FLAGS_STEREO)
192 IMADecoderADPCM(&pState->decoderR, (EAS_U8)(pState->srcByte >> 4));
194 pState->hiNibble = EAS_TRUE;
200 pState->decoderL.x1 = pState->decoderL.x0;
201 pState->decoderR.x1 = pState->decoderR.x0;
225 static void IMADecoderADPCM (S_DECODER_STATE *pState, EAS_U8 nibble)
231 stepSize = imaStepSizeTable[pState->step];
251 pState->acc -= delta;
253 pState->acc += delta;
256 if (pState->acc > 32767)
257 pState->acc = 32767;
258 if (pState->acc < -32768)
259 pState->acc = -32768;
260 pState->x1 = (EAS_PCM) pState->acc;
263 pState->step += imaIndexTable[nibble];
264 if (pState->step < 0)
265 pState->step = 0;
266 if (pState->step > 88)
267 pState->step = 88;
270 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "In=%u, Pred=%d, Step=%d\n", nibble, pState->acc, imaStepSizeTable[pState->step]); */ }
280 static EAS_RESULT IMADecoderLocate (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState, EAS_I32 time)
296 if (pState->blockSize == 0)
300 if (pState->flags & PCM_FLAGS_STEREO)
301 samplesPerBlock = pState->blockSize - 7;
303 samplesPerBlock = (pState->blockSize << 1) - 7;
310 temp = (msecs * pState->sampleRate);
314 temp += secs * pState->sampleRate;
321 if ((temp > pState->byteCount) && (pState->loopSamples != 0))
327 numBlocks = (EAS_I32) (pState->loopStart / pState->blockSize);
328 samplesInLastBlock = (EAS_I32) pState->loopStart - (numBlocks * pState->blockSize);
331 if (pState->flags & PCM_FLAGS_STEREO)
345 temp = (temp / samplesPerBlock) * pState->blockSize;
353 if ((result = EAS_PESeek(pEASData, pState, &temp)) != EAS_SUCCESS)
357 EAS_ReportEx(_EAS_SEVERITY_NOFILTER, 0x2380b977, 0x00000009 , pState->bytesLeft);
361 pState->blockCount = 0;
362 pState->hiNibble = EAS_FALSE;
363 if ((pState->state != EAS_STATE_PAUSING) && (pState->state != EAS_STATE_PAUSED))
364 pState->state = EAS_STATE_READY;