From: Loren Merritt Date: Mon, 8 Aug 2011 13:40:53 +0000 (+0000) Subject: Shut up some valgrind false-positives X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=d89a7d5dd4496e38da657879574b4eb3fbde5071;p=x264.git Shut up some valgrind false-positives --- diff --git a/common/frame.c b/common/frame.c index 21134a85..b9a2333b 100644 --- a/common/frame.c +++ b/common/frame.c @@ -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; diff --git a/encoder/encoder.c b/encoder/encoder.c index e6584488..26672138 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -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++; diff --git a/tools/checkasm.c b/tools/checkasm.c index 70ff2461..8f851bad 100644 --- a/tools/checkasm.c +++ b/tools/checkasm.c @@ -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 );