+static subpicture_t *Subpicture( decoder_t *p_dec, video_format_t *p_fmt,
+ bool b_text,
+ int i_columns, int i_rows, int i_align,
+ mtime_t i_pts )
+{
+ video_format_t fmt;
+ subpicture_t *p_spu;
+
+ /* If there is a page or sub to render, then we do that here */
+ /* Create the subpicture unit */
+ p_spu = p_dec->pf_spu_buffer_new( p_dec );
+ if( !p_spu )
+ {
+ msg_Warn( p_dec, "can't get spu buffer" );
+ return NULL;
+ }
+
+ memset( &fmt, 0, sizeof(video_format_t) );
+ fmt.i_chroma = b_text ? VLC_FOURCC('T','E','X','T') :
+ VLC_FOURCC('R','G','B','A');
+ fmt.i_aspect = b_text ? 0 : VOUT_ASPECT_FACTOR;
+ if( b_text )
+ {
+ fmt.i_bits_per_pixel = 0;
+ }
+ else
+ {
+ fmt.i_sar_num = fmt.i_sar_den = 1;
+ fmt.i_width = fmt.i_visible_width = i_columns * 12;
+ fmt.i_height = fmt.i_visible_height = i_rows * 10;
+ fmt.i_bits_per_pixel = 32;
+ }
+ fmt.i_x_offset = fmt.i_y_offset = 0;
+
+ p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_dec), &fmt );
+ if( p_spu->p_region == NULL )
+ {
+ msg_Err( p_dec, "cannot allocate SPU region" );
+ p_dec->pf_spu_buffer_del( p_dec, p_spu );
+ return NULL;
+ }
+
+ p_spu->p_region->i_x = 0;
+ p_spu->p_region->i_y = 0;
+ p_spu->p_region->i_align = i_align;
+
+ /* Normal text subs, easy markup */
+ p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM;
+
+ p_spu->i_start = i_pts;
+ p_spu->i_stop = 0;
+ p_spu->b_ephemer = true;
+ p_spu->b_absolute = false;
+ p_spu->b_pausable = true;
+
+
+ if( !b_text )
+ {
+ p_spu->i_width =
+ p_spu->i_original_picture_width = fmt.i_width;
+ p_spu->i_height =
+ p_spu->i_original_picture_height = fmt.i_height;
+ }
+
+ /* */
+ *p_fmt = fmt;
+ return p_spu;
+}
+