[vlc-devel] commit: Factorize avcodec table - spare about 5kb ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Oct 19 21:49:54 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Oct 19 22:49:28 2008 +0300| [1d35bcd2835dd85f7c28832e52791d1107a6b1be] | committer: Rémi Denis-Courmont 

Factorize avcodec table - spare about 5kb

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

 modules/codec/avcodec/Modules.am             |    2 +-
 modules/codec/avcodec/avcodec.c              |    1 -
 modules/codec/avcodec/avcodec.h              |    5 +++
 modules/codec/avcodec/encoder.c              |    1 -
 modules/codec/avcodec/{fourcc.h => fourcc.c} |   38 +++++++++++++++++---------
 5 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/modules/codec/avcodec/Modules.am b/modules/codec/avcodec/Modules.am
index 67cfb8a..f680229 100644
--- a/modules/codec/avcodec/Modules.am
+++ b/modules/codec/avcodec/Modules.am
@@ -5,7 +5,7 @@ SOURCES_avcodec = \
 	audio.c \
 	deinterlace.c \
 	avutil.h \
-	fourcc.h \
+	fourcc.c \
 	chroma.h \
 	$(NULL)
 
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index fda4da2..59953ab 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -48,7 +48,6 @@
 #endif
 
 #include "avcodec.h"
-#include "fourcc.h"
 #include "avutil.h"
 
 /*****************************************************************************
diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
index 2c467e8..6d8e082 100644
--- a/modules/codec/avcodec/avcodec.h
+++ b/modules/codec/avcodec/avcodec.h
@@ -21,6 +21,11 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+int GetFfmpegCodec( vlc_fourcc_t i_fourcc, int *pi_cat,
+                    int *pi_ffmpeg_codec, const char **ppsz_name );
+int GetVlcFourcc( int i_ffmpeg_codec, int *pi_cat,
+                  vlc_fourcc_t *pi_fourcc, const char **ppsz_name );
+
 picture_t * DecodeVideo    ( decoder_t *, block_t ** );
 aout_buffer_t * DecodeAudio( decoder_t *, block_t ** );
 
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index d9b8285..675c811 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -51,7 +51,6 @@
 
 #include "avcodec.h"
 #include "chroma.h"
-#include "fourcc.h"
 
 #define HURRY_UP_GUARD1 (450000)
 #define HURRY_UP_GUARD2 (300000)
diff --git a/modules/codec/avcodec/fourcc.h b/modules/codec/avcodec/fourcc.c
similarity index 98%
rename from modules/codec/avcodec/fourcc.h
rename to modules/codec/avcodec/fourcc.c
index 0fb2dd6..9175056 100644
--- a/modules/codec/avcodec/fourcc.h
+++ b/modules/codec/avcodec/fourcc.c
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * fourcc.h: libavcodec <-> libvlc conversion routines
+ * fourcc.c: libavcodec <-> libvlc conversion routines
  *****************************************************************************
  * Copyright (C) 1999-2008 the VideoLAN team
  * $Id$
@@ -22,6 +22,22 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <vlc_common.h>
+#include <vlc_codec.h>
+
+#ifdef HAVE_LIBAVCODEC_AVCODEC_H
+#   include <libavcodec/avcodec.h>
+#elif defined(HAVE_FFMPEG_AVCODEC_H)
+#   include <ffmpeg/avcodec.h>
+#else
+#   include <avcodec.h>
+#endif
+#include "avcodec.h"
+
 /*****************************************************************************
  * Codec fourcc -> ffmpeg_id mapping
  *****************************************************************************/
@@ -30,7 +46,7 @@ static const struct
     vlc_fourcc_t  i_fourcc;
     int  i_codec;
     int  i_cat;
-    const char *psz_name;
+    const char psz_name[40];
 
 } codecs_table[] =
 {
@@ -1049,15 +1065,13 @@ static const struct
       SPU_ES, "SubStation Alpha subtitles" },
 #endif
 
-    { 0, 0, 0, 0 }
+    { 0, 0, 0, "" }
 };
 
-static int GetFfmpegCodec( vlc_fourcc_t i_fourcc, int *pi_cat,
-                           int *pi_ffmpeg_codec, const char **ppsz_name )
+int GetFfmpegCodec( vlc_fourcc_t i_fourcc, int *pi_cat,
+                    int *pi_ffmpeg_codec, const char **ppsz_name )
 {
-    int i;
-
-    for( i = 0; codecs_table[i].i_fourcc != 0; i++ )
+    for( unsigned i = 0; codecs_table[i].i_fourcc != 0; i++ )
     {
         if( codecs_table[i].i_fourcc == i_fourcc )
         {
@@ -1071,12 +1085,10 @@ static int GetFfmpegCodec( vlc_fourcc_t i_fourcc, int *pi_cat,
     return false;
 }
 
-static int GetVlcFourcc( int i_ffmpeg_codec, int *pi_cat,
-                         vlc_fourcc_t *pi_fourcc, const char **ppsz_name )
+int GetVlcFourcc( int i_ffmpeg_codec, int *pi_cat,
+                  vlc_fourcc_t *pi_fourcc, const char **ppsz_name )
 {
-    int i;
-
-    for( i = 0; codecs_table[i].i_codec != 0; i++ )
+    for( unsigned i = 0; codecs_table[i].i_codec != 0; i++ )
     {
         if( codecs_table[i].i_codec == i_ffmpeg_codec )
         {




More information about the vlc-devel mailing list