Applied patch "[ 1232957 ] MP3 metadata fixes for software codec".
Thanks to Magnus Holmgren. Now metadata reading is better with improved performance for mp3 files. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7030 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1e5119b77b
commit
5c2c991d14
9 changed files with 19 additions and 23 deletions
|
@ -74,7 +74,6 @@ struct codec_api ci = {
|
|||
0, /* filesize */
|
||||
0, /* curpos */
|
||||
NULL, /* id3 */
|
||||
NULL, /* mp3data */
|
||||
NULL, /* taginfo_ready */
|
||||
false, /* stop_codec */
|
||||
false, /* reload_codec */
|
||||
|
|
|
@ -121,7 +121,6 @@ struct codec_api {
|
|||
|
||||
/* For gapless mp3 */
|
||||
struct mp3entry *id3; /* TAG metadata pointer */
|
||||
struct mp3info *mp3data; /* MP3 metadata pointer */
|
||||
bool *taginfo_ready; /* Is metadata read */
|
||||
|
||||
/* Codec should periodically check if stop_codec is set to true.
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "playback.h"
|
||||
#include "dsp.h"
|
||||
#include "mp3data.h"
|
||||
#include "lib/codeclib.h"
|
||||
|
||||
struct mad_stream Stream IDATA_ATTR;
|
||||
|
@ -61,7 +60,6 @@ extern char iramend[];
|
|||
enum codec_status codec_start(struct codec_api* api)
|
||||
{
|
||||
struct codec_api *ci = api;
|
||||
struct mp3info *info;
|
||||
int Status = 0;
|
||||
size_t size;
|
||||
int file_end;
|
||||
|
@ -115,7 +113,6 @@ enum codec_status codec_start(struct codec_api* api)
|
|||
for gapless playback */
|
||||
next_track:
|
||||
|
||||
info = ci->mp3data;
|
||||
first_frame = false;
|
||||
file_end = 0;
|
||||
OutputPtr = OutputBuffer;
|
||||
|
@ -128,24 +125,24 @@ enum codec_status codec_start(struct codec_api* api)
|
|||
|
||||
ci->request_buffer(&size, ci->id3->first_frame_offset);
|
||||
ci->advance_buffer(size);
|
||||
|
||||
if (info->enc_delay >= 0 && info->enc_padding >= 0) {
|
||||
stop_skip = info->enc_padding - mpeg_latency[info->layer];
|
||||
|
||||
if (ci->id3->lead_trim >= 0 && ci->id3->tail_trim >= 0) {
|
||||
stop_skip = ci->id3->tail_trim - mpeg_latency[ci->id3->layer];
|
||||
if (stop_skip < 0) stop_skip = 0;
|
||||
start_skip = info->enc_delay + mpeg_latency[info->layer];
|
||||
start_skip = ci->id3->lead_trim + mpeg_latency[ci->id3->layer];
|
||||
} else {
|
||||
stop_skip = 0;
|
||||
/* We want to skip this amount anyway */
|
||||
start_skip = mpeg_latency[info->layer];
|
||||
start_skip = mpeg_latency[ci->id3->layer];
|
||||
}
|
||||
|
||||
/* NOTE: currently this doesn't work, the below calculated samples_count
|
||||
seems to be right, but sometimes libmad just can't supply us with
|
||||
all the data we need... */
|
||||
if (info->frame_count) {
|
||||
if (ci->id3->frame_count) {
|
||||
/* TODO: 1152 is the frame size in samples for MPEG1 layer 2 and layer 3,
|
||||
it's probably not correct at all for MPEG2 and layer 1 */
|
||||
samplecount = info->frame_count*1152 - (start_skip + stop_skip);
|
||||
samplecount = ci->id3->frame_count*1152 - (start_skip + stop_skip);
|
||||
samplesdone = ci->id3->elapsed * frequency_divider / 10;
|
||||
} else {
|
||||
samplecount = ci->id3->length * frequency_divider / 10;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "metadata.h"
|
||||
#include "mp3_playback.h"
|
||||
#include "mp3data.h"
|
||||
#include "logf.h"
|
||||
#include "atoi.h"
|
||||
|
||||
|
@ -113,10 +112,6 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
|
|||
mp3info(&track->id3, trackname, v1first);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
/* This is too slow to execute on some files. */
|
||||
get_mp3file_info(fd, &track->mp3data);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
/*
|
||||
logf("T:%s", track->id3.title);
|
||||
logf("L:%d", track->id3.length);
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "audio.h"
|
||||
#include "logf.h"
|
||||
#include "mp3_playback.h"
|
||||
#include "mp3data.h"
|
||||
#include "usb.h"
|
||||
#include "status.h"
|
||||
#include "main_menu.h"
|
||||
|
@ -738,7 +737,6 @@ bool loadcodec(const char *trackname, bool start_play)
|
|||
cur_ti = &tracks[track_widx];
|
||||
ci.filesize = cur_ti->filesize;
|
||||
ci.id3 = (struct mp3entry *)&cur_ti->id3;
|
||||
ci.mp3data = (struct mp3info *)&cur_ti->mp3data;
|
||||
ci.taginfo_ready = (bool *)&cur_ti->taginfo_ready;
|
||||
ci.curpos = 0;
|
||||
playing = true;
|
||||
|
@ -1179,7 +1177,6 @@ void audio_update_trackinfo(void)
|
|||
cur_ti->id3.elapsed = 0;
|
||||
cur_ti->id3.offset = 0;
|
||||
ci.id3 = (struct mp3entry *)&cur_ti->id3;
|
||||
ci.mp3data = (struct mp3info *)&cur_ti->mp3data;
|
||||
ci.curpos = 0;
|
||||
cur_ti->start_pos = 0;
|
||||
ci.taginfo_ready = (bool *)&cur_ti->taginfo_ready;
|
||||
|
|
|
@ -44,10 +44,9 @@ enum {
|
|||
/* Not yet implemented. */
|
||||
#define CODEC_SET_AUDIOBUF_WATERMARK 4
|
||||
|
||||
#define MAX_TRACK 10
|
||||
#define MAX_TRACK 32
|
||||
struct track_info {
|
||||
struct mp3entry id3; /* TAG metadata */
|
||||
struct mp3info mp3data; /* MP3 metadata */
|
||||
char *codecbuf; /* Pointer to codec buffer */
|
||||
long codecsize; /* Codec length in bytes */
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#ifndef ID3_H
|
||||
#define ID3_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "config.h"
|
||||
#include "file.h"
|
||||
|
||||
|
@ -78,12 +79,16 @@ struct mp3entry {
|
|||
unsigned int length; /* song length */
|
||||
unsigned int 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 */
|
||||
long bpf; /* bytes per frame */
|
||||
long tpf; /* time per frame */
|
||||
long frame_count; /* number of frames in the file (if VBR) */
|
||||
|
||||
/* Xing VBR fields */
|
||||
bool vbr;
|
||||
|
|
|
@ -832,9 +832,14 @@ static int getsonglength(int fd, struct mp3entry *entry)
|
|||
|
||||
entry->tpf = info.frame_time;
|
||||
entry->bpf = info.frame_size;
|
||||
entry->frame_count = info.frame_count;
|
||||
|
||||
entry->vbr = info.is_vbr;
|
||||
entry->has_toc = info.has_toc;
|
||||
|
||||
entry->lead_trim = info.enc_delay;
|
||||
entry->tail_trim = info.enc_padding;
|
||||
|
||||
memcpy(entry->toc, info.toc, sizeof(info.toc));
|
||||
|
||||
entry->vbr_header_pos = info.vbr_header_pos;
|
||||
|
|
|
@ -266,7 +266,7 @@ static int fileread(int fd, unsigned char *c)
|
|||
#if defined(IRIVER_H100) && !defined(SIMULATOR)
|
||||
/* We don't want to eat all cpu power. Maybe better way to do this
|
||||
should be implemented. */
|
||||
while (pcm_is_lowdata())
|
||||
if (pcm_is_lowdata())
|
||||
yield();
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue