libquicktime: Color handling

# Color handling

## Defines
#define | BC_RGB565 2
#define | BC_BGR565 3
#define | BC_BGR888 4
#define | BC_BGR8888 5
#define | BC_RGB888 6
#define | BC_RGBA8888 7
#define | BC_RGB161616 8
#define | BC_RGBA16161616 9
#define | BC_YUVA8888 10
#define | BC_YUV422 13
#define | BC_YUV420P 14
#define | BC_YUV422P 15
#define | BC_YUV444P 16
#define | BC_YUV411P 17
#define | BC_YUVJ420P 18
#define | BC_YUVJ422P 19
#define | BC_YUVJ444P 20
#define | BC_YUV422P16 21
#define | BC_YUV444P16 22
#define | LQT_COLORMODEL_NONE -1
## Functions
const char * | lqt_colormodel_to_string (int colormodel)
| Convert a colormodel to a human readable string.
int | lqt_string_to_colormodel (const char *str)
| Convert a description string to a colormodel.
int | lqt_colormodel_is_planar (int colormodel)
| Check if a colormodel is planar.
int | lqt_colormodel_has_alpha (int colormodel)
| Check if a colormodel has an alpha (transperency) channel.
int | lqt_colormodel_is_rgb (int colormodel)
| Check, if a colormodel is RGB based.
int | lqt_colormodel_is_yuv (int colormodel)
| Check, if a colormodel is YUV based.
void | lqt_colormodel_get_chroma_sub (int colormodel, int *sub_h, int *sub_v)
| Get the chroma subsampling factors.
void | lqt_get_default_rowspan (int colormodel, int width, int *rowspan, int *rowspan_uv)
| Get the default row span for a colormodel and an image width.
int | lqt_colormodel_has_conversion (int in_cmodel, int out_cmodel)
| Check if a colormodel conversion is supported by libquicktime.
int | lqt_num_colormodels ()
| Get number of supported colormodels.
const char * | lqt_get_colormodel_string (int index)
| Get a colormodel string.
int | lqt_get_colormodel (int index)
| Get a colormodel.

## Detailed Description

Libquicktime has a built in colormodel converter, which can do implicit colormodel conversions while en-/decoding. It is, however, far from perfect: It is incomplete (i.e. not all conversions are present), slow and sometimes inaccurate. Therefore, there is a possibility to bypass internal colormodel conversions.

## Define Documentation

#define BC_RGB565 2

16 bit RGB. Each pixel is a uint16_t in native byte order. Color masks are: for red: 0xf800, for green: 0x07e0, for blue: 0x001f

#define BC_BGR565 3

16 bit BGR. Each pixel is a uint16_t in native byte order. Color masks are: for red: 0x001f, for green: 0x07e0, for blue: 0xf800

#define BC_BGR888 4

24 bit BGR. Each color is an uint8_t. Color order is BGR

#define BC_BGR8888 5

32 bit BGR. Each color is an uint8_t. Color order is BGRXBGRX, where X is unused

#define BC_RGB888 6

24 bit RGB. Each color is an uint8_t. Color order is RGB

#define BC_RGBA8888 7

32 bit RGBA. Each color is an uint8_t. Color order is RGBARGBA

#define BC_RGB161616 8

48 bit RGB. Each color is an uint16_t in native byte order. Color order is RGB

#define BC_RGBA16161616 9

64 bit RGBA. Each color is an uint16_t in native byte order. Color order is RGBA

#define BC_YUVA8888 10

Packed YCbCrA 4:4:4:4. Each component is an uint8_t. Component order is YUVA

#define BC_YUV422 13

Packed YCbCr 4:2:2. Each component is an uint8_t. Component order is Y1 U1 Y2 V1

#define BC_YUV420P 14

Planar YCbCr 4:2:0. Each component is an uint8_t. Chroma placement is defined by lqt_chroma_placement_t

#define BC_YUV422P 15

Planar YCbCr 4:2:2. Each component is an uint8_t

#define BC_YUV444P 16

Planar YCbCr 4:4:4. Each component is an uint8_t

#define BC_YUV411P 17

Planar YCbCr 4:1:1. Each component is an uint8_t

#define BC_YUVJ420P 18

Planar YCbCr 4:2:0. Each component is an uint8_t, luma and chroma values are full range (0x00 .. 0xff)

