Mercurial > audlegacy-plugins
diff src/aac/mp4ff/mp4meta.c @ 3005:3d6a2732f26a
Update mp4ff as well. Eternal glory for the one who finds the hidden PACKAGE in the about dialog.
| author | Tony Vroon <chainsaw@gentoo.org> |
|---|---|
| date | Wed, 08 Apr 2009 22:16:01 +0100 |
| parents | 22a470857579 |
| children | 281fc9f7f126 |
line wrap: on
line diff
--- a/src/aac/mp4ff/mp4meta.c Wed Apr 08 20:12:57 2009 +0100 +++ b/src/aac/mp4ff/mp4meta.c Wed Apr 08 22:16:01 2009 +0100 @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: mp4meta.c,v 1.13 2004/01/11 15:52:18 menno Exp $ +** $Id: mp4meta.c,v 1.21 2009/01/19 23:56:30 menno Exp $ **/ #ifdef USE_TAGGING @@ -32,7 +35,9 @@ #include <string.h> #include "mp4ffint.h" -int32_t mp4ff_tag_add_field_len(mp4ff_metadata_t *tags, const char *item, const char *value, uint32_t valuelen) + + +static int32_t mp4ff_tag_add_field(mp4ff_metadata_t *tags, const char *item, const char *value) { void *backup = (void *)tags->tags; @@ -45,13 +50,7 @@ return 0; } else { tags->tags[tags->count].item = strdup(item); - - /* ugly hack to make covers work */ - tags->tags[tags->count].value = malloc(valuelen+1); - memcpy(tags->tags[tags->count].value, value, valuelen); - tags->tags[tags->count].value[valuelen] = '\0'; - - tags->tags[tags->count].value_length = valuelen; + tags->tags[tags->count].value = strdup(value); if (!tags->tags[tags->count].item || !tags->tags[tags->count].value) { @@ -59,7 +58,6 @@ if (!tags->tags[tags->count].value) free (tags->tags[tags->count].value); tags->tags[tags->count].item = NULL; tags->tags[tags->count].value = NULL; - tags->tags[tags->count].value_length = 0; return 0; } @@ -68,12 +66,7 @@ } } -int32_t mp4ff_tag_add_field(mp4ff_metadata_t *tags, const char *item, const char *value) -{ - return mp4ff_tag_add_field_len(tags, item, value, strlen(value)); -} - -int32_t mp4ff_tag_set_field(mp4ff_metadata_t *tags, const char *item, const char *value) +static int32_t mp4ff_tag_set_field(mp4ff_metadata_t *tags, const char *item, const char *value) { unsigned int i; @@ -85,7 +78,6 @@ { free(tags->tags[i].value); tags->tags[i].value = strdup(value); - tags->tags[i].value_length = strlen(value); return 1; } } @@ -111,7 +103,7 @@ return 0; } -const char* ID3v1GenreList[] = { +static const char* ID3v1GenreList[] = { "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", @@ -163,7 +155,7 @@ } -int32_t TrackToString(char** str, const uint16_t track, const uint16_t totalTracks) +static int32_t TrackToString(char** str, const uint16_t track, const uint16_t totalTracks) { char temp[32]; sprintf(temp, "%.5u of %.5u", track, totalTracks); @@ -171,12 +163,18 @@ return 0; } -int32_t mp4ff_set_metadata_name(mp4ff_t *f, const uint8_t atom_type, unsigned char **name) +static int32_t mp4ff_set_metadata_name(mp4ff_t *f, const uint8_t atom_type, char **name) { - char *tag_names[] = { + static char *tag_names[] = { "unknown", "title", "artist", "writer", "album", "date", "tool", "comment", "genre", "track", - "disc", "compilation", "genre", "tempo", "cover" + "disc", "compilation", "genre", "tempo", "cover", + "album_artist", "contentgroup", "lyrics", "description", + "network", "show", "episodename", + "sorttitle", "sortalbum", "sortartist", "sortalbumartist", + "sortwriter", "sortshow", + "season", "episode", "podcast" + }; uint8_t tag_idx = 0; @@ -196,23 +194,39 @@ case ATOM_GENRE2: tag_idx = 12; break; case ATOM_TEMPO: tag_idx = 13; break; case ATOM_COVER: tag_idx = 14; break; + case ATOM_ALBUM_ARTIST: tag_idx = 15; break; + case ATOM_CONTENTGROUP: tag_idx = 16; break; + case ATOM_LYRICS: tag_idx = 17; break; + case ATOM_DESCRIPTION: tag_idx = 18; break; + case ATOM_NETWORK: tag_idx = 19; break; + case ATOM_SHOW: tag_idx = 20; break; + case ATOM_EPISODENAME: tag_idx = 21; break; + case ATOM_SORTTITLE: tag_idx = 22; break; + case ATOM_SORTALBUM: tag_idx = 23; break; + case ATOM_SORTARTIST: tag_idx = 24; break; + case ATOM_SORTALBUMARTIST: tag_idx = 25; break; + case ATOM_SORTWRITER: tag_idx = 26; break; + case ATOM_SORTSHOW: tag_idx = 27; break; + case ATOM_SEASON: tag_idx = 28; break; + case ATOM_EPISODE: tag_idx = 29; break; + case ATOM_PODCAST: tag_idx = 30; break; default: tag_idx = 0; break; } - *name = (unsigned char*)strdup(tag_names[tag_idx]); + *name = strdup(tag_names[tag_idx]); return 0; } -int32_t mp4ff_parse_tag(mp4ff_t *f, const uint8_t parent_atom_type, const int32_t size) +static int32_t mp4ff_parse_tag(mp4ff_t *f, const uint8_t parent_atom_type, const int32_t size) { uint8_t atom_type; uint8_t header_size = 0; uint64_t subsize, sumsize = 0; - unsigned char * name = NULL; - unsigned char * data = NULL; - uint32_t datalen = 0; - uint32_t done = 0; + char * name = NULL; + char * data = NULL; + uint32_t done = 0; + while (sumsize < size) { @@ -251,14 +265,22 @@ done = 1; } } else if (parent_atom_type == ATOM_TRACK || parent_atom_type == ATOM_DISC) { - if (!done && subsize - header_size >= 8 + 8) + /* if (!done && subsize - header_size >= 8 + 8) */ + /* modified by AJS */ + if ( !done && (subsize - header_size) >= + (sizeof(char) + sizeof(uint8_t)*3 + sizeof(uint32_t) + /* version + flags + reserved */ + + sizeof(uint16_t) /* leading uint16_t */ + + sizeof(uint16_t) /* track / disc */ + + sizeof(uint16_t)) /* totaltracks / totaldiscs */ + ) { uint16_t index,total; char temp[32]; mp4ff_read_int16(f); index = mp4ff_read_int16(f); total = mp4ff_read_int16(f); - mp4ff_read_int16(f); + /* modified by AJS */ + /* mp4ff_read_int16(f); */ sprintf(temp,"%d",index); mp4ff_tag_add_field(&(f->tags), parent_atom_type == ATOM_TRACK ? "track" : "disc", temp); @@ -273,7 +295,6 @@ { if (data) {free(data);data = NULL;} data = mp4ff_read_string(f,(uint32_t)(subsize-(header_size+8))); - datalen = (uint32_t)(subsize-(header_size+8)); } } else if (atom_type == ATOM_NAME) { if (!done) @@ -294,7 +315,7 @@ if (!done) { if (name == NULL) mp4ff_set_metadata_name(f, parent_atom_type, &name); - if (name) mp4ff_tag_add_field_len(&(f->tags), (char *)name, (char *)data, datalen); + if (name) mp4ff_tag_add_field(&(f->tags), name, data); } free(data); @@ -312,6 +333,8 @@ while (sumsize < size) { subsize = mp4ff_atom_read_header(f, &atom_type, &header_size); + if (subsize == 0) + break; mp4ff_parse_tag(f, atom_type, (uint32_t)(subsize-header_size)); sumsize += subsize; } @@ -321,7 +344,7 @@ /* find a metadata item by name */ /* returns 0 if item found, 1 if no such item */ -int32_t mp4ff_meta_find_by_name(const mp4ff_t *f, const char *item, char **value) +static int32_t mp4ff_meta_find_by_name(const mp4ff_t *f, const char *item, char **value) { uint32_t i; @@ -329,13 +352,8 @@ { if (!stricmp(f->tags.tags[i].item, item)) { - uint32_t value_length = f->tags.tags[i].value_length; - - if (value_length > 0) { - *value = malloc(value_length+1); - memcpy(*value, f->tags.tags[i].value, value_length+1); - return value_length; - } + *value = strdup(f->tags.tags[i].value); + return 1; } } @@ -410,11 +428,21 @@ return mp4ff_meta_find_by_name(f, "track", value); } +int32_t mp4ff_meta_get_totaltracks(const mp4ff_t *f, char **value) +{ + return mp4ff_meta_find_by_name(f, "totaltracks", value); +} + int32_t mp4ff_meta_get_disc(const mp4ff_t *f, char **value) { return mp4ff_meta_find_by_name(f, "disc", value); } +int32_t mp4ff_meta_get_totaldiscs(const mp4ff_t *f, char **value) +{ + return mp4ff_meta_find_by_name(f, "totaldiscs", value); +} + int32_t mp4ff_meta_get_compilation(const mp4ff_t *f, char **value) { return mp4ff_meta_find_by_name(f, "compilation", value); @@ -430,4 +458,4 @@ return mp4ff_meta_find_by_name(f, "cover", value); } -#endif +#endif \ No newline at end of file
