+ if( p_region->fmt.i_chroma == VLC_FOURCC('T','E','X','T') )
+ {
+ if( p_spu->p_text && p_spu->p_text->p_module &&
+ p_spu->p_text->pf_render_text )
+ {
+ p_region->i_align = p_subpic->i_flags;
+ p_spu->p_text->pf_render_text( p_spu->p_text,
+ p_region, p_region );
+ }
+ }
+
+ /* Force palette if requested */
+ if( p_spu->b_force_palette && VLC_FOURCC('Y','U','V','P') ==
+ p_region->fmt.i_chroma )
+ {
+ memcpy( p_region->fmt.p_palette->palette,
+ p_spu->palette, 16 );
+ }
+
+ /* Scale SPU if necessary */
+ if( p_region->p_cache )
+ {
+ if( i_scale_width * p_region->fmt.i_width / 1000 !=
+ p_region->p_cache->fmt.i_width ||
+ i_scale_height * p_region->fmt.i_height / 1000 !=
+ p_region->p_cache->fmt.i_height )
+ {
+ p_subpic->pf_destroy_region( VLC_OBJECT(p_spu),
+ p_region->p_cache );
+ p_region->p_cache = 0;
+ }
+ }
+
+ if( (i_scale_width != 1000 || i_scale_height != 1000) &&
+ p_spu->p_scale && !p_region->p_cache )
+ {
+ picture_t *p_pic;
+
+ p_spu->p_scale->fmt_in.video = p_region->fmt;
+ p_spu->p_scale->fmt_out.video = p_region->fmt;
+
+ p_region->p_cache =
+ p_subpic->pf_create_region( VLC_OBJECT(p_spu),
+ &p_spu->p_scale->fmt_out.video );
+ if( p_spu->p_scale->fmt_out.video.p_palette )
+ *p_spu->p_scale->fmt_out.video.p_palette =
+ *p_region->fmt.p_palette;
+ p_region->p_cache->p_next = p_region->p_next;
+
+ vout_CopyPicture( p_spu, &p_region->p_cache->picture,
+ &p_region->picture );
+
+ p_spu->p_scale->fmt_out.video.i_width =
+ p_region->fmt.i_width * i_scale_width / 1000;
+ p_spu->p_scale->fmt_out.video.i_visible_width =
+ p_region->fmt.i_visible_width * i_scale_width / 1000;
+ p_spu->p_scale->fmt_out.video.i_height =
+ p_region->fmt.i_height * i_scale_height / 1000;
+ p_spu->p_scale->fmt_out.video.i_visible_height =
+ p_region->fmt.i_visible_height * i_scale_height / 1000;
+ p_region->p_cache->fmt = p_spu->p_scale->fmt_out.video;
+ p_region->p_cache->i_x = p_region->i_x * i_scale_width / 1000;
+ p_region->p_cache->i_y = p_region->i_y * i_scale_height / 1000;
+
+ p_pic = p_spu->p_scale->pf_video_filter(
+ p_spu->p_scale, &p_region->p_cache->picture );
+ if( p_pic )
+ {
+ picture_t p_pic_tmp = p_region->p_cache->picture;
+ p_region->p_cache->picture = *p_pic;
+ *p_pic = p_pic_tmp;
+ free( p_pic );
+ }
+ }
+ if( (i_scale_width != 1000 || i_scale_height != 1000) &&
+ p_spu->p_scale && p_region->p_cache )
+ {
+ p_region = p_region->p_cache;
+ }
+
+ if( p_subpic->i_flags & SUBPICTURE_ALIGN_BOTTOM )