[x264-devel] commit: Promote chroma planes to 16 byte alignment. (Guillaume Poirier )

git version control git at videolan.org
Mon Feb 9 21:37:01 CET 2009


x264 | branch: master | Guillaume Poirier <gpoirier at mplayerhq.hu> | Mon Feb  9 21:12:23 2009 +0100| [37f98cb85024d288eab5508a3b04ca1324335693] | committer: Guillaume Poirier 

Promote chroma planes to 16 byte alignment.
This will allow simplifying vectors loads that can only load 16-bytes
aligned data (such as AltiVec).

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=37f98cb85024d288eab5508a3b04ca1324335693
---

 common/frame.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/frame.c b/common/frame.c
index a51dc29..de305d1 100644
--- a/common/frame.c
+++ b/common/frame.c
@@ -35,6 +35,7 @@ x264_frame_t *x264_frame_new( x264_t *h )
     int i_stride, i_width, i_lines;
     int i_padv = PADV << h->param.b_interlaced;
     int luma_plane_size;
+    int chroma_plane_size;
     int align = h->param.cpu&X264_CPU_CACHELINE_64 ? 64 : h->param.cpu&X264_CPU_CACHELINE_32 ? 32 : 16;
 
     if( !frame ) return NULL;
@@ -49,15 +50,16 @@ x264_frame_t *x264_frame_new( x264_t *h )
     frame->i_plane = 3;
     for( i = 0; i < 3; i++ )
     {
-        frame->i_stride[i] = i_stride >> !!i;
+        frame->i_stride[i] = ALIGN( i_stride >> !!i, 16 );
         frame->i_width[i] = i_width >> !!i;
         frame->i_lines[i] = i_lines >> !!i;
     }
 
     luma_plane_size = (frame->i_stride[0] * ( frame->i_lines[0] + 2*i_padv ));
+    chroma_plane_size = (frame->i_stride[1] * ( frame->i_lines[1] + 2*i_padv ));
     for( i = 1; i < 3; i++ )
     {
-        CHECKED_MALLOC( frame->buffer[i], luma_plane_size/4 );
+        CHECKED_MALLOC( frame->buffer[i], chroma_plane_size );
         frame->plane[i] = frame->buffer[i] + (frame->i_stride[i] * i_padv + PADH)/2;
     }
     /* all 4 luma planes allocated together, since the cacheline split code



More information about the x264-devel mailing list