Skip to content

Commit

Permalink
fourcc.c: make fourcc lists fit in .rodata
Browse files Browse the repository at this point in the history
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ò <[email protected]>
Signed-off-by: Rafaël Carré <[email protected]>
  • Loading branch information
Flameeyes authored and funman committed Sep 5, 2012
1 parent fbe2c9b commit 0346a35
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/misc/fourcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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 "),
Expand Down Expand Up @@ -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;
Expand All @@ -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 );

Expand Down

0 comments on commit 0346a35

Please sign in to comment.