]> git.sesse.net Git - x264/commitdiff
Shut up some valgrind false-positives
authorLoren Merritt <pengvado@akuvian.org>
Mon, 8 Aug 2011 13:40:53 +0000 (13:40 +0000)
committerFiona Glaser <fiona@x264.com>
Wed, 24 Aug 2011 17:23:17 +0000 (10:23 -0700)
common/frame.c
encoder/encoder.c
tools/checkasm.c

index 92ce87d52e56b56c456e7ee183925552fe71d082..b95c2a868252b0313710272f9c0f5c6b9d0501f3 100644 (file)
@@ -706,8 +706,11 @@ void x264_weight_scale_plane( x264_t *h, pixel *dst, int i_dst_stride, pixel *sr
      * in terms of the cache loads. */
     while( i_height > 0 )
     {
-        for( int x = 0; x < i_width; x += 16 )
+        int x;
+        for( x = 0; x < i_width-8; x += 16 )
             w->weightfn[16>>2]( dst+x, i_dst_stride, src+x, i_src_stride, w, X264_MIN( i_height, 16 ) );
+        if( x < i_width )
+            w->weightfn[ 8>>2]( dst+x, i_dst_stride, src+x, i_src_stride, w, X264_MIN( i_height, 16 ) );
         i_height -= 16;
         dst += 16 * i_dst_stride;
         src += 16 * i_src_stride;
index 5456518a7e768aeb2b63488dc77c0ae396f6c27b..1bb1ed303d6612173781a6d4a499d72d8c1c1e64 100644 (file)
@@ -1381,7 +1381,11 @@ static int x264_nal_check_buffer( x264_t *h )
 static int x264_nal_end( x264_t *h )
 {
     x264_nal_t *nal = &h->out.nal[h->out.i_nal];
-    nal->i_payload = &h->out.p_bitstream[bs_pos( &h->out.bs ) / 8] - nal->p_payload;
+    uint8_t *end = &h->out.p_bitstream[bs_pos( &h->out.bs ) / 8];
+    nal->i_payload = end - nal->p_payload;
+    /* nal_escape_mmx reads past the end of the input.
+     * While undefined padding wouldn't actually affect the output, it makes valgrind unhappy. */
+    memset( end, 0xff, 32 );
     if( h->param.nalu_process )
         h->param.nalu_process( h, nal );
     h->out.i_nal++;
index d457b1ba0b36a2d04b132707495c2b4a634b8020..8ec773c2064e014640d524ad6f021a35cf5d04be 100644 (file)
@@ -1996,7 +1996,7 @@ static int check_bitstream( int cpu_ref, int cpu_new )
             /* Test corner-case sizes */
             int test_size = i < 10 ? i+1 : rand() & 0x3fff;
             /* Test 8 different probability distributions of zeros */
-            for( int j = 0; j < test_size; j++ )
+            for( int j = 0; j < test_size+32; j++ )
                 input[j] = (rand()&((1 << ((i&7)+1)) - 1)) * rand();
             uint8_t *end_c = (uint8_t*)call_c1( bs_c.nal_escape, output1, input, input+test_size );
             uint8_t *end_a = (uint8_t*)call_a1( bs_a.nal_escape, output2, input, input+test_size );
@@ -2009,7 +2009,7 @@ static int check_bitstream( int cpu_ref, int cpu_new )
                 break;
             }
         }
-        for( int j = 0; j < size; j++ )
+        for( int j = 0; j < size+32; j++ )
             input[j] = rand();
         call_c2( bs_c.nal_escape, output1, input, input+size );
         call_a2( bs_a.nal_escape, output2, input, input+size );