[vlc-devel] [PATCH 15/19] vt_utils: set the picture planes once the picture is created

Steve Lhomme robux4 at ycbcr.xyz
Thu Jul 30 14:16:56 CEST 2020


---
 modules/codec/vt_utils.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/modules/codec/vt_utils.c b/modules/codec/vt_utils.c
index a27b42e58f4..a4bc02cc9ba 100644
--- a/modules/codec/vt_utils.c
+++ b/modules/codec/vt_utils.c
@@ -153,38 +153,37 @@ cvpxpic_create_mapped(const video_format_t *fmt, CVPixelBufferRef cvpx,
 
     CVPixelBufferLockFlags lock = readonly ? kCVPixelBufferLock_ReadOnly : 0;
     CVPixelBufferLockBaseAddress(cvpx, lock);
-    picture_resource_t rsc = { };
 
 #ifndef NDEBUG
     assert(CVPixelBufferGetPlaneCount(cvpx) == planes_count);
 #endif
 
+    void (*pf_destroy)(picture_context_t *) = readonly ?
+        cvpxpic_destroy_mapped_ro_cb : cvpxpic_destroy_mapped_rw_cb;
+
+    picture_t *pic = picture_NewFromResource(fmt, NULL, NULL);
+    if (pic == NULL
+     || cvpxpic_attach_common(pic, cvpx, pf_destroy, vctx, NULL) != VLC_SUCCESS)
+    {
+        CVPixelBufferUnlockBaseAddress(cvpx, lock);
+        return NULL;
+    }
     if (planes_count == 0)
     {
-        rsc.p[0].p_pixels = CVPixelBufferGetBaseAddress(cvpx);
-        rsc.p[0].i_lines = CVPixelBufferGetHeight(cvpx);
-        rsc.p[0].i_pitch = CVPixelBufferGetBytesPerRow(cvpx);
+        pic->p[0].p_pixels = CVPixelBufferGetBaseAddress(cvpx);
+        pic->p[0].i_lines = CVPixelBufferGetHeight(cvpx);
+        pic->p[0].i_pitch = CVPixelBufferGetBytesPerRow(cvpx);
     }
     else
     {
         for (unsigned i = 0; i < planes_count; ++i)
         {
-            rsc.p[i].p_pixels = CVPixelBufferGetBaseAddressOfPlane(cvpx, i);
-            rsc.p[i].i_lines = CVPixelBufferGetHeightOfPlane(cvpx, i);
-            rsc.p[i].i_pitch = CVPixelBufferGetBytesPerRowOfPlane(cvpx, i);
+            pic->p[i].p_pixels = CVPixelBufferGetBaseAddressOfPlane(cvpx, i);
+            pic->p[i].i_lines = CVPixelBufferGetHeightOfPlane(cvpx, i);
+            pic->p[i].i_pitch = CVPixelBufferGetBytesPerRowOfPlane(cvpx, i);
         }
     }
 
-    void (*pf_destroy)(picture_context_t *) = readonly ?
-        cvpxpic_destroy_mapped_ro_cb : cvpxpic_destroy_mapped_rw_cb;
-
-    picture_t *pic = picture_NewFromResource(fmt, NULL, &rsc);
-    if (pic == NULL
-     || cvpxpic_attach_common(pic, cvpx, pf_destroy, vctx, NULL) != VLC_SUCCESS)
-    {
-        CVPixelBufferUnlockBaseAddress(cvpx, lock);
-        return NULL;
-    }
     return pic;
 }
 
-- 
2.26.2



More information about the vlc-devel mailing list