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

Removed spu_Create/DestroySubpicture in favor of subpicture_*.

parent 90554602
......@@ -99,11 +99,19 @@ VLC_EXPORT( int, spu_Init, ( spu_t * ) );
VLC_EXPORT( void, spu_Destroy, ( spu_t * ) );
void spu_Attach( spu_t *, vlc_object_t *, bool );
VLC_EXPORT( subpicture_t *, spu_CreateSubpicture, ( spu_t * ) );
/* XXX you cannot call spu_DestroySubpicture on a displayed picture */
VLC_EXPORT( void, spu_DestroySubpicture, ( spu_t *, subpicture_t * ) );
/**
* This function sends a subpicture to the spu_t core.
*
* You cannot use the provided subpicture anymore. The spu_t core
* will destroy it at its convenience.
*/
VLC_EXPORT( void, spu_DisplaySubpicture, ( spu_t *, subpicture_t * ) );
/**
* This function asks the spu_t core a list of subpictures to display.
*
* The returned list can only be used by spu_RenderSubpictures.
*/
VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t display_date, bool b_paused, bool b_subtitle_only ) );
/**
......
......@@ -322,14 +322,23 @@ struct subpicture_region_t
subpicture_region_private_t *p_private; /**< Private data for spu_t *only* */
};
/* Subpicture region position flags */
#define SUBPICTURE_ALIGN_LEFT 0x1
#define SUBPICTURE_ALIGN_RIGHT 0x2
#define SUBPICTURE_ALIGN_TOP 0x4
#define SUBPICTURE_ALIGN_BOTTOM 0x8
#define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
/**
* This function will create a new subpicture.
* You can must use subpicture_region_Delete to destroy it.
* This function will create a new subpicture region.
*
* You must use subpicture_region_Delete to destroy it.
*/
VLC_EXPORT( subpicture_region_t *, subpicture_region_New, ( const video_format_t *p_fmt ) );
/**
* This function will destroy a subpicture allocated by
* This function will destroy a subpicture region allocated by
* subpicture_region_New.
*
* You may give it NULL.
......@@ -337,7 +346,7 @@ VLC_EXPORT( subpicture_region_t *, subpicture_region_New, ( const video_format_t
VLC_EXPORT( void, subpicture_region_Delete, ( subpicture_region_t *p_region ) );
/**
* This function will destroy a list of subpicture allocated by
* This function will destroy a list of subpicture regions allocated by
* subpicture_region_New.
*
* Provided for convenience.
......@@ -404,17 +413,23 @@ struct subpicture_t
subpicture_sys_t *p_sys; /* subpicture data */
};
/**
* This function create a new empty subpicture.
*
* You must use subpicture_Delete to destroy it.
*/
VLC_EXPORT( subpicture_t *, subpicture_New, ( void ) );
/**
* This function delete a subpicture created by subpicture_New.
* You may give it NULL.
*/
VLC_EXPORT( void, subpicture_Delete, ( subpicture_t *p_subpic ) );
/* Default subpicture channel ID */
#define DEFAULT_CHAN 1
/* Subpicture position flags */
#define SUBPICTURE_ALIGN_LEFT 0x1
#define SUBPICTURE_ALIGN_RIGHT 0x2
#define SUBPICTURE_ALIGN_TOP 0x4
#define SUBPICTURE_ALIGN_BOTTOM 0x8
#define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
/*****************************************************************************
* Prototypes
*****************************************************************************/
......
......@@ -2419,14 +2419,14 @@ static int transcode_spu_process( sout_stream_t *p_stream,
static subpicture_t *spu_new_buffer( decoder_t *p_dec )
{
sout_stream_t *p_stream = (sout_stream_t *)p_dec->p_owner;
return spu_CreateSubpicture( p_stream->p_sys->p_spu );
VLC_UNUSED( p_dec );
return subpicture_New();
}
static void spu_del_buffer( decoder_t *p_dec, subpicture_t *p_subpic )
{
sout_stream_t *p_stream = (sout_stream_t *)p_dec->p_owner;
spu_DestroySubpicture( p_stream->p_sys->p_spu, p_subpic );
VLC_UNUSED( p_dec );
subpicture_Delete( p_subpic );
}
/*
......@@ -2542,7 +2542,7 @@ static int transcode_osd_process( sout_stream_t *p_stream,
}
p_block = id->p_encoder->pf_encode_sub( id->p_encoder, p_subpic );
spu_DestroySubpicture( p_sys->p_spu, p_subpic );
subpicture_Delete( p_subpic );
if( p_block )
{
p_block->i_dts = p_block->i_pts = in->i_dts;
......
......@@ -1085,7 +1085,7 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
if( p_spu->i_start < p_dec->p_owner->i_preroll_end &&
( p_spu->i_stop <= 0 || p_spu->i_stop < p_dec->p_owner->i_preroll_end ) )
{
spu_DestroySubpicture( p_vout->p_spu, p_spu );
subpicture_Delete( p_spu );
}
else
spu_DisplaySubpicture( p_vout->p_spu, p_spu );
......@@ -1460,7 +1460,7 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec )
p_sys->p_spu_vout = p_vout;
}
p_subpic = spu_CreateSubpicture( p_vout->p_spu );
p_subpic = subpicture_New();
if( p_subpic )
{
p_subpic->i_channel = p_sys->i_spu_channel;
......@@ -1487,7 +1487,7 @@ static void spu_del_buffer( decoder_t *p_dec, subpicture_t *p_subpic )
return;
}
spu_DestroySubpicture( p_vout->p_spu, p_subpic );
subpicture_Delete( p_subpic );
vlc_object_release( p_vout );
}
......
......@@ -339,9 +339,7 @@ sout_StreamDelete
sout_StreamNew
sout_UpdateStatistic
__spu_Create
spu_CreateSubpicture
spu_Destroy
spu_DestroySubpicture
spu_DisplaySubpicture
spu_Init
spu_RenderSubpictures
......@@ -375,6 +373,9 @@ stream_vaControl
__str_format
__str_format_meta
str_format_time
subpicture_Delete
subpicture_New
subpicture_region_New
subpicture_region_ChainDelete
subpicture_region_Delete
subpicture_region_New
......
......@@ -78,7 +78,7 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
if( !psz_string ) return VLC_EGENERIC;
p_spu = spu_CreateSubpicture( p_spu_channel );
p_spu = subpicture_New();
if( !p_spu )
return VLC_EGENERIC;
......@@ -98,7 +98,7 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
if( !p_spu->p_region )
{
msg_Err( p_spu_channel, "cannot allocate SPU region" );
spu_DestroySubpicture( p_spu_channel, p_spu );
subpicture_Delete( p_spu );
return VLC_EGENERIC;
}
......
......@@ -196,8 +196,10 @@ subpicture_t *osd_CreateWidget( spu_t *p_spu, int i_channel )
subpicture_t *p_subpic;
mtime_t i_now = mdate();
VLC_UNUSED(p_spu);
/* Create and initialize a subpicture */
p_subpic = spu_CreateSubpicture( p_spu );
p_subpic = subpicture_New();
if( p_subpic == NULL ) return NULL;
p_subpic->i_channel = i_channel;
......
......@@ -80,7 +80,7 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
if( !psz_string ) return VLC_EGENERIC;
p_spu = spu_CreateSubpicture( p_vout->p_spu );
p_spu = subpicture_New();
if( !p_spu )
return VLC_EGENERIC;
......@@ -102,7 +102,7 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
if( !p_spu->p_region )
{
msg_Err( p_vout, "cannot allocate SPU region" );
spu_DestroySubpicture( p_vout->p_spu, p_spu );
subpicture_Delete( p_spu );
return VLC_EGENERIC;
}
......
......@@ -457,7 +457,7 @@ static int VoutSnapshotPip( vout_thread_t *p_vout, image_handler_t *p_image, pic
if( !p_pip )
return VLC_EGENERIC;
p_subpic = spu_CreateSubpicture( p_vout->p_spu );
p_subpic = subpicture_New();
if( p_subpic == NULL )
{
picture_Release( p_pip );
......
......@@ -48,11 +48,6 @@
#define VLC_FOURCC_RGBA VLC_FOURCC('R','G','B','A')
#define VLC_FOURCC_TEXT VLC_FOURCC('T','E','X','T')
/* TODO export */
static subpicture_t *subpicture_New( void );
static void subpicture_Delete( subpicture_t *p_subpic );
static void SubpictureChain( subpicture_t **pp_head, subpicture_t *p_subpic );
/* */
typedef struct
{
......@@ -142,6 +137,7 @@ static bool spu_area_overlap( spu_area_t, spu_area_t );
#define SCALE_UNIT (1000)
static void SubpictureChain( subpicture_t **pp_head, subpicture_t *p_subpic );
static int SubpictureCmp( const void *s0, const void *s1 );
static void SpuRenderRegion( spu_t *,
......@@ -355,38 +351,6 @@ void spu_DisplaySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
vlc_mutex_unlock( &p_sys->lock );
}
/**
* Allocate a subpicture in the spu heap.
*
* This function create a reserved subpicture in the spu heap.
* A null pointer is returned if the function fails. This method provides an
* already allocated zone of memory in the spu data fields. It needs locking
* since several pictures can be created by several producers threads.
* \param p_spu the subpicture unit in which to create the subpicture
* \return NULL on error, a reserved subpicture otherwise
*/
subpicture_t *spu_CreateSubpicture( spu_t *p_spu )
{
VLC_UNUSED(p_spu);
return subpicture_New();
}
/**
* Remove a subpicture from the heap
*
* This function frees a previously reserved subpicture.
* It is meant to be used when the construction of a picture aborted.
* This function does not need locking since reserved subpictures are ignored
* by the spu.
*/
void spu_DestroySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
{
VLC_UNUSED(p_spu);
subpicture_Delete( p_subpic );
}
/**
* This function renders all sub picture units in the list.
*/
......@@ -671,10 +635,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date,
/*****************************************************************************
* subpicture_t allocation
*****************************************************************************/
/**
* This function create a new empty subpicture.
*/
static subpicture_t *subpicture_New( void )
subpicture_t *subpicture_New( void )
{
subpicture_t *p_subpic = calloc( 1, sizeof(*p_subpic) );
if( !p_subpic )
......@@ -693,7 +654,7 @@ static subpicture_t *subpicture_New( void )
return p_subpic;
}
static void subpicture_Delete( subpicture_t *p_subpic )
void subpicture_Delete( subpicture_t *p_subpic )
{
subpicture_region_ChainDelete( p_subpic->p_region );
p_subpic->p_region = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment