changeset 1012:d0d99b22e393 trunk

[svn] import major update by Aleksander Djuric (the original author). - major code cleanups - fix for badly playlist names - remove unnecessary functions - remove no-longer-needed files
author yaz
date Fri, 11 May 2007 01:15:39 -0700
parents 4a693f5b7054
children 177d47add6dd
files ChangeLog src/tta/Makefile src/tta/Readme src/tta/aud-support.h src/tta/aud-tta.c src/tta/crc32.h src/tta/filters.h src/tta/id3.c src/tta/id3genre.h src/tta/libtta.c src/tta/ttadec.c src/tta/ttadec.h src/tta/ttaid3tag.h src/tta/ttalib.h
diffstat 14 files changed, 1184 insertions(+), 1754 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu May 10 22:27:38 2007 -0700
+++ b/ChangeLog	Fri May 11 01:15:39 2007 -0700
@@ -1,3 +1,12 @@
+2007-05-11 05:27:38 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [2186]
+  - replace xmms_remote_*() with playlist functions.
+  
+  trunk/src/filewriter/filewriter.c |   30 +++++++++++++-----------------
+  trunk/src/filewriter/filewriter.h |    2 +-
+  2 files changed, 14 insertions(+), 18 deletions(-)
+
+
 2007-05-11 04:43:57 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [2184]
   - make this compile again and indent properly
--- a/src/tta/Makefile	Thu May 10 22:27:38 2007 -0700
+++ b/src/tta/Makefile	Fri May 11 01:15:39 2007 -0700
@@ -5,7 +5,7 @@
 
 LIBDIR = $(plugindir)/$(INPUT_PLUGIN_DIR)
 
-SOURCES = aud-tta.c id3.c ttadec.c
+SOURCES = libtta.c ttadec.c
 
 OBJECTS = ${SOURCES:.c=.o}
 
--- a/src/tta/Readme	Thu May 10 22:27:38 2007 -0700
+++ b/src/tta/Readme	Fri May 11 01:15:39 2007 -0700
@@ -1,26 +1,26 @@
-TTA Input Plug-In for Beep Media Player
-=======================================
+TTA Input Plug-In for Audacious Media Player
+============================================
 
-Version 1.2, (c) 2004 Alexander Djourik. All rights reserved.
+Version 1.4, (c) 2004 Alexander Djourik. All rights reserved.
 
-* About Beep Media Player
+* About Audacious Media Player
 
+Audacious is a fork of beep-media-player 0.9.7.1.
 Beep Media Player is a media player for the X Window System that
 supports Winamp skins and that has a sophisticated plugin system
 that allows for easy extension of its abilities. Beep Media Player
 is able to deal with all common types of media files.
 
-For more information please visit a Beep Media Player homepage
-http://www.sosdg.org/~larne/w/BMP_Homepage
+For more information please visit a Audacious Media Player homepage
+http://audacious-media-player.org/
 
 * Introduction
 
-This Beep Media Player plug-in is a part of the TTA audio compressor
-which performs lossless compression on multichannel 8,16,24 integer
-and 32-bit IEEE floating-point data of the wav audio files.
-Being "lossless" means that no data/quality is lost in the
-compression - when uncompressed, the data will be identical to
-the original.
+This Audacious Media Player plug-in is a part of the TTA audio
+compressor which performs lossless compression on multichannel
+8,16 and 24-bit data of the wav audio files. Being "lossless"
+means that no data/quality is lost in the compression - when
+uncompressed, the data will be identical to the original.
 
 At now, mostly all of the popular lossless compressors gives a same
 compression results (difference about 1-3%). TTA is a hardware-
@@ -31,9 +31,9 @@
 
 * Configuration
 
-1. Copy the file libtta.so out of your Beep Media Player input
-   plugins directory (usually ${INSTALL_PATH}/bmp/Input).
-2. Start Beep Media Player.
+1. Copy the file libtta.so out of your Audacious Media Player input
+   plugins directory (usually ${INSTALL_PATH}/audacious/Input).
+2. Start Audacious Media Player.
 3. Play TTA files and enjoy highest quality sound.
 
 * Requirements
@@ -42,8 +42,8 @@
 
 * Developers
 
-  Alexander Djourik <sasha@iszf.irk.ru>
-  Pavel Zhilin <pzh@iszf.irk.ru>
+  Alexander Djourik <ald@true-audio.com>
+  Yoshiki Yazawa <yaz@cc.rim.or.jp>
 
 * Copying
 
@@ -69,4 +69,3 @@
 
 Please visit the TTA homepage at http://www.true-audio.com for the
 latest in news and downloads.
