[vlc-commits] [Git][videolan/vlc][master] 2 commits: decoder: move code to avoid forward declaration
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Oct 8 01:42:18 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
4b7b7f4e by Thomas Guillem at 2023-10-07T17:07:02+00:00
decoder: move code to avoid forward declaration
In the next commit.
- - - - -
8d7695e6 by Thomas Guillem at 2023-10-07T17:07:02+00:00
decoder: optimize locking when fetching the status
The mutex was unlocked and locked right after when
vlc_input_decoder_GetStatus() was called just after
vlc_input_decoder_Decode().
- - - - -
3 changed files:
- src/input/decoder.c
- src/input/decoder.h
- src/input/es_out.c
Changes:
=====================================
src/input/decoder.c
=====================================
@@ -2246,8 +2246,38 @@ void vlc_input_decoder_Delete( vlc_input_decoder_t *p_owner )
DeleteDecoder(p_owner, p_owner->dec_fmt_in.i_cat);
}
-void vlc_input_decoder_Decode( vlc_input_decoder_t *p_owner, vlc_frame_t *frame,
- bool b_do_pace )
+static void GetStatusLocked(vlc_input_decoder_t *p_owner,
+ struct vlc_input_decoder_status *status)
+{
+ vlc_fifo_Assert(p_owner->p_fifo);
+
+ status->format.changed = p_owner->b_fmt_description;
+ p_owner->b_fmt_description = false;
+
+ if( status->format.changed && p_owner->fmt.i_cat == UNKNOWN_ES )
+ {
+ /* The format changed but the output creation failed */
+ status->format.changed = false;
+ }
+
+ if( status->format.changed )
+ {
+ es_format_Copy( &status->format.fmt, &p_owner->fmt );
+ status->format.meta = NULL;
+
+ if( p_owner->p_description )
+ {
+ status->format.meta = vlc_meta_New();
+ if( status->format.meta )
+ vlc_meta_Merge( status->format.meta, p_owner->p_description );
+ }
+ }
+ status->cc.desc = p_owner->cc.desc;
+}
+
+void vlc_input_decoder_DecodeWithStatus(vlc_input_decoder_t *p_owner, vlc_frame_t *frame,
+ bool b_do_pace,
+ struct vlc_input_decoder_status *status)
{
if( vlc_input_decoder_IsSynchronous( p_owner ) )
{
@@ -2255,6 +2285,8 @@ void vlc_input_decoder_Decode( vlc_input_decoder_t *p_owner, vlc_frame_t *frame,
assert( vlc_fifo_IsEmpty( p_owner->p_fifo ) );
vlc_fifo_Lock(p_owner->p_fifo);
DecoderThread_ProcessInput( p_owner, frame );
+ if (status != NULL)
+ GetStatusLocked(p_owner, status);
vlc_fifo_Unlock(p_owner->p_fifo);
return;
}
@@ -2283,9 +2315,17 @@ void vlc_input_decoder_Decode( vlc_input_decoder_t *p_owner, vlc_frame_t *frame,
}
vlc_fifo_QueueUnlocked( p_owner->p_fifo, frame );
+ if (status != NULL)
+ GetStatusLocked(p_owner, status);
vlc_fifo_Unlock( p_owner->p_fifo );
}
+void vlc_input_decoder_Decode(vlc_input_decoder_t *p_owner, vlc_frame_t *frame,
+ bool b_do_pace)
+{
+ vlc_input_decoder_DecodeWithStatus(p_owner, frame, b_do_pace, NULL);
+}
+
bool vlc_input_decoder_IsEmpty( vlc_input_decoder_t * p_owner )
{
assert( !p_owner->b_waiting );
@@ -2595,37 +2635,6 @@ void vlc_input_decoder_FrameNext( vlc_input_decoder_t *p_owner )
vlc_fifo_Unlock(p_owner->p_fifo);
}
-void vlc_input_decoder_GetStatus( vlc_input_decoder_t *p_owner,
- struct vlc_input_decoder_status *status )
-{
- vlc_fifo_Lock(p_owner->p_fifo);
-
- status->format.changed = p_owner->b_fmt_description;
- p_owner->b_fmt_description = false;
-
- if( status->format.changed && p_owner->fmt.i_cat == UNKNOWN_ES )
- {
- /* The format changed but the output creation failed */
- status->format.changed = false;
- }
-
- if( status->format.changed )
- {
- es_format_Copy( &status->format.fmt, &p_owner->fmt );
- status->format.meta = NULL;
-
- if( p_owner->p_description )
- {
- status->format.meta = vlc_meta_New();
- if( status->format.meta )
- vlc_meta_Merge( status->format.meta, p_owner->p_description );
- }
- }
- status->cc.desc = p_owner->cc.desc;
-
- vlc_fifo_Unlock(p_owner->p_fifo);
-}
-
size_t vlc_input_decoder_GetFifoSize( vlc_input_decoder_t *p_owner )
{
return block_FifoSize( p_owner->p_fifo );
=====================================
src/input/decoder.h
=====================================
@@ -145,8 +145,9 @@ struct vlc_input_decoder_status
/**
* Get the last status of the decoder.
*/
-void vlc_input_decoder_GetStatus( vlc_input_decoder_t *p_dec,
- struct vlc_input_decoder_status *status );
+void vlc_input_decoder_DecodeWithStatus(vlc_input_decoder_t *p_dec,
+ vlc_frame_t *frame, bool do_pace,
+ struct vlc_input_decoder_status *status);
/**
* This function returns the current size in bytes of the decoder fifo
=====================================
src/input/es_out.c
=====================================
@@ -2968,11 +2968,10 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
vlc_input_decoder_Decode( es->p_dec_record, p_dup,
input_priv(p_input)->b_out_pace_control );
}
- vlc_input_decoder_Decode( es->p_dec, p_block,
- input_priv(p_input)->b_out_pace_control );
-
struct vlc_input_decoder_status status;
- vlc_input_decoder_GetStatus( es->p_dec, &status );
+ vlc_input_decoder_DecodeWithStatus(es->p_dec, p_block,
+ input_priv(p_input)->b_out_pace_control,
+ &status);
if( status.format.changed )
{
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5974d7abd012694f0e306e41c3de5a150d95ea00...8d7695e6cf1cc44ead47e4ae03faa5c0f6db8b17
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5974d7abd012694f0e306e41c3de5a150d95ea00...8d7695e6cf1cc44ead47e4ae03faa5c0f6db8b17
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