Split id3.c/h into metadata.c/h and metadata/mp3.c. Updated all references. Moved mp3data.c/h from firmware to apps.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18814 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2008-10-15 06:38:51 +00:00
parent a18ef2efd3
commit 51b45d5602
51 changed files with 440 additions and 466 deletions

View file

@ -7,7 +7,6 @@ abrepeat.c
bookmark.c
debug_menu.c
filetypes.c
id3.c
language.c
main.c
menu.c
@ -31,6 +30,7 @@ menus/recording_menu.c
menus/settings_menu.c
menus/sound_menu.c
misc.c
mp3data.c
onplay.c
playlist.c
playlist_catalog.c
@ -130,6 +130,7 @@ eq_arm.S
#endif
#endif
metadata.c
metadata/mp3.c
#if CONFIG_CODEC == SWCODEC
metadata/metadata_common.c
metadata/aiff.c

View file

@ -36,7 +36,7 @@
#include "config.h"
#include "kernel.h"
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "audio.h"
#ifdef RB_PROFILE
#include "profile.h"

View file

@ -25,7 +25,7 @@
#include "codecs.h"
#include "dsp.h"
#include "codeclib.h"
#include "id3.h"
#include "metadata.h"
long mem_ptr;
long bufsize;

View file

@ -25,7 +25,7 @@
#include <stdbool.h>
#include "screens.h"
#include "file.h"
#include "id3.h"
#include "metadata.h"
#define MAX_NAME 80 /* Max length of information strings */
#define MAX_TRACKS 99 /* Max number of tracks in a cuesheet */

View file

@ -23,7 +23,7 @@
#include "screen_access.h"
#include "statusbar.h"
#include "id3.h"
#include "metadata.h"
/* constants used in line_type and as refresh_mode for wps_refresh */
#define WPS_REFRESH_STATIC 1 /* line doesn't change over time */

View file

@ -27,7 +27,7 @@
#include "sound.h"
#include "settings.h"
#if CONFIG_CODEC == SWCODEC
#include "id3.h"
#include "metadata.h"
#endif
#include "icons.h"
#include "powermgmt.h"

View file

