[x264-devel] [PATCH] fix the compiler warning

Limin Wang lance.lmwang at gmail.com
Thu Jan 11 03:41:06 CET 2007


Hi there,

I don't think it'll cause any unsafe issue, however it's
better to fix them. Attached is the patch, please review it.


Thanks,
Limin
-------------- next part --------------
Index: encoder/macroblock.c
===================================================================
--- encoder/macroblock.c	(revision 617)
+++ encoder/macroblock.c	(working copy)
@@ -298,7 +298,7 @@
         {
             /* Near null chroma 8x8 block so make it null (bits saving) */
             memset( &h->dct.block[16+ch*4], 0, 4 * sizeof( *h->dct.block ) );
-            if( !array_non_zero( (int*)dct2x2, sizeof(dct2x2)/sizeof(int) ) )
+            if( !array_int16_non_zero( (int16_t*)dct2x2, sizeof(dct2x2)/sizeof(int) ) )
                 continue;
             memset( dct4x4, 0, sizeof( dct4x4 ) );
         }
@@ -663,7 +663,7 @@
     DECLARE_ALIGNED( int,     dctscan[16], 16 );
 
     int i_qp = h->mb.i_qp;
-    int mvp[2];
+    int mvp[2] = {0,0};
     int ch;
 
     int i8x8, i4x4;
@@ -836,7 +836,7 @@
         if( b_decimate )
             nnz8x8 = 4 <= x264_mb_decimate_score( h->dct.luma8x8[i8], 64 );
         else
-            nnz8x8 = array_non_zero( (int*)dct8x8, sizeof(dct8x8)/sizeof(int) );
+            nnz8x8 = array_int16_non_zero( (int16_t*)dct8x8, sizeof(dct8x8)/sizeof(int) );
 
         if( nnz8x8 )
         {
@@ -864,7 +864,7 @@
             nnz8x8 = 4 <= i_decimate_8x8;
         }
         else
-            nnz8x8 = array_non_zero( (int*)dct4x4, sizeof(dct4x4)/sizeof(int) );
+            nnz8x8 = array_int16_non_zero( (int16_t*)dct4x4, sizeof(dct4x4)/sizeof(int) );
 
         if( nnz8x8 )
         {
@@ -885,7 +885,7 @@
         h->dctf.sub4x4_dct( dct4x4, p_fenc, p_fdec );
         quant_4x4_chroma( h, dct4x4, h->quant4_mf[CQM_4PC], i_qp, 0 );
         h->zigzagf.scan_4x4ac( h->dct.block[16+i8+ch*4].residual_ac, dct4x4 );
-        if( array_non_zero( (int*)dct4x4, sizeof(dct4x4)/sizeof(int) ) )
+        if( array_int16_non_zero( (int16_t*)dct4x4, sizeof(dct4x4)/sizeof(int) ) )
         {
             h->quantf.dequant_4x4( dct4x4, h->dequant4_mf[CQM_4PC], i_qp );
             h->dctf.add4x4_idct( p_fdec, dct4x4 );
Index: encoder/macroblock.h
===================================================================
--- encoder/macroblock.h	(revision 617)
+++ encoder/macroblock.h	(working copy)
@@ -62,6 +62,14 @@
     return 0;
 }
 
+static inline int array_int16_non_zero( int16_t *v, int i_count )
+{
+    int i;
+    for( i = 0; i < i_count; i++ )
+        if( v[i] ) return 1;
+    return 0;
+}
+
 static inline int array_non_zero_count( int *v, int i_count )
 {
     int i;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: not available
Url : http://mailman.videolan.org/pipermail/x264-devel/attachments/20070111/382afc1e/attachment.pgp 


More information about the x264-devel mailing list