[cairo] glitz - YUV - _glitz_pixel_transform_op_t stride

Patrick Pailhes patrick.pailhes at gmail.com
Mon Feb 6 11:44:28 PST 2006


Hi there,

I have looked at the code in glitz_pixel.c about YV12/RGB conversion
(notably the functions _fetch_yv12, _store_yv12 and
_glitz_pixel_transform). I want to implement and test the functions
_fetch_imc2 and _store_imc2 that would perform respectively IMC2/RGB
and RGB/IMC2 conversions. The IMC2 format is very similar to YV12. The
difference is that the V and U lines are interleaved at half stride
boundaries.

Now, in terms of code, the structure glitz_pixel_transform_op_t holds
the Y, U and V components (see below):

typedef struct _glitz_pixel_transform_op {
    char                 *line, *line2, *line3;
    int                  offset;
    glitz_pixel_format_t *format;
    glitz_pixel_color_t  *color;
} glitz_pixel_transform_op_t;

For YV12, Y is stored in line, V in line2 and U in line3. However, 
for the IMC2 format, both V and U would be stored in the variable
line2. Now, I believe that we need an extra a variable in the
structure glitz_pixel_transform_op_t. This variable would hold the
stride of the YUV array (i.e. the width of the surface). The stride is
needed in order to retrieve the U components (see below):

int16_t u = ((uint8_t *)op->line2)[(op->offset >> 1) + (op->stride >>
1)] - 128; // u = op->line2[offset/2 + half stride])

Thus, I think we could add a minor change to the structure
glitz_pixel_transform_op_t:

typedef struct _glitz_pixel_transform_op {
    char                 *line, *line2, *line3;
    int                  offset;
    int stride;
    glitz_pixel_format_t *format;
    glitz_pixel_color_t  *color;
} glitz_pixel_transform_op_t;


Regards,

Patrick Pailhes


More information about the cairo mailing list