[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4219 - in Extractor: . src/main src/plugins
From: |
cyberix |
Subject: |
[GNUnet-SVN] r4219 - in Extractor: . src/main src/plugins |
Date: |
Sat, 6 Jan 2007 04:36:36 -0800 (PST) |
Author: cyberix
Date: 2007-01-06 04:36:27 -0800 (Sat, 06 Jan 2007)
New Revision: 4219
Added:
Extractor/src/plugins/nsfeextractor.c
Modified:
Extractor/AUTHORS
Extractor/ChangeLog
Extractor/NEWS
Extractor/src/main/extractor.c
Extractor/src/plugins/Makefile.am
Log:
Added nsfe support.
Modified: Extractor/AUTHORS
===================================================================
--- Extractor/AUTHORS 2007-01-06 12:26:48 UTC (rev 4218)
+++ Extractor/AUTHORS 2007-01-06 12:36:27 UTC (rev 4219)
@@ -35,6 +35,7 @@
word - Ariya Hidayat <address@hidden> and Sacha Fuentes
<address@hidden>
nsf - Toni Ruottu <address@hidden>
sid - Toni Ruottu <address@hidden>
+nsfe - Toni Ruottu <address@hidden>
General contributors:
Yuri N. Sedunov <address@hidden>
Modified: Extractor/ChangeLog
===================================================================
--- Extractor/ChangeLog 2007-01-06 12:26:48 UTC (rev 4218)
+++ Extractor/ChangeLog 2007-01-06 12:36:27 UTC (rev 4219)
@@ -1,3 +1,6 @@
+Sat Jan 6 14:27:18 EET 2007
+ Added an NSFE (Extended Nintendo Sound Format) plugin.
+
Tue Jan 2 19:38:10 MST 2007
Fixed various build issues. Releasing libextractor 0.5.17a.
Modified: Extractor/NEWS
===================================================================
--- Extractor/NEWS 2007-01-06 12:26:48 UTC (rev 4218)
+++ Extractor/NEWS 2007-01-06 12:36:27 UTC (rev 4219)
@@ -1,3 +1,6 @@
+Sat Jan 6 14:27:18 EET 2007
+ Added an NSFE (Extended Nintendo Sound Format) plugin.
+
Mon Nov 20 22:08:55 EET 2006
Added an SID (C64 music file) plugin.
Modified: Extractor/src/main/extractor.c
===================================================================
--- Extractor/src/main/extractor.c 2007-01-06 12:26:48 UTC (rev 4218)
+++ Extractor/src/main/extractor.c 2007-01-06 12:36:27 UTC (rev 4219)
@@ -171,11 +171,12 @@
gettext_noop("song count"),
gettext_noop("starting song"),
gettext_noop("hardware dependency"),
+ gettext_noop("ripper"),
NULL,
};
/* the number of keyword types (for bounds-checking) */
-#define HIGHEST_TYPE_NUMBER 130
+#define HIGHEST_TYPE_NUMBER 131
#ifdef HAVE_LIBOGG
#if HAVE_VORBIS
@@ -241,6 +242,7 @@
libextractor_oo:\
libextractor_asf:\
libextractor_sid:\
+libextractor_nsfe:\
libextractor_nsf"
#define DEFAULT_LIBRARIES EXSO OLESO OGGSO QTSO DEFSO
Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am 2007-01-06 12:26:48 UTC (rev 4218)
+++ Extractor/src/plugins/Makefile.am 2007-01-06 12:36:27 UTC (rev 4219)
@@ -74,6 +74,7 @@
libextractor_mp3.la \
$(extrampeg) \
libextractor_nsf.la \
+ libextractor_nsfe.la \
$(extraogg) \
libextractor_png.la \
libextractor_ps.la \
@@ -307,6 +308,13 @@
libextractor_nsf_la_LIBADD = \
$(top_builddir)/src/main/libextractor.la
+libextractor_nsfe_la_SOURCES = \
+ nsfeextractor.c
+libextractor_nsfe_la_LDFLAGS = \
+ $(PLUGINFLAGS) $(retaincommand)
+libextractor_nsfe_la_LIBADD = \
+ $(top_builddir)/src/main/libextractor.la
+
libextractor_split_la_SOURCES = \
splitextractor.c
libextractor_split_la_LDFLAGS = \
Added: Extractor/src/plugins/nsfeextractor.c
===================================================================
--- Extractor/src/plugins/nsfeextractor.c 2007-01-06 12:26:48 UTC (rev
4218)
+++ Extractor/src/plugins/nsfeextractor.c 2007-01-06 12:36:27 UTC (rev
4219)
@@ -0,0 +1,366 @@
+/*
+ * This file is part of libextractor.
+ * (C) 2007 Toni Ruottu
+ *
+ * libextractor is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * libextractor is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libextractor; see the file COPYING. If not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "platform.h"
+#include "extractor.h"
+#include "convert.h"
+
+#define HEADER_SIZE 0x04
+
+/* television system flags */
+
+#define PAL_FLAG 0x01
+#define DUAL_FLAG 0x02
+
+/* sound chip flags */
+
+#define VRCVI_FLAG 0x01
+#define VRCVII_FLAG 0x02
+#define FDS_FLAG 0x04
+#define MMC5_FLAG 0x08
+#define NAMCO_FLAG 0x10
+#define SUNSOFT_FLAG 0x20
+
+#define UINT16 unsigned short
+
+struct header
+{
+ char magicid[ 4 ];
+};
+
+struct infochunk
+{
+ UINT16 loadaddr;
+ UINT16 initaddr;
+ UINT16 playaddr;
+ char tvflags;
+ char chipflags;
+ char songs;
+ char firstsong;
+};
+
+int nsfeuint( char * data )
+{
+ int i, value = 0;
+
+ for( i = 3; i >= 0 ; i-- )
+ {
+ value += ( unsigned char ) data[ i ];
+
+ if( i > 0 )
+ {
+ value *= 0x100;
+ }
+ }
+
+ return( value );
+}
+
+char * nsfestring( char * data, int size )
+{
+ char *s;
+ int length;
+
+ if( size < strlen( data ) )
+ {
+ length = size;
+ }
+ else
+ {
+ length = strlen( data );
+ }
+
+ s = ( char * ) malloc( length + 1 );
+
+ if( data != NULL )
+ {
+ strncpy( s, data, length );
+ }
+
+ s[ strlen( data ) ] = '\0';
+
+ return( s );
+}
+
+static struct EXTRACTOR_Keywords * addkword
+(
+ EXTRACTOR_KeywordList *oldhead,
+ const char * phrase,
+ EXTRACTOR_KeywordType type
+)
+{
+ EXTRACTOR_KeywordList * keyword;
+
+ keyword = malloc( sizeof( EXTRACTOR_KeywordList ) );
+ keyword->next = oldhead;
+ keyword->keyword = strdup( phrase );
+ keyword->keywordType = type;
+ return( keyword );
+}
+
+struct EXTRACTOR_Keywords * libextractor_nsfe_info_extract
+(
+ char * data,
+ size_t size,
+ struct EXTRACTOR_Keywords * prev
+)
+{
+ struct infochunk *ichunk;
+ char songs[ 32 ];
+
+ ichunk = ( struct infochunk * ) data;
+
+ if( size < 8 )
+ {
+ return( prev );
+ }
+
+
+ /* PAL or NTSC */
+
+ if( ichunk->tvflags & DUAL_FLAG )
+ {
+ prev = addkword( prev, "PAL/NTSC", EXTRACTOR_TELEVISION_SYSTEM
);
+ }
+ else
+ {
+ if( ichunk->tvflags & PAL_FLAG )
+ {
+ prev = addkword( prev, "PAL",
EXTRACTOR_TELEVISION_SYSTEM );
+ }
+ else
+ {
+ prev = addkword( prev, "NTSC",
EXTRACTOR_TELEVISION_SYSTEM );
+ }
+ }
+
+
+ /* Detect Extra Sound Chips needed to play the files */
+
+ if( ichunk->chipflags & VRCVI_FLAG )
+ {
+ prev = addkword( prev, "VRCVI", EXTRACTOR_HARDWARE_DEPENDENCY );
+ }
+ if( ichunk->chipflags & VRCVII_FLAG )
+ {
+ prev = addkword( prev, "VRCVII", EXTRACTOR_HARDWARE_DEPENDENCY
);
+ }
+ if( ichunk->chipflags & FDS_FLAG )
+ {
+ prev = addkword( prev, "FDS Sound",
EXTRACTOR_HARDWARE_DEPENDENCY );
+ }
+ if( ichunk->chipflags & MMC5_FLAG )
+ {
+ prev = addkword( prev, "MMC5 audio",
EXTRACTOR_HARDWARE_DEPENDENCY );
+ }
+ if( ichunk->chipflags & NAMCO_FLAG )
+ {
+ prev = addkword( prev, "Namco 106",
EXTRACTOR_HARDWARE_DEPENDENCY );
+ }
+ if( ichunk->chipflags & SUNSOFT_FLAG )
+ {
+ prev = addkword( prev, "Sunsoft FME-07",
EXTRACTOR_HARDWARE_DEPENDENCY );
+ }
+
+ if( size < 9 )
+ {
+ prev = addkword( prev, "1", EXTRACTOR_SONG_COUNT );
+ return( prev );
+ }
+
+ sprintf( songs, "%d", ichunk->songs );
+ prev = addkword( prev, songs, EXTRACTOR_SONG_COUNT );
+
+
+ return( prev );
+}
+
+
+struct EXTRACTOR_Keywords * libextractor_nsfe_tlbl_extract
+(
+ char * data,
+ size_t size,
+ struct EXTRACTOR_Keywords * prev
+)
+{
+ char * title;
+ int left = size;
+
+
+ while( left > 0 )
+ {
+ title = nsfestring( &data[ size - left ], left );
+ prev = addkword( prev, title, EXTRACTOR_TITLE );
+
+ left -= ( strlen( title ) + 1 );
+ }
+
+ return( prev );
+}
+
+struct EXTRACTOR_Keywords * libextractor_nsfe_auth_extract
+(
+ char * data,
+ size_t size,
+ struct EXTRACTOR_Keywords * prev
+)
+{
+ char * album;
+ char * artist;
+ char * copyright;
+ char * ripper;
+ int left = size;
+
+ if( left < 1 )
+ {
+ return( prev );
+ }
+
+ album = nsfestring( &data[ size - left ], left );
+ prev = addkword( prev, album, EXTRACTOR_ALBUM );
+
+ left -= ( strlen( album ) + 1 );
+
+ if( left < 1 )
+ {
+ return( prev );
+ }
+
+ artist = nsfestring( &data[ size - left ], left );
+ prev = addkword( prev, artist, EXTRACTOR_ARTIST );
+
+ left -= ( strlen( artist ) + 1 );
+
+ if( left < 1 )
+ {
+ return( prev );
+ }
+
+ copyright = nsfestring( &data[ size - left ], left );
+ prev = addkword( prev, copyright, EXTRACTOR_COPYRIGHT );
+
+ left -= ( strlen( copyright ) + 1 );
+
+ if( left < 1 )
+ {
+ return( prev );
+ }
+
+ ripper = nsfestring( &data[ size - left ], left );
+ prev = addkword( prev, ripper, EXTRACTOR_RIPPER );
+
+ return( prev );
+}
+
+
+/* "extract" keyword from an Extended Nintendo Sound Format file
+ *
+ * NSFE specification revision 2 (Sep. 3, 2003)
+ * was used, while this piece of software was
+ * originally written.
+ *
+ */
+struct EXTRACTOR_Keywords * libextractor_nsfe_extract
+(
+ const char * filename,
+ char * data,
+ size_t size,
+ struct EXTRACTOR_Keywords * prev
+)
+{
+ struct header *head;
+ int i;
+ char chunkid[ 5 ] = " ";
+
+ /* Check header size */
+
+ if( size < HEADER_SIZE )
+ {
+ return( prev );
+ }
+
+ head = ( struct header * ) data;
+
+ /* Check "magic" id bytes */
+
+ if( memcmp( head->magicid, "NSFE", 4 ) )
+ {
+ return( prev );
+ }
+
+
+ /* Mime-type */
+
+ prev = addkword( prev, "audio/x-nsfe", EXTRACTOR_MIMETYPE );
+
+ i = 4; /* Jump over magic id */
+
+ while( i + 7 < size && strncmp( chunkid, "NEND", 4 ) ) /* CHECK */
+ {
+
+ unsigned int chunksize = nsfeuint( &data[ i ] );
+
+ i += 4; /* Jump over chunk size */
+
+ memcpy( &chunkid, data + i, 4 );
+ chunkid[ 4 ] = '\0';
+
+ i += 4; /* Jump over chunk id */
+
+ if( ! strncmp( chunkid, "INFO", 4 ) )
+ {
+ prev = libextractor_nsfe_info_extract
+ (
+ data + i,
+ chunksize,
+ prev
+ );
+ }
+
+ if( ! strncmp( chunkid, "auth", 4 ) )
+ {
+ prev = libextractor_nsfe_auth_extract
+ (
+ data + i,
+ chunksize,
+ prev
+ );
+ }
+
+ if( ! strncmp( chunkid, "tlbl", 4 ) )
+ {
+ prev = libextractor_nsfe_tlbl_extract
+ (
+ data + i,
+ chunksize,
+ prev
+ );
+ }
+
+ /* Ignored chunks: DATA, NEND, plst, time, fade, BANK */
+
+ i += chunksize;
+
+ }
+
+ return( prev );
+
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4219 - in Extractor: . src/main src/plugins,
cyberix <=