From 1296a0105c400a3a24bf0c0fe9c8c1ad22653e60 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Thu, 15 May 2014 22:26:32 +0300 Subject: spu_dec: fix aliasing --- src/spu_dec/Makefile.am | 2 +- src/spu_dec/cc_decoder.c | 15 +++++---------- src/spu_dec/spudvb_decoder.c | 25 ++++++++++++++++--------- 3 files changed, 22 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/spu_dec/Makefile.am b/src/spu_dec/Makefile.am index 355a8a607..b44bf7bb2 100644 --- a/src/spu_dec/Makefile.am +++ b/src/spu_dec/Makefile.am @@ -15,7 +15,7 @@ xineplug_LTLIBRARIES = \ xineplug_decode_spucc_la_SOURCES = cc_decoder.c cc_decoder.h xine_cc_decoder.c xineplug_decode_spucc_la_LIBADD = $(XINE_LIB) -xineplug_decode_spucc_la_CFLAGS = $(AM_CFLAGS) -fno-strict-aliasing +xineplug_decode_spucc_la_CFLAGS = $(AM_CFLAGS) xineplug_decode_spucmml_la_SOURCES = cmml_decoder.c xineplug_decode_spucmml_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) diff --git a/src/spu_dec/cc_decoder.c b/src/spu_dec/cc_decoder.c index aadfb5a5d..b3a5a9416 100644 --- a/src/spu_dec/cc_decoder.c +++ b/src/spu_dec/cc_decoder.c @@ -850,28 +850,23 @@ static void cc_renderer_build_palette(cc_renderer_t *this) memset(this->cc_trans, 0, sizeof (this->cc_trans)); for (i = 0; i < NUM_FG_COL; i++) { /* background color */ - this->cc_palette[i * TEXT_PALETTE_SIZE + 1 + OSD_TEXT1] = - *(uint32_t *) &cc_text[i].bgcol; + memcpy(&this->cc_palette[i * TEXT_PALETTE_SIZE + 1 + OSD_TEXT1], &cc_text[i].bgcol, sizeof(uint32_t)); /* background -> border */ for (j = 2; j <= 5; j++) { clut_t col = interpolate_color(cc_text[i].bgcol, cc_text[i].bordercol, 4, j - 1); - this->cc_palette[i * TEXT_PALETTE_SIZE + j + OSD_TEXT1] = - *(uint32_t *) &col; + memcpy(&this->cc_palette[i * TEXT_PALETTE_SIZE + j + OSD_TEXT1], &col, sizeof(uint32_t)); } /* border color */ - this->cc_palette[i * TEXT_PALETTE_SIZE + 6 + OSD_TEXT1] = - *(uint32_t *) &cc_text[i].bordercol; + memcpy(&this->cc_palette[i * TEXT_PALETTE_SIZE + 6 + OSD_TEXT1], &cc_text[i].bordercol, sizeof(uint32_t)); /* border -> foreground */ for (j = 7; j <= 9; j++) { clut_t col = interpolate_color(cc_text[i].bordercol, cc_text[i].textcol, 3, j - 6); - this->cc_palette[i * TEXT_PALETTE_SIZE + j + OSD_TEXT1] = - *(uint32_t *) &col; + memcpy(&this->cc_palette[i * TEXT_PALETTE_SIZE + j + OSD_TEXT1], &col, sizeof(uint32_t)); } /* foreground color */ - this->cc_palette[i * TEXT_PALETTE_SIZE + 10 + OSD_TEXT1] = - *(uint32_t *) &cc_text[i].textcol; + memcpy(&this->cc_palette[i * TEXT_PALETTE_SIZE + 10 + OSD_TEXT1], &cc_text[i].textcol, sizeof(uint32_t)); /* alpha values */ for (j = 0; j <= 10; j++) diff --git a/src/spu_dec/spudvb_decoder.c b/src/spu_dec/spudvb_decoder.c index 705693b1c..832830468 100644 --- a/src/spu_dec/spudvb_decoder.c +++ b/src/spu_dec/spudvb_decoder.c @@ -66,6 +66,11 @@ typedef struct { osd_object_t *osd; } region_t; +typedef struct { + clut_t c; + uint32_t u32; +} clut_union_t; + typedef struct { /* dvbsub stuff */ int x; @@ -79,7 +84,7 @@ typedef struct { int compat_depth; page_t page; region_t regions[MAX_REGIONS]; - clut_t colours[MAX_REGIONS*256]; + clut_union_t colours[MAX_REGIONS*256]; unsigned char trans[MAX_REGIONS*256]; struct { unsigned char lut24[4], lut28[4], lut48[16]; @@ -473,10 +478,10 @@ static void recalculate_trans (dvb_spu_decoder_t *this) _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) + if (dvbsub->colours[i].c.y == 0) dvbsub->trans[i] = 0; else { - int v = _x_spu_calculate_opacity (&dvbsub->colours[i], dvbsub->colours[i].foo, &opacity); + int v = _x_spu_calculate_opacity (&dvbsub->colours[i].c, dvbsub->colours[i].c.foo, &opacity); dvbsub->trans[i] = v * 14 / 255 + 1; } } @@ -491,10 +496,10 @@ static void set_clut(dvb_spu_decoder_t *this,int CLUT_id,int CLUT_entry_id,int Y return; } - 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; - dvbsub->colours[(CLUT_id*256)+CLUT_entry_id].foo = T_value; + dvbsub->colours[(CLUT_id*256)+CLUT_entry_id].c.y = Y_value; + dvbsub->colours[(CLUT_id*256)+CLUT_entry_id].c.cr = Cr_value; + dvbsub->colours[(CLUT_id*256)+CLUT_entry_id].c.cb = Cb_value; + dvbsub->colours[(CLUT_id*256)+CLUT_entry_id].c.foo = T_value; } static void process_CLUT_definition_segment(dvb_spu_decoder_t *this) { @@ -891,7 +896,9 @@ static void draw_subtitles (dvb_spu_decoder_t * this) reg = this->dvbsub->regions[r].img; reg_width = this->dvbsub->regions[r].width; } - this->stream->osd_renderer->set_palette( this->dvbsub->regions[r].osd, (uint32_t*)(&this->dvbsub->colours[this->dvbsub->regions[r].CLUT_id*256]), &this->dvbsub->trans[this->dvbsub->regions[r].CLUT_id*256]); + this->stream->osd_renderer->set_palette( this->dvbsub->regions[r].osd, + &this->dvbsub->colours[this->dvbsub->regions[r].CLUT_id*256].u32, + &this->dvbsub->trans[this->dvbsub->regions[r].CLUT_id*256]); this->stream->osd_renderer->draw_bitmap( this->dvbsub->regions[r].osd, reg, 0, 0, reg_width, this->dvbsub->regions[r].height, NULL ); } } @@ -1165,7 +1172,7 @@ static spu_decoder_t *dvb_spu_class_open_plugin (spu_decoder_class_t * class_gen t = _x_spu_calculate_opacity (&black, 0, &opacity); for (i = 0; i < MAX_REGIONS * 256; i++) - this->dvbsub->colours[i].foo = t; + this->dvbsub->colours[i].c.foo = t; } pthread_mutex_init(&this->dvbsub_osd_mutex, NULL); -- cgit v1.2.3