[vlc-devel] [PATCH 1/2] [RFC] picture: bump the plane alignment from 16 to 32 bytes
Steve Lhomme
robux4 at videolabs.io
Fri Dec 15 13:11:43 CET 2017
---
include/vlc_picture.h | 2 ++
src/misc/picture.c | 6 ++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index 72e6bb8bb7..ea971e01ef 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -56,6 +56,8 @@ typedef struct plane_t
*/
#define PICTURE_PLANE_MAX (VOUT_MAX_PLANES)
+#define VLC_PLANE_ALIGNMENT 32 /* matches avcodec */
+
typedef struct picture_context_t
{
void (*destroy)(struct picture_context_t *);
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 809ed1f4d8..5d4f140df1 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -79,10 +79,12 @@ static int AllocatePicture( picture_t *p_pic )
/* Fill the p_pixels field for each plane */
p_pic->p[0].p_pixels = p_data;
+ assert(!(((uintptr_t)p_pic->p[0].p_pixels) % VLC_PLANE_ALIGNMENT));
for( int i = 1; i < p_pic->i_planes; i++ )
{
p_pic->p[i].p_pixels = &p_pic->p[i-1].p_pixels[ p_pic->p[i-1].i_lines *
p_pic->p[i-1].i_pitch ];
+ assert(!(((uintptr_t)p_pic->p[i].p_pixels) % VLC_PLANE_ALIGNMENT));
}
return VLC_SUCCESS;
@@ -177,7 +179,7 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
unsigned int i_ratio_h = 1;
for( unsigned i = 0; i < p_dsc->plane_count; i++ )
{
- i_modulo_w = LCM( i_modulo_w, 16 * p_dsc->p[i].w.den );
+ i_modulo_w = LCM( i_modulo_w, VLC_PLANE_ALIGNMENT * p_dsc->p[i].w.den );
i_modulo_h = LCM( i_modulo_h, 16 * p_dsc->p[i].h.den );
if( i_ratio_h < p_dsc->p[i].h.den )
i_ratio_h = p_dsc->p[i].h.den;
@@ -196,7 +198,7 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
p->i_visible_pitch = fmt->i_visible_width * p_dsc->p[i].w.num / p_dsc->p[i].w.den * p_dsc->pixel_size;
p->i_pixel_pitch = p_dsc->pixel_size;
- assert( (p->i_pitch % 16) == 0 );
+ assert( (p->i_pitch % VLC_PLANE_ALIGNMENT) == 0 );
}
p_picture->i_planes = p_dsc->plane_count;
p_picture->i_alignment = i_modulo_w;
--
2.14.2
More information about the vlc-devel
mailing list