for (i = 0; i < s->channels; i++) s->last_delta[i] = predictor[i];
static int dpcm_decode_frame(AVCodecContext *avctx,                             void *data, int *data_size,                             uint8_t *buf, int buf_size){    DPCMContext *s = avctx->priv_data;    int in, out = 0;    int i;    int predictor[2];    int channel_number = 0;    short *output_samples = data;    int sequence_number;    int shift[2];    unsigned char byte;    short diff;    switch(avctx->codec->id) {    case CODEC_ID_ROQ_DPCM:        if (s->channels == 1)            predictor[0] = LE_16(&buf[6]);        else {            predictor[0] = buf[7] << 8;            predictor[1] = buf[6] << 8;        }        SE_16BIT(predictor[0]);        SE_16BIT(predictor[1]);        /* decode the samples */        for (in = 8, out = 0; in < buf_size; in++, out++) {            predictor[channel_number] += s->roq_square_array[buf[in]];            SATURATE_S16(predictor[channel_number]);            output_samples[out] = predictor[channel_number];            /* toggle channel */            channel_number ^= s->channels - 1;        }        break;    case CODEC_ID_INTERPLAY_DPCM:        in = 0;        sequence_number = LE_16(&buf[in]);        in += 6;  /* skip over the stream mask and stream length */        if (sequence_number == 1) {            predictor[0] = LE_16(&buf[in]);            in += 2;            SE_16BIT(predictor[0])            if (s->channels == 2) {                predictor[1] = LE_16(&buf[in]);                SE_16BIT(predictor[1])                in += 2;            }        } else {            for (i = 0; i < s->channels; i++)                predictor[i] = s->last_delta[i];        }        while (in < buf_size) {            predictor[channel_number] += interplay_delta_table[buf[in++]];            SATURATE_S16(predictor[channel_number]);            output_samples[out++] = predictor[channel_number];            /* toggle channel */            channel_number ^= s->channels - 1;        }        /* save predictors for next round */        for (i = 0; i < s->channels; i++)            s->last_delta[i] = predictor[i];        break;    case CODEC_ID_XAN_DPCM:        in = 0;        shift[0] = shift[1] = 4;        predictor[0] = LE_16(&buf[in]);        in += 2;        SE_16BIT(predictor[0]);        if (s->channels == 2) {            predictor[1] = LE_16(&buf[in]);            in += 2;            SE_16BIT(predictor[1]);        }        while (in < buf_size) {            byte = buf[in++];            diff = (byte & 0xFC) << 8;            if ((byte & 0x03) == 3)                shift[channel_number]++;            else                shift[channel_number] -= (2 * (byte & 3));            /* saturate the shifter to a lower limit of 0 */            if (shift[channel_number] < 0)                shift[channel_number] = 0;            diff >>= shift[channel_number];            predictor[channel_number] += diff;            SATURATE_S16(predictor[channel_number]);            output_samples[out++] = predictor[channel_number];            /* toggle channel */            channel_number ^= s->channels - 1;        }        break;    }    *data_size = out * sizeof(short);    return buf_size;}