summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Thommeret <hftom@free.fr>2007-08-20 14:40:05 +0100
committerChristophe Thommeret <hftom@free.fr>2007-08-20 14:40:05 +0100
commitdaf3bd7edff3f513f821391b2e833fdd67aac1b2 (patch)
tree1563fdf0113a709629c1dc08ace70690b38523cd
parenteb48b09c6b86980ddc72b98dece6ae68e49ecc06 (diff)
downloadxine-lib-daf3bd7edff3f513f821391b2e833fdd67aac1b2.tar.gz
xine-lib-daf3bd7edff3f513f821391b2e833fdd67aac1b2.tar.bz2
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.
-rw-r--r--src/libspudvb/xine_spudvb_decoder.c34
1 files 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; j<reg->height; j++ ) {
+ for ( i=0,k=0; i<reg->width && k<dest_width; i+=inc,k++ ) {
+ dest[(j*dest_width)+(int)k] = reg->img[(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;