[vlc-commits] [Git][videolan/vlc][master] 4 commits: vout: samplebufferdisplay: Rename converter functions

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Oct 11 09:07:31 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
e1821564 by Maxime Chapelet at 2023-10-11T08:51:06+00:00
vout: samplebufferdisplay: Rename converter functions

Refactor CVPX converter functions' name and parameters for consistency

- - - - -
03a668f8 by Maxime Chapelet at 2023-10-11T08:51:06+00:00
vout: samplebufferdisplay: Move converter functions

Move CVPX converter functions' to the top of source file

- - - - -
bf442dcb by Maxime Chapelet at 2023-10-11T08:51:06+00:00
vout: samplebufferdisplay: Delete converter when display closes

Also hold converter's decoder device properly

- - - - -
f5116997 by Maxime Chapelet at 2023-10-11T08:51:06+00:00
vout: samplebufferdisplay: Allocate decoder device properly

Allocate a new decoder device for each converter instead of allocating it once statically

- - - - -


1 changed file:

- modules/video_output/apple/VLCSampleBufferDisplay.m


Changes:

=====================================
modules/video_output/apple/VLCSampleBufferDisplay.m
=====================================
@@ -48,6 +48,71 @@
 
 #include "../../codec/vt_utils.h"
 
+static vlc_decoder_device * CVPXHoldDecoderDevice(vlc_object_t *o, void *sys)
+{
+    VLC_UNUSED(o);
+    vout_display_t *vd = sys;
+    vlc_decoder_device *device =
+        vlc_decoder_device_Create(VLC_OBJECT(vd), vd->cfg->window);
+    static const struct vlc_decoder_device_operations ops =
+    {
+        NULL,
+    };
+    device->ops = &ops;
+    device->type = VLC_DECODER_DEVICE_VIDEOTOOLBOX;
+    return device;
+}
+
+static filter_t *
+CreateCVPXConverter(vout_display_t *vd)
+{
+    filter_t *converter = vlc_object_create(vd, sizeof(filter_t));
+    if (!converter)
+        return NULL;
+
+    static const struct filter_video_callbacks cbs =
+    {
+        .buffer_new = NULL,
+        .hold_device = CVPXHoldDecoderDevice,
+    };
+    converter->owner.video = &cbs;
+    converter->owner.sys = vd;
+
+    es_format_InitFromVideo( &converter->fmt_in,  vd->fmt );
+    es_format_InitFromVideo( &converter->fmt_out,  vd->fmt );
+
+    converter->fmt_out.video.i_chroma =
+    converter->fmt_out.i_codec = VLC_CODEC_CVPX_BGRA;
+
+    converter->p_module = module_need(converter, "video converter", NULL, false);
+    if (!converter->p_module)
+    {
+        vlc_object_delete(converter);
+        return NULL;
+    }
+    assert( converter->ops != NULL );
+
+    return converter;
+}
+
+
+static void DeleteCVPXConverter( filter_t * p_converter )
+{
+    if (!p_converter)
+        return;
+
+    if( p_converter->p_module )
+    {
+        filter_Close( p_converter );
+        module_unneed( p_converter, p_converter->p_module );
+    }
+
+    es_format_Clean( &p_converter->fmt_in );
+    es_format_Clean( &p_converter->fmt_out );
+
+    vlc_object_delete(p_converter);
+}
+
 /**
  * Protocol declaration that drawable-nsobject should follow
  */
@@ -252,6 +317,8 @@ static void Close(vout_display_t *vd)
     VLCSampleBufferDisplay *sys;
     sys = (__bridge_transfer VLCSampleBufferDisplay*)vd->sys;
 
+    DeleteCVPXConverter(sys->converter);
+
     dispatch_async(dispatch_get_main_queue(), ^{
         if ([sys.container respondsToSelector:@selector(removeVoutSubview:)]) {
             [sys.container removeVoutSubview:sys.displayView];
@@ -560,74 +627,6 @@ static int Control (vout_display_t *vd, int query)
     return VLC_SUCCESS;
 }
 
-static vlc_decoder_device * CVPXHoldDecoderDevice(vlc_object_t *o, void *sys)
-{
-    VLC_UNUSED(o);
-    vout_display_t *vd = sys;
-    static vlc_decoder_device *device = NULL;
-    if (!device) {
-        device = vlc_decoder_device_Create(VLC_OBJECT(vd), vd->cfg->window);
-        static const struct vlc_decoder_device_operations ops =
-        {
-            NULL,
-        };
-        device->ops = &ops;
-        device->type = VLC_DECODER_DEVICE_VIDEOTOOLBOX;
-    }
-    
-    return device;
-}
-
-static filter_t *
-SW_to_CVPX_converter_Create(vout_display_t *vd)
-{
-    filter_t *converter = vlc_object_create(vd, sizeof(filter_t));
-    if (!converter)
-        return NULL;
-
-    static const struct filter_video_callbacks cbs =
-    {
-        .buffer_new = NULL,
-        .hold_device = CVPXHoldDecoderDevice,
-    };
-    converter->owner.video = &cbs;
-    converter->owner.sys = vd;
-
-    es_format_InitFromVideo( &converter->fmt_in,  vd->fmt );
-    es_format_InitFromVideo( &converter->fmt_out,  vd->fmt );
-
-    converter->fmt_out.video.i_chroma =
-    converter->fmt_out.i_codec = VLC_CODEC_CVPX_BGRA;
-
-    converter->p_module = module_need(converter, "video converter", NULL, false);
-    if (!converter->p_module)
-    {
-        vlc_object_delete(converter);
-        return NULL;
-    }
-    assert( converter->ops != NULL );
-
-    return converter;
-}
-
-
-static void DeleteFilter( filter_t * p_filter )
-{
-    if (!p_filter)
-        return;
-
-    if( p_filter->p_module )
-    {
-        filter_Close( p_filter );
-        module_unneed( p_filter, p_filter->p_module );
-    }
-
-    es_format_Clean( &p_filter->fmt_in );
-    es_format_Clean( &p_filter->fmt_out );
-
-    vlc_object_delete(p_filter);
-}
-
 static int Open (vout_display_t *vd,
                  video_format_t *fmt, vlc_video_context *context)
 {
@@ -648,7 +647,7 @@ static int Open (vout_display_t *vd,
     // Display will only work with CVPX video context
     filter_t *converter = NULL;
     if (!vlc_video_context_GetPrivate(context, VLC_VIDEO_CONTEXT_CVPX)) {
-        converter = SW_to_CVPX_converter_Create(vd);
+        converter = CreateCVPXConverter(vd);
         if (!converter)
             return VLC_EGENERIC;
     }
@@ -658,7 +657,7 @@ static int Open (vout_display_t *vd,
         id container = (__bridge id)vd->cfg->window->handle.nsobject;
         if (!container) {
             msg_Err(vd, "No drawable-nsobject found!");
-            DeleteFilter(converter);
+            DeleteCVPXConverter(converter);
             return VLC_EGENERIC;
         }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/07437f3bfa54fe78166a8e098aff36334d2e4f5d...f5116997fd1810208549bbf268f0c8e71f6531c2

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/07437f3bfa54fe78166a8e098aff36334d2e4f5d...f5116997fd1810208549bbf268f0c8e71f6531c2
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