@ -1,246 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Daniel Stenberg
*
* 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef ID3_H
#define ID3_H
#include <stdbool.h>
#include "config.h"
#include "file.h"
#define ID3V2_BUF_SIZE 300
/* Audio file types. */
/* NOTE: The values of the AFMT_* items are used for the %fc tag in the WPS
- so new entries MUST be added to the end to maintain compatibility.
*/
enum
{
AFMT_UNKNOWN = 0, /* Unknown file format */
/* start formats */
AFMT_MPA_L1, /* MPEG Audio layer 1 */
AFMT_MPA_L2, /* MPEG Audio layer 2 */
AFMT_MPA_L3, /* MPEG Audio layer 3 */
#if CONFIG_CODEC == SWCODEC
AFMT_AIFF, /* Audio Interchange File Format */
AFMT_PCM_WAV, /* Uncompressed PCM in a WAV file */
AFMT_OGG_VORBIS, /* Ogg Vorbis */
AFMT_FLAC, /* FLAC */
AFMT_MPC, /* Musepack */
AFMT_A52, /* A/52 (aka AC3) audio */
AFMT_WAVPACK, /* WavPack */
AFMT_ALAC, /* Apple Lossless Audio Codec */
AFMT_AAC, /* Advanced Audio Coding (AAC) in M4A container */
AFMT_SHN, /* Shorten */
AFMT_SID, /* SID File Format */
AFMT_ADX, /* ADX File Format */
AFMT_NSF, /* NESM (NES Sound Format) */
AFMT_SPEEX, /* Ogg Speex speech */
AFMT_SPC, /* SPC700 save state */
AFMT_APE, /* Monkey's Audio (APE) */
AFMT_WMA, /* WMAV1/V2 in ASF */
AFMT_MOD, /* Amiga MOD File Format */
AFMT_SAP, /* Amiga 8Bit SAP Format */
#endif
/* add new formats at any index above this line to have a sensible order -
specified array index inits are used */
/* format arrays defined in id3.c */
AFMT_NUM_CODECS,
#if CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING)
/* masks to decompose parts */
CODEC_AFMT_MASK = 0x0fff,
CODEC_TYPE_MASK = 0x7000,
/* switch for specifying codec type when requesting a filename */
CODEC_TYPE_DECODER = (0 << 12), /* default */
CODEC_TYPE_ENCODER = (1 << 12),
#endif /* CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING) */
};
#if CONFIG_CODEC == SWCODEC
#define CODEC_EXTENSION "codec"
#ifdef HAVE_RECORDING
#define ENCODER_SUFFIX "_enc"
enum rec_format_indexes
{
__REC_FORMAT_START_INDEX = -1,
/* start formats */
REC_FORMAT_PCM_WAV,
REC_FORMAT_AIFF,
REC_FORMAT_WAVPACK,
REC_FORMAT_MPA_L3,
/* add new formats at any index above this line to have a sensible order -
specified array index inits are used
REC_FORMAT_CFG_NUM_BITS should allocate enough bits to hold the range
REC_FORMAT_CFG_VALUE_LIST should be in same order as indexes
*/
REC_NUM_FORMATS,
REC_FORMAT_DEFAULT = REC_FORMAT_PCM_WAV,
REC_FORMAT_CFG_NUM_BITS = 2
};
#define REC_FORMAT_CFG_VAL_LIST "wave,aiff,wvpk,mpa3"
/* get REC_FORMAT_* corresponding AFMT_* */
extern const int rec_format_afmt[REC_NUM_FORMATS];
/* get AFMT_* corresponding REC_FORMAT_* */
extern const int afmt_rec_format[AFMT_NUM_CODECS];
#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
{ label, root_fname, enc_root_fname, ext_list }
#else /* !HAVE_RECORDING */
#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
{ label, root_fname, ext_list }
#endif /* HAVE_RECORDING */
#else /* !SWCODEC */
#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
{ label, ext_list }
#endif /* CONFIG_CODEC == SWCODEC */
/* record describing the audio format */
struct afmt_entry
{
char label[8]; /* format label */
#if CONFIG_CODEC == SWCODEC
char *codec_root_fn; /* root codec filename (sans _enc and .codec) */
#ifdef HAVE_RECORDING
char *codec_enc_root_fn; /* filename of encoder codec */
#endif
#endif
char *ext_list; /* double NULL terminated extension
list for type with the first as
the default for recording */
};
/* database of labels and codecs. add formats per above enum */
extern const struct afmt_entry audio_formats[AFMT_NUM_CODECS];
struct mp3entry {
char path[MAX_PATH];
char* title;
char* artist;
char* album;
char* genre_string;
char* disc_string;
char* track_string;
char* year_string;
char* composer;
char* comment;
char* albumartist;
char* grouping;
int discnum;
int tracknum;
int version;
int layer;
int year;
unsigned char id3version;
unsigned int codectype;
unsigned int bitrate;
unsigned long frequency;
unsigned long id3v2len;
unsigned long id3v1len;
unsigned long first_frame_offset; /* Byte offset to first real MP3 frame.
Used for skipping leading garbage to
avoid gaps between tracks. */
unsigned long vbr_header_pos;
unsigned long filesize; /* without headers; in bytes */
unsigned long length; /* song length in ms */
unsigned long elapsed; /* ms played */
int lead_trim; /* Number of samples to skip at the beginning */
int tail_trim; /* Number of samples to remove from the end */
/* Added for Vorbis */
unsigned long samples; /* number of samples in track */
/* MP3 stream specific info */
unsigned long frame_count; /* number of frames in the file (if VBR) */
/* Used for A52/AC3 */
unsigned long bytesperframe; /* number of bytes per frame (if CBR) */
/* Xing VBR fields */
bool vbr;
bool has_toc; /* True if there is a VBR header in the file */
unsigned char toc[100]; /* table of contents */
/* these following two fields are used for local buffering */
char id3v2buf[ID3V2_BUF_SIZE];
char id3v1buf[4][92];
/* resume related */
unsigned long offset; /* bytes played */
int index; /* playlist index */
/* runtime database fields */
long tagcache_idx; /* 0=invalid, otherwise idx+1 */
int rating;
int score;
long playcount;
long lastplayed;
long playtime;
/* replaygain support */
#if CONFIG_CODEC == SWCODEC
char* track_gain_string;
char* album_gain_string;
long track_gain; /* 7.24 signed fixed point. 0 for no gain. */
long album_gain;
long track_peak; /* 7.24 signed fixed point. 0 for no peak. */
long album_peak;
#endif
/* Cuesheet support */
int cuesheet_type; /* 0: none, 1: external, 2: embedded */
/* Musicbrainz Track ID */
char* mb_track_id;
};
enum {
ID3_VER_1_0 = 1,
ID3_VER_1_1,
ID3_VER_2_2,
ID3_VER_2_3,
ID3_VER_2_4
};
bool get_mp3_metadata(int fd, struct mp3entry *entry, const char *filename);
bool mp3info(struct mp3entry *entry, const char *filename);
char* id3_get_num_genre(unsigned int genre_num);
int getid3v2len(int fd);
void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig);
void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig);
#endif

View file

@ -55,7 +55,7 @@
#endif
#include "splash.h"
#if CONFIG_CODEC == SWCODEC
#include "id3.h"
#include "metadata.h"
#include "dsp.h"
#include "menus/eq_menu.h"
#ifdef HAVE_RECORDING

View file

