Commit 09177fb3 authored by Jean-Paul Saman's avatar Jean-Paul Saman Committed by Jean-Paul Saman

Fix errors in transcoding.

- in Add() made osd transcoding selection part of else if
- copy region picture width/height to new region
- added some more debugging
- some cleanup

However not all bugs are gone. Need to figure out where they are.
parent be6ca153
......@@ -982,13 +982,16 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->p_encoder->fmt_out.video.i_frame_rate_base = 1001;
}
}
else if( p_fmt->i_cat == SPU_ES && (p_sys->i_scodec || p_sys->psz_senc) )
else if( p_fmt->i_cat == SPU_ES &&
(p_sys->i_scodec || p_sys->psz_senc) &&
!p_sys->b_soverlay )
{
msg_Dbg( p_stream, "creating subtitles transcoding from fcc=`%4.4s' "
"to fcc=`%4.4s'", (char*)&p_fmt->i_codec,
(char*)&p_sys->i_scodec );
/* Complete destination format */
//id->p_encoder->fmt_out.fmt.i_codec = VLC_FOURCC( 'Y', 'U', 'V', 'A' );
id->p_encoder->fmt_out.i_codec = p_sys->i_scodec;
/* build decoder -> filter -> encoder */
......@@ -1013,26 +1016,16 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
msg_Dbg( p_stream, "subtitles (fcc=`%4.4s') overlaying",
(char*)&p_fmt->i_codec );
id->b_transcode = VLC_TRUE;
/* Build decoder -> filter -> overlaying chain */
if( transcode_spu_new( p_stream, id ) )
{
msg_Err( p_stream, "cannot create subtitles chain" );
goto error;
}
}
else
{
msg_Dbg( p_stream, "not transcoding a stream (fcc=`%4.4s')",
(char*)&p_fmt->i_codec );
id->id = p_sys->p_out->pf_add( p_sys->p_out, p_fmt );
id->b_transcode = VLC_FALSE;
if( !id->id ) goto error;
id->b_transcode = VLC_TRUE;
}
if( p_sys->b_sout_osd )
else if( p_sys->b_sout_osd )
{
/* Create a fake OSD menu elementary stream */
if( !p_sys->b_es_osd && (p_sys->i_osdcodec != 0 || p_sys->psz_osdenc) )
......@@ -1045,6 +1038,16 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
p_sys->b_es_osd = VLC_TRUE;
}
}
else
{
msg_Dbg( p_stream, "not transcoding a stream (fcc=`%4.4s')",
(char*)&p_fmt->i_codec );
id->id = p_sys->p_out->pf_add( p_sys->p_out, p_fmt );
id->b_transcode = VLC_FALSE;
if( !id->id ) goto error;
}
return id;
error:
......@@ -1157,7 +1160,10 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
break;
}
if( p_out ) return p_sys->p_out->pf_send( p_sys->p_out, id->id, p_out );
if( p_out )
{
return p_sys->p_out->pf_send( p_sys->p_out, id->id, p_out );
}
return VLC_SUCCESS;
}
......@@ -2562,71 +2568,7 @@ static void video_unlink_picture_decoder( decoder_t *p_dec, picture_t *p_pic )
*/
static subpicture_t *spu_new_buffer( decoder_t * );
static void spu_del_buffer( decoder_t *, subpicture_t * );
#if 0
static filter_t *transcode_spu_filter_new( sout_stream_t *p_stream,
sout_stream_id_t *id,
es_format_t *p_fmt_in,
es_format_t *p_fmt_out )
{
int i;
sout_stream_sys_t *p_sys = p_stream->p_sys;
filter_t *p_filter = vlc_object_create( p_stream, VLC_OBJECT_FILTER );
vlc_object_attach( p_filter, p_stream );
p_filter->pf_vout_buffer_new = video_new_buffer_filter;
p_filter->pf_vout_buffer_del = video_del_buffer_filter;
p_filter->fmt_in = *p_fmt_in;
p_filter->fmt_out = *p_fmt_out;
p_filter->p_module = module_Need( p_filter, "video filter2", 0, 0 );
if( p_filter->p_module )
{
p_filter->p_owner = malloc( sizeof(filter_owner_sys_t) );
if( !p_filter->p_owner )
{
msg_Err( p_stream, "out of memory" );
module_Unneed( p_filter, p_filter->p_module );
vlc_object_detach( p_filter );
vlc_object_destroy( p_filter );
return NULL;
}
for( i = 0; i < PICTURE_RING_SIZE; i++ )
p_filter->p_owner->pp_pics[i] = NULL;
p_filter->p_owner->p_sys = p_sys;
*p_fmt_in = p_filter->fmt_out;
}
else
{
vlc_object_detach( p_filter );
vlc_object_destroy( p_filter );
p_filter = NULL;
}
return p_filter;
}
static void transcode_spu_filter_del( sout_stream_t *p_stream, filter_t *p_filter )
{
int j;
vlc_object_detach( p_filter );
if( p_filter->p_module )
module_Unneed( p_filter, p_filter->p_module );
/* Clean-up pictures ring buffer */
for( j = 0; j < PICTURE_RING_SIZE; j++ )
{
if( p_filter->p_owner->pp_pics[j] )
video_del_buffer( VLC_OBJECT(p_filter),
p_filter->p_owner->pp_pics[j] );
}
free( p_filter->p_owner );
vlc_object_destroy( p_filter );
p_filter = NULL;
}
#endif
static int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_t *id )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
......@@ -2660,10 +2602,6 @@ static int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_t *id )
es_format_Init( &id->p_encoder->fmt_in, SPU_ES,
id->p_decoder->fmt_in.i_codec );
id->p_encoder->fmt_out.i_id = 0xbd1;
id->p_encoder->fmt_out.i_group = 3;
id->p_encoder->fmt_out.psz_language = strdup( "unknown" );
id->p_encoder->p_cfg = p_sys->p_spu_cfg;
id->p_encoder->p_module =
......@@ -2716,16 +2654,12 @@ static int transcode_spu_process( sout_stream_t *p_stream,
}
/* Do we need a chroma conversion? */
if( ( id->p_decoder->fmt_out.video.i_chroma != VLC_FOURCC('Y','U','V','A') ) ||
( id->p_decoder->fmt_out.video.i_chroma != VLC_FOURCC('Y','U','V','P') ) )
if( id->p_decoder->fmt_out.video.i_chroma == VLC_FOURCC('R','G','B','A') )
{
subpicture_region_t *p_region = p_subpic->p_region;
subpicture_region_t *p_list = NULL, *p_tail = NULL, *p_old = p_region;
if( id->p_decoder->fmt_out.video.i_chroma == VLC_FOURCC('R','G','B','A') )
id->p_encoder->fmt_in.video.i_chroma = VLC_FOURCC('Y','U','V','A');
else
id->p_encoder->fmt_in.video.i_chroma = VLC_FOURCC('Y','U','V','P');
id->p_encoder->fmt_in.video.i_chroma = VLC_FOURCC('Y','U','V','A');
memcpy( &id->p_decoder->fmt_out, &p_region->fmt, sizeof(video_format_t) );
id->p_encoder->fmt_in.video.i_aspect = VOUT_ASPECT_FACTOR;
......@@ -2751,6 +2685,7 @@ static int transcode_spu_process( sout_stream_t *p_stream,
while( p_region && p_sys->p_spu->p_blend &&
p_sys->p_spu->p_blend->pf_video_blend )
{
subpicture_region_t *p_tmp = NULL;
subpicture_region_t *p_new = NULL;
video_format_t fmt;
......@@ -2758,9 +2693,12 @@ static int transcode_spu_process( sout_stream_t *p_stream,
memset( &fmt, 0, sizeof(video_format_t) );
fmt.i_chroma = VLC_FOURCC('Y','U','V','A');
fmt.i_aspect = VOUT_ASPECT_FACTOR;
fmt.i_sar_num = fmt.i_sar_den = 1;
fmt.i_width = fmt.i_visible_width = p_region->fmt.i_visible_width;
fmt.i_height = fmt.i_visible_height = p_region->fmt.i_visible_height;
fmt.i_sar_num = p_region->fmt.i_sar_num;
fmt.i_sar_den = p_region->fmt.i_sar_den;
fmt.i_width = p_region->fmt.i_width;
fmt.i_height = p_region->fmt.i_height;
fmt.i_visible_width = p_region->fmt.i_visible_width;
fmt.i_visible_height = p_region->fmt.i_visible_height;
fmt.i_bits_per_pixel = p_region->fmt.i_bits_per_pixel;
fmt.i_y_offset = p_region->fmt.i_y_offset;
fmt.i_x_offset = p_region->fmt.i_x_offset;
......@@ -2771,18 +2709,18 @@ static int transcode_spu_process( sout_stream_t *p_stream,
msg_Err( p_stream, "out of memory" );
break;
}
p_new->i_x = 0;
p_new->i_y = 0;
p_new->i_x = p_region->i_x;
p_new->i_y = p_region->i_y;
p_new->i_align = SUBPICTURE_ALIGN_TOP;
/* Force palette if requested */
if( p_sys->p_spu->b_force_palette &&
(VLC_FOURCC('Y','U','V','P') == p_region->fmt.i_chroma) )
(VLC_FOURCC('Y','U','V','P') == p_new->fmt.i_chroma) )
{
memcpy( p_region->fmt.p_palette->palette,
memcpy( p_new->fmt.p_palette->palette,
p_sys->p_spu->palette, 16 );
}
p_sys->p_spu->p_blend->fmt_in.video = p_region->fmt;
p_sys->p_spu->p_blend->fmt_in.video = p_new->fmt;
/* Update the output picture size */
p_sys->p_spu->p_blend->fmt_out.video.i_width =
......@@ -2794,7 +2732,13 @@ static int transcode_spu_process( sout_stream_t *p_stream,
p_sys->p_spu->p_blend->pf_video_blend( p_sys->p_spu->p_blend,
&p_new->picture, &p_new->picture, &p_region->picture,
p_subpic->i_x, p_subpic->i_y, 0 );
p_region->i_x, p_region->i_y, 0 );
msg_Dbg( p_stream, "Y (%d,%d,0x%p), U (%d,%d,0x%p), V (%d,%d,0x%p), A (%d,%d,0x%p)",
p_new->picture.p[Y_PLANE].i_lines,p_new->picture.p[Y_PLANE].i_pitch,p_new->picture.p[Y_PLANE].p_pixels,
p_new->picture.p[U_PLANE].i_lines,p_new->picture.p[U_PLANE].i_pitch,p_new->picture.p[U_PLANE].p_pixels,
p_new->picture.p[V_PLANE].i_lines,p_new->picture.p[V_PLANE].i_pitch,p_new->picture.p[V_PLANE].p_pixels,
p_new->picture.p[A_PLANE].i_lines,p_new->picture.p[A_PLANE].i_pitch,p_new->picture.p[A_PLANE].p_pixels );
if( !p_list )
{
......@@ -2806,12 +2750,13 @@ static int transcode_spu_process( sout_stream_t *p_stream,
p_tail->p_next = p_new;
p_tail = p_new;
}
p_region = p_region->p_next;
p_tmp = p_region->p_next;
p_region = p_tmp;
}
if( p_list )
{
p_subpic->pf_destroy_region( VLC_OBJECT(id->p_decoder), p_old );
p_subpic->p_region = p_list;
p_subpic->pf_destroy_region( VLC_OBJECT(id->p_decoder), p_old );
}
}
......@@ -2822,27 +2767,16 @@ static int transcode_spu_process( sout_stream_t *p_stream,
else
{
block_t *p_block = NULL;
#if 1
p_block = id->p_encoder->pf_encode_sub( id->p_encoder, p_subpic );
msg_Dbg( p_stream, ">>>>>> time start "I64Fd" stop "I64Fd, p_subpic->i_start, p_subpic->i_stop );
// p_block->i_dts = p_block->i_pts = p_subpic->i_start;
spu_del_buffer( id->p_decoder, p_subpic );
if( p_block )
{
block_ChainAppend( out, p_block );
return VLC_SUCCESS;
}
#else
if( p_block )
{
p_block->i_dts = p_block->i_pts = p_subpic->i_start;
block_ChainAppend( out, p_block );
if( *out )
{
if( p_sys->p_out->pf_send( p_sys->p_out, id, *out ) == VLC_SUCCESS )
spu_del_buffer( id->p_decoder, p_subpic );
}
return VLC_SUCCESS;
}
#endif
}
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