[vlc-devel] [PATCH] [RFC] picture: keep track of the alignment necessary for each plane

Steve Lhomme robux4 at videolabs.io
Fri Dec 15 13:11:25 CET 2017


In some cases it may be more than 16.

We could also store each value in each plane_t but in the end the allocation
needs to use the biggest value anyway.
---
 include/vlc_picture.h | 1 +
 src/misc/picture.c    | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index 1ab8fef14f..72e6bb8bb7 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -74,6 +74,7 @@ struct picture_t
 
     plane_t         p[PICTURE_PLANE_MAX];     /**< description of the planes */
     int             i_planes;                /**< number of allocated planes */
+    size_t          i_alignment;    /**< allocation alignment for each plane */
 
     /** \name Picture management properties
      * These properties can be modified using the video output thread API,
diff --git a/src/misc/picture.c b/src/misc/picture.c
index bafa16f534..809ed1f4d8 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -70,7 +70,7 @@ static int AllocatePicture( picture_t *p_pic )
         return VLC_ENOMEM;
     }
 
-    uint8_t *p_data = aligned_alloc( 16, i_bytes );
+    uint8_t *p_data = aligned_alloc( p_pic->i_alignment, i_bytes );
     if( i_bytes > 0 && p_data == NULL )
     {
         p_pic->i_planes = 0;
@@ -199,6 +199,7 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
         assert( (p->i_pitch % 16) == 0 );
     }
     p_picture->i_planes  = p_dsc->plane_count;
+    p_picture->i_alignment = i_modulo_w;
 
     return VLC_SUCCESS;
 }
-- 
2.14.2



More information about the vlc-devel mailing list