#define BC_YUVJ422P 19

Planar YCbCr 4:2:2. Each component is an uint8_t, luma and chroma values are full range (0x00 .. 0xff)

#define BC_YUVJ444P 20

Planar YCbCr 4:4:4. Each component is an uint8_t, luma and chroma values are full range (0x00 .. 0xff)

#define BC_YUV422P16 21

16 bit Planar YCbCr 4:2:2. Each component is an uint16_t in native byte order.

#define BC_YUV444P16 22

16 bit Planar YCbCr 4:4:4. Each component is an uint16_t in native byte order.

#define LQT_COLORMODEL_NONE -1

This value is used for termination of colormodel arrays

## Function Documentation

const char* lqt_colormodel_to_string | ( | int | colormodel | ) |

Convert a colormodel to a human readable string.

Parameters:

  | colormodel | A colormodel

Returns:
  A description of the colormodel

int lqt_string_to_colormodel | ( | const char * | str | ) |

Convert a description string to a colormodel.

Parameters:

  | str | A colormodel description (as returned by lqt_colormodel_to_string)

Returns:
  The corresponding colormodel or LQT_COLORMODEL_NONE

int lqt_colormodel_is_planar | ( | int | colormodel | ) |

Check if a colormodel is planar.

Parameters:

  | colormodel | A colormodel

Returns:
  1 if the colormodel is planar, 0 else

int lqt_colormodel_has_alpha | ( | int | colormodel | ) |

Check if a colormodel has an alpha (transperency) channel.

Parameters:

  | colormodel | A colormodel

Returns:
  1 if the colormodel has an alpha channel, 0 else

int lqt_colormodel_is_rgb | ( | int | colormodel | ) |

Check, if a colormodel is RGB based.

Parameters:

  | colormodel | A colormodel

Returns:
  1 if the colormodel is RGB based, 0 else

int lqt_colormodel_is_yuv | ( | int | colormodel | ) |

Check, if a colormodel is YUV based.

Parameters:

  | colormodel | A colormodel

Returns:
  1 if the colormodel is YUV based, 0 else

void lqt_colormodel_get_chroma_sub | ( | int | colormodel,
|  | int * | sub_h,
|  | int * | sub_v |
| ) |  |  |

Get the chroma subsampling factors.

Parameters:

  | colormodel | A colormodel
  | sub_h | Returns the horizontal subsampling factor
  | sub_v | Returns the vertical subsampling factor

void lqt_get_default_rowspan | ( | int | colormodel,
|  | int | width,
|  | int * | rowspan,
|  | int * | rowspan_uv |
| ) |  |  |

Get the default row span for a colormodel and an image width.

Parameters:

  | colormodel | A colormodel
  | width | Image width
  | rowspan | Returns the rowspan for the luminance (Y) plane
  | rowspan_uv | Returns the rowspan for the chrominance (U/V) planes

The rowspan is the byte offset between scanlines. It can be calculated from the colormodel and the image width. Some APIs however, padd the scanlines to certain boundaries, so the rowspans might become larger here (see lqt_set_row_span and lqt_set_row_span_uv).

int lqt_colormodel_has_conversion | ( | int | in_cmodel,
|  | int | out_cmodel |
| ) |  |  |

Check if a colormodel conversion is supported by libquicktime.

Parameters:

  | in_cmodel | Input colormodel
  | out_cmodel | Output colormodel

Returns:
  1 if the requested conversion is possible, 0 else

As noted before, the colormodel converter is not complete, and this function checks it. As a fallback, conversions from and to BC_RGB888 are always supported. If you need a converison, which is not present, contact the authors for hints how to write it :)

int lqt_num_colormodels | ( |  | ) |

Get number of supported colormodels.

Returns:
  The number of colormodels known to your version of libquicktime

const char* lqt_get_colormodel_string | ( | int | index | ) |

Get a colormodel string.

Parameters:

  | index | Index of the colormodel (between 0 and the return value of lqt_num_colormodels - 1)

Returns:
  A description of the colormodel according to index or NULL.

int lqt_get_colormodel | ( | int | index | ) |

Get a colormodel.

Parameters:

  | index | Index of the colormodel (between 0 and the return value of lqt_num_colormodels - 1)

Returns:
  The colormodel according to index or LQT_COLORMODEL_NONE