Please consider a donation to the Higher Intellect project. See https://preterhuman.net/donate.php or the Donate to Higher Intellect page for more info.

CL FORMAT YCbCr422DC and DM IMAGE PACKING CbYCrYYY

From Higher Intellect Vintage Wiki
Jump to navigation Jump to search

This section of the packings document described the 4:2:0 sampling pattern.

There are two libraries which can represent data in this format: the the DM (digital media library), via DM_IMAGE_PACKING_CbYCrYYY, and the CL (Compression Library), via CL_FORMAT_YCbCr422DC (DC stands for "Duplicate Chroma"). The CL representation looks exactly like a 4:2:2 packing, except that each pair of image lines has identical Cr,Cb values. An example:

Say we have an image which is 4 pixels wide and 2 pixels high:

   1   2   3   4   
   5   6   7   8

Encoding that with the 420 DM_IMAGE_PACKING_CbYCrYYY packing, I'd get

this in memory (increasing mem address):

   byte[ 0] = Cb(center of 1256) 
   byte[ 1] = Y(1) 
   byte[ 2] = Cr(center of 1256)
   byte[ 3] = Y(2) 
   byte[ 4] = Y(5)
   byte[ 5] = Y(6) 
   byte[ 6] = Cb(center of 3478) 
   byte[ 7] = Y(3) 
   byte[ 8] = Cr(center of 3478)
   byte[ 9] = Y(4) 
   byte[10] = Y(7)
   byte[11] = Y(8) 

With the CL_FORMAT_YCbCr422DC packing, what I get instead is this:

   byte[ 0] = Cb(center of 1256) 
   byte[ 1] = Y(1) 
   byte[ 2] = Cr(center of 1256)
   byte[ 3] = Y(2) 
   byte[ 4] = Cb(center of 3478) 
   byte[ 5] = Y(3) 
   byte[ 6] = Cr(center of 3478)
   byte[ 7] = Y(4) 
   byte[ 8] = Cb(center of 1256) AGAIN -- duplicate
   byte[ 9] = Y(5) 
   byte[10] = Cr(center of 1256) AGAIN -- duplicate
   byte[11] = Y(6) 
   byte[12] = Cb(center of 3478) AGAIN -- duplicate
   byte[13] = Y(7) 
   byte[14] = Cr(center of 3478) AGAIN -- duplicate
   byte[15] = Y(8) 

Say the image lines are numbered 0,1,2,3,4,.... If you are using CL_FORMAT_YCbCr422DC and the chroma on lines 0,2,4,6,... is not identical to that on lnies 1,3,5,7,..., then it is an error.