[vlc-devel] [PATCH 11/31] decoder: split the decoder format update in 2 parts
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jul 5 16:19:50 CEST 2019
The first part is to create the decoder device.
The second part is to create the display module (or other depending on the
decoder owner).
Turn decoder_UpdateVideoFormat() into an inline calling the two new functions.
---
include/vlc_codec.h | 43 ++++++++++++++++++++++++++++++++++++-
src/input/decoder_helpers.c | 14 +++++++++++-
src/libvlccore.sym | 3 ++-
3 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index a2f81756b5..95dfbc8ff6 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -49,6 +49,7 @@ struct decoder_owner_callbacks
{
struct
{
+ int (*get_device)( decoder_t * );
int (*format_update)( decoder_t * );
/* cf. decoder_NewPicture, can be called from any decoder thread */
@@ -253,6 +254,40 @@ struct encoder_t
* @{
*/
+/**
+ * Creates/Updates the output decoder device.
+ *
+ * This function notifies the video output pipeline of a new video output
+ * format (fmt_out.video). If there was no video output from the decoder so far
+ * or if the video output format requires a new decoder device, a new decoder
+ * device will be set up. decoder_UpdateVideoOutput() can then be used.
+ *
+ * If the format is unchanged, this function has no effects and returns zero.
+ *
+ * \note
+ * This function is not reentrant.
+ *
+ * @return 0 if the video output was set up successfully, -1 otherwise.
+ */
+VLC_API int decoder_UpdateDecoderDevice( decoder_t *dec );
+
+/**
+ * Creates/Updates the rest of the video output pipeline.
+ *
+ * After a call to decoder_UpdateDecoderDevice() this function notifies the
+ * video output pipeline of a new video output format (fmt_out.video). If there
+ * was no video output from the decoder so far, a new decoder video output will
+ * be set up. decoder_NewPicture() can then be used to allocate picture buffers.
+ *
+ * If the format is unchanged, this function has no effects and returns zero.
+ *
+ * \note
+ * This function is not reentrant.
+ *
+ * @return 0 if the video output was set up successfully, -1 otherwise.
+ */
+VLC_API int decoder_UpdateVideoOutput( decoder_t *dec );
+
/**
* Updates the video output format.
*
@@ -268,7 +303,13 @@ struct encoder_t
*
* @return 0 if the video output was set up successfully, -1 otherwise.
*/
-VLC_API int decoder_UpdateVideoFormat( decoder_t *dec );
+static inline int decoder_UpdateVideoFormat( decoder_t *dec )
+{
+ int res = decoder_UpdateDecoderDevice( dec );
+ if (res == 0)
+ res = decoder_UpdateVideoOutput( dec );
+ return res;
+}
/**
* Allocates an output picture buffer.
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index f484180371..b8257e62a6 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -75,7 +75,19 @@ void decoder_Destroy( decoder_t *p_dec )
}
}
-int decoder_UpdateVideoFormat( decoder_t *dec )
+int decoder_UpdateDecoderDevice( decoder_t *dec )
+{
+ vlc_assert( dec->fmt_in.i_cat == VIDEO_ES && dec->cbs != NULL );
+ if ( unlikely(dec->fmt_in.i_cat != VIDEO_ES || dec->cbs == NULL ) )
+ return -1;
+
+ if ( dec->cbs->video.get_device == NULL )
+ return 0; /* TODO make it mandatory for all decoder owners */
+
+ return dec->cbs->video.get_device( dec );
+}
+
+int decoder_UpdateVideoOutput( decoder_t *dec )
{
vlc_assert( dec->fmt_in.i_cat == VIDEO_ES && dec->cbs != NULL );
if ( unlikely(dec->fmt_in.i_cat != VIDEO_ES || dec->cbs == NULL ||
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 662ad6d3d3..4fbd6f7d4f 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -81,7 +81,8 @@ decoder_Clean
decoder_Destroy
decoder_AbortPictures
decoder_NewAudioBuffer
-decoder_UpdateVideoFormat
+decoder_UpdateDecoderDevice
+decoder_UpdateVideoOutput
vlc_decoder_device_Hold
vlc_decoder_device_Release
demux_PacketizerDestroy
--
2.17.1
More information about the vlc-devel
mailing list