39 #define CM_HAVE_YCGCO_SUPPORT
40 #define CM_DRIVER_T xxxx_driver_t
73#define CM_CONFIG_NAME "video.output.color_matrix"
74#define CM_CONFIG_SIGNAL 0
75#define CM_CONFIG_SIZE 1
79#define CR_CONFIG_NAME "video.output.color_range"
80#define CR_CONFIG_AUTO 0
81#define CR_CONFIG_MPEG 1
82#define CR_CONFIG_FULL 2
88 "full range ITU-R 709 / HDTV",
90 "full range, undefined",
91 "ITU-R 470 BG / SDTV",
92 "full range ITU-R 470 BG / SDTV",
95 "ITU-R 470 BG / SDTV",
96 "full range ITU-R 470 BG / SDTV",
98 "full range SMPTE 170M",
100 "full range SMPTE 240M",
101#if defined(CM_HAVE_YCGCO_SUPPORT) || defined(CM_HAVE_BT2020_SUPPORT)
105 "fullrange BT.2020 NCL",
107 "fullrange BT.2020 CL",
126static const char *
const cm_conf_labels[] = {
127 "Signal",
"Signal+Size",
"SD",
"HD",
NULL
130static const char *
const cr_conf_labels[] = {
131 "Auto",
"MPEG",
"FULL",
NULL
134#ifdef CM_HAVE_YCGCO_SUPPORT
140#ifdef CM_HAVE_BT2020_SUPPORT
141# define CM_2020 18,20
143# define CM_2020 10,10
151 10, 2,10, 6, 8,10,12,14,CM_G,CM_2020,10,10,10,10,10,
152 10, 2, 0, 6, 8,10,12,14,CM_G,CM_2020,10,10,10,10,10,
153 10,10,10,10,10,10,10,10,CM_G, 10, 10,10,10,10,10,10,
154 10, 2, 2, 2, 2, 2, 2, 2,CM_G, 2, 2, 2, 2, 2, 2, 2
160 const uint8_t *a = cm_m + ((this->cm_state >> 2) << 4);
161 uint8_t *d = this->cm_lut, *e = d + 32;
170 for (i = 1; i < 32; i += 2)
171 this->cm_lut[i] |= 1;
175 for (i = 0; i < 32; i += 1)
176 this->cm_lut[i] |= 1;
184 this->cm_state = (this->cm_state & 3) | (entry->
num_value << 2);
190 this->cm_state = (this->cm_state & 0x1c) | entry->
num_value;
196 this->cm_state = this->xine->config->register_enum (
200 (
char **)cm_conf_labels,
201 _(
"Output colour matrix"),
202 _(
"Tell how output colours should be calculated.\n\n"
203 "Signal: Do as current stream suggests.\n"
204 " This may be wrong sometimes.\n\n"
205 "Signal+Size: Same as above,\n"
206 " but assume HD colour for unmarked HD streams.\n\n"
207 "SD: Force SD video standard ITU-R 470/601.\n"
208 " Try this if you get too little green.\n\n"
209 "HD: Force HD video standard ITU-R 709.\n"
210 " Try when there is too much green coming out.\n\n"),
215 this->cm_state |= this->xine->config->register_enum (
219 (
char **)cr_conf_labels,
220 _(
"Output colour range"),
221 _(
"Tell how output colours should be ranged.\n\n"
222 "Auto: Do as current stream suggests.\n"
223 " This may be wrong sometimes.\n\n"
224 "MPEG: Force MPEG colour range (16..235) / studio swing / video mode.\n"
225 " Try if image looks dull (no real black or white in it).\n\n"
226 "FULL: Force FULL colour range (0..255) / full swing / PC mode.\n"
227 " Try when flat black and white spots appear.\n\n"),
239 cm = this->cm_lut[cm & 31];
242 return cm | ((frame->height - frame->crop_top - frame->crop_bottom >= 720) ||
243 (frame->width - frame->crop_left - frame->crop_right >= 1280) ? 2 : 10);
245 static uint8_t cm_r[] = {0, 0, 1, 0};
246 int cf = this->cm_state;
247 cm_m[18] = (frame->height - frame->crop_top - frame->crop_bottom >= 720) ||
248 (frame->width - frame->crop_left - frame->crop_right >= 1280) ? 2 : 10;
250 return cm_m[((cf >> 2) << 4) | (cm >> 1)] | cm_r[cf & 3];
255void cm_fill_matrix(
float *matrix,
int color_matrix,
256 float hue,
float saturation,
float contrast,
float brightness) {
257 float uvcos = saturation * cos( hue );
258 float uvsin = saturation * sin( hue );
261 if ((color_matrix >> 1) == 8) {
266 matrix[1] = -1.0 * uvcos - 1.0 * uvsin;
267 matrix[2] = 1.0 * uvcos - 1.0 * uvsin;
268 matrix[5] = 1.0 * uvcos;
269 matrix[6] = 1.0 * uvsin;
270 matrix[9] = -1.0 * uvcos + 1.0 * uvsin;
271 matrix[10] = -1.0 * uvcos - 1.0 * uvsin;
272 for (i = 0; i < 12; i += 4) {
274 matrix[i + 3] = (brightness *
contrast - 128.0 * (matrix[i + 1] + matrix[i + 2])) / 255.0;
279 float vr, vg, ug, ub;
280 float ygain, yoffset;
282 switch (color_matrix >> 1) {
283 case 1: kb = 0.0722; kr = 0.2126;
break;
284 case 4: kb = 0.1100; kr = 0.3000;
break;
285 case 7: kb = 0.0870; kr = 0.2120;
break;
287 case 9: kb = 0.0593; kr = 0.2627;
break;
288 default: kb = 0.1140; kr = 0.2990;
290 vr = 2.0 * (1.0 - kr);
291 vg = -2.0 * kr * (1.0 - kr) / (1.0 - kb - kr);
292 ug = -2.0 * kb * (1.0 - kb) / (1.0 - kb - kr);
293 ub = 2.0 * (1.0 - kb);
295 if (color_matrix & 1) {
297 yoffset = brightness;
303 yoffset = brightness - 16.0;
310 matrix[1] = -uvsin * vr;
311 matrix[2] = uvcos * vr;
312 matrix[5] = uvcos * ug - uvsin * vg;
313 matrix[6] = uvcos * vg + uvsin * ug;
314 matrix[9] = uvcos * ub;
315 matrix[10] = uvsin * ub;
316 for (i = 0; i < 12; i += 4) {
318 matrix[i + 3] = (yoffset * ygain - 128.0 * (matrix[i + 1] + matrix[i + 2])) / 255.0;
325 this->xine->config->unregister_callbacks (this->xine->config,
NULL,
NULL,
this, sizeof (*
this));
#define CR_CONFIG_AUTO
Definition color_matrix.c:80
#define CR_CONFIG_NAME
Definition color_matrix.c:79
static const char *const cm_names[]
Definition color_matrix.c:84
#define CM_CONFIG_SIZE
Definition color_matrix.c:75
#define CM_CONFIG_NAME
Definition color_matrix.c:73
#define CR_CONFIG_FULL
Definition color_matrix.c:82
contrast
Definition eq.c:160
#define VO_GET_FLAGS_CM(flags)
Definition video_out.h:317
Definition video_out.h:70
vo_driver_t * driver
Definition video_out.h:162
int num_value
Definition xine.h:1670
#define _(String)
Definition vcdplayer.h:39
#define CM_DRIVER_T
Definition video_out_opengl.c:250
NULL
Definition xine_plugin.c:78