@ -24,23 +24,126 @@
#include <ctype.h>
#include <inttypes.h>
#include "system.h"
#include "playback.h"
#include "debug.h"
#include "logf.h"
#include "cuesheet.h"
#include "metadata.h"
#include "metadata/metadata_parsers.h"
#if CONFIG_CODEC == SWCODEC
/* For trailing tag stripping */
#include "buffering.h"
#include "metadata/metadata_common.h"
#include "metadata/metadata_parsers.h"
#endif /* CONFIG_CODEC == SWCODEC */
const struct afmt_entry audio_formats[AFMT_NUM_CODECS] =
{
/* Unknown file format */
[AFMT_UNKNOWN] =
AFMT_ENTRY("???", NULL, NULL, NULL ),
/* MPEG Audio layer 1 */
[AFMT_MPA_L1] =
AFMT_ENTRY("MP1", "mpa", NULL, "mp1\0" ),
/* MPEG Audio layer 2 */
[AFMT_MPA_L2] =
AFMT_ENTRY("MP2", "mpa", NULL, "mpa\0mp2\0" ),
/* MPEG Audio layer 3 */
[AFMT_MPA_L3] =
AFMT_ENTRY("MP3", "mpa", "mp3_enc", "mp3\0" ),
#if CONFIG_CODEC == SWCODEC
/* Audio Interchange File Format */
[AFMT_AIFF] =
AFMT_ENTRY("AIFF", "aiff", "aiff_enc", "aiff\0aif\0"),
/* Uncompressed PCM in a WAV file */
[AFMT_PCM_WAV] =
AFMT_ENTRY("WAV", "wav", "wav_enc", "wav\0" ),
/* Ogg Vorbis */
[AFMT_OGG_VORBIS] =
AFMT_ENTRY("Ogg", "vorbis", NULL, "ogg\0" ),
/* FLAC */
[AFMT_FLAC] =
AFMT_ENTRY("FLAC", "flac", NULL, "flac\0" ),
/* Musepack */
[AFMT_MPC] =
AFMT_ENTRY("MPC", "mpc", NULL, "mpc\0" ),
/* A/52 (aka AC3) audio */
[AFMT_A52] =
AFMT_ENTRY("AC3", "a52", NULL, "a52\0ac3\0" ),
/* WavPack */
[AFMT_WAVPACK] =
AFMT_ENTRY("WV", "wavpack", "wavpack_enc", "wv\0" ),
/* Apple Lossless Audio Codec */
[AFMT_ALAC] =
AFMT_ENTRY("ALAC", "alac", NULL, "m4a\0m4b\0" ),
/* Advanced Audio Coding in M4A container */
[AFMT_AAC] =
AFMT_ENTRY("AAC", "aac", NULL, "mp4\0" ),
/* Shorten */
[AFMT_SHN] =
AFMT_ENTRY("SHN", "shorten", NULL, "shn\0" ),
/* SID File Format */
[AFMT_SID] =
AFMT_ENTRY("SID", "sid", NULL, "sid\0" ),
/* ADX File Format */
[AFMT_ADX] =
AFMT_ENTRY("ADX", "adx", NULL, "adx\0" ),
/* NESM (NES Sound Format) */
[AFMT_NSF] =
AFMT_ENTRY("NSF", "nsf", NULL, "nsf\0nsfe\0" ),
/* Speex File Format */
[AFMT_SPEEX] =
AFMT_ENTRY("Speex","speex", NULL, "spx\0" ),
/* SPC700 Save State */
[AFMT_SPC] =
AFMT_ENTRY("SPC", "spc", NULL, "spc\0" ),
/* APE (Monkey's Audio) */
[AFMT_APE] =
AFMT_ENTRY("APE", "ape", NULL, "ape\0mac\0" ),
/* WMA (WMAV1/V2 in ASF) */
[AFMT_WMA] =
AFMT_ENTRY("WMA", "wma", NULL, "wma\0wmv\0asf\0" ),
/* Amiga MOD File */
[AFMT_MOD] =
AFMT_ENTRY("MOD", "mod", NULL, "mod\0" ),
/* Amiga SAP File */
[AFMT_SAP] =
AFMT_ENTRY("SAP", "asap", NULL, "sap\0" ),
#endif
};
#if CONFIG_CODEC == SWCODEC && defined (HAVE_RECORDING)
/* get REC_FORMAT_* corresponding AFMT_* */
const int rec_format_afmt[REC_NUM_FORMATS] =
{
/* give AFMT_UNKNOWN by default */
[0 ... REC_NUM_FORMATS-1] = AFMT_UNKNOWN,
/* add new entries below this line */
[REC_FORMAT_AIFF] = AFMT_AIFF,
[REC_FORMAT_MPA_L3] = AFMT_MPA_L3,
[REC_FORMAT_WAVPACK] = AFMT_WAVPACK,
[REC_FORMAT_PCM_WAV] = AFMT_PCM_WAV,
};
/* get AFMT_* corresponding REC_FORMAT_* */
const int afmt_rec_format[AFMT_NUM_CODECS] =
{
/* give -1 by default */
[0 ... AFMT_NUM_CODECS-1] = -1,
/* add new entries below this line */
[AFMT_AIFF] = REC_FORMAT_AIFF,
[AFMT_MPA_L3] = REC_FORMAT_MPA_L3,
[AFMT_WAVPACK] = REC_FORMAT_WAVPACK,
[AFMT_PCM_WAV] = REC_FORMAT_PCM_WAV,
};
#endif /* CONFIG_CODEC == SWCODEC && defined (HAVE_RECORDING) */
/* Simple file type probing by looking at the filename extension. */
unsigned int probe_file_format(const char *filename)
@ -78,6 +181,23 @@ unsigned int probe_file_format(const char *filename)
return AFMT_UNKNOWN;
}
/* Note, that this returns false for successful, true for error! */
bool mp3info(struct mp3entry *entry, const char *filename)
{
int fd;
bool result;
fd = open(filename, O_RDONLY);
if (fd < 0)
return true;
result = !get_metadata(entry, fd, filename);
close(fd);
return result;
}
/* Get metadata for track - return false if parsing showed problems with the
* file that would prevent playback.
*/
@ -314,3 +434,50 @@ void strip_tags(int handle_id)
bufcuttail(handle_id, len);
}
#endif /* CONFIG_CODEC == SWCODEC */
void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig)
{
long offset;
if (orig > dest)
offset = - ((size_t)orig - (size_t)dest);
else
offset = (size_t)dest - (size_t)orig;
if (entry->title)
entry->title += offset;
if (entry->artist)
entry->artist += offset;
if (entry->album)
entry->album += offset;
if (entry->genre_string && !id3_is_genre_string(entry->genre_string))
/* Don't adjust that if it points to an entry of the "genres" array */
entry->genre_string += offset;
if (entry->track_string)
entry->track_string += offset;
if (entry->disc_string)
entry->disc_string += offset;
if (entry->year_string)
entry->year_string += offset;
if (entry->composer)
entry->composer += offset;
if (entry->comment)
entry->comment += offset;
if (entry->albumartist)
entry->albumartist += offset;
if (entry->grouping)
entry->grouping += offset;
#if CONFIG_CODEC == SWCODEC
if (entry->track_gain_string)
entry->track_gain_string += offset;
if (entry->album_gain_string)
entry->album_gain_string += offset;
#endif
if (entry->mb_track_id)
entry->mb_track_id += offset;
}
void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig)
{
memcpy(dest, orig, sizeof(struct mp3entry));
adjust_mp3entry(dest, dest, orig);
}

