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;