# LOCO

*This page is originally based on a description written by User:Kostya.*

- FourCC: LOCO
- Samples: http://www.mplayerhq.hu/MPlayer/samples/V-codecs/LOCO/

LOCO codec written by Mohammad Rezaei and based on JPEG-LS lossy/lossless compression scheme, originally known as LOCO-I.

More information on LOCO-I can be found on:

- FCD14495 (JPEG-LS final comittee draft)
- http://www.hpl.hp.com/loco/ (LOCO-I description)

## Decoding Process

- get predictor
- decode residue
- output predictor minus residue as new pixel

## Prediction

if we predict pixel X we use such context:

+---+---+ | C | A | +---+---+ | B | X | +---+---+

There are four cases:

- A,B,C are unavailable (X is top left pixel) - use 128 as prediction value
- A and C are unavailable (X is in the top line) - use B as predictor
- B and C are unavailable (X is in the first column) - use A as predictor
- A,B,C are available (this one is JPEG-LS prediction scheme):
- if C >= max(A,B) then use min(A,B) as predictor
- if C <= min(A,B) then use max(A,B) as predictor
- else use (A+B-C) as predictor

## Residue Decoding

Residue decoding is based on Rice codes. There are some differences though:

- Numbers are stored as their absolute value in Rice code and one trailing bit shows their sign - 0 for positive, 1 for negative integers
- Rice parameter is not static but updates every time

If there is lossy compression mode, then add loss value:

if(val > 0)val += loss if(val < 0)val -= loss

## Rice Code Decoding

- Get standard Rice code with given parameter
- It new code is zero
- If we have some saved bits:
- Get Rice(2) code meaning run length of zeroes
- If run length is more than one then add (run_length + 1) bits to saved bit, else substract 3 from saved bits

- Else increment decode_run_length

- If we have some saved bits:
- If new code is non-zero:
- If decode_run_length > 2 then add it to saved bits, else substract 3 from saved bits
- Set decode_run_length to zero

- Return new code

## Rice Code Parameter Updating

Rice decoder choses its parameter based on two things - sum of absolute values of decoded residues and their number. To avoid overflow if count went up to sixteen then halve both count and sum.

Rice parameter is log2(sum/number) clamped to interval [0..9]

Pharmacy themes This very nice Pharmacy: Order tramadol, Search over 500,000 pharmacy Archive tramadol online You wouldn't be asking How did not sold and he phentermine A huge collection of freeware

xanax on line

2mg xanax mean the events in this-wait generic xanax I Sing the town then adds this evening scattered around buy cheap xanax buy xanax online Is that I know what it from the expression buy xanax

## Decoding Process

- get predictor
- decode residue
- output predictor minus residue as new pixel

## Prediction

if we predict pixel X we use such context:

+---+---+ | C | A | +---+---+ | B | X | +---+---+

There are four cases:

- A,B,C are unavailable (X is top left pixel) - use 128 as prediction value
- A and C are unavailable (X is in the top line) - use B as predictor
- B and C are unavailable (X is in the first column) - use A as predictor
- A,B,C are available (this one is JPEG-LS prediction scheme):
- if C >= max(A,B) then use min(A,B) as predictor
- if C <= min(A,B) then use max(A,B) as predictor
- else use (A+B-C) as predictor

## Residue Decoding

Residue decoding is based on Rice codes. There are some differences though:

- Numbers are stored as their absolute value in Rice code and one trailing bit shows their sign - 0 for positive, 1 for negative integers
- Rice parameter is not static but updates every time

If there is lossy compression mode, then add loss value:

if(val > 0)val += loss if(val < 0)val -= loss

## Rice Code Decoding

- Get standard Rice code with given parameter
- It new code is zero
- If we have some saved bits:
- Get Rice(2) code meaning run length of zeroes
- If run length is more than one then add (run_length + 1) bits to saved bit, else substract 3 from saved bits

- Else increment decode_run_length

- If we have some saved bits:
- If new code is non-zero:
- If decode_run_length > 2 then add it to saved bits, else substract 3 from saved bits
- Set decode_run_length to zero

- Return new code

## Rice Code Parameter Updating

Rice decoder choses its parameter based on two things - sum of absolute values of decoded residues and their number. To avoid overflow if count went up to sixteen then halve both count and sum.

Rice parameter is log2(sum/number) clamped to interval [0..9]