[x264-devel] Shut up some valgrind false-positives
Loren Merritt
git at videolan.org
Wed Aug 24 22:40:19 CEST 2011
x264 | branch: master | Loren Merritt <pengvado at akuvian.org> | Mon Aug 8 13:40:53 2011 +0000| [d89a7d5dd4496e38da657879574b4eb3fbde5071] | committer: Jason Garrett-Glaser
Shut up some valgrind false-positives
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=d89a7d5dd4496e38da657879574b4eb3fbde5071
---
common/frame.c | 5 ++++-
encoder/encoder.c | 6 +++++-
tools/checkasm.c | 4 ++--
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/common/frame.c b/common/frame.c
index 21134a8..b9a2333 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 e658448..2667213 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 70ff246..8f851ba 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 );
More information about the x264-devel
mailing list