[x264-devel] Fix a few static analyzer performance hints

Anton Mitrofanov git at videolan.org
Sun Oct 11 19:01:09 CEST 2015


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Tue Sep 22 21:33:07 2015 +0300| [fad44d59b3adeb29b9c92fde0b80116cde79020e] | committer: Henrik Gramner

Fix a few static analyzer performance hints

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=fad44d59b3adeb29b9c92fde0b80116cde79020e
---

 encoder/encoder.c |    6 +++---
 filters/filters.c |    5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index 79997b9..c87d79d 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -3962,13 +3962,13 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,
     {
         pic_out->prop.f_ssim = h->stat.frame.f_ssim / h->stat.frame.i_ssim_cnt;
         h->stat.f_ssim_mean_y[h->sh.i_type] += pic_out->prop.f_ssim * dur;
-        snprintf( psz_message + strlen(psz_message), 80 - strlen(psz_message),
-                  " SSIM Y:%.5f", pic_out->prop.f_ssim );
+        int msg_len = strlen(psz_message);
+        snprintf( psz_message + msg_len, 80 - msg_len, " SSIM Y:%.5f", pic_out->prop.f_ssim );
     }
     psz_message[79] = '\0';
 
     x264_log( h, X264_LOG_DEBUG,
-                  "frame=%4d QP=%.2f NAL=%d Slice:%c Poc:%-3d I:%-4d P:%-4d SKIP:%-4d size=%d bytes%s\n",
+              "frame=%4d QP=%.2f NAL=%d Slice:%c Poc:%-3d I:%-4d P:%-4d SKIP:%-4d size=%d bytes%s\n",
               h->i_frame,
               h->fdec->f_qp_avg_aq,
               h->i_nal_ref_idc,
diff --git a/filters/filters.c b/filters/filters.c
index 224f368..b3162fe 100644
--- a/filters/filters.c
+++ b/filters/filters.c
@@ -32,8 +32,9 @@ char **x264_split_string( char *string, char *sep, int limit )
     if( !string )
         return NULL;
     int sep_count = 0;
+    int sep_len = strlen( sep );
     char *tmp = string;
-    while( ( tmp = ( tmp = strstr( tmp, sep ) ) ? tmp + strlen( sep ) : 0 ) )
+    while( ( tmp = ( tmp = strstr( tmp, sep ) ) ? tmp + sep_len : 0 ) )
         ++sep_count;
     if( sep_count == 0 )
     {
@@ -61,7 +62,7 @@ char **x264_split_string( char *string, char *sep, int limit )
             int j = i-1;
             if( esc )
                 esc[0] = '\0';
-            split[j] = realloc( split[j], strlen( split[j] ) + strlen( sep ) + strlen( tok ) + 1 );
+            split[j] = realloc( split[j], strlen( split[j] ) + sep_len + strlen( tok ) + 1 );
             assert( split[j] );
             strcat( split[j], sep );
             strcat( split[j], tok );



More information about the x264-devel mailing list