Shorten updates from Mark Arigo: calculate average bitrate, skip id3v2 tags and remove debugf definition from codec

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7840 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2005-11-13 11:04:02 +00:00
parent f40a6fcb30
commit c01775ff41
3 changed files with 28 additions and 8 deletions

View File

@ -24,11 +24,6 @@
*
*/
#include "../codec.h"
#include "../lib/codeclib.h"
extern struct codec_api* ci;
#define DEBUGF ci->debugf
#include "bitstream.h"
#include "golomb.h"
#include "shndec.h"

View File

@ -78,6 +78,12 @@ next_track:
/* Shorten decoder initialization */
ci->memset(&sc, 0, sizeof(ShortenContext));
/* Skip id3v2 tags */
if (ci->id3->first_frame_offset) {
buf = ci->request_buffer(&bytesleft, ci->id3->first_frame_offset);
ci->advance_buffer(ci->id3->first_frame_offset);
}
/* Read the shorten & wave headers */
buf = ci->request_buffer(&bytesleft, MAX_FRAMESIZE);
res = shorten_init(&sc, buf, bytesleft);
@ -86,9 +92,18 @@ next_track:
return CODEC_ERROR;
}
ci->configure(DSP_SET_FREQUENCY, (long *)(sc.sample_rate));
ci->id3->frequency = sc.sample_rate;
ci->id3->length = (sc.totalsamples / sc.sample_rate) * 1000;
ci->configure(DSP_SET_FREQUENCY, (long *)(sc.sample_rate));
if (sc.sample_rate) {
ci->id3->length = (sc.totalsamples / sc.sample_rate) * 1000;
} else {
ci->id3->length = 0;
}
if (ci->id3->length) {
ci->id3->bitrate = (ci->id3->filesize * 8) / ci->id3->length;
}
consumed = sc.gb.index/8;
ci->advance_buffer(consumed);
@ -112,7 +127,7 @@ seek_start:
/* Seek to start of track */
if (ci->seek_time == 1) {
if (ci->seek_buffer(sc.header_bits/8)) {
if (ci->seek_buffer(sc.header_bits/8 + ci->id3->first_frame_offset)) {
sc.bitindex = sc.header_bits - 8*(sc.header_bits/8);
ci->set_elapsed(0);
ci->seek_complete();

View File

@ -1520,6 +1520,16 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
break;
case AFMT_SHN:
track->id3.vbr = true;
track->id3.filesize = filesize(fd);
if (!skip_id3v2(fd, &(track->id3)))
{
return false;
}
/* TODO: read the id3v2 header if it exists */
break;
/* If we don't know how to read the metadata, just store the filename */
default:
break;