400 dst = &vm->
memory[length];
401 for (i = 0; i < numchannels; i++) {
403 memset(&state, 0,
sizeof(state));
404 for (j = i; j < length; j += numchannels) {
405 int8_t
delta = (int8_t)*src++;
406 uint8_t predbyte, byte;
408 state.delta[2] = state.delta[1];
409 state.delta[1] = state.lastdelta - state.delta[0];
410 state.delta[0] = state.lastdelta;
411 predbyte = ((8 * state.lastbyte + state.weight[0] * state.delta[0] + state.weight[1] * state.delta[1] + state.weight[2] * state.delta[2]) >> 3) & 0xFF;
412 byte = (predbyte -
delta) & 0xFF;
413 prederror = delta << 3;
414 state.error[0] += abs(prederror);
415 state.error[1] += abs(prederror - state.delta[0]); state.error[2] += abs(prederror + state.delta[0]);
416 state.error[3] += abs(prederror - state.delta[1]); state.error[4] += abs(prederror + state.delta[1]);
417 state.error[5] += abs(prederror - state.delta[2]); state.error[6] += abs(prederror + state.delta[2]);
418 state.lastdelta = (int8_t)(byte - state.lastbyte);
419 dst[j] = state.lastbyte = byte;
420 if (!(state.count++ & 0x1F)) {
422 for (k = 1; k < 7; k++) {
423 if (state.error[k] < state.error[idx])
426 memset(state.error, 0,
sizeof(state.error));
428 case 1:
if (state.weight[0] >= -16) state.weight[0]--;
break;
429 case 2:
if (state.weight[0] < 16) state.weight[0]++;
break;
430 case 3:
if (state.weight[1] >= -16) state.weight[1]--;
break;
431 case 4:
if (state.weight[1] < 16) state.weight[1]++;
break;
432 case 5:
if (state.weight[2] >= -16) state.weight[2]--;
break;
433 case 6:
if (state.weight[2] < 16) state.weight[2]++;
break;