[vlc-devel] [PATCH v2 13/14] picture: remove unused resource parameter from picture_NewFromResource

Steve Lhomme robux4 at ycbcr.xyz
Fri Aug 14 14:01:48 CEST 2020


And rename he function to picture_NewWithGC.
---
 include/vlc_picture.h                    | 21 ++-------------------
 modules/codec/vt_utils.c                 |  3 +--
 modules/hw/d3d11/d3d11_surface.c         |  2 +-
 modules/hw/d3d9/dxa9.c                   |  2 +-
 modules/hw/vaapi/vlc_vaapi.c             |  2 +-
 modules/hw/vdpau/picture.c               |  2 +-
 modules/video_chroma/copy.c              |  2 +-
 modules/video_output/android/display.c   |  2 +-
 modules/video_output/fb.c                |  4 +---
 modules/video_output/kms.c               |  4 +---
 modules/video_output/opengl/interop_sw.c |  2 +-
 modules/video_output/vmem.c              |  3 +--
 modules/video_output/win32/direct3d11.c  |  2 +-
 src/libvlccore.sym                       |  2 +-
 src/misc/picture.c                       | 13 +------------
 15 files changed, 16 insertions(+), 50 deletions(-)

diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index 178118633d0..5df18b8c62f 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -183,23 +183,6 @@ VLC_API picture_t * picture_New( vlc_fourcc_t i_chroma, int i_width, int i_heigh
  */
 VLC_API picture_t * picture_NewFromFormat( const video_format_t *p_fmt ) VLC_USED;
 
-/**
- * Resource for a picture.
- */
-typedef struct
-{
-    /* Plane resources
-     * XXX all fields MUST be set to the right value.
-     */
-    struct
-    {
-        uint8_t *p_pixels;  /**< Start of the plane's data */
-        int i_lines;        /**< Number of lines, including margins */
-        int i_pitch;        /**< Number of bytes in a line, including margins */
-    } p[PICTURE_PLANE_MAX];
-
-} picture_resource_t;
-
 /**
  * Callback structure to release allocated resources when a picture is released
  * for good.
@@ -211,9 +194,9 @@ typedef struct
 } picture_gc_t;
 
 /**
- * This function will create a new picture using the provided resource.
+ * This function will create a new picture using the provided destructor.
  */
-VLC_API picture_t * picture_NewFromResource( const video_format_t *, const picture_gc_t *, const picture_resource_t * ) VLC_USED;
+VLC_API picture_t * picture_NewWithGC( const video_format_t *, const picture_gc_t * ) VLC_USED;
 
 /**
  * Destroys a picture without references.
diff --git a/modules/codec/vt_utils.c b/modules/codec/vt_utils.c
index b3281a489f6..74fa874923a 100644
--- a/modules/codec/vt_utils.c
+++ b/modules/codec/vt_utils.c
@@ -153,7 +153,6 @@ 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);
@@ -162,7 +161,7 @@ cvpxpic_create_mapped(const video_format_t *fmt, CVPixelBufferRef cvpx,
     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);
+    picture_t *pic = picture_NewWithGC(fmt, NULL);
     if (pic == NULL
      || cvpxpic_attach_common(pic, cvpx, pf_destroy, vctx, NULL) != VLC_SUCCESS)
     {
diff --git a/modules/hw/d3d11/d3d11_surface.c b/modules/hw/d3d11/d3d11_surface.c
index f5750cb02c8..25ce8b2c6cc 100644
--- a/modules/hw/d3d11/d3d11_surface.c
+++ b/modules/hw/d3d11/d3d11_surface.c
@@ -619,7 +619,7 @@ static picture_t *AllocateCPUtoGPUTexture(filter_t *p_filter, filter_sys_t *p_sy
     fmt_staging.i_chroma = cfg->fourcc;
 
     // allocate a picture with the planes setup but no attached buffer
-    picture_t *p_dst = picture_NewFromResource(&fmt_staging, NULL, NULL);
+    picture_t *p_dst = picture_NewWithGC(&fmt_staging, NULL);
     if (p_dst == NULL) {
         msg_Err(p_filter, "Failed to map create the temporary picture.");
         goto done;
diff --git a/modules/hw/d3d9/dxa9.c b/modules/hw/d3d9/dxa9.c
index a6f8d9171bd..25567079ffb 100644
--- a/modules/hw/d3d9/dxa9.c
+++ b/modules/hw/d3d9/dxa9.c
@@ -348,7 +348,7 @@ static picture_t *AllocateCPUtoGPUTexture(filter_t *p_filter)
     fmt_staging.i_chroma = format;
 
     // allocate a picture with the planes setup but no attached buffer
-    picture_t *p_dst = picture_NewFromResource(&fmt_staging, NULL, NULL);
+    picture_t *p_dst = picture_NewWithGC(&fmt_staging, NULL);
     if (p_dst == NULL) {
         msg_Err(p_filter, "Failed to map create the temporary picture.");
         goto done;
diff --git a/modules/hw/vaapi/vlc_vaapi.c b/modules/hw/vaapi/vlc_vaapi.c
index dcf09fed374..f4c6b814269 100644
--- a/modules/hw/vaapi/vlc_vaapi.c
+++ b/modules/hw/vaapi/vlc_vaapi.c
@@ -513,7 +513,7 @@ vlc_vaapi_PoolNew(vlc_object_t *o, vlc_video_context *vctx,
         p_sys->ctx.ctx.va_dpy = dpy;
         p_sys->ctx.picref = NULL;
         picture_gc_t gc = (picture_gc_t) { pool_pic_destroy_cb, p_sys };
-        pics[i] = picture_NewFromResource(fmt, &gc, NULl);
+        pics[i] = picture_NewWithGC(fmt, &gc);
         if (pics[i] == NULL)
         {
             free(p_sys);
diff --git a/modules/hw/vdpau/picture.c b/modules/hw/vdpau/picture.c
index 4a6406d1899..12f5e179e39 100644
--- a/modules/hw/vdpau/picture.c
+++ b/modules/hw/vdpau/picture.c
@@ -173,7 +173,7 @@ error:
         vlc_vdp_output_surface_destroy, sys,
     };
 
-    picture_t *pic = picture_NewFromResource(fmt, &gc, NULL);
+    picture_t *pic = picture_NewWithGC(fmt, &gc);
     if (unlikely(pic == NULL))
     {
         vdp_output_surface_destroy(vdpau_dev->vdp, sys->surface);
diff --git a/modules/video_chroma/copy.c b/modules/video_chroma/copy.c
index 717e20ddf7f..315b3b2e528 100644
--- a/modules/video_chroma/copy.c
+++ b/modules/video_chroma/copy.c
@@ -1113,7 +1113,7 @@ static picture_t *pic_new_unaligned(const video_format_t *fmt)
     if (unlikely(rsc == NULL))
         return NULL;
     picture_gc_t gc = { pic_rsc_destroy, rsc };
-    picture_t *pic = picture_NewFromResource(fmt, &gc, NULL);
+    picture_t *pic = picture_NewWithGC(fmt, &gc);
     if (unlikely(pic == NULL))
     {
         free(rsc);
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index cbc34c57f65..ccc6e2aa254 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -187,7 +187,7 @@ static picture_t *PictureAlloc(video_format_t *fmt)
 
     picture_gc_t gc = (picture_gc_t) { AndroidPicture_Destroy, p_picsys };
 
-    p_pic = picture_NewFromResource(fmt, &gc, NULL);
+    p_pic = picture_NewWithGC(fmt, &gc);
     if (!p_pic)
     {
         free(p_picsys);
diff --git a/modules/video_output/fb.c b/modules/video_output/fb.c
index fa0463becc4..32e7b2b7464 100644
--- a/modules/video_output/fb.c
+++ b/modules/video_output/fb.c
@@ -596,9 +596,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution)
         return VLC_EGENERIC;
     }
 
-    picture_resource_t rsc = { 0 };
-
-    sys->picture = picture_NewFromResource(&vd->fmt, NULL, &rsc);
+    sys->picture = picture_NewWithGC(&vd->fmt, NULL);
     if (unlikely(sys->picture == NULL)) {
         munmap(sys->video_ptr, sys->video_size);
         ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
diff --git a/modules/video_output/kms.c b/modules/video_output/kms.c
index 7652067557a..29928a9ab2b 100644
--- a/modules/video_output/kms.c
+++ b/modules/video_output/kms.c
@@ -576,9 +576,7 @@ static int OpenDisplay(vout_display_t *vd)
     if (!found_connector)
         goto err_out;
 
-    picture_resource_t rsc = { 0 };
-
-    sys->picture = picture_NewFromResource(&vd->fmt, NULL, &rsc);
+    sys->picture = picture_NewWithGC(&vd->fmt, NULL);
 
     if (!sys->picture)
         goto err_out;
diff --git a/modules/video_output/opengl/interop_sw.c b/modules/video_output/opengl/interop_sw.c
index 10fb1434553..7450104977a 100644
--- a/modules/video_output/opengl/interop_sw.c
+++ b/modules/video_output/opengl/interop_sw.c
@@ -68,7 +68,7 @@ pbo_picture_create(const struct vlc_gl_interop *interop)
         return NULL;
 
     picture_gc_t gc = (picture_gc_t) { pbo_picture_destroy, picsys };
-    picture_t *pic = picture_NewFromResource(&interop->fmt_out, &gc, NULL);
+    picture_t *pic = picture_NewWithGC(&interop->fmt_out, &gc);
     if (pic == NULL)
     {
         free(picsys);
diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
index 878672680f8..f50c295c837 100644
--- a/modules/video_output/vmem.c
+++ b/modules/video_output/vmem.c
@@ -239,12 +239,11 @@ static void Prepare(vout_display_t *vd, picture_t *pic, subpicture_t *subpic,
 {
     VLC_UNUSED(date);
     vout_display_sys_t *sys = vd->sys;
-    picture_resource_t rsc = { 0 };
     void *planes[PICTURE_PLANE_MAX];
 
     sys->pic_opaque = sys->lock(sys->opaque, planes);
 
-    picture_t *locked = picture_NewFromResource(&vd->fmt, NULL, &rsc);
+    picture_t *locked = picture_NewWithGC(&vd->fmt, NULL);
     if (likely(locked != NULL)) {
         for (unsigned i = 0; i < PICTURE_PLANE_MAX; i++) {
             locked->p[i].p_pixels = planes[i];
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 7904b7298ab..3a3d3c32367 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1339,7 +1339,7 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
                 continue;
             }
             picture_gc_t gc = (picture_gc_t) { DestroyPictureQuad, d3dquad };
-            (*region)[i] = picture_NewFromResource(&r->p_picture->format, &gc, NULL);
+            (*region)[i] = picture_NewWithGC(&r->p_picture->format, &gc);
             if ((*region)[i] == NULL) {
                 msg_Err(vd, "Failed to create %dx%d picture for OSD",
                         r->fmt.i_width, r->fmt.i_height);
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index ed43c17715c..6f661741897 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -308,7 +308,7 @@ picture_fifo_Pop
 picture_fifo_Push
 picture_New
 picture_NewFromFormat
-picture_NewFromResource
+picture_NewWithGC
 picture_pool_Release
 picture_pool_Get
 picture_pool_New
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 3c527a44e9d..895ee3d0f13 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -208,8 +208,7 @@ static bool picture_InitPrivate(const video_format_t *restrict p_fmt,
     return true;
 }
 
-picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_gc_t *gc,
-                                    const picture_resource_t *p_resource )
+picture_t *picture_NewWithGC( const video_format_t *p_fmt, const picture_gc_t *gc )
 {
     picture_priv_t *priv = malloc(sizeof(*priv));
     if (unlikely(priv == NULL))
@@ -234,16 +233,6 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_g
         p_picture->p_sys = NULL;
     }
 
-    if (p_resource != NULL)
-    {
-        for( int i = 0; i < p_picture->i_planes; i++ )
-        {
-            p_picture->p[i].p_pixels = p_resource->p[i].p_pixels;
-            p_picture->p[i].i_lines  = p_resource->p[i].i_lines;
-            p_picture->p[i].i_pitch  = p_resource->p[i].i_pitch;
-        }
-    }
-
     return p_picture;
 }
 
-- 
2.26.2



More information about the vlc-devel mailing list