+ i_wanted_page );
+#endif
+ /* If there is a page or sub to render, then we do that here */
+ /* Create the subpicture unit */
+ p_spu = Subpicture( p_dec, &fmt, p_sys->b_text,
+ p_page.columns, p_page.rows,
+ i_align, p_block->i_pts );
+ if( !p_spu )
+ goto error;
+
+ if( p_sys->b_text )
+ {
+ unsigned int i_textsize = 7000;
+ int i_total;
+ char p_text[i_textsize+1];
+
+ i_total = vbi_print_page_region( &p_page, p_text, i_textsize,
+ "UTF-8", 0, 0, 0, 0, p_page.columns, p_page.rows );
+ p_text[i_total] = '\0';
+ /* Strip off the pagenumber */
+ if( i_total <= 40 )
+ goto error;
+ p_spu->p_region->psz_text = strdup( &p_text[8] );
+
+#ifdef ZVBI_DEBUG
+ msg_Info( p_dec, "page %x-%x(%d)\n%s", p_page.pgno, p_page.subno, i_total, p_text );
+#endif
+ }
+ else
+ {
+ picture_t *p_pic = &p_spu->p_region->picture;
+
+ /* ZVBI is stupid enough to assume pitch == width */
+ p_pic->p->i_pitch = 4 * fmt.i_width;
+ vbi_draw_vt_page( &p_page, ZVBI_PIXFMT_RGBA32,
+ p_spu->p_region->picture.p->p_pixels, 1, 1 );
+
+ OpaquePage( p_pic, p_page, fmt, b_opaque );
+ }
+
+exit:
+ vbi_unref_page( &p_page );
+ block_Release( p_block );
+ return p_spu;
+
+error:
+ vbi_unref_page( &p_page );
+ if( p_spu != NULL )
+ {
+ p_dec->pf_spu_buffer_del( p_dec, p_spu );
+ p_spu = NULL;
+ }
+
+ block_Release( p_block );
+ return NULL;
+}
+
+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;