[vlc-commits] Avoid a few relocations

Rafaël Carré git at videolan.org
Mon Sep 10 15:06:09 CEST 2012


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Mon Sep 10 14:53:26 2012 +0200| [e7c2da6c16ccd419f8632e521e600e8e68e00ddc] | committer: Rafaël Carré

Avoid a few relocations

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

 src/audio_output/common.c      |    8 ++------
 src/misc/image.c               |   16 +++++-----------
 src/video_output/interlacing.c |    6 +++---
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index c12a7a9..c4775c0 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -625,13 +625,12 @@ bool aout_CheckChannelExtraction( int *pi_selection,
 static int FilterOrder( const char *psz_name )
 {
     static const struct {
-        const char *psz_name;
+        const char psz_name[10];
         int        i_order;
     } filter[] = {
         { "equalizer",  0 },
-        { NULL,         INT_MAX },
     };
-    for( int i = 0; filter[i].psz_name; i++ )
+    for( unsigned i = 0; i < ARRAY_SIZE(filter); i++ )
     {
         if( !strcmp( filter[i].psz_name, psz_name ) )
             return filter[i].i_order;
@@ -742,6 +741,3 @@ bool aout_ChangeFilterString( vlc_object_t *p_obj, vlc_object_t *p_aout,
 
     return true;
 }
-
-
-
diff --git a/src/misc/image.c b/src/misc/image.c
index d9f7956..3f55ef6 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -531,7 +531,7 @@ static picture_t *ImageFilter( image_handler_t *p_image, picture_t *p_pic,
 static const struct
 {
     vlc_fourcc_t i_codec;
-    const char *psz_ext;
+    const char psz_ext[7];
 
 } ext_table[] =
 {
@@ -554,14 +554,11 @@ static const struct
     { VLC_CODEC_TIFF,              "tiff" },
     { VLC_FOURCC('l','b','m',' '), "lbm" },
     { VLC_CODEC_PPM,               "ppm" },
-    { 0, NULL }
 };
 
 vlc_fourcc_t image_Type2Fourcc( const char *psz_type )
 {
-    int i;
-
-    for( i = 0; ext_table[i].i_codec; i++ )
+    for( unsigned i = 0; i < ARRAY_SIZE(ext_table); i++ )
         if( !strcasecmp( ext_table[i].psz_ext, psz_type ) )
             return ext_table[i].i_codec;
 
@@ -580,12 +577,9 @@ vlc_fourcc_t image_Ext2Fourcc( const char *psz_name )
 /*
 static const char *Fourcc2Ext( vlc_fourcc_t i_codec )
 {
-    int i;
-
-    for( i = 0; ext_table[i].i_codec != 0; i++ )
-    {
-        if( ext_table[i].i_codec == i_codec ) return ext_table[i].psz_ext;
-    }
+    for( unsigned i = 0; i < ARRAY_SIZE(ext_table); i++ )
+        if( ext_table[i].i_codec == i_codec )
+            return ext_table[i].psz_ext;
 
     return NULL;
 }
diff --git a/src/video_output/interlacing.c b/src/video_output/interlacing.c
index c65bf35..13ec36f 100644
--- a/src/video_output/interlacing.c
+++ b/src/video_output/interlacing.c
@@ -38,7 +38,7 @@
  * You can use the non vout filter if and only if the video properties stay the
  * same (width/height/chroma/fps), at least for now.
  */
-static const char *deinterlace_modes[] = {
+static const char deinterlace_modes[][9]= {
     ""
     "discard",
     "blend",
@@ -50,11 +50,11 @@ static const char *deinterlace_modes[] = {
     "yadif2x",
     "phosphor",
     "ivtc",
-    NULL
 };
+
 static bool DeinterlaceIsModeValid(const char *mode)
 {
-    for (unsigned i = 0; deinterlace_modes[i]; i++) {
+    for (unsigned i = 0; i < ARRAY_SIZE(deinterlace_modes); i++) {
         if (!strcmp(deinterlace_modes[i], mode))
             return true;
     }



More information about the vlc-commits mailing list