YLC: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
No edit summary
(fill missing details)
 
Line 9: Line 9:
  bytes  0- 3 'YLC0'
  bytes  0- 3 'YLC0'
  bytes  4- 7 zero
  bytes  4- 7 zero
  bytes  8-11 offset to luma plane (should be 16)
  bytes  8-11 offset to the Huffman table descriptors (should be 16)
  bytes 12-15 offset to chroma plane
  bytes 12-15 offset to the compressed YUY2 data


Bitstream is read as 32-bit little-endian words MSB.
Bitstream is read as 32-bit little-endian words MSB.


Luma plane contains residues stored as exp-Golomb codes (unary-coded exponent + N bits of mantiss).
Table descriptors contain 256 gamma'-coded weights for each of the four Huffman tables (special, Y delta, U delta, V delta)


Chroma plane contains chroma values coded in groups and uses static Huffman trees:
Delta values are decoded in the following way:


   if (get_bit()) {
   if (get_bit()) {
       val = decode_sym(tree1);
       val = decode_sym(tree1);
       if (val < 0xE1) {
       if (val < 0xE1) {
           output chroma_table[val];
           output predefined YUYV quad from the constant table;
       } else {
       } else {
           for (i = 0; i < (val - 0xDF); i++)
           for (i = 0; i < (val - 0xDF); i++)
Line 35: Line 35:
   }
   }


Looks like for luma plane median prediction is used and for chroma only left prediction is used.
Then the reconstruction stage follows: first left-predict top line (each component independently), then use <code>left + top - topleft</code> prediction on the rest of pixel components. Unlike many other codecs, prediction here wraps around (i.e. left predictor for the first pixel is the last pixel on a previous line) and the initial left and top-left predictors are set to 128 for all components.


[[Category:Video Codecs]]
[[Category:Video Codecs]]
[[Category:Lossless Video Codecs]]
[[Category:Lossless Video Codecs]]
[[Category:Incomplete Video Codecs]]

Latest revision as of 06:56, 22 July 2023

The website names it as "YUY2 Lossless Codec".

Format

bytes  0- 3 'YLC0'
bytes  4- 7 zero
bytes  8-11 offset to the Huffman table descriptors (should be 16)
bytes 12-15 offset to the compressed YUY2 data

Bitstream is read as 32-bit little-endian words MSB.

Table descriptors contain 256 gamma'-coded weights for each of the four Huffman tables (special, Y delta, U delta, V delta)

Delta values are decoded in the following way:

 if (get_bit()) {
     val = decode_sym(tree1);
     if (val < 0xE1) {
         output predefined YUYV quad from the constant table;
     } else {
         for (i = 0; i < (val - 0xDF); i++)
             output {0, 0, 0, 0}
     }
 } else {
     u0 = decode_sym(tree2);
     v0 = decode_sym(tree3);
     u1 = decode_sym(tree2);
     v1 = decode_sym(tree4);

     output { u0, v0, u0 + u1, v1 }
 }

Then the reconstruction stage follows: first left-predict top line (each component independently), then use left + top - topleft prediction on the rest of pixel components. Unlike many other codecs, prediction here wraps around (i.e. left predictor for the first pixel is the last pixel on a previous line) and the initial left and top-left predictors are set to 128 for all components.