00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef COLORMODELS_H
00020 #define COLORMODELS_H
00021
00022
00023 #define BC_TRANSPARENCY 0
00024 #define BC_COMPRESSED 1
00025 #define BC_RGB8 2
00026 #define BC_RGB565 3
00027 #define BC_BGR565 4
00028 #define BC_BGR888 5
00029 #define BC_BGR8888 6
00030
00031 #define BC_RGB888 9
00032 #define BC_RGBA8888 10
00033 #define BC_ARGB8888 20
00034 #define BC_ABGR8888 21
00035 #define BC_RGB161616 11
00036 #define BC_RGBA16161616 12
00037 #define BC_YUV888 13
00038 #define BC_YUVA8888 14
00039 #define BC_YUV161616 15
00040 #define BC_YUVA16161616 16
00041 #define BC_YUV422 19
00042 #define BC_A8 22
00043 #define BC_A16 23
00044 #define BC_A_FLOAT 31
00045 #define BC_YUV101010 24
00046 #define BC_VYU888 25
00047 #define BC_UYVA8888 26
00048 #define BC_RGB_FLOAT 29
00049 #define BC_RGBA_FLOAT 30
00050
00051 #define BC_YUV420P 7
00052 #define BC_YUV422P 17
00053 #define BC_YUV444P 27
00054 #define BC_YUV411P 18
00055 #define BC_YUV9P 28 // Disasterous cmodel from Sorenson
00056
00057
00058
00059
00060 #define FOURCC_YV12 0x32315659
00061 #define FOURCC_YUV2 0x32595559
00062 #define FOURCC_I420 0x30323449
00063
00064 #undef CLAMP
00065 #define CLAMP(x, y, z) ((x) = ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x))))
00066
00067 #undef CLIP
00068 #define CLIP(x, y, z) ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x)))
00069
00070
00071 #ifdef __cplusplus
00072 extern "C" {
00073 #endif
00074
00075 typedef struct
00076 {
00077 int rtoy_tab[0x100], gtoy_tab[0x100], btoy_tab[0x100];
00078 int rtou_tab[0x100], gtou_tab[0x100], btou_tab[0x100];
00079 int rtov_tab[0x100], gtov_tab[0x100], btov_tab[0x100];
00080
00081 int vtor_tab[0x100], vtog_tab[0x100];
00082 int utog_tab[0x100], utob_tab[0x100];
00083
00084 int *vtor, *vtog, *utog, *utob;
00085
00086 short int vtor_tab8[0x100], vtog_tab8[0x100];
00087 short int utog_tab8[0x100], utob_tab8[0x100];
00088 short int *vtor8, *vtog8, *utog8, *utob8;
00089
00090 float vtor_float_tab[0x100], vtog_float_tab[0x100];
00091 float utog_float_tab[0x100], utob_float_tab[0x100];
00092 float *vtor_float, *vtog_float, *utog_float, *utob_float;
00093
00094 int rtoy_tab16[0x10000], gtoy_tab16[0x10000], btoy_tab16[0x10000];
00095 int rtou_tab16[0x10000], gtou_tab16[0x10000], btou_tab16[0x10000];
00096 int rtov_tab16[0x10000], gtov_tab16[0x10000], btov_tab16[0x10000];
00097
00098 int vtor_tab16[0x10000], vtog_tab16[0x10000];
00099 int utog_tab16[0x10000], utob_tab16[0x10000];
00100 int *vtor16, *vtog16, *utog16, *utob16;
00101
00102 float v16tor_float_tab[0x10000], v16tog_float_tab[0x10000];
00103 float u16tog_float_tab[0x10000], u16tob_float_tab[0x10000];
00104 float *v16tor_float, *v16tog_float, *u16tog_float, *u16tob_float;
00105 } cmodel_yuv_t;
00106
00107 extern cmodel_yuv_t *yuv_table;
00108
00109 int cmodel_calculate_pixelsize(int colormodel);
00110 int cmodel_calculate_datasize(int w, int h, int bytes_per_line, int color_model);
00111 int cmodel_calculate_max(int colormodel);
00112 int cmodel_components(int colormodel);
00113 int cmodel_is_yuv(int colormodel);
00114 int cmodel_has_alpha(int colormodel);
00115
00116
00117 int cmodel_is_planar(int color_model);
00118 void cmodel_to_text(char *string, int cmodel);
00119 int cmodel_from_text(char *text);
00120
00121
00122
00123 void cmodel_transfer(unsigned char **output_rows,
00124 unsigned char **input_rows,
00125 unsigned char *out_y_plane,
00126 unsigned char *out_u_plane,
00127 unsigned char *out_v_plane,
00128 unsigned char *in_y_plane,
00129 unsigned char *in_u_plane,
00130 unsigned char *in_v_plane,
00131 int in_x,
00132 int in_y,
00133 int in_w,
00134 int in_h,
00135 int out_x,
00136 int out_y,
00137 int out_w,
00138 int out_h,
00139 int in_colormodel,
00140 int out_colormodel,
00141 int bg_color,
00142 int in_rowspan,
00143 int out_rowspan);
00144
00145 void cmodel_init_yuv(cmodel_yuv_t *yuv_table);
00146 void cmodel_delete_yuv(cmodel_yuv_t *yuv_table);
00147 int cmodel_bc_to_x(int color_model);
00148
00149 #ifdef __cplusplus
00150 }
00151 #endif
00152
00153 #endif