diff options
-rw-r--r-- | osd.c | 45 | ||||
-rw-r--r-- | xine_input_vdr.c | 23 | ||||
-rw-r--r-- | xine_osd_command.h | 17 |
3 files changed, 63 insertions, 22 deletions
@@ -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<colors; c++) { - int alpha = (palette[c] & 0xff000000)>>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<colors; c++) clut[c].alpha = (clut[c].alpha >> 1) | 0x80; if(xc.osd_mixer & OSD_MIXER_GRAY) - for(c=0; c<colors; c++) - clut[c].cb = clut[c].cr = 0x80; + for(c=0; c<colors; c++) { + if(rgb) + clut[c].r = clut[c].g = clut[c].b = (clut[c].r + clut[c].g + clut[c].b)/3; + else + clut[c].cb = clut[c].cr = 0x80; + } } } } @@ -205,7 +216,7 @@ void cXinelibOsd::CmdRle(int Wnd, int X0, int Y0, osdcmd.w = W; osdcmd.h = H; - prepare_palette(&clut[0], Palette, Colors, Top); + prepare_palette(&clut[0], Palette, Colors, Top, true); osdcmd.colors = Colors; osdcmd.palette = clut; diff --git a/xine_input_vdr.c b/xine_input_vdr.c index 3a097d4a..cb64a3d6 100644 --- a/xine_input_vdr.c +++ b/xine_input_vdr.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: xine_input_vdr.c,v 1.118 2008-02-26 22:49:27 phintuka Exp $ + * $Id: xine_input_vdr.c,v 1.119 2008-02-27 00:27:48 phintuka Exp $ * */ @@ -1764,6 +1764,26 @@ static int update_video_size(vdr_input_plugin_t *this) return 0; } +#define saturate(x,min,max) ( (x)<(min) ? (min) : (x)>(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<colors; c++) { + int R = clut[c].r; + int G = clut[c].g; + int B = clut[c].b; + 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); + } + } +} + 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 */ |