diff options
Diffstat (limited to 'src/libspudvb/xine_spudvb_decoder.c')
-rw-r--r-- | src/libspudvb/xine_spudvb_decoder.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/libspudvb/xine_spudvb_decoder.c b/src/libspudvb/xine_spudvb_decoder.c index 0f4716564..0f300138a 100644 --- a/src/libspudvb/xine_spudvb_decoder.c +++ b/src/libspudvb/xine_spudvb_decoder.c @@ -28,6 +28,7 @@ #include "pthread.h" #include <errno.h> #include "xine_internal.h" +#include "spu.h" #include "osd.h" #define MAX_REGIONS 7 @@ -290,6 +291,24 @@ static void decode_4bit_pixel_code_string (dvb_spu_decoder_t * this, int r, int } } +static void recalculate_trans (dvb_spu_decoder_t *this) +{ + dvbsub_func_t *const dvbsub = this->dvbsub; + xine_spu_opacity_t opacity; + int i; + + _x_spu_get_opacity (this->stream->xine, &opacity); + for (i = 0; i < MAX_REGIONS * 256; ++i) { + /* ETSI-300-743 says "full transparency if Y == 0". */ + if (dvbsub->colours[i].y == 0) + dvbsub->trans[i] = 0; + else { + int v = _x_spu_calculate_opacity (&dvbsub->colours[i], dvbsub->colours[i].foo, &opacity); + dvbsub->trans[i] = v * 14 / 255 + 1; + } + } + +} static void set_clut(dvb_spu_decoder_t *this,int CLUT_id,int CLUT_entry_id,int Y_value, int Cr_value, int Cb_value, int T_value) { @@ -302,13 +321,7 @@ static void set_clut(dvb_spu_decoder_t *this,int CLUT_id,int CLUT_entry_id,int Y dvbsub->colours[(CLUT_id*256)+CLUT_entry_id].y=Y_value; dvbsub->colours[(CLUT_id*256)+CLUT_entry_id].cr=Cr_value; dvbsub->colours[(CLUT_id*256)+CLUT_entry_id].cb=Cb_value; - - if (Y_value==0) { - dvbsub->trans[(CLUT_id*256)+CLUT_entry_id]=T_value; - } else { - dvbsub->trans[(CLUT_id*256)+CLUT_entry_id]=255; - } - + dvbsub->colours[(CLUT_id*256)+CLUT_entry_id].foo = T_value; } static void process_CLUT_definition_segment(dvb_spu_decoder_t *this) { @@ -814,6 +827,7 @@ static void spudec_decode_data (spu_decoder_t * this_gen, buf_element_t * buf) process_object_data_segment (this); break; case 0x80: /* Page is now completely rendered */ + recalculate_trans(this); draw_subtitles( this ); break; default: @@ -909,6 +923,18 @@ static spu_decoder_t *dvb_spu_class_open_plugin (spu_decoder_class_t * class_gen this->dvbsub->regions[i].CLUT_id = 0; } + { + xine_spu_opacity_t opacity; + static const clut_t black = { 0, 0, 0, 0 }; + int t; + + _x_spu_get_opacity (this->stream->xine, &opacity); + t = _x_spu_calculate_opacity (&black, 0, &opacity); + + for (i = 0; i < MAX_REGIONS * 256; i++) + this->dvbsub->colours[i].foo = t; + } + pthread_mutex_init(&this->dvbsub_osd_mutex, NULL); pthread_cond_init(&this->dvbsub_restart_timeout, NULL); this->dvbsub_hide_timeout.tv_nsec = 0; |