[vlc-devel] [PATCH 04/19] picture: move the resource init outside of picture_InitPrivate

Steve Lhomme robux4 at ycbcr.xyz
Thu Jul 30 14:16:45 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, 6 insertions(+), 12 deletions(-)

diff --git a/src/misc/picture.c b/src/misc/picture.c
index caea971a092..167fd6826b1 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -197,11 +197,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;
-
     memset( p_picture, 0, sizeof( *p_picture ) );
     p_picture->date = VLC_TICK_INVALID;
 
@@ -212,8 +209,6 @@ static bool picture_InitPrivate(const video_format_t *restrict p_fmt,
 
     atomic_init(&p_picture->refs, 1);
 
-    p_picture->p_sys = p_resource->p_sys;
-
     return true;
 }
 
@@ -225,7 +220,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;
@@ -238,6 +233,8 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_r
 
     picture_t *p_picture = &priv->picture;
 
+    p_picture->p_sys = p_resource->p_sys;
+
     for( int i = 0; i < p_picture->i_planes; i++ )
     {
         p_picture->p[i].p_pixels = p_resource->p[i].p_pixels;
@@ -266,16 +263,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