View file

@ -23,11 +23,228 @@
#define _METADATA_H
#include <stdbool.h>
#include "file.h"
#include "config.h"
#include "id3.h"
/* Audio file types. */
/* NOTE: The values of the AFMT_* items are used for the %fc tag in the WPS
- so new entries MUST be added to the end to maintain compatibility.
*/
enum
{
AFMT_UNKNOWN = 0, /* Unknown file format */
/* start formats */
AFMT_MPA_L1, /* MPEG Audio layer 1 */
AFMT_MPA_L2, /* MPEG Audio layer 2 */
AFMT_MPA_L3, /* MPEG Audio layer 3 */
#if CONFIG_CODEC == SWCODEC
AFMT_AIFF, /* Audio Interchange File Format */
AFMT_PCM_WAV, /* Uncompressed PCM in a WAV file */
AFMT_OGG_VORBIS, /* Ogg Vorbis */
AFMT_FLAC, /* FLAC */
AFMT_MPC, /* Musepack */
AFMT_A52, /* A/52 (aka AC3) audio */
AFMT_WAVPACK, /* WavPack */
AFMT_ALAC, /* Apple Lossless Audio Codec */
AFMT_AAC, /* Advanced Audio Coding (AAC) in M4A container */
AFMT_SHN, /* Shorten */
AFMT_SID, /* SID File Format */
AFMT_ADX, /* ADX File Format */
AFMT_NSF, /* NESM (NES Sound Format) */
AFMT_SPEEX, /* Ogg Speex speech */
AFMT_SPC, /* SPC700 save state */
AFMT_APE, /* Monkey's Audio (APE) */
AFMT_WMA, /* WMAV1/V2 in ASF */
AFMT_MOD, /* Amiga MOD File Format */
AFMT_SAP, /* Amiga 8Bit SAP Format */
#endif
/* add new formats at any index above this line to have a sensible order -
specified array index inits are used */
/* format arrays defined in id3.c */
AFMT_NUM_CODECS,
#if CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING)
/* masks to decompose parts */
CODEC_AFMT_MASK = 0x0fff,
CODEC_TYPE_MASK = 0x7000,
/* switch for specifying codec type when requesting a filename */
CODEC_TYPE_DECODER = (0 << 12), /* default */
CODEC_TYPE_ENCODER = (1 << 12),
#endif /* CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING) */
};
#if CONFIG_CODEC == SWCODEC
#define CODEC_EXTENSION "codec"
#ifdef HAVE_RECORDING
#define ENCODER_SUFFIX "_enc"
enum rec_format_indexes
{
__REC_FORMAT_START_INDEX = -1,
/* start formats */
REC_FORMAT_PCM_WAV,
REC_FORMAT_AIFF,
REC_FORMAT_WAVPACK,
REC_FORMAT_MPA_L3,
/* add new formats at any index above this line to have a sensible order -
specified array index inits are used
REC_FORMAT_CFG_NUM_BITS should allocate enough bits to hold the range
REC_FORMAT_CFG_VALUE_LIST should be in same order as indexes
*/
REC_NUM_FORMATS,
REC_FORMAT_DEFAULT = REC_FORMAT_PCM_WAV,
REC_FORMAT_CFG_NUM_BITS = 2
};
#define REC_FORMAT_CFG_VAL_LIST "wave,aiff,wvpk,mpa3"
/* get REC_FORMAT_* corresponding AFMT_* */
extern const int rec_format_afmt[REC_NUM_FORMATS];
/* get AFMT_* corresponding REC_FORMAT_* */
extern const int afmt_rec_format[AFMT_NUM_CODECS];
#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
{ label, root_fname, enc_root_fname, ext_list }
#else /* !HAVE_RECORDING */
#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
{ label, root_fname, ext_list }
#endif /* HAVE_RECORDING */
#else /* !SWCODEC */
#define AFMT_ENTRY(label, root_fname, enc_root_fname, ext_list) \
{ label, ext_list }
#endif /* CONFIG_CODEC == SWCODEC */
/** Database of audio formats **/
/* record describing the audio format */
struct afmt_entry
{
char label[8]; /* format label */
#if CONFIG_CODEC == SWCODEC
char *codec_root_fn; /* root codec filename (sans _enc and .codec) */
#ifdef HAVE_RECORDING
char *codec_enc_root_fn; /* filename of encoder codec */
#endif
#endif
char *ext_list; /* double NULL terminated extension
list for type with the first as
the default for recording */
};
/* database of labels and codecs. add formats per above enum */
extern const struct afmt_entry audio_formats[AFMT_NUM_CODECS];
#define ID3V2_BUF_SIZE 300
enum {
ID3_VER_1_0 = 1,
ID3_VER_1_1,
ID3_VER_2_2,
ID3_VER_2_3,
ID3_VER_2_4
};
struct mp3entry {
char path[MAX_PATH];
char* title;
char* artist;
char* album;
char* genre_string;
char* disc_string;
char* track_string;
char* year_string;
char* composer;
char* comment;
char* albumartist;
char* grouping;
int discnum;
int tracknum;
int version;
int layer;
int year;
unsigned char id3version;
unsigned int codectype;
unsigned int bitrate;
unsigned long frequency;
unsigned long id3v2len;
unsigned long id3v1len;
unsigned long first_frame_offset; /* Byte offset to first real MP3 frame.
Used for skipping leading garbage to
avoid gaps between tracks. */
unsigned long vbr_header_pos;
unsigned long filesize; /* without headers; in bytes */
unsigned long length; /* song length in ms */
unsigned long elapsed; /* ms played */
int lead_trim; /* Number of samples to skip at the beginning */
int tail_trim; /* Number of samples to remove from the end */
/* Added for Vorbis */
unsigned long samples; /* number of samples in track */
/* MP3 stream specific info */
unsigned long frame_count; /* number of frames in the file (if VBR) */
/* Used for A52/AC3 */
unsigned long bytesperframe; /* number of bytes per frame (if CBR) */
/* Xing VBR fields */
bool vbr;
bool has_toc; /* True if there is a VBR header in the file */
unsigned char toc[100]; /* table of contents */
/* these following two fields are used for local buffering */
char id3v2buf[ID3V2_BUF_SIZE];
char id3v1buf[4][92];
/* resume related */
unsigned long offset; /* bytes played */
int index; /* playlist index */
/* runtime database fields */
long tagcache_idx; /* 0=invalid, otherwise idx+1 */
int rating;
int score;
long playcount;
long lastplayed;
long playtime;
/* replaygain support */
#if CONFIG_CODEC == SWCODEC
char* track_gain_string;
char* album_gain_string;
long track_gain; /* 7.24 signed fixed point. 0 for no gain. */
long album_gain;
long track_peak; /* 7.24 signed fixed point. 0 for no peak. */
long album_peak;
#endif
/* Cuesheet support */
int cuesheet_type; /* 0: none, 1: external, 2: embedded */
/* Musicbrainz Track ID */
char* mb_track_id;
};
unsigned int probe_file_format(const char *filename);
bool get_metadata(struct mp3entry* id3, int fd, const char* trackname);
bool mp3info(struct mp3entry *entry, const char *filename);
void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig);
void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig);
#if CONFIG_CODEC == SWCODEC
void strip_tags(int handle_id);
#endif

