Lines Matching refs:state
44 struct MS_ADPCM_decodestate state[2];
81 static Sint32 MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
92 new_sample = ((state->iSamp1 * coeff[0]) +
93 (state->iSamp2 * coeff[1]))/256;
95 new_sample += state->iDelta * (nybble-0x10);
97 new_sample += state->iDelta * nybble;
105 delta = ((Sint32)state->iDelta * adaptive[nybble])/256;
109 state->iDelta = (Uint16)delta;
110 state->iSamp2 = state->iSamp1;
111 state->iSamp1 = (Sint16)new_sample;
117 struct MS_ADPCM_decodestate *state[2];
140 state[0] = &MS_ADPCM_state.state[0];
141 state[1] = &MS_ADPCM_state.state[stereo];
144 state[0]->hPredictor = *encoded++;
146 state[1]->hPredictor = *encoded++;
148 state[0]->iDelta = ((encoded[1]<<8)|encoded[0]);
151 state[1]->iDelta = ((encoded[1]<<8)|encoded[0]);
154 state[0]->iSamp1 = ((encoded[1]<<8)|encoded[0]);
157 state[1]->iSamp1 = ((encoded[1]<<8)|encoded[0]);
160 state[0]->iSamp2 = ((encoded[1]<<8)|encoded[0]);
163 state[1]->iSamp2 = ((encoded[1]<<8)|encoded[0]);
166 coeff[0] = MS_ADPCM_state.aCoeff[state[0]->hPredictor];
167 coeff[1] = MS_ADPCM_state.aCoeff[state[1]->hPredictor];
170 decoded[0] = state[0]->iSamp2&0xFF;
171 decoded[1] = state[0]->iSamp2>>8;
174 decoded[0] = state[1]->iSamp2&0xFF;
175 decoded[1] = state[1]->iSamp2>>8;
178 decoded[0] = state[0]->iSamp1&0xFF;
179 decoded[1] = state[0]->iSamp1>>8;
182 decoded[0] = state[1]->iSamp1&0xFF;
183 decoded[1] = state[1]->iSamp1>>8;
192 new_sample = MS_ADPCM_nibble(state[0],nybble,coeff[0]);
199 new_sample = MS_ADPCM_nibble(state[1],nybble,coeff[1]);
222 struct IMA_ADPCM_decodestate state[2];
245 static Sint32 IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state,Uint8 nybble)
268 step = step_table[state->index];
274 state->sample += delta;
277 state->index += index_table[nybble];
278 if ( state->index > 88 ) {
279 state->index = 88;
281 if ( state->index < 0 ) {
282 state->index = 0;
286 if ( state->sample > max_audioval ) {
287 state->sample = max_audioval;
289 if ( state->sample < min_audioval ) {
290 state->sample = min_audioval;
292 return(state->sample);
297 int channel, int numchannels, struct IMA_ADPCM_decodestate *state)
306 new_sample = IMA_ADPCM_nibble(state, nybble);
313 new_sample = IMA_ADPCM_nibble(state, nybble);
325 struct IMA_ADPCM_decodestate *state;
330 /* Check to make sure we have enough variables in the state array */
332 if ( channels > SDL_arraysize(IMA_ADPCM_state.state) ) {
334 SDL_arraysize(IMA_ADPCM_state.state));
337 state = IMA_ADPCM_state.state;
357 /* Fill the state information for this block */
358 state[c].sample = ((encoded[1]<<8)|encoded[0]);
360 if ( state[c].sample & 0x8000 ) {
361 state[c].sample -= 0x10000;
363 state[c].index = *encoded++;
370 decoded[0] = (Uint8)(state[c].sample&0xFF);
371 decoded[1] = (Uint8)(state[c].sample>>8);
380 c, channels, &state[c]);