Commit 338f5aa9 authored by Gildas Bazin's avatar Gildas Bazin

* modules/stream_out/transcode.c: backport of 11327.

parent 09f5cc1a
...@@ -322,10 +322,12 @@ struct sout_stream_sys_t ...@@ -322,10 +322,12 @@ struct sout_stream_sys_t
struct decoder_owner_sys_t struct decoder_owner_sys_t
{ {
picture_t *pp_pics[PICTURE_RING_SIZE]; picture_t *pp_pics[PICTURE_RING_SIZE];
sout_stream_sys_t *p_sys;
}; };
struct filter_owner_sys_t struct filter_owner_sys_t
{ {
picture_t *pp_pics[PICTURE_RING_SIZE]; picture_t *pp_pics[PICTURE_RING_SIZE];
sout_stream_sys_t *p_sys;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -1281,6 +1283,7 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -1281,6 +1283,7 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_t *id )
id->p_decoder->p_owner = malloc( sizeof(decoder_owner_sys_t) ); id->p_decoder->p_owner = malloc( sizeof(decoder_owner_sys_t) );
for( i = 0; i < PICTURE_RING_SIZE; i++ ) for( i = 0; i < PICTURE_RING_SIZE; i++ )
id->p_decoder->p_owner->pp_pics[i] = 0; id->p_decoder->p_owner->pp_pics[i] = 0;
id->p_decoder->p_owner->p_sys = p_sys;
//id->p_decoder->p_cfg = p_sys->p_video_cfg; //id->p_decoder->p_cfg = p_sys->p_video_cfg;
id->p_decoder->p_module = id->p_decoder->p_module =
...@@ -1624,6 +1627,7 @@ static int transcode_video_process( sout_stream_t *p_stream, ...@@ -1624,6 +1627,7 @@ static int transcode_video_process( sout_stream_t *p_stream,
malloc( sizeof(filter_owner_sys_t) ); malloc( sizeof(filter_owner_sys_t) );
for( i = 0; i < PICTURE_RING_SIZE; i++ ) for( i = 0; i < PICTURE_RING_SIZE; i++ )
id->pp_filter[id->i_filter]->p_owner->pp_pics[i] = 0; id->pp_filter[id->i_filter]->p_owner->pp_pics[i] = 0;
id->pp_filter[id->i_filter]->p_owner->p_sys = p_sys;
id->i_filter++; id->i_filter++;
} }
...@@ -1666,6 +1670,7 @@ static int transcode_video_process( sout_stream_t *p_stream, ...@@ -1666,6 +1670,7 @@ static int transcode_video_process( sout_stream_t *p_stream,
malloc( sizeof(filter_owner_sys_t) ); malloc( sizeof(filter_owner_sys_t) );
for( i = 0; i < PICTURE_RING_SIZE; i++ ) for( i = 0; i < PICTURE_RING_SIZE; i++ )
id->pp_filter[id->i_filter]->p_owner->pp_pics[i] = 0; id->pp_filter[id->i_filter]->p_owner->pp_pics[i] = 0;
id->pp_filter[id->i_filter]->p_owner->p_sys = p_sys;
id->i_filter++; id->i_filter++;
} }
...@@ -1866,6 +1871,33 @@ static picture_t *video_new_buffer( vlc_object_t *p_this, picture_t **pp_ring ) ...@@ -1866,6 +1871,33 @@ static picture_t *video_new_buffer( vlc_object_t *p_this, picture_t **pp_ring )
if( pp_ring[i] == 0 ) break; if( pp_ring[i] == 0 ) break;
} }
if( i == PICTURE_RING_SIZE && p_dec->p_owner->p_sys->i_threads >= 1 )
{
int i_first_pic = p_dec->p_owner->p_sys->i_first_pic;
if( p_dec->p_owner->p_sys->i_first_pic !=
p_dec->p_owner->p_sys->i_last_pic )
{
/* Encoder still has stuff to encode, wait to clear-up the list */
while( p_dec->p_owner->p_sys->i_first_pic == i_first_pic )
msleep( 100000 );
}
/* Find an empty space in the picture ring buffer */
for( i = 0; i < PICTURE_RING_SIZE; i++ )
{
if( pp_ring[i] != 0 && pp_ring[i]->i_status == DESTROYED_PICTURE )
{
pp_ring[i]->i_status = RESERVED_PICTURE;
return pp_ring[i];
}
}
for( i = 0; i < PICTURE_RING_SIZE; i++ )
{
if( pp_ring[i] == 0 ) break;
}
}
if( i == PICTURE_RING_SIZE ) if( i == PICTURE_RING_SIZE )
{ {
msg_Err( p_this, "decoder/filter is leaking pictures, " msg_Err( p_this, "decoder/filter is leaking pictures, "
......
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