View file

@ -19,7 +19,7 @@
*
****************************************************************************/
#include "id3.h"
#include "metadata.h"
#include "logf.h"
#include "metadata_parsers.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "debug.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "structec.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "rbunicode.h"

View file

@ -25,7 +25,7 @@
#include <ctype.h>
#include <inttypes.h>
#include "id3.h"
#include "metadata.h"
#include "replaygain.h"
#include "debug.h"
#include "rbunicode.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "logf.h"

View file

@ -25,8 +25,9 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "replaygain.h"
/* Skip an ID3v2 tag if it can be found. We assume the tag is located at the

View file

@ -18,7 +18,7 @@
* KIND, either express or implied.
*
****************************************************************************/
#include "id3.h"
#include "metadata.h"
#ifdef ROCKBOX_BIG_ENDIAN
#define IS_BIG_ENDIAN 1

View file

@ -18,7 +18,11 @@
* KIND, either express or implied.
*
****************************************************************************/
#include "id3.h"
char* id3_get_num_genre(unsigned int genre_num);
bool id3_is_genre_string(const char *string);
int getid3v2len(int fd);
bool get_mp3_metadata(int fd, struct mp3entry* id3, const char *filename);
bool get_adx_metadata(int fd, struct mp3entry* id3);
bool get_aiff_metadata(int fd, struct mp3entry* id3);

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "rbunicode.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"

