Commit 8f83ef4b authored by Laurent Aimar's avatar Laurent Aimar

Changed subpicture_region_t->picture into a picture_t *

It will avoid useless picture copy.
parent 692cad3b
...@@ -289,6 +289,11 @@ struct picture_heap_t ...@@ -289,6 +289,11 @@ struct picture_heap_t
* @{ * @{
*/ */
/**
* Video subtitle region spu core private
*/
typedef struct subpicture_region_private_t subpicture_region_private_t;
/** /**
* Video subtitle region * Video subtitle region
* *
...@@ -299,7 +304,7 @@ struct picture_heap_t ...@@ -299,7 +304,7 @@ struct picture_heap_t
struct subpicture_region_t struct subpicture_region_t
{ {
video_format_t fmt; /**< format of the picture */ video_format_t fmt; /**< format of the picture */
picture_t picture; /**< picture comprising this region */ picture_t *p_picture; /**< picture comprising this region */
int i_x; /**< position of region */ int i_x; /**< position of region */
int i_y; /**< position of region */ int i_y; /**< position of region */
...@@ -311,7 +316,7 @@ struct subpicture_region_t ...@@ -311,7 +316,7 @@ struct subpicture_region_t
text_style_t *p_style; /**< a description of the text style formatting */ text_style_t *p_style; /**< a description of the text style formatting */
subpicture_region_t *p_next; /**< next region in the list */ subpicture_region_t *p_next; /**< next region in the list */
subpicture_region_t *p_cache; /**< modified version of this region */ subpicture_region_private_t *p_private; /**< modified version of this region */
}; };
/** /**
......
...@@ -305,14 +305,14 @@ static void UpdateRegions( spu_t *p_spu, subpicture_t *p_subpic, ...@@ -305,14 +305,14 @@ static void UpdateRegions( spu_t *p_spu, subpicture_t *p_subpic,
/* */ /* */
p_spu_region->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT; p_spu_region->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
memset( p_spu_region->picture.Y_PIXELS, 0x00, p_spu_region->picture.Y_PITCH * p_sys->fmt_cached.i_height ); memset( p_spu_region->p_picture->Y_PIXELS, 0x00, p_spu_region->p_picture->Y_PITCH * p_sys->fmt_cached.i_height );
/* */ /* */
//msg_Dbg( p_dec, "TS %lf", ts * 0.000001 ); //msg_Dbg( p_dec, "TS %lf", ts * 0.000001 );
memset( &csri_frame, 0, sizeof(csri_frame) ); memset( &csri_frame, 0, sizeof(csri_frame) );
csri_frame.pixfmt = CSRI_F_BGRA; csri_frame.pixfmt = CSRI_F_BGRA;
csri_frame.planes[0] = (unsigned char*)p_spu_region->picture.Y_PIXELS; csri_frame.planes[0] = (unsigned char*)p_spu_region->p_picture->Y_PIXELS;
csri_frame.strides[0] = p_spu_region->picture.Y_PITCH; csri_frame.strides[0] = p_spu_region->p_picture->Y_PITCH;
csri_render( p_sys->p_instance, &csri_frame, ts * 0.000001 ); csri_render( p_sys->p_instance, &csri_frame, ts * 0.000001 );
} }
} }
......
...@@ -569,7 +569,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data, ...@@ -569,7 +569,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data,
subpicture_region_t *p_region ) subpicture_region_t *p_region )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
uint8_t *p_dest = p_region->picture.Y_PIXELS; uint8_t *p_dest = p_region->p_picture->Y_PIXELS;
int i_field; /* The subtitles are interlaced */ int i_field; /* The subtitles are interlaced */
int i_row, i_column; /* scanline row/column number */ int i_row, i_column; /* scanline row/column number */
uint8_t i_color, i_count; uint8_t i_color, i_count;
...@@ -591,7 +591,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data, ...@@ -591,7 +591,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data,
/* Fill the rest of the line with next color */ /* Fill the rest of the line with next color */
i_color = bs_read( &bs, 4 ); i_color = bs_read( &bs, 4 );
memset( &p_dest[i_row * p_region->picture.Y_PITCH + memset( &p_dest[i_row * p_region->p_picture->Y_PITCH +
i_column], i_color, i_column], i_color,
p_sys->i_width - i_column ); p_sys->i_width - i_column );
i_column = p_sys->i_width; i_column = p_sys->i_width;
...@@ -605,7 +605,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data, ...@@ -605,7 +605,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data,
i_count = __MIN( i_count, p_sys->i_width - i_column ); i_count = __MIN( i_count, p_sys->i_width - i_column );
memset( &p_dest[i_row * p_region->picture.Y_PITCH + memset( &p_dest[i_row * p_region->p_picture->Y_PITCH +
i_column], i_color, i_count ); i_column], i_color, i_count );
i_column += i_count - 1; i_column += i_count - 1;
continue; continue;
......
...@@ -1571,8 +1571,8 @@ static subpicture_t *render( decoder_t *p_dec ) ...@@ -1571,8 +1571,8 @@ static subpicture_t *render( decoder_t *p_dec )
} }
p_src = p_region->p_pixbuf; p_src = p_region->p_pixbuf;
p_dst = p_spu_region->picture.Y_PIXELS; p_dst = p_spu_region->p_picture->Y_PIXELS;
i_pitch = p_spu_region->picture.Y_PITCH; i_pitch = p_spu_region->p_picture->Y_PITCH;
/* Copy pixel buffer */ /* Copy pixel buffer */
for( j = 0; j < p_region->i_height; j++ ) for( j = 0; j < p_region->i_height; j++ )
...@@ -1710,11 +1710,11 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic ) ...@@ -1710,11 +1710,11 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic )
#else #else
int *pi_delta; int *pi_delta;
#endif #endif
int i_pixels = p_region->picture.p[0].i_visible_lines int i_pixels = p_region->p_picture->p[0].i_visible_lines
* p_region->picture.p[0].i_pitch; * p_region->p_picture->p[0].i_pitch;
int i_iterator = p_region->picture.p[0].i_visible_lines * 3 / 4 int i_iterator = p_region->p_picture->p[0].i_visible_lines * 3 / 4
* p_region->picture.p[0].i_pitch * p_region->p_picture->p[0].i_pitch
+ p_region->picture.p[0].i_pitch * 1 / 3; + p_region->p_picture->p[0].i_pitch * 1 / 3;
int i_tolerance = 0; int i_tolerance = 0;
#ifdef DEBUG_DVBSUB #ifdef DEBUG_DVBSUB
...@@ -1754,10 +1754,10 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic ) ...@@ -1754,10 +1754,10 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic )
for( i = 0; i < i_pixels ; ) for( i = 0; i < i_pixels ; )
{ {
uint8_t y, u, v, a; uint8_t y, u, v, a;
y = p_region->picture.p[0].p_pixels[i]; y = p_region->p_picture->p[0].p_pixels[i];
u = p_region->picture.p[1].p_pixels[i]; u = p_region->p_picture->p[1].p_pixels[i];
v = p_region->picture.p[2].p_pixels[i]; v = p_region->p_picture->p[2].p_pixels[i];
a = p_region->picture.p[3].p_pixels[i]; a = p_region->p_picture->p[3].p_pixels[i];
for( j = 0; j < p_fmt->p_palette->i_entries; j++ ) for( j = 0; j < p_fmt->p_palette->i_entries; j++ )
{ {
if( abs((int)p_fmt->p_palette->palette[j][0] - (int)y) <= i_tolerance && if( abs((int)p_fmt->p_palette->palette[j][0] - (int)y) <= i_tolerance &&
...@@ -1799,29 +1799,29 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic ) ...@@ -1799,29 +1799,29 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic )
#endif #endif
#ifndef RANDOM_DITHERING #ifndef RANDOM_DITHERING
pi_delta = malloc( ( p_region->picture.p[0].i_pitch + 1 ) pi_delta = malloc( ( p_region->p_picture->p[0].i_pitch + 1 )
* sizeof(int) * 4 ); * sizeof(int) * 4 );
for( i = 0; i < (p_region->picture.p[0].i_pitch + 1) * 4 ; i++ ) for( i = 0; i < (p_region->p_picture->p[0].i_pitch + 1) * 4 ; i++ )
{ {
pi_delta[ i ] = 0; pi_delta[ i ] = 0;
} }
#endif #endif
/* Fill image with our new colours */ /* Fill image with our new colours */
for( p = 0; p < p_region->picture.p[0].i_visible_lines ; p++ ) for( p = 0; p < p_region->p_picture->p[0].i_visible_lines ; p++ )
{ {
int i_ydelta = 0, i_udelta = 0, i_vdelta = 0, i_adelta = 0; int i_ydelta = 0, i_udelta = 0, i_vdelta = 0, i_adelta = 0;
for( n = 0; n < p_region->picture.p[0].i_pitch ; n++ ) for( n = 0; n < p_region->p_picture->p[0].i_pitch ; n++ )
{ {
int i_offset = p * p_region->picture.p[0].i_pitch + n; int i_offset = p * p_region->p_picture->p[0].i_pitch + n;
int y, u, v, a; int y, u, v, a;
int i_mindist, i_best; int i_mindist, i_best;
y = (int)p_region->picture.p[0].p_pixels[i_offset]; y = (int)p_region->p_picture->p[0].p_pixels[i_offset];
u = (int)p_region->picture.p[1].p_pixels[i_offset]; u = (int)p_region->p_picture->p[1].p_pixels[i_offset];
v = (int)p_region->picture.p[2].p_pixels[i_offset]; v = (int)p_region->p_picture->p[2].p_pixels[i_offset];
a = (int)p_region->picture.p[3].p_pixels[i_offset]; a = (int)p_region->p_picture->p[3].p_pixels[i_offset];
/* Add dithering compensation */ /* Add dithering compensation */
#ifdef RANDOM_DITHERING #ifdef RANDOM_DITHERING
...@@ -1854,7 +1854,7 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic ) ...@@ -1854,7 +1854,7 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic )
} }
/* Set pixel to best color */ /* Set pixel to best color */
p_region->picture.p[0].p_pixels[i_offset] = i_best; p_region->p_picture->p[0].p_pixels[i_offset] = i_best;
/* Update dithering state */ /* Update dithering state */
#ifdef RANDOM_DITHERING #ifdef RANDOM_DITHERING
...@@ -2364,8 +2364,8 @@ static void encode_pixel_line_2bp( bs_t *s, subpicture_region_t *p_region, ...@@ -2364,8 +2364,8 @@ static void encode_pixel_line_2bp( bs_t *s, subpicture_region_t *p_region,
int i_line ) int i_line )
{ {
unsigned int i, i_length = 0; unsigned int i, i_length = 0;
int i_pitch = p_region->picture.p->i_pitch; int i_pitch = p_region->p_picture->p->i_pitch;
uint8_t *p_data = &p_region->picture.p->p_pixels[ i_pitch * i_line ]; uint8_t *p_data = &p_region->p_picture->p->p_pixels[ i_pitch * i_line ];
int i_last_pixel = p_data[0]; int i_last_pixel = p_data[0];
for( i = 0; i <= p_region->fmt.i_visible_width; i++ ) for( i = 0; i <= p_region->fmt.i_visible_width; i++ )
...@@ -2455,8 +2455,8 @@ static void encode_pixel_line_4bp( bs_t *s, subpicture_region_t *p_region, ...@@ -2455,8 +2455,8 @@ static void encode_pixel_line_4bp( bs_t *s, subpicture_region_t *p_region,
int i_line ) int i_line )
{ {
unsigned int i, i_length = 0; unsigned int i, i_length = 0;
int i_pitch = p_region->picture.p->i_pitch; int i_pitch = p_region->p_picture->p->i_pitch;
uint8_t *p_data = &p_region->picture.p->p_pixels[ i_pitch * i_line ]; uint8_t *p_data = &p_region->p_picture->p->p_pixels[ i_pitch * i_line ];
int i_last_pixel = p_data[0]; int i_last_pixel = p_data[0];
for( i = 0; i <= p_region->fmt.i_visible_width; i++ ) for( i = 0; i <= p_region->fmt.i_visible_width; i++ )
...@@ -2553,8 +2553,8 @@ static void encode_pixel_line_8bp( bs_t *s, subpicture_region_t *p_region, ...@@ -2553,8 +2553,8 @@ static void encode_pixel_line_8bp( bs_t *s, subpicture_region_t *p_region,
int i_line ) int i_line )
{ {
unsigned int i, i_length = 0; unsigned int i, i_length = 0;
int i_pitch = p_region->picture.p->i_pitch; int i_pitch = p_region->p_picture->p->i_pitch;
uint8_t *p_data = &p_region->picture.p->p_pixels[ i_pitch * i_line ]; uint8_t *p_data = &p_region->p_picture->p->p_pixels[ i_pitch * i_line ];
int i_last_pixel = p_data[0]; int i_last_pixel = p_data[0];
for( i = 0; i <= p_region->fmt.i_visible_width; i++ ) for( i = 0; i <= p_region->fmt.i_visible_width; i++ )
......
...@@ -640,7 +640,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, kate_packet *p_kp, block_t ...@@ -640,7 +640,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, kate_packet *p_kp, block_t
CreateKatePalette( fmt.p_palette, ev->palette ); CreateKatePalette( fmt.p_palette, ev->palette );
/* create the bitmap */ /* create the bitmap */
CreateKateBitmap( &p_bitmap_region->picture, ev->bitmap ); CreateKateBitmap( p_bitmap_region->p_picture, ev->bitmap );
msg_Dbg(p_dec, "Created bitmap, %zux%zu, %zu colors\n", ev->bitmap->width, ev->bitmap->height, ev->palette->ncolors); msg_Dbg(p_dec, "Created bitmap, %zux%zu, %zu colors\n", ev->bitmap->width, ev->bitmap->height, ev->palette->ncolors);
} }
......
...@@ -569,7 +569,7 @@ static int BuildRegions( spu_t *p_spu, rectangle_t *p_region, int i_max_region, ...@@ -569,7 +569,7 @@ static int BuildRegions( spu_t *p_spu, rectangle_t *p_region, int i_max_region,
static void RegionDraw( subpicture_region_t *p_region, ass_image_t *p_img ) static void RegionDraw( subpicture_region_t *p_region, ass_image_t *p_img )
{ {
const plane_t *p = &p_region->picture.p[0]; const plane_t *p = &p_region->p_picture->p[0];
const int i_x = p_region->i_x; const int i_x = p_region->i_x;
const int i_y = p_region->i_y; const int i_y = p_region->i_y;
const int i_width = p_region->fmt.i_width; const int i_width = p_region->fmt.i_width;
......
...@@ -676,8 +676,8 @@ static void Render( decoder_t *p_dec, subpicture_t *p_spu, ...@@ -676,8 +676,8 @@ static void Render( decoder_t *p_dec, subpicture_t *p_spu,
p_spu->p_region->i_x = p_spu_properties->i_x; p_spu->p_region->i_x = p_spu_properties->i_x;
p_spu->p_region->i_y = p_spu_properties->i_y + p_spu_data->i_y_top_offset; p_spu->p_region->i_y = p_spu_properties->i_y + p_spu_data->i_y_top_offset;
p_p = p_spu->p_region->picture.p->p_pixels; p_p = p_spu->p_region->p_picture->p->p_pixels;
i_pitch = p_spu->p_region->picture.p->i_pitch; i_pitch = p_spu->p_region->p_picture->p->i_pitch;
/* Build palette */ /* Build palette */
fmt.p_palette->i_entries = 4; fmt.p_palette->i_entries = 4;
......
...@@ -1208,7 +1208,8 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec, ...@@ -1208,7 +1208,8 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec,
return NULL; return NULL;
} }
assert( p_pic->format.i_chroma == VLC_FOURCC('Y','U','V','A') ); assert( p_pic->format.i_chroma == VLC_FOURCC('Y','U','V','A') );
picture_CopyPixels( &p_region->picture, p_pic ); /* FIXME the copy is probably not needed anymore */
picture_CopyPixels( p_region->p_picture, p_pic );
/* This isn't the best way to do this - if you really want transparency, then /* This isn't the best way to do this - if you really want transparency, then
* you're much better off using an image type that supports it like PNG. The * you're much better off using an image type that supports it like PNG. The
...@@ -1231,11 +1232,11 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec, ...@@ -1231,11 +1232,11 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec,
{ {
for( unsigned int x = 0; x < p_region->fmt.i_width; x++ ) for( unsigned int x = 0; x < p_region->fmt.i_width; x++ )
{ {
if( p_region->picture.Y_PIXELS[y*p_region->picture.Y_PITCH + x] != i_y || if( p_region->p_picture->Y_PIXELS[y*p_region->p_picture->Y_PITCH + x] != i_y ||
p_region->picture.U_PIXELS[y*p_region->picture.U_PITCH + x] != i_u || p_region->p_picture->U_PIXELS[y*p_region->p_picture->U_PITCH + x] != i_u ||
p_region->picture.V_PIXELS[y*p_region->picture.V_PITCH + x] != i_v ) p_region->p_picture->V_PIXELS[y*p_region->p_picture->V_PITCH + x] != i_v )
continue; continue;
p_region->picture.A_PIXELS[y*p_region->picture.A_PITCH + x] = 0; p_region->p_picture->A_PIXELS[y*p_region->p_picture->A_PITCH + x] = 0;
} }
} }
......
...@@ -544,7 +544,7 @@ static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data, ...@@ -544,7 +544,7 @@ static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data,
subpicture_region_t *p_region ) subpicture_region_t *p_region )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
uint8_t *p_dest = p_region->picture.Y_PIXELS; uint8_t *p_dest = p_region->p_picture->Y_PIXELS;
int i_field; /* The subtitles are interlaced */ int i_field; /* The subtitles are interlaced */
int i_row, i_column; /* scanline row/column number */ int i_row, i_column; /* scanline row/column number */
uint8_t i_color, i_count; uint8_t i_color, i_count;
...@@ -563,13 +563,13 @@ static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data, ...@@ -563,13 +563,13 @@ static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data,
if( i_color == 0 && (i_count = bs_read( &bs, 2 )) ) if( i_color == 0 && (i_count = bs_read( &bs, 2 )) )
{ {
i_count = __MIN( i_count, p_sys->i_width - i_column ); i_count = __MIN( i_count, p_sys->i_width - i_column );
memset( &p_dest[i_row * p_region->picture.Y_PITCH + memset( &p_dest[i_row * p_region->p_picture->Y_PITCH +
i_column], 0, i_count + 1 ); i_column], 0, i_count + 1 );
i_column += i_count; i_column += i_count;
continue; continue;
} }
p_dest[i_row * p_region->picture.Y_PITCH + i_column] = i_color; p_dest[i_row * p_region->p_picture->Y_PITCH + i_column] = i_color;
} }
bs_align( &bs ); bs_align( &bs );
......
...@@ -418,12 +418,12 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block ) ...@@ -418,12 +418,12 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
} }
else else
{ {
picture_t *p_pic = &p_spu->p_region->picture; picture_t *p_pic = p_spu->p_region->p_picture;
/* ZVBI is stupid enough to assume pitch == width */ /* ZVBI is stupid enough to assume pitch == width */
p_pic->p->i_pitch = 4 * fmt.i_width; p_pic->p->i_pitch = 4 * fmt.i_width;
vbi_draw_vt_page( &p_page, ZVBI_PIXFMT_RGBA32, vbi_draw_vt_page( &p_page, ZVBI_PIXFMT_RGBA32,
p_spu->p_region->picture.p->p_pixels, 1, 1 ); p_spu->p_region->p_picture->p->p_pixels, 1, 1 );
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
memcpy( p_sys->nav_link, &p_page.nav_link, sizeof( p_sys->nav_link )) ; memcpy( p_sys->nav_link, &p_page.nav_link, sizeof( p_sys->nav_link )) ;
......
...@@ -883,23 +883,22 @@ static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string, ...@@ -883,23 +883,22 @@ static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string,
fmt_out.i_bits_per_pixel = 32; fmt_out.i_bits_per_pixel = 32;
vlc_memcpy( p_fmt, &fmt_out, sizeof(video_format_t) ); vlc_memcpy( p_fmt, &fmt_out, sizeof(video_format_t) );
/* FIXME not needed to copy the picture anymore no ? */
p_dest = AllocatePicture( VLC_OBJECT(p_intf), &fmt_out ); p_dest = AllocatePicture( VLC_OBJECT(p_intf), &fmt_out );
if( !p_dest ) if( !p_dest )
{ {
if( p_region->picture.pf_release ) picture_Release( p_region->p_picture );
p_region->picture.pf_release( &p_region->picture );
free( p_region->psz_text ); free( p_region->psz_text );
free( p_region ); free( p_region );
return NULL; return NULL;
} }
vout_CopyPicture( VLC_OBJECT(p_intf), p_dest, &p_region->picture ); vout_CopyPicture( VLC_OBJECT(p_intf), p_dest, p_region->p_picture );
#else #else
fmt_out.i_chroma = p_fmt->i_chroma; fmt_out.i_chroma = p_fmt->i_chroma;
p_dest = ConvertImage( p_intf, &p_region->picture, p_dest = ConvertImage( p_intf, &p_region->p_picture,
&p_region->fmt, &fmt_out ); &p_region->fmt, &fmt_out );
#endif #endif
if( p_region->picture.pf_release ) picture_Release( p_region->p_picture );
p_region->picture.pf_release( &p_region->picture );
free( p_region->psz_text ); free( p_region->psz_text );
free( p_region ); free( p_region );
return p_dest; return p_dest;
......
...@@ -662,7 +662,6 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, ...@@ -662,7 +662,6 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
int i, x, y, i_pitch; int i, x, y, i_pitch;
uint8_t i_y; /* YUV values, derived from incoming RGB */ uint8_t i_y; /* YUV values, derived from incoming RGB */
int8_t i_u, i_v; int8_t i_u, i_v;
subpicture_region_t *p_region_tmp;
/* Create a new subpicture region */ /* Create a new subpicture region */
memset( &fmt, 0, sizeof(video_format_t) ); memset( &fmt, 0, sizeof(video_format_t) );
...@@ -675,16 +674,12 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, ...@@ -675,16 +674,12 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
if( p_region->fmt.i_visible_height > 0 ) if( p_region->fmt.i_visible_height > 0 )
fmt.i_visible_height = p_region->fmt.i_visible_height; fmt.i_visible_height = p_region->fmt.i_visible_height;
fmt.i_x_offset = fmt.i_y_offset = 0; fmt.i_x_offset = fmt.i_y_offset = 0;
p_region_tmp = spu_CreateRegion( p_filter, &fmt );
if( !p_region_tmp )
{
msg_Err( p_filter, "cannot allocate SPU region" );
return VLC_EGENERIC;
}
p_region->fmt = p_region_tmp->fmt; assert( !p_region->p_picture );
p_region->picture = p_region_tmp->picture; p_region->p_picture = picture_New( fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_aspect );
free( p_region_tmp ); if( !p_region->p_picture )
return VLC_EGENERIC;
p_region->fmt = fmt;
/* Calculate text color components */ /* Calculate text color components */
i_y = (uint8_t)(( 66 * p_line->i_red + 129 * p_line->i_green + i_y = (uint8_t)(( 66 * p_line->i_red + 129 * p_line->i_green +
...@@ -715,8 +710,8 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, ...@@ -715,8 +710,8 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
(int)fmt.p_palette->palette[i][3] * (255 - p_line->i_alpha) / 255; (int)fmt.p_palette->palette[i][3] * (255 - p_line->i_alpha) / 255;
} }
p_dst = p_region->picture.Y_PIXELS; p_dst = p_region->p_picture->Y_PIXELS;
i_pitch = p_region->picture.Y_PITCH; i_pitch = p_region->p_picture->Y_PITCH;
/* Initialize the region pixels */ /* Initialize the region pixels */
memset( p_dst, 0, i_pitch * p_region->fmt.i_height ); memset( p_dst, 0, i_pitch * p_region->fmt.i_height );
...@@ -768,21 +763,21 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, ...@@ -768,21 +763,21 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
/* Outlining (find something better than nearest neighbour filtering ?) */ /* Outlining (find something better than nearest neighbour filtering ?) */
if( 1 ) if( 1 )
{ {
uint8_t *p_dst = p_region->picture.Y_PIXELS; uint8_t *p_dst = p_region->p_picture->Y_PIXELS;
uint8_t *p_top = p_dst; /* Use 1st line as a cache */ uint8_t *p_top = p_dst; /* Use 1st line as a cache */
uint8_t left, current; uint8_t left, current;
for( y = 1; y < (int)fmt.i_height - 1; y++ ) for( y = 1; y < (int)fmt.i_height - 1; y++ )
{ {
if( y > 1 ) memcpy( p_top, p_dst, fmt.i_width ); if( y > 1 ) memcpy( p_top, p_dst, fmt.i_width );
p_dst += p_region->picture.Y_PITCH; p_dst += p_region->p_picture->Y_PITCH;
left = 0; left = 0;
for( x = 1; x < (int)fmt.i_width - 1; x++ ) for( x = 1; x < (int)fmt.i_width - 1; x++ )
{ {
current = p_dst[x]; current = p_dst[x];
p_dst[x] = ( 8 * (int)p_dst[x] + left + p_dst[x+1] + p_top[x -1]+ p_top[x] + p_top[x+1] + p_dst[x] = ( 8 * (int)p_dst[x] + left + p_dst[x+1] + p_top[x -1]+ p_top[x] + p_top[x+1] +
p_dst[x -1 + p_region->picture.Y_PITCH ] + p_dst[x + p_region->picture.Y_PITCH] + p_dst[x + 1 + p_region->picture.Y_PITCH]) / 16; p_dst[x -1 + p_region->p_picture->Y_PITCH ] + p_dst[x + p_region->p_picture->Y_PITCH] + p_dst[x + 1 + p_region->p_picture->Y_PITCH]) / 16;
left = current; left = current;
} }
} }
...@@ -803,11 +798,11 @@ static void UnderlineGlyphYUVA( int i_line_thickness, int i_line_offset, bool b_ ...@@ -803,11 +798,11 @@ static void UnderlineGlyphYUVA( int i_line_thickness, int i_line_offset, bool b_
int i_pitch; int i_pitch;
uint8_t *p_dst_y,*p_dst_u,*p_dst_v,*p_dst_a; uint8_t *p_dst_y,*p_dst_u,*p_dst_v,*p_dst_a;
p_dst_y = p_region->picture.Y_PIXELS; p_dst_y = p_region->p_picture->Y_PIXELS;
p_dst_u = p_region->picture.U_PIXELS; p_dst_u = p_region->p_picture->U_PIXELS;
p_dst_v = p_region->picture.V_PIXELS; p_dst_v = p_region->p_picture->V_PIXELS;
p_dst_a = p_region->picture.A_PIXELS; p_dst_a = p_region->p_picture->A_PIXELS;
i_pitch = p_region->picture.A_PITCH; i_pitch = p_region->p_picture->A_PITCH;
int i_offset = ( p_this_glyph_pos->y + i_glyph_tmax + i_line_offset + 3 ) * i_pitch + int i_offset = ( p_this_glyph_pos->y + i_glyph_tmax + i_line_offset + 3 ) * i_pitch +
p_this_glyph_pos->x + p_this_glyph->left + 3 + i_align_offset; p_this_glyph_pos->x + p_this_glyph->left + 3 + i_align_offset;
...@@ -866,8 +861,8 @@ static void UnderlineGlyphYUVA( int i_line_thickness, int i_line_offset, bool b_ ...@@ -866,8 +861,8 @@ static void UnderlineGlyphYUVA( int i_line_thickness, int i_line_offset, bool b_
static void DrawBlack( line_desc_t *p_line, int i_width, subpicture_region_t *p_region, int xoffset, int yoffset ) static void DrawBlack( line_desc_t *p_line, int i_width, subpicture_region_t *p_region, int xoffset, int yoffset