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

index 21134a859fed1884a497ac7d429812e9c2706906..b9a2333b8af676f8865419c331d347122dcc6282 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 e6584488141a69b4aeaeba37493547284b67c312..26672138133288bf3db9be6be2f57d61395ceb94 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 70ff246116610811b83e19141bf23eb8ad4f6602..8f851bad9ac3b7b60a40e347b71c9865f281986f 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 );