View file

@ -39,117 +39,11 @@
#include "file.h"
#include "logf.h"
#include "id3.h"
#include "mp3data.h"
#include "system.h"
#include "replaygain.h"
#include "rbunicode.h"
/** Database of audio formats **/
const struct afmt_entry audio_formats[AFMT_NUM_CODECS] =
{
/* Unknown file format */
[AFMT_UNKNOWN] =
AFMT_ENTRY("???", NULL, NULL, NULL ),
/* MPEG Audio layer 1 */
[AFMT_MPA_L1] =
AFMT_ENTRY("MP1", "mpa", NULL, "mp1\0" ),
/* MPEG Audio layer 2 */
[AFMT_MPA_L2] =
AFMT_ENTRY("MP2", "mpa", NULL, "mpa\0mp2\0" ),
/* MPEG Audio layer 3 */
[AFMT_MPA_L3] =
AFMT_ENTRY("MP3", "mpa", "mp3_enc", "mp3\0" ),
#if CONFIG_CODEC == SWCODEC
/* Audio Interchange File Format */
[AFMT_AIFF] =
AFMT_ENTRY("AIFF", "aiff", "aiff_enc", "aiff\0aif\0"),
/* Uncompressed PCM in a WAV file */
[AFMT_PCM_WAV] =
AFMT_ENTRY("WAV", "wav", "wav_enc", "wav\0" ),
/* Ogg Vorbis */
[AFMT_OGG_VORBIS] =
AFMT_ENTRY("Ogg", "vorbis", NULL, "ogg\0" ),
/* FLAC */
[AFMT_FLAC] =
AFMT_ENTRY("FLAC", "flac", NULL, "flac\0" ),
/* Musepack */
[AFMT_MPC] =
AFMT_ENTRY("MPC", "mpc", NULL, "mpc\0" ),
/* A/52 (aka AC3) audio */
[AFMT_A52] =
AFMT_ENTRY("AC3", "a52", NULL, "a52\0ac3\0" ),
/* WavPack */
[AFMT_WAVPACK] =
AFMT_ENTRY("WV", "wavpack", "wavpack_enc", "wv\0" ),
/* Apple Lossless Audio Codec */
[AFMT_ALAC] =
AFMT_ENTRY("ALAC", "alac", NULL, "m4a\0m4b\0" ),
/* Advanced Audio Coding in M4A container */
[AFMT_AAC] =
AFMT_ENTRY("AAC", "aac", NULL, "mp4\0" ),
/* Shorten */
[AFMT_SHN] =
AFMT_ENTRY("SHN", "shorten", NULL, "shn\0" ),
/* SID File Format */
[AFMT_SID] =
AFMT_ENTRY("SID", "sid", NULL, "sid\0" ),
/* ADX File Format */
[AFMT_ADX] =
AFMT_ENTRY("ADX", "adx", NULL, "adx\0" ),
/* NESM (NES Sound Format) */
[AFMT_NSF] =
AFMT_ENTRY("NSF", "nsf", NULL, "nsf\0nsfe\0" ),
/* Speex File Format */
[AFMT_SPEEX] =
AFMT_ENTRY("Speex","speex", NULL, "spx\0" ),
/* SPC700 Save State */
[AFMT_SPC] =
AFMT_ENTRY("SPC", "spc", NULL, "spc\0" ),
/* APE (Monkey's Audio) */
[AFMT_APE] =
AFMT_ENTRY("APE", "ape", NULL, "ape\0mac\0" ),
/* WMA (WMAV1/V2 in ASF) */
[AFMT_WMA] =
AFMT_ENTRY("WMA", "wma", NULL, "wma\0wmv\0asf\0" ),
/* Amiga MOD File */
[AFMT_MOD] =
AFMT_ENTRY("MOD", "mod", NULL, "mod\0" ),
/* Amiga SAP File */
[AFMT_SAP] =
AFMT_ENTRY("SAP", "asap", NULL, "sap\0" ),
#endif
};
#if CONFIG_CODEC == SWCODEC && defined (HAVE_RECORDING)
/* get REC_FORMAT_* corresponding AFMT_* */
const int rec_format_afmt[REC_NUM_FORMATS] =
{
/* give AFMT_UNKNOWN by default */
[0 ... REC_NUM_FORMATS-1] = AFMT_UNKNOWN,
/* add new entries below this line */
[REC_FORMAT_AIFF] = AFMT_AIFF,
[REC_FORMAT_MPA_L3] = AFMT_MPA_L3,
[REC_FORMAT_WAVPACK] = AFMT_WAVPACK,
[REC_FORMAT_PCM_WAV] = AFMT_PCM_WAV,
};
/* get AFMT_* corresponding REC_FORMAT_* */
const int afmt_rec_format[AFMT_NUM_CODECS] =
{
/* give -1 by default */
[0 ... AFMT_NUM_CODECS-1] = -1,
/* add new entries below this line */
[AFMT_AIFF] = REC_FORMAT_AIFF,
[AFMT_MPA_L3] = REC_FORMAT_MPA_L3,
[AFMT_WAVPACK] = REC_FORMAT_WAVPACK,
[AFMT_PCM_WAV] = REC_FORMAT_PCM_WAV,
};
#endif /* CONFIG_CODEC == SWCODEC && defined (HAVE_RECORDING) */
/****/
static unsigned long unsync(unsigned long b0,
unsigned long b1,
unsigned long b2,
@ -200,7 +94,7 @@ char* id3_get_num_genre(unsigned int genre_num)
}
/* True if the string is from the "genres" array */
static bool id3_is_genre_string(const char *string)
bool id3_is_genre_string(const char *string)
{
return ( string >= genres[0] &&
string <= genres[sizeof(genres)/sizeof(char*) - 1] );
@ -1233,70 +1127,6 @@ bool get_mp3_metadata(int fd, struct mp3entry *entry, const char *filename)
return true;
}
/* Note, that this returns false for successful, true for error! */
bool mp3info(struct mp3entry *entry, const char *filename)
{
int fd;
bool result;
fd = open(filename, O_RDONLY);
if (fd < 0)
return true;
result = !get_mp3_metadata(fd, entry, filename);
close(fd);
return result;
}
void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig)
{
long offset;
if (orig > dest)
offset = - ((size_t)orig - (size_t)dest);
else
offset = (size_t)dest - (size_t)orig;
if (entry->title)
entry->title += offset;
if (entry->artist)
entry->artist += offset;
if (entry->album)
entry->album += offset;
if (entry->genre_string && !id3_is_genre_string(entry->genre_string))
/* Don't adjust that if it points to an entry of the "genres" array */
entry->genre_string += offset;
if (entry->track_string)
entry->track_string += offset;
if (entry->disc_string)
entry->disc_string += offset;
if (entry->year_string)
entry->year_string += offset;
if (entry->composer)
entry->composer += offset;
if (entry->comment)
entry->comment += offset;
if (entry->albumartist)
entry->albumartist += offset;
if (entry->grouping)
entry->grouping += offset;
#if CONFIG_CODEC == SWCODEC
if (entry->track_gain_string)
entry->track_gain_string += offset;
if (entry->album_gain_string)
entry->album_gain_string += offset;
#endif
if (entry->mb_track_id)
entry->mb_track_id += offset;
}
void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig)
{
memcpy(dest, orig, sizeof(struct mp3entry));
adjust_mp3entry(dest, dest, orig);
}
#ifdef DEBUG_STANDALONE
char *secs2str(int ms)

