summaryrefslogtreecommitdiff
path: root/src/xine-engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/xine-engine')
-rw-r--r--src/xine-engine/alphablend.c30
-rw-r--r--src/xine-engine/video_overlay.c13
2 files changed, 43 insertions, 0 deletions
diff --git a/src/xine-engine/alphablend.c b/src/xine-engine/alphablend.c
index b6e284ccd..0b5e3252f 100644
--- a/src/xine-engine/alphablend.c
+++ b/src/xine-engine/alphablend.c
@@ -2171,3 +2171,33 @@ void _x_alphablend_free(alphablend_t *extra_data)
extra_data->buffer_size = 0;
}
+#define saturate(n, l, u) ((n) < (l) ? (l) : ((n) > (u) ? (u) : (n)))
+
+void _x_clut_yuv2rgb(uint32_t *clut, int num_items)
+{
+ uint32_t *end = clut + num_items;
+ if (end <= clut) return;
+
+ while (clut < end) {
+ union {
+ uint32_t u32;
+ clut_t c;
+ } tmp = { *clut };
+
+ int y, u, v, r, g, b;
+ y = saturate(tmp.c.y, 16, 235);
+ u = saturate(tmp.c.cb, 16, 240);
+ v = saturate(tmp.c.cr, 16, 240);
+
+ y = (9 * y) / 8;
+ r = y + (25 * v) / 16 - 218;
+ g = y + (-13 * v) / 16 + (-25 * u) / 64 + 136;
+ b = y + 2 * u - 274;
+
+ tmp.c.cb = saturate(b, 0, 255);
+ tmp.c.cr = saturate(g, 0, 255);
+ tmp.c.y = saturate(r, 0, 255);
+
+ *clut++ = tmp.u32;
+ }
+}
diff --git a/src/xine-engine/video_overlay.c b/src/xine-engine/video_overlay.c
index fb207905b..fe9caee34 100644
--- a/src/xine-engine/video_overlay.c
+++ b/src/xine-engine/video_overlay.c
@@ -507,6 +507,19 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) {
return processed;
}
+void _x_overlay_clut_yuv2rgb(vo_overlay_t *overlay)
+{
+ if (!overlay->rgb_clut) {
+ _x_clut_yuv2rgb(overlay->color, sizeof(overlay->color) / sizeof (overlay->color[0]));
+ overlay->rgb_clut++;
+ }
+
+ if (!overlay->hili_rgb_clut) {
+ _x_clut_yuv2rgb(overlay->hili_color, sizeof (overlay->color) / sizeof (overlay->color[0]));
+ overlay->hili_rgb_clut++;
+ }
+}
+
/* This is called from video_out.c
* must call output->overlay_blend for each active overlay.
*/