From daf3bd7edff3f513f821391b2e833fdd67aac1b2 Mon Sep 17 00:00:00 2001 From: Christophe Thommeret Date: Mon, 20 Aug 2007 14:40:05 +0100 Subject: spudvb bitmaps downscale xine_spudvb_decoder.c has hardcoded frame size (720x576). While this is fine for most dvb channels, some channels have smaller frame size (e.g. 544x576) but the dvb subs bitmaps are however still 720 width. In such case, some right aligned subs appear truncated. This patch adds a (very basic) function to downscale subs to fit frame width. --- src/libspudvb/xine_spudvb_decoder.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/libspudvb/xine_spudvb_decoder.c b/src/libspudvb/xine_spudvb_decoder.c index 339d66b2e..befdf7ac7 100644 --- a/src/libspudvb/xine_spudvb_decoder.c +++ b/src/libspudvb/xine_spudvb_decoder.c @@ -121,6 +121,7 @@ void process_CLUT_definition_segment (dvb_spu_decoder_t * this); void process_object_data_segment (dvb_spu_decoder_t * this); void draw_subtitles (dvb_spu_decoder_t * this); static void spudec_dispose (spu_decoder_t * this_gen); +void downscale_region_image( region_t *reg, unsigned char *dest, int dest_width ); void create_region (dvb_spu_decoder_t * this, int region_id, int region_width, int region_height, int region_depth) { @@ -595,11 +596,31 @@ static void* dvbsub_timer_func(void *this_gen) return NULL; } +void downscale_region_image( region_t *reg, unsigned char *dest, int dest_width ) +{ + float i, k, inc=reg->width/(float)dest_width; + int j; + for ( j=0; jheight; j++ ) { + for ( i=0,k=0; iwidth && kimg[(j*reg->width)+(int)i]; + } + } +} + void draw_subtitles (dvb_spu_decoder_t * this) { int r; int x, y, out_y; int display=0; + int64_t dum; + int dest_width=0, dest_height, reg_width; + this->stream->video_out->status(this->stream->video_out, NULL, &dest_width, &dest_height, &dum); + unsigned char tmp[dest_width*576]; + unsigned char *reg; + + if ( !dest_width ) + return; + /* clear it */ memset (this->bitmap, 0, 720 * 576); /* render all regions onto the page */ @@ -608,11 +629,20 @@ void draw_subtitles (dvb_spu_decoder_t * this) for (r = 0; r < MAX_REGIONS; r++) { if (this->dvbsub->regions[r].win >= 0) { if (this->dvbsub->page.regions[r].is_visible) { + if (this->dvbsub->regions[r].width>dest_width) { + downscale_region_image(&this->dvbsub->regions[r], tmp, dest_width); + reg = tmp; + reg_width = dest_width; + } + else { + reg = this->dvbsub->regions[r].img; + reg_width = this->dvbsub->regions[r].width; + } out_y = this->dvbsub->page.regions[r].y * 720; for (y = 0; y < this->dvbsub->regions[r].height; y++) { - for (x = 0; x < this->dvbsub->regions[r].width; x++) { - this->bitmap[out_y + x + this->dvbsub->page.regions[r].x] = this->dvbsub->regions[r].img[(y * this->dvbsub->regions[r].width) + x]; + for (x = 0; x < reg_width; x++) { + this->bitmap[out_y + x + this->dvbsub->page.regions[r].x] = reg[(y*reg_width) + x]; if (this->bitmap[out_y + x + this->dvbsub->page.regions[r].x]) { display=1; -- cgit v1.2.3