Differences between revisions 4 and 5
Revision 4 as of 2009-11-22 13:12:39
Size: 2879
Editor: 74
Revision 5 as of 2009-11-22 13:13:50
Size: 2887
Editor: 74
Deletions are marked like this. Additions are marked like this.
Line 43: Line 43:
Line 44: Line 45:

Here are some notes on how to integrate YCbCr into pixman:

  • Converting chroma subsampled formats requires interpolation when converting to RGB. This conversion is
    • pixman_filter_neareest:
      • for each destination pixel determine location in source. Then take the nearest luma/chroma samples and apply the matrix.
    • pixman_filter_bilinear:
      • for each destination pixel determine location in source, then determine the four closest luma samples and the four closest chroma samples, then bilinearly filter those and apply the matrix.
    • pixman_filter_convolution:

       for each destination pixel
           s = location in source

           find nearest luma sample 

           align midpoint of convolution kernel with that sample

           for each pixel in convolution kernel,           
               find nearest luma sample, apply weight, add to sum
               find nearest chroma sample, apply weight, add to sum
           apply the color matrix.
  • When YUV formats are added to cairo, cairo will need to set
    • pixman_filter_bilinear on a YUV pattern, even when there is no transformation. For RGB formats with an identity transformation, bilinear is the same as nearest. But as mentioned above, this is not the case for YCbCr formats.
  • Planar formats will be handled with something like this:

         pixman_image_create_bits (format, char **planes, int **rowstrides);
  • If you pass NULL for plane data, the bits will be 0, not
    • black. This is actually already the case because it's somewhat unclear what a premultiplied (0, 0, 0, 0) ARGB pixel actually is.
  • Chroma samples have a defined location; it may be different from
    • video codec to video codec. I believe ds said that it would be fine to use an enum value for each format as opposed to trying to exhaustively describe all the YUV formats. This implies that the chroma shift is embedded in the name. Is there a standard way of referring to chroma shifts?

Proposed API:

typedef enum
} pixman_color_matrix_t:

/* - Default is MATRIX_NONE.
 * - If you set a YCrCb format, then you should also set
 *   a matrix, or things will not make sense
pixman_image_set_color_matrix (pixman_image_t        *image,
                               pixman_color_matrix_t  matrix);

/* 'jpeg' means half-sited chroma positions
 *  'mpeg2' means co-sited positions
typedef enum

} pixman_format_t;

VideoHackfest/pixman (last edited 2009-11-22 13:13:50 by 74)