[vlc-devel] [PATCH 05/11] image: implement the get_device to provide a decoder device to the decoder

Steve Lhomme robux4 at ycbcr.xyz
Mon Nov 4 13:05:24 CET 2019


The decoder device is created with a NULL window. This can work with some
decoder devices but in some case none will be created and we just get NULL.
---
 src/misc/image.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/misc/image.c b/src/misc/image.c
index 9797a8c47cc..53bdf1b5523 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -51,6 +51,7 @@
 struct decoder_owner
 {
     decoder_t dec;
+    vlc_decoder_device *dec_dev;
     image_handler_t *p_image;
 };
 
@@ -86,6 +87,12 @@ vlc_fourcc_t image_Ext2Fourcc( const char * );
 
 static void ReleaseDecoder(decoder_t *p_dec)
 {
+    struct decoder_owner *p_owner = dec_get_owner( p_dec );
+    if (p_owner->dec_dev)
+    {
+        vlc_decoder_device_Release(p_owner->dec_dev);
+        p_owner->dec_dev = NULL;
+    }
     decoder_Destroy( p_dec );
 }
 
@@ -661,6 +668,16 @@ vlc_fourcc_t image_Mime2Fourcc( const char *psz_mime )
     return 0;
 }
 
+static vlc_decoder_device * image_get_device( decoder_t *p_dec )
+{
+    struct decoder_owner *p_owner = dec_get_owner( p_dec );
+    if ( p_owner->dec_dev == NULL )
+    {
+        p_owner->dec_dev = vlc_decoder_device_Create(p_dec, NULL);
+    }
+    return p_owner->dec_dev ? vlc_decoder_device_Hold(p_owner->dec_dev) : NULL;
+}
+
 static decoder_t *CreateDecoder( image_handler_t *p_image, const es_format_t *fmt )
 {
     decoder_t *p_dec;
@@ -677,6 +694,7 @@ static decoder_t *CreateDecoder( image_handler_t *p_image, const es_format_t *fm
     static const struct decoder_owner_callbacks dec_cbs =
     {
         .video = {
+            .get_device = image_get_device,
             .queue = ImageQueueVideo,
         },
     };
-- 
2.17.1



More information about the vlc-devel mailing list