-
--- a/src/tta/aud-support.h	Thu May 10 22:27:38 2007 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-#include <audacious/vfs.h>
-
-#define FILE VFSFile
-#define fopen 	vfs_fopen
-#define fclose 	vfs_fclose
-#define fwrite  vfs_fwrite
-#define fread	vfs_fread
-#define frewind vfs_frewind
-#define ftell	vfs_ftell
-#define fseek	vfs_fseek
-
-size_t file_size (char *filename)
-{
-    VFSFile *f;
-    size_t size = -1;
-
-    if ((f = vfs_fopen (filename, "r")))
-    {
-	vfs_fseek (f, 0, SEEK_END);
-	size = vfs_ftell (f);
-	vfs_fclose (f); 
-    }
-    return size;
-}
--- a/src/tta/aud-tta.c	Thu May 10 22:27:38 2007 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1019 +0,0 @@
-/*
- * aud--tta.c
- *
- * Description:	 TTA input plug-in for Audacious
- * Developed by: Alexander Djourik <sasha@iszf.irk.ru>
- *               Pavel Zhilin <pzh@iszf.irk.ru>
- * Audacious port: Yoshiki Yazawa <yaz@cc.rim.or.jp>
- *
- * Copyright (c) 2004 Alexander Djourik. All rights reserved.
- *
- */
-
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Please see the file COPYING in this directory for full copyright
- * information.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <glib.h>
-#include <string.h>
-
-#include <audacious/util.h>
-#include <audacious/plugin.h>
-#include <audacious/titlestring.h>
-#include <audacious/vfs.h>
-#include "aud-support.h"
-#include <audacious/output.h>
-#include <audacious/strings.h>
-#include <audacious/i18n.h>
-
-#include <audacious/id3tag.h>
-
-/* #define DEBUG 1 */
-
-#define  PLUGIN_VERSION "1.2"
-#define  PROJECT_URL "<http://www.true-audio.com>"
-
-#include "ttalib.h"
-
-#define OUTPUT_ERROR (MEMORY_ERROR+1)
-#define MAX_BSIZE (MAX_BPS>>3)
-
-
-static void init ();
-static void cleanup ();
-static int  is_our_file (char *filename);
-static void play_file (InputPlayback *playback);
-static void tta_pause (InputPlayback *playback, short paused);
-static void stop (InputPlayback *playback);
-static void seek (InputPlayback *playback, int time);
-static int  get_time (InputPlayback *playback);
-static void get_song_info (char *filename, char **title, int *length);
-static void file_info (char *filename);
-static void about ();
-static TitleInput *get_song_tuple(char *filename);
-static gchar *extname(const char *filename);
-static void mseek (InputPlayback *data, gulong millisecond);
-
-
-gchar *tta_fmts[] = { "tta", NULL };
-
-InputPlugin tta_ip = 
-{
-    NULL,
-    NULL,
-    NULL,
-    init,
-    about,
-    NULL,
-    is_our_file,
-    NULL,
-    play_file,
-    stop,
-    tta_pause,
-    seek,
-    NULL,
-    get_time,
-    NULL,
-    NULL,
-    cleanup,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    get_song_info,
-    file_info,	
-    NULL,
-    get_song_tuple, // get_song_tuple
-    NULL, // set_song_tuple
-    NULL, // buffer
-    NULL, // vfs
-    tta_fmts,
-    mseek,
-};
-
-InputPlugin *
-get_iplugin_info (void)
-{
-    tta_ip.description = g_strdup_printf ("True Audio Plugin %s", PLUGIN_VERSION);
-    return &tta_ip;
-}
-
-static GThread *decode_thread;
-static char sample_buffer[PCM_BUFFER_LENGTH * MAX_BSIZE * MAX_NCH];
-static tta_info info;		// currently playing file info
-static int seek_position = -1;
-static int  playing = FALSE;
-static int  read_samples = -1;
-
-static GMutex *play_mutex;
-static GCond *play_cond;
-
-static void
-tta_error (int error)
-{
-    char *message;
-    static GtkWidget *errorbox;
-    if (errorbox != NULL) return;
-
-    switch (error)
-    {
-      case OPEN_ERROR:
-	  message = "Can't open file\n";
-	  break;
-      case FORMAT_ERROR:
-	  message = "Not supported file format\n";
-	  break;
-      case FILE_ERROR:
-	  message = "File is corrupted\n";
-	  break;
-      case READ_ERROR:
-	  message = "Can't read from file\n";
-	  break;
-      case MEMORY_ERROR:
-	  message = "Insufficient memory available\n";
-	  break;
-      case OUTPUT_ERROR:
-	  message = "Output plugin error\n";
-	  break;
-    default:
-	  message = "Unknown error\n";
-	  break;
-    }
-
-    xmms_show_message ("TTA Decoder Error", message,
-	"Ok", FALSE, NULL, NULL);
-
-    gtk_signal_connect(GTK_OBJECT(errorbox), "destroy",
-        G_CALLBACK(gtk_widget_destroyed), &errorbox);
-}
-
-static gchar *
-get_title (char *filename, tta_info *ttainfo)
-{
-    char *name, *p;
-
-    if (ttainfo->id3v2.id3has &&
-	    (*ttainfo->id3v2.artist || *ttainfo->id3v2.title)) {
-	    if (*ttainfo->id3v2.artist && *ttainfo->id3v2.title)
-		    return g_strdup_printf("%s - %s", ttainfo->id3v2.artist, ttainfo->id3v2.title);
-	    else if (*ttainfo->id3v2.artist && *ttainfo->id3v2.album)
-		    return g_strdup_printf("%s - %s", ttainfo->id3v2.artist, ttainfo->id3v2.album);
-	    else if (*ttainfo->id3v2.artist) return g_strdup(ttainfo->id3v2.artist);
-	    else if (*ttainfo->id3v2.title)  return g_strdup(ttainfo->id3v2.title);
-    } else if (ttainfo->id3v1.id3has &&
-	    (*ttainfo->id3v1.artist || *ttainfo->id3v1.title)) {
-	    if (*ttainfo->id3v1.artist && *ttainfo->id3v1.title)
-		    return g_strdup_printf("%s - %s", ttainfo->id3v1.artist, ttainfo->id3v1.title);
-	    else if (*ttainfo->id3v1.artist && *ttainfo->id3v1.album)
-		    return g_strdup_printf("%s - %s", ttainfo->id3v1.artist, ttainfo->id3v1.album);
-	    else if (*ttainfo->id3v1.artist) return g_strdup(ttainfo->id3v1.artist);
-	    else if (*ttainfo->id3v1.title)  return g_strdup(ttainfo->id3v1.title);
-    }
-    name = g_strdup (g_basename(filename));
-    p = name + strlen(name);
-    while (*p != '.' && p >= name) p--;
-    if (*p == '.') *p = '\0';
-    p = g_strdup (name);
-    g_free (name);
-    return p;
-}
-
-static void *
-play_loop (gpointer arg)
-{
-    InputPlayback *playback = (InputPlayback *)arg;
-    int  bufsize = PCM_BUFFER_LENGTH  * info.BSIZE * info.NCH;
-    GTimeVal sleep_time;
-
-    ////////////////////////////////////////
-    // decode PCM_BUFFER_LENGTH samples
-    // into the current PCM buffer position
-
-    while (playing) {
-        while ((read_samples = get_samples (sample_buffer)) > 0) {
-            // wait for buffer becomes available
-            while ((playback->output->buffer_free () < bufsize) && seek_position == -1) {
-                g_get_current_time(&sleep_time);
-                g_time_val_add(&sleep_time, 10000);
-                g_mutex_lock(play_mutex);
-                g_cond_timed_wait(play_cond, play_mutex, &sleep_time);
-                g_mutex_unlock(play_mutex);
-                if (!playing)
-                    goto DONE;
-            }
-
-            if (!playing)
-                goto DONE;
-
-            if (seek_position == -1) {
-                produce_audio(playback->output->written_time(),
-                              ((info.BPS == 8) ? FMT_U8 : FMT_S16_LE),
-                              info.NCH,
-                              read_samples * info.NCH * info.BSIZE,
-                              sample_buffer,
-                              NULL);
-            }
-            else {
-                set_position (seek_position / SEEK_STEP); //now seek_postion is in millisecond.
-                playback->output->flush (seek_position);
-                seek_position = -1;
-            }
-        }
-
-        // process remaining data
-        playback->output->buffer_free ();
-        playback->output->buffer_free ();
-
-        while(playback->output->buffer_playing()) {
-            g_get_current_time(&sleep_time);
-            g_time_val_add(&sleep_time, 10000);
-            g_mutex_lock(play_mutex);
-            g_cond_timed_wait(play_cond, play_mutex, &sleep_time);
-            g_mutex_unlock(play_mutex);
-            if(!playing)
-                goto DONE;
-        }
-    }
-
-DONE:
-    g_thread_exit(NULL);
-}
-
-static void
-init ()
-{
-    memset (&info, 0, sizeof (tta_info));
-    play_mutex = g_mutex_new();
-    play_cond = g_cond_new();
-}
-
-static void
-cleanup ()
-{
-    g_cond_free(play_cond);
-    g_mutex_free(play_mutex);
-}
-
-static void
-about ()
-{
-    static GtkWidget *aboutbox;
-    if (aboutbox != NULL) return;
-
-    aboutbox = xmms_show_message(
-	"About True Audio Plugin",
-	"TTA input plugin" PLUGIN_VERSION "for BMP\n"
-	"Copyright (c) 2004 True Audio Software\n"
-	PROJECT_URL, "Ok", FALSE, NULL, NULL);
-
-    gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy",
-        G_CALLBACK(gtk_widget_destroyed), &aboutbox);
-}
-
-static GtkWidget *window = NULL;
-static GtkWidget *filename_entry, *title_entry,
-		 *artist_entry, *album_entry,
-		 *year_entry, *tracknum_entry,
-		 *comment_entry, *genre_entry,
-		 *info_frame;
-
-extern char *genre[];
-
-static void
-file_info (char *filename)
-{
-    tta_info ttainfo;
-    char *title;
-    gchar *utf_filename = NULL;
-
-    if (!window) {
-	GtkWidget *vbox, *hbox, *left_vbox, *table;
-	GtkWidget *label, *filename_hbox, *button_ok;
-
-	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-	gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
-	gtk_signal_connect(GTK_OBJECT(window), "destroy",
-	    G_CALLBACK(gtk_widget_destroyed), &window);
-	gtk_container_set_border_width(GTK_CONTAINER(window), 10);
-    
-	vbox = gtk_vbox_new(FALSE, 10);
-	gtk_container_add(GTK_CONTAINER(window), vbox);
-
-	filename_hbox = gtk_hbox_new(FALSE, 5);
-	gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0);
-	label = gtk_label_new("Filename:");
-	gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0);
-
-	filename_entry = gtk_entry_new_with_max_length(1024);
-	gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE);
-	gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0);
-
-	hbox = gtk_hbox_new(FALSE, 10);
-	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
-	left_vbox = gtk_vbox_new(FALSE, 10);
-	gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0);
-
-	info_frame = gtk_frame_new("ID3 Tag:");
-	gtk_box_pack_start(GTK_BOX(left_vbox), info_frame, FALSE, FALSE, 0);
-
-	table = gtk_table_new(5, 5, FALSE);
-	gtk_container_set_border_width(GTK_CONTAINER(table), 5);
-	gtk_container_add(GTK_CONTAINER(info_frame), table);
-
-	label = gtk_label_new("Title:");
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 5, 5);
-
-	title_entry = gtk_entry_new_with_max_length(1024);
-	gtk_editable_set_editable(GTK_EDITABLE(title_entry), FALSE);
-	gtk_table_attach(GTK_TABLE(table), title_entry, 1, 4, 0, 1,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
-	label = gtk_label_new("Artist:");
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
-	    GTK_FILL, GTK_FILL, 5, 5);
-
-	artist_entry = gtk_entry_new_with_max_length(1024);
-	gtk_editable_set_editable(GTK_EDITABLE(artist_entry), FALSE);
-	gtk_table_attach(GTK_TABLE(table), artist_entry, 1, 4, 1, 2,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
-	label = gtk_label_new("Album:");
-	    gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
-	    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
-	    GTK_FILL, GTK_FILL, 5, 5);
-
-	album_entry = gtk_entry_new_with_max_length(1024);
-	gtk_editable_set_editable(GTK_EDITABLE(album_entry), FALSE);
-	    gtk_table_attach(GTK_TABLE(table), album_entry, 1, 4, 2, 3,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
-	label = gtk_label_new("Comment:");
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4,
-	    GTK_FILL, GTK_FILL, 5, 5);
-
-	comment_entry = gtk_entry_new_with_max_length(1024);
-	gtk_editable_set_editable(GTK_EDITABLE(comment_entry), FALSE);
-	gtk_table_attach(GTK_TABLE(table), comment_entry, 1, 4, 3, 4,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
-	label = gtk_label_new("Year:");
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5,
-	    GTK_FILL, GTK_FILL, 5, 5);
-
-	year_entry = gtk_entry_new_with_max_length(4);
-	    gtk_editable_set_editable(GTK_EDITABLE(year_entry), FALSE);
-	    gtk_widget_set_usize(year_entry, 40, -1);
-	    gtk_table_attach(GTK_TABLE(table), year_entry, 1, 2, 4, 5,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
- 	label = gtk_label_new("Track number:");
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
-	gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5,
-	    GTK_FILL, GTK_FILL, 5, 5);
-
-	tracknum_entry = gtk_entry_new_with_max_length(3);
-	gtk_editable_set_editable(GTK_EDITABLE(tracknum_entry), FALSE);
-	gtk_widget_set_usize(tracknum_entry, 40, -1);
-	gtk_table_attach(GTK_TABLE(table), tracknum_entry, 3, 4, 4, 5,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
-	label = gtk_label_new("Genre:");
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6,
-	    GTK_FILL, GTK_FILL, 5, 5);
-
-	genre_entry = gtk_entry_new_with_max_length(1024);
-	gtk_editable_set_editable(GTK_EDITABLE(genre_entry), FALSE);
-	gtk_widget_set_usize(genre_entry, 40, -1);
-	gtk_table_attach(GTK_TABLE(table), genre_entry, 1, 4, 5, 6,
-            GTK_FILL | GTK_EXPAND | GTK_SHRINK,
-	    GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
-
-	button_ok = gtk_button_new_with_label("Ok");
-	gtk_signal_connect_object(GTK_OBJECT(button_ok), "clicked",
-		  G_CALLBACK(gtk_widget_destroy), G_OBJECT(window));
-	GTK_WIDGET_SET_FLAGS(button_ok, GTK_CAN_DEFAULT);
-	gtk_box_pack_start(GTK_BOX(vbox), button_ok, TRUE, TRUE, 0);
-
-	gtk_widget_show_all (window);
-    }
-    
-    utf_filename = str_to_utf8(filename);
-    title = g_strdup_printf(_("File Info - %s"), g_basename(utf_filename));
-    gtk_window_set_title(GTK_WINDOW(window), title);
-    g_free(title);
-    
-    gtk_entry_set_text(GTK_ENTRY(filename_entry), utf_filename);
-    gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1);
-
-#if 1
-    title = g_strdup(g_basename(utf_filename));
-//    if ((tmp = strrchr(title, '.')) != NULL) *tmp = '\0';
-    gtk_entry_set_text(GTK_ENTRY(title_entry), title);
-    g_free(title);
-#endif
-    g_free(utf_filename);
-
-    if (open_tta_file (filename, &ttainfo, 0) >= 0)
-    {
-	gtk_entry_set_text(GTK_ENTRY(title_entry), "");
-	gtk_entry_set_text(GTK_ENTRY(artist_entry), "");
-	gtk_entry_set_text(GTK_ENTRY(album_entry), "");
-	gtk_entry_set_text(GTK_ENTRY(year_entry), "");
-	gtk_entry_set_text(GTK_ENTRY(tracknum_entry), "");
-	gtk_entry_set_text(GTK_ENTRY(comment_entry), "");
-	gtk_entry_set_text(GTK_ENTRY(genre_entry), "");
-
-	if (ttainfo.id3v2.id3has)
-	{
-	    gtk_entry_set_text(GTK_ENTRY(title_entry), ttainfo.id3v2.title);
-	    gtk_entry_set_text(GTK_ENTRY(artist_entry), ttainfo.id3v2.artist);
-	    gtk_entry_set_text(GTK_ENTRY(album_entry), ttainfo.id3v2.album);
-	    gtk_entry_set_text(GTK_ENTRY(year_entry), ttainfo.id3v2.year);
-	    gtk_entry_set_text(GTK_ENTRY(tracknum_entry), ttainfo.id3v2.track);
-	    gtk_entry_set_text(GTK_ENTRY(comment_entry), ttainfo.id3v2.comment);
-	    gtk_entry_set_text(GTK_ENTRY(genre_entry), ttainfo.id3v2.genre);
-	}
-	else if (ttainfo.id3v1.id3has)
-	{ 
-	    gchar *track = g_strdup_printf ("%2d", ttainfo.id3v1.track);
-	    gtk_entry_set_text(GTK_ENTRY(title_entry), ttainfo.id3v1.title);
-	    gtk_entry_set_text(GTK_ENTRY(artist_entry), ttainfo.id3v1.artist);
-	    gtk_entry_set_text(GTK_ENTRY(album_entry), ttainfo.id3v1.album);
-	    gtk_entry_set_text(GTK_ENTRY(year_entry), ttainfo.id3v1.year);
-	    gtk_entry_set_text(GTK_ENTRY(tracknum_entry), track);
-	    gtk_entry_set_text(GTK_ENTRY(comment_entry), ttainfo.id3v1.comment);
-	    gtk_entry_set_text(GTK_ENTRY(genre_entry),
-		genre[ttainfo.id3v1.genre <= GENRES ? ttainfo.id3v1.genre : 12]);
-	    g_free (track);
-	}
-    }
-    close_tta_file (&ttainfo);
-
-    gtk_widget_set_sensitive(info_frame, TRUE);
-}
-
-static int
-is_our_file (char *filename)
-{
-    if (!strcasecmp (filename + strlen (filename) - 4, ".tta"))
-    {
-	return TRUE;
-    }
-    return FALSE;
-}
-
-static void
-play_file (InputPlayback *playback)
-{
-    char *filename = playback->filename;
-    char *title;
-    int datasize, origsize, bitrate;
-
-    g_mutex_lock(play_mutex);
-    playing = FALSE;
-    g_mutex_unlock(play_mutex);
-    g_cond_signal(play_cond);
-
-    ////////////////////////////////////////
-    // open TTA file
-    if (open_tta_file (filename, &info, 0) < 0)
-    {
-        tta_error (info.STATE);
-        close_tta_file (&info);
-        return;
-    }
-
-    ////////////////////////////////////////
-    // initialize TTA player
-    if (player_init (&info) < 0)
-    {
-        tta_error (info.STATE);
-        close_tta_file (&info);
-        return;
-    }
-
-
-    if (playback->output->open_audio ((info.BPS == 8) ? FMT_U8 : FMT_S16_LE,
-                                      info.SAMPLERATE, info.NCH) == 0)
-    {
-        tta_error (OUTPUT_ERROR);
-        close_tta_file (&info);
-        return;
-    }
-    title = get_title (filename, &info);
-#ifdef DEBUG
-    printf("title @1 = %s\n", title);
-#endif
-    {
-	    TitleInput *tuple;
-
-	    tuple = get_song_tuple(filename);
-	    if(tuple->track_name) {
-		    g_free(title);
-		    title = g_strdup(tuple->track_name);
-#ifdef DEBUG
-		    printf("title @2 = %s\n", title);
-#endif
-	    }
-
-	    bmp_title_input_free(tuple);
-    }
-
-    datasize = file_size(filename) - info.DATAPOS;
-    origsize = info.DATALENGTH * info.BSIZE * info.NCH;
-
-    bitrate  = (int) ((float) datasize / origsize *
-                       (info.SAMPLERATE * info.NCH * info.BPS));
-
-    tta_ip.set_info (title, 1000 * info.LENGTH, bitrate, info.SAMPLERATE, info.NCH);
-    
-    if (title)
-        g_free (title);
-
-    g_mutex_lock(play_mutex);
-    playing = TRUE;
-    seek_position = -1;
-    read_samples = -1;
-    g_mutex_unlock(play_mutex);
-    g_cond_signal(play_cond);
-
-    decode_thread = g_thread_create(play_loop, (gpointer)playback, TRUE, NULL);
-#ifdef DEBUG
-    printf("decode_thread = %p\n", decode_thread);
-#endif
-}
-
-static void
-tta_pause (InputPlayback *playback, short paused)
-{
-    playback->output->pause (paused);
-}
-
-static void
-stop (InputPlayback *playback)
-{
-    g_mutex_lock(play_mutex);
-    playing = FALSE;
-    g_mutex_unlock(play_mutex);
-    g_cond_signal(play_cond);
-#ifdef DEBUG
-    printf("tta: i: stop: stop signaled\n");
-#endif
-    if (decode_thread) {
-        g_thread_join(decode_thread);
-    }
-
-#ifdef DEBUG
-    printf("tta: stop: decode_thread joined\n");
-#endif
-    playback->output->close_audio ();
-    player_stop();
-    close_tta_file (&info);
-    read_samples = 0;
-}
-
-static void
-mseek (InputPlayback *data, gulong millisecond)
-{
-    if (playing) {
-        seek_position = millisecond;
-    }
-}
-
-static void
-seek (InputPlayback *data, int time)
-{
-    mseek(data, 1000 * time);
-}
-
-static int
-get_time (InputPlayback *playback)
-{
-    if (playing && (read_samples || playback->output->buffer_playing()))
-        return playback->output->output_time();
-
-    return -1;
-}
-
-static void
-get_song_info (char *filename, char **title, int *length)
-{
-    tta_info ttainfo;
-
-    if (open_tta_file (filename, &ttainfo, 0) >= 0)
-    {
-	*title = get_title (filename, &ttainfo);
-	*length = ttainfo.LENGTH * 1000;
-    }
-    close_tta_file (&ttainfo);
-}
-
-
-
-static TitleInput *
-get_song_tuple(char *filename)
-{
-	TitleInput *tuple = NULL;
-	tta_info *ttainfo;
-	VFSFile *file;
-
-	ttainfo = g_malloc0(sizeof(tta_info));
-
-	if((file = vfs_fopen(filename, "rb")) != NULL) {
-
-#ifdef DEBUG
-		printf("about to open_tta_file\n");
-#endif
-		if(open_tta_file(filename, ttainfo, 0) >= 0) {
-			tuple = bmp_title_input_new();
-#ifdef DEBUG
-			printf("open_tta_file succeed\n");
-#endif
-			tuple->file_name = g_path_get_basename(filename);
-			tuple->file_path = g_path_get_dirname(filename);
-			tuple->file_ext = extname(filename);
-			tuple->length = ttainfo->LENGTH * 1000;
-
-			if (ttainfo->id3v2.id3has) {
-				if(ttainfo->id3v2.artist)
-					tuple->performer = g_strdup(ttainfo->id3v2.artist);
-
-				if(ttainfo->id3v2.album)
-					tuple->album_name = g_strdup(ttainfo->id3v2.album);
-
-				if(ttainfo->id3v2.title)
-					tuple->track_name = g_strdup(ttainfo->id3v2.title);
-
-				tuple->year = atoi(ttainfo->id3v2.year);
-
-				tuple->track_number = atoi(ttainfo->id3v2.track);
-
-				if(ttainfo->id3v2.genre){
-//					printf("genre = %s\n",ttainfo->id3v2.genre);
-					tuple->genre = g_strdup(ttainfo->id3v2.genre);
-				}
-				if(ttainfo->id3v2.comment)
-					tuple->comment = g_strdup(ttainfo->id3v2.comment);
-			} else if (ttainfo->id3v1.id3has) {
-				if(ttainfo->id3v1.artist)
-					tuple->performer = g_strdup(ttainfo->id3v1.artist);
-
-				if(ttainfo->id3v1.album)
-					tuple->album_name = g_strdup(ttainfo->id3v1.album);
-
-				if(ttainfo->id3v1.title)
-					tuple->track_name = g_strdup(ttainfo->id3v1.title);
-
-				tuple->year = atoi(ttainfo->id3v1.year);
-
-				tuple->track_number = (int)ttainfo->id3v1.track;
-
-				if(ttainfo->id3v1.genre)
-					tuple->genre = g_strdup(genre[ttainfo->id3v1.genre <= GENRES ? ttainfo->id3v1.genre : 12]);
-				if(ttainfo->id3v1.comment)
-					tuple->comment = g_strdup(ttainfo->id3v1.comment);
-			}
-
-			close_tta_file (ttainfo);
-		}
-
-		vfs_fclose(file);
-	}
-	return tuple;
-}
-
-static gchar *
-extname(const char *filename)
-{
-    gchar *ext = strrchr(filename, '.');
-
-    if (ext != NULL)
-        ++ext;
-
-    return ext;
-}
-
-/* return length in letters */
-size_t tta_ucs4len(id3_ucs4_t *ucs)
-{
-    id3_ucs4_t *ptr = ucs;
-    size_t len = 0;
-
-    while(*ptr++ != 0)
-        len++;
-
-    return len;
-}
-
-/* duplicate id3_ucs4_t string. new string will be terminated with 0. */
-id3_ucs4_t *tta_ucs4dup(id3_ucs4_t *org)
-{
-    id3_ucs4_t *new = NULL;
-    size_t len = tta_ucs4len(org);
-
-    new = g_malloc0((len + 1) * sizeof(id3_ucs4_t));
-    memcpy(new, org, len * sizeof(id3_ucs4_t));
-    *(new + len) = 0; //terminate
-
-    return new;
-}
-
-#define BYTES(x) ((x) * sizeof(id3_ucs4_t))
-
-id3_ucs4_t *tta_parse_genre(const id3_ucs4_t *string)
-{
-    id3_ucs4_t *ret = NULL;
-    id3_ucs4_t *tmp = NULL;
-    id3_ucs4_t *genre = NULL;
-    id3_ucs4_t *ptr, *end, *tail, *tp;
-    size_t ret_len = 0; //num of ucs4 char!
-    size_t tmp_len = 0;
-    gboolean is_num = TRUE;
-
-    tail = (id3_ucs4_t *)string + tta_ucs4len((id3_ucs4_t *)string);
-
-    ret = g_malloc0(1024);
-
-    for(ptr = (id3_ucs4_t *)string; *ptr != 0 && ptr <= tail; ptr++) {
-        if(*ptr == '(') {
-            if(*(++ptr) == '(') { // escaped text like: ((something)
-                for(end = ptr; *end != ')' && *end != 0;) { // copy "(something)"
-                    end++;
-                }
-                end++; //include trailing ')'
-                memcpy(ret, ptr, BYTES(end - ptr));
-                ret_len += (end - ptr);
-                *(ret + ret_len) = 0; //terminate
-                ptr = end + 1;
-            }
-            else {
-                // reference to an id3v1 genre code
-                for(end = ptr; *end != ')' && *end != 0;) {
-                    end++;
-                }
-
-                tmp = g_malloc0(BYTES(end - ptr + 1));
-                memcpy(tmp, ptr, BYTES(end - ptr));
-                *(tmp + (end - ptr)) = 0; //terminate
-                ptr += end - ptr;
-
-                genre = (id3_ucs4_t *)id3_genre_name((const id3_ucs4_t *)tmp);
-
-                g_free(tmp);
-                tmp = NULL;
-
-                tmp_len = tta_ucs4len(genre);
-
-                memcpy(ret + BYTES(ret_len), genre, BYTES(tmp_len));
-
-                ret_len += tmp_len;
-                *(ret + ret_len) = 0; //terminate
-            }
-        }
-        else {
-            for(end = ptr; *end != '(' && *end != 0; ) {
-                end++;
-            }
-            // scan string to determine whether a genre code number or not
-            tp = ptr;
-            is_num = TRUE;
-            while(tp < end) {
-                if(*tp < '0' || *tp > '9') { // anything else than number appears.
-                    is_num = FALSE;
-                    break;
-                }
-                tp++;
-            }
-            if(is_num) {
-#ifdef DEBUG
-                printf("is_num!\n");
-#endif
-                tmp = g_malloc0(BYTES(end - ptr + 1));
-                memcpy(tmp, ptr, BYTES(end - ptr));
-                *(tmp + (end - ptr)) = 0; //terminate
-                ptr += end - ptr;
-
-                genre = (id3_ucs4_t *)id3_genre_name((const id3_ucs4_t *)tmp);
-#ifdef DEBUG
-                printf("genre length = %d\n", tta_ucs4len(genre));
-#endif
-                g_free(tmp);
-                tmp = NULL;
-
-                tmp_len = tta_ucs4len(genre);
-
-                memcpy(ret + BYTES(ret_len), genre, BYTES(tmp_len));
-
-                ret_len += tmp_len;
-                *(ret + ret_len) = 0; //terminate
-            }
-            else { // plain text
-#ifdef DEBUG
-                printf("plain!\n");
-                printf("ret_len = %d\n", ret_len);
-#endif
-                memcpy(ret + BYTES(ret_len), ptr, BYTES(end - ptr));
-                ret_len = ret_len + (end - ptr);
-                *(ret + ret_len) = 0; //terminate
-                ptr += (end - ptr);
-            }
-        }
-    }
-    return ret;
-}
-
-gchar *tta_input_id3_get_string(struct id3_tag * tag, char *frame_name)
-{
-    gchar *rtn;
-    gchar *rtn2;
-    const id3_ucs4_t *string_const;
-    id3_ucs4_t *string;
-    id3_ucs4_t *ucsptr;
-    struct id3_frame *frame;
-    union id3_field *field;
-    gboolean flagutf = FALSE;
-
-    frame = id3_tag_findframe(tag, frame_name, 0);
-    if (!frame)
-        return NULL;
-
-    if (frame_name == ID3_FRAME_COMMENT)
-        field = id3_frame_field(frame, 3);
-    else
-        field = id3_frame_field(frame, 1);
-
-    if (!field)
-        return NULL;
-
-    if (frame_name == ID3_FRAME_COMMENT)
-        string_const = id3_field_getfullstring(field);
-    else
-        string_const = id3_field_getstrings(field, 0);
-
-    if (!string_const)
-        return NULL;
-
-    string = tta_ucs4dup((id3_ucs4_t *)string_const);
-
-    if (frame_name == ID3_FRAME_GENRE) {
-        id3_ucs4_t *string2 = NULL;
-        string2 = tta_parse_genre(string);
-        g_free((void *)string);
-        string = string2;
-    }
-
-    ucsptr = (id3_ucs4_t *)string;
-    while (*ucsptr) {
-        if (*ucsptr > 0x000000ffL) {
-            flagutf = TRUE;
-            break;
-        }
-        ucsptr++;
-    }
-
-    if (flagutf) {
-#ifdef DEBUG
-        g_message("aud-tta: flagutf!\n");
-#endif
-        rtn = id3_ucs4_utf8duplicate(string);
-    }
-    else {
-        rtn = id3_ucs4_latin1duplicate(string);
-        rtn2 = str_to_utf8(rtn);
-        free(rtn);
-        rtn = rtn2;
-    }
-    g_free(string);
-    string = NULL;
-#ifdef DEBUG
-    g_print("string = %s\n", rtn);
-#endif    
-    return rtn;
-}
-
-int get_id3_tags (const char *filename, tta_info *ttainfo) {
-	int id3v2_size;
-	gchar *str = NULL;
-
-	struct id3_file *id3file = NULL;
-	struct id3_tag  *tag = NULL;
-
-	ttainfo->id3v2.id3has = 0;
-	ttainfo->id3v1.id3has = 0;
-
-	  id3file = id3_file_open (filename, ID3_FILE_MODE_READONLY);
-
-	  if (id3file) {
-		  tag = id3_file_tag (id3file);
-
-		  if (tag) {
-			  str = tta_input_id3_get_string (tag, ID3_FRAME_ARTIST);
-			  if(str) {
-				strncpy(ttainfo->id3v2.artist, str, MAX_LINE);
-				strncpy(ttainfo->id3v1.artist, str, 30);
-			  }
-			  free(str);
-			  str = NULL;
-
-			  str = tta_input_id3_get_string (tag, ID3_FRAME_ALBUM);
-			  if(str){
-				  strncpy(ttainfo->id3v2.album, str, MAX_LINE);
-				  strncpy(ttainfo->id3v1.album, str, 30);
-			  }
-			  free(str);
-			  str = NULL;
-
-			  str = tta_input_id3_get_string (tag, ID3_FRAME_TITLE);
-			  if(str) {
-				  strncpy(ttainfo->id3v2.title, str, MAX_LINE);
-				  strncpy(ttainfo->id3v1.title, str, 30);
-			  }
-			  free(str);
-			  str = NULL;
-
-			  // year
-			  str = tta_input_id3_get_string (tag, ID3_FRAME_YEAR); //TDRC
-			  if(!str) {
-				  str = tta_input_id3_get_string (tag, "TYER");
-			  }
-
-			  if(str){
-				  strncpy(ttainfo->id3v2.year, str, 5);
-				  strncpy(ttainfo->id3v1.year, str, 5);
-			  }
-			  free(str);
-			  str = NULL;
-
-			  // track number
-			  str = tta_input_id3_get_string (tag, ID3_FRAME_TRACK);
-			  if(str)
-				  strncpy(ttainfo->id3v2.track, str, MAX_TRACK);
-			  free(str);
-			  str = NULL;
-
-			  // genre
-			  str = tta_input_id3_get_string (tag, ID3_FRAME_GENRE);
-			  if(str) {
-				  id3_ucs4_t *tmp = NULL;
-				  strncpy(ttainfo->id3v2.genre, str, MAX_GENRE);
-				  tmp = id3_latin1_ucs4duplicate((id3_latin1_t *)str);
-				  ttainfo->id3v1.genre =  id3_genre_number(tmp);
-				  g_free(tmp);
-			  }
-			  free(str);
-			  str = NULL;
-
-			  // comment
-			  str = tta_input_id3_get_string (tag, ID3_FRAME_COMMENT);
-			  if(str) {
-				  strncpy(ttainfo->id3v2.comment, str, MAX_LINE);
-				  strncpy(ttainfo->id3v1.comment, str, 30);
-			  }
-			  free(str);
-			  str = NULL;
-
-			  if(*(ttainfo->id3v2.title) && *(ttainfo->id3v2.artist)) {
-				  ttainfo->id3v2.id3has = 1;
-				  ttainfo->id3v2.id3has = 1;
-			  }
-		  }
-		  id3_file_close(id3file);
-	  }
-	return id3v2_size; // not used
-}
--- a/src/tta/crc32.h	Thu May 10 22:27:38 2007 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*
- * crc32.h
- *
- * Description:	 CRC32 functions
- * Developed by: Alexander Djourik <sasha@iszf.irk.ru>
- *               Pavel Zhilin <pzh@iszf.irk.ru>
- *
- * Copyright (c) 1999-2004 Alexander Djourik. All rights reserved.
- *
- */
-
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Please see the file COPYING in this directory for full copyright
- * information.
- */
-
-#ifndef CRC32_H
-#define CRC32_H
-
-const __uint32_t crc32_table[256] = {
-	0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
-	0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
-	0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
-	0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
-	0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
-	0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
-	0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
-	0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
-	0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
-	0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
-	0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
-	0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
-	0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
-	0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
-	0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
-	0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
-	0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
-	0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
-	0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
-	0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
-	0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
-	0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
-	0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
-	0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
-	0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
-	0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
-	0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
-	0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
-	0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
-	0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
-	0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
-	0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
-	0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
-	0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
-	0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
-	0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
-	0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
-	0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
-	0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
-	0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
-	0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
-	0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
-	0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
-	0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
-	0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
-	0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
-	0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
-	0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
-	0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
-	0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
-	0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
-	0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
-	0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
-	0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
-	0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
-	0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
-	0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
-	0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
-	0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
-	0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
-	0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
-	0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
-	0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
-	0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-}; 
-
-#define UPDATE_CRC32(x, crc) crc = \
-	(((crc>>8) & 0x00FFFFFF) ^ crc32_table[(crc^x) & 0xFF])
-
-static __uint32_t
-crc32 (unsigned char *buffer, unsigned int len) {
-	unsigned int	i;
-	unsigned int	crc = 0xFFFFFFFF;
-
-	for (i = 0; i < len; i++) UPDATE_CRC32(buffer[i], crc);
-
-	return (crc ^ 0xFFFFFFFF);
-}
-
-#endif	/* CRC32_H */
--- a/src/tta/filters.h	Thu May 10 22:27:38 2007 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
- * filters.h
- *
- * Description:	 TTAv1 filter functions
- * Developed by: Alexander Djourik <sasha@iszf.irk.ru>
- *               Pavel Zhilin <pzh@iszf.irk.ru>
- *
- * Copyright (c) 1999-2004 Alexander Djourik. All rights reserved.
- *
- */
-
-/*
- * This program 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 of the License, or
- * (at your option) any later version.
- *
- * This program 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
- * aint with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Please see the file COPYING in this directory for full copyright
- * information.
- */
-
-#ifndef FILTERS_H
-#define FILTERS_H
-
-///////// Filter Settings //////////
-static int flt_set[3] = {10, 9, 10};
-
-__inline void
-memshl (register int *pA, register int *pB) {
-	*pA++ = *pB++;
-	*pA++ = *pB++;
-	*pA++ = *pB++;
-	*pA++ = *pB++;
-	*pA++ = *pB++;
-	*pA++ = *pB++;
-	*pA++ = *pB++;
-	*pA   = *pB;
-}
-
-__inline void
-hybrid_filter (fltst *fs, int *in) {
-	register int *pA = fs->dl;
-	register int *pB = fs->qm;
-	register int *pM = fs->dx;
-	register int sum = fs->round;
-
-	if (!fs->error) {
-		sum += *pA++ * *pB, pB++;
-		sum += *pA++ * *pB, pB++;
-		sum += *pA++ * *pB, pB++;
-		sum += *pA++ * *pB, pB++;
-		sum += *pA++ * *pB, pB++;
-		sum += *pA++ * *pB, pB++;
-		sum += *pA++ * *pB, pB++;
-		sum += *pA++ * *pB, pB++; pM += 8;
-	} else if (fs->error < 0) {
-		sum += *pA++ * (*pB -= *pM++), pB++;
-		sum += *pA++ * (*pB -= *pM++), pB++;
-		sum += *pA++ * (*pB -= *pM++), pB++;
-		sum += *pA++ * (*pB -= *pM++), pB++;
-		sum += *pA++ * (*pB -= *pM++), pB++;
-		sum += *pA++ * (*pB -= *pM++), pB++;
-		sum += *pA++ * (*pB -= *pM++), pB++;
-		sum += *pA++ * (*pB -= *pM++), pB++;
-	} else {
-		sum += *pA++ * (*pB += *pM++), pB++;
-		sum += *pA++ * (*pB += *pM++), pB++;
-		sum += *pA++ * (*pB += *pM++), pB++;
-		sum += *pA++ * (*pB += *pM++), pB++;
-		sum += *pA++ * (*pB += *pM++), pB++;
-		sum += *pA++ * (*pB += *pM++), pB++;
-		sum += *pA++ * (*pB += *pM++), pB++;
-		sum += *pA++ * (*pB += *pM++), pB++;
-	}
-
-	*(pM-0) = ((*(pA-1) >> 30) | 1) << 2;
-	*(pM-1) = ((*(pA-2) >> 30) | 1) << 1;
-	*(pM-2) = ((*(pA-3) >> 30) | 1) << 1;
-	*(pM-3) = ((*(pA-4) >> 30) | 1);
-
-	fs->error = *in;
-	*in += (sum >> fs->shift);
-	*pA = *in;
-
-	*(pA-1) = *(pA-0) - *(pA-1);
-	*(pA-2) = *(pA-1) - *(pA-2);
-	*(pA-3) = *(pA-2) - *(pA-3);
-
-	memshl (fs->dl, fs->dl + 1);
-	memshl (fs->dx, fs->dx + 1);
-}
-
-void
-filter_init (fltst *fs, int shift) {
-	memset (fs, 0, sizeof(fltst));
-	fs->shift = shift;
-	fs->round = 1 << (shift - 1);
-}
-
-#endif	/* FILTERS_H */
-
--- a/src/tta/id3.c	Thu May 10 22:27:38 2007 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "ttalib.h"
-#include "id3genre.h"
-#include "audacious/util.h"
-#include <stdlib.h>
-#include <audacious/titlestring.h>
-
-/***********************************************************************
- * ID3 tags manipulation routines
- *
- * Provides read access to ID3v1 tags v1.1, ID3v2 tags v2.3.x and above
- * Supported ID3v2 frames: Title, Artist, Album, Track, Year,
- *                         Genre, Comment.
- *
- **********************************************************************/
-
-static unsigned int unpack_sint28 (const char *ptr) {
-	unsigned int value = 0;
-
-	if (ptr[0] & 0x80) return 0;
-
-	value =  value       | (ptr[0] & 0x7f);
-	value = (value << 7) | (ptr[1] & 0x7f);
-	value = (value << 7) | (ptr[2] & 0x7f);
-	value = (value << 7) | (ptr[3] & 0x7f);
-
-	return value;
-}
-
-static unsigned int unpack_sint32 (const char *ptr) {
-	unsigned int value = 0;
-
-	if (ptr[0] & 0x80) return 0;
-
-	value = (value << 8) | ptr[0];
-	value = (value << 8) | ptr[1];
-	value = (value << 8) | ptr[2];
-	value = (value << 8) | ptr[3];
-
-	return value;
-}
-
-static int get_frame_id (const char *id) {
-	if (!memcmp(id, "TIT2", 4)) return TIT2;	// Title
-	if (!memcmp(id, "TPE1", 4)) return TPE1;	// Artist
-	if (!memcmp(id, "TALB", 4)) return TALB;	// Album
-	if (!memcmp(id, "TRCK", 4)) return TRCK;	// Track
-	if (!memcmp(id, "TYER", 4)) return TYER;	// Year
-	if (!memcmp(id, "TCON", 4)) return TCON;	// Genre
-	if (!memcmp(id, "COMM", 4)) return COMM;	// Comment
-	return 0;
-}
-
-int skip_v2_header(tta_info *ttainfo) {
-	id3v2_tag id3v2;
-	id3v2_frame frame_header;
-	int id3v2_size;
-	unsigned char *buffer, *ptr;
-	gchar *utf;
-	gchar tmp[MAX_LINE];
-	gchar *tmpptr;
-	int tmplen;
-
-	if (!fread(&id3v2, 1, sizeof (id3v2_tag), ttainfo->HANDLE) || 
-	    memcmp(id3v2.id, "ID3", 3))
-	 {
-		fseek (ttainfo->HANDLE, 0, SEEK_SET);
-		return 0;
-	}
-
-	id3v2_size = unpack_sint28(id3v2.size) + 10;
-
-	fseek (ttainfo->HANDLE, id3v2_size, SEEK_SET);
-	ttainfo->id3v2.size = id3v2_size;
-
-	return id3v2_size;
-}
-
-/* eof */
--- a/src/tta/id3genre.h	Thu May 10 22:27:38 2007 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
-/* ID3v1 names with Winamp extensions */
-
-
-char *genre[] = {
-  /*   0 */  "Blues",
-  /*   1 */  "Classic Rock",
-  /*   2 */  "Country",
-  /*   3 */  "Dance",
-  /*   4 */  "Disco",
-  /*   5 */  "Funk",
-  /*   6 */  "Grunge",
-  /*   7 */  "Hip-Hop",
-  /*   8 */  "Jazz",
-  /*   9 */  "Metal",
-  /*  10 */  "New Age",
-  /*  11 */  "Oldies",
-  /*  12 */  "Other",
-  /*  13 */  "Pop",
-  /*  14 */  "R&B",
-  /*  15 */  "Rap",
-  /*  16 */  "Reggae",
-  /*  17 */  "Rock",
-  /*  18 */  "Techno",
-  /*  19 */  "Industrial",
-  /*  20 */  "Alternative",
-  /*  21 */  "Ska",
-  /*  22 */  "Death Metal",
-  /*  23 */  "Pranks",
-  /*  24 */  "Soundtrack",
-  /*  25 */  "Euro-Techno",
-  /*  26 */  "Ambient",
-  /*  27 */  "Trip-Hop",
-  /*  28 */  "Vocal",
-  /*  29 */  "Jazz+Funk",
-  /*  30 */  "Fusion",
-  /*  31 */  "Trance",
-  /*  32 */  "Classical",
-  /*  33 */  "Instrumental",
-  /*  34 */  "Acid",
-  /*  35 */  "House",
-  /*  36 */  "Game",
-  /*  37 */  "Sound Clip",
-  /*  38 */  "Gospel",
-  /*  39 */  "Noise",
-  /*  40 */  "AlternRock",
-  /*  41 */  "Bass",
-  /*  42 */  "Soul",
-  /*  43 */  "Punk",
-  /*  44 */  "Space",
-  /*  45 */  "Meditative",
-  /*  46 */  "Instrumental Pop",
-  /*  47 */  "Instrumental Rock",
-  /*  48 */  "Ethnic",
-  /*  49 */  "Gothic",
-  /*  50 */  "Darkwave",
-  /*  51 */  "Techno-Industrial",
-  /*  52 */  "Electronic",
-  /*  53 */  "Pop-Folk",
-  /*  54 */  "Eurodance",
-  /*  55 */  "Dream",
-  /*  56 */  "Southern Rock",
-  /*  57 */  "Comedy",
-  /*  58 */  "Cult",
-  /*  59 */  "Gangsta",
-  /*  60 */  "Top 40",
-  /*  61 */  "Christian Rap",
-  /*  62 */  "Pop/Funk",
-  /*  63 */  "Jungle",
-  /*  64 */  "Native American",
-  /*  65 */  "Cabaret",
-  /*  66 */  "New Wave",
-  /*  67 */  "Psychedelic",
-  /*  68 */  "Rave",
-  /*  69 */  "Showtunes",
-  /*  70 */  "Trailer",
-  /*  71 */  "Lo-Fi",
-  /*  72 */  "Tribal",
-  /*  73 */  "Acid Punk",
-  /*  74 */  "Acid Jazz",
-  /*  75 */  "Polka",
-  /*  76 */  "Retro",
-  /*  77 */  "Musical",
-  /*  78 */  "Rock & Roll",
-  /*  79 */  "Hard Rock",
-  /*  80 */  "Folk",
-  /*  81 */  "Folk/Rock",
-  /*  82 */  "National Folk",
-  /*  83 */  "Swing",
-  /*  84 */  "Fast-Fusion",
-  /*  85 */  "Bebob",
-  /*  86 */  "Latin",
-  /*  87 */  "Revival",
-  /*  88 */  "Celtic",
-  /*  89 */  "Bluegrass",
-  /*  90 */  "Avantgarde",
-  /*  91 */  "Gothic Rock",
-  /*  92 */  "Progressive Rock",
-  /*  93 */  "Psychedelic Rock",
-  /*  94 */  "Symphonic Rock",
-  /*  95 */  "Slow Rock",
-  /*  96 */  "Big Band",
-  /*  97 */  "Chorus",
-  /*  98 */  "Easy Listening",
-  /*  99 */  "Acoustic",
-  /* 100 */  "Humour",
-  /* 101 */  "Speech",
-  /* 102 */  "Chanson",
-  /* 103 */  "Opera",
-  /* 104 */  "Chamber Music",
-  /* 105 */  "Sonata",
-  /* 106 */  "Symphony",
-  /* 107 */  "Booty Bass",
-  /* 108 */  "Primus",
-  /* 109 */  "Porn Groove",
-  /* 110 */  "Satire",
-  /* 111 */  "Slow Jam",
-  /* 112 */  "Club",
-  /* 113 */  "Tango",
-  /* 114 */  "Samba",
-  /* 115 */  "Folklore",
-  /* 116 */  "Ballad",
-  /* 117 */  "Power Ballad",
-  /* 118 */  "Rhythmic Soul",
-  /* 119 */  "Freestyle",
-  /* 120 */  "Duet",
-  /* 121 */  "Punk Rock",
-  /* 122 */  "Drum Solo",
-  /* 123 */  "A Cappella",
-  /* 124 */  "Euro-House",
-  /* 125 */  "Dance Hall",
-  /* 126 */  "Goa",
-  /* 127 */  "Drum & Bass",
-  /* 128 */  "Club-House",
-  /* 129 */  "Hardcore",
-  /* 130 */  "Terror",
-  /* 131 */  "Indie",
-  /* 132 */  "BritPop",
-  /* 133 */  "Negerpunk",
-  /* 134 */  "Polsk Punk",
-  /* 135 */  "Beat",
-  /* 136 */  "Christian Gangsta Rap",
-  /* 137 */  "Heavy Metal",
-  /* 138 */  "Black Metal",
-  /* 139 */  "Crossover",
-  /* 140 */  "Contemporary Christian",
-  /* 141 */  "Christian Rock",
-  /* 142 */  "Merengue",
-  /* 143 */  "Salsa",
-  /* 144 */  "Thrash Metal",
-  /* 145 */  "Anime",
-  /* 146 */  "JPop",
-  /* 147 */  "Synthpop"
-};
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tta/libtta.c	Fri May 11 01:15:39 2007 -0700
@@ -0,0 +1,861 @@
+/*
+ * libtta.c
+ *
+ * Description:	 TTA input plug-in for Audacious
+ * Developed by: Alexander Djourik <ald@true-audio.com>
+ * Audacious port: Yoshiki Yazawa <yaz@cc.rim.or.jp>
+ *
+ * Copyright (c) 2007 Alexander Djourik. All rights reserved.
+ *
+ */
+
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Please see the file COPYING in this directory for full copyright
+ * information.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <glib.h>
+#include <pthread.h>
+#include <string.h>
+
+#include <audacious/util.h>
+#include <audacious/plugin.h>
+#include <audacious/titlestring.h>
+#include <audacious/vfs.h>
+#include <audacious/output.h>
+#include <audacious/strings.h>
+#include <audacious/i18n.h>
+
+#include <audacious/id3tag.h>
+
+#define  PLUGIN_VERSION "1.4"
+#define  PROJECT_URL "<http://www.true-audio.com>"
+
+#include "ttalib.h"
+
+#define OUTPUT_ERROR (MEMORY_ERROR+1)
+#define MAX_BSIZE (MAX_BPS>>3)
+#define BYTES(x) ((x) * sizeof(id3_ucs4_t))
+
+static void init ();
+static void cleanup ();
+static int  is_our_file (char *filename);
+static void play_file (InputPlayback *playback);
+static void tta_pause (InputPlayback *playback, short paused);
+static void stop (InputPlayback *playback);
+static void seek (InputPlayback *playback, int time);
+static int  get_time (InputPlayback *playback);
+static void get_song_info (char *filename, char **title, int *length);
+static void file_info (char *filename);
+static void about ();
+static TitleInput *get_song_tuple(char *filename);
+static gchar *extname(const char *filename);
+
+static pthread_t decode_thread;
+static char sample_buffer[PCM_BUFFER_LENGTH * MAX_BSIZE * MAX_NCH];
+static tta_info info;		// currently playing file info
+static int seek_position = -1;
+static int playing = FALSE;
+static int read_samples = -1;
+
+gchar *tta_fmts[] = { "tta", NULL };
+
+InputPlugin tta_ip = 
+{
+	NULL,
+	NULL,
+	NULL,
+	init,
+	about,
+	NULL,
+	is_our_file,
+	NULL,
+	play_file,
+	stop,
+	tta_pause,
+	seek,
+	NULL,
+	get_time,
+	NULL,
+	NULL,
+	cleanup,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	get_song_info,
+	file_info,	
+	NULL,
+	get_song_tuple, // get_song_tuple
+	NULL, // set_song_tuple
+	NULL, // buffer
+	NULL, // vfs
+	tta_fmts,
+};
+
+InputPlugin *
+get_iplugin_info (void)
+{
+	tta_ip.description = g_strdup_printf ("True Audio Plugin %s", PLUGIN_VERSION);
+	return &tta_ip;
+}
+
+size_t
+file_size (char *filename)
+{
+	VFSFile *f;
+	size_t size = -1;
+
+	if ((f = vfs_fopen (filename, "r")))
+	{
+	    vfs_fseek (f, 0, SEEK_END);
+	    size = vfs_ftell (f);
+	    vfs_fclose (f); 
+	}
+	return size;
+}
+
+static void
+tta_error (int error)
+{
+	char *message;
+	static GtkWidget *errorbox;
+	if (errorbox != NULL) return;
+
+	switch (error)
+	{
+        case OPEN_ERROR:
+	    message = "Can't open file\n";
+	    break;
+        case FORMAT_ERROR:
+	    message = "Not supported file format\n";
+	    break;
+        case FILE_ERROR:
+	    message = "File is corrupted\n";
+	    break;
+        case READ_ERROR:
+	    message = "Can't read from file\n";
+	    break;
+        case MEMORY_ERROR:
+	    message = "Insufficient memory available\n";
+	    break;
+        case OUTPUT_ERROR:
+	    message = "Output plugin error\n";
+	    break;
+	default:
+	    message = "Unknown error\n";
+	    break;
+	}
+
+	xmms_show_message ("TTA Decoder Error", message,
+	    "Ok", FALSE, NULL, NULL);
+
+	gtk_signal_connect(GTK_OBJECT(errorbox), "destroy",
+    	    G_CALLBACK(gtk_widget_destroyed), &errorbox);
+}
+
+static gchar *
+get_song_title(TitleInput *tuple)
+{
+	return xmms_get_titlestring(xmms_get_gentitle_format(), tuple);
+}
+
+static void
+get_song_info (char *filename, char **title, int *length)
+{
+	TitleInput *tuple;
+
+    	*length = -1;
+    	*title = NULL;
+
+	if ((tuple = get_song_tuple(filename)) != NULL) {
+    	    *length = tuple->length;
+    	    *title = get_song_title(tuple);
+	}
+
+	bmp_title_input_free(tuple);
+}
+
+static void *
+play_loop (void *arg)
+{
+	InputPlayback *playback = arg;
+	int  bufsize = PCM_BUFFER_LENGTH  * info.BSIZE * info.NCH;
+
+	////////////////////////////////////////
+	// decode PCM_BUFFER_LENGTH samples
+	// into the current PCM buffer position
+
+	while (playing)
+	{
+	    while ((read_samples = get_samples (sample_buffer)) > 0)
+	    {
+
+		while ((playback->output->buffer_free () < bufsize)
+		    && seek_position == -1)
+		{
+		    if (!playing)
+			goto DONE;
+		    xmms_usleep (10000);
+		}
+
+		if (seek_position == -1)
+		{
+		    produce_audio(playback->output->written_time(),
+			      ((info.BPS == 8) ? FMT_U8 : FMT_S16_LE),
+			      info.NCH,
+			      read_samples * info.NCH * info.BSIZE,
+			      sample_buffer,
+			      NULL);
+		}
+		else
+		{
+		    set_position (seek_position);
+		    playback->output->flush (seek_position * SEEK_STEP);
+		    seek_position = -1;
+		}
+	    }
+
+	    playback->output->buffer_free ();
+	    playback->output->buffer_free ();
+	    xmms_usleep(10000);
+	}
+
+DONE:
+	////////////////////////
+	// destroy memory pools
+	player_stop ();
+
+	///////////////////////////////
+	// close currently playing file
+	close_tta_file (&info);
+
+	pthread_exit (NULL);
+}
+
+static void
+init ()
+{
+	memset (&info, 0, sizeof (tta_info));
+}
+
+static void
+cleanup ()
+{
+}
+
+static void
+about ()
+{
+	static GtkWidget *aboutbox;
+	if (aboutbox != NULL) return;
+
+	aboutbox = xmms_show_message(
+	    "About True Audio Plugin",
+	    "TTA input plugin" PLUGIN_VERSION "for BMP\n"
+	    "Copyright (c) 2004 True Audio Software\n"
+	    PROJECT_URL, "Ok", FALSE, NULL, NULL);
+
+	gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy",
+    	    G_CALLBACK(gtk_widget_destroyed), &aboutbox);
+}
+
+static GtkWidget *window = NULL;
+static GtkWidget *filename_entry, *title_entry,
+		 *artist_entry, *album_entry,
+		 *year_entry, *tracknum_entry,
+		 *comment_entry, *genre_entry,
+		 *info_frame;
+
+static void
+file_info (char *filename)
+{
+	tta_info ttainfo;
+	char *title;
+	gchar *utf_filename = NULL;
+
+	if (!window) {
+	    GtkWidget *vbox, *hbox, *left_vbox, *table;
+	    GtkWidget *label, *filename_hbox, *button_ok;
+
+	    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+	    gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
+	    gtk_signal_connect(GTK_OBJECT(window), "destroy",
+		G_CALLBACK(gtk_widget_destroyed), &window);
+	    gtk_container_set_border_width(GTK_CONTAINER(window), 10);
+    
+	    vbox = gtk_vbox_new(FALSE, 10);
+	    gtk_container_add(GTK_CONTAINER(window), vbox);
+
+	    filename_hbox = gtk_hbox_new(FALSE, 5);
+	    gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0);
+	    label = gtk_label_new("Filename:");
+	    gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0);
+
+	    filename_entry = gtk_entry_new_with_max_length(1024);
+	    gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE);
+	    gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0);
+
+	    hbox = gtk_hbox_new(FALSE, 10);
+	    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
+	    left_vbox = gtk_vbox_new(FALSE, 10);
+	    gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0);
+
+	    info_frame = gtk_frame_new("ID3 Tag:");
+	    gtk_box_pack_start(GTK_BOX(left_vbox), info_frame, FALSE, FALSE, 0);
+
+	    table = gtk_table_new(5, 5, FALSE);
+	    gtk_container_set_border_width(GTK_CONTAINER(table), 5);
+	    gtk_container_add(GTK_CONTAINER(info_frame), table);
+
+	    label = gtk_label_new("Title:");
+	    gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
+	    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 5, 5);
+
+	    title_entry = gtk_entry_new_with_max_length(1024);
+	    gtk_editable_set_editable(GTK_EDITABLE(title_entry), FALSE);
+	    gtk_table_attach(GTK_TABLE(table), title_entry, 1, 4, 0, 1,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
+
+	    label = gtk_label_new("Artist:");
+	    gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
+	    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
+		GTK_FILL, GTK_FILL, 5, 5);
+
+	    artist_entry = gtk_entry_new_with_max_length(1024);
+	    gtk_editable_set_editable(GTK_EDITABLE(artist_entry), FALSE);
+	    gtk_table_attach(GTK_TABLE(table), artist_entry, 1, 4, 1, 2,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
+
+	    label = gtk_label_new("Album:");
+	    gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
+	    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
+		GTK_FILL, GTK_FILL, 5, 5);
+
+	    album_entry = gtk_entry_new_with_max_length(1024);
+	    gtk_editable_set_editable(GTK_EDITABLE(album_entry), FALSE);
+	    gtk_table_attach(GTK_TABLE(table), album_entry, 1, 4, 2, 3,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
+
+	    label = gtk_label_new("Comment:");
+	    gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
+	    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4,
+		GTK_FILL, GTK_FILL, 5, 5);
+
+	    comment_entry = gtk_entry_new_with_max_length(1024);
+	    gtk_editable_set_editable(GTK_EDITABLE(comment_entry), FALSE);
+	    gtk_table_attach(GTK_TABLE(table), comment_entry, 1, 4, 3, 4,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
+
+	    label = gtk_label_new("Year:");
+	    gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
+	    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5,
+		GTK_FILL, GTK_FILL, 5, 5);
+
+	    year_entry = gtk_entry_new_with_max_length(4);
+	    gtk_editable_set_editable(GTK_EDITABLE(year_entry), FALSE);
+	    gtk_widget_set_usize(year_entry, 40, -1);
+	    gtk_table_attach(GTK_TABLE(table), year_entry, 1, 2, 4, 5,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
+
+ 	    label = gtk_label_new("Track number:");
+	    gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
+	    gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5,
+		GTK_FILL, GTK_FILL, 5, 5);
+
+	    tracknum_entry = gtk_entry_new_with_max_length(3);
+	    gtk_editable_set_editable(GTK_EDITABLE(tracknum_entry), FALSE);
+	    gtk_widget_set_usize(tracknum_entry, 40, -1);
+	    gtk_table_attach(GTK_TABLE(table), tracknum_entry, 3, 4, 4, 5,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
+
+	    label = gtk_label_new("Genre:");
+	    gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
+	    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6,
+		GTK_FILL, GTK_FILL, 5, 5);
+
+	    genre_entry = gtk_entry_new_with_max_length(1024);
+	    gtk_editable_set_editable(GTK_EDITABLE(genre_entry), FALSE);
+	    gtk_widget_set_usize(genre_entry, 40, -1);
+	    gtk_table_attach(GTK_TABLE(table), genre_entry, 1, 4, 5, 6,
+        	GTK_FILL | GTK_EXPAND | GTK_SHRINK,
+		GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
+
+	    button_ok = gtk_button_new_with_label("Ok");
+	    gtk_signal_connect_object(GTK_OBJECT(button_ok), "clicked",
+		G_CALLBACK(gtk_widget_destroy), G_OBJECT(window));
+	    GTK_WIDGET_SET_FLAGS(button_ok, GTK_CAN_DEFAULT);
+	    gtk_box_pack_start(GTK_BOX(vbox), button_ok, TRUE, TRUE, 0);
+
+	    gtk_widget_show_all (window);
+	}
+    
+	utf_filename = str_to_utf8(filename);
+	title = g_strdup_printf(_("File Info - %s"), g_basename(utf_filename));
+	gtk_window_set_title(GTK_WINDOW(window), title);
+	g_free(title);
+    
+	gtk_entry_set_text(GTK_ENTRY(filename_entry), utf_filename);
+	gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1);
+
+	title = g_strdup(g_basename(utf_filename));
+	gtk_entry_set_text(GTK_ENTRY(title_entry), title);
+
+	g_free(title);
+	g_free(utf_filename);
+
+	if (open_tta_file (filename, &ttainfo, 0) >= 0)
+	{
+	    gtk_entry_set_text(GTK_ENTRY(title_entry), ttainfo.ID3.title);
+	    gtk_entry_set_text(GTK_ENTRY(artist_entry), ttainfo.ID3.artist);
+	    gtk_entry_set_text(GTK_ENTRY(album_entry), ttainfo.ID3.album);
+	    gtk_entry_set_text(GTK_ENTRY(year_entry), ttainfo.ID3.year);
+	    gtk_entry_set_text(GTK_ENTRY(tracknum_entry), ttainfo.ID3.track);
+	    gtk_entry_set_text(GTK_ENTRY(comment_entry), ttainfo.ID3.comment);
+	    gtk_entry_set_text(GTK_ENTRY(genre_entry), ttainfo.ID3.genre);
+	}
+	close_tta_file (&ttainfo);
+
+	gtk_widget_set_sensitive(info_frame, TRUE);
+}
+
+static int
+is_our_file (char *filename)
+{
+	gchar *ext = strrchr(filename, '.');
+
+	if (!strncasecmp(ext, ".tta", 4))
+	    return TRUE;
+
+	return FALSE;
+}
+
+static void
+play_file (InputPlayback *playback)
+{
+	char *filename = playback->filename;
+	char *title;
+	int datasize, origsize, bitrate;
+	TitleInput *tuple = NULL;
+
+	playing = FALSE;
+
+	////////////////////////////////////////
+	// open TTA file
+	if (open_tta_file (filename, &info, 0) < 0)
+	{
+	    tta_error (info.STATE);
+	    close_tta_file (&info);
+	    return;
+	}
+
+	////////////////////////////////////////
+	// initialize TTA player
+	if (player_init (&info) < 0)
+	{
+	    tta_error (info.STATE);
+	    close_tta_file (&info);
+	    return;
+	}
+
+	if (playback->output->open_audio ((info.BPS == 8) ? FMT_U8 : FMT_S16_LE,
+	    info.SAMPLERATE, info.NCH) == 0)
+	{
+	    tta_error (OUTPUT_ERROR);
+	    close_tta_file (&info);
+	    return;
+	}
+
+	tuple = get_song_tuple(filename);
+	title = get_song_title(tuple);
+	bmp_title_input_free(tuple);
+
+	datasize = file_size(filename) - info.DATAPOS;
+	origsize = info.DATALENGTH * info.BSIZE * info.NCH;
+
+	bitrate  = (int) ((float) datasize / origsize *
+	        (info.SAMPLERATE * info.NCH * info.BPS));
+
+	tta_ip.set_info (title, 1000 * info.LENGTH, bitrate, info.SAMPLERATE, info.NCH);
+    
+	if (title)
+	    g_free (title);
+
+	playing = TRUE;
+	seek_position = -1;
+	read_samples = -1;
+
+	pthread_create (&decode_thread, NULL, play_loop, playback);
+}
+
+static void
+tta_pause (InputPlayback *playback, short paused)
+{
+	playback->output->pause (paused);
+}
+
+static void
+stop (InputPlayback *playback)
+{
+	if (playing)
+	{
+	    playing = FALSE;
+	    pthread_join (decode_thread, NULL);
+	    playback->output->close_audio ();
+	    close_tta_file (&info);
+	    read_samples = 0;
+	}
+}
+
+static void
+seek (InputPlayback *data, int time)
+{
+	if (playing)
+	{
+	    seek_position = 1000 * time / SEEK_STEP;
+
+	    while (seek_position != -1)
+		xmms_usleep (10000);
+	}
+}
+
+static int
+get_time (InputPlayback *playback)
+{
+	if (playing && (read_samples || playback->output->buffer_playing()))
+    	    return playback->output->output_time();
+
+	return -1;
+}
+
+static TitleInput *
+get_song_tuple(char *filename)
+{
+	TitleInput *tuple = NULL;
+	tta_info *ttainfo;
+	VFSFile *file;
+
+	ttainfo = g_malloc0(sizeof(tta_info));
+
+	if((file = vfs_fopen(filename, "rb")) != NULL) {
+		if(open_tta_file(filename, ttainfo, 0) >= 0) {
+			tuple = bmp_title_input_new();
+
+			tuple->file_name = g_path_get_basename(filename);
+			tuple->file_path = g_path_get_dirname(filename);
+			tuple->file_ext = extname(filename);
+			tuple->length = ttainfo->LENGTH * 1000;
+
+			if (ttainfo->ID3.id3has) {
+				if(ttainfo->ID3.artist) tuple->performer = g_strdup(ttainfo->ID3.artist);
+				if(ttainfo->ID3.album) tuple->album_name = g_strdup(ttainfo->ID3.album);
+				if(ttainfo->ID3.title) tuple->track_name = g_strdup(ttainfo->ID3.title);
+				if(ttainfo->ID3.year) tuple->year = atoi(ttainfo->ID3.year);
+				if(ttainfo->ID3.track) tuple->track_number = atoi(ttainfo->ID3.track);
+				if(ttainfo->ID3.genre) tuple->genre = g_strdup(ttainfo->ID3.genre);
+				if(ttainfo->ID3.comment) tuple->comment = g_strdup(ttainfo->ID3.comment);
+			}
+			close_tta_file (ttainfo);
+		}
+		vfs_fclose(file);
+	}
+	return tuple;
+}
+
+static gchar *
+extname(const char *filename)
+{
+	gchar *ext = strrchr(filename, '.');
+
+	if (ext != NULL)
+    	    ++ext;
+
+	return ext;
+}
+
+/* return length in letters */
+size_t tta_ucs4len(id3_ucs4_t *ucs)
+{
+	id3_ucs4_t *ptr = ucs;
+	size_t len = 0;
+
+	while(*ptr++ != 0)
+    	    len++;
+
+	return len;
+}
+
+/* duplicate id3_ucs4_t string. new string will be terminated with 0. */
+id3_ucs4_t *tta_ucs4dup(id3_ucs4_t *org)
+{
+	id3_ucs4_t *new = NULL;
+	size_t len = tta_ucs4len(org);
+
+	new = g_malloc0((len + 1) * sizeof(id3_ucs4_t));
+	memcpy(new, org, len * sizeof(id3_ucs4_t));
+	*(new + len) = 0; //terminate
+
+	return new;
+}
+
+id3_ucs4_t *tta_parse_genre(const id3_ucs4_t *string)
+{
+    id3_ucs4_t *ret = NULL;
+    id3_ucs4_t *tmp = NULL;
+    id3_ucs4_t *genre = NULL;
+    id3_ucs4_t *ptr, *end, *tail, *tp;
+    size_t ret_len = 0; //num of ucs4 char!
+    size_t tmp_len = 0;
+    gboolean is_num = TRUE;
+
+    tail = (id3_ucs4_t *)string + tta_ucs4len((id3_ucs4_t *)string);
+
+    ret = g_malloc0(1024);
+
+    for(ptr = (id3_ucs4_t *)string; *ptr != 0 && ptr <= tail; ptr++) {
+        if(*ptr == '(') {
+            if(*(++ptr) == '(') { // escaped text like: ((something)
+                for(end = ptr; *end != ')' && *end != 0;) { // copy "(something)"
+                    end++;
+                }
+                end++; //include trailing ')'
+                memcpy(ret, ptr, BYTES(end - ptr));
+                ret_len += (end - ptr);
+                *(ret + ret_len) = 0; //terminate
+                ptr = end + 1;
+            }
+            else {
+                // reference to an id3v1 genre code
+                for(end = ptr; *end != ')' && *end != 0;) {
+                    end++;
+                }
+
+                tmp = g_malloc0(BYTES(end - ptr + 1));
+                memcpy(tmp, ptr, BYTES(end - ptr));
+                *(tmp + (end - ptr)) = 0; //terminate
+                ptr += end - ptr;
+
+                genre = (id3_ucs4_t *)id3_genre_name((const id3_ucs4_t *)tmp);
+
+                g_free(tmp);
+                tmp = NULL;
+
+                tmp_len = tta_ucs4len(genre);
+
+                memcpy(ret + BYTES(ret_len), genre, BYTES(tmp_len));
+
+                ret_len += tmp_len;
+                *(ret + ret_len) = 0; //terminate
+            }
+        }
+        else {
+            for(end = ptr; *end != '(' && *end != 0; ) {
+                end++;
+            }
+            // scan string to determine whether a genre code number or not
+            tp = ptr;
+            is_num = TRUE;
+            while(tp < end) {
+                if(*tp < '0' || *tp > '9') { // anything else than number appears.
+                    is_num = FALSE;
+                    break;
+                }
+                tp++;
+            }
+            if(is_num) {
+#ifdef DEBUG
+                printf("is_num!\n");
+#endif
+                tmp = g_malloc0(BYTES(end - ptr + 1));
+                memcpy(tmp, ptr, BYTES(end - ptr));
+                *(tmp + (end - ptr)) = 0; //terminate
+                ptr += end - ptr;
+
+                genre = (id3_ucs4_t *)id3_genre_name((const id3_ucs4_t *)tmp);
+#ifdef DEBUG
+                printf("genre length = %d\n", tta_ucs4len(genre));
+#endif
+                g_free(tmp);
+                tmp = NULL;
+
+                tmp_len = tta_ucs4len(genre);
+
+                memcpy(ret + BYTES(ret_len), genre, BYTES(tmp_len));
+
+                ret_len += tmp_len;
+                *(ret + ret_len) = 0; //terminate
+            }
+            else { // plain text
+#ifdef DEBUG
+                printf("plain!\n");
+                printf("ret_len = %d\n", ret_len);
+#endif
+                memcpy(ret + BYTES(ret_len), ptr, BYTES(end - ptr));
+                ret_len = ret_len + (end - ptr);
+                *(ret + ret_len) = 0; //terminate
+                ptr += (end - ptr);
+            }
+        }
+    }
+
+    return ret;
+}
+
+gchar *tta_input_id3_get_string(struct id3_tag * tag, char *frame_name)
+{
+    gchar *rtn;
+    gchar *rtn2;
+    const id3_ucs4_t *string_const;
+    id3_ucs4_t *string;
+    id3_ucs4_t *ucsptr;
+    struct id3_frame *frame;
+    union id3_field *field;
+    gboolean flagutf = FALSE;
+
+    frame = id3_tag_findframe(tag, frame_name, 0);
+    if (!frame)
+        return NULL;
+
+    if (frame_name == ID3_FRAME_COMMENT)
+        field = id3_frame_field(frame, 3);
+    else
+        field = id3_frame_field(frame, 1);
+
+    if (!field)
+        return NULL;
+
+    if (frame_name == ID3_FRAME_COMMENT)
+        string_const = id3_field_getfullstring(field);
+    else
+        string_const = id3_field_getstrings(field, 0);
+
+    if (!string_const)
+        return NULL;
+
+    string = tta_ucs4dup((id3_ucs4_t *)string_const);
+
+    if (frame_name == ID3_FRAME_GENRE) {
+        id3_ucs4_t *string2 = NULL;
+        string2 = tta_parse_genre(string);
+        g_free((void *)string);
+        string = string2;
+    }
+
+    ucsptr = (id3_ucs4_t *)string;
+    while (*ucsptr) {
+        if (*ucsptr > 0x000000ffL) {
+            flagutf = TRUE;
+            break;
+        }
+        ucsptr++;
+    }
+
+    if (flagutf) {
+#ifdef DEBUG
+        g_message("aud-tta: flagutf!\n");
+#endif
+        rtn = id3_ucs4_utf8duplicate(string);
+    }
+    else {
+        rtn = id3_ucs4_latin1duplicate(string);
+        rtn2 = str_to_utf8(rtn);
+        free(rtn);
+        rtn = rtn2;
+    }
+    g_free(string);
+    string = NULL;
+#ifdef DEBUG
+    g_print("string = %s\n", rtn);
+#endif    
+
+    return rtn;
+}
+
+int get_id3_tags (const char *filename, tta_info *ttainfo) {
+	int id3v2_size = 0;
+	gchar *str = NULL;
+
+	struct id3_file *id3file = NULL;
+	struct id3_tag  *tag = NULL;
+
+	id3file = id3_file_open (filename, ID3_FILE_MODE_READONLY);
+
+	if (id3file) {
+		tag = id3_file_tag (id3file);
+
+		if (tag) {
+			ttainfo->ID3.id3has = 1;
+			id3v2_size = tag->paddedsize;
+
+			str = tta_input_id3_get_string (tag, ID3_FRAME_ARTIST);
+			if(str) strncpy(ttainfo->ID3.artist, str, MAX_LINE);
+			free(str);
+			str = NULL;
+
+			str = tta_input_id3_get_string (tag, ID3_FRAME_ALBUM);
+			if(str) strncpy(ttainfo->ID3.album, str, MAX_LINE);
+			free(str);
+			str = NULL;
+
+			str = tta_input_id3_get_string (tag, ID3_FRAME_TITLE);
+			if(str) strncpy(ttainfo->ID3.title, str, MAX_LINE);
+			free(str);
+			str = NULL;
+
+			str = tta_input_id3_get_string (tag, ID3_FRAME_YEAR);
+			if(!str) str = tta_input_id3_get_string (tag, "TYER");
+			if(str) strncpy(ttainfo->ID3.year, str, MAX_YEAR);
+			free(str);
+			str = NULL;
+
+			str = tta_input_id3_get_string (tag, ID3_FRAME_TRACK);
+			if(str) strncpy(ttainfo->ID3.track, str, MAX_TRACK);
+			free(str);
+			str = NULL;
+
+			str = tta_input_id3_get_string (tag, ID3_FRAME_GENRE);
+			if(str) strncpy(ttainfo->ID3.genre, str, MAX_GENRE);
+			free(str);
+			str = NULL;
+
+			str = tta_input_id3_get_string (tag, ID3_FRAME_COMMENT);
+			if(str) strncpy(ttainfo->ID3.comment, str, MAX_LINE);
+			free(str);
+			str = NULL;
+		}
+
+		id3_file_close(id3file);
+	}
+
+	return id3v2_size; // not used
+}
--- a/src/tta/ttadec.c	Thu May 10 22:27:38 2007 -0700
+++ b/src/tta/ttadec.c	Fri May 11 01:15:39 2007 -0700
@@ -1,11 +1,10 @@
 /*
  * ttadec.c
  *
- * Description:	 TTAv1 decoder library for HW players.
- * Developed by: Alexander Djourik <sasha@iszf.irk.ru>
- *               Pavel Zhilin <pzh@iszf.irk.ru>
+ * Description:	 TTAv1 decoder library
+ * Developed by: Alexander Djourik <ald@true-audio.com>
  *
- * Copyright (c) 1999-2004 Alexander Djourik. All rights reserved.
+ * Copyright (c) 1999-2007 Alexander Djourik. All rights reserved.
  *
  */
 
