summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2005-11-13 11:04:02 +0000
committerDave Chapman <dave@dchapman.com>2005-11-13 11:04:02 +0000
commitc01775ff4177d491a79dc65403698c4f39350de1 (patch)
treeadeba8fdf355a666c465b5c69023a45cc6fba230
parentf40a6fcb30bd6170514446a93b023cfcfc6bd44d (diff)
downloadrockbox-c01775ff4177d491a79dc65403698c4f39350de1.tar.gz
rockbox-c01775ff4177d491a79dc65403698c4f39350de1.zip
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
-rw-r--r--apps/codecs/libffmpegFLAC/shndec.c5
-rw-r--r--apps/codecs/shorten.c21
-rw-r--r--apps/metadata.c10
3 files changed, 28 insertions, 8 deletions
diff --git a/apps/codecs/libffmpegFLAC/shndec.c b/apps/codecs/libffmpegFLAC/shndec.c
index 7f5f5f4767..6dde8f7a70 100644
--- a/apps/codecs/libffmpegFLAC/shndec.c
+++ b/apps/codecs/libffmpegFLAC/shndec.c
@@ -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"
diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c
index c64615665f..50d72997ce 100644
--- a/apps/codecs/shorten.c
+++ b/apps/codecs/shorten.c
@@ -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();
diff --git a/apps/metadata.c b/apps/metadata.c
index d0557b13f9..5ed16e5847 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -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;