[vlc-devel] [PATCH 13/39] decoder: split the decoder format update in 2 parts

Steve Lhomme robux4 at ycbcr.xyz
Wed Oct 2 16:23:28 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() is calling the two new functions.
---
 include/vlc_codec.h         | 47 +++++++++++++++++++++++++++++++++++++
 src/input/decoder_helpers.c |  7 ++++++
 src/libvlccore.sym          |  1 +
 3 files changed, 55 insertions(+)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 25e516c5f00..dc1d4dda188 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -49,6 +49,7 @@ struct decoder_owner_callbacks
     {
         struct
         {
+            vlc_decoder_device * (*get_device)( decoder_t * );
             int         (*format_update)( decoder_t * );
 
             /* cf. decoder_NewPicture, can be called from any decoder thread */
@@ -255,6 +256,52 @@ 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 decoder device so far or a new
+ * decoder device is required, 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.
+ *
+ * \param dec the decoder object
+ *
+ * \note
+ * This function is not reentrant.
+ *
+ * @return the received of the held decoder device, NULL not to get one
+ */
+static inline vlc_decoder_device * decoder_GetDecoderDevice( 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 NULL;
+
+    if ( dec->cbs->video.get_device == NULL )
+        return NULL; /* TODO make it mandatory for all decoder owners */
+
+    return dec->cbs->video.get_device( dec );
+}
+
+/**
+ * Creates/Updates the rest of the video output pipeline.
+ *
+ * After a call to decoder_GetDecoderDevice() 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.
  *
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index d2c9a82c382..eac988f85db 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -76,6 +76,13 @@ void decoder_Destroy( decoder_t *p_dec )
 }
 
 int decoder_UpdateVideoFormat( decoder_t *dec )
+{
+    vlc_decoder_device *dec_dev = decoder_GetDecoderDevice( dec );
+    if (dec_dev) vlc_decoder_device_Release( dec_dev );
+    return decoder_UpdateVideoOutput( 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 960541512b3..2037763178d 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -82,6 +82,7 @@ decoder_Destroy
 decoder_AbortPictures
 decoder_NewAudioBuffer
 decoder_UpdateVideoFormat
+decoder_UpdateVideoOutput
 vlc_decoder_device_Hold
 vlc_decoder_device_Release
 demux_PacketizerDestroy
-- 
2.17.1



More information about the vlc-devel mailing list