pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/audio/mserv Extend id3v2 handling by adding (very simp...
details: https://anonhg.NetBSD.org/pkgsrc/rev/e8051bc244ae
branches: trunk
changeset: 565565:e8051bc244ae
user: martin <martin%pkgsrc.org@localhost>
date: Sat Sep 26 21:16:57 2009 +0000
description:
Extend id3v2 handling by adding (very simplistic) handling for unicode
tags, and also make it deal with gaps after the header or junk before the
actual start of mp3 data.
This makes it able to properly extract info from all mp3 files I have.
diffstat:
audio/mserv/Makefile | 5 +-
audio/mserv/distinfo | 4 +-
audio/mserv/patches/patch-ae | 148 +++++++++++++++++++++++++++++++++++++++++-
3 files changed, 147 insertions(+), 10 deletions(-)
diffs (214 lines):
diff -r c23cc22dda1c -r e8051bc244ae audio/mserv/Makefile
--- a/audio/mserv/Makefile Sat Sep 26 19:56:23 2009 +0000
+++ b/audio/mserv/Makefile Sat Sep 26 21:16:57 2009 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.33 2009/05/19 06:54:51 abs Exp $
+# $NetBSD: Makefile,v 1.34 2009/09/26 21:16:57 martin Exp $
#
DISTNAME= mserv-0.35
-PKGREVISION= 12
+PKGREVISION= 13
CATEGORIES= audio
MASTER_SITES= http://www.mserv.org/download/
@@ -14,6 +14,7 @@
GNU_CONFIGURE= yes
CONFIGURE_ARGS+= --datadir=${PREFIX}/share/mserv
+CONFIGURE_ENV+= COPTS="-g"
CONFIGURE_ENV+= MY_LIBS="-lvorbisfile -lvorbis"
USE_LIBTOOL= yes
USE_TOOLS+= perl:run
diff -r c23cc22dda1c -r e8051bc244ae audio/mserv/distinfo
--- a/audio/mserv/distinfo Sat Sep 26 19:56:23 2009 +0000
+++ b/audio/mserv/distinfo Sat Sep 26 21:16:57 2009 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.18 2005/02/23 20:39:49 agc Exp $
+$NetBSD: distinfo,v 1.19 2009/09/26 21:16:58 martin Exp $
SHA1 (mserv-0.35.tar.gz) = 850835946e4d5a0deccdd22a18f30170c0a7b57c
RMD160 (mserv-0.35.tar.gz) = 0665c1b1807da675486b58013715b737b8de606e
@@ -7,7 +7,7 @@
SHA1 (patch-ab) = 91d6840eae30182343db97d3f67d23d0c423dbe7
SHA1 (patch-ac) = 068b14b4a8a0ce4dcb19e0cd28fc6a7296f86dad
SHA1 (patch-ad) = 105edf313c2101f0961aab8a94022a5a0d07eb22
-SHA1 (patch-ae) = 559f2ecf11bcd25b5ea3423dff4b1a4bf4066b78
+SHA1 (patch-ae) = c46482ba78594d4fc22262c540d7356e1b651c0e
SHA1 (patch-af) = d92f0bf56a04cf3b2f7001c4f68c1bb1b5ea007f
SHA1 (patch-ag) = 7d5fae48c89db4b9bdccf371528c3b3e890455a9
SHA1 (patch-ah) = c089ae56f23c83291a1e9b5502b952cd58be4860
diff -r c23cc22dda1c -r e8051bc244ae audio/mserv/patches/patch-ae
--- a/audio/mserv/patches/patch-ae Sat Sep 26 19:56:23 2009 +0000
+++ b/audio/mserv/patches/patch-ae Sat Sep 26 21:16:57 2009 +0000
@@ -1,16 +1,26 @@
-$NetBSD: patch-ae,v 1.8 2004/02/20 00:41:16 abs Exp $
+$NetBSD: patch-ae,v 1.9 2009/09/26 21:16:58 martin Exp $
---- mserv/mp3info.c.orig Thu Feb 19 17:46:03 2004
-+++ mserv/mp3info.c
-@@ -27,6 +27,7 @@
+--- mserv/mp3info.c.orig 2003-07-29 02:17:48.000000000 +0200
++++ mserv/mp3info.c 2009-09-26 22:11:43.000000000 +0200
+@@ -26,7 +26,17 @@
+ #define h_id(val) ((val>>19)&1)
#define h_thing(val) ((val>>20)&0xfff)
++#ifdef STANDALONE
++#define VERBOSE
++#endif
++#ifdef VERBOSE
++#define LOGF(ARG) printf ARG
++#else
++#define LOGF(ARG)
++#endif
++
#define ID3V2HEADERLEN 10
+#define min(x,y) ((x)<(y)?(x):(y))
/* mp3 bit rate and sampling frequency tables */
-@@ -45,12 +46,14 @@ const int sampling_freq_table[2][3] =
+@@ -45,12 +55,14 @@ const int sampling_freq_table[2][3] =
/* structure of id3 tag in mp3 file */
typedef struct id3tag_disc_str
@@ -31,7 +41,100 @@
unsigned char genre;
} id3tag_disc;
-@@ -312,38 +315,44 @@ int mserv_mp3info_readlen(const char *fn
+@@ -228,11 +240,28 @@ static int read_id3v2_frame(FILE *f, id3
+ if (fread(frame->data, 1, frame->datalen, f) != frame->datalen)
+ return -1;
+ if (frame->frameid[0] == 'T' && memcmp(frame->frameid + 1, "XXX", 3)) {
+- frame->data[frame->datalen] = 0;
+- if (frame->data[0] == 0) /* Only handle non unicode */
++ if (frame->data[0] == 0) {
++ /* ISO8859-1 */
++ frame->data[frame->datalen] = 0;
+ strcpy(frame->data, frame->data + 1);
+- else
+- frame->data[0] = 0;
++ } else if (frame->data[0] == 1 && frame->datalen >= 5) {
++ /* unicode, convert as long as it is 8 bit only */
++ int d = 0, i = 1, off0 = 0, off1 = 1;
++ /* check BOM vs. endianess */
++ if ((unsigned char)frame->data[i] == 0xff && (unsigned char)frame->data[i+1] == 0xfe) {
++ off0 = 1; off1 = 0;
++ } else if ((unsigned char)frame->data[i] == 0xfe && (unsigned char)frame->data[i+1] == 0xff) {
++ off1 = 1; off0 = 0;
++ } else {
++ return -1;
++ }
++ for (i=3; (i+1) < frame->datalen /* && frame->data[i] == 0 */; i+=2) {
++ frame->data[d++] = frame->data[i+off1];
++ if (frame->data[i] == 0 && frame->data[i+1] == 0)
++ break;
++ }
++ frame->data[d] = 0;
++ }
+ }
+ return 0;
+ }
+@@ -264,12 +293,12 @@ int mserv_mp3info_readlen(const char *fn
+ {
+ FILE *f;
+ int bitrate, fs, length, headerlen;
+- long int filelen;
++ long int filelen, skipped;
+ float mean_frame_size;
+ char tag[3];
+ unsigned char data[4];
+ unsigned long int flags;
+- int errnok;
++ int errnok, found;
+ char *e;
+
+ if (id3tag)
+@@ -281,15 +310,39 @@ int mserv_mp3info_readlen(const char *fn
+ if ((headerlen = mp3_id3v2head(f)) == -1)
+ goto error;
+
+- if (fseek(f, headerlen, SEEK_SET) == -1 || fread(&data, 4, 1, f) != 1)
++ if (fseek(f, headerlen, SEEK_SET) == -1 || fread(&data[0], 1, 1, f) != 1) {
++ LOGF(("%s: can't read after headerlen %d\n", fname, headerlen));
+ goto error;
++ }
+
+- /* endian independent to 32-bit flags */
+- flags = (data[0]<<24)+(data[1]<<16)+(data[2]<<8)+data[3];
+- if (!is_mp3(flags)) {
+- errno = EDOM;
++ found = skipped = 0;
++ for (;;) {
++ while (data[0] != 0xff) {
++ /* skip junk at beginning or after header - happens quite often */
++ if (fread(&data[0], 1, 1, f) != 1)
++ goto error;
++ skipped++;
++ if (headerlen < 1 && skipped > 4096)
++ break; /* we are not sure this even is a mp3 file */
++ }
++ if (fread(&data[1], 1, 3, f) != 3)
++ goto error;
++
++ /* endian independent to 32-bit flags */
++ flags = (data[0]<<24)+(data[1]<<16)+(data[2]<<8)+data[3];
++ if (is_mp3(flags)) {
++ found = 1;
++ break;
++ }
++ if (headerlen < 1 && skipped > 4096)
++ break; /* we are not sure this even is a mp3 file */
++ }
++ if (!found) {
++ LOGF(("%s: no header found within 4k\n", fname));
+ goto error;
+ }
++ if (skipped)
++ LOGF(("%s: skipped %ld bytes\n", fname, skipped));
+
+ bitrate = bitrate_table[h_id(flags)][3-h_layer(flags)]
+ [h_bitrate_index(flags)];
+@@ -312,38 +365,44 @@ int mserv_mp3info_readlen(const char *fn
if (id3tag)
{
id3tag_disc tag_disc;
@@ -86,3 +189,36 @@
e = id3tag->comment + strlen(id3tag->comment);
while (e > id3tag->comment && *(e-1) == ' ')
*--e = '\0';
+@@ -395,3 +454,32 @@ int mserv_mp3info_readlen(const char *fn
+ errno = errnok;
+ return -1;
+ }
++
++#ifdef STANDALONE
++int main(int argc, char **argv)
++{
++ t_id3tag tag;
++ int bitrate, len;
++
++ if (argc < 2) {
++ printf("usage: minfo (filename)\n");
++ return 1;
++ }
++ len = mserv_mp3info_readlen(argv[1], &bitrate, &tag);
++ if (len < 0) {
++ printf("no mp3 found\n");
++ } else {
++ if (bitrate)
++ printf("bitrate %d kbit/s, estimated length "
++ "%d:%02d.%02d s\n",
++ bitrate, len/6000, (len%6000)/100, len%100);
++ if (tag.present) {
++ printf("title: %s\n", tag.title);
++ printf("album: %s\n", tag.album);
++ printf("artist: %s\n", tag.artist);
++ printf("year: %s\n", tag.year);
++ }
++ }
++ return 0;
++}
++#endif
Home |
Main Index |
Thread Index |
Old Index