[vlc-devel] [PATCH 2/2] transcode: video: implement the get_device to provide a decoder device to the decoder

Steve Lhomme robux4 at ycbcr.xyz
Fri Oct 25 14:31:07 CEST 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.
---
 modules/stream_out/transcode/transcode.h |  1 +
 modules/stream_out/transcode/video.c     | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/modules/stream_out/transcode/transcode.h b/modules/stream_out/transcode/transcode.h
index a704a61f455..1090d57c1b5 100644
--- a/modules/stream_out/transcode/transcode.h
+++ b/modules/stream_out/transcode/transcode.h
@@ -129,6 +129,7 @@ struct sout_stream_id_sys_t
              vlc_blender_t   *p_spu_blender;
              spu_t           *p_spu;
              video_format_t  fmt_input_video;
+             vlc_decoder_device *dec_dev;
          };
          struct
          {
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 04f749a9906..ee7cbb6d535 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -60,6 +60,16 @@ static const video_format_t* filtered_video_format( sout_stream_id_sys_t *id,
     return &p_pic->format;
 }
 
+static vlc_decoder_device * video_get_decoder_device( decoder_t *p_dec )
+{
+    struct decoder_owner *p_owner = dec_get_owner( p_dec );
+    if (p_owner->id->dec_dev == NULL)
+    {
+        p_owner->id->dec_dev = vlc_decoder_device_Create( NULL );
+    }
+    return p_owner->id->dec_dev ? vlc_decoder_device_Hold(p_owner->id->dec_dev) : NULL;
+}
+
 static void debug_format( sout_stream_t *p_stream, const es_format_t *fmt )
 {
     msg_Dbg( p_stream, "format now %4.4s/%4.4s %dx%d(%dx%d) ΓΈ%d",
@@ -166,6 +176,7 @@ int transcode_video_init( sout_stream_t *p_stream, const es_format_t *p_fmt,
     static const struct decoder_owner_callbacks dec_cbs =
     {
         .video = {
+            .get_device = video_get_decoder_device,
             .format_update = video_update_format_decoder,
             .queue = decoder_queue_video,
         },
@@ -393,6 +404,8 @@ void transcode_video_clean( sout_stream_t *p_stream,
         filter_DeleteBlend( id->p_spu_blender );
     if( id->p_spu )
         spu_Destroy( id->p_spu );
+    if ( id->dec_dev )
+        vlc_decoder_device_Release( id->dec_dev );
 }
 
 void transcode_video_push_spu( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
-- 
2.17.1



More information about the vlc-devel mailing list