[vlc-commits] [Git][videolan/vlc][master] 2 commits: picture: use container_of to get the clone private parts

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Mar 13 09:09:30 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
09da4566 by Steve Lhomme at 2024-03-13T08:46:12+00:00
picture: use container_of to get the clone private parts

- - - - -
69ef5f36 by Steve Lhomme at 2024-03-13T08:46:12+00:00
picture: use a real copy of the video format

If the format contains a palette, it may be gone after the picture is created.
We want to keep it in the picture.

- - - - -


1 changed file:

- src/misc/picture.c


Changes:

=====================================
src/misc/picture.c
=====================================
@@ -211,10 +211,13 @@ static bool picture_InitPrivate(const video_format_t *restrict p_fmt,
     memset( p_picture, 0, sizeof( *p_picture ) );
     p_picture->date = VLC_TICK_INVALID;
 
-    p_picture->format = *p_fmt;
+    video_format_Copy(&p_picture->format, p_fmt);
     /* Make sure the real dimensions are a multiple of 16 */
     if( picture_Setup( p_picture, p_fmt ) )
+    {
+        video_format_Clean(&p_picture->format);
         return false;
+    }
 
     vlc_atomic_rc_init(&p_picture->refs);
     priv->gc.opaque = NULL;
@@ -324,6 +327,7 @@ picture_t *picture_NewFromFormat(const video_format_t *restrict fmt)
 
     return pic;
 error:
+    video_format_Clean(&priv->picture.format);
     free(privbuf);
     return NULL;
 }
@@ -353,6 +357,7 @@ void picture_Destroy(picture_t *picture)
     assert(priv->gc.destroy != NULL);
     priv->gc.destroy(picture);
     vlc_ancillary_array_Clear(&priv->ancillaries);
+    video_format_Clean(&picture->format);
     free(priv);
 }
 
@@ -429,7 +434,8 @@ void picture_Copy( picture_t *p_dst, const picture_t *p_src )
 
 static void picture_DestroyClone(picture_t *clone)
 {
-    picture_t *picture = ((picture_priv_t *)clone)->gc.opaque;
+    picture_priv_t *clone_priv = container_of(clone, picture_priv_t, picture);
+    picture_t *picture = clone_priv->gc.opaque;
 
     picture_Release(picture);
 }
@@ -450,7 +456,8 @@ picture_t *picture_InternalClone(picture_t *picture,
 
     picture_t *clone = picture_NewFromResource(&picture->format, &res);
     if (likely(clone != NULL)) {
-        ((picture_priv_t *)clone)->gc.opaque = opaque;
+        picture_priv_t *clone_priv = container_of(clone, picture_priv_t, picture);
+        clone_priv->gc.opaque = opaque;
 
         /* The picture context is responsible for potentially holding the
          * video context attached to the picture if needed. */



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/45573a4d34e744d110e32b4bc64e4954d2b5182c...69ef5f36fc7a3042fe60e94df0280947e6b9d4cf

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/45573a4d34e744d110e32b4bc64e4954d2b5182c...69ef5f36fc7a3042fe60e94df0280947e6b9d4cf
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