summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPetri Hintukainen <phintuka@users.sourceforge.net>2014-05-13 10:28:01 +0300
committerPetri Hintukainen <phintuka@users.sourceforge.net>2014-05-13 10:28:01 +0300
commit2e5a14ede18c8ccc861783e4cf2fbbcc91e1713c (patch)
tree688b43a13a1a0635a4002d39865fdd1c88d4c4d5 /src
parent0d205ba48e9fa4e1a741de95cc9abea1c4f15a6b (diff)
downloadxine-lib-2e5a14ede18c8ccc861783e4cf2fbbcc91e1713c.tar.gz
xine-lib-2e5a14ede18c8ccc861783e4cf2fbbcc91e1713c.tar.bz2
factorize overlay color space conversion from vo plugins
Diffstat (limited to 'src')
-rw-r--r--src/video_out/video_out_opengl2.c41
-rw-r--r--src/video_out/video_out_raw.c36
-rw-r--r--src/video_out/video_out_vaapi.c37
-rw-r--r--src/xine-engine/alphablend.c30
-rw-r--r--src/xine-engine/video_overlay.c13
5 files changed, 46 insertions, 111 deletions
diff --git a/src/video_out/video_out_opengl2.c b/src/video_out/video_out_opengl2.c
index 145a039bc..4de8ccfec 100644
--- a/src/video_out/video_out_opengl2.c
+++ b/src/video_out/video_out_opengl2.c
@@ -47,8 +47,6 @@
#include <xine/xine_internal.h>
#include <xine/xineutils.h>
-#include "yuv2rgb.h"
-
#ifdef HAVE_FFMPEG_AVUTIL_H
# include <mem.h>
#else
@@ -130,8 +128,6 @@ typedef struct {
int ovl_vid_scale;
int num_ovls;
opengl2_overlay_t overlays[XINE_VORAW_MAX_OVL];
- yuv2rgb_factory_t *yuv2rgb_factory;
- yuv2rgb_t *ovl_yuv2rgb;
opengl2_program_t sharpness_program;
float csc_matrix[3 * 4];
@@ -523,34 +519,6 @@ static int opengl2_check_textures_size( opengl2_driver_t *this_gen, int w, int h
return 1;
}
-
-
-static void opengl2_overlay_clut_yuv2rgb(opengl2_driver_t *this, vo_overlay_t *overlay, opengl2_frame_t *frame)
-{
- //fprintf(stderr, "opengl2_overlay_clut_yuv2rgb\n");
- int i;
- uint32_t *rgb;
-
- if (!overlay->rgb_clut) {
- rgb = overlay->color;
- for (i = sizeof (overlay->color) / sizeof (overlay->color[0]); i > 0; i--) {
- clut_t *yuv = (clut_t *)rgb;
- *rgb++ = this->ovl_yuv2rgb->yuv2rgb_single_pixel_fun (this->ovl_yuv2rgb, yuv->y, yuv->cb, yuv->cr);
- }
- overlay->rgb_clut++;
- }
-
- if (!overlay->hili_rgb_clut) {
- rgb = overlay->hili_color;
- for (i = sizeof (overlay->color) / sizeof (overlay->color[0]); i > 0; i--) {
- clut_t *yuv = (clut_t *)rgb;
- *rgb++ = this->ovl_yuv2rgb->yuv2rgb_single_pixel_fun (this->ovl_yuv2rgb, yuv->y, yuv->cb, yuv->cr);
- }
- overlay->hili_rgb_clut++;
- }
-}
-
-
static int opengl2_process_ovl( opengl2_driver_t *this_gen, vo_overlay_t *overlay )
{
//fprintf(stderr, "opengl2_process_ovl\n");
@@ -664,7 +632,6 @@ static void opengl2_overlay_begin (vo_driver_t *this_gen, vo_frame_t *frame_gen,
static void opengl2_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay)
{
opengl2_driver_t *this = (opengl2_driver_t *) this_gen;
- opengl2_frame_t *frame = (opengl2_frame_t *) frame_gen;
if ( !this->ovl_changed || this->ovl_changed>XINE_VORAW_MAX_OVL )
return;
@@ -683,7 +650,7 @@ static void opengl2_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen,
else if (overlay->rle) {
if (!overlay->rgb_clut || !overlay->hili_rgb_clut)
- opengl2_overlay_clut_yuv2rgb(this, overlay, frame);
+ _x_overlay_clut_yuv2rgb(overlay);
if ( opengl2_process_ovl( this, overlay ) )
++this->ovl_changed;
}
@@ -1712,9 +1679,6 @@ static void opengl2_dispose( vo_driver_t *this_gen )
glXDestroyContext( this->display, this->context );
- this->ovl_yuv2rgb->dispose(this->ovl_yuv2rgb);
- this->yuv2rgb_factory->dispose (this->yuv2rgb_factory);
-
free (this);
}
@@ -1843,9 +1807,6 @@ static vo_driver_t *opengl2_open_plugin( video_driver_class_t *class_gen, const
this->ovl_changed = 0;
this->num_ovls = 0;
- this->yuv2rgb_factory = yuv2rgb_factory_init (MODE_24_BGR, 0, NULL);
- this->ovl_yuv2rgb = this->yuv2rgb_factory->create_converter( this->yuv2rgb_factory );
-
if ( this->texture_float ) {
this->scale_bicubic = config->register_bool( config, "video.output.opengl2_bicubic_scaling", 0,
_("opengl2: use a bicubic algo to scale the video"),
diff --git a/src/video_out/video_out_raw.c b/src/video_out/video_out_raw.c
index 4ca8b536a..702c7dc2e 100644
--- a/src/video_out/video_out_raw.c
+++ b/src/video_out/video_out_raw.c
@@ -85,7 +85,6 @@ typedef struct {
int ovl_changed;
raw_overlay_t overlays[XINE_VORAW_MAX_OVL];
- yuv2rgb_t *ovl_yuv2rgb;
int doYV12;
int doYUY2;
@@ -102,32 +101,6 @@ typedef struct {
} raw_class_t;
-
-static void raw_overlay_clut_yuv2rgb(raw_driver_t *this, vo_overlay_t *overlay, raw_frame_t *frame)
-{
- int i;
- uint32_t *rgb;
-
- if (!overlay->rgb_clut) {
- rgb = overlay->color;
- for (i = sizeof (overlay->color) / sizeof (overlay->color[0]); i > 0; i--) {
- clut_t *yuv = (clut_t *)rgb;
- *rgb++ = this->ovl_yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, yuv->y, yuv->cb, yuv->cr);
- }
- overlay->rgb_clut++;
- }
-
- if (!overlay->hili_rgb_clut) {
- rgb = overlay->hili_color;
- for (i = sizeof (overlay->color) / sizeof (overlay->color[0]); i > 0; i--) {
- clut_t *yuv = (clut_t *)rgb;
- *rgb++ = this->ovl_yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, yuv->y, yuv->cb, yuv->cr);
- }
- overlay->hili_rgb_clut++;
- }
-}
-
-
static int raw_process_ovl( raw_driver_t *this_gen, vo_overlay_t *overlay )
{
raw_overlay_t *ovl = &this_gen->overlays[this_gen->ovl_changed-1];
@@ -204,14 +177,13 @@ static void raw_overlay_begin (vo_driver_t *this_gen, vo_frame_t *frame_gen, int
static void raw_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay)
{
raw_driver_t *this = (raw_driver_t *) this_gen;
- raw_frame_t *frame = (raw_frame_t *) frame_gen;
if ( !this->ovl_changed || this->ovl_changed>XINE_VORAW_MAX_OVL )
return;
if (overlay->rle) {
if (!overlay->rgb_clut || !overlay->hili_rgb_clut)
- raw_overlay_clut_yuv2rgb (this, overlay, frame);
+ _x_overlay_clut_yuv2rgb (overlay);
if ( raw_process_ovl( this, overlay ) )
++this->ovl_changed;
}
@@ -557,12 +529,6 @@ static vo_driver_t *raw_open_plugin (video_driver_class_t *class_gen, const void
}
this->ovl_changed = 0;
- /* we have to use a second converter for overlays
- * because "MODE_24_BGR, 1 (swap)" breaks overlays conversion */
- yuv2rgb_factory_t *factory = yuv2rgb_factory_init (MODE_24_BGR, 0, NULL);
- this->ovl_yuv2rgb = factory->create_converter( factory );
- factory->dispose( factory );
-
return &this->vo_driver;
}
diff --git a/src/video_out/video_out_vaapi.c b/src/video_out/video_out_vaapi.c
index a234fa133..af759c2ff 100644
--- a/src/video_out/video_out_vaapi.c
+++ b/src/video_out/video_out_vaapi.c
@@ -45,7 +45,6 @@
#include <X11/cursorfont.h>
#include <time.h>
#include <unistd.h>
-#include "yuv2rgb.h"
#define LOG_MODULE "video_out_vaapi"
#define LOG_VERBOSE
@@ -234,9 +233,6 @@ struct vaapi_driver_s {
uint32_t overlay_unscaled_height;
vaapi_rect_t overlay_unscaled_dirty_rect;
- yuv2rgb_factory_t *yuv2rgb_factory;
- yuv2rgb_t *ovl_yuv2rgb;
-
/* all scaling information goes here */
vo_scale_t sc;
@@ -2506,30 +2502,6 @@ static int vaapi_ovl_associate(vo_driver_t *this_gen, int format, int bShow) {
return 0;
}
-static void vaapi_overlay_clut_yuv2rgb(vaapi_driver_t *this, vo_overlay_t *overlay, vaapi_frame_t *frame)
-{
- int i;
- uint32_t *rgb;
-
- if (!overlay->rgb_clut) {
- rgb = overlay->color;
- for (i = sizeof (overlay->color) / sizeof (overlay->color[0]); i > 0; i--) {
- clut_t *yuv = (clut_t *)rgb;
- *rgb++ = this->ovl_yuv2rgb->yuv2rgb_single_pixel_fun (this->ovl_yuv2rgb, yuv->y, yuv->cb, yuv->cr);
- }
- overlay->rgb_clut++;
- }
-
- if (!overlay->hili_rgb_clut) {
- rgb = overlay->hili_color;
- for (i = sizeof (overlay->color) / sizeof (overlay->color[0]); i > 0; i--) {
- clut_t *yuv = (clut_t *)rgb;
- *rgb++ = this->ovl_yuv2rgb->yuv2rgb_single_pixel_fun (this->ovl_yuv2rgb, yuv->y, yuv->cb, yuv->cr);
- }
- overlay->hili_rgb_clut++;
- }
-}
-
static void vaapi_overlay_begin (vo_driver_t *this_gen,
vo_frame_t *frame_gen, int changed) {
vaapi_driver_t *this = (vaapi_driver_t *) this_gen;
@@ -2752,7 +2724,7 @@ static void vaapi_overlay_end (vo_driver_t *this_gen, vo_frame_t *frame_gen) {
continue;
if (!ovl->rgb_clut || !ovl->hili_rgb_clut)
- vaapi_overlay_clut_yuv2rgb (this, ovl, frame);
+ _x_overlay_clut_yuv2rgb (ovl);
bitmap = rgba = calloc(ovl->width * ovl->height * 4, sizeof(uint32_t));
@@ -3995,9 +3967,6 @@ static void vaapi_dispose_locked (vo_driver_t *this_gen) {
DO_LOCKDISPLAY;
- this->ovl_yuv2rgb->dispose(this->ovl_yuv2rgb);
- this->yuv2rgb_factory->dispose (this->yuv2rgb_factory);
-
vaapi_close(this_gen);
free(va_context);
@@ -4220,10 +4189,6 @@ static vo_driver_t *vaapi_open_plugin (video_driver_class_t *class_gen, const vo
this->capabilities = VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_CROP | VO_CAP_UNSCALED_OVERLAY | VO_CAP_ARGB_LAYER_OVERLAY | VO_CAP_VAAPI | VO_CAP_CUSTOM_EXTENT_OVERLAY;
- /* overlay converter */
- this->yuv2rgb_factory = yuv2rgb_factory_init (MODE_24_BGR, 0, NULL);
- this->ovl_yuv2rgb = this->yuv2rgb_factory->create_converter( this->yuv2rgb_factory );
-
this->vo_driver.get_capabilities = vaapi_get_capabilities;
this->vo_driver.alloc_frame = vaapi_alloc_frame;
this->vo_driver.update_frame_format = vaapi_update_frame_format;
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.
*/