View file

@ -26,7 +26,7 @@
#include "system.h"
#include "errno.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "logf.h"

View file

@ -22,7 +22,7 @@
#include <string.h>
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "logf.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "logf.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "rbunicode.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "debug.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "structec.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"

View file

@ -25,7 +25,7 @@
#include <inttypes.h>
#include "system.h"
#include "id3.h"
#include "metadata.h"
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "logf.h"

View file

@ -26,7 +26,7 @@
#include "debug.h"
#include "panic.h"
#include "id3.h"
#include "metadata.h"
#include "mpeg.h"
#include "audio.h"
#include "ata.h"

View file

@ -22,7 +22,7 @@
#define _MPEG_H_
#include <stdbool.h>
#include "id3.h"
#include "metadata.h"
#define MPEG_SWAP_CHUNKSIZE 0x2000
#define MPEG_HIGH_WATER 2 /* We leave 2 bytes empty because otherwise we

View file

@ -37,7 +37,7 @@
#include "kernel.h"
#include "keyboard.h"
#include "mp3data.h"
#include "id3.h"
#include "metadata.h"
#include "screens.h"
#include "tree.h"
#include "buffer.h"

View file

@ -25,7 +25,7 @@
#include <stdbool.h>
#include "file.h"
#include "kernel.h"
#include "id3.h"
#include "metadata.h"
#define PLAYLIST_ATTR_QUEUED 0x01
#define PLAYLIST_ATTR_INSERTED 0x02

