From 82a7d2990093118f23032f576cd6e9cdc5bee7e7 Mon Sep 17 00:00:00 2001 From: phintuka Date: Wed, 27 Feb 2008 00:27:48 +0000 Subject: Preparation for HUD OSD: move RGB->YUV conversion to client side. --- osd.c | 45 ++++++++++++++++++++++++++++----------------- xine_input_vdr.c | 23 ++++++++++++++++++++++- xine_osd_command.h | 17 +++++++++++++---- 3 files changed, 63 insertions(+), 22 deletions(-) diff --git a/osd.c b/osd.c index 9d0d057e..0c16dd09 100644 --- a/osd.c +++ b/osd.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: osd.c,v 1.14 2007-10-31 00:52:27 phintuka Exp $ + * $Id: osd.c,v 1.15 2008-02-27 00:27:48 phintuka Exp $ * */ @@ -32,7 +32,7 @@ static inline int saturate(int x, int min, int max) return x < min ? min : (x > max ? max : x); } -static inline void prepare_palette(xine_clut_t *clut, const unsigned int *palette, int colors, bool top) +static inline void prepare_palette(xine_clut_t *clut, const unsigned int *palette, int colors, bool top, bool rgb) { if (colors) { int c; @@ -40,18 +40,25 @@ static inline void prepare_palette(xine_clut_t *clut, const unsigned int *palett // Apply alpha layer correction and convert ARGB -> AYCrCb for(c=0; c>24; - alpha = alpha + xc.alpha_correction*alpha/100 + xc.alpha_correction_abs; - int R = ((palette[c] & 0x00ff0000) >> 16); - int G = ((palette[c] & 0x0000ff00) >> 8); - int B = ((palette[c] & 0x000000ff)); - int Y = (( + 66*R + 129*G + 25*B + 0x80) >> 8) + 16; - int CR = (( + 112*R - 94*G - 18*B + 0x80) >> 8) + 128; - int CB = (( - 38*R - 74*G + 112*B + 0x80) >> 8) + 128; - clut[c].y = saturate( Y, 16, 235); - clut[c].cb = saturate( CB, 16, 240); - clut[c].cr = saturate( CR, 16, 240); - clut[c].alpha = saturate(alpha, 0, 255); + int A = (palette[c] & 0xff000000) >> 24; + int R = (palette[c] & 0x00ff0000) >> 16; + int G = (palette[c] & 0x0000ff00) >> 8; + int B = (palette[c] & 0x000000ff); + A = A + xc.alpha_correction*A/100 + xc.alpha_correction_abs; + if(rgb) { + clut[c].r = R; + clut[c].g = G; + clut[c].b = B; + clut[c].alpha = saturate( A, 0, 255); + } else { + int Y = (( + 66*R + 129*G + 25*B + 0x80) >> 8) + 16; + int CR = (( + 112*R - 94*G - 18*B + 0x80) >> 8) + 128; + int CB = (( - 38*R - 74*G + 112*B + 0x80) >> 8) + 128; + clut[c].y = saturate( Y, 16, 235); + clut[c].cb = saturate(CB, 16, 240); + clut[c].cr = saturate(CR, 16, 240); + clut[c].alpha = saturate( A, 0, 255); + } } // Apply OSD mixer settings @@ -61,8 +68,12 @@ static inline void prepare_palette(xine_clut_t *clut, const unsigned int *palett for(c=0; c> 1) | 0x80; if(xc.osd_mixer & OSD_MIXER_GRAY) - for(c=0; c(max) ? (max) : (x)) + +static void palette_rgb_to_yuy(xine_clut_t *clut, int colors) +{ + if (clut && colors>0) { + int c; + for (c=0; c> 8) + 16; + int CR = (( + 112*R - 94*G - 18*B + 0x80) >> 8) + 128; + int CB = (( - 38*R - 74*G + 112*B + 0x80) >> 8) + 128; + clut[c].y = saturate( Y, 16, 235); + clut[c].cb = saturate(CB, 16, 240); + clut[c].cr = saturate(CR, 16, 240); + } + } +} + static xine_rle_elem_t *uncompress_osd_net(uint8_t *raw, int elems, int datalen) { xine_rle_elem_t *data = (xine_rle_elem_t*)malloc(elems*sizeof(xine_rle_elem_t)); @@ -2293,6 +2313,7 @@ static int vdr_plugin_exec_osd_command(input_plugin_t *this_gen, int video_changed = 0; if(!pthread_mutex_lock (&this->osd_lock)) { + palette_rgb_to_yuy(cmd->palette, cmd->colors); video_changed = update_video_size(this); this->class->xine->port_ticket->acquire(this->class->xine->port_ticket, 1); result = exec_osd_command(this, cmd); diff --git a/xine_osd_command.h b/xine_osd_command.h index a11982e7..af05aecb 100644 --- a/xine_osd_command.h +++ b/xine_osd_command.h @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: xine_osd_command.h,v 1.6 2008-02-05 00:59:07 phintuka Exp $ + * $Id: xine_osd_command.h,v 1.7 2008-02-27 00:27:48 phintuka Exp $ * */ @@ -33,9 +33,18 @@ typedef enum { } osd_command_id_t; typedef struct xine_clut_s { - uint8_t cb /*: 8*/; - uint8_t cr /*: 8*/; - uint8_t y /*: 8*/; + union { + uint8_t cb /*: 8*/; + uint8_t g; + }; + union { + uint8_t cr /*: 8*/; + uint8_t b; + }; + union { + uint8_t y /*: 8*/; + uint8_t r; + }; uint8_t alpha /*: 8*/; } PACKED xine_clut_t; /* from xine, alphablend.h */ -- cgit v1.2.3