From 8f83ef4b74b37d92e95fc9bcebabf67e9aeef291 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sat, 20 Sep 2008 00:09:37 +0200 Subject: [PATCH] Changed subpicture_region_t->picture into a picture_t * It will avoid useless picture copy. --- include/vlc_vout.h | 9 +- modules/codec/csri.c | 6 +- modules/codec/cvdsub.c | 6 +- modules/codec/dvbsub.c | 54 +++---- modules/codec/kate.c | 2 +- modules/codec/libass.c | 2 +- modules/codec/spudec/parse.c | 4 +- modules/codec/subtitles/subsusf.c | 11 +- modules/codec/svcdsub.c | 6 +- modules/codec/zvbi.c | 4 +- modules/gui/fbosd.c | 11 +- modules/misc/freetype.c | 63 +++----- modules/misc/quartztext.c | 25 ++- modules/misc/svg.c | 27 ++-- modules/misc/win32text.c | 22 +-- .../dynamicoverlay/dynamicoverlay.c | 3 +- modules/video_filter/logo.c | 3 +- modules/video_filter/mosaic.c | 4 +- modules/video_filter/osdmenu.c | 3 +- modules/video_filter/remoteosd.c | 3 +- modules/video_filter/rss.c | 3 +- src/osd/osd_widgets.c | 22 +-- src/video_output/vout_intf.c | 10 +- src/video_output/vout_subpictures.c | 151 +++++++++--------- 24 files changed, 225 insertions(+), 229 deletions(-) diff --git a/include/vlc_vout.h b/include/vlc_vout.h index 377448d8c0..b3b2afdb98 100644 --- a/include/vlc_vout.h +++ b/include/vlc_vout.h @@ -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 * @@ -299,7 +304,7 @@ struct picture_heap_t struct subpicture_region_t { 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_y; /**< position of region */ @@ -311,7 +316,7 @@ struct subpicture_region_t 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_cache; /**< modified version of this region */ + subpicture_region_private_t *p_private; /**< modified version of this region */ }; /** diff --git a/modules/codec/csri.c b/modules/codec/csri.c index 6bc21f0068..919e086f62 100644 --- a/modules/codec/csri.c +++ b/modules/codec/csri.c @@ -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; - 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 ); memset( &csri_frame, 0, sizeof(csri_frame) ); csri_frame.pixfmt = CSRI_F_BGRA; - csri_frame.planes[0] = (unsigned char*)p_spu_region->picture.Y_PIXELS; - csri_frame.strides[0] = p_spu_region->picture.Y_PITCH; + csri_frame.planes[0] = (unsigned char*)p_spu_region->p_picture->Y_PIXELS; + csri_frame.strides[0] = p_spu_region->p_picture->Y_PITCH; csri_render( p_sys->p_instance, &csri_frame, ts * 0.000001 ); } } diff --git a/modules/codec/cvdsub.c b/modules/codec/cvdsub.c index 90cdc33475..eb934b5ca7 100644 --- a/modules/codec/cvdsub.c +++ b/modules/codec/cvdsub.c @@ -569,7 +569,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data, subpicture_region_t *p_region ) { 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_row, i_column; /* scanline row/column number */ uint8_t i_color, i_count; @@ -591,7 +591,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data, /* Fill the rest of the line with next color */ 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, p_sys->i_width - i_column ); i_column = p_sys->i_width; @@ -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 ); - 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_count - 1; continue; diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c index 30db44ea70..baf589c101 100644 --- a/modules/codec/dvbsub.c +++ b/modules/codec/dvbsub.c @@ -1571,8 +1571,8 @@ static subpicture_t *render( decoder_t *p_dec ) } p_src = p_region->p_pixbuf; - p_dst = p_spu_region->picture.Y_PIXELS; - i_pitch = p_spu_region->picture.Y_PITCH; + p_dst = p_spu_region->p_picture->Y_PIXELS; + i_pitch = p_spu_region->p_picture->Y_PITCH; /* Copy pixel buffer */ for( j = 0; j < p_region->i_height; j++ ) @@ -1710,11 +1710,11 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic ) #else int *pi_delta; #endif - int i_pixels = p_region->picture.p[0].i_visible_lines - * p_region->picture.p[0].i_pitch; - int i_iterator = p_region->picture.p[0].i_visible_lines * 3 / 4 - * p_region->picture.p[0].i_pitch - + p_region->picture.p[0].i_pitch * 1 / 3; + int i_pixels = p_region->p_picture->p[0].i_visible_lines + * p_region->p_picture->p[0].i_pitch; + int i_iterator = p_region->p_picture->p[0].i_visible_lines * 3 / 4 + * p_region->p_picture->p[0].i_pitch + + p_region->p_picture->p[0].i_pitch * 1 / 3; int i_tolerance = 0; #ifdef DEBUG_DVBSUB @@ -1754,10 +1754,10 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic ) for( i = 0; i < i_pixels ; ) { uint8_t y, u, v, a; - y = p_region->picture.p[0].p_pixels[i]; - u = p_region->picture.p[1].p_pixels[i]; - v = p_region->picture.p[2].p_pixels[i]; - a = p_region->picture.p[3].p_pixels[i]; + y = p_region->p_picture->p[0].p_pixels[i]; + u = p_region->p_picture->p[1].p_pixels[i]; + v = p_region->p_picture->p[2].p_pixels[i]; + a = p_region->p_picture->p[3].p_pixels[i]; 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 && @@ -1799,29 +1799,29 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic ) #endif #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 ); - 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; } #endif /* 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; - 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 i_mindist, i_best; - y = (int)p_region->picture.p[0].p_pixels[i_offset]; - u = (int)p_region->picture.p[1].p_pixels[i_offset]; - v = (int)p_region->picture.p[2].p_pixels[i_offset]; - a = (int)p_region->picture.p[3].p_pixels[i_offset]; + y = (int)p_region->p_picture->p[0].p_pixels[i_offset]; + u = (int)p_region->p_picture->p[1].p_pixels[i_offset]; + v = (int)p_region->p_picture->p[2].p_pixels[i_offset]; + a = (int)p_region->p_picture->p[3].p_pixels[i_offset]; /* Add dithering compensation */ #ifdef RANDOM_DITHERING @@ -1854,7 +1854,7 @@ static subpicture_t *YuvaYuvp( subpicture_t *p_subpic ) } /* 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 */ #ifdef RANDOM_DITHERING @@ -2364,8 +2364,8 @@ static void encode_pixel_line_2bp( bs_t *s, subpicture_region_t *p_region, int i_line ) { unsigned int i, i_length = 0; - int i_pitch = p_region->picture.p->i_pitch; - uint8_t *p_data = &p_region->picture.p->p_pixels[ i_pitch * i_line ]; + int i_pitch = p_region->p_picture->p->i_pitch; + uint8_t *p_data = &p_region->p_picture->p->p_pixels[ i_pitch * i_line ]; int i_last_pixel = p_data[0]; 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, int i_line ) { unsigned int i, i_length = 0; - int i_pitch = p_region->picture.p->i_pitch; - uint8_t *p_data = &p_region->picture.p->p_pixels[ i_pitch * i_line ]; + int i_pitch = p_region->p_picture->p->i_pitch; + uint8_t *p_data = &p_region->p_picture->p->p_pixels[ i_pitch * i_line ]; int i_last_pixel = p_data[0]; 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, int i_line ) { unsigned int i, i_length = 0; - int i_pitch = p_region->picture.p->i_pitch; - uint8_t *p_data = &p_region->picture.p->p_pixels[ i_pitch * i_line ]; + int i_pitch = p_region->p_picture->p->i_pitch; + uint8_t *p_data = &p_region->p_picture->p->p_pixels[ i_pitch * i_line ]; int i_last_pixel = p_data[0]; for( i = 0; i <= p_region->fmt.i_visible_width; i++ ) diff --git a/modules/codec/kate.c b/modules/codec/kate.c index b014bc4062..b8646aef1c 100644 --- a/modules/codec/kate.c +++ b/modules/codec/kate.c @@ -640,7 +640,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, kate_packet *p_kp, block_t CreateKatePalette( fmt.p_palette, ev->palette ); /* 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); } diff --git a/modules/codec/libass.c b/modules/codec/libass.c index 74b5e10061..582cb7224d 100644 --- a/modules/codec/libass.c +++ b/modules/codec/libass.c @@ -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 ) { - 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_y = p_region->i_y; const int i_width = p_region->fmt.i_width; diff --git a/modules/codec/spudec/parse.c b/modules/codec/spudec/parse.c index 3e0efff3a8..4e118e02b1 100644 --- a/modules/codec/spudec/parse.c +++ b/modules/codec/spudec/parse.c @@ -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_y = p_spu_properties->i_y + p_spu_data->i_y_top_offset; - p_p = p_spu->p_region->picture.p->p_pixels; - i_pitch = p_spu->p_region->picture.p->i_pitch; + p_p = p_spu->p_region->p_picture->p->p_pixels; + i_pitch = p_spu->p_region->p_picture->p->i_pitch; /* Build palette */ fmt.p_palette->i_entries = 4; diff --git a/modules/codec/subtitles/subsusf.c b/modules/codec/subtitles/subsusf.c index c603532009..b03be78b8d 100644 --- a/modules/codec/subtitles/subsusf.c +++ b/modules/codec/subtitles/subsusf.c @@ -1208,7 +1208,8 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec, return NULL; } 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 * 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, { 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 || - p_region->picture.U_PIXELS[y*p_region->picture.U_PITCH + x] != i_u || - p_region->picture.V_PIXELS[y*p_region->picture.V_PITCH + x] != i_v ) + if( p_region->p_picture->Y_PIXELS[y*p_region->p_picture->Y_PITCH + x] != i_y || + p_region->p_picture->U_PIXELS[y*p_region->p_picture->U_PITCH + x] != i_u || + p_region->p_picture->V_PIXELS[y*p_region->p_picture->V_PITCH + x] != i_v ) 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; } } diff --git a/modules/codec/svcdsub.c b/modules/codec/svcdsub.c index 2c54c17029..5a1ecbfb8e 100644 --- a/modules/codec/svcdsub.c +++ b/modules/codec/svcdsub.c @@ -544,7 +544,7 @@ static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data, subpicture_region_t *p_region ) { 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_row, i_column; /* scanline row/column number */ uint8_t i_color, i_count; @@ -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 )) ) { 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 += i_count; 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 ); diff --git a/modules/codec/zvbi.c b/modules/codec/zvbi.c index 88fe5bd269..5e26f457a9 100644 --- a/modules/codec/zvbi.c +++ b/modules/codec/zvbi.c @@ -418,12 +418,12 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block ) } 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 */ 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 ); + p_spu->p_region->p_picture->p->p_pixels, 1, 1 ); vlc_mutex_lock( &p_sys->lock ); memcpy( p_sys->nav_link, &p_page.nav_link, sizeof( p_sys->nav_link )) ; diff --git a/modules/gui/fbosd.c b/modules/gui/fbosd.c index 4c1f657684..710452ce9d 100644 --- a/modules/gui/fbosd.c +++ b/modules/gui/fbosd.c @@ -883,23 +883,22 @@ static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string, fmt_out.i_bits_per_pixel = 32; 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 ); if( !p_dest ) { - if( p_region->picture.pf_release ) - p_region->picture.pf_release( &p_region->picture ); + picture_Release( p_region->p_picture ); free( p_region->psz_text ); free( p_region ); 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 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 ); #endif - if( p_region->picture.pf_release ) - p_region->picture.pf_release( &p_region->picture ); + picture_Release( p_region->p_picture ); free( p_region->psz_text ); free( p_region ); return p_dest; diff --git a/modules/misc/freetype.c b/modules/misc/freetype.c index c5864307b3..ff72294db2 100644 --- a/modules/misc/freetype.c +++ b/modules/misc/freetype.c @@ -662,7 +662,6 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, int i, x, y, i_pitch; uint8_t i_y; /* YUV values, derived from incoming RGB */ int8_t i_u, i_v; - subpicture_region_t *p_region_tmp; /* Create a new subpicture region */ memset( &fmt, 0, sizeof(video_format_t) ); @@ -675,16 +674,12 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, if( p_region->fmt.i_visible_height > 0 ) fmt.i_visible_height = p_region->fmt.i_visible_height; 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; - p_region->picture = p_region_tmp->picture; - free( p_region_tmp ); + assert( !p_region->p_picture ); + p_region->p_picture = picture_New( fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_aspect ); + if( !p_region->p_picture ) + return VLC_EGENERIC; + p_region->fmt = fmt; /* Calculate text color components */ 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, (int)fmt.p_palette->palette[i][3] * (255 - p_line->i_alpha) / 255; } - p_dst = p_region->picture.Y_PIXELS; - i_pitch = p_region->picture.Y_PITCH; + p_dst = p_region->p_picture->Y_PIXELS; + i_pitch = p_region->p_picture->Y_PITCH; /* Initialize the region pixels */ 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, /* Outlining (find something better than nearest neighbour filtering ?) */ 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 left, current; for( y = 1; y < (int)fmt.i_height - 1; y++ ) { 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; for( x = 1; x < (int)fmt.i_width - 1; 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 -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; } } @@ -803,11 +798,11 @@ static void UnderlineGlyphYUVA( int i_line_thickness, int i_line_offset, bool b_ int i_pitch; uint8_t *p_dst_y,*p_dst_u,*p_dst_v,*p_dst_a; - p_dst_y = p_region->picture.Y_PIXELS; - p_dst_u = p_region->picture.U_PIXELS; - p_dst_v = p_region->picture.V_PIXELS; - p_dst_a = p_region->picture.A_PIXELS; - i_pitch = p_region->picture.A_PITCH; + p_dst_y = p_region->p_picture->Y_PIXELS; + p_dst_u = p_region->p_picture->U_PIXELS; + p_dst_v = p_region->p_picture->V_PIXELS; + p_dst_a = p_region->p_picture->A_PIXELS; + 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 + 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_ static void DrawBlack( line_desc_t *p_line, int i_width, subpicture_region_t *p_region, int xoffset, int yoffset ) { - uint8_t *p_dst = p_region->picture.A_PIXELS; - int i_pitch = p_region->picture.A_PITCH; + uint8_t *p_dst = p_region->p_picture->A_PIXELS; + int i_pitch = p_region->p_picture->A_PITCH; int x,y; for( ; p_line != NULL; p_line = p_line->p_next ) @@ -930,7 +925,6 @@ static int RenderYUVA( filter_t *p_filter, subpicture_region_t *p_region, video_format_t fmt; int i, x, y, i_pitch, i_alpha; uint8_t i_y, i_u, i_v; /* YUV values, derived from incoming RGB */ - subpicture_region_t *p_region_tmp; if( i_width == 0 || i_height == 0 ) return VLC_SUCCESS; @@ -946,16 +940,11 @@ static int RenderYUVA( filter_t *p_filter, subpicture_region_t *p_region, if( p_region->fmt.i_visible_height > 0 ) fmt.i_visible_height = p_region->fmt.i_visible_height; 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; - p_region->picture = p_region_tmp->picture; - free( p_region_tmp ); + p_region->p_picture = picture_New( fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_aspect ); + if( !p_region->p_picture ) + return VLC_EGENERIC; + p_region->fmt = fmt; /* Calculate text color components */ YUVFromRGB( (p_line->i_red << 16) | @@ -964,11 +953,11 @@ static int RenderYUVA( filter_t *p_filter, subpicture_region_t *p_region, &i_y, &i_u, &i_v); i_alpha = p_line->i_alpha; - p_dst_y = p_region->picture.Y_PIXELS; - p_dst_u = p_region->picture.U_PIXELS; - p_dst_v = p_region->picture.V_PIXELS; - p_dst_a = p_region->picture.A_PIXELS; - i_pitch = p_region->picture.A_PITCH; + p_dst_y = p_region->p_picture->Y_PIXELS; + p_dst_u = p_region->p_picture->U_PIXELS; + p_dst_v = p_region->p_picture->V_PIXELS; + p_dst_a = p_region->p_picture->A_PIXELS; + i_pitch = p_region->p_picture->A_PITCH; /* Initialize the region pixels */ if( p_filter->p_sys->i_effect != EFFECT_BACKGROUND ) diff --git a/modules/misc/quartztext.c b/modules/misc/quartztext.c index f0d6a41728..fb345a50d1 100644 --- a/modules/misc/quartztext.c +++ b/modules/misc/quartztext.c @@ -1321,7 +1321,6 @@ static int RenderYUVA( filter_t *p_filter, subpicture_region_t *p_region, UniCha video_format_t fmt; int x, y, i_offset, i_pitch; uint8_t i_y, i_u, i_v; // YUV values, derived from incoming RGB - subpicture_region_t *p_region_tmp; // Create a new subpicture region memset( &fmt, 0, sizeof(video_format_t) ); @@ -1330,21 +1329,17 @@ static int RenderYUVA( filter_t *p_filter, subpicture_region_t *p_region, UniCha fmt.i_width = fmt.i_visible_width = i_width; fmt.i_height = fmt.i_visible_height = i_textblock_height + VERTICAL_MARGIN * 2; 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" ); + + p_region->p_picture = picture_New( fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_aspect ); + if( !p_region->p_picture ) return VLC_EGENERIC; - } - p_region->fmt = p_region_tmp->fmt; - p_region->picture = p_region_tmp->picture; - free( p_region_tmp ); - - p_dst_y = p_region->picture.Y_PIXELS; - p_dst_u = p_region->picture.U_PIXELS; - p_dst_v = p_region->picture.V_PIXELS; - p_dst_a = p_region->picture.A_PIXELS; - i_pitch = p_region->picture.A_PITCH; + p_region->fmt = fmt; + + p_dst_y = p_region->p_picture->Y_PIXELS; + p_dst_u = p_region->p_picture->U_PIXELS; + p_dst_v = p_region->p_picture->V_PIXELS; + p_dst_a = p_region->p_picture->A_PIXELS; + i_pitch = p_region->p_picture->A_PITCH; i_offset = VERTICAL_MARGIN *i_pitch; for( y=0; yp_sys->i_width != i_width || p_filter->p_sys->i_height != i_height ) @@ -284,31 +283,27 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, fmt.i_width = fmt.i_visible_width = i_width; fmt.i_height = fmt.i_visible_height = i_height; 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" ); + + p_region->p_picture = picture_New( fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_aspect ); + if( !p_region->p_picture ) return VLC_EGENERIC; - } - p_region->fmt = p_region_tmp->fmt; - p_region->picture = p_region_tmp->picture; - free( p_region_tmp ); + p_region->fmt = fmt; p_region->i_x = p_region->i_y = 0; - p_y = p_region->picture.Y_PIXELS; - p_u = p_region->picture.U_PIXELS; - p_v = p_region->picture.V_PIXELS; - p_a = p_region->picture.A_PIXELS; + p_y = p_region->p_picture->Y_PIXELS; + p_u = p_region->p_picture->U_PIXELS; + p_v = p_region->p_picture->V_PIXELS; + p_a = p_region->p_picture->A_PIXELS; - i_pitch = p_region->picture.Y_PITCH; - i_u_pitch = p_region->picture.U_PITCH; + i_pitch = p_region->p_picture->Y_PITCH; + i_u_pitch = p_region->p_picture->U_PITCH; /* Initialize the region pixels (only the alpha will be changed later) */ memset( p_y, 0x00, i_pitch * p_region->fmt.i_height ); memset( p_u, 0x80, i_u_pitch * p_region->fmt.i_height ); memset( p_v, 0x80, i_u_pitch * p_region->fmt.i_height ); - p_pic = &p_region->picture; + p_pic = p_region->p_picture; /* Copy the data */ diff --git a/modules/misc/win32text.c b/modules/misc/win32text.c index 75ad54be30..9c16c12c70 100644 --- a/modules/misc/win32text.c +++ b/modules/misc/win32text.c @@ -217,7 +217,6 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, uint8_t *p_dst; video_format_t fmt; int i, i_pitch; - subpicture_region_t *p_region_tmp; bool b_outline = true; /* Create a new subpicture region */ @@ -226,12 +225,6 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, fmt.i_width = fmt.i_visible_width = i_width + (b_outline ? 4 : 0); fmt.i_height = fmt.i_visible_height = i_height + (b_outline ? 4 : 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; - } /* Build palette */ fmt.p_palette->i_entries = 16; @@ -243,17 +236,18 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, fmt.p_palette->palette[i][3] = pi_gamma[i]; } - p_region->fmt = p_region_tmp->fmt; - p_region->picture = p_region_tmp->picture; - free( p_region_tmp ); + p_region->p_picture = picture_New( fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_aspect ); + if( !p_region->p_picture ) + return VLC_EGENERIC; + p_region->fmt = fmt; - p_dst = p_region->picture.Y_PIXELS; - i_pitch = p_region->picture.Y_PITCH; + p_dst = p_region->p_picture->Y_PIXELS; + i_pitch = p_region->p_picture->Y_PITCH; if( b_outline ) { memset( p_dst, 0, i_pitch * fmt.i_height ); - p_dst += p_region->picture.Y_PITCH * 2 + 2; + p_dst += p_region->p_picture->Y_PITCH * 2 + 2; } for( i = 0; i < i_height; i++ ) @@ -270,7 +264,7 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, uint8_t left, current; int x, y; - p_dst = p_region->picture.Y_PIXELS; + p_dst = p_region->p_picture->Y_PIXELS; for( y = 1; y < (int)fmt.i_height - 1; y++ ) { diff --git a/modules/video_filter/dynamicoverlay/dynamicoverlay.c b/modules/video_filter/dynamicoverlay/dynamicoverlay.c index 80800d9db9..0c85468ce7 100644 --- a/modules/video_filter/dynamicoverlay/dynamicoverlay.c +++ b/modules/video_filter/dynamicoverlay/dynamicoverlay.c @@ -365,7 +365,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) } else { - vout_CopyPicture( p_filter, &p_region->picture, p_overlay->data.p_pic ); + /* FIXME the copy is probably not needed anymore */ + vout_CopyPicture( p_filter, p_region->p_picture, p_overlay->data.p_pic ); } p_region->i_x = p_overlay->i_x; p_region->i_y = p_overlay->i_y; diff --git a/modules/video_filter/logo.c b/modules/video_filter/logo.c index 4c7321da3f..9e1791b462 100644 --- a/modules/video_filter/logo.c +++ b/modules/video_filter/logo.c @@ -873,7 +873,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) return NULL; } - vout_CopyPicture( p_filter, &p_region->picture, p_pic ); + /* FIXME the copy is probably not needed anymore */ + vout_CopyPicture( p_filter, &p_region->p_picture, p_pic ); vlc_mutex_unlock( &p_logo_list->lock ); /* where to locate the logo: */ diff --git a/modules/video_filter/mosaic.c b/modules/video_filter/mosaic.c index 661eb77e26..169155d7ab 100644 --- a/modules/video_filter/mosaic.c +++ b/modules/video_filter/mosaic.c @@ -642,9 +642,9 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) } p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt_out ); - /* XXX That's a pity to do a copy, but it is needed for now */ + /* FIXME the copy is probably not needed anymore */ if( p_region ) - picture_Copy( &p_region->picture, p_converted ); + picture_Copy( &p_region->p_picture, p_converted ); if( !p_sys->b_keep ) picture_Release( p_converted ); diff --git a/modules/video_filter/osdmenu.c b/modules/video_filter/osdmenu.c index d8f68f7a3e..1c3d5bbca6 100644 --- a/modules/video_filter/osdmenu.c +++ b/modules/video_filter/osdmenu.c @@ -426,8 +426,9 @@ static subpicture_region_t *create_picture_region( filter_t *p_filter, subpictur p_region->fmt.i_width = p_region->fmt.i_visible_width = 0; p_region->fmt.i_height = p_region->fmt.i_visible_height = 0; } + /* FIXME the copy is probably not needed anymore */ if( p_pic ) - vout_CopyPicture( p_filter, &p_region->picture, p_pic ); + vout_CopyPicture( p_filter, p_region->p_picture, p_pic ); p_region->i_x = 0; p_region->i_y = 0; diff --git a/modules/video_filter/remoteosd.c b/modules/video_filter/remoteosd.c index 04ef5d2fe3..a6a253bfa4 100644 --- a/modules/video_filter/remoteosd.c +++ b/modules/video_filter/remoteosd.c @@ -1171,7 +1171,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) return NULL; } - vout_CopyPicture( p_filter, &p_region->picture, p_pic ); + /* FIXME the copy is probably not needed anymore */ + vout_CopyPicture( p_filter, p_region->p_picture, p_pic ); p_sys->b_need_update = false; diff --git a/modules/video_filter/rss.c b/modules/video_filter/rss.c index 29a42debce..dbb5dbe748 100644 --- a/modules/video_filter/rss.c +++ b/modules/video_filter/rss.c @@ -557,7 +557,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) { p_region->i_x = p_sys->i_xoff; p_region->i_y = p_sys->i_yoff; - vout_CopyPicture( p_filter, &p_region->picture, p_pic ); + /* FIXME the copy is probably not needed anymore */ + vout_CopyPicture( p_filter, p_region->p_picture, p_pic ); p_spu->p_region->p_next = p_region; } diff --git a/src/osd/osd_widgets.c b/src/osd/osd_widgets.c index 5d8fafd988..2d384d1b4c 100644 --- a/src/osd/osd_widgets.c +++ b/src/osd/osd_widgets.c @@ -52,8 +52,8 @@ static void DrawRect( subpicture_t *p_subpic, int i_x1, int i_y1, int i_x2, int i_y2, short fill ) { int x, y; - uint8_t *p_a = p_subpic->p_region->picture.A_PIXELS; - int i_pitch = p_subpic->p_region->picture.Y_PITCH; + uint8_t *p_a = p_subpic->p_region->p_picture->A_PIXELS; + int i_pitch = p_subpic->p_region->p_picture->Y_PITCH; if( fill == STYLE_FILLED ) { @@ -88,8 +88,8 @@ static void DrawTriangle( subpicture_t *p_subpic, int i_x1, int i_y1, int i_x2, int i_y2, short fill ) { int x, y, i_mid, h; - uint8_t *p_a = p_subpic->p_region->picture.A_PIXELS; - int i_pitch = p_subpic->p_region->picture.Y_PITCH; + uint8_t *p_a = p_subpic->p_region->p_picture->A_PIXELS; + int i_pitch = p_subpic->p_region->p_picture->Y_PITCH; i_mid = i_y1 + ( ( i_y2 - i_y1 ) >> 1 ); @@ -173,11 +173,11 @@ static int CreatePicture( spu_t *p_spu, subpicture_t *p_subpic, p_subpic->p_region->i_x = i_x; p_subpic->p_region->i_y = i_y; - p_y = p_subpic->p_region->picture.Y_PIXELS; - p_u = p_subpic->p_region->picture.U_PIXELS; - p_v = p_subpic->p_region->picture.V_PIXELS; - p_a = p_subpic->p_region->picture.A_PIXELS; - i_pitch = p_subpic->p_region->picture.Y_PITCH; + p_y = p_subpic->p_region->p_picture->Y_PIXELS; + p_u = p_subpic->p_region->p_picture->U_PIXELS; + p_v = p_subpic->p_region->p_picture->V_PIXELS; + p_a = p_subpic->p_region->p_picture->A_PIXELS; + i_pitch = p_subpic->p_region->p_picture->Y_PITCH; /* Initialize the region pixels (only the alpha will be changed later) */ memset( p_y, 0xff, i_pitch * p_subpic->p_region->fmt.i_height ); @@ -328,8 +328,8 @@ int osd_Icon( vlc_object_t *p_this, spu_t *p_spu, STYLE_FILLED ); if( i_type == OSD_MUTE_ICON ) { - uint8_t *p_a = p_subpic->p_region->picture.A_PIXELS; - int i_pitch = p_subpic->p_region->picture.Y_PITCH; + uint8_t *p_a = p_subpic->p_region->p_picture->A_PIXELS; + int i_pitch = p_subpic->p_region->p_picture->Y_PITCH; int i; for( i = 1; i < i_pitch; i++ ) { diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c index 2d48bb7407..a57e88bacc 100644 --- a/src/video_output/vout_intf.c +++ b/src/video_output/vout_intf.c @@ -477,8 +477,14 @@ static int VoutSnapshotPip( vout_thread_t *p_vout, image_handler_t *p_image, pic p_subpic->p_region = spu_CreateRegion( p_vout->p_spu, &fmt_out ); if( p_subpic->p_region ) - vout_CopyPicture( p_image->p_parent, &p_subpic->p_region->picture, p_pip ); - picture_Release( p_pip ); + { + picture_Release( p_subpic->p_region->p_picture ); + p_subpic->p_region->p_picture = p_pip; + } + else + { + picture_Release( p_pip ); + } spu_DisplaySubpicture( p_vout->p_spu, p_subpic ); return VLC_SUCCESS; diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c index 1ed10213fa..cf8ac2ee3c 100644 --- a/src/video_output/vout_subpictures.c +++ b/src/video_output/vout_subpictures.c @@ -70,6 +70,39 @@ struct filter_owner_sys_t #define SCALE_UNIT (1000) +/* */ +struct subpicture_region_private_t +{ + video_format_t fmt; + picture_t *p_picture; +}; + +static subpicture_region_private_t *SpuRegionPrivateCreate( video_format_t *p_fmt ) +{ + subpicture_region_private_t *p_private = malloc( sizeof(*p_private) ); + + if( !p_private ) + return NULL; + + p_private->fmt = *p_fmt; + if( p_fmt->p_palette ) + { + p_private->fmt.p_palette = malloc( sizeof(*p_private->fmt.p_palette) ); + if( p_private->fmt.p_palette ) + *p_private->fmt.p_palette = *p_fmt->p_palette; + } + p_private->p_picture = NULL; + + return p_private; +} +static void SpuRegionPrivateDestroy( subpicture_region_private_t *p_private ) +{ + if( p_private->p_picture ) + picture_Release( p_private->p_picture ); + free( p_private->fmt.p_palette ); + free( p_private ); +} + /* */ static void SpuRenderCreateAndLoadText( spu_t *p_spu ); static void SpuRenderCreateAndLoadScale( spu_t *p_spu ); @@ -215,19 +248,6 @@ void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach ) } } - -/* */ -static void RegionPictureRelease( picture_t *p_picture ) -{ - if( --p_picture->i_refcount > 0 ) - return; - - assert( p_picture->i_refcount == 0 ); - free( p_picture->p_q ); - free( p_picture->p_data_orig ); - free( p_picture->p_sys ); -} - /** * Create a subpicture region * @@ -250,26 +270,23 @@ subpicture_region_t *__spu_CreateRegion( vlc_object_t *p_this, p_region->fmt = *p_fmt; p_region->i_alpha = 0xff; p_region->p_next = NULL; - p_region->p_cache = NULL; + p_region->p_private = NULL; p_region->psz_text = NULL; p_region->p_style = NULL; + p_region->p_picture = NULL; if( p_fmt->i_chroma == VLC_FOURCC('T','E','X','T') ) return p_region; - vout_AllocatePicture( p_this, &p_region->picture, p_fmt->i_chroma, - p_fmt->i_width, p_fmt->i_height, p_fmt->i_aspect ); - - if( !p_region->picture.i_planes ) + p_region->p_picture = picture_New( p_fmt->i_chroma, p_fmt->i_width, p_fmt->i_height, + p_fmt->i_aspect ); + if( !p_region->p_picture ) { free( p_fmt->p_palette ); free( p_region ); return NULL; } - p_region->picture.i_refcount = 1; - p_region->picture.pf_release = RegionPictureRelease; - return p_region; } @@ -284,11 +301,13 @@ void __spu_DestroyRegion( vlc_object_t *p_this, subpicture_region_t *p_region ) if( !p_region ) return; - picture_Release( &p_region->picture ); + if( p_region->p_private ) + SpuRegionPrivateDestroy( p_region->p_private ); + + if( p_region->p_picture ) + picture_Release( p_region->p_picture ); free( p_region->fmt.p_palette ); - if( p_region->p_cache ) - __spu_DestroyRegion( p_this, p_region->p_cache ); free( p_region->psz_text ); free( p_region->psz_html ); @@ -902,6 +921,9 @@ static void SpuRenderRegion( spu_t *p_spu, int i_y_offset; filter_t *p_scale; + video_format_t *p_region_fmt; + picture_t *p_region_picture; + vlc_assert_locked( &p_spu->subpicture_lock ); /* Invalidate area by default */ @@ -958,6 +980,7 @@ static void SpuRenderRegion( spu_t *p_spu, i_x_offset = spu_scale_w( p_area->i_x, p_area->scale ); i_y_offset = spu_scale_h( p_area->i_y, p_area->scale ); + /* */ if( b_force_palette ) { /* It looks so wrong I won't comment @@ -968,12 +991,14 @@ static void SpuRenderRegion( spu_t *p_spu, memcpy( p_region->fmt.p_palette->palette, p_spu->palette, 4*sizeof(uint32_t) ); } - if( b_using_palette ) - p_scale = p_spu->p_scale_yuvp; - else - p_scale = p_spu->p_scale; + /* */ + p_region_fmt = &p_region->fmt; + p_region_picture = p_region->p_picture; + /* Scale from rendered size to destination size */ + p_scale = b_using_palette ? p_spu->p_scale_yuvp : p_spu->p_scale; + if( p_scale && ( scale_size.w != SCALE_UNIT || scale_size.h != SCALE_UNIT || b_force_palette ) ) { @@ -983,21 +1008,17 @@ static void SpuRenderRegion( spu_t *p_spu, /* TODO when b_using_palette is true, we should first convert it to YUVA to allow * a proper rescaling */ - /* Destroy if cache is unusable */ - if( p_region->p_cache ) + /* Destroy if cache is unusable + * FIXME do not always destroy the region it can sometimes be reused + * if same size and same palette if present */ + if( p_region->p_private ) { - if( p_region->p_cache->fmt.i_width != i_dst_width || - p_region->p_cache->fmt.i_height != i_dst_height || - b_force_palette ) - { - p_subpic->pf_destroy_region( VLC_OBJECT(p_spu), - p_region->p_cache ); - p_region->p_cache = NULL; - } + SpuRegionPrivateDestroy( p_region->p_private ); + p_region->p_private = NULL; } /* Scale if needed into cache */ - if( !p_region->p_cache ) + if( !p_region->p_private ) { picture_t *p_pic; @@ -1012,52 +1033,33 @@ static void SpuRenderRegion( spu_t *p_spu, p_scale->fmt_out.video.i_visible_height = spu_scale_h( p_region->fmt.i_visible_height, scale_size ); - p_region->p_cache = - p_subpic->pf_create_region( VLC_OBJECT(p_spu), - &p_scale->fmt_out.video ); + p_region->p_private = SpuRegionPrivateCreate( &p_scale->fmt_out.video ); - p_pic = NULL; if( p_scale->p_module ) { - picture_Yield( &p_region->picture ); - p_pic = p_scale->pf_video_filter( p_scale, &p_region->picture ); + picture_Yield( p_region->p_picture ); + p_region->p_private->p_picture = p_scale->pf_video_filter( p_scale, p_region->p_picture ); } - if( p_pic ) - { - picture_CopyPixels( &p_region->p_cache->picture, p_pic ); - picture_Release( p_pic ); - - if( p_region->p_cache->fmt.p_palette ) - *p_region->p_cache->fmt.p_palette = *p_region->fmt.p_palette; - - /* i_x/i_y of cached region should NOT be used. I set them to - * an invalid value to catch it (assert) */ - p_region->p_cache->i_x = INT_MAX; - p_region->p_cache->i_y = INT_MAX; - p_region->p_cache->i_align = p_region->i_align; - p_region->p_cache->i_alpha = p_region->i_alpha; - } - else + if( !p_region->p_private->p_picture ) { msg_Err( p_spu, "scaling failed (module not loaded)" ); - p_subpic->pf_destroy_region( VLC_OBJECT(p_spu), - p_region->p_cache ); - p_region->p_cache = NULL; + SpuRegionPrivateDestroy( p_region->p_private ); + p_region->p_private = NULL; } } /* And use the scaled picture */ - if( p_region->p_cache ) + if( p_region->p_private ) { - p_region = p_region->p_cache; - fmt_original = p_region->fmt; + p_region_fmt = &p_region->p_private->fmt; + p_region_picture = p_region->p_private->p_picture; } } /* Force cropping if requested */ if( b_force_crop ) { - video_format_t *p_fmt = &p_region->fmt; + video_format_t *p_fmt = p_region_fmt; int i_crop_x = spu_scale_w( p_spu->i_crop_x, scale_size ); int i_crop_y = spu_scale_h( p_spu->i_crop_y, scale_size ); int i_crop_width = spu_scale_w( p_spu->i_crop_width, scale_size ); @@ -1094,14 +1096,14 @@ static void SpuRenderRegion( spu_t *p_spu, } /* Update the blender */ - SpuRenderUpdateBlend( p_spu, p_fmt->i_width, p_fmt->i_height, &p_region->fmt ); + SpuRenderUpdateBlend( p_spu, p_fmt->i_width, p_fmt->i_height, p_region_fmt ); if( p_spu->p_blend->p_module ) { const int i_alpha = SpuRegionAlpha( p_subpic, p_region ); p_spu->p_blend->pf_video_blend( p_spu->p_blend, p_pic_dst, - &p_region->picture, i_x_offset, i_y_offset, i_alpha ); + p_region_picture, i_x_offset, i_y_offset, i_alpha ); } else { @@ -1118,8 +1120,13 @@ exit: * pre-rendered state, so the next time through everything is * calculated again. */ - p_region->picture.pf_release( &p_region->picture ); - memset( &p_region->picture, 0, sizeof( picture_t ) ); + picture_Release( p_region->p_picture ); + p_region->p_picture = NULL; + if( p_region->p_private ) + { + SpuRegionPrivateDestroy( p_region->p_private ); + p_region->p_private = NULL; + } p_region->i_align &= ~SUBPICTURE_RENDERED; } if( b_restore_format ) -- 2.39.2