Commit 2c9f14c5 authored by Gildas Bazin's avatar Gildas Bazin

* modules/mux/mpeg/ts.c: reworked muxing of subtitles ES.

* modules/stream_out/transcode.c: support for subtitles transcoding.
* modules/codec/dvbsub.c: DVB subtitles encoder (developed for Anevia, www.anevia.com).
  + only works on YUVP subpictures for now.
  + not completely spec compliant yet.
parent c57912c9
This diff is collapsed.
......@@ -910,9 +910,7 @@ static int Mux( sout_mux_t *p_mux )
{
sout_input_t *p_input = p_mux->pp_inputs[i];
ts_stream_t *p_stream = (ts_stream_t*)p_input->p_sys;
int64_t i_spu_length = 0;
int64_t i_spu_dts = 0;
int64_t i_spu_delay = 0;
if( ( p_stream == p_pcr_stream &&
p_stream->i_pes_length < i_shaping_delay ) ||
......@@ -933,19 +931,25 @@ static int Mux( sout_mux_t *p_mux )
/* spu, only one packet is needed */
continue;
}
else
{
/* Don't mux the SPU yet if it is too early */
block_t *p_spu = block_FifoShow( p_input->p_fifo );
i_spu_delay =
p_spu->i_dts - p_pcr_stream->i_pes_dts;
if( i_spu_delay > 100000 &&
i_spu_delay < I64C(100000000) ) continue;
}
}
b_ok = VLC_FALSE;
p_data = block_FifoGet( p_input->p_fifo );
if( p_input->p_fmt->i_codec == VLC_FOURCC('s','u','b','t'))
{
i_spu_length = p_data->i_length;/* save info for SPU */
i_spu_dts = p_data->i_dts;
}
if( p_input->p_fifo->i_depth > 0 )
if( p_input->p_fifo->i_depth > 0 &&
p_input->p_fmt->i_cat != SPU_ES )
{
block_t *p_next = block_FifoShow( p_input->p_fifo );
p_data->i_length = p_next->i_dts - p_data->i_dts;
}
......@@ -970,19 +974,19 @@ static int Mux( sout_mux_t *p_mux )
p_stream->i_pes_used = 0;
p_stream->i_pes_length = 0;
BufferChainClean( p_mux->p_sout,
&p_pcr_stream->chain_pes );
p_pcr_stream->i_pes_dts = 0;
p_pcr_stream->i_pes_used = 0;
p_pcr_stream->i_pes_length = 0;
if( p_input->p_fmt->i_cat != SPU_ES )
{
BufferChainClean( p_mux->p_sout,
&p_pcr_stream->chain_pes );
p_pcr_stream->i_pes_dts = 0;
p_pcr_stream->i_pes_used = 0;
p_pcr_stream->i_pes_length = 0;
}
}
else
{
if( p_input->p_fmt->i_cat == SPU_ES )
{
/* Arbitrary */
p_data->i_length = 1000;
if( p_input->p_fmt->i_codec ==
VLC_FOURCC('s','u','b','t') )
{
......@@ -999,7 +1003,29 @@ static int Mux( sout_mux_t *p_mux )
p_data->p_buffer[p_data->i_buffer -1] ==
'\0' )
p_data->i_buffer--;
/* Append a empty sub (sub text only) */
if( p_data->i_length > 0 &&
!( p_data->i_buffer == 1 &&
*p_data->p_buffer == ' ' ) )
{
block_t *p_spu = block_New( p_mux, 3 );
p_spu->i_dts = p_spu->i_pts =
p_data->i_dts + p_data->i_length;
p_spu->i_length = 1000;
p_spu->p_buffer[0] = 0;
p_spu->p_buffer[1] = 1;
p_spu->p_buffer[2] = ' ';
E_(EStoPES)( p_mux->p_sout, &p_spu, p_spu,
p_stream->i_stream_id, 1 );
p_data->p_next = p_spu;
}
}
p_data->i_length = i_spu_delay;
}
else if( p_data->i_length < 0 ||
p_data->i_length > 2000000 )
......@@ -1035,25 +1061,6 @@ static int Mux( sout_mux_t *p_mux )
i_shaping_delay = p_stream->i_pes_length;
p_stream->b_key_frame = 1;
}
/* Append a empty sub (sub text only) */
if( i_spu_length > 0 )
{
block_t *p_spu = block_New( p_mux, 3 );
p_spu->i_dts = p_spu->i_pts = i_spu_dts +
i_spu_length;
p_spu->i_length = 1000;
p_spu->p_buffer[0] = 0;
p_spu->p_buffer[1] = 1;
p_spu->p_buffer[2] = ' ';
p_stream->i_pes_length += p_spu->i_length;
E_( EStoPES )( p_mux->p_sout, &p_spu, p_spu,
p_stream->i_stream_id, 1 );
BufferChainAppend( &p_stream->chain_pes, p_spu );
}
}
}
}
......
......@@ -657,8 +657,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->f_dst.i_group = id->f_src.i_group;
if( id->f_src.psz_language )
id->f_dst.psz_language = strdup( id->f_src.psz_language );
id->f_dst.i_extra = 0;
id->f_dst.p_extra = NULL;
id->f_dst.i_extra = 0;
id->f_dst.p_extra = NULL;
/* build decoder -> filter -> encoder */
if( transcode_spu_new( p_stream, id ) )
......@@ -2188,6 +2188,11 @@ static int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_t *id )
msg_Err( p_stream, "cannot find encoder" );
return VLC_EGENERIC;
}
id->f_dst.i_extra = id->p_encoder->fmt_out.i_extra;
id->f_dst.p_extra = id->p_encoder->fmt_out.p_extra;
id->f_dst.i_codec = id->p_encoder->fmt_out.i_codec;
id->f_dst.subs = id->p_encoder->fmt_out.subs;
}
else
{
......@@ -2241,6 +2246,7 @@ static int transcode_spu_process( sout_stream_t *p_stream,
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
subpicture_t *p_subpic;
*out = NULL;
p_subpic = id->p_decoder->pf_decode_sub( id->p_decoder, &in );
if( p_subpic && p_sys->b_soverlay )
......@@ -2262,12 +2268,18 @@ static int transcode_spu_process( sout_stream_t *p_stream,
}
}
if( !p_sys->b_soverlay && p_subpic )
if( p_subpic && !p_sys->b_soverlay )
{
block_t *p_block;
p_block = id->p_encoder->pf_encode_sub( id->p_encoder, p_subpic );
if( p_block ) block_ChainAppend( out, p_block );
return VLC_SUCCESS;
spu_del_buffer( id->p_decoder, p_subpic );
if( p_block )
{
block_ChainAppend( out, p_block );
return VLC_SUCCESS;
}
}
return VLC_EGENERIC;
......
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