[x264-devel] commit: Fix some crashes with high bit depth (Jason Garrett-Glaser )

git at videolan.org git at videolan.org
Sat Nov 20 01:16:57 CET 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Fri Nov 19 15:40:23 2010 -0800| [c764e29dad01f4c1441b614171a92453019a5e4c] | committer: Jason Garrett-Glaser 

Fix some crashes with high bit depth
Not all arrays were sufficiently aligned.

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

 common/pixel.c      |    2 +-
 encoder/analyse.c   |   16 ++++++++--------
 encoder/me.c        |    4 ++--
 encoder/slicetype.c |    8 ++++----
 tools/checkasm.c    |    2 +-
 5 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/common/pixel.c b/common/pixel.c
index b9fa83e..1e21550 100644
--- a/common/pixel.c
+++ b/common/pixel.c
@@ -500,7 +500,7 @@ SATD_X_DECL7( _neon )
 #define INTRA_MBCMP_8x8( mbcmp, cpu )\
 void x264_intra_##mbcmp##_x3_8x8##cpu( pixel *fenc, pixel edge[33], int res[3] )\
 {\
-    pixel pix[8*FDEC_STRIDE];\
+    ALIGNED_ARRAY_16( pixel, pix, [8*FDEC_STRIDE] );\
     x264_predict_8x8_v_c( pix, edge );\
     res[0] = x264_pixel_##mbcmp##_8x8##cpu( pix, FDEC_STRIDE, fenc, FENC_STRIDE );\
     x264_predict_8x8_h_c( pix, edge );\
diff --git a/encoder/analyse.c b/encoder/analyse.c
index de47159..544bd16 100644
--- a/encoder/analyse.c
+++ b/encoder/analyse.c
@@ -1530,7 +1530,7 @@ static void x264_mb_analyse_inter_p8x16( x264_t *h, x264_mb_analysis_t *a, int i
 
 static int x264_mb_analyse_inter_p4x4_chroma( x264_t *h, x264_mb_analysis_t *a, pixel **p_fref, int i8x8, int size )
 {
-    ALIGNED_ARRAY_8( pixel, pix1,[16*8] );
+    ALIGNED_ARRAY_16( pixel, pix1,[16*8] );
     pixel *pix2 = pix1+8;
     const int i_stride = h->mb.pic.i_stride[1];
     const int or = 8*(i8x8&1) + 2*(i8x8&2)*i_stride;
@@ -1686,8 +1686,8 @@ static void x264_mb_analyse_inter_p4x8( x264_t *h, x264_mb_analysis_t *a, int i8
 
 static ALWAYS_INLINE int x264_analyse_bi_chroma( x264_t *h, x264_mb_analysis_t *a, int idx, int i_pixel )
 {
-    ALIGNED_ARRAY_8( pixel, pix, [4],[8*8] );
-    ALIGNED_ARRAY_8( pixel,  bi, [2],[8*8] );
+    ALIGNED_ARRAY_16( pixel, pix, [4],[8*8] );
+    ALIGNED_ARRAY_16( pixel,  bi, [2],[8*8] );
     int l0_mvy_offset, l1_mvy_offset;
     int i_chroma_cost = 0;
 
@@ -1875,8 +1875,8 @@ static void x264_mb_analyse_inter_b16x16( x264_t *h, x264_mb_analysis_t *a )
 
         if( h->mb.b_chroma_me )
         {
-            ALIGNED_ARRAY_8( pixel, pixuv, [2],[8*FENC_STRIDE] );
-            ALIGNED_ARRAY_8( pixel, bi, [8*FENC_STRIDE] );
+            ALIGNED_ARRAY_16( pixel, pixuv, [2],[8*FENC_STRIDE] );
+            ALIGNED_ARRAY_16( pixel, bi, [8*FENC_STRIDE] );
 
             if( h->mb.b_interlaced & a->l0.bi16x16.i_ref )
             {
@@ -2018,7 +2018,7 @@ static inline void x264_mb_cache_mv_b8x16( x264_t *h, x264_mb_analysis_t *a, int
 
 static void x264_mb_analyse_inter_b8x8_mixed_ref( x264_t *h, x264_mb_analysis_t *a )
 {
-    ALIGNED_ARRAY_8( pixel, pix,[2],[8*8] );
+    ALIGNED_ARRAY_16( pixel, pix,[2],[8*8] );
     int i_maxref[2] = {h->mb.pic.i_fref[0]-1, h->mb.pic.i_fref[1]-1};
 
     /* early termination: if 16x16 chose ref 0, then evalute no refs older
@@ -2133,7 +2133,7 @@ static void x264_mb_analyse_inter_b8x8( x264_t *h, x264_mb_analysis_t *a )
     pixel **p_fref[2] =
         { h->mb.pic.p_fref[0][a->l0.me16x16.i_ref],
           h->mb.pic.p_fref[1][a->l1.me16x16.i_ref] };
-    ALIGNED_ARRAY_8( pixel, pix,[2],[8*8] );
+    ALIGNED_ARRAY_16( pixel, pix,[2],[8*8] );
 
     /* XXX Needed for x264_mb_predict_mv */
     h->mb.i_partition = D_8x8;
@@ -2301,7 +2301,7 @@ static void x264_mb_analyse_inter_b16x8( x264_t *h, x264_mb_analysis_t *a, int i
 
 static void x264_mb_analyse_inter_b8x16( x264_t *h, x264_mb_analysis_t *a, int i_best_satd )
 {
-    ALIGNED_ARRAY_8( pixel, pix,[2],[8*16] );
+    ALIGNED_ARRAY_16( pixel, pix,[2],[8*16] );
     ALIGNED_4( int16_t mvc[3][2] );
 
     h->mb.i_partition = D_8x16;
diff --git a/encoder/me.c b/encoder/me.c
index 90f7dfd..bd0a082 100644
--- a/encoder/me.c
+++ b/encoder/me.c
@@ -945,8 +945,8 @@ static void ALWAYS_INLINE x264_me_refine_bidir( x264_t *h, x264_me_t *m0, x264_m
     const int bw = x264_pixel_size[i_pixel].w;
     const int bh = x264_pixel_size[i_pixel].h;
     ALIGNED_ARRAY_16( pixel, pixy_buf,[2],[9][16*16] );
-    ALIGNED_ARRAY_8( pixel, pixu_buf,[2],[9][8*8] );
-    ALIGNED_ARRAY_8( pixel, pixv_buf,[2],[9][8*8] );
+    ALIGNED_ARRAY_16( pixel, pixu_buf,[2],[9][8*8] );
+    ALIGNED_ARRAY_16( pixel, pixv_buf,[2],[9][8*8] );
     pixel *src[2][9];
     pixel *pix  = &h->mb.pic.p_fdec[0][8*x + 8*y*FDEC_STRIDE];
     pixel *pixu = &h->mb.pic.p_fdec[1][4*x + 4*y*FDEC_STRIDE];
diff --git a/encoder/slicetype.c b/encoder/slicetype.c
index 54c4762..450cc5c 100644
--- a/encoder/slicetype.c
+++ b/encoder/slicetype.c
@@ -159,7 +159,7 @@ static NOINLINE unsigned int x264_weight_cost_luma( x264_t *h, x264_frame_t *fen
     int i_lines = fenc->i_lines_lowres;
     int i_width = fenc->i_width_lowres;
     pixel *fenc_plane = fenc->lowres[0];
-    ALIGNED_ARRAY_8( pixel, buf,[8*8] );
+    ALIGNED_ARRAY_16( pixel, buf,[8*8] );
     int pixoff = 0;
     int i_mb = 0;
 
@@ -189,9 +189,9 @@ static NOINLINE unsigned int x264_weight_cost_chroma( x264_t *h, x264_frame_t *f
     int i_lines = fenc->i_lines[1];
     int i_width = fenc->i_width[1];
     pixel *src = ref + i_offset;
-    ALIGNED_ARRAY_8( pixel, buf, [8*8] );
+    ALIGNED_ARRAY_16( pixel, buf, [8*8] );
     int pixoff = 0;
-    ALIGNED_8( pixel flat[8] ) = {0};
+    ALIGNED_16( static pixel flat [8] ) = {0};
     if( w )
     {
         for( int y = 0; y < i_lines; y += 8, pixoff = y*i_stride )
@@ -370,7 +370,7 @@ static void x264_slicetype_mb_cost( x264_t *h, x264_mb_analysis_t *a,
                             i_mb_y > 0 && i_mb_y < h->mb.i_mb_height - 1) ||
                             h->mb.i_mb_width <= 2 || h->mb.i_mb_height <= 2;
 
-    ALIGNED_ARRAY_8( pixel, pix1,[9*FDEC_STRIDE] );
+    ALIGNED_ARRAY_16( pixel, pix1,[9*FDEC_STRIDE] );
     pixel *pix2 = pix1+8;
     x264_me_t m[2];
     int i_bcost = COST_MAX;
diff --git a/tools/checkasm.c b/tools/checkasm.c
index 218f87e..4bd6dd5 100644
--- a/tools/checkasm.c
+++ b/tools/checkasm.c
@@ -536,7 +536,7 @@ static int check_dct( int cpu_ref, int cpu_new )
     ALIGNED_16( dctcoef dct2[16][16] );
     ALIGNED_16( dctcoef dct4[16][16] );
     ALIGNED_16( dctcoef dct8[4][64] );
-    ALIGNED_8( dctcoef dctdc[2][4] );
+    ALIGNED_16( dctcoef dctdc[2][4] );
     x264_t h_buf;
     x264_t *h = &h_buf;
 



More information about the x264-devel mailing list