From 41658bd07a1bc7b48ef12b356f67f11225593ddd Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Sun, 27 Feb 2011 20:49:08 +0000 Subject: [PATCH] Remove some useless code and variables in the area of metadata parsing. Bump codec API. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29438 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs.h | 4 ++-- apps/metadata.h | 4 +--- apps/metadata/mp3.c | 7 ++----- apps/mp3data.c | 23 ++++++++++++++++------- apps/mp3data.h | 8 +------- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/apps/codecs.h b/apps/codecs.h index a3f5d4045a..8a40791106 100644 --- a/apps/codecs.h +++ b/apps/codecs.h @@ -75,12 +75,12 @@ #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ /* increase this every time the api struct changes */ -#define CODEC_API_VERSION 37 +#define CODEC_API_VERSION 38 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define CODEC_MIN_API_VERSION 37 +#define CODEC_MIN_API_VERSION 38 /* codec return codes */ enum codec_status { diff --git a/apps/metadata.h b/apps/metadata.h index 5662c2e840..4c7e94f394 100644 --- a/apps/metadata.h +++ b/apps/metadata.h @@ -221,7 +221,6 @@ struct mp3entry { char* grouping; int discnum; int tracknum; - int version; int layer; int year; unsigned char id3version; @@ -233,7 +232,6 @@ struct mp3entry { 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 */ @@ -241,7 +239,7 @@ struct mp3entry { 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 */ + /* Added for Vorbis, used by mp4 parser as well. */ unsigned long samples; /* number of samples in track */ /* MP3 stream specific info */ diff --git a/apps/metadata/mp3.c b/apps/metadata/mp3.c index 9309242604..feb1a52f77 100644 --- a/apps/metadata/mp3.c +++ b/apps/metadata/mp3.c @@ -100,10 +100,9 @@ static int getsonglength(int fd, struct mp3entry *entry) } } - entry->bitrate = info.bitrate; + entry->bitrate = info.bitrate; entry->frequency = info.frequency; - entry->version = info.version; - entry->layer = info.layer; + entry->layer = info.layer; switch(entry->layer) { #if CONFIG_CODEC==SWCODEC case 0: @@ -149,8 +148,6 @@ static int getsonglength(int fd, struct mp3entry *entry) memcpy(entry->toc, info.toc, sizeof(info.toc)); - entry->vbr_header_pos = info.vbr_header_pos; - /* Update the seek point for the first playable frame */ entry->first_frame_offset = bytecount; logf("First frame is at %lx", entry->first_frame_offset); diff --git a/apps/mp3data.c b/apps/mp3data.c index 44208604bc..f5ef122801 100644 --- a/apps/mp3data.c +++ b/apps/mp3data.c @@ -142,8 +142,10 @@ static bool mp3headerinfo(struct mp3info *info, unsigned long header) if (info->layer == 3) return false; +/* Rockbox: not used info->protection = (header & PROTECTION_MASK) ? true : false; - +*/ + /* Bitrate */ bitindex = (header & BITRATE_MASK) >> 12; info->bitrate = bitrate_table[info->version][info->layer][bitindex]; @@ -187,14 +189,15 @@ static bool mp3headerinfo(struct mp3info *info, unsigned long header) info->ft_num = 1000 * info->ft_den * info->frame_samples / info->frequency; info->channel_mode = (header & CHANNELMODE_MASK) >> 6; +/* Rockbox: not used info->mode_extension = (header & MODE_EXT_MASK) >> 4; info->emphasis = header & EMPHASIS_MASK; - +*/ VDEBUGF( "Header: %08lx, Ver %d, lay %d, bitr %d, freq %ld, " - "chmode %d, mode_ext %d, emph %d, bytes: %d time: %d/%d\n", + "chmode %d, bytes: %d time: %d/%d\n", header, info->version, info->layer+1, info->bitrate, - info->frequency, info->channel_mode, info->mode_extension, - info->emphasis, info->frame_size, info->ft_num, info->ft_den); + info->frequency, info->channel_mode, + info->frame_size, info->ft_num, info->ft_den); return true; } @@ -405,8 +408,9 @@ int get_mp3file_info(int fd, struct mp3info *info) /* DEBUGF("Xing/Info header\n"); */ /* Remember where in the file the Xing header is */ +/* Rockbox: not used info->vbr_header_pos = lseek(fd, 0, SEEK_CUR) - info->frame_size; - +*/ /* We want to skip the Xing frame when playing the stream */ bytecount += info->frame_size; @@ -420,7 +424,10 @@ int get_mp3file_info(int fd, struct mp3info *info) return -5; /* Is it a VBR file? */ - info->is_vbr = info->is_xing_vbr = !memcmp(vbrheader, "Xing", 4); + info->is_vbr = !memcmp(vbrheader, "Xing", 4); +/* Rockbox: not used + info->is_xing_vbr = info->is_vbr; +*/ if (vbrheader[7] & VBR_FRAMES_FLAG) /* Is the frame count there? */ { @@ -506,7 +513,9 @@ int get_mp3file_info(int fd, struct mp3info *info) /* Yes, it is a FhG VBR file */ info->is_vbr = true; +/* Rockbox: not used info->is_vbri_vbr = true; +*/ info->has_toc = false; /* We don't parse the TOC (yet) */ info->byte_count = bytes2int(vbrheader[10], vbrheader[11], diff --git a/apps/mp3data.h b/apps/mp3data.h index 2a6a27ac2d..0fccd62827 100644 --- a/apps/mp3data.h +++ b/apps/mp3data.h @@ -30,27 +30,21 @@ struct mp3info { /* Standard MP3 frame header fields */ int version; int layer; - bool protection; int bitrate; long frequency; int padding; int channel_mode; - int mode_extension; - int emphasis; int frame_size; /* Frame size in bytes */ - int frame_samples; /* Samples per frame */ + int frame_samples;/* Samples per frame */ int ft_num; /* Numerator of frametime in milliseconds */ int ft_den; /* Denominator of frametime in milliseconds */ bool is_vbr; /* True if the file is VBR */ bool has_toc; /* True if there is a VBR header in the file */ - bool is_xing_vbr; /* True if the VBR header is of Xing type */ - bool is_vbri_vbr; /* True if the VBR header is of VBRI type */ unsigned char toc[100]; unsigned long frame_count; /* Number of frames in the file (if VBR) */ unsigned long byte_count; /* File size in bytes */ unsigned long file_time; /* Length of the whole file in milliseconds */ - unsigned long vbr_header_pos; int enc_delay; /* Encoder delay, fetched from LAME header */ int enc_padding; /* Padded samples added to last frame. LAME header */ };