[vlc-commits] fourcc.c: make fourcc lists fit in .rodata

Diego Elio Pettenò git at videolan.org
Wed Sep 5 02:43:43 CEST 2012


vlc | branch: master | Diego Elio Pettenò <flameeyes at flameeyes.eu> | Tue Sep  4 07:25:09 2012 -0700| [0346a35cee7d880f16ad24ca983a0885d85b363d] | committer: Rafaël Carré

fourcc.c: make fourcc lists fit in .rodata

By changing the description from a pointer to an array of characters,
the long tables don't need to be relocated. Unfortunately this adds
30KB of padding zeroes for empty strings.

Since Lookup() returns a custom entry_t object, with a possibly
modified description, this is implemented by creating a new structure
type. With more work it would be possible to simply filling all the
entries with final description and remove the extra matching and entry
manipulation.

Signed-off-by: Diego Elio Pettenò <flameeyes at flameeyes.eu>
Signed-off-by: Rafaël Carré <funman at videolan.org>

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

 src/misc/fourcc.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/misc/fourcc.c b/src/misc/fourcc.c
index 12e97ba..ea599c5 100644
--- a/src/misc/fourcc.c
+++ b/src/misc/fourcc.c
@@ -33,6 +33,14 @@
 #include <vlc_es.h>
 #include <assert.h>
 
+
+typedef struct
+{
+    char p_class[4];
+    char p_fourcc[4];
+    char psz_description[56];
+} staticentry_t;
+
 typedef struct
 {
     char p_class[4];
@@ -57,7 +65,7 @@ typedef struct
 
 
 /* */
-static const entry_t p_list_video[] = {
+static const staticentry_t p_list_video[] = {
 
     B(VLC_CODEC_MPGV, "MPEG-1/2 Video"),
         A("mpgv"),
@@ -947,7 +955,7 @@ static const entry_t p_list_video[] = {
 
     B(0, "")
 };
-static const entry_t p_list_audio[] = {
+static const staticentry_t p_list_audio[] = {
 
     /* Windows Media Audio 1 */
     B(VLC_CODEC_WMA1, "Windows Media Audio 1"),
@@ -1321,7 +1329,7 @@ static const entry_t p_list_audio[] = {
 
     B(0, "")
 };
-static const entry_t p_list_spu[] = {
+static const staticentry_t p_list_spu[] = {
 
     B(VLC_CODEC_SPU, "DVD Subtitles"),
         A("spu "),
@@ -1383,7 +1391,7 @@ static inline vlc_fourcc_t CreateFourcc( const char *psz_fourcc )
 }
 
 /* */
-static entry_t Lookup( const entry_t p_list[], vlc_fourcc_t i_fourcc )
+static entry_t Lookup( const staticentry_t p_list[], vlc_fourcc_t i_fourcc )
 {
     const char *p_class = NULL;
     const char *psz_description = NULL;
@@ -1392,7 +1400,7 @@ static entry_t Lookup( const entry_t p_list[], vlc_fourcc_t i_fourcc )
 
     for( int i = 0; ; i++ )
     {
-        const entry_t *p = &p_list[i];
+        const staticentry_t *p = &p_list[i];
         const vlc_fourcc_t i_entry_fourcc = CreateFourcc( p->p_fourcc );
         const vlc_fourcc_t i_entry_class = CreateFourcc( p->p_class );
 



More information about the vlc-commits mailing list