[vlc-commits] [Git][videolan/vlc][master] 5 commits: mux/dummy: remove use of FifoGet/FifoCount
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Thu Jul 6 22:47:56 UTC 2023
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
fb452233 by Ilkka Ollakka at 2023-07-06T22:02:17+00:00
mux/dummy: remove use of FifoGet/FifoCount
Just take whole queue and handle them all without counter
- - - - -
f55108c2 by Ilkka Ollakka at 2023-07-06T22:02:17+00:00
mux/ogg: remove use of FifoGet/FifoCount
Rework MuxBlock to take block_t * in instead of checking one from fifo, allows handling one block or whole queue
- - - - -
0c379bd7 by Ilkka Ollakka at 2023-07-06T22:02:17+00:00
mux/avi: remove use of FifoGet/FifoCount
Just take whole queue and handle them all without counter or locking per block
- - - - -
ad08ac23 by Ilkka Ollakka at 2023-07-06T22:02:17+00:00
mux/mp4: reduce use of FifoGet/FifoCount
Rework MuxStream to take in block_t instead of getting it itself from fifo
we can't handle whole fifo in Mux, as it checks smallest timestamp to mux for each packet
- - - - -
28d1b426 by Ilkka Ollakka at 2023-07-06T22:02:17+00:00
stream_output: no need to check FifoCount on calling pf_mux
muxers check anyway if there are stuff in queue
- - - - -
5 changed files:
- modules/mux/avi.c
- modules/mux/dummy.c
- modules/mux/mp4/mp4.c
- modules/mux/ogg.c
- src/stream_output/stream_output.c
Changes:
=====================================
modules/mux/avi.c
=====================================
@@ -521,7 +521,6 @@ static int Mux ( sout_mux_t *p_mux )
for( i = 0; i < p_mux->i_nb_inputs; i++ )
{
- int i_count;
block_fifo_t *p_fifo;
if (!p_mux->pp_inputs[i]->p_sys)
@@ -531,23 +530,25 @@ static int Mux ( sout_mux_t *p_mux )
p_stream = &p_sys->stream[i_stream];
p_fifo = p_mux->pp_inputs[i]->p_fifo;
- i_count = block_FifoCount( p_fifo );
- while( i_count > 1 )
+ vlc_fifo_Lock( p_fifo );
+ block_t *p_data = vlc_fifo_DequeueAllUnlocked( p_fifo );
+ vlc_fifo_Unlock( p_fifo );
+
+ while( p_data != NULL )
{
avi_idx1_entry_t *p_idx;
- block_t *p_data;
- p_data = block_FifoGet( p_fifo );
- if( block_FifoCount( p_fifo ) > 0 )
+ block_t *p_next = p_data->p_next;
+ p_data->p_next = NULL;
+ if( p_next )
{
- block_t *p_next = block_FifoShow( p_fifo );
p_data->i_length = p_next->i_dts - p_data->i_dts;
}
if( PrepareSamples( p_stream, &p_mux->pp_inputs[i]->fmt,
&p_data ) != VLC_SUCCESS )
{
- i_count--;
+ p_data = p_next;
continue;
}
@@ -556,7 +557,7 @@ static int Mux ( sout_mux_t *p_mux )
{
msg_Warn( p_mux, "argg length < 0 l" );
block_Release( p_data );
- i_count--;
+ p_data = p_next;
continue;
}
p_stream->i_duration += p_data->i_length;
@@ -598,7 +599,7 @@ static int Mux ( sout_mux_t *p_mux )
}
}
- i_count--;
+ p_data = p_next;
}
}
=====================================
modules/mux/dummy.c
=====================================
@@ -139,7 +139,6 @@ static int Mux( sout_mux_t *p_mux )
for( i = 0; i < p_mux->i_nb_inputs; i++ )
{
block_fifo_t *p_fifo;
- int i_count;
if( p_sys->b_header && p_mux->pp_inputs[i]->p_fmt->i_extra )
{
@@ -157,14 +156,17 @@ static int Mux( sout_mux_t *p_mux )
}
p_fifo = p_mux->pp_inputs[i]->p_fifo;
- i_count = block_FifoCount( p_fifo );
- while( i_count > 0 )
+ vlc_fifo_Lock( p_fifo );
+ block_t *p_data = vlc_fifo_DequeueAllUnlocked( p_fifo );
+ vlc_fifo_Unlock( p_fifo );
+ while( p_data != NULL )
{
- block_t *p_data = block_FifoGet( p_fifo );
+ block_t *p_next = p_data->p_next;
+ p_data->p_next = NULL;
sout_AccessOutWrite( p_mux->p_access, p_data );
- i_count--;
+ p_data = p_next;
}
}
p_sys->b_header = false;
=====================================
modules/mux/mp4/mp4.c
=====================================
@@ -221,7 +221,7 @@ static void box_send(sout_mux_t *p_mux, bo_t *box);
static block_t *ConvertSUBT(block_t *);
static bool CreateCurrentEdit(mp4_stream_t *, vlc_tick_t, bool);
-static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_stream);
+static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_stream, block_t *p_data);
static int WriteSlowStartHeader(sout_mux_t *p_mux)
{
@@ -540,8 +540,16 @@ static void DelStream(sout_mux_t *p_mux, sout_input_t *p_input)
if(!mp4mux_Is(p_sys->muxh, FRAGMENTED))
{
- while(block_FifoCount(p_input->p_fifo) > 0 &&
- MuxStream(p_mux, p_input, p_stream) == VLC_SUCCESS) {};
+ vlc_fifo_Lock( p_input->p_fifo );
+ block_t *p_data = vlc_fifo_DequeueAllUnlocked( p_input->p_fifo );
+ vlc_fifo_Unlock( p_input->p_fifo );
+ while( p_data != NULL )
+ {
+ block_t *p_next = p_data->p_next;
+ p_data->p_next = NULL;
+ MuxStream(p_mux, p_input, p_stream, p_data);
+ p_data = p_next;
+ }
if(CreateCurrentEdit(p_stream, p_sys->i_start_dts, false))
mp4mux_track_DebugEdits(VLC_OBJECT(p_mux), p_stream->tinfo);
@@ -637,11 +645,10 @@ static inline vlc_tick_t dts_fb_pts( const block_t *p_data )
return p_data->i_dts != VLC_TICK_INVALID ? p_data->i_dts: p_data->i_pts;
}
-static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_stream)
+static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_stream, block_t *p_data)
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
- block_t *p_data = BlockDequeue(p_input, p_stream);
if(!p_data)
return VLC_SUCCESS;
@@ -866,7 +873,13 @@ static int Mux(sout_mux_t *p_mux)
sout_input_t *p_input = p_mux->pp_inputs[i_stream];
mp4_stream_t *p_stream = (mp4_stream_t*)p_input->p_sys;
- i_ret = MuxStream(p_mux, p_input, p_stream);
+ vlc_fifo_Lock( p_input->p_fifo );
+ block_t *p_data = vlc_fifo_DequeueUnlocked( p_input->p_fifo );
+ vlc_fifo_Unlock( p_input->p_fifo );
+ if (unlikely(p_data == NULL))
+ continue;
+
+ i_ret = MuxStream(p_mux, p_input, p_stream, p_data);
} while( i_ret == VLC_SUCCESS );
return i_ret;
=====================================
modules/mux/ogg.c
=====================================
@@ -75,7 +75,7 @@ static int Control ( sout_mux_t *, int, va_list );
static int AddStream( sout_mux_t *, sout_input_t * );
static void DelStream( sout_mux_t *, sout_input_t * );
static int Mux ( sout_mux_t * );
-static int MuxBlock ( sout_mux_t *, sout_input_t * );
+static int MuxBlock ( sout_mux_t *, sout_input_t *, block_t * );
static bool OggCreateHeaders( sout_mux_t * );
static void OggFillSkeletonFishead( uint8_t *p_buffer, sout_mux_t *p_mux );
@@ -561,8 +561,16 @@ static void DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
if( !p_stream->b_new )
{
- while( block_FifoCount( p_input->p_fifo ) )
- MuxBlock( p_mux, p_input );
+ vlc_fifo_Lock( p_input->p_fifo);
+ block_t *p_block = vlc_fifo_DequeueAllUnlocked( p_input->p_fifo );
+ vlc_fifo_Unlock( p_input->p_fifo );
+ while( p_block != NULL )
+ {
+ block_t *p_next = p_block->p_next;
+ p_block->p_next = NULL;
+ MuxBlock( p_mux, p_input, p_block );
+ p_block = p_next;
+ }
}
if( !p_stream->b_new &&
@@ -1568,17 +1576,24 @@ static int Mux( sout_mux_t *p_mux )
int i_stream = sout_MuxGetStream( p_mux, 1, NULL );
if( i_stream < 0 )
return VLC_SUCCESS;
- MuxBlock( p_mux, p_mux->pp_inputs[i_stream] );
+
+ sout_input_t *p_input = p_mux->pp_inputs[i_stream];
+ vlc_fifo_Lock( p_input->p_fifo);
+ block_t *p_block = vlc_fifo_DequeueUnlocked( p_input->p_fifo );
+ vlc_fifo_Unlock( p_input->p_fifo );
+ if( unlikely( p_block == NULL ) )
+ continue;
+
+ MuxBlock( p_mux, p_mux->pp_inputs[i_stream], p_block );
}
return VLC_SUCCESS;
}
-static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
+static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input, block_t *p_data )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
ogg_stream_t *p_stream = (ogg_stream_t*)p_input->p_sys;
- block_t *p_data = block_FifoGet( p_input->p_fifo );
block_t *p_og = NULL;
ogg_packet op;
vlc_tick_t i_time;
=====================================
src/stream_output/stream_output.c
=====================================
@@ -439,8 +439,7 @@ void sout_MuxDeleteStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
int i_index;
- if( p_mux->b_waiting_stream
- && block_FifoCount( p_input->p_fifo ) > 0 )
+ if( p_mux->b_waiting_stream )
{
/* We stop waiting, and call the muxer for taking care of the data
* before we remove this es */
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/416e3d12c85a82fdddac78b05f07b28fd449b5f8...28d1b42626fdd7a430709e978400c7565b1bac28
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/416e3d12c85a82fdddac78b05f07b28fd449b5f8...28d1b42626fdd7a430709e978400c7565b1bac28
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list