@@ -34,8 +33,6 @@
 
 #include "ttadec.h"
 #include "ttalib.h"
-#include "crc32.h"
-#include "filters.h"
 
 /******************* static variables and structures *******************/
 
@@ -64,19 +61,31 @@
 static unsigned char *bitpos;
 static unsigned int bitrate;
 
-void get_id3v1_tag (tta_info *ttainfo);
-int  get_id3v2_tag (tta_info *ttainfo);
+/************************* crc32 functions *****************************/
+
+#define UPDATE_CRC32(x, crc) crc = \
+	(((crc>>8) & 0x00FFFFFF) ^ crc32_table[(crc^x) & 0xFF])
+
+static __uint32_t
+crc32 (unsigned char *buffer, unsigned int len) {
+	unsigned int	i;
+	unsigned int	crc = 0xFFFFFFFF;
+
+	for (i = 0; i < len; i++) UPDATE_CRC32(buffer[i], crc);
+
+	return (crc ^ 0xFFFFFFFF);
+}
 
 /************************* bit operations ******************************/
 
 static void init_buffer_read() {
-    frame_crc32 = 0xFFFFFFFFUL;
-    bit_count = bit_cache = 0;
-    bitpos = iso_buffers_end;
+	frame_crc32 = 0xFFFFFFFFUL;
+	bit_count = bit_cache = 0;
+	bitpos = iso_buffers_end;
 }
 
 __inline void get_binary(unsigned int *value, unsigned int bits) {
-    while (bit_count < bits) {
+	while (bit_count < bits) {
 		if (bitpos == iso_buffers_end) {
 			int res = fread(isobuffers, 1,
 				ISO_BUFFERS_SIZE, ttainfo->HANDLE);
@@ -91,18 +100,18 @@
 		bit_cache |= *bitpos << bit_count;
 		bit_count += 8;
 		bitpos++;
-    }
+	}
 
-    *value = bit_cache & bit_mask[bits];
-    bit_cache >>= bits;
-    bit_count -= bits;
-    bit_cache &= bit_mask[bit_count];
+	*value = bit_cache & bit_mask[bits];
+	bit_cache >>= bits;
+	bit_count -= bits;
+	bit_cache &= bit_mask[bit_count];
 }
 
 __inline void get_unary(unsigned int *value) {
-    *value = 0;
+	*value = 0;
 
-    while (!(bit_cache ^ bit_mask[bit_count])) {
+	while (!(bit_cache ^ bit_mask[bit_count])) {
 		if (bitpos == iso_buffers_end) {
 			int res = fread(isobuffers, 1,
 				ISO_BUFFERS_SIZE, ttainfo->HANDLE);
@@ -117,24 +126,24 @@
 		bit_cache = *bitpos++;
 		UPDATE_CRC32(bit_cache, frame_crc32);
 		bit_count = 8;
-    }
+	}
 
-    while (bit_cache & 1) {
+	while (bit_cache & 1) {
 		(*value)++;
 		bit_cache >>= 1;
 		bit_count--;
-    }
+	}
 
-    bit_cache >>= 1;
-    bit_count--;
+	bit_cache >>= 1;
+	bit_count--;
 }
 
 static int done_buffer_read() {
-    unsigned int crc32, rbytes, res;
-    frame_crc32 ^= 0xFFFFFFFFUL;
+	unsigned int crc32, rbytes, res;
+	frame_crc32 ^= 0xFFFFFFFFUL;
 
-    rbytes = iso_buffers_end - bitpos;
-    if (rbytes < sizeof(int)) {
+	rbytes = iso_buffers_end - bitpos;
+	if (rbytes < sizeof(int)) {
 		memcpy(isobuffers, bitpos, 4);
 		res = fread(isobuffers + rbytes, 1,
 			ISO_BUFFERS_SIZE - rbytes, ttainfo->HANDLE);
@@ -143,29 +152,106 @@
 			return 0;
 		}
 		bitpos = isobuffers;
-    }
+	}
 
-    memcpy(&crc32, bitpos, 4);
-    crc32 = ENDSWAP_INT32(crc32);
-    bitpos += sizeof(int);
-    res = (crc32 != frame_crc32);
+	memcpy(&crc32, bitpos, 4);
+	crc32 = ENDSWAP_INT32(crc32);
+	bitpos += sizeof(int);
+	res = (crc32 != frame_crc32);
 
-    bit_cache = bit_count = 0;
-    frame_crc32 = 0xFFFFFFFFUL;
+	bit_cache = bit_count = 0;
+	frame_crc32 = 0xFFFFFFFFUL;
 
-    // calculate dynamic bitrate
-    if (data_pos < fframes) {
+	// calculate dynamic bitrate
+	if (data_pos < fframes) {
 		rbytes = seek_table[data_pos] -
 			seek_table[data_pos - 1];
 		bitrate = (rbytes << 3) / 1070;
-    }
+	}
+
+	return res;
+}
+
+/************************** filter functions ****************************/
+
+///////// Filter Settings //////////
+static int flt_set[3] = {10, 9, 10};
+
+__inline void
+memshl (register int *pA, register int *pB) {
+	*pA++ = *pB++;
+	*pA++ = *pB++;
+	*pA++ = *pB++;
+	*pA++ = *pB++;
+	*pA++ = *pB++;
+	*pA++ = *pB++;
+	*pA++ = *pB++;
+	*pA   = *pB;
+}
+
+__inline void
+hybrid_filter (fltst *fs, int *in) {
+	register int *pA = fs->dl;
+	register int *pB = fs->qm;
+	register int *pM = fs->dx;
+	register int sum = fs->round;
 
-    return res;
+	if (!fs->error) {
+		sum += *pA++ * *pB, pB++;
+		sum += *pA++ * *pB, pB++;
+		sum += *pA++ * *pB, pB++;
+		sum += *pA++ * *pB, pB++;
+		sum += *pA++ * *pB, pB++;
+		sum += *pA++ * *pB, pB++;
+		sum += *pA++ * *pB, pB++;
+		sum += *pA++ * *pB, pB++; pM += 8;
+	} else if (fs->error < 0) {
+		sum += *pA++ * (*pB -= *pM++), pB++;
+		sum += *pA++ * (*pB -= *pM++), pB++;
+		sum += *pA++ * (*pB -= *pM++), pB++;
+		sum += *pA++ * (*pB -= *pM++), pB++;
+		sum += *pA++ * (*pB -= *pM++), pB++;
+		sum += *pA++ * (*pB -= *pM++), pB++;
+		sum += *pA++ * (*pB -= *pM++), pB++;
+		sum += *pA++ * (*pB -= *pM++), pB++;
+	} else {
+		sum += *pA++ * (*pB += *pM++), pB++;
+		sum += *pA++ * (*pB += *pM++), pB++;
+		sum += *pA++ * (*pB += *pM++), pB++;
+		sum += *pA++ * (*pB += *pM++), pB++;
+		sum += *pA++ * (*pB += *pM++), pB++;
+		sum += *pA++ * (*pB += *pM++), pB++;
+		sum += *pA++ * (*pB += *pM++), pB++;
+		sum += *pA++ * (*pB += *pM++), pB++;
+	}
+
+	*(pM-0) = ((*(pA-1) >> 30) | 1) << 2;
+	*(pM-1) = ((*(pA-2) >> 30) | 1) << 1;
+	*(pM-2) = ((*(pA-3) >> 30) | 1) << 1;
+	*(pM-3) = ((*(pA-4) >> 30) | 1);
+
+	fs->error = *in;
+	*in += (sum >> fs->shift);
+	*pA = *in;
+
+	*(pA-1) = *(pA-0) - *(pA-1);
+	*(pA-2) = *(pA-1) - *(pA-2);
+	*(pA-3) = *(pA-2) - *(pA-3);
+
+	memshl (fs->dl, fs->dl + 1);
+	memshl (fs->dx, fs->dx + 1);
+}
+
+void
+filter_init (fltst *fs, int shift) {
+	memset (fs, 0, sizeof(fltst));
+	fs->shift = shift;
+	fs->round = 1 << (shift - 1);
 }
 
 /************************* decoder functions ****************************/
 
-static int skip_id3v2_header (FILE *infile) {
+int id3v2_header_length (tta_info *ttainfo) {
 	struct {
 		unsigned char	id[3];
 		unsigned short	version;
@@ -174,28 +260,20 @@
 	} __ATTRIBUTE_PACKED__ id3v2;
 	unsigned int len = 0;
 
-	// read ID3V2 header
-	if (fread (&id3v2, sizeof(id3v2), 1, infile) == 0) {
-		fclose (infile);
-		ttainfo->STATE = READ_ERROR;
-		return -1;
+	if (!fread(&id3v2, sizeof(id3v2), 1, ttainfo->HANDLE) || 
+	    memcmp(id3v2.id, "ID3", 3) ||
+	    id3v2.size[0] & 0x80)
+	{
+		fseek (ttainfo->HANDLE, 0, SEEK_SET);
+		return 0;
 	}
 
-	// skip ID3V2 header
-	if (!memcmp (id3v2.id, "ID3", 3)) {
-		if (id3v2.size[0] & 0x80) {
-			fclose (infile);
-			ttainfo->STATE = FILE_ERROR;
-			return FILE_ERROR;
-		}
-		len = (id3v2.size[0] & 0x7f);
-		len = (len << 7) | (id3v2.size[1] & 0x7f);
-		len = (len << 7) | (id3v2.size[2] & 0x7f);
-		len = (len << 7) | (id3v2.size[3] & 0x7f);
-		len += 10;
-		if (id3v2.flags & (1 << 4)) len += 10;
-		fseek (infile, len, SEEK_SET);
-	} else fseek (infile, 0, SEEK_SET);
+	len = (id3v2.size[0] & 0x7f);
+	len = (len << 7) | (id3v2.size[1] & 0x7f);
+	len = (len << 7) | (id3v2.size[2] & 0x7f);
+	len = (len << 7) | (id3v2.size[3] & 0x7f);
+	len += 10;
+	if (id3v2.flags & (1 << 4)) len += 10;
 
 	return len;
 }
@@ -208,22 +286,15 @@
 	// clear the memory
 	memset (info, 0, sizeof(tta_info));
 
-//	printf("0: open_tta_file\n");
 	info->HANDLE = infile = fopen(filename, "rb");
 	if (!infile) return OPEN_ERROR;
 
-//	printf("1: data_offset %ld\n", data_offset);
 	// read id3v2 header
-	if (!data_offset) {
-//		data_offset = skip_id3v2_header(infile);
-//		data_offset = get_id3v2_tag(info);
-		data_offset = skip_v2_header(info);
-//		printf("2: data_offset %ld\n", data_offset);
-//		get_id3v1_tag (info);
-		if (data_offset < 0) return -1;
-	} else fseek (infile, data_offset, SEEK_SET);
+//	if (!data_offset)
+//		data_offset = id3v2_header_length(info);
 
-	get_id3_tags (filename, info);
+	data_offset = get_id3_tags (filename, info);
+	fseek (infile, data_offset, SEEK_SET);
 
 	// read TTA header
 	if (fread (&ttahdr, 1, sizeof (ttahdr), infile) == 0) {
@@ -289,21 +360,21 @@
 }
 
 static void rice_init(adapt *rice, unsigned int k0, unsigned int k1) {
-    rice->k0 = k0;
-    rice->k1 = k1;
-    rice->sum0 = shift_16[k0];
-    rice->sum1 = shift_16[k1];
+	rice->k0 = k0;
+	rice->k1 = k1;
+	rice->sum0 = shift_16[k0];
+	rice->sum1 = shift_16[k1];
 }
 
 static void decoder_init(decoder *tta, int nch, int byte_size) {
-    int shift = flt_set[byte_size - 1];
-    int i;
+	int shift = flt_set[byte_size - 1];
+	int i;
 
-    for (i = 0; i < nch; i++) {
+	for (i = 0; i < nch; i++) {
 		filter_init(&tta[i].fst, shift);
 		rice_init(&tta[i].rice, 10, 10);
 		tta[i].last = 0;
-    }
+	}
 }
 
 static void seek_table_init (unsigned int *seek_table,
@@ -503,4 +574,3 @@
 }
 
 /* end */
-
--- a/src/tta/ttadec.h	Thu May 10 22:27:38 2007 -0700
+++ b/src/tta/ttadec.h	Fri May 11 01:15:39 2007 -0700
@@ -2,10 +2,9 @@
  * ttadec.h
  *
  * Description:	 TTAv1 decoder definitions and prototypes
- * Developed by: Alexander Djourik <sasha@iszf.irk.ru>
- *               Pavel Zhilin <pzh@iszf.irk.ru>
+ * Developed by: Alexander Djourik <ald@true-audio.com>
  *
- * Copyright (c) 1999-2004 Alexander Djourik. All rights reserved.
+ * Copyright (c) 1999-2007 Alexander Djourik. All rights reserved.
  *
  */
 
@@ -46,29 +45,96 @@
 #define WAVE_FORMAT_PCM	1
 #endif
 
-const unsigned int bit_mask[] = {
-    0x00000000, 0x00000001, 0x00000003, 0x00000007,
-    0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
-    0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
-    0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
-    0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
-    0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
-    0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
-    0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
-    0xffffffff
+const __uint32_t crc32_table[256] = {
+	0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
+	0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
+	0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+	0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
+	0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+	0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+	0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
+	0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
+	0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+	0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+	0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
+	0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+	0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
+	0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
+	0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+	0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
+	0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
+	0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+	0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
+	0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+	0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+	0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
+	0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
+	0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+	0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+	0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
+	0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+	0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
+	0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
+	0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+	0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
+	0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
+	0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+	0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
+	0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+	0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+	0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
+	0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
+	0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+	0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+	0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
+	0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+	0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
+	0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
+	0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+	0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
+	0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
+	0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+	0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
+	0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+	0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+	0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
+	0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
+	0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+	0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+	0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
+	0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+	0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
+	0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
+	0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+	0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
+	0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
+	0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+	0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
+}; 
+
+const __uint32_t bit_mask[] = {
+	0x00000000, 0x00000001, 0x00000003, 0x00000007,
+	0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
+	0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
+	0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
+	0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
+	0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
+	0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
+	0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
+	0xffffffff
 };
 
-const unsigned int bit_shift[] = {
-    0x00000001, 0x00000002, 0x00000004, 0x00000008,
-    0x00000010, 0x00000020, 0x00000040, 0x00000080,
-    0x00000100, 0x00000200, 0x00000400, 0x00000800,
-    0x00001000, 0x00002000, 0x00004000, 0x00008000,
-    0x00010000, 0x00020000, 0x00040000, 0x00080000,
-    0x00100000, 0x00200000, 0x00400000, 0x00800000,
-    0x01000000, 0x02000000, 0x04000000, 0x08000000,
-    0x10000000, 0x20000000, 0x40000000, 0x80000000,
-    0x80000000, 0x80000000, 0x80000000, 0x80000000,
-    0x80000000, 0x80000000, 0x80000000, 0x80000000
+const __uint32_t bit_shift[] = {
+	0x00000001, 0x00000002, 0x00000004, 0x00000008,
+	0x00000010, 0x00000020, 0x00000040, 0x00000080,
+	0x00000100, 0x00000200, 0x00000400, 0x00000800,
+	0x00001000, 0x00002000, 0x00004000, 0x00008000,
+	0x00010000, 0x00020000, 0x00040000, 0x00080000,
+	0x00100000, 0x00200000, 0x00400000, 0x00800000,
+	0x01000000, 0x02000000, 0x04000000, 0x08000000,
+	0x10000000, 0x20000000, 0x40000000, 0x80000000,
+	0x80000000, 0x80000000, 0x80000000, 0x80000000,
+	0x80000000, 0x80000000, 0x80000000, 0x80000000
 };
 
 const unsigned int *shift_16 = bit_shift + 4;
@@ -95,13 +161,13 @@
 #define DEC(x)			(((x)&1)?(++(x)>>1):(-(x)>>1))
 
 typedef struct {
-    unsigned int TTAid;
-    unsigned short AudioFormat;
-    unsigned short NumChannels;
-    unsigned short BitsPerSample;
-    unsigned int SampleRate;
-    unsigned int DataLength;
-    unsigned int CRC32;
+	unsigned int TTAid;
+	unsigned short AudioFormat;
+	unsigned short NumChannels;
+	unsigned short BitsPerSample;
+	unsigned int SampleRate;
+	unsigned int DataLength;
+	unsigned int CRC32;
 } __ATTRIBUTE_PACKED__ tta_hdr;
 
 typedef struct {
--- a/src/tta/ttaid3tag.h	Thu May 10 22:27:38 2007 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
- * id3tag.h
- *
- * Description:	ID3 functions prototypes
- *
- */
-
-#pragma pack(1)
-
-#define MAX_LINE 4096
-#define MAX_YEAR 5
-#define MAX_TRACK 3
-#define MAX_GENRE 256
-//#define ID3_VERSION 3
-
-/* ID3 common headers set */
-
-#define TIT2	1
-#define TPE1	2
-#define TALB	3
-#define TRCK	4
-#define TYER	5
-#define TCON	6
-#define COMM	7
-
-/* ID3 tag checked flags */
-
-#define ID3_UNSYNCHRONISATION_FLAG		0x80
-#define ID3_EXTENDEDHEADER_FLAG			0x40
-#define ID3_EXPERIMENTALTAG_FLAG		0x20
-#define ID3_FOOTERPRESENT_FLAG			0x10
-
-/* ID3 frame checked flags */
-
-#define FRAME_COMPRESSION_FLAG			0x0008
-#define FRAME_ENCRYPTION_FLAG			0x0004
-#define FRAME_UNSYNCHRONISATION_FLAG	0x0002
-
-/* ID3 field text encoding */
-
-#define FIELD_TEXT_ISO_8859_1	0x00
-#define FIELD_TEXT_UTF_16		0x01
-#define FIELD_TEXT_UTF_16BE		0x02
-#define FIELD_TEXT_UTF_8		0x03
-
-#define GENRES	148
-
-typedef struct {
-	unsigned char  id[3];
-	unsigned char  title[30];
-	unsigned char  artist[30];
-	unsigned char  album[30];
-	unsigned char  year[4];
-	unsigned char  comment[28];
-	unsigned char  zero;
-	unsigned char  track;
-	unsigned char  genre;
-} id3v1_tag;
-
-typedef struct {
-	unsigned char  id[3];
-	unsigned short version;
-	unsigned char  flags;
-	unsigned char  size[4];
-} id3v2_tag;
-
-typedef struct {
-	unsigned char  id[4];
-	unsigned char  size[4];
-	unsigned short flags;
-} id3v2_frame;
-
-typedef struct {
-	unsigned char  name[31];
-	unsigned char  title[31];
-	unsigned char  artist[31];
-	unsigned char  album[31];
-	unsigned char  comment[31];
-	unsigned char  year[5];
-	unsigned char  track;
-	unsigned char  genre;
-	unsigned char  id3has;
-} id3v1_data;
-
-typedef struct {
-	unsigned char  name[MAX_LINE];
-	unsigned char  title[MAX_LINE];
-	unsigned char  artist[MAX_LINE];
-	unsigned char  album[MAX_LINE];
-	unsigned char  comment[MAX_LINE];
-	unsigned char  year[MAX_YEAR];
-	unsigned char  track[MAX_TRACK];
-	unsigned char  genre[MAX_GENRE];
-	unsigned char  id3has;
-	__uint32_t     size;
-} id3v2_data;
-
--- a/src/tta/ttalib.h	Thu May 10 22:27:38 2007 -0700
+++ b/src/tta/ttalib.h	Fri May 11 01:15:39 2007 -0700
@@ -2,10 +2,9 @@
  * ttalib.h
  *
  * Description:	 TTAv1 player library prototypes
- * Developed by: Alexander Djourik <sasha@iszf.irk.ru>
- *               Pavel Zhilin <pzh@iszf.irk.ru>
+ * Developed by: Alexander Djourik <ald@true-audio.com>
  *
- * Copyright (c) 1999-2004 Alexander Djourik. All rights reserved.
+ * Copyright (c) 1999-2007 Alexander Djourik. All rights reserved.
  *
  */
 
@@ -31,9 +30,18 @@
 #ifndef TTALIB_H_
 #define TTALIB_H_
 
-#include "ttaid3tag.h"
+#include <audacious/vfs.h>
 
-//#define _BIG_ENDIAN
+// audacious support
+#define FILE	VFSFile
+#define fopen	vfs_fopen
+#define fclose	vfs_fclose
+#define fwrite	vfs_fwrite
+#define fread	vfs_fread
+#define frewind vfs_frewind
+#define ftell	vfs_ftell
+#define fseek	vfs_fseek
+
 #define MAX_BPS         24	// Max supported Bit resolution
 #define MAX_NCH         8	// Max supported number of channels
 
@@ -54,20 +62,36 @@
 #define ISO_BUFFERS_SIZE	(ISO_BUFFER_LENGTH*ISO_NBUFFERS)
 #define PCM_BUFFER_LENGTH	(4608)
 
+#define MAX_LINE 4096
+#define MAX_YEAR 5
+#define MAX_TRACK 3
+#define MAX_GENRE 256
+
 typedef struct {
-	FILE            *HANDLE;	// file handle
-	unsigned short  NCH;		// number of channels
-	unsigned short  BPS;		// bits per sample
-	unsigned short  BSIZE;		// byte size
-	unsigned short  FORMAT;		// audio format
-	unsigned int   SAMPLERATE;	// samplerate (sps)
-	unsigned int   DATALENGTH;	// data length in samples
-	unsigned int   FRAMELEN;	// frame length
-	unsigned int   LENGTH;		// playback time (sec)
-	unsigned int   STATE;		// return code
-	unsigned int   DATAPOS;	// size of ID3v2 header
-	id3v1_data	id3v1;
-	id3v2_data	id3v2;
+	unsigned char  name[MAX_LINE];
+	unsigned char  title[MAX_LINE];
+	unsigned char  artist[MAX_LINE];
+	unsigned char  album[MAX_LINE];
+	unsigned char  comment[MAX_LINE];
+	unsigned char  year[MAX_YEAR];
+	unsigned char  track[MAX_TRACK];
+	unsigned char  genre[MAX_GENRE];
+	unsigned char  id3has;
+} id3_info;
+
+typedef struct {
+	FILE		*HANDLE;	// file handle
+	unsigned short	NCH;		// number of channels
+	unsigned short	BPS;		// bits per sample
+	unsigned short	BSIZE;		// byte size
+	unsigned short	FORMAT;		// audio format
+	unsigned int	SAMPLERATE;	// samplerate (sps)
+	unsigned int	DATALENGTH;	// data length in samples
+	unsigned int	FRAMELEN;	// frame length
+	unsigned int	LENGTH;		// playback time (sec)
+	unsigned int	STATE;		// return code
+	unsigned int	DATAPOS;	// size of ID3v2 header
+	id3_info	ID3;
 } tta_info;
 
 /*********************** Library functions *************************/
@@ -89,7 +113,7 @@
 }
 #endif /* LIBTEST */
 
-int    open_tta_file (		// FUNCTION: opens TTA file
+int open_tta_file (		// FUNCTION: opens TTA file
         const char *filename,	// file to open
         tta_info *info,		// file info structure
         unsigned int offset);	// ID3v2 header size
@@ -101,10 +125,10 @@
  *
  */
 
-void    close_tta_file (	// FUNCTION: closes currently playing file
+void close_tta_file (		// FUNCTION: closes currently playing file
         tta_info *info);	// file info structure
 
-int    set_position (		// FUNCTION: sets playback position
+int set_position (		// FUNCTION: sets playback position
         unsigned int pos);	// seek position = seek_time_ms / SEEK_STEP
 /*
  * RETURN VALUE
@@ -114,7 +138,7 @@
  *
  */
 
-int    player_init (		// FUNCTION: initializes TTA player
+int player_init (		// FUNCTION: initializes TTA player
         tta_info *info);	// file info structure
 /*
  * RETURN VALUE
@@ -124,9 +148,9 @@
  *
  */
 
-void    player_stop (void);	// FUNCTION: destroys memory pools
+void player_stop (void);	// FUNCTION: destroys memory pools
 
-int    get_samples (		// FUNCTION: decode PCM_BUFFER_LENGTH samples
+int get_samples (		// FUNCTION: decode PCM_BUFFER_LENGTH samples
         unsigned char *buffer);	// into the current PCM buffer position
 /*
  * RETURN VALUE
@@ -136,7 +160,7 @@
  *
  */
 
-int	get_bitrate (void);	// RETURN VALUE: TTA dynamic bitrate
+int get_bitrate (void);		// RETURN VALUE: TTA dynamic bitrate
 
 #endif /* TTALIB_H_ */