Commit 28ed0fc9 authored by Gildas Bazin's avatar Gildas Bazin

* ALL: separation of the SPU engine from the VOUT.

* modules/stream_out/transcode.c: re-use the SPU engine.
* src/video_output/vout_subpictures.c: support for resizing subpictures.
parent e9097e4f
......@@ -108,6 +108,7 @@ HEADERS_include = \
include/vlc_meta.h \
include/vlc_objects.h \
include/vlc_playlist.h \
include/vlc_spu.h \
include/vlc_stream.h \
include/vlc_threads_funcs.h \
include/vlc_threads.h \
......
......@@ -126,22 +126,8 @@ struct vout_thread_t
/* Picture heap */
picture_t p_picture[2*VOUT_MAX_PICTURES+1]; /**< pictures */
/* Subpicture properties */
subpicture_t p_subpicture[VOUT_MAX_PICTURES]; /**< subpictures */
subpicture_t *p_default_channel; /**< subpicture in the default
channel */
int i_channel_count; /**< index of last subpicture
channel registered */
filter_t *p_blend; /**< alpha blending module */
filter_t *p_text; /**< text renderer module */
vlc_bool_t b_force_crop; /**< force cropping of subpicture */
int i_crop_x, i_crop_y, i_crop_width, i_crop_height; /**< cropping */
vlc_bool_t b_force_alpha; /**< force alpha palette of subpicture */
uint8_t pi_alpha[4]; /**< forced alpha palette */
/* Subpicture unit */
spu_t *p_spu;
/* Statistics */
count_t c_loops;
......@@ -260,27 +246,6 @@ enum output_query_e
VOUT_CLOSE
};
/**
* \addtogroup subpicture
* @{
*/
VLC_EXPORT( subpicture_t *, vout_CreateSubPicture, ( vout_thread_t *, int, int ) );
VLC_EXPORT( void, vout_DestroySubPicture, ( vout_thread_t *, subpicture_t * ) );
VLC_EXPORT( void, vout_DisplaySubPicture, ( vout_thread_t *, subpicture_t * ) );
VLC_EXPORT( int, vout_RegisterOSDChannel, ( vout_thread_t * ) );
VLC_EXPORT( void, vout_ClearOSDChannel, ( vout_thread_t *, int ) );
#define spu_CreateRegion(a,b) __spu_CreateRegion(VLC_OBJECT(a),b)
VLC_EXPORT( subpicture_region_t *,__spu_CreateRegion, ( vlc_object_t *, video_format_t * ) );
#define spu_DestroyRegion(a,b) __spu_DestroyRegion(VLC_OBJECT(a),b)
VLC_EXPORT( void, __spu_DestroyRegion, ( vlc_object_t *, subpicture_region_t * ) );
void vout_InitSPU( vout_thread_t * );
void vout_DestroySPU( vout_thread_t * );
void vout_AttachSPU( vout_thread_t *, vlc_object_t *, vlc_bool_t );
subpicture_t * vout_SortSubPictures ( vout_thread_t *, mtime_t );
void vout_RenderSubPictures( vout_thread_t *, picture_t *,
picture_t *, subpicture_t * );
/** @}*/
/**
* @}
*/
......@@ -2,7 +2,7 @@
* vout.h: video output header for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vout.h,v 1.3 2004/01/25 18:17:08 zorglub Exp $
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -36,6 +36,7 @@ extern "C" {
*****************************************************************************/
#include "vlc_video.h"
#include "video_output.h"
#include "vlc_spu.h"
# ifdef __cplusplus
}
......
......@@ -279,16 +279,18 @@ typedef struct aout_filter_t aout_filter_t;
/* Video */
typedef struct vout_thread_t vout_thread_t;
typedef struct vout_sys_t vout_sys_t;
typedef struct vout_synchro_t vout_synchro_t;
typedef struct chroma_sys_t chroma_sys_t;
typedef video_format_t video_frame_format_t;
typedef struct picture_t picture_t;
typedef struct picture_sys_t picture_sys_t;
typedef struct picture_heap_t picture_heap_t;
typedef struct spu_t spu_t;
typedef struct subpicture_t subpicture_t;
typedef struct subpicture_sys_t subpicture_sys_t;
typedef struct subpicture_region_t subpicture_region_t;
typedef struct vout_synchro_t vout_synchro_t;
typedef struct text_renderer_sys_t text_renderer_sys_t;
typedef struct text_style_t text_style_t;
/* Stream output */
......
......@@ -43,7 +43,7 @@ struct filter_t
/* Module properties */
module_t * p_module;
filter_sys_t * p_sys;
filter_sys_t * p_sys;
/* Input format */
es_format_t fmt_in;
......@@ -57,6 +57,8 @@ struct filter_t
picture_t *, picture_t *,
int, int );
subpicture_t * ( *pf_subpicture_filter ) ( filter_t * );
subpicture_t * ( *pf_render_string ) ( filter_t *, block_t * );
/*
......
......@@ -54,6 +54,8 @@
#define VLC_OBJECT_STREAM (-20)
#define VLC_OBJECT_OPENGL (-21)
#define VLC_OBJECT_FILTER (-22)
#define VLC_OBJECT_VOD (-23)
#define VLC_OBJECT_SPU (-24)
#define VLC_OBJECT_GENERIC (-666)
......
/*****************************************************************************
* vlc_spu.h : subpicture unit
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/**
* \defgroup spu Subpicture Unit
* This module describes the programming interface for the subpicture unit.
* It includes functions allowing to create/destroy an spu, create/destroy
* subpictures and render them.
* @{
*/
/**
* Subpicture unit descriptor
*/
struct spu_t
{
VLC_COMMON_MEMBERS
vlc_mutex_t subpicture_lock; /**< subpicture heap lock */
subpicture_t p_subpicture[VOUT_MAX_PICTURES]; /**< subpictures */
int i_channel; /**< number of subpicture channels registered */
filter_t *p_blend; /**< alpha blending module */
filter_t *p_text; /**< text renderer module */
filter_t *p_scale; /**< scaling module */
vlc_bool_t b_force_crop; /**< force cropping of subpicture */
int i_crop_x, i_crop_y, i_crop_width, i_crop_height; /**< cropping */
int i_margin; /**< force position of a subpicture */
vlc_bool_t b_force_alpha; /**< force alpha palette of subpicture */
uint8_t pi_alpha[4]; /**< forced alpha palette */
int ( *pf_control ) ( spu_t *, int, va_list );
};
static inline int spu_vaControl( spu_t *p_spu, int i_query, va_list args )
{
if( p_spu->pf_control )
return p_spu->pf_control( p_spu, i_query, args );
else
return VLC_EGENERIC;
}
static inline int spu_Control( spu_t *p_spu, int i_query, ... )
{
va_list args;
int i_result;
va_start( args, i_query );
i_result = spu_vaControl( p_spu, i_query, args );
va_end( args );
return i_result;
}
enum spu_query_e
{
SPU_CHANNEL_REGISTER, /* arg1= int * res= */
SPU_CHANNEL_CLEAR /* arg1= int res= */
};
/**
* \addtogroup subpicture
* @{
*/
#define spu_Init(a) __spu_Init(VLC_OBJECT(a))
VLC_EXPORT( spu_t *, __spu_Init, ( vlc_object_t * ) );
VLC_EXPORT( void, spu_Destroy, ( spu_t * ) );
void spu_Attach( spu_t *, vlc_object_t *, vlc_bool_t );
VLC_EXPORT( subpicture_t *, spu_CreateSubpicture, ( spu_t * ) );
VLC_EXPORT( void, spu_DestroySubpicture, ( spu_t *, subpicture_t * ) );
VLC_EXPORT( void, spu_DisplaySubpicture, ( spu_t *, subpicture_t * ) );
#define spu_CreateRegion(a,b) __spu_CreateRegion(VLC_OBJECT(a),b)
VLC_EXPORT( subpicture_region_t *,__spu_CreateRegion, ( vlc_object_t *, video_format_t * ) );
#define spu_DestroyRegion(a,b) __spu_DestroyRegion(VLC_OBJECT(a),b)
VLC_EXPORT( void, __spu_DestroyRegion, ( vlc_object_t *, subpicture_region_t * ) );
VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t ) );
VLC_EXPORT( void, spu_RenderSubpictures, ( spu_t *, video_format_t *, picture_t *, picture_t *, subpicture_t *, int, int ) );
/** @}*/
/**
* @}
*/
......@@ -210,8 +210,8 @@ struct subpicture_region_t
int i_y; /**< position of region */
subpicture_region_t *p_next; /**< next region in the list */
subpicture_region_t *p_cache; /**< modified version of this region */
/**@}*/
};
/**
......
......@@ -151,24 +151,11 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
/* Erase the anchor text description from the video output if it exists */
p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_vout != NULL && p_vout->p_subpicture != NULL )
if( p_vout )
{
subpicture_t *p_subpic;
int i_subpic;
for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
{
p_subpic = &p_vout->p_subpicture[i_subpic];
if( p_subpic != NULL &&
( p_subpic->i_status == RESERVED_SUBPICTURE
|| p_subpic->i_status == READY_SUBPICTURE ) )
{
vout_DestroySubPicture( p_vout, p_subpic );
}
}
spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );
vlc_object_release( p_vout );
}
if( p_vout ) vlc_object_release( p_vout );
var_DelCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
......
......@@ -49,26 +49,11 @@ void VCDSubClose( vlc_object_t *p_this )
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_EXT) , "");
if( !p_sys->b_packetizer )
if( !p_sys->b_packetizer && p_sys->p_vout )
{
/* FIXME check if it's ok to not lock vout */
if( p_sys->p_vout != NULL && p_sys->p_vout->p_subpicture != NULL )
{
subpicture_t * p_subpic;
int i_subpic;
for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
{
p_subpic = &p_sys->p_vout->p_subpicture[i_subpic];
if( p_subpic != NULL &&
( ( p_subpic->i_status == RESERVED_SUBPICTURE ) ||
( p_subpic->i_status == READY_SUBPICTURE ) ) )
{
vout_DestroySubPicture( p_sys->p_vout, p_subpic );
}
}
}
spu_Control( p_sys->p_vout->p_spu, SPU_CHANNEL_CLEAR,
p_sys->i_subpic_channel );
}
if( p_sys->p_block )
......
......@@ -158,8 +158,8 @@ Decode ( decoder_t *p_dec, block_t **pp_block )
{
if( p_last_vout != p_sys->p_vout )
{
p_sys->i_subpic_channel =
vout_RegisterOSDChannel( p_sys->p_vout );
spu_Control( p_sys->p_vout->p_spu, SPU_CHANNEL_REGISTER,
&p_sys->i_subpic_channel );
}
/* Parse and decode */
......
......@@ -292,12 +292,10 @@ E_(ParsePacket)( decoder_t *p_dec)
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_EXT) , "");
/* Allocate the subpicture internal data. */
p_spu = vout_CreateSubPicture( p_sys->p_vout, p_sys->i_subpic_channel,
MEMORY_SUBPICTURE );
if( p_spu == NULL )
{
return;
}
p_spu = spu_CreateSubpicture( p_sys->p_vout->p_spu );
if( p_spu == NULL ) return;
p_spu->i_channel = p_sys->i_subpic_channel;
/* In ParseImage we expand the run-length encoded color 0's; also
we expand pixels and remove the color palette. This should
......@@ -349,12 +347,12 @@ E_(ParsePacket)( decoder_t *p_dec)
if( ParseImage( p_dec, p_spu ) )
{
/* There was a parse error, delete the subpicture */
vout_DestroySubPicture( p_sys->p_vout, p_spu );
spu_DestroySubpicture( p_sys->p_vout->p_spu, p_spu );
return;
}
/* SPU is finished - we can ask the video output to display it */
vout_DisplaySubPicture( p_sys->p_vout, p_spu );
spu_DisplaySubpicture( p_sys->p_vout->p_spu, p_spu );
}
......
......@@ -156,8 +156,8 @@ Decode ( decoder_t *p_dec, block_t **pp_block )
{
if( p_last_vout != p_sys->p_vout )
{
p_sys->i_subpic_channel =
vout_RegisterOSDChannel( p_sys->p_vout );
spu_Control( p_sys->p_vout->p_spu, SPU_CHANNEL_REGISTER,
&p_sys->i_subpic_channel );
}
/* Parse and decode */
......
......@@ -165,12 +165,10 @@ E_(ParsePacket)( decoder_t *p_dec)
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_EXT) , "");
/* Allocate the subpicture internal data. */
p_spu = vout_CreateSubPicture( p_sys->p_vout, p_sys->i_subpic_channel,
MEMORY_SUBPICTURE );
if( p_spu == NULL )
{
return;
}
p_spu = spu_CreateSubpicture( p_sys->p_vout->p_spu );
if( p_spu == NULL ) return;
p_spu->i_channel = p_sys->i_subpic_channel;
/* In ParseImage we expand the run-length encoded color 0's; also
we expand pixels and remove the color palette. This should
......@@ -221,12 +219,12 @@ E_(ParsePacket)( decoder_t *p_dec)
if( ParseImage( p_dec, p_spu ) )
{
/* There was a parse error, delete the subpicture */
vout_DestroySubPicture( p_sys->p_vout, p_spu );
spu_DestroySubpicture( p_sys->p_vout->p_spu, p_spu );
return;
}
/* SPU is finished - we can ask the video output to display it */
vout_DisplaySubPicture( p_sys->p_vout, p_spu );
spu_DisplaySubpicture( p_sys->p_vout->p_spu, p_spu );
}
......
......@@ -228,8 +228,8 @@ static void Run( intf_thread_t *p_intf )
{
for( i = 0; i < CHANNELS_NUMBER; i++ )
{
p_intf->p_sys->p_channels[ i ] =
vout_RegisterOSDChannel( p_vout );
spu_Control( p_vout->p_spu, SPU_CHANNEL_REGISTER,
&p_intf->p_sys->p_channels[ i ] );
}
}
......@@ -734,10 +734,11 @@ static void ClearChannels( intf_thread_t *p_intf, vout_thread_t *p_vout )
if( p_vout )
{
vout_ClearOSDChannel( p_vout, DEFAULT_CHAN );
spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );
for( i = 0; i < CHANNELS_NUMBER; i++ )
{
vout_ClearOSDChannel( p_vout, p_intf->p_sys->p_channels[ i ] );
spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR,
p_intf->p_sys->p_channels[ i ] );
}
}
}
......@@ -222,8 +222,6 @@ static int transcode_spu_new ( sout_stream_t *, sout_stream_id_t * );
static void transcode_spu_close ( sout_stream_t *, sout_stream_id_t * );
static int transcode_spu_process( sout_stream_t *, sout_stream_id_t *,
block_t *, block_t ** );
static subpicture_t *transcode_spu_get( sout_stream_t *, sout_stream_id_t *,
mtime_t );
static int EncoderThread( struct sout_stream_sys_t * p_sys );
......@@ -283,10 +281,7 @@ struct sout_stream_sys_t
char *psz_senc;
vlc_bool_t b_soverlay;
sout_cfg_t *p_spu_cfg;
subpicture_t *pp_subpics[SUBPICTURE_RING_SIZE];
/* Filters */
filter_t *p_filter_blend;
spu_t *p_spu;
/* Sync */
vlc_bool_t b_audio_sync;
......@@ -310,7 +305,6 @@ static int Open( vlc_object_t *p_this )
sout_stream_t *p_stream = (sout_stream_t*)p_this;
sout_stream_sys_t *p_sys;
vlc_value_t val;
int i;
p_sys = vlc_object_create( p_this, sizeof( sout_stream_sys_t ) );
......@@ -458,9 +452,7 @@ static int Open( vlc_object_t *p_this )
var_Get( p_stream, SOUT_CFG_PREFIX "soverlay", &val );
p_sys->b_soverlay = val.b_bool;
p_sys->p_filter_blend = 0;
for( i = 0; i < SUBPICTURE_RING_SIZE; i++ ) p_sys->pp_subpics[i] = 0;
p_sys->p_spu = 0;
var_Get( p_stream, SOUT_CFG_PREFIX "audio-sync", &val );
p_sys->b_audio_sync = val.b_bool;
......@@ -481,7 +473,6 @@ static void Close( vlc_object_t * p_this )
{
sout_stream_t *p_stream = (sout_stream_t*)p_this;
sout_stream_sys_t *p_sys = p_stream->p_sys;
int i;
sout_StreamDelete( p_sys->p_out );
......@@ -527,24 +518,7 @@ static void Close( vlc_object_t * p_this )
}
if( p_sys->psz_senc ) free( p_sys->psz_senc );
if( p_sys->p_filter_blend )
{
if( p_sys->p_filter_blend->p_module )
module_Unneed( p_sys->p_filter_blend,
p_sys->p_filter_blend->p_module );
/* Clean-up pictures ring buffer */
for( i = 0; i < PICTURE_RING_SIZE; i++ )
{
if( p_sys->p_filter_blend->p_owner->pp_pics[i] )
video_del_buffer( VLC_OBJECT(p_sys->p_filter_blend),
p_sys->p_filter_blend->p_owner->pp_pics[i] );
}
free( p_sys->p_filter_blend->p_owner );
vlc_object_detach( p_sys->p_filter_blend );
vlc_object_destroy( p_sys->p_filter_blend );
}
if( p_sys->p_spu ) spu_Destroy( p_sys->p_spu );
vlc_object_destroy( p_sys );
}
......@@ -1553,104 +1527,42 @@ static int transcode_video_process( sout_stream_t *p_stream,
*/
/* Check if we have a subpicture to overlay */
if( p_sys->p_filter_blend )
if( p_sys->p_spu )
{
p_subpic = transcode_spu_get( p_stream, id, p_pic->date );
p_subpic = spu_SortSubpictures( p_sys->p_spu, p_pic->date );
/* TODO: get another pic */
}
/* Overlay subpicture */
if( p_subpic )
{
int i_width, i_height;
int i_scale_width, i_scale_height;
video_format_t *p_fmt;
p_sys->p_filter_blend->fmt_out = id->p_encoder->fmt_in;
p_sys->p_filter_blend->fmt_out.video.i_visible_width =
p_sys->p_filter_blend->fmt_out.video.i_width;
p_sys->p_filter_blend->fmt_out.video.i_visible_height =
p_sys->p_filter_blend->fmt_out.video.i_height;
p_sys->p_filter_blend->fmt_out.video.i_chroma =
VLC_FOURCC('I','4','2','0');
i_scale_width = id->p_encoder->fmt_in.video.i_width * 1000 /
id->p_decoder->fmt_out.video.i_width;
i_scale_height = id->p_encoder->fmt_in.video.i_height * 1000 /
id->p_decoder->fmt_out.video.i_height;
i_width = id->p_encoder->fmt_in.video.i_width;
i_height = id->p_encoder->fmt_in.video.i_height;
if( p_pic->i_refcount )
if( p_pic->i_refcount && !id->i_filter )
{
/* We can't modify the picture, we need to duplicate it */
picture_t *p_tmp =
video_new_buffer_filter( p_sys->p_filter_blend );
picture_t *p_tmp = video_new_buffer_decoder( id->p_decoder );
if( p_tmp )
{
int i, j;
for( i = 0; i < p_pic->i_planes; i++ )
{
for( j = 0; j < p_pic->p[i].i_visible_lines; j++ )
{
memcpy( p_tmp->p[i].p_pixels + j *
p_tmp->p[i].i_pitch,
p_pic->p[i].p_pixels + j *
p_pic->p[i].i_pitch,
p_tmp->p[i].i_visible_pitch );
}
}
p_tmp->date = p_pic->date;
p_tmp->b_force = p_pic->b_force;
p_tmp->i_nb_fields = p_pic->i_nb_fields;
p_tmp->b_progressive = p_pic->b_progressive;
p_tmp->b_top_field_first = p_pic->b_top_field_first;
vout_CopyPicture( p_stream, p_tmp, p_pic );
p_pic->pf_release( p_pic );
p_pic = p_tmp;
}
}
while( p_subpic != NULL )
{
subpicture_region_t *p_region = p_subpic->p_region;
while( p_region && p_sys->p_filter_blend &&
p_sys->p_filter_blend->pf_video_blend )
{
int i_x_offset = p_region->i_x + p_subpic->i_x;
int i_y_offset = p_region->i_y + p_subpic->i_y;
if( p_subpic->i_flags & OSD_ALIGN_BOTTOM )
{
i_y_offset = i_height - p_region->fmt.i_height -
p_subpic->i_y;
}
else if ( !(p_subpic->i_flags & OSD_ALIGN_TOP) )
{
i_y_offset = i_height / 2 - p_region->fmt.i_height / 2;
}
if( p_subpic->i_flags & OSD_ALIGN_RIGHT )
{
i_x_offset = i_width - p_region->fmt.i_width -
p_subpic->i_x;
}
else if ( !(p_subpic->i_flags & OSD_ALIGN_LEFT) )
{
i_x_offset = i_width / 2 - p_region->fmt.i_width / 2;
}
if( p_subpic->b_absolute )
{
i_x_offset = p_region->i_x + p_subpic->i_x;
i_y_offset = p_region->i_y + p_subpic->i_y;
}
p_sys->p_filter_blend->fmt_in.video = p_region->fmt;
p_sys->p_filter_blend->pf_video_blend(
p_sys->p_filter_blend, p_pic, p_pic,
&p_region->picture, i_x_offset, i_y_offset );
p_region = p_region->p_next;
}
if( id->i_filter )
p_fmt = &id->pp_filter[id->i_filter -1]->fmt_out.video;
else
p_fmt = &id->p_decoder->fmt_out.video;
p_subpic = p_subpic->p_next;
}
spu_RenderSubpictures( p_sys->p_spu, p_fmt, p_pic, p_pic, p_subpic,
i_scale_width, i_scale_height );
}
if( p_sys->i_threads >= 1 )
......@@ -1872,6 +1784,7 @@ static int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_t *id )
/* Initialization of decoder structures */
id->p_decoder->pf_spu_buffer_new = spu_new_buffer;
id->p_decoder->pf_spu_buffer_del = spu_del_buffer;
id->p_decoder->p_owner = (decoder_owner_sys_t *)p_stream;
//id->p_decoder->p_cfg = p_sys->p_spu_cfg;
id->p_decoder->p_module =
......@@ -1905,26 +1818,9 @@ static int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_t *id )
return VLC_EGENERIC;
}
}
else if( !p_sys->p_filter_blend )
else if( !p_sys->p_spu )
{
int i;
p_sys->p_filter_blend =
vlc_object_create( p_stream, VLC_OBJECT_FILTER );
vlc_object_attach( p_sys->p_filter_blend, p_stream );
p_sys->p_filter_blend->fmt_out.video.i_chroma =
VLC_FOURCC('I','4','2','0');
p_sys->p_filter_blend->fmt_in.video.i_chroma =
VLC_FOURCC('Y','U','V','A');
p_sys->p_filter_blend->pf_vout_buffer_new = video_new_buffer_filter;
p_sys->p_filter_blend->pf_vout_buffer_del = video_del_buffer_filter;
p_sys->p_filter_blend->p_owner = malloc( sizeof(filter_owner_sys_t) );
for( i = 0; i < PICTURE_RING_SIZE; i++ )
p_sys->p_filter_blend->p_owner->pp_pics[i] = 0;
p_sys->p_filter_blend->p_module =
module_Need( p_sys->p_filter_blend, "video blending", 0, 0 );
p_sys->p_spu = spu_Init( p_stream );
}
return VLC_SUCCESS;
......@@ -1932,9 +1828,6 @@ static int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_t *id )
static void transcode_spu_close( sout_stream_t *p_stream, sout_stream_id_t *id)
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
int i;
/* Close decoder */
if( id->p_decoder->p_module )
module_Unneed( id->p_decoder, id->p_decoder->p_module );
......@@ -1942,15 +1835,6 @@ static void transcode_spu_close( sout_stream_t *p_stream, sout_stream_id_t *id)
/* Close encoder */
if( id->p_encoder->p_module )
module_Unneed( id->p_encoder, id->p_encoder->p_module );
/* Free subpictures */
for( i = 0; i < SUBPICTURE_RING_SIZE; i++ )
{
if( !p_sys->pp_subpics[i] ) continue;
spu_del_buffer( id->p_decoder, p_sys->pp_subpics[i] );
p_sys->pp_subpics[i] = NULL;
}
}
static int transcode_spu_process( sout_stream_t *p_stream,
......@@ -1964,24 +1848,10 @@ static int transcode_spu_process( sout_stream_t *p_stream,
p_subpic = id->p_decoder->pf_decode_sub( id->p_decoder, &in );
if( p_subpic && p_sys->b_soverlay )
{
int i;
/* Find a free slot in our supictures ring buffer */
for( i = 0; i < SUBPICTURE_RING_SIZE; i++ )
{
if( !p_sys->pp_subpics[i] )
{
p_sys->pp_subpics[i] = p_subpic;
break;
}
}
if( i == SUBPICTURE_RING_SIZE )
{
spu_del_buffer( id->p_decoder, p_subpic );
}
spu_DisplaySubpicture( p_sys->p_spu, p_subpic );
}
if( p_subpic && !p_sys->b_soverlay )
if( p_subpic && !p_sys->b_soverlay )
{
block_t *p_block;
......@@ -1998,78 +1868,14 @@ static int transcode_spu_process( sout_stream_t *p_stream,
return VLC_EGENERIC;
}
static subpicture_t *transcode_spu_get( sout_stream_t *p_stream,
sout_stream_id_t *id,
mtime_t display_date )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
subpicture_t