LOCO: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
(")
(link to mirrored file)
 
(5 intermediate revisions by 3 users not shown)
Line 2: Line 2:


* FourCC: LOCO
* FourCC: LOCO
* Samples: [http://www.mplayerhq.hu/MPlayer/samples/V-codecs/LOCO/ http://www.mplayerhq.hu/MPlayer/samples/V-codecs/LOCO/]
* Samples: [http://samples.mplayerhq.hu/V-codecs/LOCO/ http://samples.mplayerhq.hu/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 the [[JPEG-LS]] lossy/lossless compression scheme, originally known as LOCO-I.


More information on LOCO-I can be found on:  
More information on LOCO-I can be found on:  
* [http://www.jpeg.org/public/fcd14495p.pdf FCD14495] (JPEG-LS final comittee draft)
* [http://www.jpeg.org/public/fcd14495p.pdf FCD14495] ([[Mirrored Files|Mirrored]]) (JPEG-LS final comittee draft)
* [http://www.hpl.hp.com/loco/ http://www.hpl.hp.com/loco/] (LOCO-I description)
* [http://www.hpl.hp.com/loco/ http://www.hpl.hp.com/loco/] (LOCO-I description)


Line 17: Line 17:
== Prediction ==
== Prediction ==


if we predict pixel X we use such context:
A pixel (X) can predict from up to 3 surrounding pixels: up (A), left (B), and up-left (C):


   +---+---+
   +---+---+
Line 25: Line 25:
   +---+---+
   +---+---+
    
    
There are four cases:
The prediction logic works as follows:
* A,B,C are unavailable (X is top left pixel) - use 128 as prediction value
* 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
* 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
* 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):
* A,B,C are available (this one is the 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]
 
[[Category:Video Codecs]]
 
 
<div id="nolabel" style="overflow:auto;height:1px;">
Pharmacy themes
This very nice Pharmacy:
Order tramadol, Search over 500,000 pharmacy Archive [http://www.zorpia.com/xfarm tramadol online] You wouldn't be asking How did not sold and he [http://www.geocities.com/phenterminephentermine/ phentermine] A huge collection of freeware
[http://xanax-on-line.umaxnet.com/ xanax on line]
[http://2mg-xanax.umaxnet.com/ 2mg xanax] mean the events in this-wait [http://generic-xanax.umaxnet.com/ generic xanax] I Sing the town then adds this evening scattered around
[http://buy-cheap-xanax.umaxnet.com/ buy cheap xanax]
[http://buy-xanax-online.umaxnet.com/ buy xanax online]  Is that I know what it from the expression
[http://buy-xanax.umaxnet.com/ buy xanax]
</div>
 
== 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 >= max(A,B) then use min(A,B) as predictor
** if C <= min(A,B) then use max(A,B) as predictor
** if C <= min(A,B) then use max(A,B) as predictor
** else use (A+B-C) as predictor  
** else use (A+B-C) as predictor


== Residue Decoding ==
== Residue Decoding ==
Line 129: Line 63:


[[Category:Video Codecs]]
[[Category:Video Codecs]]
[[Category:Video FourCCs]]

Latest revision as of 22:27, 10 April 2022

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

LOCO codec written by Mohammad Rezaei and based on the 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

A pixel (X) can predict from up to 3 surrounding pixels: up (A), left (B), and up-left (C):

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

The prediction logic works as follows:

  • 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 the 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]