View file

@ -52,7 +52,7 @@ void* plugin_get_buffer(size_t *buffer_size);
#include "usb.h"
#include "font.h"
#include "lcd.h"
#include "id3.h"
#include "metadata.h"
#include "sound.h"
#include "mpeg.h"
#include "audio.h"

View file

@ -23,7 +23,7 @@
#include "sprintf.h"
#include "system.h"
#include "albumart.h"
#include "id3.h"
#include "metadata.h"
#include "gwps.h"
#include "buffering.h"
#include "dircache.h"

View file

@ -25,7 +25,7 @@
#ifdef HAVE_ALBUMART
#include <stdbool.h>
#include "id3.h"
#include "metadata.h"
#include "gwps.h"
/* Look for albumart bitmap in the same dir as the track and in its parent dir.

View file

@ -28,7 +28,7 @@
#include "settings.h"
#include "id3.h"
#include "metadata.h"
#include "icons.h"
const unsigned char bitmap_icons_5x8[][5] =

View file

@ -24,6 +24,7 @@
#ifndef PLUGIN
#include <lcd.h>
#include "metadata.h"
#ifdef HAVE_LCD_BITMAP
@ -88,7 +89,7 @@ enum Glyphs_4x8 {
extern const unsigned char bitmap_glyphs_4x8[Glyph_4x8Last][4];
#define BM_MPA_L3_M_WIDTH 6
#ifdef ID3_H
/* This enum is redundant but sort of in keeping with the style */
enum rec_format_18x8 {
Format_18x8_AIFF = REC_FORMAT_AIFF,
@ -98,7 +99,7 @@ enum rec_format_18x8 {
Format_18x8Last = REC_NUM_FORMATS
};
extern const unsigned char bitmap_formats_18x8[Format_18x8Last][18];
#endif /* ID3_H */
#endif /* CONFIG_CODEC == SWCODEC && defined (HAVE_RECORDING) */
extern const unsigned char bitmap_icons_5x8[Icon5x8Last][5];

View file

@ -30,7 +30,7 @@
#include "general.h"
#include "audio.h"
#include "sound.h"
#include "id3.h"
#include "metadata.h"
#ifdef HAVE_SPDIF_IN
#include "spdif.h"
#endif

View file

@ -27,7 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <system.h>
#include "id3.h"
#include "metadata.h"
#include "debug.h"
#include "replaygain.h"

View file

@ -22,7 +22,7 @@
#ifndef _REPLAYGAIN_H
#define _REPLAYGAIN_H
#include "id3.h"
#include "metadata.h"
long get_replaygain_int(long int_gain);
long parse_replaygain(const char* key, const char* value,

View file

@ -46,7 +46,7 @@
#include "action.h"
#include "talk.h"
#include "misc.h"
#include "id3.h"
#include "metadata.h"
#include "screens.h"
#include "debug.h"
#include "led.h"

View file

@ -27,7 +27,7 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging
#include "sprintf.h"
#include "playback.h"
#include "logf.h"
#include "id3.h"
#include "metadata.h"
#include "kernel.h"
#include "audio.h"
#include "buffer.h"

View file

@ -69,7 +69,7 @@
#include "string.h"
#include "usb.h"
#include "metadata.h"
#include "id3.h"
#include "metadata.h"
#include "tagcache.h"
#include "buffer.h"
#include "crc32.h"

View file

@ -22,7 +22,7 @@
#ifndef _TAGCACHE_H
#define _TAGCACHE_H
#include "id3.h"
#include "metadata.h"
/**
Note: When adding new tags, make sure to update index_entry_ec in

View file

@ -36,7 +36,7 @@
#include "audio.h"
#include "lang.h"
#include "talk.h"
#include "id3.h"
#include "metadata.h"
#include "logf.h"
#include "bitswap.h"
#include "structec.h"

View file

@ -180,7 +180,6 @@ drivers/tuner/tea5767.c
#if CONFIG_CODEC != SWCODEC
mp3_playback.c
#endif /* CONFIG_CODEC != SWCODEC */
mp3data.c
sound.c
#if CONFIG_CODEC == SWCODEC