LOCO: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
(Fixed link on FCD)
m (sample link)
Line 1: Line 1:
''This page is originally based on a description written by [[User:Kostya]].''
''This page is originally based on a description written by [[User:Kostya]].''


* FOURCC: LOCO
* FourCC: LOCO
* Samples: [http://www.mplayerhq.hu/MPlayer/samples/V-codecs/LOCO/ 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.
LOCO codec written by Mohammad Rezaei and based on JPEG-LS lossy/lossless compression scheme, originally known as LOCO-I.

Revision as of 23:50, 16 March 2006

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

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:

Decoding Process

  1. get predictor
  2. decode residue
  3. 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 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]