MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / predictor_calc_error

Function predictor_calc_error

libavcodec/sonic.c:381–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381static int predictor_calc_error(int *k, int *state, int order, int error)
382{
383 int i, x = error - shift_down(k[order-1] * state[order-1], LATTICE_SHIFT);
384
385#if 1
386 int *k_ptr = &(k[order-2]),
387 *state_ptr = &(state[order-2]);
388 for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--)
389 {
390 int k_value = *k_ptr, state_value = *state_ptr;
391 x -= shift_down(k_value * state_value, LATTICE_SHIFT);
392 state_ptr[1] = state_value + shift_down(k_value * x, LATTICE_SHIFT);
393 }
394#else
395 for (i = order-2; i >= 0; i--)
396 {
397 x -= shift_down(k[i] * state[i], LATTICE_SHIFT);
398 state[i+1] = state[i] + shift_down(k[i] * x, LATTICE_SHIFT);
399 }
400#endif
401
402 // don't drift too far, to avoid overflows
403 if (x > (SAMPLE_FACTOR<<16)) x = (SAMPLE_FACTOR<<16);
404 if (x < -(SAMPLE_FACTOR<<16)) x = -(SAMPLE_FACTOR<<16);
405
406 state[0] = x;
407
408 return x;
409}
410
411#if CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER
412// Heavily modified Levinson-Durbin algorithm which

Callers 1

sonic_decode_frameFunction · 0.85

Calls 1

shift_downFunction · 0.85

Tested by

no test coverage detected