Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
767ade02
Commit
767ade02
authored
Feb 11, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag_table: convert to a struct
The struct is smaller because it is sparse. Its traversal is also more efficient.
parent
6e05071a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
14 deletions
+22
-14
mp4ff_decoder_plugin.c
src/decoder/mp4ff_decoder_plugin.c
+6
-5
tag_ape.c
src/tag_ape.c
+5
-4
tag_table.h
src/tag_table.h
+11
-5
No files found.
src/decoder/mp4ff_decoder_plugin.c
View file @
767ade02
...
...
@@ -356,16 +356,17 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
mp4ff_close
(
mp4fh
);
}
static
const
char
*
const
mp4ff_tag_names
[
TAG_NUM_OF_ITEM_TYPES
]
=
{
[
TAG_ALBUM_ARTIST
]
=
"album artist"
,
[
TAG_COMPOSER
]
=
"writer"
,
[
TAG_PERFORMER
]
=
"band"
,
static
const
struct
tag_table
mp4ff_tags
[]
=
{
{
"album artist"
,
TAG_ALBUM_ARTIST
},
{
"writer"
,
TAG_COMPOSER
},
{
"band"
,
TAG_PERFORMER
},
{
NULL
,
TAG_NUM_OF_ITEM_TYPES
}
};
static
enum
tag_type
mp4ff_tag_name_parse
(
const
char
*
name
)
{
enum
tag_type
type
=
tag_table_lookup
(
mp4ff_tag_name
s
,
name
);
enum
tag_type
type
=
tag_table_lookup
_i
(
mp4ff_tag
s
,
name
);
if
(
type
==
TAG_NUM_OF_ITEM_TYPES
)
type
=
tag_name_parse_i
(
name
);
...
...
src/tag_ape.c
View file @
767ade02
...
...
@@ -23,15 +23,16 @@
#include "tag_table.h"
#include "ape.h"
static
const
char
*
const
ape_tag_names
[
TAG_NUM_OF_ITEM_TYPES
]
=
{
[
TAG_ALBUM_ARTIST
]
=
"album artist"
,
[
TAG_DATE
]
=
"year"
,
static
const
struct
tag_table
ape_tags
[]
=
{
{
"album artist"
,
TAG_ALBUM_ARTIST
},
{
"year"
,
TAG_DATE
},
{
NULL
,
TAG_NUM_OF_ITEM_TYPES
}
};
static
enum
tag_type
tag_ape_name_parse
(
const
char
*
name
)
{
enum
tag_type
type
=
tag_table_lookup
(
ape_tag_name
s
,
name
);
enum
tag_type
type
=
tag_table_lookup
_i
(
ape_tag
s
,
name
);
if
(
type
==
TAG_NUM_OF_ITEM_TYPES
)
type
=
tag_name_parse_i
(
name
);
...
...
src/tag_table.h
View file @
767ade02
...
...
@@ -24,18 +24,24 @@
#include <glib.h>
struct
tag_table
{
const
char
*
name
;
enum
tag_type
type
;
};
/**
* Looks up a string in a tag translation table (case insensitive).
* Returns TAG_NUM_OF_ITEM_TYPES if the specified name was not found
* in the table.
*/
G_GNUC_PURE
static
inline
enum
tag_type
tag_table_lookup
(
const
char
*
const
*
table
,
const
char
*
name
)
tag_table_lookup
_i
(
const
struct
tag_table
*
table
,
const
char
*
name
)
{
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
i
++
)
if
(
table
[
i
]
!=
NULL
&&
g_ascii_strcasecmp
(
name
,
table
[
i
])
==
0
)
return
(
enum
tag_type
)
i
;
for
(;
table
->
name
!=
NULL
;
++
table
)
if
(
g_ascii_strcasecmp
(
name
,
table
->
name
)
==
0
)
return
table
->
type
;
return
TAG_NUM_OF_ITEM_TYPES
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment