[vlc-devel] [PATCH v3 10/12] picture: move the resource init outside of picture_InitPrivate

Steve Lhomme robux4 at ycbcr.xyz
Tue Aug 18 08:24:51 CEST 2020


We can set the p_sys value directly rather than passing a fake
picture_resource_t to picture_NewFromFormat.
---
 src/misc/picture.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/src/misc/picture.c b/src/misc/picture.c
index 6b03ed7e4be..183a7969e39 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -188,11 +188,8 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
  *****************************************************************************/
 
 static bool picture_InitPrivate(const video_format_t *restrict p_fmt,
-                                picture_priv_t *priv,
-                                const picture_resource_t *p_resource)
+                                picture_t *p_picture)
 {
-    picture_t *p_picture = &priv->picture;
-
     p_picture->date = VLC_TICK_INVALID;
 
     p_picture->format = *p_fmt;
@@ -202,9 +199,6 @@ static bool picture_InitPrivate(const video_format_t *restrict p_fmt,
 
     atomic_init(&p_picture->refs, 1);
 
-    if ( p_resource != NULL)
-        p_picture->p_sys = p_resource->p_sys;
-
     return true;
 }
 
@@ -214,7 +208,7 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_r
     if (unlikely(priv == NULL))
         return NULL;
 
-    if (!picture_InitPrivate(p_fmt, priv, p_resource))
+    if (!picture_InitPrivate(p_fmt, &priv->picture))
     {
         free(priv);
         return NULL;
@@ -222,6 +216,7 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_r
 
     if ( p_resource != NULL)
     {
+        priv->picture.p_sys = p_resource->p_sys;
         priv->gc = (picture_gc_t) { p_resource->pf_destroy, p_resource->p_sys };
     }
 
@@ -246,16 +241,13 @@ picture_t *picture_NewFromFormat(const video_format_t *restrict fmt)
 
     picture_buffer_t *res = &privbuf->res;
 
-    picture_resource_t pic_res = {
-        .p_sys = res,
-    };
-
     picture_priv_t *priv = &privbuf->priv;
-    if (!picture_InitPrivate(fmt, priv, &pic_res))
+    if (!picture_InitPrivate(fmt, &priv->picture))
         goto error;
 
     picture_t *pic = &priv->picture;
 
+    pic->p_sys = res;
     priv->gc = (picture_gc_t) { picture_DestroyFromFormat, NULL };
 
     if (pic->i_planes == 0) {
-- 
2.26.2



More information about the vlc-devel mailing list