shithub: aacenc

Download patch

ref: 193311f8d1bcd4cb0dcd1ce0ece3d7707baa6767
parent: 20faadc49d21f56dc1b9a50a5b76774e39153166
author: menno <menno>
date: Thu Jul 8 04:40:42 EDT 2004

Updated plugins for FAAC

--- a/plugins/cooledit/.cvsignore
+++ b/plugins/cooledit/.cvsignore
@@ -10,4 +10,5 @@
 Release
 Debug
 ReleaseGUI
-DebugGUI
\ No newline at end of file
+DebugGUI
+FAAC.suo
\ No newline at end of file
--- a/plugins/cooledit/CRegistry.cpp
+++ b/plugins/cooledit/CRegistry.cpp
@@ -138,13 +138,13 @@
 //************************************************************************************************
 //************************************************************************************************
 
-void CRegistry::SetBool(char *keyStr, BOOL val)
+void CRegistry::SetBool(char *keyStr, bool val)
 {
-BOOL tempVal;
-DWORD len;
+bool tempVal;
+DWORD len=sizeof(bool);
 	if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS ||
 		tempVal!=val)
-		RegSetValueEx(regKey, keyStr, 0, REG_BINARY, (BYTE *)&val, sizeof(BOOL));
+		RegSetValueEx(regKey, keyStr, 0, REG_BINARY, (BYTE *)&val, sizeof(bool));
 }
 //************************************************************************************************
 
--- a/plugins/cooledit/CRegistry.h
+++ b/plugins/cooledit/CRegistry.h
@@ -41,7 +41,7 @@
 	void	DeleteVal(char *SubKey);
 	void	DeleteKey(char *SubKey);
 
-	void	SetBool(char *keyStr , BOOL val);
+	void	SetBool(char *keyStr , bool val);
 	void	SetByte(char *keyStr , BYTE val);
 	void	SetWord(char *keyStr , WORD val);
 	void	SetDword(char *keyStr , DWORD val);
--- /dev/null
+++ b/plugins/cooledit/CTag.cpp
@@ -1,0 +1,316 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2002-2004 Antonio Foranna
+
+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.
+	
+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
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+			
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
+#include <stdlib.h>
+#include <mp4.h>
+#include <faac.h>
+#include "CTag.h"
+
+
+
+// *********************************************************************************************
+//										CMP4Tag
+// *********************************************************************************************
+
+CMP4Tag::CMP4Tag()
+{
+//	memset(this,0,sizeof(*this));
+	copyright=NULL;
+	artist=title=album=year=genre=writer=comment=NULL;
+	trackno=ntracks=discno=ndiscs=0;
+	compilation=0;
+	artFilename=NULL;
+	art.pictureType=0; // = other
+	memset(&art,0,sizeof(art));
+}
+// *********************************************************************************************
+
+void CMP4Tag::FreeTag()
+{
+	FREE_ARRAY(artist);
+	FREE_ARRAY(title);
+	FREE_ARRAY(album);
+	FREE_ARRAY(year);
+	FREE_ARRAY(genre);
+	FREE_ARRAY(writer);
+	FREE_ARRAY(comment);
+	FREE_ARRAY(artFilename);
+	FREE_ARRAY(art.data);
+	FREE_ARRAY(art.description);
+	FREE_ARRAY(art.mimeType);
+	FREE_ARRAY(art.format);
+}
+// ***********************************************************************************************
+
+int CMP4Tag::check_image_header(const char *buf)
+{
+	if(!strncmp(buf, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8))
+		return 1; /* PNG */
+	if(!strncmp(buf, "\xFF\xD8\xFF\xE0", 4) &&
+		!strncmp(buf + 6, "JFIF\0",	5))
+		return 2; /* JPEG */
+	if(!strncmp(buf, "GIF87a", 6)	|| !strncmp(buf, "GIF89a", 6))
+		return 3; /* GIF */
+
+	return 0;
+}
+// -----------------------------------------------------------------------------------------------
+
+int CMP4Tag::ReadCoverArtFile(char *pCoverArtFile, char **artData)
+{
+FILE *artFile;
+
+	if(!pCoverArtFile || !*pCoverArtFile)
+		return 0;
+
+	if(!(artFile=fopen(pCoverArtFile, "rb")))
+	{
+		MessageBox(NULL,"ReadCoverArtFile: fopen",NULL,MB_OK);
+		return 0;
+	}
+
+int r;
+char *art;
+int	artSize=0;
+
+	fseek(artFile, 0, SEEK_END);
+	artSize=ftell(artFile);
+	fseek(artFile, 0, SEEK_SET);
+
+	if(!(art=(char *)malloc(artSize)))
+	{
+		fclose(artFile);
+		MessageBox(NULL,"ReadCoverArtFile: Memory allocation error!", NULL, MB_OK);
+		return 0;
+	}
+
+	r=fread(art, 1, artSize, artFile);
+	if(r!=artSize)
+	{
+		free(art);
+		fclose(artFile);
+		MessageBox(NULL,"ReadCoverArtFile: Error reading cover art file!", NULL, MB_OK);
+		return 0;
+	}
+	else
+		if(artSize<12 || !check_image_header(art))
+		{
+			// the above expression checks the image signature
+			free(art);
+			fclose(artFile);
+			MessageBox(NULL,"ReadCoverArtFile: Unsupported cover image file format!", NULL, MB_OK);
+			return 0;
+		}
+
+	FREE_ARRAY(*artData);
+	*artData=art;
+	fclose(artFile);
+	return artSize;
+}
+// *********************************************************************************************
+
+void CMP4Tag::WriteMP4Tag(MP4FileHandle MP4File)
+{
+char	buf[512], *faac_id_string, *faac_copyright_string;
+
+	sprintf(buf, "FAAC v%s", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version");
+	MP4SetMetadataTool(MP4File, buf);
+
+	if(artist) MP4SetMetadataArtist(MP4File, artist);
+	if(writer) MP4SetMetadataWriter(MP4File, writer);
+	if(title) MP4SetMetadataName(MP4File, title);
+	if(album) MP4SetMetadataAlbum(MP4File, album);
+	if(trackno>0) MP4SetMetadataTrack(MP4File, trackno, ntracks);
+	if(discno>0) MP4SetMetadataDisk(MP4File, discno, ndiscs);
+	if(compilation) MP4SetMetadataCompilation(MP4File, compilation);
+	if(year) MP4SetMetadataYear(MP4File, year);
+	if(genre) MP4SetMetadataGenre(MP4File, genre);
+	if(comment) MP4SetMetadataComment(MP4File, comment);
+	if(art.size=ReadCoverArtFile(artFilename,&art.data))
+	{
+		MP4SetMetadataCoverArt(MP4File, (BYTE *)art.data, art.size);
+		FREE_ARRAY(art.data);
+	}
+}
+// *********************************************************************************************
+
+void CMP4Tag::ReadMp4Tag(char *Filename)						 
+{
+MP4FileHandle MP4File;
+
+	if(!(MP4File=MP4Read(Filename, 0)))
+	{
+		MessageBox(NULL,"Can't open file",NULL,MB_OK);
+		return;
+	}
+
+	FREE_ARRAY(copyright);
+	MP4GetMetadataTool(MP4File, &copyright);
+
+	FREE_ARRAY(artist);
+	MP4GetMetadataArtist(MP4File, &artist);
+	FREE_ARRAY(writer);
+	MP4GetMetadataWriter(MP4File, &writer);
+	FREE_ARRAY(title);
+	MP4GetMetadataName(MP4File, &title);
+	FREE_ARRAY(album);
+	MP4GetMetadataAlbum(MP4File, &album);
+	MP4GetMetadataTrack(MP4File, &trackno, &ntracks);
+	MP4GetMetadataDisk(MP4File, &discno, &ndiscs);
+	MP4GetMetadataCompilation(MP4File, &compilation);
+	FREE_ARRAY(year);
+	MP4GetMetadataYear(MP4File, &year);
+	FREE_ARRAY(genre);
+	MP4GetMetadataGenre(MP4File, &genre);
+	FREE_ARRAY(comment);
+	MP4GetMetadataComment(MP4File, &comment);
+	FREE_ARRAY(art.data);
+	MP4GetMetadataCoverArt(MP4File, (BYTE **)&art.data, (u_int32_t *)&art.size);
+
+	MP4Close(MP4File);
+/*
+	FILE *f=fopen("D:\\prova.jpg","wb");
+		fwrite(artFile,1,artSize,f);
+		fclose(f);*/
+}
+// *********************************************************************************************
+
+#define DEL_FIELD(id3Tag,ID3FID) \
+{ \
+ID3_Frame *Frame=id3Tag.Find(ID3FID); \
+	if(Frame!=NULL) \
+		id3Tag.RemoveFrame(Frame); \
+}
+// -----------------------------------------------------------------------------------------------
+
+#define ADD_FIELD(id3Tag,ID3FID,ID3FN,data) \
+{ \
+ID3_Frame *NewFrame=new ID3_Frame(ID3FID); \
+	NewFrame->Field(ID3FN)=data; \
+	DEL_FIELD(id3Tag,ID3FID); \
+	id3Tag.AttachFrame(NewFrame); \
+}
+// -----------------------------------------------------------------------------------------------
+
+void CMP4Tag::WriteAacTag(char *Filename)
+{
+char	buf[512], *faac_id_string, *faac_copyright_string;
+ID3_Tag id3Tag;
+
+	id3Tag.Link(Filename);
+
+	sprintf(buf, "FAAC v%s", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version");
+	ADD_FIELD(id3Tag,ID3FID_ENCODEDBY,ID3FN_TEXT,buf);
+
+	ADD_FIELD(id3Tag,ID3FID_LEADARTIST,ID3FN_TEXT,artist);
+	ADD_FIELD(id3Tag,ID3FID_COMPOSER,ID3FN_TEXT,writer);
+	ADD_FIELD(id3Tag,ID3FID_TITLE,ID3FN_TEXT,title);
+	ADD_FIELD(id3Tag,ID3FID_ALBUM,ID3FN_TEXT,album);
+	sprintf(buf,"%d",trackno);
+	ADD_FIELD(id3Tag,ID3FID_TRACKNUM,ID3FN_TEXT,buf);
+	ADD_FIELD(id3Tag,ID3FID_YEAR,ID3FN_TEXT,year);
+	ADD_FIELD(id3Tag,ID3FID_CONTENTTYPE,ID3FN_TEXT,genre);
+	ADD_FIELD(id3Tag,ID3FID_COMMENT,ID3FN_TEXT,comment);
+	art.size=ReadCoverArtFile(artFilename,&art.data);
+	if(art.size)
+	{
+	ID3_Frame *NewFrame=new ID3_Frame(ID3FID_PICTURE);
+	char name[_MAX_FNAME], ext[_MAX_EXT];
+		_splitpath(artFilename,NULL,NULL,name,ext);
+
+		NewFrame->Field(ID3FN_DESCRIPTION)=name;
+	char buf[15];
+		sprintf(buf,"image/%s",check_image_header(art.data)==2 ? "jpeg" : strlwr(ext+1));
+		NewFrame->Field(ID3FN_MIMETYPE)=buf;
+//		NewFrame->Field(ID3FN_IMAGEFORMAT)=;
+		NewFrame->Field(ID3FN_PICTURETYPE)=(DWORD)art.pictureType;
+		NewFrame->Field(ID3FN_DATA).Set((BYTE *)art.data,art.size);
+		id3Tag.AttachFrame(NewFrame);
+	}
+
+	// setup all our rendering parameters
+    id3Tag.SetUnsync(false);
+    id3Tag.SetExtendedHeader(true);
+    id3Tag.SetCompression(true);
+    id3Tag.SetPadding(true);
+ 
+	// write any changes to the file
+    id3Tag.Update();
+
+	FREE_ARRAY(art.data);
+}
+// *********************************************************************************************
+
+#define GET_FIELD_STR(id3Tag,ID3FID,ID3FN,data) \
+{ \
+	Frame=id3Tag.Find(ID3FID); \
+	if(Frame!=NULL) \
+	{ \
+	DWORD size=Frame->Field(ID3FN).Size(); \
+		FREE_ARRAY(data); \
+		if(data=(char *)malloc(size+1)) \
+			Frame->Field(ID3FN).Get(data,size+1); \
+	} \
+	else \
+		FREE_ARRAY(data); \
+}
+// -----------------------------------------------------------------------------------------------
+
+void CMP4Tag::ReadAacTag(char *Filename)
+{
+char	*buf=NULL;
+ID3_Tag id3Tag;
+ID3_Frame *Frame;
+
+	id3Tag.Link(Filename);
+
+	GET_FIELD_STR(id3Tag,ID3FID_ENCODEDBY,ID3FN_TEXT,copyright);
+
+	GET_FIELD_STR(id3Tag,ID3FID_LEADARTIST,ID3FN_TEXT,artist);
+	GET_FIELD_STR(id3Tag,ID3FID_COMPOSER,ID3FN_TEXT,writer);
+	GET_FIELD_STR(id3Tag,ID3FID_TITLE,ID3FN_TEXT,title);
+	GET_FIELD_STR(id3Tag,ID3FID_ALBUM,ID3FN_TEXT,album);
+
+	GET_FIELD_STR(id3Tag,ID3FID_TRACKNUM,ID3FN_TEXT,buf);
+	if(buf)
+		trackno=atoi(buf);
+	FREE_ARRAY(buf);
+	GET_FIELD_STR(id3Tag,ID3FID_YEAR,ID3FN_TEXT,year);
+	GET_FIELD_STR(id3Tag,ID3FID_CONTENTTYPE,ID3FN_TEXT,genre);
+	GET_FIELD_STR(id3Tag,ID3FID_COMMENT,ID3FN_TEXT,comment);
+
+	if(Frame=id3Tag.Find(ID3FID_PICTURE))
+	{
+		art.size=Frame->Field(ID3FN_DATA).Size();
+		FREE_ARRAY(art.data);
+		if(art.data=(char *)malloc(art.size))
+			memcpy(art.data,Frame->Field(ID3FN_DATA).GetBinary(),art.size);
+
+		GET_FIELD_STR(id3Tag,ID3FID_PICTURE,ID3FN_MIMETYPE,art.mimeType);
+		GET_FIELD_STR(id3Tag,ID3FID_PICTURE,ID3FN_DESCRIPTION,art.description);
+		GET_FIELD_STR(id3Tag,ID3FID_PICTURE,ID3FN_IMAGEFORMAT,art.format);
+		art.pictureType=Frame->Field(ID3FN_PICTURETYPE).Get();
+/*
+	FILE *f=fopen("D:\\prova.jpg","wb");
+		fwrite(artFile,1,artSize,f);
+		fclose(f);*/
+	}
+}
\ No newline at end of file
--- /dev/null
+++ b/plugins/cooledit/CTag.h
@@ -1,0 +1,85 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2004 Antonio Foranna
+
+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.
+	
+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
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+			
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
+#ifndef _CTag_H
+#define _CTag_H
+
+// *********************************************************************************************
+
+#include <mp4.h>
+#include <id3/tag.h>	// id3 tag
+#include "CRegistry.h"
+#include "Defines.h"
+
+// *********************************************************************************************
+
+#define REG_TAGON "Tag On"
+#define REG_ARTIST "Tag Artist"
+#define REG_TITLE "Tag Title"
+#define REG_ALBUM "Tag Album"
+#define REG_YEAR "Tag Year"
+#define REG_GENRE "Tag Genre"
+#define REG_WRITER "Tag Writer"
+#define REG_COMMENT "Tag Comment"
+#define REG_TRACK "Tag Track"
+#define REG_NTRACKS "Tag Tracks"
+#define REG_DISK "Tag Disk"
+#define REG_NDISKS "Tag Disks"
+#define REG_COMPILATION "Tag Compilation"
+#define REG_ARTFILE "Tag Art file"
+
+// *********************************************************************************************
+
+typedef struct
+{
+	char	*data;
+	DWORD	size;
+	DWORD	pictureType; // front, back, icon, ...
+	char	*mimeType, // jpg, png, gif
+			*format, // ???
+			*description; // text description
+} id3Picture;
+
+class CMP4Tag
+{
+private:
+	int check_image_header(const char *buf);
+	int ReadCoverArtFile(char *pCoverArtFile, char **artBuf);
+
+public:
+	CMP4Tag();
+	virtual ~CMP4Tag() { FreeTag(); }
+
+	virtual void FreeTag();
+	virtual void WriteMP4Tag(MP4FileHandle MP4File);
+	virtual void WriteAacTag(char *Filename);
+	virtual void ReadMp4Tag(char *Filename);
+	virtual void ReadAacTag(char *Filename);
+
+	char	*copyright; // used in Cfaad
+	char	*artist, *title, *album, *year, *genre, *writer, *comment;
+	WORD	trackno,ntracks, discno,ndiscs;
+	BYTE	compilation;
+	char	*artFilename;
+	id3Picture art; // used in ReadAacTag(). Remark: field not stored into registry
+};
+
+#endif
\ No newline at end of file
--- a/plugins/cooledit/Cfaac.cpp
+++ b/plugins/cooledit/Cfaac.cpp
@@ -24,9 +24,96 @@
 
 
 // *********************************************************************************************
+//										CMyEncCfg
+// *********************************************************************************************
 
+void CMyEncCfg::getCfg(CMyEncCfg *cfg)
+{ 
+CRegistry reg;
 
+	if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAC"))
+	{
+		cfg->AutoCfg=reg.GetSetBool(REG_AUTO,DEF_AUTO);
+		cfg->SaveMP4=reg.GetSetBool(REG_WRITEMP4,DEF_WRITEMP4);
+		cfg->EncCfg.mpegVersion=reg.GetSetDword(REG_MPEGVER,DEF_MPEGVER); 
+		cfg->EncCfg.aacObjectType=reg.GetSetDword(REG_PROFILE,DEF_PROFILE); 
+		cfg->EncCfg.allowMidside=reg.GetSetDword(REG_MIDSIDE,DEF_MIDSIDE); 
+		cfg->EncCfg.useTns=reg.GetSetDword(REG_TNS,DEF_TNS); 
+		cfg->EncCfg.useLfe=reg.GetSetDword(REG_LFE,DEF_LFE);
+		cfg->UseQuality=reg.GetSetBool(REG_USEQUALTY,DEF_USEQUALTY);
+		cfg->EncCfg.quantqual=reg.GetSetDword(REG_QUALITY,DEF_QUALITY); 
+		cfg->EncCfg.bitRate=reg.GetSetDword(REG_BITRATE,DEF_BITRATE); 
+		cfg->EncCfg.bandWidth=reg.GetSetDword(REG_BANDWIDTH,DEF_BANDWIDTH); 
+		cfg->EncCfg.outputFormat=reg.GetSetDword(REG_HEADER,DEF_HEADER); 
 
+		cfg->OutDir=reg.GetSetStr(REG_OutFolder,"");
+
+		cfg->TagOn=reg.GetSetByte(REG_TAGON,0);
+		cfg->Tag.artist=reg.GetSetStr(REG_ARTIST,"");
+		cfg->Tag.title=reg.GetSetStr(REG_TITLE,"");
+		cfg->Tag.album=reg.GetSetStr(REG_ALBUM,"");
+		cfg->Tag.year=reg.GetSetStr(REG_YEAR,"");
+		cfg->Tag.genre=reg.GetSetStr(REG_GENRE,"");
+		cfg->Tag.writer=reg.GetSetStr(REG_WRITER,"");
+		cfg->Tag.comment=reg.GetSetStr(REG_COMMENT,"");
+		cfg->Tag.trackno=reg.GetSetWord(REG_TRACK,0);
+		cfg->Tag.ntracks=reg.GetSetWord(REG_NTRACKS,0);
+		cfg->Tag.discno=reg.GetSetWord(REG_DISK,0);
+		cfg->Tag.ndiscs=reg.GetSetWord(REG_NDISKS,0);
+		cfg->Tag.compilation=reg.GetSetByte(REG_COMPILATION,0);
+		cfg->Tag.artFilename=reg.GetSetStr(REG_ARTFILE,"");
+	}
+	else
+		MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
+}
+// -----------------------------------------------------------------------------------------------
+
+void CMyEncCfg::setCfg(CMyEncCfg *cfg)
+{ 
+CRegistry reg;
+
+	if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAC"))
+	{
+		reg.SetBool(REG_AUTO,cfg->AutoCfg); 
+		reg.SetBool(REG_WRITEMP4,cfg->SaveMP4); 
+		reg.SetDword(REG_MPEGVER,cfg->EncCfg.mpegVersion); 
+		reg.SetDword(REG_PROFILE,cfg->EncCfg.aacObjectType); 
+		reg.SetDword(REG_MIDSIDE,cfg->EncCfg.allowMidside); 
+		reg.SetDword(REG_TNS,cfg->EncCfg.useTns); 
+		reg.SetDword(REG_LFE,cfg->EncCfg.useLfe); 
+		reg.SetBool(REG_USEQUALTY,cfg->UseQuality); 
+		reg.SetDword(REG_QUALITY,cfg->EncCfg.quantqual); 
+		reg.SetDword(REG_BITRATE,cfg->EncCfg.bitRate); 
+		reg.SetDword(REG_BANDWIDTH,cfg->EncCfg.bandWidth); 
+		reg.SetDword(REG_HEADER,cfg->EncCfg.outputFormat); 
+
+		reg.SetStr(REG_OutFolder,cfg->OutDir);
+
+		reg.SetByte(REG_TAGON,cfg->TagOn);
+		reg.SetStr(REG_ARTIST,cfg->Tag.artist);
+		reg.SetStr(REG_TITLE,cfg->Tag.title);
+		reg.SetStr(REG_ALBUM,cfg->Tag.album);
+		reg.SetStr(REG_YEAR,cfg->Tag.year);
+		reg.SetStr(REG_GENRE,cfg->Tag.genre);
+		reg.SetStr(REG_WRITER,cfg->Tag.writer);
+		reg.SetStr(REG_COMMENT,cfg->Tag.comment);
+		reg.SetWord(REG_TRACK,cfg->Tag.trackno); 
+		reg.SetWord(REG_NTRACKS,cfg->Tag.ntracks); 
+		reg.SetWord(REG_DISK,cfg->Tag.discno); 
+		reg.SetWord(REG_NDISKS,cfg->Tag.ndiscs); 
+		reg.SetByte(REG_COMPILATION,cfg->Tag.compilation); 
+		reg.SetStr(REG_ARTFILE,cfg->Tag.artFilename);
+	}
+	else
+		MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
+}
+
+// *********************************************************************************************
+//											Cfaac
+// *********************************************************************************************
+
+
+
 Cfaac::Cfaac(HANDLE hOut)
 {
 	if(hOut)
@@ -70,14 +157,9 @@
 		fclose(mo->aacFile);
 		mo->aacFile=0;
 
-	MY_ENC_CFG	cfg;
-		getFaacCfg(&cfg);
-		if(cfg.Tag.On && mo->Filename)
-		{
-			WriteAacTag(mo->Filename,&cfg.Tag);
-			FREE_ARRAY(mo->Filename);
-		}
-		FreeTag(&cfg.Tag);
+	CMyEncCfg cfg(false);
+		if(cfg.TagOn && mo->Filename)
+			cfg.Tag.WriteAacTag(mo->Filename);
 	}
 	else
 	{
@@ -209,144 +291,7 @@
 			break;
 	}
 }
-// *********************************************************************************************
 
-int Cfaac::check_image_header(const char *buf)
-{
-  if (!strncmp(buf, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8))
-    return 1; /* PNG */
-  else if (!strncmp(buf, "\xFF\xD8\xFF\xE0", 4) &&
-	   !strncmp(buf + 6, "JFIF\0", 5))
-    return 1; /* JPEG */
-  else if (!strncmp(buf, "GIF87a", 6) || !strncmp(buf, "GIF89a", 6))
-    return 1; /* GIF */
-  else
-    return 0;
-}
-// -----------------------------------------------------------------------------------------------
-
-int Cfaac::ReadCoverArtFile(char *pCoverArtFile, char **artData)
-{
-FILE *artFile;
-
-	if(!pCoverArtFile || !*pCoverArtFile)
-		return 0;
-
-	if(!(artFile=fopen(pCoverArtFile, "rb")))
-	{
-		MessageBox(NULL,"ReadCoverArtFile: fopen",NULL,MB_OK);
-		return 0;
-	}
-
-int r;
-char *art;
-int	artSize=0;
-
-	fseek(artFile, 0, SEEK_END);
-	artSize=ftell(artFile);
-	fseek(artFile, 0, SEEK_SET);
-
-	if(!(art=(char *)malloc(artSize)))
-	{
-		fclose(artFile);
-		MessageBox(NULL,"ReadCoverArtFile: Memory allocation error!", NULL, MB_OK);
-		return 0;
-	}
-
-	r=fread(art, 1, artSize, artFile);
-	if(r!=artSize)
-	{
-		free(art);
-		fclose(artFile);
-		MessageBox(NULL,"ReadCoverArtFile: Error reading cover art file!", NULL, MB_OK);
-		return 0;
-	}
-	else
-		if(artSize<12 || !check_image_header(art))
-		{
-			// the above expression checks the image signature
-			free(art);
-			fclose(artFile);
-			MessageBox(NULL,"ReadCoverArtFile: Unsupported cover image file format!", NULL, MB_OK);
-			return 0;
-		}
-
-	FREE_ARRAY(*artData);
-	*artData=art;
-	fclose(artFile);
-	return artSize;
-}
-
-void Cfaac::WriteMP4Tag(MP4FileHandle MP4File, MP4TAG *Tag)
-{
-char	*art=NULL;
-DWORD	artSize;
-
-char	buf[512], *faac_id_string, *faac_copyright_string;
-	sprintf(buf, "FAAC v%s", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version");
-	MP4SetMetadataTool(MP4File, buf);
-
-	if(Tag->artist) MP4SetMetadataArtist(MP4File, Tag->artist);
-	if(Tag->writer) MP4SetMetadataWriter(MP4File, Tag->writer);
-	if(Tag->title) MP4SetMetadataName(MP4File, Tag->title);
-	if(Tag->album) MP4SetMetadataAlbum(MP4File, Tag->album);
-	if(Tag->trackno>0) MP4SetMetadataTrack(MP4File, Tag->trackno, Tag->ntracks);
-	if(Tag->discno>0) MP4SetMetadataDisk(MP4File, Tag->discno, Tag->ndiscs);
-	if(Tag->compilation) MP4SetMetadataCompilation(MP4File, Tag->compilation);
-	if(Tag->year) MP4SetMetadataYear(MP4File, Tag->year);
-	if(Tag->genre) MP4SetMetadataGenre(MP4File, Tag->genre);
-	if(Tag->comment) MP4SetMetadataComment(MP4File, Tag->comment);
-	artSize=ReadCoverArtFile(Tag->artFileName,&art);
-	if(artSize)
-	{
-		MP4SetMetadataCoverArt(MP4File, (BYTE *)art, artSize);
-		free(art);
-	}
-}
-
-#define ADD_FIELD(id3Tag,NewFrame,ID3FID,ID3FN,data) \
-{ \
-	ID3_Frame *NewFrame=new ID3_Frame(ID3FID); \
-		NewFrame->Field(ID3FN)=data; \
-		id3Tag.AttachFrame(NewFrame); \
-}
-
-void Cfaac::WriteAacTag(char *Filename, MP4TAG *Tag)
-{
-char	buf[512], *faac_id_string, *faac_copyright_string;
-char	*art=NULL;
-DWORD	artSize;
-ID3_Tag id3Tag;
-ID3_Frame *Frame;
-
-	id3Tag.Link(Filename);
-//	Frame=id3Tag.Find(ID3FID_ALBUM);
-//	if(Frame!=NULL)
-//		myTag.RemoveFrame(Frame);
-
-	sprintf(buf, "FAAC v%s", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version");
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_ENCODEDBY,ID3FN_TEXT,buf);
-
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_LEADARTIST,ID3FN_TEXT,Tag->artist);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_COMPOSER,ID3FN_TEXT,Tag->writer);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_TITLE,ID3FN_TEXT,Tag->title);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_ALBUM,ID3FN_TEXT,Tag->album);
-	sprintf(buf,"%d",Tag->trackno);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_TRACKNUM,ID3FN_TEXT,buf);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_YEAR,ID3FN_TEXT,Tag->year);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_CONTENTTYPE,ID3FN_TEXT,Tag->genre);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_COMMENT,ID3FN_TEXT,Tag->comment);
-	artSize=ReadCoverArtFile(Tag->artFileName,&art);
-	if(artSize)
-	{
-		ADD_FIELD(id3Tag,NewFrame,ID3FID_PICTURE,ID3FN_PICTURETYPE,Tag->artFileName);
-		id3Tag.Update();
-		free(art);
-	}
-	else
-		id3Tag.Update();
-}
-
 // *********************************************************************************************
 //									Main functions
 // *********************************************************************************************
@@ -371,102 +316,10 @@
 }
 // *********************************************************************************************
 
-void Cfaac::FreeTag(MP4TAG *Tag)
-{
-	FREE_ARRAY(Tag->artist);
-	FREE_ARRAY(Tag->title);
-	FREE_ARRAY(Tag->album);
-	FREE_ARRAY(Tag->year);
-	FREE_ARRAY(Tag->genre);
-	FREE_ARRAY(Tag->writer);
-	FREE_ARRAY(Tag->comment);
-	FREE_ARRAY(Tag->artFileName);
-}
-// -----------------------------------------------------------------------------------------------
-
-void Cfaac::getFaacCfg(MY_ENC_CFG *cfg)
-{ 
-CRegistry reg;
-
-	if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAC"))
-	{
-		cfg->AutoCfg=reg.GetSetBool(REG_AUTO,DEF_AUTO);
-		cfg->SaveMP4=reg.GetSetBool(REG_WRITEMP4,DEF_WRITEMP4);
-		cfg->EncCfg.mpegVersion=reg.GetSetDword(REG_MPEGVER,DEF_MPEGVER); 
-		cfg->EncCfg.aacObjectType=reg.GetSetDword(REG_PROFILE,DEF_PROFILE); 
-		cfg->EncCfg.allowMidside=reg.GetSetDword(REG_MIDSIDE,DEF_MIDSIDE); 
-		cfg->EncCfg.useTns=reg.GetSetDword(REG_TNS,DEF_TNS); 
-		cfg->EncCfg.useLfe=reg.GetSetDword(REG_LFE,DEF_LFE);
-		cfg->UseQuality=reg.GetSetBool(REG_USEQUALTY,DEF_USEQUALTY);
-		cfg->EncCfg.quantqual=reg.GetSetDword(REG_QUALITY,DEF_QUALITY); 
-		cfg->EncCfg.bitRate=reg.GetSetDword(REG_BITRATE,DEF_BITRATE); 
-		cfg->EncCfg.bandWidth=reg.GetSetDword(REG_BANDWIDTH,DEF_BANDWIDTH); 
-		cfg->EncCfg.outputFormat=reg.GetSetDword(REG_HEADER,DEF_HEADER); 
-		cfg->OutDir=NULL;
-
-		cfg->Tag.On=reg.GetSetByte(REG_TAGON,0);
-		cfg->Tag.artist=reg.GetSetStr(REG_ARTIST,"");
-		cfg->Tag.title=reg.GetSetStr(REG_TITLE,"");
-		cfg->Tag.album=reg.GetSetStr(REG_ALBUM,"");
-		cfg->Tag.year=reg.GetSetStr(REG_YEAR,"");
-		cfg->Tag.genre=reg.GetSetStr(REG_GENRE,"");
-		cfg->Tag.writer=reg.GetSetStr(REG_WRITER,"");
-		cfg->Tag.comment=reg.GetSetStr(REG_COMMENT,"");
-		cfg->Tag.trackno=reg.GetSetDword(REG_TRACK,0);
-		cfg->Tag.ntracks=reg.GetSetDword(REG_NTRACKS,0);
-		cfg->Tag.discno=reg.GetSetDword(REG_DISK,0);
-		cfg->Tag.ndiscs=reg.GetSetDword(REG_NDISKS,0);
-		cfg->Tag.compilation=reg.GetSetByte(REG_COMPILATION,0);
-		cfg->Tag.artFileName=reg.GetSetStr(REG_ARTFILE,"");
-	}
-	else
-		MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
-}
-// -----------------------------------------------------------------------------------------------
-
-void Cfaac::setFaacCfg(MY_ENC_CFG *cfg)
-{ 
-CRegistry reg;
-
-	if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAC"))
-	{
-		reg.SetBool(REG_AUTO,cfg->AutoCfg); 
-		reg.SetBool(REG_WRITEMP4,cfg->SaveMP4); 
-		reg.SetDword(REG_MPEGVER,cfg->EncCfg.mpegVersion); 
-		reg.SetDword(REG_PROFILE,cfg->EncCfg.aacObjectType); 
-		reg.SetDword(REG_MIDSIDE,cfg->EncCfg.allowMidside); 
-		reg.SetDword(REG_TNS,cfg->EncCfg.useTns); 
-		reg.SetDword(REG_LFE,cfg->EncCfg.useLfe); 
-		reg.SetBool(REG_USEQUALTY,cfg->UseQuality); 
-		reg.SetDword(REG_QUALITY,cfg->EncCfg.quantqual); 
-		reg.SetDword(REG_BITRATE,cfg->EncCfg.bitRate); 
-		reg.SetDword(REG_BANDWIDTH,cfg->EncCfg.bandWidth); 
-		reg.SetDword(REG_HEADER,cfg->EncCfg.outputFormat); 
-
-		reg.SetByte(REG_TAGON,cfg->Tag.On);
-		reg.SetStr(REG_ARTIST,cfg->Tag.artist);
-		reg.SetStr(REG_TITLE,cfg->Tag.title);
-		reg.SetStr(REG_ALBUM,cfg->Tag.album);
-		reg.SetStr(REG_YEAR,cfg->Tag.year);
-		reg.SetStr(REG_GENRE,cfg->Tag.genre);
-		reg.SetStr(REG_WRITER,cfg->Tag.writer);
-		reg.SetStr(REG_COMMENT,cfg->Tag.comment);
-		reg.SetDword(REG_TRACK,cfg->Tag.trackno); 
-		reg.SetDword(REG_NTRACKS,cfg->Tag.ntracks); 
-		reg.SetDword(REG_DISK,cfg->Tag.discno); 
-		reg.SetDword(REG_NDISKS,cfg->Tag.ndiscs); 
-		reg.SetByte(REG_COMPILATION,cfg->Tag.compilation); 
-		reg.SetStr(REG_ARTFILE,cfg->Tag.artFileName);
-	}
-	else
-		MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
-}
-// *********************************************************************************************
-
 HANDLE Cfaac::Init(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long FileSize)
 {
 MYOUTPUT	*mo;
-MY_ENC_CFG	cfg;
+CMyEncCfg	cfg(false);
 DWORD		samplesInput,
 			maxBytesOutput;
 
@@ -490,8 +343,6 @@
 	if(!(mo->buf32bit=(int32_t *)malloc(samplesInput*sizeof(int32_t))))
 		return ERROR_Init("Memory allocation error: 32 bit buffer");
 
-	getFaacCfg(&cfg);
-
 	if(cfg.SaveMP4)// || cfg.Tag.On)
 		if(!strcmpi(lpstrFilename+lstrlen(lpstrFilename)-4,".aac"))
 		{
@@ -539,16 +390,16 @@
 			CurFormat->bitRate=0;//myFormat->bitRate;
 		}
 		else
-			if(!CurFormat->bitRate)
-				CurFormat->bitRate=myFormat->bitRate;
-			else
-				CurFormat->bitRate*=1000;
+		{
+			CurFormat->bitRate=myFormat->bitRate*1000;
+			CurFormat->quantqual=100;
+		}
 
 		switch(CurFormat->bandWidth)
 		{
-		case 0:
+		case 0: // Auto
 			break;
-		case 0xffffffff:
+		case 0xffffffff: // Full
 			CurFormat->bandWidth=lSamprate/2;
 			break;
 		default:
@@ -605,8 +456,8 @@
 		mo->frameSize=samplesInput/wChannels;
 		mo->ofs=mo->frameSize;
 
-		if(cfg.Tag.On)
-			WriteMP4Tag(mo->MP4File,&cfg.Tag);
+		if(cfg.TagOn)
+			cfg.Tag.WriteMP4Tag(mo->MP4File);
 	}
 	else // Create AAC file -----------------------------------------------------------------------------
 	{
@@ -622,7 +473,6 @@
 
 	showInfo(mo);
 
-	FreeTag(&cfg.Tag);
 	GlobalUnlock(hOutput);
     return hOutput;
 }
@@ -659,7 +509,7 @@
 		if(bytesEncoded>0)
 		{
 			if((bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->aacFile))!=bytesEncoded)
-				return ERROR_processData("fwrite");
+				return ERROR_processData("Write failed!");
 			mo->WrittenSamples=1; // needed into destructor
 		}
 	}
@@ -682,7 +532,7 @@
 		if(bytesEncoded>0)
 		{
 			if(!(bytesWritten=MP4WriteSample(mo->MP4File, mo->MP4track, (unsigned __int8 *)mo->bitbuf, (DWORD)bytesEncoded, dur, mo->ofs, true) ? bytesEncoded : -1))
-				return ERROR_processData("MP4WriteSample");
+				return ERROR_processData("MP4WriteSample()");
 			mo->ofs=0;
 			mo->WrittenSamples+=dur;
 		}
--- a/plugins/cooledit/Cfaac.h
+++ b/plugins/cooledit/Cfaac.h
@@ -37,8 +37,8 @@
 #endif
 #include <faac.h>
 #include <win32_ver.h>	// mpeg4ip version
-#include <id3/tag.h>	// id3 tag
 #include "CRegistry.h"
+#include "CTag.h"
 #include "Defines.h"	// my defines
 
 // *********************************************************************************************
@@ -75,42 +75,33 @@
 #define REG_HEADER "Header"
 #define DEF_HEADER ADTS
 
-#define REG_TAGON "Tag On"
-#define REG_ARTIST "Tag Artist"
-#define REG_TITLE "Tag Title"
-#define REG_ALBUM "Tag Album"
-#define REG_YEAR "Tag Year"
-#define REG_GENRE "Tag Genre"
-#define REG_WRITER "Tag Writer"
-#define REG_COMMENT "Tag Comment"
-#define REG_TRACK "Tag Track"
-#define REG_NTRACKS "Tag Tracks"
-#define REG_DISK "Tag Disk"
-#define REG_NDISKS "Tag Disks"
-#define REG_COMPILATION "Tag Compilation"
-#define REG_ARTFILE "Tag Art file"
+#define REG_OutFolder "Output folder"
 
 // *********************************************************************************************
 
-typedef struct
+class CMyEncCfg
 {
-BYTE	On;
-char	*artist, *title, *album, *year, *genre, *writer, *comment;
-int		trackno,ntracks, discno,ndiscs;
-BYTE	compilation;
-char	*artFileName;
-} MP4TAG;
-// -----------------------------------------------------------------------------------------------
+private:
 
-typedef struct mec
-{
-bool					AutoCfg,
-						UseQuality,
-						SaveMP4;
-char					*OutDir;
-faacEncConfiguration	EncCfg;
-MP4TAG					Tag;
-} MY_ENC_CFG;
+	bool SaveCfgOnDestroy;
+
+public:
+
+	CMyEncCfg(bool SaveOnDestroy=true) { getCfg(this); SaveCfgOnDestroy=SaveOnDestroy; }
+	virtual ~CMyEncCfg() { if(SaveCfgOnDestroy) setCfg(this); FreeCfg(this); }
+
+	void FreeCfg(CMyEncCfg *cfg) { Tag.FreeTag(); FREE_ARRAY(OutDir); }
+	void getCfg(CMyEncCfg *cfg);
+	void setCfg(CMyEncCfg *cfg);
+
+	bool					AutoCfg,
+							UseQuality,
+							SaveMP4;
+	char					*OutDir;
+	faacEncConfiguration	EncCfg;
+	CMP4Tag					Tag;
+	BYTE					TagOn;
+};
 // -----------------------------------------------------------------------------------------------
 
 typedef struct output_tag  // any special vars associated with output file
@@ -161,18 +152,11 @@
 	virtual void showInfo(MYOUTPUT *mi) {}
 	virtual void showProgress(MYOUTPUT *mi) {}
 	void To32bit(int32_t *buf, BYTE *bufi, int size, BYTE samplebytes, BYTE bigendian);
-	int check_image_header(const char *buf);
-	int ReadCoverArtFile(char *pCoverArtFile, char **artBuf);
 
 public:
     Cfaac(HANDLE hOutput=NULL);
     virtual ~Cfaac();
 
-	static void FreeTag(MP4TAG *Tag);
-	static void getFaacCfg(MY_ENC_CFG *cfg);
-	static void setFaacCfg(MY_ENC_CFG *cfg);
-	virtual void WriteMP4Tag(MP4FileHandle MP4File, MP4TAG *Tag);
-	virtual void WriteAacTag(char *Filename, MP4TAG *Tag);
     virtual HANDLE Init(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long FileSize);
     virtual int processData(HANDLE hOutput, BYTE *bufIn, DWORD len);
 	virtual int processDataBufferized(HANDLE hOutput, BYTE *bufIn, long lBytes);
--- a/plugins/cooledit/Cfaad.cpp
+++ b/plugins/cooledit/Cfaad.cpp
@@ -29,6 +29,9 @@
 
 Cfaad::Cfaad(HANDLE hIn)
 {
+	ShowDlg4RawAAC=NULL;
+	pCfg=NULL;
+
 	if(hIn)
 	{
 		hInput=hIn;
@@ -48,11 +51,11 @@
     mi->buffer=0;
 	mi->bytes_read=0;*/
 	mi->BitsPerSample=16;
-//	newpos_ms=-1;
-//	seek_table=0;
-//	seek_table_length=0;
 	mi->FindBitrate=FALSE;
-//	BlockSeeking=false;
+	newpos_ms=-1;
+	mi->seek_table=NULL;
+	mi->seek_table_length=0;
+	mi->LockSeeking=false;
 	GlobalUnlock(hInput);
 }
 // -----------------------------------------------------------------------------------------------
@@ -73,7 +76,7 @@
 	if(mi->hDecoder)
 		faacDecClose(mi->hDecoder);
 	FREE_ARRAY(mi->buffer);
-//	FREE_ARRAY(mi->seek_table);
+	FREE_ARRAY(mi->seek_table);
 
 	GlobalUnlock(hInput);
 	GlobalFree(hInput);
@@ -134,13 +137,27 @@
 	return 0;
 }
 // *********************************************************************************************
+long Cfaad::id3v2_TagSize(unsigned char *buffer)
+{
+	if(StringComp((const char *)buffer, "ID3", 3) == 0)
+	{
+	unsigned long tagsize;
 
+	// high bit is not used
+		tagsize =	(buffer[6] << 21) | (buffer[7] << 14) |
+					(buffer[8] <<  7) | (buffer[9] <<  0);
+		tagsize += 10;
+		return tagsize;
+	}
+	return 0;
+}
+/*
 long Cfaad::id3v2_TagSize(aac_buffer *b)
 {
 DWORD    tagsize = 0;
     if (!memcmp(b->buffer, "ID3", 3))
     {
-        /* high bit is not used */
+        // high bit is not used
         tagsize = (b->buffer[6] << 21) | (b->buffer[7] << 14) |
             (b->buffer[8] <<  7) | (b->buffer[9] <<  0);
 
@@ -215,14 +232,14 @@
     int samplerate;
     float frames_per_sec, bytes_per_frame;
 
-    /* Read all frames to ensure correct time and bitrate */
-    for (frames = 0; /* */; frames++)
+    // Read all frames to ensure correct time and bitrate
+    for (frames = 0; ; frames++)
     {
         fill_buffer(b);
 
         if (b->bytes_into_buffer > 7)
         {
-            /* check syncword */
+            // check syncword 
             if (!((b->buffer[0] == 0xFF)&&((b->buffer[1] & 0xF6) == 0xF0)))
                 break;
 
@@ -258,11 +275,11 @@
 }
 // *********************************************************************************************
 
-/* get AAC infos for printing */
+// get AAC infos for printing 
 void Cfaad::GetAACInfos(aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate, long filesize)
 {
-int		bitrate;
-float	length;
+int		bitrate=0;
+float	length=0;
 int		bread;
 long	tagsize=id3v2_TagSize(b);
 
@@ -306,23 +323,59 @@
 	*pbitrate=bitrate;
 }
 
+void Cfaad::GetAACInfos(char *Filename, aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate)
+{
+	if(!(b->infile=fopen(Filename,"rb")))
+	{
+		MessageBox(NULL,"Error opening file",NULL,MB_OK);
+		return;
+	}
+	fseek(b->infile, 0, SEEK_END);
+long	src_size=ftell(b->infile);
+	fseek(b->infile, 0, SEEK_SET);
+	if(!(b->buffer=(BYTE *)malloc(FAAD_STREAMSIZE)))
+	{
+		MessageBox(NULL,"Memory allocation error: b->buffer",NULL,MB_OK);
+		return;
+	}
+
+int	tread=src_size<FAAD_STREAMSIZE ? src_size : FAAD_STREAMSIZE;
+	b->bytes_into_buffer=fread(b->buffer, 1, tread, b->infile);
+	if(b->bytes_into_buffer!=tread)
+	{
+		MessageBox(NULL,"Read failed!",NULL,MB_OK);
+		return;
+	}
+	b->bytes_consumed=0;
+	b->file_offset=0;
+	b->at_eof=(b->bytes_into_buffer!=tread) ? 1 : 0;
+
+	*header_type = 0;
+	b->file_offset=0;
+
+	GetAACInfos(b,header_type,song_length,pbitrate,src_size);
+
+	free(b->buffer);
+	fclose(b->infile);
+}
+*/
 // *********************************************************************************************
 //									Main functions
 // *********************************************************************************************
 
-void Cfaad::ReadCfgDec(MY_DEC_CFG *cfg) 
+void CMyDecCfg::getCfg(CMyDecCfg *cfg) 
 { 
 CRegistry reg;
 
-if(reg.OpenCreate(HKEY_LOCAL_MACHINE, REGISTRY_PROGRAM_NAME "\\FAAD"))
+if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAD"))
 	{
-		cfg->DefaultCfg=reg.GetSetBool("Default",true);
-		cfg->DecCfg.defObjectType=reg.GetSetByte("Profile",LC);
-		cfg->DecCfg.defSampleRate=reg.GetSetDword("SampleRate",44100);
-		cfg->DecCfg.outputFormat=reg.GetSetByte("Bps",FAAD_FMT_16BIT);
-		cfg->DecCfg.downMatrix=reg.GetSetByte("Downmatrix",0);
-		cfg->DecCfg.useOldADTSFormat=reg.GetSetByte("Old ADTS",0);
-		cfg->DecCfg.dontUpSampleImplicitSBR=reg.GetSetByte("Don\'t upsample implicit SBR",1);
+		cfg->DefaultCfg=reg.GetSetBool(REG_DEFAULT,true);
+		cfg->DecCfg.defObjectType=reg.GetSetByte(REG_PROFILE,LC);
+		cfg->DecCfg.defSampleRate=reg.GetSetDword(REG_SAMPLERATE,44100);
+		cfg->DecCfg.outputFormat=reg.GetSetByte(REG_BPS,FAAD_FMT_16BIT);
+		cfg->DecCfg.downMatrix=reg.GetSetByte(REG_DOWNMATRIX,0);
+		cfg->DecCfg.useOldADTSFormat=reg.GetSetByte(REG_OLDADTS,0);
+		cfg->DecCfg.dontUpSampleImplicitSBR=reg.GetSetByte(REG_DONTUPSAMPLESBR,1);
 //		cfg->Channels=reg.GetSetByte("Channels",2);
 	}
 	else
@@ -330,19 +383,19 @@
 }
 // -----------------------------------------------------------------------------------------------
 
-void Cfaad::WriteCfgDec(MY_DEC_CFG *cfg)
+void CMyDecCfg::setCfg(CMyDecCfg *cfg)
 { 
 CRegistry reg;
 
-	if(reg.OpenCreate(HKEY_LOCAL_MACHINE, REGISTRY_PROGRAM_NAME "\\FAAD"))
+	if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAD"))
 	{
-		reg.SetBool("Default",cfg->DefaultCfg);
-		reg.SetByte("Profile",cfg->DecCfg.defObjectType);
-		reg.SetDword("SampleRate",cfg->DecCfg.defSampleRate);
-		reg.SetByte("Bps",cfg->DecCfg.outputFormat);
-		reg.SetByte("Downmatrix",cfg->DecCfg.downMatrix);
-		reg.SetByte("Old ADTS",cfg->DecCfg.useOldADTSFormat);
-		reg.SetByte("Don\'t upsample implicit SBR",cfg->DecCfg.dontUpSampleImplicitSBR);
+		reg.SetBool(REG_DEFAULT,cfg->DefaultCfg);
+		reg.SetByte(REG_PROFILE,cfg->DecCfg.defObjectType);
+		reg.SetDword(REG_SAMPLERATE,cfg->DecCfg.defSampleRate);
+		reg.SetByte(REG_BPS,cfg->DecCfg.outputFormat);
+		reg.SetByte(REG_DOWNMATRIX,cfg->DecCfg.downMatrix);
+		reg.SetByte(REG_OLDADTS,cfg->DecCfg.useOldADTSFormat);
+		reg.SetByte(REG_DONTUPSAMPLESBR,cfg->DecCfg.dontUpSampleImplicitSBR);
 //		reg.SetByte("Channels",cfg->Channels);
 	}
 	else
@@ -350,36 +403,42 @@
 }
 // *********************************************************************************************
 
-void Cfaad::setFaadCfg(faacDecHandle hDecoder)
+void Cfaad::setFaadCfg(faacDecHandle hDecoder, CMyDecCfg Cfg)
 {
-faacDecConfigurationPtr	config;
+faacDecConfigurationPtr	config=faacDecGetCurrentConfiguration(hDecoder);
 
-	config=faacDecGetCurrentConfiguration(hDecoder);
-	config->outputFormat = FAAD_FMT_16BIT;
-	config->downMatrix = 0;
-	config->useOldADTSFormat = 0;
-	config->dontUpSampleImplicitSBR = 1;
-	faacDecSetConfiguration(hDecoder, config);
-/*
-	ReadCfgDec(&Cfg);
-	if(!Bitrate4RawAAC)
-		DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_DECODER),(HWND)hWnd, (DLGPROC)DialogMsgProcDecoder, (DWORD)&Cfg);
-	config=faacDecGetCurrentConfiguration(mi->hDecoder);
-	if(Cfg.DefaultCfg)
+	if(!Cfg.DefaultCfg)
 	{
-		config->defObjectType=mi->file_info.object_type;
-		config->defSampleRate=mi->file_info.sampling_rate;//*lSamprate; // doesn't work!
+		config->defObjectType=Cfg.DecCfg.defObjectType;
+		config->outputFormat=Cfg.DecCfg.outputFormat;
+		config->defSampleRate=Cfg.DecCfg.defSampleRate;
+		config->downMatrix=Cfg.DecCfg.downMatrix;
+		config->useOldADTSFormat=Cfg.DecCfg.useOldADTSFormat;
+		config->dontUpSampleImplicitSBR=1;
 	}
 	else
 	{
-		config->defObjectType=Cfg.DecCfg.defObjectType;
-		config->defSampleRate=Cfg.DecCfg.defSampleRate;
+		config->defObjectType=LC;
+		config->outputFormat=FAAD_FMT_16BIT;
+		config->defSampleRate=44100;
+		config->downMatrix=0;
+		config->useOldADTSFormat=0;
+		config->dontUpSampleImplicitSBR=1;
 	}
-	config->outputFormat=FAAD_FMT_16BIT;
-	faacDecSetConfiguration(mi->hDecoder, config);*/
+	faacDecSetConfiguration(hDecoder, config);
 }
 // -----------------------------------------------------------------------------------------------
 
+void Cfaad::setDefaultFaadCfg(faacDecHandle hDecoder, BOOL showDlg)
+{
+	if(showDlg && ShowDlg4RawAAC)
+		ShowDlg4RawAAC();
+
+CMyDecCfg Cfg(false);
+	setFaadCfg(hDecoder,Cfg);
+}
+// -----------------------------------------------------------------------------------------------
+
 void Cfaad::DisplayError(char *ProcName, char *str)
 {
 MYINPUT *mi;
@@ -404,8 +463,12 @@
 {
 MYINPUT *mi;
 
-	GLOBALLOCK(mi,hInput,MYINPUT,return 0);
+// test tags
+//CMyDecCfg cfg;	cfg.Tag.ReadMp4Tag(lpstrFilename);
+//CMyDecCfg cfg;	cfg.Tag.ReadAacTag(lpstrFilename);
 
+	GLOBALLOCK(mi,hInput,MYINPUT,return NULL);
+
 //	mi->IsAAC=strcmpi(lpstrFilename+lstrlen(lpstrFilename)-4,".aac")==0;
 	if((mi->IsMP4=IsMP4(lpstrFilename))==-1)
 		return ERROR_getInfos("Error opening file");
@@ -429,7 +492,7 @@
 
 		MP4GetTrackESConfiguration(mi->mp4File, mi->track, (unsigned __int8 **)&mi->buffer, &buffer_size);
 		if(!mi->buffer)
-			return ERROR_getInfos("MP4GetTrackESConfiguration");
+			return ERROR_getInfos("MP4GetTrackESConfiguration()");
 		AudioSpecificConfig(mi->buffer, buffer_size, &mp4ASC);
 
         timeScale = mp4ASC.samplingFrequency;
@@ -448,6 +511,9 @@
 		mi->file_info.version=MP4GetTrackAudioType(mi->mp4File, mi->track)==MP4_MPEG4_AUDIO_TYPE ? 4 : 2;
 		mi->numSamples=MP4GetTrackNumberOfSamples(mi->mp4File, mi->track);
 		mi->sampleId=1;
+
+		mi->IsSeekable=true;
+		mi->LockSeeking=!mi->IsSeekable;
 	}
 	else // AAC file ------------------------------------------------------------------------------
 	{   
@@ -479,14 +545,51 @@
 		else
 			return ERROR_getInfos("Read failed!");
 
-aac_buffer	b;
-float		fLength;
-DWORD		headertype;
+		// skip Tag
+	long tagsize;
+		if(tagsize=id3v2_TagSize(mi->buffer))
+		{
+			if(tagsize>(long)mi->src_size)
+				ERROR_getInfos("Corrupt stream!");
+			if(tagsize<mi->bytes_into_buffer)
+			{
+				mi->bytes_into_buffer-=tagsize;
+				memcpy(mi->buffer,mi->buffer+tagsize,mi->bytes_into_buffer);
+			}
+			else
+			{
+				mi->bytes_read=tagsize;
+				mi->bytes_into_buffer=0;
+				if(tagsize>mi->bytes_into_buffer)
+					fseek(mi->aacFile, tagsize, SEEK_SET);
+			}
+			if(mi->src_size<mi->bytes_read+FAAD_STREAMSIZE-mi->bytes_into_buffer)
+				tmp=mi->src_size-mi->bytes_read;
+			else
+				tmp=FAAD_STREAMSIZE-mi->bytes_into_buffer;
+			read=fread(mi->buffer+mi->bytes_into_buffer, 1, tmp, mi->aacFile);
+			if(read==tmp)
+			{
+				mi->bytes_read+=read;
+				mi->bytes_into_buffer+=read;
+			}
+			else
+				ERROR_getInfos("Read failed!");
+		}
+
+		if(get_AAC_format(lpstrFilename, &mi->file_info, &mi->seek_table, &mi->seek_table_length, 0))
+			ERROR_getInfos("get_AAC_format()");
+		mi->IsSeekable=mi->file_info.headertype==ADTS && mi->seek_table && mi->seek_table_length>0;
+		mi->LockSeeking=!mi->IsSeekable;
+/*
+	aac_buffer	b;
+	float		fLength;
+	DWORD		headertype;
 		b.infile=mi->aacFile;
 		b.buffer=mi->buffer;
 	    b.bytes_into_buffer=read;
 		b.bytes_consumed=mi->bytes_consumed;
-//		b.file_offset=mi->tagsize;
+		b.file_offset=0;
 		b.at_eof=(read!=tmp) ? 1 : 0;
 		GetAACInfos(&b,&headertype,&fLength,&mi->file_info.bitrate,mi->src_size);
 		mi->file_info.bitrate*=1024;
@@ -493,70 +596,67 @@
 		mi->file_info.headertype=headertype;
         mi->bytes_into_buffer=b.bytes_into_buffer;
         mi->bytes_consumed=b.bytes_consumed;
-//		mi->bytes_read=b.file_offset;
-
-/*		IsSeekable=mi->file_info.headertype==ADTS && fLength>0;
-		BlockSeeking=!IsSeekable;
+		IsSeekable=false; // only mp4 can be seeked
 */
+		if(!mi->FindBitrate) // open a new instance to get info from decoder
+		{
+		MYINPUT *miTmp;
+		Cfaad	*NewInst;
+			if(!(NewInst=new Cfaad()))
+				return ERROR_getInfos("Memory allocation error: NewInst");
+
+			GLOBALLOCK(miTmp,NewInst->hInput,MYINPUT,return 0);
+			miTmp->FindBitrate=TRUE;
+			NewInst->ShowDlg4RawAAC=ShowDlg4RawAAC;
+			NewInst->pCfg=pCfg;
+			if(!NewInst->getInfos(lpstrFilename))
+				return ERROR_getInfos(0);
+			mi->Channels=miTmp->frameInfo.channels;
+			if(mi->file_info.headertype==RAW)
+				mi->file_info.bitrate=miTmp->file_info.bitrate;//*mi->Channels;
+			mi->Samprate=miTmp->Samprate;
+			mi->file_info.headertype=miTmp->file_info.headertype;
+			mi->file_info.object_type=miTmp->file_info.object_type;
+			mi->file_info.version=miTmp->file_info.version;
+			GlobalUnlock(NewInst->hInput);
+			delete NewInst;
+		}
+
 		if(!(mi->hDecoder=faacDecOpen()))
 			return ERROR_getInfos("Can't open library");
-
 		if(mi->file_info.headertype==RAW)
-			setFaadCfg(mi->hDecoder);
-		if((mi->bytes_consumed=faacDecInit(mi->hDecoder, mi->buffer, mi->bytes_into_buffer, &mi->Samprate, &mi->Channels))<0)
-			return ERROR_getInfos("faacDecInit failed!");
+			if(pCfg)
+				setFaadCfg(mi->hDecoder,*pCfg);
+			else
+				setDefaultFaadCfg(mi->hDecoder,mi->FindBitrate);
+	BYTE Channels; // faacDecInit doesn't report correctly the number of channels in raw aac files
+		if((mi->bytes_consumed=faacDecInit(mi->hDecoder, mi->buffer, mi->bytes_into_buffer, &mi->Samprate, &Channels))<0)
+			return ERROR_getInfos("faacDecInit()");
 		mi->bytes_into_buffer-=mi->bytes_consumed;
 
-//		if(mi->file_info.headertype==RAW)
-			if(!mi->FindBitrate)
-			{
-			MYINPUT *miTmp;
-			Cfaad	*NewInst;
-				if(!(NewInst=new Cfaad()))
-					return ERROR_getInfos("Memory allocation error: NewInst");
+		if(mi->FindBitrate) // get info from decoder
+		{
+		DWORD	Samples,
+				BytesConsumed;
 
-				GLOBALLOCK(miTmp,NewInst->hInput,MYINPUT,return 0);
-				miTmp->FindBitrate=TRUE;
-				if(!NewInst->getInfos(lpstrFilename))
-					return ERROR_getInfos(0);
-				mi->Channels=miTmp->frameInfo.channels;
-				if(mi->file_info.headertype==RAW)
-					mi->file_info.bitrate=miTmp->file_info.bitrate*mi->Channels;
-				mi->Samprate=miTmp->Samprate;
-				mi->file_info.headertype=miTmp->file_info.headertype;
-				mi->file_info.object_type=miTmp->file_info.object_type;
-				mi->file_info.version=miTmp->file_info.version;
-				GlobalUnlock(NewInst->hInput);
-				delete NewInst;
-			}
-			else
-			{
-			DWORD	Samples,
-					BytesConsumed;
+			if(!processData(hInput,0,0))
+				return ERROR_getInfos(0);
+			Samples=mi->frameInfo.samples/sizeof(short);
+			BytesConsumed=mi->frameInfo.bytesconsumed;
+			if(mi->file_info.headertype==RAW || !mi->file_info.bitrate)
+				mi->file_info.bitrate=(BytesConsumed*8*mi->Samprate)/(Samples*2);
+			if(!mi->file_info.bitrate)
+				return ERROR_getInfos("Can't determine the bitrate");
+		}
 
-//				if((mi->bytes_consumed=faacDecInit(mi->hDecoder,mi->buffer,mi->bytes_into_buffer,&mi->Samprate,&mi->Channels))<0)
-//					return ERROR_getInfos("Can't init library");
-//				mi->bytes_into_buffer-=mi->bytes_consumed;
-				if(!processData(hInput,0,0))
-					return ERROR_getInfos(0);
-				Samples=mi->frameInfo.samples/sizeof(short);
-				BytesConsumed=mi->frameInfo.bytesconsumed;
-				processData(hInput,0,0);
-				if(BytesConsumed<mi->frameInfo.bytesconsumed)
-					BytesConsumed=mi->frameInfo.bytesconsumed;
-				if(mi->file_info.headertype==RAW)
-					mi->file_info.bitrate=(BytesConsumed*8*mi->Samprate)/Samples;
-				if(!mi->file_info.bitrate)
-					mi->file_info.bitrate=1000; // try to continue decoding
-			}
-
-		mi->len_ms=(DWORD)((1000*((float)mi->src_size*8))/mi->file_info.bitrate);
+		mi->len_ms=(DWORD)((mi->src_size<<3)/(mi->file_info.bitrate>>10));
+//		mi->len_ms=(DWORD)((1000*((float)mi->src_size*8))/mi->file_info.bitrate);
 	}
 
 	if(mi->len_ms)
 		mi->dst_size=(DWORD)(mi->len_ms*((float)mi->Samprate/1000)*mi->Channels*(mi->BitsPerSample/8));
 	else
-		mi->dst_size=mi->src_size; // corrupt stream?
+		return ERROR_getInfos("Can't determine the length");
 
 	showInfo(mi);
 
@@ -575,11 +675,26 @@
 
 	GLOBALLOCK(mi,hInput,MYINPUT,return 0);
 
+	if(mi->LockSeeking)
+	{
+		NoSeek();
+		mi->LockSeeking=false;
+	}
+
 	if(mi->IsMP4) // MP4 file --------------------------------------------------------------------------
 	{   
 	unsigned __int32 buffer_size=0;
     int rc;
 
+		if(newpos_ms>-1)
+		{
+		MP4Duration duration=MP4ConvertToTrackDuration(mi->mp4File,mi->track,newpos_ms,MP4_MSECS_TIME_SCALE);
+		MP4SampleId sampleId=MP4GetSampleIdFromTime(mi->mp4File,mi->track,duration,0);
+			mi->bytes_read=(DWORD)(((float)newpos_ms*mi->file_info.bitrate)/(8*1000));
+			if(seek(mi->bytes_read))  // update the slider
+				return ERROR_processData(0);
+			newpos_ms=-1;
+		}
 		do
 		{
 			buffer=NULL;
@@ -590,7 +705,7 @@
 			if(rc==0 || buffer==NULL)
 			{
 				FREE_ARRAY(buffer);
-				return ERROR_processData("MP4ReadSample");
+				return ERROR_processData("MP4ReadSample()");
 			}
 
 			sample_buffer=(char *)faacDecDecode(mi->hDecoder,&mi->frameInfo,buffer,buffer_size);
@@ -597,12 +712,32 @@
 			BytesDecoded=mi->frameInfo.samples*sizeof(short);
 			if(BytesDecoded>(DWORD)lBytes)
 				BytesDecoded=lBytes;
-			memcpy(bufout,sample_buffer,BytesDecoded);
+			memmove(bufout,sample_buffer,BytesDecoded);
 			FREE_ARRAY(buffer);
+			// to update the slider
+			mi->bytes_read+=buffer_size;
+			if(seek(mi->bytes_read))
+				return ERROR_processData(0);
 		}while(!BytesDecoded && !mi->frameInfo.error);
 	}
 	else // AAC file --------------------------------------------------------------------------
 	{   
+		if(newpos_ms>-1)
+		{
+			if(mi->IsSeekable)
+			{
+			DWORD normalized=mi->len_ms/(mi->seek_table_length-1);
+				if(normalized<1000)
+					normalized=1000;
+				mi->bytes_read=mi->seek_table[newpos_ms/normalized];
+				fseek(mi->aacFile, mi->bytes_read, SEEK_SET);
+				if(seek(mi->bytes_read))  // update the slider
+					return ERROR_processData(0);
+				mi->bytes_into_buffer=0;
+				mi->bytes_consumed=FAAD_STREAMSIZE;
+			}
+			newpos_ms=-1;
+		}
 		buffer=mi->buffer;
 		do
 		{
@@ -639,7 +774,7 @@
 
 			if(mi->bytes_into_buffer<1)
 				if(mi->bytes_read<mi->src_size)
-					return ERROR_processData("ReadFilterInput: buffer empty!");
+					return ERROR_processData("Buffer empty!");
 				else
 					return ERROR_processData(0);
 
@@ -650,11 +785,10 @@
 				if(BytesDecoded>(DWORD)lBytes)
 					BytesDecoded=lBytes;
 				if(sample_buffer && BytesDecoded && !mi->frameInfo.error)
-					memcpy(bufout,sample_buffer,BytesDecoded);
+					memmove(bufout,sample_buffer,BytesDecoded);
 			}
 			else // Data needed to decode Raw files
 			{
-				mi->bytesconsumed=mi->frameInfo.bytesconsumed;
 				mi->Channels=mi->frameInfo.channels;
 				mi->file_info.object_type=mi->frameInfo.object_type;
 			}
--- a/plugins/cooledit/Cfaad.h
+++ b/plugins/cooledit/Cfaad.h
@@ -23,7 +23,7 @@
 #define _Cfaad_H
 
 #include <mp4.h>
-#include "faac.h"
+#include <faac.h>
 
 #ifdef MAIN
 	#undef MAIN
@@ -35,24 +35,18 @@
 	#undef LTP
 #endif
 
-#include "faad.h"
+#include <faad.h>
+extern "C" {
+	#include <aacinfo.h>    // get_AAC_format()
+}
 #include "Defines.h"
 #include "CRegistry.h"
+#include "CTag.h"
 
-#if RAW!=0
-	#undef RAW
-	#define RAW 0
-#endif
-#if ADTS!=1
-	#undef ADTS
-	#define ADTS 1
-#endif
-#if ADIF!=2
-	#undef ADIF
-	#define ADIF 2
-#endif
 
 
+// *********************************************************************************************
+
 // make this higher to support files with more channels
 #define MAX_CHANNELS 6
 #if FAAD_MIN_STREAMSIZE<2048
@@ -63,14 +57,22 @@
 
 #define	FAAD_STREAMSIZE	(FAAD_MIN_STREAMSIZE*MAX_CHANNELS)
 
+// -----------------------------------------------------------------------------------------------
 
+#define REG_DEFAULT "Default"
+#define REG_PROFILE "Profile"
+#define REG_SAMPLERATE "SampleRate"
+#define REG_BPS "Bps"
+#define REG_DOWNMATRIX "Downmatrix"
+#define REG_OLDADTS "Old ADTS"
+#define REG_DONTUPSAMPLESBR "Don\'t upsample implicit SBR"
 
-// -----------------------------------------------------------------------------------------------
+// *********************************************************************************************
 
 
 
 /* FAAD file buffering routines */
-typedef struct {
+/*typedef struct {
     long bytes_into_buffer;
     long bytes_consumed;
     long file_offset;
@@ -89,15 +91,34 @@
     int object_type;
     int headertype;
 } faadAACInfo;
-// -----------------------------------------------------------------------------------------------
+*/
 
-typedef struct mdc
+// *********************************************************************************************
+
+class CMyDecCfg
 {
-bool					DefaultCfg;
-BYTE					Channels;
-DWORD					BitRate;
-faacDecConfiguration	DecCfg;
-} MY_DEC_CFG;
+private:
+
+	bool SaveCfgOnDestroy;
+
+public:
+
+	CMyDecCfg(bool SaveOnDestroy=true) { getCfg(this); SaveCfgOnDestroy=SaveOnDestroy; }
+	virtual ~CMyDecCfg() { if(SaveCfgOnDestroy) setCfg(this); FreeCfg(this); }
+
+	void FreeCfg(CMyDecCfg *cfg) { cfg->Tag.FreeTag(); }
+	void FreeCfg() { this->Tag.FreeTag(); }
+	void getCfg(CMyDecCfg *cfg);
+	void getCfg() { getCfg(this); }
+	void setCfg(CMyDecCfg *cfg);
+	void setCfg() { setCfg(this); }
+
+	bool					DefaultCfg;
+	BYTE					Channels;
+	DWORD					BitRate;
+	faacDecConfiguration	DecCfg;
+	CMP4Tag					Tag;
+};
 // -----------------------------------------------------------------------------------------------
 
 typedef struct input_tag // any special vars associated with input file
@@ -117,9 +138,10 @@
 long			bytes_consumed;	// from buffer by faadDecDecode
 long			bytes_into_buffer;
 unsigned char	*buffer;
+DWORD			*seek_table;
+int				seek_table_length;
 
 // Raw AAC
-DWORD			bytesconsumed;	// to decode current frame by faadDecDecode
 BOOL			FindBitrate;
 
 // GLOBAL
@@ -133,6 +155,8 @@
 DWORD			dst_size;		// size of decoded file. Cooledit needs it to update its progress bar
 //char			*src_name;		// name of compressed file
 int				IsMP4;
+bool			LockSeeking,
+				IsSeekable;
 } MYINPUT;
 // -----------------------------------------------------------------------------------------------
 
@@ -140,35 +164,37 @@
 {
 private:
 	virtual int GetAACTrack(MP4FileHandle infile);
-	long id3v2_TagSize(aac_buffer *b);
+	long id3v2_TagSize(unsigned char *buffer);
+/*	long id3v2_TagSize(aac_buffer *b);
 	int fill_buffer(aac_buffer *b);
 	void advance_buffer(aac_buffer *b, int bytes);
 	int adts_parse(aac_buffer *b, int *bitrate, float *length);
 	void GetAACInfos(aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate, long filesize);
-	int IsMP4(LPSTR lpstrFilename);
-
+*/
 	virtual void DisplayError(char *ProcName, char *str);
 	virtual HANDLE ERROR_getInfos(char *str) { DisplayError("getInfos", str); return NULL; }
 	virtual int ERROR_processData(char *str) { DisplayError("processData", str); return 0; }
 	virtual void showInfo(MYINPUT *mi) {}
 	virtual void showProgress(MYINPUT *mi) {}
-	virtual void setFaadCfg(faacDecHandle hDecoder);
+	virtual void setDefaultFaadCfg(faacDecHandle hDecoder, BOOL showDlg);
+	virtual void setFaadCfg(faacDecHandle hDecoder, CMyDecCfg Cfg);
+	virtual int seek(int newpos_bytes) { return 0; } // !=0 => error
+	virtual void NoSeek() {} // put here the code to block seeking of player
 
 public:
     Cfaad(HANDLE hInput=NULL);
     virtual ~Cfaad();
 
-	static void ReadCfgDec(MY_DEC_CFG *cfg);
-	static void WriteCfgDec(MY_DEC_CFG *cfg);
+	int (*ShowDlg4RawAAC)(); // set this to show your dialog (to decode raw aac files)
+	int IsMP4(LPSTR lpstrFilename);
+	inline bool CanSeek() { MYINPUT	*mi; GLOBALLOCK(mi,hInput,MYINPUT,return 0); bool IsSeekable=mi->IsSeekable; GlobalUnlock(hInput); return IsSeekable; }
+//	virtual void GetAACInfos(char *Filename, aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate);
     virtual HANDLE getInfos(LPSTR lpstrFilename);
     virtual int processData(HANDLE hInput, unsigned char far *bufout, long lBytes);
 
-// AAC
-//	bool            BlockSeeking;
-
 // GLOBAL
-//	long            newpos_ms;
-//	BOOL            IsSeekable;
+	long            newpos_ms; // set this to change position
 	HANDLE			hInput;
+	CMyDecCfg		*pCfg; // set this to use your cfg (to decode raw aac files)
 };
 #endif
--- /dev/null
+++ b/plugins/cooledit/DecDialog.cpp
@@ -1,0 +1,193 @@
+#include <windows.h>
+#include "resource.h"
+#include "Defines.h"	// my defines
+#include "Cfaad.h"
+#include "DecDialog.h"
+#include "EncDialog.h"
+
+// *********************************************************************************************
+
+extern HINSTANCE hInstance;
+extern HBITMAP hBmBrowse;
+
+// -----------------------------------------------------------------------------------------------
+
+#ifndef FAAD_FMT_64BIT
+#define FAAD_FMT_64BIT 5
+#endif
+
+// *********************************************************************************************
+
+int ShowDlg4RawAAC()
+{
+	return DialogBoxParam((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_DECODER),(HWND)NULL, (DLGPROC)DialogMsgProcDec, 0);
+//	return DialogBoxParam((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_DECODER),(HWND)hWnd, (DLGPROC)DialogMsgProcDec, (DWORD)&cfg);
+}
+
+// *********************************************************************************************
+
+#define INIT_CB(hWnd,nID,list,IdSelected) \
+{ \
+	for(int i=0; list[i]; i++) \
+		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)list[i]); \
+	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
+}
+// -----------------------------------------------------------------------------------------------
+
+//	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
+#define DISABLE_CTRLS_DEC(Enabled) \
+{ \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_DOWNMATRIX), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_OLDADTS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_SAMPLERATE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), Enabled); \
+}
+// -----------------------------------------------------------------------------------------------
+
+BOOL DialogMsgProcDec(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
+{
+	switch(Message)
+	{
+	case WM_INITDIALOG:
+		{
+/*			if(!lParam)
+			{
+				MessageBox(hWndDlg,"Pointer==NULL",0,MB_OK|MB_ICONSTOP);
+				EndDialog(hWndDlg, 0);
+				return TRUE;
+			}
+*/
+		char buf[50];
+		char	*SampleRate[]={"6000","8000","16000","22050","32000","44100","48000","64000","88200","96000","192000",0},
+				*BitsPerSample[]={"16","24","32","32 bit FLOAT","64 bit FLOAT",0};
+		CMyDecCfg cfg(false);
+
+			SetWindowPos(GetDlgItem(hWndDlg,IDC_CHK_DEFAULTCFG),GetDlgItem(hWndDlg,IDC_GRP_DEFAULT),0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
+
+			INIT_CB(hWndDlg,IDC_CB_BITSPERSAMPLE,BitsPerSample,0);
+			INIT_CB(hWndDlg,IDC_CB_SAMPLERATE,SampleRate,5);
+			sprintf(buf,"%lu",cfg.DecCfg.defSampleRate);
+			SetDlgItemText(hWndDlg, IDC_CB_SAMPLERATE, buf);
+
+			switch(cfg.DecCfg.defObjectType)
+			{
+			case MAIN:
+				CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+				break;
+			case LC:
+				CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
+				break;
+			case SSR:
+				CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
+				break;
+			case LTP:
+				CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
+				break;
+			case HE_AAC:
+				CheckDlgButton(hWndDlg,IDC_RADIO_HE,TRUE);
+				break;
+			}
+
+			switch(cfg.DecCfg.outputFormat)
+			{
+			case FAAD_FMT_16BIT:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_SETCURSEL, 0, 0);
+				break;
+			case FAAD_FMT_24BIT:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_SETCURSEL, 1, 0);
+				break;
+			case FAAD_FMT_32BIT:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_SETCURSEL, 2, 0);
+				break;
+			case FAAD_FMT_FLOAT:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_SETCURSEL, 3, 0);
+				break;
+			case FAAD_FMT_64BIT:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_SETCURSEL, 4, 0);
+				break;
+			}
+
+			CheckDlgButton(hWndDlg,IDC_CHK_DOWNMATRIX, cfg.DecCfg.downMatrix);
+			CheckDlgButton(hWndDlg,IDC_CHK_OLDADTS, cfg.DecCfg.useOldADTSFormat);
+
+			CheckDlgButton(hWndDlg,IDC_CHK_DEFAULTCFG, cfg.DefaultCfg);
+			DISABLE_CTRLS_DEC(!cfg.DefaultCfg);
+		}
+		break; // End of WM_INITDIALOG                                 
+
+	case WM_CLOSE:
+		// Closing the Dialog behaves the same as Cancel               
+		PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0);
+		break; // End of WM_CLOSE                                      
+
+	case WM_COMMAND:
+		switch(LOWORD(wParam))
+		{
+		case IDC_CHK_DEFAULTCFG:
+			{
+			char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_DEFAULTCFG);
+				DISABLE_CTRLS_DEC(Enabled);
+			}
+			break;
+
+		case IDOK:
+			{
+		CMyDecCfg cfg;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
+					cfg.DecCfg.defObjectType=MAIN;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
+					cfg.DecCfg.defObjectType=LC;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
+					cfg.DecCfg.defObjectType=SSR;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
+					cfg.DecCfg.defObjectType=LTP;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_HE))
+					cfg.DecCfg.defObjectType=HE_AAC;
+				switch(SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITSPERSAMPLE), CB_GETCURSEL, 0, 0))
+				{
+				case 0:
+					cfg.DecCfg.outputFormat=FAAD_FMT_16BIT;
+					break;
+				case 1:
+					cfg.DecCfg.outputFormat=FAAD_FMT_24BIT;
+					break;
+				case 2:
+					cfg.DecCfg.outputFormat=FAAD_FMT_32BIT;
+					break;
+				case 3:
+					cfg.DecCfg.outputFormat=FAAD_FMT_FLOAT;
+					break;
+				case 4:
+					cfg.DecCfg.outputFormat=FAAD_FMT_64BIT;
+					break;
+				}
+
+				cfg.DecCfg.defSampleRate=GetDlgItemInt(hWndDlg, IDC_CB_SAMPLERATE, 0, FALSE);
+				cfg.DecCfg.downMatrix=IsDlgButtonChecked(hWndDlg,IDC_CHK_DOWNMATRIX) ? TRUE : FALSE;
+				cfg.DecCfg.useOldADTSFormat=IsDlgButtonChecked(hWndDlg,IDC_CHK_OLDADTS) ? TRUE : FALSE;
+				cfg.DefaultCfg=IsDlgButtonChecked(hWndDlg,IDC_CHK_DEFAULTCFG) ? TRUE : FALSE;
+
+				EndDialog(hWndDlg, (DWORD)TRUE);
+			}
+			break;
+
+        case IDCANCEL:
+			// Ignore data values entered into the controls        
+			// and dismiss the dialog window returning FALSE
+			EndDialog(hWndDlg, (DWORD)FALSE);
+			break;
+
+		case IDC_BTN_ABOUT:
+				DialogBox((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_ABOUT), (HWND)hWndDlg, (DLGPROC)DialogMsgProcAbout);
+			break;
+		}
+		break; // End of WM_COMMAND
+	default: 
+		return FALSE;
+	}
+ 
+	return TRUE;
+}
--- /dev/null
+++ b/plugins/cooledit/DecDialog.h
@@ -1,0 +1,39 @@
+extern BOOL DialogMsgProcDec(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam);
+extern int ShowDlg4RawAAC();
+
+static const char* mpeg4AudioNames[]=
+{
+	"Raw PCM",
+	"AAC Main",
+	"AAC LC (Low Complexity)",
+	"AAC SSR",
+	"AAC LTP (Long Term Prediction)",
+	"AAC HE (High Efficiency)",
+	"AAC Scalable",
+	"TwinVQ",
+	"CELP",
+	"HVXC",
+	"Reserved",
+	"Reserved",
+	"TTSI",
+	"Main synthetic",
+	"Wavetable synthesis",
+	"General MIDI",
+	"Algorithmic Synthesis and Audio FX",
+// defined in MPEG-4 version 2
+	"ER AAC LC (Low Complexity)",
+	"Reserved",
+	"ER AAC LTP (Long Term Prediction)",
+	"ER AAC Scalable",
+	"ER TwinVQ",
+	"ER BSAC",
+	"ER AAC LD (Low Delay)",
+	"ER CELP",
+	"ER HVXC",
+	"ER HILN",
+	"ER Parametric",
+	"Reserved",
+	"Reserved",
+	"Reserved",
+	"Reserved"
+};
--- /dev/null
+++ b/plugins/cooledit/EncDialog.cpp
@@ -1,0 +1,748 @@
+#include <windows.h>
+#include <shlobj.h>		// Browse
+#include <shellapi.h>	// ShellExecute
+#include <Commdlg.h>
+#include "resource.h"
+#include "Defines.h"	// my defines
+#include "CTag.h"
+#include "Cfaac.h"
+#include "EncDialog.h"
+
+#include <commctrl.h>
+#include <id3v2tag.h>
+//#include <id3\globals.h> // ID3LIB_RELEASE
+
+// *********************************************************************************************
+
+#ifdef IDC_BTN_BROWSE			
+extern char	config_AACoutdir[MAX_PATH];
+#endif
+
+extern HINSTANCE hInstance;
+extern HBITMAP hBmBrowse;
+
+// *********************************************************************************************
+
+/*
+DWORD PackCfg(MY_ENC_CFG *cfg)
+{
+DWORD dwOptions=0;
+
+	if(cfg->AutoCfg)
+		dwOptions=1<<31;
+	dwOptions|=(DWORD)cfg->EncCfg.mpegVersion<<30;
+	dwOptions|=(DWORD)cfg->EncCfg.aacObjectType<<28;
+	dwOptions|=(DWORD)cfg->EncCfg.allowMidside<<27;
+	dwOptions|=(DWORD)cfg->EncCfg.useTns<<26;
+	dwOptions|=(DWORD)cfg->EncCfg.useLfe<<25;
+	dwOptions|=(DWORD)cfg->EncCfg.outputFormat<<24;
+	if(cfg->UseQuality)
+		dwOptions|=(((DWORD)cfg->EncCfg.quantqual>>1)&0xff)<<16; // [2,512]
+	else
+		dwOptions|=(((DWORD)cfg->EncCfg.bitRate>>1)&0xff)<<16; // [2,512]
+	if(cfg->UseQuality)
+		dwOptions|=1<<15;
+	dwOptions|=((DWORD)cfg->EncCfg.bandWidth>>1)&&0x7fff; // [0,65536]
+
+	return dwOptions;
+}
+// -----------------------------------------------------------------------------------------------
+
+void UnpackCfg(MY_ENC_CFG *cfg, DWORD dwOptions)
+{
+	cfg->AutoCfg=dwOptions>>31;
+	cfg->EncCfg.mpegVersion=(dwOptions>>30)&1;
+	cfg->EncCfg.aacObjectType=(dwOptions>>28)&3;
+	cfg->EncCfg.allowMidside=(dwOptions>>27)&1;
+	cfg->EncCfg.useTns=(dwOptions>>26)&1;
+	cfg->EncCfg.useLfe=(dwOptions>>25)&1;
+	cfg->EncCfg.outputFormat=(dwOptions>>24)&1;
+	cfg->EncCfg.bitRate=((dwOptions>>16)&0xff)<<1;
+	cfg->UseQuality=(dwOptions>>15)&1;
+	cfg->EncCfg.bandWidth=(dwOptions&0x7fff)<<1;
+}*/
+// -----------------------------------------------------------------------------------------------
+
+#define INIT_CB(hWnd,nID,list,IdSelected) \
+{ \
+	for(int i=0; list[i]; i++) \
+		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)list[i]); \
+	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
+}
+// -----------------------------------------------------------------------------------------------
+
+#define INIT_CB_GENRES(hWnd,nID,ID3Genres,IdSelected) \
+{ \
+	for(int i=0; i<(sizeof(ID3Genres)/sizeof(ID3Genres[0])); i++) \
+		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)ID3Genres[i].name); \
+	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
+}
+// -----------------------------------------------------------------------------------------------
+
+#define DISABLE_LTP \
+{ \
+	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \
+	   IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \
+	{ \
+		CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); \
+		CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); \
+	} \
+    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \
+}
+// -----------------------------------------------------------------------------------------------
+
+//        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
+//        EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled);
+#define DISABLE_CTRLS_ENC(Enabled) \
+{ \
+	CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_RAW), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_ADTS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_ALLOWMIDSIDE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USETNS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_QUALITY), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_QUALITY), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_BITRATE), Enabled); \
+    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
+    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
+    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
+	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4)) \
+		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
+	else \
+		DISABLE_LTP \
+}
+// -----------------------------------------------------------------------------------------------
+
+#define ENABLE_TAG(Enabled) \
+{ \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTIST), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_TITLE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ALBUM), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_YEAR), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_GENRE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_WRITER), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMMENT), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_COMPILATION), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_TRACK), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTFILE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), Enabled); \
+}
+// -----------------------------------------------------------------------------------------------
+
+#define ENABLE_AACTAGS(Enabled) \
+{ \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_COMPILATION), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \
+}
+// -----------------------------------------------------------------------------------------------
+
+#ifdef IDC_BTN_BROWSE			
+static int CALLBACK BrowseCallbackProc( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
+{
+	if (uMsg == BFFM_INITIALIZED)
+	{
+		SetWindowText(hwnd,"Select Directory");
+		SendMessage(hwnd,BFFM_SETSELECTION,(WPARAM)1,(LPARAM)config_AACoutdir);
+	}
+	return 0;
+}
+#endif
+// -----------------------------------------------------------------------------------------------
+
+BOOL DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
+{
+	switch(Message)
+	{
+	case WM_INITDIALOG:
+		{
+		char buf[512];
+		char *faac_id_string, *faac_copyright_string;
+
+		sprintf(buf,
+					APP_NAME " plugin " APP_VER " by Antonio Foranna\n\n"
+					"Libraries used:\n"
+					"\tlibfaac v%s\n"
+					"\tFAAD2 v" FAAD2_VERSION "\n"
+					"\t" PACKAGE " v" VERSION "\n"
+					"\tid3v2 \n\n" //"\t %s v %s \n\n"
+					"This code is given with FAAC package and does not contain executables.\n"
+					"This program is free software and can be distributed/modifyed under the terms of the GNU General Public License.\n"
+					"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.\n\n"
+					"Compiled on %s\n",
+				(faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version",
+//					ID3LIB_FULL_NAME, ID3LIB_RELEASE,
+					__DATE__
+					);
+			SetDlgItemText(hWndDlg, IDC_L_ABOUT, buf);
+		}
+		break;
+	case WM_COMMAND:
+		switch(LOWORD(wParam))
+		{
+		case IDOK:
+			EndDialog(hWndDlg, TRUE);
+			break;
+        case IDCANCEL:
+			// Ignore data values entered into the controls and dismiss the dialog window returning FALSE
+			EndDialog(hWndDlg, FALSE);
+			break;
+		case IDC_AUDIOCODING:
+			ShellExecute(hWndDlg, NULL, "http://www.audiocoding.com", NULL, NULL, SW_SHOW);
+			break;
+		case IDC_MPEG4IP:
+			ShellExecute(hWndDlg, NULL, "http://www.mpeg4ip.net", NULL, NULL, SW_SHOW);
+			break;
+		case IDC_ID3:
+			ShellExecute(hWndDlg, NULL, "http://id3lib.sourceforge.net", NULL, NULL, SW_SHOW);
+			break;
+		case IDC_EMAIL:
+			ShellExecute(hWndDlg, NULL, "mailto:ntnfrn_email-temp@yahoo.it", NULL, NULL, SW_SHOW);
+			break;
+		}
+		break;
+	default: 
+		return FALSE;
+	}
+
+	return TRUE;
+}
+// -----------------------------------------------------------------------------------------------
+
+// ripped from id3v2tag.c
+ID3GENRES ID3Genres[]=
+{
+    123,    "Acapella",
+    34,     "Acid",
+    74,     "Acid Jazz",
+    73,     "Acid Punk",
+    99,     "Acoustic",
+    20,     "Alternative",
+    40,     "AlternRock",
+    26,     "Ambient",
+    90,     "Avantgarde",
+    116,    "Ballad",
+    41,     "Bass",
+    85,     "Bebob",
+    96,     "Big Band",
+    89,     "Bluegrass",
+    0,      "Blues",
+    107,    "Booty Bass",
+    65,     "Cabaret",
+    88,     "Celtic",
+    104,    "Chamber Music",
+    102,    "Chanson",
+    97,     "Chorus",
+    61,     "Christian Rap",
+    1,      "Classic Rock",
+    32,     "Classical",
+    112,    "Club",
+    57,     "Comedy",
+    2,      "Country",
+    58,     "Cult",
+    3,      "Dance",
+    125,    "Dance Hall",
+    50,     "Darkwave",
+    254,    "Data",
+    22,     "Death Metal",
+    4,      "Disco",
+    55,     "Dream",
+    122,    "Drum Solo",
+    120,    "Duet",
+    98,     "Easy Listening",
+    52,     "Electronic",
+    48,     "Ethnic",
+    124,    "Euro-House",
+    25,     "Euro-Techno",
+    54,     "Eurodance",
+    84,     "Fast Fusion",
+    80,     "Folk",
+    81,     "Folk-Rock",
+    115,    "Folklore",
+    119,    "Freestyle",
+    5,      "Funk",
+    30,     "Fusion",
+    36,     "Game",
+    59,     "Gangsta",
+    38,     "Gospel",
+    49,     "Gothic",
+    91,     "Gothic Rock",
+    6,      "Grunge",
+    79,     "Hard Rock",
+    7,      "Hip-Hop",
+    35,     "House",
+    100,    "Humour",
+    19,     "Industrial",
+    33,     "Instrumental",
+    46,     "Instrumental Pop",
+    47,     "Instrumental Rock",
+    8,      "Jazz",
+    29,     "Jazz+Funk",
+    63,     "Jungle",
+    86,     "Latin",
+    71,     "Lo-Fi",
+    45,     "Meditative",
+    9,      "Metal",
+    77,     "Musical",
+    82,     "National Folk",
+    64,     "Native American",
+    10,     "New Age",
+    66,     "New Wave",
+    39,     "Noise",
+    255,    "Not Set",
+    11,     "Oldies",
+    103,    "Opera",
+    12,     "Other",
+    75,     "Polka",
+    13,     "Pop",
+    62,     "Pop/Funk",
+    53,     "Pop-Folk",
+    109,    "Porn Groove",
+    117,    "Power Ballad",
+    23,     "Pranks",
+    108,    "Primus",
+    92,     "Progressive Rock",
+    67,     "Psychadelic",
+    93,     "Psychedelic Rock",
+    43,     "Punk",
+    121,    "Punk Rock",
+    14,     "R&B",
+    15,     "Rap",
+    68,     "Rave",
+    16,     "Reggae",
+    76,     "Retro",
+    87,     "Revival",
+    118,    "Rhythmic Soul",
+    17,     "Rock",
+    78,     "Rock & Roll",
+    114,    "Samba",
+    110,    "Satire",
+    69,     "Showtunes",
+    21,     "Ska",
+    111,    "Slow Jam",
+    95,     "Slow Rock",
+    105,    "Sonata",
+    42,     "Soul",
+    37,     "Sound Clip",
+    24,     "Soundtrack",
+    56,     "Southern Rock",
+    44,     "Space",
+    101,    "Speech",
+    83,     "Swing",
+    94,     "Symphonic Rock",
+    106,    "Symphony",
+    113,    "Tango",
+    18,     "Techno",
+    51,     "Techno-Industrial",
+    60,     "Top 40",
+    70,     "Trailer",
+    31,     "Trance",
+    72,     "Tribal",
+    27,     "Trip-Hop",
+    28,     "Vocal"
+};
+
+BOOL CALLBACK DIALOGMsgProcEnc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
+{
+	switch(Message)
+	{
+	case WM_INITDIALOG:
+		{
+		char buf[50];
+		char *Quality[]={"Default","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","200","300","400","500",0};
+		char *BitRate[]={"Auto","8","18","20","24","32","40","48","56","64","96","112","128","160","192","224","256","320","384",0};
+		char *BandWidth[]={"Auto","Full","4000","8000","11025","16000","22050","24000","32000","44100","48000",0};
+		CMyEncCfg cfg(false);
+			
+			SetWindowPos(GetDlgItem(hWndDlg,IDC_CHK_TAG),GetDlgItem(hWndDlg,IDC_GRP_TAG),0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
+
+			INIT_CB(hWndDlg,IDC_CB_QUALITY,Quality,0);
+			INIT_CB(hWndDlg,IDC_CB_BITRATE,BitRate,0);
+			INIT_CB(hWndDlg,IDC_CB_BANDWIDTH,BandWidth,0);
+
+			INIT_CB_GENRES(hWndDlg,IDC_CB_GENRE,ID3Genres,0);
+
+			SendMessage(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
+#ifdef IDC_BTN_BROWSE			
+			SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
+			if(!cfg.OutDir || !*cfg.OutDir)
+			{
+				GetCurrentDirectory(MAX_PATH,config_AACoutdir);
+				FREE_ARRAY(cfg.OutDir);
+				cfg.OutDir=strdup(config_AACoutdir);
+			}
+			else
+				strcpy(config_AACoutdir,cfg.OutDir);
+			SetDlgItemText(hWndDlg, IDC_E_BROWSE, cfg.OutDir);			
+#endif
+			if(cfg.EncCfg.mpegVersion==MPEG4)
+				CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
+			else
+				CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
+			
+			switch(cfg.EncCfg.aacObjectType)
+			{
+			case MAIN:
+				CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+				break;
+			case LOW:
+				CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
+				break;
+			case SSR:
+				CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
+				break;
+			case LTP:
+				CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
+				DISABLE_LTP
+				break;
+			}
+			
+			switch(cfg.EncCfg.outputFormat)
+			{
+			case RAW:
+				CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);
+				break;
+			case ADTS:
+				CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
+				break;
+			}
+			
+			CheckDlgButton(hWndDlg, IDC_CHK_ALLOWMIDSIDE, cfg.EncCfg.allowMidside);
+			CheckDlgButton(hWndDlg, IDC_CHK_USETNS, cfg.EncCfg.useTns);
+			CheckDlgButton(hWndDlg, IDC_CHK_USELFE, cfg.EncCfg.useLfe);
+
+			if(cfg.UseQuality)
+				CheckDlgButton(hWndDlg,IDC_RADIO_QUALITY,TRUE);
+			else
+				CheckDlgButton(hWndDlg,IDC_RADIO_BITRATE,TRUE);
+
+			switch(cfg.EncCfg.quantqual)
+			{
+			case 100:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_QUALITY), CB_SETCURSEL, 0, 0);
+				break;
+			default:
+				if(cfg.EncCfg.quantqual<10)
+					cfg.EncCfg.quantqual=10;
+				if(cfg.EncCfg.quantqual>500)
+					cfg.EncCfg.quantqual=500;
+				sprintf(buf,"%lu",cfg.EncCfg.quantqual);
+				SetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf);
+				break;
+			}
+			switch(cfg.EncCfg.bitRate)
+			{
+			case 0:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 0, 0);
+				break;
+			default:
+				sprintf(buf,"%lu",cfg.EncCfg.bitRate);
+				SetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf);
+				break;
+			}
+			switch(cfg.EncCfg.bandWidth)
+			{
+			case 0:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0);
+				break;
+			case 0xffffffff:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 1, 0);
+				break;
+			default:
+				sprintf(buf,"%lu",cfg.EncCfg.bandWidth);
+				SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf);
+				break;
+			}
+			
+			CheckDlgButton(hWndDlg, IDC_CHK_WRITEMP4, cfg.SaveMP4);
+
+			CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, cfg.AutoCfg);
+			DISABLE_CTRLS_ENC(!cfg.AutoCfg);
+
+			CheckDlgButton(hWndDlg,IDC_CHK_TAG, cfg.TagOn);
+			ENABLE_TAG(cfg.TagOn);
+			ENABLE_AACTAGS(cfg.SaveMP4);
+			SetDlgItemText(hWndDlg, IDC_E_ARTIST, cfg.Tag.artist);
+			SetDlgItemText(hWndDlg, IDC_E_TITLE, cfg.Tag.title);
+			SetDlgItemText(hWndDlg, IDC_E_ALBUM, cfg.Tag.album);
+			SetDlgItemText(hWndDlg, IDC_E_YEAR, cfg.Tag.year);
+			SetDlgItemText(hWndDlg, IDC_CB_GENRE, cfg.Tag.genre);
+			SetDlgItemText(hWndDlg, IDC_E_WRITER, cfg.Tag.writer);
+			SetDlgItemText(hWndDlg, IDC_E_COMMENT, cfg.Tag.comment);
+			SetDlgItemText(hWndDlg, IDC_E_ARTFILE, cfg.Tag.artFilename);
+			SetDlgItemInt(hWndDlg, IDC_E_TRACK, cfg.Tag.trackno, FALSE);
+			SetDlgItemInt(hWndDlg, IDC_E_NTRACKS, cfg.Tag.ntracks, FALSE);
+			SetDlgItemInt(hWndDlg, IDC_E_DISK, cfg.Tag.discno, FALSE);
+			SetDlgItemInt(hWndDlg, IDC_E_NDISKS, cfg.Tag.ndiscs, FALSE);
+			SetDlgItemInt(hWndDlg, IDC_E_COMPILATION, cfg.Tag.compilation, FALSE);
+			CheckDlgButton(hWndDlg, IDC_CHK_COMPILATION, cfg.Tag.compilation);
+		}
+		break; // End of WM_INITDIALOG                                 
+		
+	case WM_CLOSE:
+		// Closing the Dialog behaves the same as Cancel               
+		PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
+		break; // End of WM_CLOSE                                      
+		
+	case WM_COMMAND:
+		switch(LOWORD(wParam))
+		{
+		case IDOK:
+			{
+//			HANDLE hCfg=(HANDLE)lParam;
+			char buf[50];
+			CMyEncCfg cfg;
+
+				cfg.AutoCfg=IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG) ? TRUE : FALSE;
+				cfg.EncCfg.mpegVersion=IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4) ? MPEG4 : MPEG2;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
+					cfg.EncCfg.aacObjectType=MAIN;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
+					cfg.EncCfg.aacObjectType=LOW;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
+					cfg.EncCfg.aacObjectType=SSR;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
+					cfg.EncCfg.aacObjectType=LTP;
+				cfg.EncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_CHK_ALLOWMIDSIDE);
+				cfg.EncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_CHK_USETNS);
+				cfg.EncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_CHK_USELFE);
+				
+				GetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf, 50);
+				switch(*buf)
+				{
+				case 'A': // Auto
+					cfg.EncCfg.bitRate=0;
+					break;
+				default:
+					cfg.EncCfg.bitRate=GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
+				}
+				GetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf, 50);
+				switch(*buf)
+				{
+				case 'A': // Auto
+					cfg.EncCfg.bandWidth=0;
+					break;
+				case 'F': // Full
+					cfg.EncCfg.bandWidth=0xffffffff;
+					break;
+				default:
+					cfg.EncCfg.bandWidth=GetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, 0, FALSE);
+				}
+				cfg.UseQuality=IsDlgButtonChecked(hWndDlg,IDC_RADIO_QUALITY) ? TRUE : FALSE;
+				GetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf, 50);
+				switch(*buf)
+				{
+				case 'D': // Default
+					cfg.EncCfg.quantqual=100;
+					break;
+				default:
+					cfg.EncCfg.quantqual=GetDlgItemInt(hWndDlg, IDC_CB_QUALITY, 0, FALSE);
+				}
+				cfg.EncCfg.outputFormat=IsDlgButtonChecked(hWndDlg,IDC_RADIO_RAW) ? RAW : ADTS;
+#ifdef IDC_E_BROWSE
+				GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir, MAX_PATH);
+				FREE_ARRAY(cfg.OutDir);
+				cfg.OutDir=strdup(config_AACoutdir);
+#endif
+				cfg.SaveMP4=IsDlgButtonChecked(hWndDlg, IDC_CHK_WRITEMP4) ? TRUE : FALSE;
+
+				cfg.TagOn=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG) ? 1 : 0;
+			char buffer[MAX_PATH];
+				GetDlgItemText(hWndDlg, IDC_E_ARTIST, buffer, MAX_PATH);
+				cfg.Tag.artist=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_TITLE, buffer, MAX_PATH);
+				cfg.Tag.title=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_ALBUM, buffer, MAX_PATH);
+				cfg.Tag.album=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_YEAR, buffer, MAX_PATH);
+				cfg.Tag.year=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_CB_GENRE, buffer, MAX_PATH);
+				cfg.Tag.genre=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_WRITER, buffer, MAX_PATH);
+				cfg.Tag.writer=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_COMMENT, buffer, MAX_PATH);
+				cfg.Tag.comment=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_ARTFILE, buffer, MAX_PATH);
+				cfg.Tag.artFilename=strdup(buffer);
+				cfg.Tag.trackno=GetDlgItemInt(hWndDlg, IDC_E_TRACK, 0, FALSE);
+				cfg.Tag.ntracks=GetDlgItemInt(hWndDlg, IDC_E_NTRACKS, 0, FALSE);
+				cfg.Tag.discno=GetDlgItemInt(hWndDlg, IDC_E_DISK, 0, FALSE);
+				cfg.Tag.ndiscs=GetDlgItemInt(hWndDlg, IDC_E_NDISKS, 0, FALSE);
+				cfg.Tag.compilation=(BYTE)GetDlgItemInt(hWndDlg, IDC_E_COMPILATION, 0, FALSE);
+				cfg.Tag.compilation=IsDlgButtonChecked(hWndDlg, IDC_CHK_COMPILATION) ? 1 : 0;
+
+				EndDialog(hWndDlg, TRUE);//(DWORD)hCfg);
+			}
+			break;
+			
+        case IDCANCEL:
+			// Ignore data values entered into the controls        
+			// and dismiss the dialog window returning FALSE
+			EndDialog(hWndDlg, FALSE);
+			break;
+
+		case IDC_BTN_ABOUT:
+			DialogBox((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_ABOUT), (HWND)hWndDlg, (DLGPROC)DialogMsgProcAbout);
+			break;
+
+		case IDC_BTN_LICENSE:
+			{
+			char *license =
+				"\nPlease note that the use of this software may require the payment of patent royalties.\n"
+				"You need to consider this issue before you start building derivative works.\n"
+				"We are not warranting or indemnifying you in any way for patent royalities!\n"
+				"YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN ACTIONS!\n"
+				"\n"
+				"FAAC is based on the ISO MPEG-4 reference code. For this code base the\n"
+				"following license applies:\n"
+				"\n"
+/*				"This software module was originally developed by\n"
+				"\n"
+				"FirstName LastName (CompanyName)\n"
+				"\n"
+				"and edited by\n"
+				"\n"
+				"FirstName LastName (CompanyName)\n"
+				"FirstName LastName (CompanyName)\n"
+				"\n"
+*/				"in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard\n"
+				"ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an\n"
+				"implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools\n"
+				"as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives\n"
+				"users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this\n"
+				"software module or modifications thereof for use in hardware or\n"
+				"software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio\n"
+				"standards. Those intending to use this software module in hardware or\n"
+				"software products are advised that this use may infringe existing\n"
+				"patents. The original developer of this software module and his/her\n"
+				"company, the subsequent editors and their companies, and ISO/IEC have\n"
+				"no liability for use of this software module or modifications thereof\n"
+				"in an implementation. Copyright is not released for non MPEG-2\n"
+				"NBC/MPEG-4 Audio conforming products. The original developer retains\n"
+				"full right to use the code for his/her own purpose, assign or donate\n"
+				"the code to a third party and to inhibit third party from using the\n"
+				"code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This\n"
+				"copyright notice must be included in all copies or derivative works.\n"
+				"\n"
+				"Copyright (c) 1997.\n"
+				"\n"
+				"For the changes made for the FAAC project the GNU Lesser General Public\n"
+				"License (LGPL), version 2 1991 applies:\n"
+				"\n"
+				"FAAC - Freeware Advanced Audio Coder\n"
+				"Copyright (C) 2001-2004 The individual contributors\n"
+				"\n"
+				"This library is free software; you can redistribute it and/or modify it under the terms of\n"
+				"the GNU Lesser General Public License as published by the Free Software Foundation;\n"
+				"either version 2.1 of the License, or (at your option) any later version.\n"
+				"\n"
+				"This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n"
+				"without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
+				"See the GNU Lesser General Public License for more details.\n"
+				"\n"
+				"You should have received a copy of the GNU Lesser General Public\n"
+				"License along with this library; if not, write to the Free Software\n"
+				"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n";
+
+				MessageBox(hWndDlg,license,"FAAC libray License",MB_OK|MB_ICONINFORMATION);
+			}
+			break;
+
+#ifdef IDC_BTN_BROWSE
+		case IDC_BTN_BROWSE:
+			{
+			char name[MAX_PATH];
+			BROWSEINFO bi;
+			ITEMIDLIST *idlist;
+				bi.hwndOwner = hWndDlg;
+				bi.pidlRoot = 0;
+				bi.pszDisplayName = name;
+				bi.lpszTitle = "Select a directory for AAC-MPEG4 file output:";
+				bi.ulFlags = BIF_RETURNONLYFSDIRS;
+				bi.lpfn = BrowseCallbackProc;
+				bi.lParam = 0;
+				
+				GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir, MAX_PATH);
+				idlist = SHBrowseForFolder( &bi );
+				if(idlist)
+				{
+					SHGetPathFromIDList( idlist, config_AACoutdir);
+					SetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir);
+				}
+			}
+			break;
+#endif			
+		case IDC_BTN_ARTFILE:
+			{
+			OPENFILENAME ofn;
+			char ArtFilename[MAX_PATH]="";
+
+//				GetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename, MAX_PATH);
+
+				ofn.lStructSize			= sizeof(OPENFILENAME);
+				ofn.hwndOwner			= (HWND)hWndDlg;
+				ofn.lpstrFilter			= "Cover art files (*.gif,*jpg,*.png)\0*.gif;*.jpg;*.png\0";
+				ofn.lpstrCustomFilter	= NULL;
+				ofn.nFilterIndex		= 1;
+				ofn.lpstrFile			= ArtFilename;
+				ofn.nMaxFile			= MAX_PATH; //sizeof ArtFilename;
+				ofn.lpstrFileTitle		= NULL;
+				ofn.nMaxFileTitle		= 0;
+				ofn.lpstrInitialDir		= NULL;
+				ofn.lpstrTitle			= "Select cover art file";
+				ofn.Flags				= OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING;
+				ofn.lpstrDefExt			= NULL;//"jpg";
+				ofn.hInstance			= hInstance;
+
+				if(GetOpenFileName(&ofn))
+					SetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename);
+			}
+			break;
+
+		case IDC_RADIO_MPEG4:
+			EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
+			break;
+			
+		case IDC_RADIO_MPEG2:
+			EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
+			DISABLE_LTP
+			break;
+
+		case IDC_CHK_AUTOCFG:
+			{
+			char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG);
+				DISABLE_CTRLS_ENC(Enabled);
+			}
+			break;
+
+		case IDC_CHK_TAG:
+			{
+			char Enabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG);
+				ENABLE_TAG(Enabled);
+			}
+//			break;
+		case IDC_CHK_WRITEMP4:
+			{
+			char Enabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_WRITEMP4) && IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG);
+				ENABLE_AACTAGS(Enabled);
+			}
+			break;
+		}
+		break; // End of WM_COMMAND
+	default: 
+		return FALSE;
+	}
+	
+	return TRUE;
+} // End of DIALOGSMsgProc                                      
--- /dev/null
+++ b/plugins/cooledit/EncDialog.h
@@ -1,0 +1,2 @@
+extern BOOL DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam);
+extern BOOL CALLBACK DIALOGMsgProcEnc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam);
--- a/plugins/cooledit/FAAC.rc
+++ b/plugins/cooledit/FAAC.rc
@@ -59,7 +59,7 @@
     CONTROL         "Bitrate per channel",IDC_RADIO_BITRATE,"Button",
                     BS_AUTORADIOBUTTON,9,105,75,10
     COMBOBOX        IDC_CB_QUALITY,102,86,48,97,CBS_DROPDOWN | WS_VSCROLL | 
-                    WS_TABSTOP
+                    WS_GROUP | WS_TABSTOP
     COMBOBOX        IDC_CB_BITRATE,102,102,48,86,CBS_DROPDOWN | WS_VSCROLL | 
                     WS_TABSTOP
     LTEXT           "Bandwidth",IDC_STATIC,21,126,34,8
@@ -68,80 +68,86 @@
     CONTROL         "Allow Mid/Side",IDC_CHK_ALLOWMIDSIDE,"Button",
                     BS_AUTOCHECKBOX | WS_TABSTOP,9,143,63,10
     CONTROL         "Use TNS",IDC_CHK_USETNS,"Button",BS_AUTOCHECKBOX | 
-                    WS_TABSTOP,9,155,45,10
+                    WS_TABSTOP,9,156,45,10
     CONTROL         "Use LFE channel",IDC_CHK_USELFE,"Button",
                     BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | 
-                    WS_TABSTOP,79,143,67,10
+                    WS_TABSTOP,71,59,67,10
     CONTROL         "Write .mp4",IDC_CHK_WRITEMP4,"Button",BS_AUTOCHECKBOX | 
-                    WS_TABSTOP,9,168,50,10
+                    WS_TABSTOP,9,169,50,10
+    GROUPBOX        "",IDC_GRP_TAG,160,4,174,200
+    CONTROL         "Tag",IDC_CHK_TAG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
+                    165,3,29,10
+    EDITTEXT        IDC_E_ARTIST,207,20,121,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_E_TITLE,207,35,121,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_E_ALBUM,207,50,121,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_E_YEAR,207,65,121,14,ES_AUTOHSCROLL
+    COMBOBOX        IDC_CB_GENRE,207,80,121,161,CBS_DROPDOWN | WS_VSCROLL | 
+                    WS_TABSTOP
+    EDITTEXT        IDC_E_WRITER,207,94,121,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_E_COMMENT,207,109,121,29,ES_MULTILINE | 
+                    ES_AUTOHSCROLL
+    EDITTEXT        IDC_E_COMPILATION,207,139,121,14,ES_AUTOHSCROLL | NOT 
+                    WS_VISIBLE
+    CONTROL         "Part of a compilation",IDC_CHK_COMPILATION,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,165,141,80,10
+    EDITTEXT        IDC_E_TRACK,233,155,40,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_E_NTRACKS,288,155,40,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_E_DISK,233,170,40,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_E_NDISKS,288,170,40,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_E_ARTFILE,207,185,98,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "&...",IDC_BTN_ARTFILE,311,185,17,14,BS_BITMAP | BS_FLAT
     GROUPBOX        "AAC type",IDC_STATIC,56,16,48,38
     GROUPBOX        "Profile",IDC_STATIC,4,16,48,59
     GROUPBOX        "Header",IDC_STATIC,108,16,48,38
     GROUPBOX        "Encoding mode",IDC_STATIC,4,78,152,42
-    GROUPBOX        "",IDC_GRP_TAG,160,4,174,200
-    CONTROL         "Tag",IDC_CHK_TAG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
-                    165,4,29,10
-    EDITTEXT        IDC_E_ARTIST,207,22,121,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_TITLE,207,36,121,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_ALBUM,207,51,121,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_YEAR,207,66,121,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_WRITER,207,95,121,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_COMMENT,207,110,121,29,ES_MULTILINE | 
-                    ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_COMPILATION,207,140,121,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_TRACK,233,156,40,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_NTRACKS,288,156,40,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_DISK,233,171,40,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_NDISKS,288,171,40,14,ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_ARTFILE,207,186,98,14,ES_AUTOHSCROLL
-    PUSHBUTTON      "&...",IDC_BTN_ARTFILE,311,186,17,14,BS_BITMAP | BS_FLAT
-    LTEXT           "Artist",IDC_STATIC,165,23,16,8
-    LTEXT           "Title",IDC_STATIC,165,38,14,8
-    LTEXT           "Album",IDC_STATIC,165,54,20,8
-    LTEXT           "Year",IDC_STATIC,165,68,16,8
-    LTEXT           "Genre",IDC_STATIC,165,83,20,8
-    LTEXT           "Writer",IDC_STATIC,165,98,20,8
-    LTEXT           "Comment\n(ctrl-Enter\nto go down)",IDC_STATIC,165,114,
+    LTEXT           "Artist",IDC_STATIC,165,22,16,8
+    LTEXT           "Title",IDC_STATIC,165,37,14,8
+    LTEXT           "Album",IDC_STATIC,165,52,20,8
+    LTEXT           "Year",IDC_STATIC,165,67,16,8
+    LTEXT           "Genre",IDC_STATIC,165,82,20,8
+    LTEXT           "Writer",IDC_STATIC,165,96,20,8
+    LTEXT           "Comment\n(ctrl-Enter\nto go down)",IDC_STATIC,165,111,
                     37,26
-    LTEXT           "Track",IDC_STATIC,165,160,20,8
-    LTEXT           "/",IDC_STATIC,277,160,8,8
-    LTEXT           "Disk",IDC_STATIC,165,174,15,8
-    LTEXT           "/",IDC_STATIC,277,174,8,8
-    LTEXT           "Compilation",IDC_STATIC,165,144,37,8
+    LTEXT           "Track",IDC_STATIC,165,159,20,8
+    LTEXT           "/",IDC_STATIC,277,159,8,8
+    LTEXT           "Disk",IDC_STATIC,165,173,15,8
+    LTEXT           "/",IDC_STATIC,277,173,8,8
     LTEXT           "Cover art file",IDC_STATIC,165,188,40,8
-    COMBOBOX        IDC_CB_GENRE,207,81,121,161,CBS_DROPDOWN | WS_VSCROLL | 
-                    WS_TABSTOP
 END
 
-IDD_DECODER DIALOG  0, 0, 141, 105
+IDD_DECODER DIALOGEX 0, 0, 162, 153
 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | 
     WS_SYSMENU
 CAPTION "Raw .AAC options"
-FONT 8, "MS Sans Serif"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
-    DEFPUSHBUTTON   "&OK",IDOK,24,84,36,14
-    PUSHBUTTON      "&Cancel",IDCANCEL,61,84,36,14
-    PUSHBUTTON      "&About",IDC_BTN_ABOUT,97,84,36,14
+    DEFPUSHBUTTON   "&OK",IDOK,47,132,36,14
+    PUSHBUTTON      "&Cancel",IDCANCEL,83,132,36,14
+    PUSHBUTTON      "&About",IDC_BTN_ABOUT,119,132,36,14
     CONTROL         "Main",IDC_RADIO_MAIN,"Button",BS_AUTORADIOBUTTON | 
-                    WS_GROUP,93,17,31,10
-    CONTROL         "Low",IDC_RADIO_LOW,"Button",BS_AUTORADIOBUTTON,93,28,29,
+                    WS_GROUP,19,33,31,10
+    CONTROL         "Low",IDC_RADIO_LOW,"Button",BS_AUTORADIOBUTTON,19,44,29,
                     10
     CONTROL         "SSR",IDC_RADIO_SSR,"Button",BS_AUTORADIOBUTTON | 
-                    WS_DISABLED,93,40,31,10
-    CONTROL         "LTP",IDC_RADIO_LTP,"Button",BS_AUTORADIOBUTTON,93,52,29,
+                    WS_DISABLED,19,56,31,10
+    CONTROL         "LTP",IDC_RADIO_LTP,"Button",BS_AUTORADIOBUTTON,19,68,29,
                     10
-    GROUPBOX        "Profile",IDC_STATIC,85,7,48,70
-    COMBOBOX        IDC_CB_SAMPLERATE,13,57,62,87,CBS_DROPDOWN | WS_VSCROLL | 
-                    WS_TABSTOP
+    GROUPBOX        "Profile",IDC_STATIC,13,23,48,70
+    COMBOBOX        IDC_CB_SAMPLERATE,72,74,69,87,CBS_DROPDOWN | WS_DISABLED | 
+                    WS_VSCROLL | WS_TABSTOP
     CONTROL         "Default settings",IDC_CHK_DEFAULTCFG,"Button",
-                    BS_AUTOCHECKBOX | WS_TABSTOP,7,11,64,10
-    GROUPBOX        "Sample rate",IDC_STATIC,7,46,73,31
-    CONTROL         "HE",IDC_RADIO_HE,"Button",BS_AUTORADIOBUTTON,93,64,26,
-                    10
-    CONTROL         "Downmatrix",IDC_CHK_DOWNMATRIX,"Button",BS_AUTOCHECKBOX | 
-                    WS_TABSTOP,7,24,53,10
-    CONTROL         "Old ADTS",IDC_CHK_OLDADTS,"Button",BS_AUTOCHECKBOX | 
-                    WS_TABSTOP,7,36,48,10
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,7,64,10
+    GROUPBOX        "Sample rate",IDC_STATIC,66,61,81,32
+    CONTROL         "HE",IDC_RADIO_HE,"Button",BS_AUTORADIOBUTTON | 
+                    WS_DISABLED,19,80,26,10
+    CONTROL         "Down matrix 5.1 to 2 channels",IDC_CHK_DOWNMATRIX,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,98,111,10
+    CONTROL         "Assume old ADTS format",IDC_CHK_OLDADTS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,110,95,10
+    COMBOBOX        IDC_CB_BITSPERSAMPLE,72,35,69,87,CBS_DROPDOWNLIST | 
+                    WS_DISABLED | WS_VSCROLL | WS_TABSTOP
+    GROUPBOX        "Output bits per sample",IDC_STATIC,66,23,81,32
+    GROUPBOX        "",IDC_GRP_DEFAULT,7,8,147,118
 END
 
 
@@ -190,9 +196,9 @@
     IDD_DECODER, DIALOG
     BEGIN
         LEFTMARGIN, 7
-        RIGHTMARGIN, 133
+        RIGHTMARGIN, 154
         TOPMARGIN, 7
-        BOTTOMMARGIN, 98
+        BOTTOMMARGIN, 146
     END
 END
 #endif    // APSTUDIO_INVOKED
@@ -215,19 +221,20 @@
 // Dialog
 //
 
-IDD_ABOUT DIALOG  0, 0, 191, 230
+IDD_ABOUT DIALOGEX 0, 0, 191, 230
 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION
 CAPTION "About"
-FONT 8, "MS Sans Serif"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
-    DEFPUSHBUTTON   "&OK",IDOK,134,208,50,14
+    DEFPUSHBUTTON   "&OK",IDOK,145,208,39,14
     CONTROL         104,IDC_AUDIOCODING,"Static",SS_BITMAP | SS_NOTIFY | 
                     SS_SUNKEN,7,7,178,69
     CONTROL         107,IDC_MPEG4IP,"Static",SS_BITMAP | SS_NOTIFY | 
-                    SS_SUNKEN,7,203,59,19
-    CONTROL         106,IDC_EMAIL,"Static",SS_BITMAP | SS_NOTIFY,77,204,43,
+                    SS_SUNKEN,7,202,59,20
+    CONTROL         106,IDC_EMAIL,"Static",SS_BITMAP | SS_NOTIFY,96,204,43,
                     18
     LTEXT           "Text",IDC_L_ABOUT,7,55,177,142
+    ICON            IDI_ID3,IDC_ID3,70,202,20,20,SS_NOTIFY | SS_SUNKEN
 END
 
 
@@ -259,6 +266,53 @@
 IDB_EMAIL               BITMAP                  "Email.bmp"
 IDB_MPEG4IP             BITMAP                  "mpeg4ip-v.bmp"
 IDB_BROWSE              BITMAP                  "Open.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ID3                 ICON                    "id3v2.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 2,4,0,0
+ PRODUCTVERSION 2,4,0,0
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "041004b0"
+        BEGIN
+            VALUE "FileDescription", "Cool FAAC"
+            VALUE "FileVersion", "2, 4, 0, 0"
+            VALUE "InternalName", "FAAC"
+            VALUE "LegalCopyright", "Copyright (C) 2004"
+            VALUE "OriginalFilename", "FAAC.dll"
+            VALUE "ProductName", " FAAC Dynamic Link Library"
+            VALUE "ProductVersion", "2, 4, 0, 0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x410, 1200
+    END
+END
+
 #endif    // Italian (Italy) resources
 /////////////////////////////////////////////////////////////////////////////
 
--- a/plugins/cooledit/FAAC.sln
+++ b/plugins/cooledit/FAAC.sln
@@ -11,6 +11,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\faad2\common\id3lib\zlib\prj\zlib.vcproj", "{873DE650-0D25-4EDA-846D-D36408A73E33}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aacInfoLib", "aacInfoLib.vcproj", "{7EFB2D8D-844F-416A-8D08-DA685C160058}"
+EndProject
 Global
 	GlobalSection(SolutionConfiguration) = preSolution
 		ConfigName.0 = Debug
@@ -19,11 +21,12 @@
 		ConfigName.3 = Release
 	EndGlobalSection
 	GlobalSection(ProjectDependencies) = postSolution
-		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.0 = {56FB973D-6363-4C20-A9EA-95759F34A8AB}
-		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.1 = {873DE650-0D25-4EDA-846D-D36408A73E33}
-		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.2 = {D155A7E9-20BE-4480-B704-A7C74AE3DBB6}
-		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.3 = {016F36CD-410C-4B47-A527-AF82B848E1EB}
-		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.4 = {2CF8D144-76E5-4F92-98C4-A572DF1CBD04}
+		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.0 = {2CF8D144-76E5-4F92-98C4-A572DF1CBD04}
+		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.1 = {7EFB2D8D-844F-416A-8D08-DA685C160058}
+		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.2 = {56FB973D-6363-4C20-A9EA-95759F34A8AB}
+		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.3 = {873DE650-0D25-4EDA-846D-D36408A73E33}
+		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.4 = {D155A7E9-20BE-4480-B704-A7C74AE3DBB6}
+		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.5 = {016F36CD-410C-4B47-A527-AF82B848E1EB}
 	EndGlobalSection
 	GlobalSection(ProjectConfiguration) = postSolution
 		{98D43204-EB3F-40C1-9B0D-2C33738C0788}.Debug.ActiveCfg = Debug|Win32
@@ -74,6 +77,14 @@
 		{873DE650-0D25-4EDA-846D-D36408A73E33}.NASM Release.Build.0 = NASM Release|Win32
 		{873DE650-0D25-4EDA-846D-D36408A73E33}.Release.ActiveCfg = Release|Win32
 		{873DE650-0D25-4EDA-846D-D36408A73E33}.Release.Build.0 = Release|Win32
+		{7EFB2D8D-844F-416A-8D08-DA685C160058}.Debug.ActiveCfg = Debug|Win32
+		{7EFB2D8D-844F-416A-8D08-DA685C160058}.Debug.Build.0 = Debug|Win32
+		{7EFB2D8D-844F-416A-8D08-DA685C160058}.NASM Debug.ActiveCfg = Debug|Win32
+		{7EFB2D8D-844F-416A-8D08-DA685C160058}.NASM Debug.Build.0 = Debug|Win32
+		{7EFB2D8D-844F-416A-8D08-DA685C160058}.NASM Release.ActiveCfg = Release|Win32
+		{7EFB2D8D-844F-416A-8D08-DA685C160058}.NASM Release.Build.0 = Release|Win32
+		{7EFB2D8D-844F-416A-8D08-DA685C160058}.Release.ActiveCfg = Release|Win32
+		{7EFB2D8D-844F-416A-8D08-DA685C160058}.Release.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 	EndGlobalSection
--- a/plugins/cooledit/FAAC.vcproj
+++ b/plugins/cooledit/FAAC.vcproj
@@ -138,6 +138,9 @@
 				RelativePath=".\CRegistry.cpp">
 			</File>
 			<File
+				RelativePath="CTag.cpp">
+			</File>
+			<File
 				RelativePath=".\Cfaac.cpp">
 			</File>
 			<File
@@ -144,6 +147,12 @@
 				RelativePath=".\Cfaad.cpp">
 			</File>
 			<File
+				RelativePath="DecDialog.cpp">
+			</File>
+			<File
+				RelativePath="EncDialog.cpp">
+			</File>
+			<File
 				RelativePath=".\FAAC.def">
 			</File>
 			<File
@@ -166,6 +175,9 @@
 				RelativePath=".\CRegistry.h">
 			</File>
 			<File
+				RelativePath="CTag.h">
+			</File>
+			<File
 				RelativePath=".\Cfaac.h">
 			</File>
 			<File
@@ -172,9 +184,15 @@
 				RelativePath=".\Cfaad.h">
 			</File>
 			<File
+				RelativePath="DecDialog.h">
+			</File>
+			<File
 				RelativePath=".\Defines.h">
 			</File>
 			<File
+				RelativePath="EncDialog.h">
+			</File>
+			<File
 				RelativePath=".\Filters.h">
 			</File>
 			<File
@@ -201,6 +219,9 @@
 			</File>
 			<File
 				RelativePath="Open.bmp">
+			</File>
+			<File
+				RelativePath="id3v2.ico">
 			</File>
 			<File
 				RelativePath=".\mpeg4ip-v.bmp">
--- a/plugins/cooledit/Faac.cpp
+++ b/plugins/cooledit/Faac.cpp
@@ -20,699 +20,18 @@
 */
 
 #include <windows.h>
-#include <shellapi.h>	// ShellExecute
-#include <Commdlg.h>
-//#include <shlobj.h>		// Browse
-//#include <stdio.h>		// FILE *
-//#include <stdlib.h>		// malloc, free
 #include "resource.h"
 #include "filters.h"	// CoolEdit
+#include "Defines.h"	// my defines
+#include "EncDialog.h"
 #include "Cfaac.h"
 
-#include <commctrl.h>
-//#include <id3.h>
-#include <id3v2tag.h>
 
-// *********************************************************************************************
 
-extern HINSTANCE hInst;
-extern HBITMAP hBmBrowse;
-
 // *********************************************************************************************
 
 
 
-/*
-DWORD PackCfg(MY_ENC_CFG *cfg)
-{
-DWORD dwOptions=0;
-
-	if(cfg->AutoCfg)
-		dwOptions=1<<31;
-	dwOptions|=(DWORD)cfg->EncCfg.mpegVersion<<30;
-	dwOptions|=(DWORD)cfg->EncCfg.aacObjectType<<28;
-	dwOptions|=(DWORD)cfg->EncCfg.allowMidside<<27;
-	dwOptions|=(DWORD)cfg->EncCfg.useTns<<26;
-	dwOptions|=(DWORD)cfg->EncCfg.useLfe<<25;
-	dwOptions|=(DWORD)cfg->EncCfg.outputFormat<<24;
-	if(cfg->UseQuality)
-		dwOptions|=(((DWORD)cfg->EncCfg.quantqual>>1)&0xff)<<16; // [2,512]
-	else
-		dwOptions|=(((DWORD)cfg->EncCfg.bitRate>>1)&0xff)<<16; // [2,512]
-	if(cfg->UseQuality)
-		dwOptions|=1<<15;
-	dwOptions|=((DWORD)cfg->EncCfg.bandWidth>>1)&&0x7fff; // [0,65536]
-
-	return dwOptions;
-}
-// -----------------------------------------------------------------------------------------------
-
-void UnpackCfg(MY_ENC_CFG *cfg, DWORD dwOptions)
-{
-	cfg->AutoCfg=dwOptions>>31;
-	cfg->EncCfg.mpegVersion=(dwOptions>>30)&1;
-	cfg->EncCfg.aacObjectType=(dwOptions>>28)&3;
-	cfg->EncCfg.allowMidside=(dwOptions>>27)&1;
-	cfg->EncCfg.useTns=(dwOptions>>26)&1;
-	cfg->EncCfg.useLfe=(dwOptions>>25)&1;
-	cfg->EncCfg.outputFormat=(dwOptions>>24)&1;
-	cfg->EncCfg.bitRate=((dwOptions>>16)&0xff)<<1;
-	cfg->UseQuality=(dwOptions>>15)&1;
-	cfg->EncCfg.bandWidth=(dwOptions&0x7fff)<<1;
-}*/
-// -----------------------------------------------------------------------------------------------
-
-#define INIT_CB(hWnd,nID,list,IdSelected) \
-{ \
-	for(int i=0; list[i]; i++) \
-		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)list[i]); \
-	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
-}
-// -----------------------------------------------------------------------------------------------
-
-#define INIT_CB_GENRES(hWnd,nID,ID3Genres,IdSelected) \
-{ \
-	for(int i=0; i<(sizeof(ID3Genres)/sizeof(ID3Genres[0])); i++) \
-		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)ID3Genres[i].name); \
-	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
-}
-// -----------------------------------------------------------------------------------------------
-
-#define DISABLE_LTP \
-{ \
-	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \
-	   IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \
-	{ \
-		CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); \
-		CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); \
-	} \
-    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \
-}
-// -----------------------------------------------------------------------------------------------
-
-//        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
-//        EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled);
-#define DISABLE_CTRL(Enabled) \
-{ \
-	CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_RAW), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_ADTS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_ALLOWMIDSIDE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USETNS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_QUALITY), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_QUALITY), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_BITRATE), Enabled); \
-    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
-    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
-    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
-	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4)) \
-		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
-	else \
-		DISABLE_LTP \
-}
-// -----------------------------------------------------------------------------------------------
-
-#define ENABLE_TAG(Enabled) \
-{ \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTIST), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_TITLE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ALBUM), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_YEAR), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_GENRE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_WRITER), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMMENT), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_TRACK), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTFILE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), Enabled); \
-}
-// -----------------------------------------------------------------------------------------------
-
-#define ENABLE_AACTAGS(Enabled) \
-{ \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \
-}
-// -----------------------------------------------------------------------------------------------
-
-BOOL DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
-{
-	switch(Message)
-	{
-	case WM_INITDIALOG:
-		{
-		char buf[512];
-		char *faac_id_string, *faac_copyright_string;
-
-		sprintf(buf,
-					APP_NAME " plugin " APP_VER " by Antonio Foranna\n\n"
-					"Engines used:\n"
-					"\tlibfaac v%s\n"
-					"\tFAAD2 v" FAAD2_VERSION "\n"
-					"\t" PACKAGE " v" VERSION "\n\n"
-					"This code is given with FAAC package and does not contain executables.\n"
-					"This program is free software and can be distributed/modifyed under the terms of the GNU General Public License.\n"
-					"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.\n\n"
-					"Compiled on %s\n",
-				(faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version",
-					__DATE__
-					);
-			SetDlgItemText(hWndDlg, IDC_L_ABOUT, buf);
-		}
-		break;
-	case WM_COMMAND:
-		switch(LOWORD(wParam))
-		{
-		case IDOK:
-			EndDialog(hWndDlg, TRUE);
-			break;
-        case IDCANCEL:
-			// Ignore data values entered into the controls and dismiss the dialog window returning FALSE
-			EndDialog(hWndDlg, FALSE);
-			break;
-		case IDC_AUDIOCODING:
-			ShellExecute(hWndDlg, NULL, "http://www.audiocoding.com", NULL, NULL, SW_SHOW);
-			break;
-		case IDC_MPEG4IP:
-			ShellExecute(hWndDlg, NULL, "http://www.mpeg4ip.net", NULL, NULL, SW_SHOW);
-			break;
-		case IDC_EMAIL:
-			ShellExecute(hWndDlg, NULL, "mailto:ntnfrn_email-temp@yahoo.it", NULL, NULL, SW_SHOW);
-			break;
-		}
-		break;
-	default: 
-		return FALSE;
-	}
-
-	return TRUE;
-}
-// -----------------------------------------------------------------------------------------------
-
-// ripped from id3v2tag.c
-ID3GENRES ID3Genres[]=
-{
-    123,    "Acapella",
-    34,     "Acid",
-    74,     "Acid Jazz",
-    73,     "Acid Punk",
-    99,     "Acoustic",
-    20,     "Alternative",
-    40,     "AlternRock",
-    26,     "Ambient",
-    90,     "Avantgarde",
-    116,    "Ballad",
-    41,     "Bass",
-    85,     "Bebob",
-    96,     "Big Band",
-    89,     "Bluegrass",
-    0,      "Blues",
-    107,    "Booty Bass",
-    65,     "Cabaret",
-    88,     "Celtic",
-    104,    "Chamber Music",
-    102,    "Chanson",
-    97,     "Chorus",
-    61,     "Christian Rap",
-    1,      "Classic Rock",
-    32,     "Classical",
-    112,    "Club",
-    57,     "Comedy",
-    2,      "Country",
-    58,     "Cult",
-    3,      "Dance",
-    125,    "Dance Hall",
-    50,     "Darkwave",
-    254,    "Data",
-    22,     "Death Metal",
-    4,      "Disco",
-    55,     "Dream",
-    122,    "Drum Solo",
-    120,    "Duet",
-    98,     "Easy Listening",
-    52,     "Electronic",
-    48,     "Ethnic",
-    124,    "Euro-House",
-    25,     "Euro-Techno",
-    54,     "Eurodance",
-    84,     "Fast Fusion",
-    80,     "Folk",
-    81,     "Folk-Rock",
-    115,    "Folklore",
-    119,    "Freestyle",
-    5,      "Funk",
-    30,     "Fusion",
-    36,     "Game",
-    59,     "Gangsta",
-    38,     "Gospel",
-    49,     "Gothic",
-    91,     "Gothic Rock",
-    6,      "Grunge",
-    79,     "Hard Rock",
-    7,      "Hip-Hop",
-    35,     "House",
-    100,    "Humour",
-    19,     "Industrial",
-    33,     "Instrumental",
-    46,     "Instrumental Pop",
-    47,     "Instrumental Rock",
-    8,      "Jazz",
-    29,     "Jazz+Funk",
-    63,     "Jungle",
-    86,     "Latin",
-    71,     "Lo-Fi",
-    45,     "Meditative",
-    9,      "Metal",
-    77,     "Musical",
-    82,     "National Folk",
-    64,     "Native American",
-    10,     "New Age",
-    66,     "New Wave",
-    39,     "Noise",
-    255,    "Not Set",
-    11,     "Oldies",
-    103,    "Opera",
-    12,     "Other",
-    75,     "Polka",
-    13,     "Pop",
-    62,     "Pop/Funk",
-    53,     "Pop-Folk",
-    109,    "Porn Groove",
-    117,    "Power Ballad",
-    23,     "Pranks",
-    108,    "Primus",
-    92,     "Progressive Rock",
-    67,     "Psychadelic",
-    93,     "Psychedelic Rock",
-    43,     "Punk",
-    121,    "Punk Rock",
-    14,     "R&B",
-    15,     "Rap",
-    68,     "Rave",
-    16,     "Reggae",
-    76,     "Retro",
-    87,     "Revival",
-    118,    "Rhythmic Soul",
-    17,     "Rock",
-    78,     "Rock & Roll",
-    114,    "Samba",
-    110,    "Satire",
-    69,     "Showtunes",
-    21,     "Ska",
-    111,    "Slow Jam",
-    95,     "Slow Rock",
-    105,    "Sonata",
-    42,     "Soul",
-    37,     "Sound Clip",
-    24,     "Soundtrack",
-    56,     "Southern Rock",
-    44,     "Space",
-    101,    "Speech",
-    83,     "Swing",
-    94,     "Symphonic Rock",
-    106,    "Symphony",
-    113,    "Tango",
-    18,     "Techno",
-    51,     "Techno-Industrial",
-    60,     "Top 40",
-    70,     "Trailer",
-    31,     "Trance",
-    72,     "Tribal",
-    27,     "Trip-Hop",
-    28,     "Vocal"
-};
-
-BOOL DIALOGMsgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
-{
-	switch(Message)
-	{
-	case WM_INITDIALOG:
-		{
-		char buf[50];
-		char *Quality[]={"Default","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","200","300","400","500",0};
-		char *BitRate[]={"Auto","8","18","20","24","32","40","48","56","64","96","112","128","160","192","224","256","320","384",0};
-		char *BandWidth[]={"Auto","Full","4000","8000","11025","16000","22050","24000","32000","44100","48000","64000","88200","96000",0};
-		MY_ENC_CFG cfg;
-
-			SetWindowPos(GetDlgItem(hWndDlg,IDC_CHK_TAG),GetDlgItem(hWndDlg,IDC_GRP_TAG),0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
-
-			Cfaac::getFaacCfg(&cfg);
-
-			INIT_CB(hWndDlg,IDC_CB_QUALITY,Quality,0);
-			INIT_CB(hWndDlg,IDC_CB_BITRATE,BitRate,0);
-			INIT_CB(hWndDlg,IDC_CB_BANDWIDTH,BandWidth,0);
-
-			INIT_CB_GENRES(hWndDlg,IDC_CB_GENRE,ID3Genres,0);
-
-			SendMessage(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
-			if(cfg.EncCfg.mpegVersion==MPEG4)
-				CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-			else
-				CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
-
-			switch(cfg.EncCfg.aacObjectType)
-			{
-			case MAIN:
-				CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-				break;
-			case LOW:
-				CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
-				break;
-			case SSR:
-				CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
-				break;
-			case LTP:
-				CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
-				DISABLE_LTP
-				break;
-			}
-
-			switch(cfg.EncCfg.outputFormat)
-			{
-			case RAW:
-				CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);
-				break;
-			case ADTS:
-				CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
-				break;
-			}
-
-			CheckDlgButton(hWndDlg, IDC_CHK_ALLOWMIDSIDE, cfg.EncCfg.allowMidside);
-			CheckDlgButton(hWndDlg, IDC_CHK_USETNS, cfg.EncCfg.useTns);
-			CheckDlgButton(hWndDlg, IDC_CHK_USELFE, cfg.EncCfg.useLfe);
-
-			if(cfg.UseQuality)
-				CheckDlgButton(hWndDlg,IDC_RADIO_QUALITY,TRUE);
-			else
-				CheckDlgButton(hWndDlg,IDC_RADIO_BITRATE,TRUE);
-
-			switch(cfg.EncCfg.quantqual)
-			{
-			case 100:
-				SendMessage(GetDlgItem(hWndDlg, IDC_CB_QUALITY), CB_SETCURSEL, 0, 0);
-				break;
-			default:
-				if(cfg.EncCfg.quantqual<10)
-					cfg.EncCfg.quantqual=10;
-				if(cfg.EncCfg.quantqual>500)
-					cfg.EncCfg.quantqual=500;
-				sprintf(buf,"%lu",cfg.EncCfg.quantqual);
-				SetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf);
-				break;
-			}
-			switch(cfg.EncCfg.bitRate)
-			{
-			case 0:
-				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 0, 0);
-				break;
-			default:
-				sprintf(buf,"%lu",cfg.EncCfg.bitRate);
-				SetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf);
-				break;
-			}
-			switch(cfg.EncCfg.bandWidth)
-			{
-			case 0:
-				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0);
-				break;
-			case 0xffffffff:
-				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 1, 0);
-				break;
-			default:
-				sprintf(buf,"%lu",cfg.EncCfg.bandWidth);
-				SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf);
-				break;
-			}
-
-			CheckDlgButton(hWndDlg, IDC_CHK_WRITEMP4, cfg.SaveMP4);
-
-			CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, cfg.AutoCfg);
-			DISABLE_CTRL(!cfg.AutoCfg);
-
-			CheckDlgButton(hWndDlg,IDC_CHK_TAG, cfg.Tag.On);
-			ENABLE_TAG(cfg.Tag.On);
-			ENABLE_AACTAGS(cfg.SaveMP4);
-			SetDlgItemText(hWndDlg, IDC_E_ARTIST, cfg.Tag.artist);
-			SetDlgItemText(hWndDlg, IDC_E_TITLE, cfg.Tag.title);
-			SetDlgItemText(hWndDlg, IDC_E_ALBUM, cfg.Tag.album);
-			SetDlgItemText(hWndDlg, IDC_E_YEAR, cfg.Tag.year);
-			SetDlgItemText(hWndDlg, IDC_CB_GENRE, cfg.Tag.genre);
-			SetDlgItemText(hWndDlg, IDC_E_WRITER, cfg.Tag.writer);
-			SetDlgItemText(hWndDlg, IDC_E_COMMENT, cfg.Tag.comment);
-			SetDlgItemText(hWndDlg, IDC_E_ARTFILE, cfg.Tag.artFileName);
-			SetDlgItemInt(hWndDlg, IDC_E_TRACK, cfg.Tag.trackno, FALSE);
-			SetDlgItemInt(hWndDlg, IDC_E_NTRACKS, cfg.Tag.ntracks, FALSE);
-			SetDlgItemInt(hWndDlg, IDC_E_DISK, cfg.Tag.discno, FALSE);
-			SetDlgItemInt(hWndDlg, IDC_E_NDISKS, cfg.Tag.ndiscs, FALSE);
-			SetDlgItemInt(hWndDlg, IDC_E_COMPILATION, cfg.Tag.compilation, FALSE);
-			Cfaac::FreeTag(&cfg.Tag);
-		}
-		break; // End of WM_INITDIALOG                                 
-
-	case WM_CLOSE:
-		// Closing the Dialog behaves the same as Cancel               
-		PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0);
-		break; // End of WM_CLOSE                                      
-
-	case WM_COMMAND:
-		switch(LOWORD(wParam))
-		{
-		case IDOK:
-			{
-			char buf[50];
-			MY_ENC_CFG cfg;
-
-				cfg.AutoCfg=IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG) ? TRUE : FALSE;
-				cfg.EncCfg.mpegVersion=IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4) ? MPEG4 : MPEG2;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
-					cfg.EncCfg.aacObjectType=MAIN;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
-					cfg.EncCfg.aacObjectType=LOW;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
-					cfg.EncCfg.aacObjectType=SSR;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
-					cfg.EncCfg.aacObjectType=LTP;
-				cfg.EncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_CHK_ALLOWMIDSIDE);
-				cfg.EncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_CHK_USETNS);
-				cfg.EncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_CHK_USELFE);
-				
-				GetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf, 50);
-				switch(*buf)
-				{
-				case 'A': // Auto
-					cfg.EncCfg.bitRate=0;
-					break;
-				default:
-					cfg.EncCfg.bitRate=GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
-				}
-				GetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf, 50);
-				switch(*buf)
-				{
-				case 'A': // Auto
-					cfg.EncCfg.bandWidth=0;
-					break;
-				case 'F': // Full
-					cfg.EncCfg.bandWidth=0xffffffff;
-					break;
-				default:
-					cfg.EncCfg.bandWidth=GetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, 0, FALSE);
-				}
-				cfg.UseQuality=IsDlgButtonChecked(hWndDlg,IDC_RADIO_QUALITY) ? TRUE : FALSE;
-				GetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf, 50);
-				switch(*buf)
-				{
-				case 'D': // Default
-					cfg.EncCfg.quantqual=100;
-					break;
-				default:
-					cfg.EncCfg.quantqual=GetDlgItemInt(hWndDlg, IDC_CB_QUALITY, 0, FALSE);
-				}
-				cfg.EncCfg.outputFormat=IsDlgButtonChecked(hWndDlg,IDC_RADIO_RAW) ? RAW : ADTS;
-
-				cfg.SaveMP4=IsDlgButtonChecked(hWndDlg, IDC_CHK_WRITEMP4) ? TRUE : FALSE;
-
-				cfg.Tag.On=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG) ? 1 : 0;
-			char buffer[MAX_PATH];
-				GetDlgItemText(hWndDlg, IDC_E_ARTIST, buffer, MAX_PATH);
-				cfg.Tag.artist=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_TITLE, buffer, MAX_PATH);
-				cfg.Tag.title=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_ALBUM, buffer, MAX_PATH);
-				cfg.Tag.album=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_YEAR, buffer, MAX_PATH);
-				cfg.Tag.year=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_CB_GENRE, buffer, MAX_PATH);
-				cfg.Tag.genre=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_WRITER, buffer, MAX_PATH);
-				cfg.Tag.writer=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_COMMENT, buffer, MAX_PATH);
-				cfg.Tag.comment=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_ARTFILE, buffer, MAX_PATH);
-				cfg.Tag.artFileName=strdup(buffer);
-				cfg.Tag.trackno=GetDlgItemInt(hWndDlg, IDC_E_TRACK, 0, FALSE);
-				cfg.Tag.ntracks=GetDlgItemInt(hWndDlg, IDC_E_NTRACKS, 0, FALSE);
-				cfg.Tag.discno=GetDlgItemInt(hWndDlg, IDC_E_DISK, 0, FALSE);
-				cfg.Tag.ndiscs=GetDlgItemInt(hWndDlg, IDC_E_NDISKS, 0, FALSE);
-				cfg.Tag.compilation=(BYTE)GetDlgItemInt(hWndDlg, IDC_E_COMPILATION, 0, FALSE);
-
-				Cfaac::setFaacCfg(&cfg);
-				Cfaac::FreeTag(&cfg.Tag);
-
-				EndDialog(hWndDlg, TRUE);
-			}
-			break;
-
-        case IDCANCEL:
-			// Ignore data values entered into the controls        
-			// and dismiss the dialog window returning FALSE
-			EndDialog(hWndDlg, FALSE);
-			break;
-
-		case IDC_BTN_ABOUT:
-			DialogBox((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_ABOUT), (HWND)hWndDlg, (DLGPROC)DialogMsgProcAbout);
-			break;
-
-		case IDC_BTN_LICENSE:
-			{
-			char *license =
-				"\nPlease note that the use of this software may require the payment of patent royalties.\n"
-				"You need to consider this issue before you start building derivative works.\n"
-				"We are not warranting or indemnifying you in any way for patent royalities!\n"
-				"YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN ACTIONS!\n"
-				"\n"
-				"FAAC is based on the ISO MPEG-4 reference code. For this code base the\n"
-				"following license applies:\n"
-				"\n"
-/*				"This software module was originally developed by\n"
-				"\n"
-				"FirstName LastName (CompanyName)\n"
-				"\n"
-				"and edited by\n"
-				"\n"
-				"FirstName LastName (CompanyName)\n"
-				"FirstName LastName (CompanyName)\n"
-				"\n"
-*/				"in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard\n"
-				"ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an\n"
-				"implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools\n"
-				"as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives\n"
-				"users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this\n"
-				"software module or modifications thereof for use in hardware or\n"
-				"software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio\n"
-				"standards. Those intending to use this software module in hardware or\n"
-				"software products are advised that this use may infringe existing\n"
-				"patents. The original developer of this software module and his/her\n"
-				"company, the subsequent editors and their companies, and ISO/IEC have\n"
-				"no liability for use of this software module or modifications thereof\n"
-				"in an implementation. Copyright is not released for non MPEG-2\n"
-				"NBC/MPEG-4 Audio conforming products. The original developer retains\n"
-				"full right to use the code for his/her own purpose, assign or donate\n"
-				"the code to a third party and to inhibit third party from using the\n"
-				"code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This\n"
-				"copyright notice must be included in all copies or derivative works.\n"
-				"\n"
-				"Copyright (c) 1997.\n"
-				"\n"
-				"For the changes made for the FAAC project the GNU Lesser General Public\n"
-				"License (LGPL), version 2 1991 applies:\n"
-				"\n"
-				"FAAC - Freeware Advanced Audio Coder\n"
-				"Copyright (C) 2001-2004 The individual contributors\n"
-				"\n"
-				"This library is free software; you can redistribute it and/or modify it under the terms of\n"
-				"the GNU Lesser General Public License as published by the Free Software Foundation;\n"
-				"either version 2.1 of the License, or (at your option) any later version.\n"
-				"\n"
-				"This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n"
-				"without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
-				"See the GNU Lesser General Public License for more details.\n"
-				"\n"
-				"You should have received a copy of the GNU Lesser General Public\n"
-				"License along with this library; if not, write to the Free Software\n"
-				"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n";
-
-				MessageBox(hWndDlg,license,"FAAC libray License",MB_OK|MB_ICONINFORMATION);
-			}
-			break;
-
-		case IDC_BTN_ARTFILE:
-			{
-			OPENFILENAME ofn;
-			char ArtFilename[MAX_PATH]="";
-
-//				GetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename, MAX_PATH);
-
-				ofn.lStructSize			= sizeof(OPENFILENAME);
-				ofn.hwndOwner			= (HWND)hWndDlg;
-				ofn.lpstrFilter			= "Cover art files (*.gif,*jpg,*.png)\0*.gif;*.jpg;*.png\0";
-				ofn.lpstrCustomFilter	= NULL;
-				ofn.nFilterIndex		= 1;
-				ofn.lpstrFile			= ArtFilename;
-				ofn.nMaxFile			= MAX_PATH; //sizeof ArtFilename;
-				ofn.lpstrFileTitle		= NULL;
-				ofn.nMaxFileTitle		= 0;
-				ofn.lpstrInitialDir		= NULL;
-				ofn.lpstrTitle			= "Select cover art file";
-				ofn.Flags				= OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING;
-				ofn.lpstrDefExt			= NULL;//"jpg";
-				ofn.hInstance			= hInst;
-
-				if(GetOpenFileName(&ofn))
-					SetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename);
-			}
-			break;
-
-		case IDC_RADIO_MPEG4:
-			EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			break;
-			
-		case IDC_RADIO_MPEG2:
-			EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
-			DISABLE_LTP
-			break;
-
-		case IDC_CHK_AUTOCFG:
-			{
-			char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG);
-				DISABLE_CTRL(Enabled);
-			}
-			break;
-
-		case IDC_CHK_TAG:
-			{
-			char Enabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG);
-				ENABLE_TAG(Enabled);
-			}
-//			break;
-		case IDC_CHK_WRITEMP4:
-			{
-			char Enabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_WRITEMP4) && IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG);
-				ENABLE_AACTAGS(Enabled);
-			}
-			break;
-		}
-		break; // End of WM_COMMAND
-	default: 
-		return FALSE;
-	}
- 
-	return TRUE;
-}
-
-// *********************************************************************************************
-// *********************************************************************************************
-// *********************************************************************************************
-
 inline DWORD ERROR_FGO(char *msg)
 {
 	if(msg)
@@ -727,7 +46,7 @@
 
 DWORD FAR PASCAL FilterGetOptions(HWND hWnd, HINSTANCE hInst, long lSamprate, WORD wChannels, WORD wBitsPerSample, DWORD dwOptions)
 {
-long retVal=DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_ENCODER), (HWND)hWnd, (DLGPROC)DIALOGMsgProc, dwOptions);
+long retVal=DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_ENCODER), (HWND)hWnd, (DLGPROC)DIALOGMsgProcEnc, dwOptions);
 
 	if(retVal==-1)
 		/*return */ERROR_FGO("DialogBoxParam");
--- a/plugins/cooledit/Faad.cpp
+++ b/plugins/cooledit/Faad.cpp
@@ -20,193 +20,13 @@
 */
 
 #include <windows.h>
-#include <stdio.h>		// FILE *
-#include "resource.h"
+//#include "resource.h"
 #include "filters.h"	// CoolEdit
-#include "CRegistry.h"
-#include "Defines.h"	// my defines
+#include "DecDialog.h"
 #include "Cfaad.h"
 
 // *********************************************************************************************
 
-extern HINSTANCE hInst;
-
-// -----------------------------------------------------------------------------------------------
-
-extern BOOL DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam);
-
-// *********************************************************************************************
-
-static const char* mpeg4AudioNames[]=
-{
-	"Raw PCM",
-	"AAC Main",
-	"AAC LC (Low Complexity)",
-	"AAC SSR",
-	"AAC LTP (Long Term Prediction)",
-	"AAC HE (High Efficiency)",
-	"AAC Scalable",
-	"TwinVQ",
-	"CELP",
-	"HVXC",
-	"Reserved",
-	"Reserved",
-	"TTSI",
-	"Main synthetic",
-	"Wavetable synthesis",
-	"General MIDI",
-	"Algorithmic Synthesis and Audio FX",
-// defined in MPEG-4 version 2
-	"ER AAC LC (Low Complexity)",
-	"Reserved",
-	"ER AAC LTP (Long Term Prediction)",
-	"ER AAC Scalable",
-	"ER TwinVQ",
-	"ER BSAC",
-	"ER AAC LD (Low Delay)",
-	"ER CELP",
-	"ER HVXC",
-	"ER HILN",
-	"ER Parametric",
-	"Reserved",
-	"Reserved",
-	"Reserved",
-	"Reserved"
-};
-
-// *********************************************************************************************
-
-#define INIT_CB(hWnd,nID,list,IdSelected) \
-{ \
-	for(int i=0; list[i]; i++) \
-		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)list[i]); \
-	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
-}
-// -----------------------------------------------------------------------------------------------
-
-//	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
-#define DISABLE_CTRL(Enabled) \
-{ \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_HE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_DOWNMATRIX), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_OLDADTS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_SAMPLERATE), Enabled); \
-}
-// -----------------------------------------------------------------------------------------------
-
-static MY_DEC_CFG *CfgDecoder;
-
-BOOL DialogMsgProcDecoder(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
-{
-	switch(Message)
-	{
-	case WM_INITDIALOG:
-		{
-			if(!lParam)
-			{
-				MessageBox(hWndDlg,"Pointer==NULL",0,MB_OK|MB_ICONSTOP);
-				EndDialog(hWndDlg, 0);
-				return TRUE;
-			}
-
-		char buf[50];
-		char *SampleRate[]={"6000","8000","16000","22050","32000","44100","48000","64000","88200","96000","192000",0};
-			CfgDecoder=(MY_DEC_CFG *)lParam;
-
-			INIT_CB(hWndDlg,IDC_CB_SAMPLERATE,SampleRate,5);
-			sprintf(buf,"%lu",CfgDecoder->DecCfg.defSampleRate);
-			SetDlgItemText(hWndDlg, IDC_CB_SAMPLERATE, buf);
-
-			switch(CfgDecoder->DecCfg.defObjectType)
-			{
-			case MAIN:
-				CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-				break;
-			case LC:
-				CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
-				break;
-			case SSR:
-				CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
-				break;
-			case LTP:
-				CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
-				break;
-			case HE_AAC:
-				CheckDlgButton(hWndDlg,IDC_RADIO_HE,TRUE);
-				break;
-			}
-
-			CheckDlgButton(hWndDlg,IDC_CHK_DOWNMATRIX, CfgDecoder->DefaultCfg);
-			CheckDlgButton(hWndDlg,IDC_CHK_OLDADTS, CfgDecoder->DefaultCfg);
-
-			CheckDlgButton(hWndDlg,IDC_CHK_DEFAULTCFG, CfgDecoder->DefaultCfg);
-			DISABLE_CTRL(!CfgDecoder->DefaultCfg);
-		}
-		break; // End of WM_INITDIALOG                                 
-
-	case WM_CLOSE:
-		// Closing the Dialog behaves the same as Cancel               
-		PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0);
-		break; // End of WM_CLOSE                                      
-
-	case WM_COMMAND:
-		switch(LOWORD(wParam))
-		{
-		case IDC_CHK_DEFAULTCFG:
-			{
-			char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_DEFAULTCFG);
-				DISABLE_CTRL(Enabled);
-			}
-			break;
-
-		case IDOK:
-			{
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
-					CfgDecoder->DecCfg.defObjectType=MAIN;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
-					CfgDecoder->DecCfg.defObjectType=LC;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
-					CfgDecoder->DecCfg.defObjectType=SSR;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
-					CfgDecoder->DecCfg.defObjectType=LTP;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_HE))
-					CfgDecoder->DecCfg.defObjectType=HE_AAC;
-
-				CfgDecoder->DecCfg.defSampleRate=GetDlgItemInt(hWndDlg, IDC_CB_SAMPLERATE, 0, FALSE);
-				CfgDecoder->DefaultCfg=IsDlgButtonChecked(hWndDlg,IDC_CHK_DEFAULTCFG) ? TRUE : FALSE;
-				CfgDecoder->DecCfg.downMatrix=IsDlgButtonChecked(hWndDlg,IDC_CHK_DOWNMATRIX) ? TRUE : FALSE;
-				CfgDecoder->DecCfg.useOldADTSFormat=IsDlgButtonChecked(hWndDlg,IDC_CHK_OLDADTS) ? TRUE : FALSE;
-				Cfaad::WriteCfgDec(CfgDecoder);
-
-				EndDialog(hWndDlg, (DWORD)CfgDecoder);
-			}
-			break;
-
-        case IDCANCEL:
-			// Ignore data values entered into the controls        
-			// and dismiss the dialog window returning FALSE
-			EndDialog(hWndDlg, (DWORD)FALSE);
-			break;
-
-		case IDC_BTN_ABOUT:
-				DialogBox((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_ABOUT), (HWND)hWndDlg, (DLGPROC)DialogMsgProcAbout);
-			break;
-		}
-		break; // End of WM_COMMAND
-	default: 
-		return FALSE;
-	}
- 
-	return TRUE;
-}
-
-// *********************************************************************************************
-// *********************************************************************************************
-// *********************************************************************************************
-
 BOOL FAR PASCAL FilterUnderstandsFormat(LPSTR filename)
 {
 WORD len;
@@ -213,7 +33,8 @@
 
 	if((len=lstrlen(filename))>4 && 
 		(!strcmpi(filename+len-4,".aac") ||
-		!strcmpi(filename+len-4,".mp4")))
+		!strcmpi(filename+len-4,".mp4") ||
+		!strcmpi(filename+len-4,".m4a")))
 		return TRUE;
 	return FALSE;
 }
@@ -319,7 +140,7 @@
 	{
 	CRegistry	reg;
 
-		if(reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME  "\\FAAD"))
+		if(reg.openCreateReg(HKEY_CURRENT_USER,REGISTRY_PROGRAM_NAME  "\\FAAD"))
 			reg.setRegBool("OpenDialog",FALSE);
 		else
 			MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
@@ -345,23 +166,41 @@
 // return handle that will be passed in to close, and write routines
 HANDLE FAR PASCAL OpenFilterInput(LPSTR lpstrFilename, long far *lSamprate, WORD far *wBitsPerSample, WORD far *wChannels, HWND hWnd, long far *lChunkSize)
 {
-HANDLE	hInput;
+HANDLE	hInput=NULL;
 Cfaad	tmp;
+CMyDecCfg cfg(false);
 
+	if(!*lSamprate && !tmp.IsMP4(lpstrFilename))
+	{
+/*	aac_buffer	b;
+	float		fLength;
+	int			bitrate;
+	DWORD		headertype;
+		tmp.GetAACInfos(lpstrFilename,&b,&headertype,&fLength,&bitrate);
+		if(headertype==RAW)
+			tmp.ShowDlg4RawAAC=ShowDlg4RawAAC;*/
+    DWORD           *seek_table;
+    int             seek_table_length;
+	faadAACInfo     file_info;
+		if(!get_AAC_format(lpstrFilename, &file_info, &seek_table, &seek_table_length, 0))
+			if(file_info.headertype==RAW)
+				tmp.ShowDlg4RawAAC=ShowDlg4RawAAC;
+	}
+
 	if(hInput=tmp.getInfos(lpstrFilename))
 	{
 	MYINPUT	*mi;
 		GLOBALLOCK(mi,hInput,MYINPUT,return NULL);
 	
-		if(mi->file_info.headertype!=RAW || mi->IsMP4) // to show dialog asking for samplerate
-			*lSamprate=mi->Samprate;
-		*wBitsPerSample=mi->BitsPerSample;
 		*wChannels=(WORD)mi->Channels;
+		*lSamprate=mi->Samprate;
+		*wBitsPerSample=mi->BitsPerSample;
 		*lChunkSize=(*wBitsPerSample/8)*1024**wChannels*2;
 
 		GlobalUnlock(hInput);
 		tmp.hInput=NULL;
 	}
+
 	return hInput;
 }
 // *********************************************************************************************
--- a/plugins/cooledit/Main.cpp
+++ b/plugins/cooledit/Main.cpp
@@ -28,7 +28,7 @@
 // Plugins of CoolEdit can be unloaded between each call of its exported funcs,
 // that's why no global variables can be used
 
-HINSTANCE hInst=NULL;
+HINSTANCE hInstance=NULL;
 HBITMAP hBmBrowse=NULL;
 
 BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
@@ -36,9 +36,9 @@
 	switch (fdwReason)
 	{
 	case DLL_PROCESS_ATTACH:
-		hInst=(HINSTANCE)hModule;
+		hInstance=(HINSTANCE)hModule;
 		if(!hBmBrowse)
-			hBmBrowse=(HBITMAP)LoadImage(hInst,MAKEINTRESOURCE(IDB_BROWSE),IMAGE_BITMAP,0,0,/*LR_CREATEDIBSECTION|*/LR_LOADTRANSPARENT|LR_LOADMAP3DCOLORS);
+			hBmBrowse=(HBITMAP)LoadImage(hInstance,MAKEINTRESOURCE(IDB_BROWSE),IMAGE_BITMAP,0,0,/*LR_CREATEDIBSECTION|*/LR_LOADTRANSPARENT|LR_LOADMAP3DCOLORS);
         /*	Code from LibMain inserted here.  Return TRUE to keep the
 			DLL loaded or return FALSE to fail loading the DLL.
 
@@ -80,7 +80,7 @@
 			LibMain) not be necessary.  Check to make certain that the
 			operating system is not doing it for you.
 			*/
-		hInst=NULL;
+		hInstance=NULL;
 		if(hBmBrowse)
 		{
             DeleteObject(hBmBrowse);
@@ -102,6 +102,7 @@
 	lstrcpy(cq->szCopyright, APP_NAME " codec");
 	lstrcpy(cq->szExt,"AAC");
 	lstrcpy(cq->szExt2,"MP4"); 
+	lstrcpy(cq->szExt3,"M4A"); 
 	cq->lChunkSize=16384; 
 	cq->dwFlags=QF_RATEADJUSTABLE|QF_CANLOAD|QF_CANSAVE|QF_HASOPTIONSBOX|QF_CANDO32BITFLOATS;
  	cq->Mono8=R_5500|R_11025|R_22050|R_32075|R_44100|R_48000;
--- a/plugins/cooledit/aacInfoLib.dsp
+++ b/plugins/cooledit/aacInfoLib.dsp
@@ -41,7 +41,6 @@
 # PROP Intermediate_Dir "Release"
 # PROP Target_Dir ""
 MTL=midl.exe
-F90=df.exe
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
 # ADD CPP /nologo /MD /W3 /GX /O2 /I "../../../faad2/common/faad" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
 # ADD BASE RSC /l 0x410 /d "NDEBUG"
@@ -66,9 +65,8 @@
 # PROP Intermediate_Dir "Debug"
 # PROP Target_Dir ""
 MTL=midl.exe
-F90=df.exe
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../../faad2/common/faad" /D "_WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../../faad2/common/faad" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
 # ADD BASE RSC /l 0x410 /d "_DEBUG"
 # ADD RSC /l 0x410 /d "_DEBUG"
 BSC32=bscmake.exe
@@ -89,11 +87,11 @@
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
 # Begin Source File
 
-SOURCE=..\..\..\faad2\common\faad\aacinfo.c
+SOURCE=..\..\common\faad\aacinfo.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\..\faad2\common\faad\filestream.c
+SOURCE=..\..\common\faad\filestream.c
 # End Source File
 # End Group
 # Begin Group "Header Files"
@@ -101,11 +99,11 @@
 # PROP Default_Filter "h;hpp;hxx;hm;inl"
 # Begin Source File
 
-SOURCE=..\..\..\faad2\common\faad\aacinfo.h
+SOURCE=..\..\common\faad\aacinfo.h
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\..\faad2\common\faad\filestream.h
+SOURCE=..\..\common\faad\filestream.h
 # End Source File
 # End Group
 # End Target
--- a/plugins/cooledit/aacInfoLib.vcproj
+++ b/plugins/cooledit/aacInfoLib.vcproj
@@ -3,6 +3,7 @@
 	ProjectType="Visual C++"
 	Version="7.00"
 	Name="aacInfoLib"
+	ProjectGUID="{7EFB2D8D-844F-416A-8D08-DA685C160058}"
 	SccProjectName=""
 	SccLocalPath="">
 	<Platforms>
@@ -24,7 +25,7 @@
 				AdditionalIncludeDirectories="../../../faad2/common/faad"
 				PreprocessorDefinitions="WIN32,_DEBUG,_LIB"
 				BasicRuntimeChecks="3"
-				RuntimeLibrary="5"
+				RuntimeLibrary="3"
 				UsePrecompiledHeader="2"
 				PrecompiledHeaderFile=".\Debug/aacInfoLib.pch"
 				AssemblerListingLocation=".\Debug/"
@@ -69,7 +70,7 @@
 				AdditionalIncludeDirectories="../../../faad2/common/faad"
 				PreprocessorDefinitions="WIN32,NDEBUG,_LIB"
 				StringPooling="TRUE"
-				RuntimeLibrary="0"
+				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="TRUE"
 				UsePrecompiledHeader="2"
 				PrecompiledHeaderFile=".\Release/aacInfoLib.pch"
@@ -107,9 +108,33 @@
 			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
 			<File
 				RelativePath="..\..\..\faad2\common\faad\aacinfo.c">
+				<FileConfiguration
+					Name="Debug|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\faad2\common\faad\filestream.c">
+				<FileConfiguration
+					Name="Debug|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)/$(InputName)1.obj"/>
+				</FileConfiguration>
 			</File>
 		</Filter>
 		<Filter
@@ -116,10 +141,10 @@
 			Name="Header Files"
 			Filter="h;hpp;hxx;hm;inl">
 			<File
-				RelativePath="..\..\..\faad2\common\faad\aacinfo.h">
+				RelativePath="..\..\common\faad\aacinfo.h">
 			</File>
 			<File
-				RelativePath="..\..\..\faad2\common\faad\filestream.h">
+				RelativePath="..\..\common\faad\filestream.h">
 			</File>
 		</Filter>
 	</Files>
--- a/plugins/cooledit/defines.h
+++ b/plugins/cooledit/defines.h
@@ -20,7 +20,7 @@
 */
 
 #define APP_NAME "MPEG4-AAC"
-#define APP_VER "v2.3"
+#define APP_VER "v2.4"
 #define REGISTRY_PROGRAM_NAME "SOFTWARE\\4N\\CoolEdit\\AAC-MPEG4"
 
 // *********************************************************************************************
binary files /dev/null b/plugins/cooledit/id3v2.ico differ
binary files a/plugins/cooledit/mpeg4ip-v.bmp b/plugins/cooledit/mpeg4ip-v.bmp differ
--- a/plugins/cooledit/resource.h
+++ b/plugins/cooledit/resource.h
@@ -9,63 +9,67 @@
 #define IDB_EMAIL                       106
 #define IDB_MPEG4IP                     107
 #define IDB_BROWSE                      108
-#define IDC_RADIO_MPEG4                 1000
-#define IDC_RADIO_MPEG2                 1001
-#define IDC_RADIO_LOW                   1002
-#define IDC_RADIO_MAIN                  1003
-#define IDC_RADIO_SSR                   1004
-#define IDC_RADIO_LTP                   1005
-#define IDC_RADIO_RAW                   1006
-#define IDC_RADIO_HE                    1006
-#define IDC_RADIO_ADTS                  1007
-#define IDC_CB_BANDWIDTH                1008
-#define IDC_CB_BITRATE                  1009
-#define IDC_CHK_ALLOWMIDSIDE            1010
-#define IDC_CHK_USETNS                  1011
-#define IDC_CHK_USELFE                  1012
-#define IDC_CHK_AUTOCFG                 1013
-#define IDC_BTN_ABOUT                   1014
-#define IDC_L_ABOUT                     1015
-#define IDC_BTN_ARTFILE                 1015
-#define IDC_AUDIOCODING                 1016
-#define IDC_CHK_USETNS2                 1016
-#define IDC_CHK_MP4                     1016
-#define WRITEMP4                        1016
-#define IDC_EMAIL                       1017
-#define IDC_E_BROWSE                    1017
-#define IDC_MPEG4IP                     1018
-#define IDC_CHK_DEFAULTCFG              1019
-#define IDC_CB_SAMPLERATE               1020
-#define IDC_RADIO_BITRATE               1022
-#define IDC_RADIO_QUALITY               1023
-#define IDC_CB_QUALITY                  1024
-#define IDC_CHK_DOWNMATRIX              1025
-#define IDC_CHK_OLDADTS                 1026
-#define IDC_CHK_WRITEMP4                1027
-#define IDC_E_ARTIST                    1028
-#define IDC_CHK_TAG                     1029
-#define IDC_E_TITLE                     1030
-#define IDC_E_ALBUM                     1031
-#define IDC_E_YEAR                      1032
-#define IDC_CB_GENRE                    1033
-#define IDC_E_WRITER                    1034
-#define IDC_E_COMMENT                   1035
-#define IDC_E_TRACK                     1036
-#define IDC_E_NTRACKS                   1037
-#define IDC_E_DISK                      1038
-#define IDC_E_NDISKS                    1039
-#define IDC_GRP_TAG                     1040
-#define IDC_E_COMPILATION               1041
-#define IDC_E_ARTFILE                   1042
-#define IDC_BTN_LICENSE                 1043
+#define IDI_ID3                         110
+#define IDC_CHK_DEFAULTCFG              1000
+#define IDC_CHK_DOWNMATRIX              1001
+#define IDC_CHK_OLDADTS                 1002
+#define IDC_CB_SAMPLERATE               1003
+#define IDC_AUDIOCODING                 1004
+#define IDC_CB_BITSPERSAMPLE            1004
+#define IDC_EMAIL                       1005
+#define IDC_MPEG4IP                     1006
+#define IDC_RADIO_MPEG4                 1009
+#define IDC_RADIO_MPEG2                 1010
+#define IDC_RADIO_LOW                   1011
+#define IDC_RADIO_MAIN                  1012
+#define IDC_RADIO_SSR                   1013
+#define IDC_RADIO_LTP                   1014
+#define IDC_RADIO_RAW                   1015
+#define IDC_RADIO_HE                    1016
+#define IDC_RADIO_ADTS                  1017
+#define IDC_CB_BANDWIDTH                1018
+#define IDC_CB_BITRATE                  1019
+#define IDC_CHK_ALLOWMIDSIDE            1020
+#define IDC_CHK_USETNS                  1021
+#define IDC_CHK_USELFE                  1022
+#define IDC_CHK_AUTOCFG                 1023
+#define IDC_BTN_ABOUT                   1024
+#define IDC_L_ABOUT                     1025
+#define IDC_BTN_ARTFILE                 1026
+#define IDC_CHK_USETNS2                 1027
+#define IDC_CHK_MP4                     1028
+#define WRITEMP4                        1029
+#define IDC_RADIO_BITRATE               1030
+#define IDC_RADIO_QUALITY               1031
+#define IDC_CB_QUALITY                  1032
+#define IDC_CHK_WRITEMP4                1033
+#define IDC_E_ARTIST                    1034
+#define IDC_CHK_TAG                     1035
+#define IDC_E_TITLE                     1036
+#define IDC_E_ALBUM                     1037
+#define IDC_E_YEAR                      1038
+#define IDC_CB_GENRE                    1039
+#define IDC_E_WRITER                    1040
+#define IDC_E_COMMENT                   1041
+#define IDC_E_TRACK                     1042
+#define IDC_E_NTRACKS                   1043
+#define IDC_E_DISK                      1044
+#define IDC_E_NDISKS                    1045
+#define IDC_GRP_TAG                     1046
+#define IDC_E_COMPILATION               1047
+#define IDC_E_ARTFILE                   1048
+#define IDC_BTN_LICENSE                 1049
+#define IDC_CHK_COMPILATION             1050
+#define IDC_GRP_DEFAULT                 1051
+#define IDC_ID3                         1052
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        109
+#define _APS_NEXT_RESOURCE_VALUE        111
 #define _APS_NEXT_COMMAND_VALUE         40001
-#define _APS_NEXT_CONTROL_VALUE         1044
+#define _APS_NEXT_CONTROL_VALUE         1054
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
--- a/plugins/winamp/.cvsignore
+++ b/plugins/winamp/.cvsignore
@@ -10,4 +10,5 @@
 Release
 Debug
 ReleaseGUI
-DebugGUI
\ No newline at end of file
+DebugGUI
+out_FAAC.suo
\ No newline at end of file
--- a/plugins/winamp/CRegistry.cpp
+++ b/plugins/winamp/CRegistry.cpp
@@ -138,13 +138,13 @@
 //************************************************************************************************
 //************************************************************************************************
 
-void CRegistry::SetBool(char *keyStr, BOOL val)
+void CRegistry::SetBool(char *keyStr, bool val)
 {
-BOOL tempVal;
-DWORD len;
+bool tempVal;
+DWORD len=sizeof(bool);
 	if(RegQueryValueEx(regKey, keyStr, NULL, NULL, (BYTE *)&tempVal, &len )!=ERROR_SUCCESS ||
 		tempVal!=val)
-		RegSetValueEx(regKey, keyStr, 0, REG_BINARY, (BYTE *)&val, sizeof(BOOL));
+		RegSetValueEx(regKey, keyStr, 0, REG_BINARY, (BYTE *)&val, sizeof(bool));
 }
 //************************************************************************************************
 
--- a/plugins/winamp/CRegistry.h
+++ b/plugins/winamp/CRegistry.h
@@ -41,7 +41,7 @@
 	void	DeleteVal(char *SubKey);
 	void	DeleteKey(char *SubKey);
 
-	void	SetBool(char *keyStr , BOOL val);
+	void	SetBool(char *keyStr , bool val);
 	void	SetByte(char *keyStr , BYTE val);
 	void	SetWord(char *keyStr , WORD val);
 	void	SetDword(char *keyStr , DWORD val);
--- /dev/null
+++ b/plugins/winamp/CTag.cpp
@@ -1,0 +1,316 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2002-2004 Antonio Foranna
+
+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.
+	
+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
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+			
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
+#include <stdlib.h>
+#include <mp4.h>
+#include <faac.h>
+#include "CTag.h"
+
+
+
+// *********************************************************************************************
+//										CMP4Tag
+// *********************************************************************************************
+
+CMP4Tag::CMP4Tag()
+{
+//	memset(this,0,sizeof(*this));
+	copyright=NULL;
+	artist=title=album=year=genre=writer=comment=NULL;
+	trackno=ntracks=discno=ndiscs=0;
+	compilation=0;
+	artFilename=NULL;
+	art.pictureType=0; // = other
+	memset(&art,0,sizeof(art));
+}
+// *********************************************************************************************
+
+void CMP4Tag::FreeTag()
+{
+	FREE_ARRAY(artist);
+	FREE_ARRAY(title);
+	FREE_ARRAY(album);
+	FREE_ARRAY(year);
+	FREE_ARRAY(genre);
+	FREE_ARRAY(writer);
+	FREE_ARRAY(comment);
+	FREE_ARRAY(artFilename);
+	FREE_ARRAY(art.data);
+	FREE_ARRAY(art.description);
+	FREE_ARRAY(art.mimeType);
+	FREE_ARRAY(art.format);
+}
+// ***********************************************************************************************
+
+int CMP4Tag::check_image_header(const char *buf)
+{
+	if(!strncmp(buf, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8))
+		return 1; /* PNG */
+	if(!strncmp(buf, "\xFF\xD8\xFF\xE0", 4) &&
+		!strncmp(buf + 6, "JFIF\0",	5))
+		return 2; /* JPEG */
+	if(!strncmp(buf, "GIF87a", 6)	|| !strncmp(buf, "GIF89a", 6))
+		return 3; /* GIF */
+
+	return 0;
+}
+// -----------------------------------------------------------------------------------------------
+
+int CMP4Tag::ReadCoverArtFile(char *pCoverArtFile, char **artData)
+{
+FILE *artFile;
+
+	if(!pCoverArtFile || !*pCoverArtFile)
+		return 0;
+
+	if(!(artFile=fopen(pCoverArtFile, "rb")))
+	{
+		MessageBox(NULL,"ReadCoverArtFile: fopen",NULL,MB_OK);
+		return 0;
+	}
+
+int r;
+char *art;
+int	artSize=0;
+
+	fseek(artFile, 0, SEEK_END);
+	artSize=ftell(artFile);
+	fseek(artFile, 0, SEEK_SET);
+
+	if(!(art=(char *)malloc(artSize)))
+	{
+		fclose(artFile);
+		MessageBox(NULL,"ReadCoverArtFile: Memory allocation error!", NULL, MB_OK);
+		return 0;
+	}
+
+	r=fread(art, 1, artSize, artFile);
+	if(r!=artSize)
+	{
+		free(art);
+		fclose(artFile);
+		MessageBox(NULL,"ReadCoverArtFile: Error reading cover art file!", NULL, MB_OK);
+		return 0;
+	}
+	else
+		if(artSize<12 || !check_image_header(art))
+		{
+			// the above expression checks the image signature
+			free(art);
+			fclose(artFile);
+			MessageBox(NULL,"ReadCoverArtFile: Unsupported cover image file format!", NULL, MB_OK);
+			return 0;
+		}
+
+	FREE_ARRAY(*artData);
+	*artData=art;
+	fclose(artFile);
+	return artSize;
+}
+// *********************************************************************************************
+
+void CMP4Tag::WriteMP4Tag(MP4FileHandle MP4File)
+{
+char	buf[512], *faac_id_string, *faac_copyright_string;
+
+	sprintf(buf, "FAAC v%s", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version");
+	MP4SetMetadataTool(MP4File, buf);
+
+	if(artist) MP4SetMetadataArtist(MP4File, artist);
+	if(writer) MP4SetMetadataWriter(MP4File, writer);
+	if(title) MP4SetMetadataName(MP4File, title);
+	if(album) MP4SetMetadataAlbum(MP4File, album);
+	if(trackno>0) MP4SetMetadataTrack(MP4File, trackno, ntracks);
+	if(discno>0) MP4SetMetadataDisk(MP4File, discno, ndiscs);
+	if(compilation) MP4SetMetadataCompilation(MP4File, compilation);
+	if(year) MP4SetMetadataYear(MP4File, year);
+	if(genre) MP4SetMetadataGenre(MP4File, genre);
+	if(comment) MP4SetMetadataComment(MP4File, comment);
+	if(art.size=ReadCoverArtFile(artFilename,&art.data))
+	{
+		MP4SetMetadataCoverArt(MP4File, (BYTE *)art.data, art.size);
+		FREE_ARRAY(art.data);
+	}
+}
+// *********************************************************************************************
+
+void CMP4Tag::ReadMp4Tag(char *Filename)						 
+{
+MP4FileHandle MP4File;
+
+	if(!(MP4File=MP4Read(Filename, 0)))
+	{
+		MessageBox(NULL,"Can't open file",NULL,MB_OK);
+		return;
+	}
+
+	FREE_ARRAY(copyright);
+	MP4GetMetadataTool(MP4File, &copyright);
+
+	FREE_ARRAY(artist);
+	MP4GetMetadataArtist(MP4File, &artist);
+	FREE_ARRAY(writer);
+	MP4GetMetadataWriter(MP4File, &writer);
+	FREE_ARRAY(title);
+	MP4GetMetadataName(MP4File, &title);
+	FREE_ARRAY(album);
+	MP4GetMetadataAlbum(MP4File, &album);
+	MP4GetMetadataTrack(MP4File, &trackno, &ntracks);
+	MP4GetMetadataDisk(MP4File, &discno, &ndiscs);
+	MP4GetMetadataCompilation(MP4File, &compilation);
+	FREE_ARRAY(year);
+	MP4GetMetadataYear(MP4File, &year);
+	FREE_ARRAY(genre);
+	MP4GetMetadataGenre(MP4File, &genre);
+	FREE_ARRAY(comment);
+	MP4GetMetadataComment(MP4File, &comment);
+	FREE_ARRAY(art.data);
+	MP4GetMetadataCoverArt(MP4File, (BYTE **)&art.data, (u_int32_t *)&art.size);
+
+	MP4Close(MP4File);
+/*
+	FILE *f=fopen("D:\\prova.jpg","wb");
+		fwrite(artFile,1,artSize,f);
+		fclose(f);*/
+}
+// *********************************************************************************************
+
+#define DEL_FIELD(id3Tag,ID3FID) \
+{ \
+ID3_Frame *Frame=id3Tag.Find(ID3FID); \
+	if(Frame!=NULL) \
+		id3Tag.RemoveFrame(Frame); \
+}
+// -----------------------------------------------------------------------------------------------
+
+#define ADD_FIELD(id3Tag,ID3FID,ID3FN,data) \
+{ \
+ID3_Frame *NewFrame=new ID3_Frame(ID3FID); \
+	NewFrame->Field(ID3FN)=data; \
+	DEL_FIELD(id3Tag,ID3FID); \
+	id3Tag.AttachFrame(NewFrame); \
+}
+// -----------------------------------------------------------------------------------------------
+
+void CMP4Tag::WriteAacTag(char *Filename)
+{
+char	buf[512], *faac_id_string, *faac_copyright_string;
+ID3_Tag id3Tag;
+
+	id3Tag.Link(Filename);
+
+	sprintf(buf, "FAAC v%s", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version");
+	ADD_FIELD(id3Tag,ID3FID_ENCODEDBY,ID3FN_TEXT,buf);
+
+	ADD_FIELD(id3Tag,ID3FID_LEADARTIST,ID3FN_TEXT,artist);
+	ADD_FIELD(id3Tag,ID3FID_COMPOSER,ID3FN_TEXT,writer);
+	ADD_FIELD(id3Tag,ID3FID_TITLE,ID3FN_TEXT,title);
+	ADD_FIELD(id3Tag,ID3FID_ALBUM,ID3FN_TEXT,album);
+	sprintf(buf,"%d",trackno);
+	ADD_FIELD(id3Tag,ID3FID_TRACKNUM,ID3FN_TEXT,buf);
+	ADD_FIELD(id3Tag,ID3FID_YEAR,ID3FN_TEXT,year);
+	ADD_FIELD(id3Tag,ID3FID_CONTENTTYPE,ID3FN_TEXT,genre);
+	ADD_FIELD(id3Tag,ID3FID_COMMENT,ID3FN_TEXT,comment);
+	art.size=ReadCoverArtFile(artFilename,&art.data);
+	if(art.size)
+	{
+	ID3_Frame *NewFrame=new ID3_Frame(ID3FID_PICTURE);
+	char name[_MAX_FNAME], ext[_MAX_EXT];
+		_splitpath(artFilename,NULL,NULL,name,ext);
+
+		NewFrame->Field(ID3FN_DESCRIPTION)=name;
+	char buf[15];
+		sprintf(buf,"image/%s",check_image_header(art.data)==2 ? "jpeg" : strlwr(ext+1));
+		NewFrame->Field(ID3FN_MIMETYPE)=buf;
+//		NewFrame->Field(ID3FN_IMAGEFORMAT)=;
+		NewFrame->Field(ID3FN_PICTURETYPE)=(DWORD)art.pictureType;
+		NewFrame->Field(ID3FN_DATA).Set((BYTE *)art.data,art.size);
+		id3Tag.AttachFrame(NewFrame);
+	}
+
+	// setup all our rendering parameters
+    id3Tag.SetUnsync(false);
+    id3Tag.SetExtendedHeader(true);
+    id3Tag.SetCompression(true);
+    id3Tag.SetPadding(true);
+ 
+	// write any changes to the file
+    id3Tag.Update();
+
+	FREE_ARRAY(art.data);
+}
+// *********************************************************************************************
+
+#define GET_FIELD_STR(id3Tag,ID3FID,ID3FN,data) \
+{ \
+	Frame=id3Tag.Find(ID3FID); \
+	if(Frame!=NULL) \
+	{ \
+	DWORD size=Frame->Field(ID3FN).Size(); \
+		FREE_ARRAY(data); \
+		if(data=(char *)malloc(size+1)) \
+			Frame->Field(ID3FN).Get(data,size+1); \
+	} \
+	else \
+		FREE_ARRAY(data); \
+}
+// -----------------------------------------------------------------------------------------------
+
+void CMP4Tag::ReadAacTag(char *Filename)
+{
+char	*buf=NULL;
+ID3_Tag id3Tag;
+ID3_Frame *Frame;
+
+	id3Tag.Link(Filename);
+
+	GET_FIELD_STR(id3Tag,ID3FID_ENCODEDBY,ID3FN_TEXT,copyright);
+
+	GET_FIELD_STR(id3Tag,ID3FID_LEADARTIST,ID3FN_TEXT,artist);
+	GET_FIELD_STR(id3Tag,ID3FID_COMPOSER,ID3FN_TEXT,writer);
+	GET_FIELD_STR(id3Tag,ID3FID_TITLE,ID3FN_TEXT,title);
+	GET_FIELD_STR(id3Tag,ID3FID_ALBUM,ID3FN_TEXT,album);
+
+	GET_FIELD_STR(id3Tag,ID3FID_TRACKNUM,ID3FN_TEXT,buf);
+	if(buf)
+		trackno=atoi(buf);
+	FREE_ARRAY(buf);
+	GET_FIELD_STR(id3Tag,ID3FID_YEAR,ID3FN_TEXT,year);
+	GET_FIELD_STR(id3Tag,ID3FID_CONTENTTYPE,ID3FN_TEXT,genre);
+	GET_FIELD_STR(id3Tag,ID3FID_COMMENT,ID3FN_TEXT,comment);
+
+	if(Frame=id3Tag.Find(ID3FID_PICTURE))
+	{
+		art.size=Frame->Field(ID3FN_DATA).Size();
+		FREE_ARRAY(art.data);
+		if(art.data=(char *)malloc(art.size))
+			memcpy(art.data,Frame->Field(ID3FN_DATA).GetBinary(),art.size);
+
+		GET_FIELD_STR(id3Tag,ID3FID_PICTURE,ID3FN_MIMETYPE,art.mimeType);
+		GET_FIELD_STR(id3Tag,ID3FID_PICTURE,ID3FN_DESCRIPTION,art.description);
+		GET_FIELD_STR(id3Tag,ID3FID_PICTURE,ID3FN_IMAGEFORMAT,art.format);
+		art.pictureType=Frame->Field(ID3FN_PICTURETYPE).Get();
+/*
+	FILE *f=fopen("D:\\prova.jpg","wb");
+		fwrite(artFile,1,artSize,f);
+		fclose(f);*/
+	}
+}
\ No newline at end of file
--- /dev/null
+++ b/plugins/winamp/CTag.h
@@ -1,0 +1,85 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2004 Antonio Foranna
+
+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.
+	
+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
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+			
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
+#ifndef _CTag_H
+#define _CTag_H
+
+// *********************************************************************************************
+
+#include <mp4.h>
+#include <id3/tag.h>	// id3 tag
+#include "CRegistry.h"
+#include "Defines.h"
+
+// *********************************************************************************************
+
+#define REG_TAGON "Tag On"
+#define REG_ARTIST "Tag Artist"
+#define REG_TITLE "Tag Title"
+#define REG_ALBUM "Tag Album"
+#define REG_YEAR "Tag Year"
+#define REG_GENRE "Tag Genre"
+#define REG_WRITER "Tag Writer"
+#define REG_COMMENT "Tag Comment"
+#define REG_TRACK "Tag Track"
+#define REG_NTRACKS "Tag Tracks"
+#define REG_DISK "Tag Disk"
+#define REG_NDISKS "Tag Disks"
+#define REG_COMPILATION "Tag Compilation"
+#define REG_ARTFILE "Tag Art file"
+
+// *********************************************************************************************
+
+typedef struct
+{
+	char	*data;
+	DWORD	size;
+	DWORD	pictureType; // front, back, icon, ...
+	char	*mimeType, // jpg, png, gif
+			*format, // ???
+			*description; // text description
+} id3Picture;
+
+class CMP4Tag
+{
+private:
+	int check_image_header(const char *buf);
+	int ReadCoverArtFile(char *pCoverArtFile, char **artBuf);
+
+public:
+	CMP4Tag();
+	virtual ~CMP4Tag() { FreeTag(); }
+
+	virtual void FreeTag();
+	virtual void WriteMP4Tag(MP4FileHandle MP4File);
+	virtual void WriteAacTag(char *Filename);
+	virtual void ReadMp4Tag(char *Filename);
+	virtual void ReadAacTag(char *Filename);
+
+	char	*copyright; // used in Cfaad
+	char	*artist, *title, *album, *year, *genre, *writer, *comment;
+	WORD	trackno,ntracks, discno,ndiscs;
+	BYTE	compilation;
+	char	*artFilename;
+	id3Picture art; // used in ReadAacTag(). Remark: field not stored into registry
+};
+
+#endif
\ No newline at end of file
--- a/plugins/winamp/Cfaac.cpp
+++ b/plugins/winamp/Cfaac.cpp
@@ -24,9 +24,96 @@
 
 
 // *********************************************************************************************
+//										CMyEncCfg
+// *********************************************************************************************
 
+void CMyEncCfg::getCfg(CMyEncCfg *cfg)
+{ 
+CRegistry reg;
 
+	if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAC"))
+	{
+		cfg->AutoCfg=reg.GetSetBool(REG_AUTO,DEF_AUTO);
+		cfg->SaveMP4=reg.GetSetBool(REG_WRITEMP4,DEF_WRITEMP4);
+		cfg->EncCfg.mpegVersion=reg.GetSetDword(REG_MPEGVER,DEF_MPEGVER); 
+		cfg->EncCfg.aacObjectType=reg.GetSetDword(REG_PROFILE,DEF_PROFILE); 
+		cfg->EncCfg.allowMidside=reg.GetSetDword(REG_MIDSIDE,DEF_MIDSIDE); 
+		cfg->EncCfg.useTns=reg.GetSetDword(REG_TNS,DEF_TNS); 
+		cfg->EncCfg.useLfe=reg.GetSetDword(REG_LFE,DEF_LFE);
+		cfg->UseQuality=reg.GetSetBool(REG_USEQUALTY,DEF_USEQUALTY);
+		cfg->EncCfg.quantqual=reg.GetSetDword(REG_QUALITY,DEF_QUALITY); 
+		cfg->EncCfg.bitRate=reg.GetSetDword(REG_BITRATE,DEF_BITRATE); 
+		cfg->EncCfg.bandWidth=reg.GetSetDword(REG_BANDWIDTH,DEF_BANDWIDTH); 
+		cfg->EncCfg.outputFormat=reg.GetSetDword(REG_HEADER,DEF_HEADER); 
 
+		cfg->OutDir=reg.GetSetStr(REG_OutFolder,"");
+
+		cfg->TagOn=reg.GetSetByte(REG_TAGON,0);
+		cfg->Tag.artist=reg.GetSetStr(REG_ARTIST,"");
+		cfg->Tag.title=reg.GetSetStr(REG_TITLE,"");
+		cfg->Tag.album=reg.GetSetStr(REG_ALBUM,"");
+		cfg->Tag.year=reg.GetSetStr(REG_YEAR,"");
+		cfg->Tag.genre=reg.GetSetStr(REG_GENRE,"");
+		cfg->Tag.writer=reg.GetSetStr(REG_WRITER,"");
+		cfg->Tag.comment=reg.GetSetStr(REG_COMMENT,"");
+		cfg->Tag.trackno=reg.GetSetWord(REG_TRACK,0);
+		cfg->Tag.ntracks=reg.GetSetWord(REG_NTRACKS,0);
+		cfg->Tag.discno=reg.GetSetWord(REG_DISK,0);
+		cfg->Tag.ndiscs=reg.GetSetWord(REG_NDISKS,0);
+		cfg->Tag.compilation=reg.GetSetByte(REG_COMPILATION,0);
+		cfg->Tag.artFilename=reg.GetSetStr(REG_ARTFILE,"");
+	}
+	else
+		MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
+}
+// -----------------------------------------------------------------------------------------------
+
+void CMyEncCfg::setCfg(CMyEncCfg *cfg)
+{ 
+CRegistry reg;
+
+	if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAC"))
+	{
+		reg.SetBool(REG_AUTO,cfg->AutoCfg); 
+		reg.SetBool(REG_WRITEMP4,cfg->SaveMP4); 
+		reg.SetDword(REG_MPEGVER,cfg->EncCfg.mpegVersion); 
+		reg.SetDword(REG_PROFILE,cfg->EncCfg.aacObjectType); 
+		reg.SetDword(REG_MIDSIDE,cfg->EncCfg.allowMidside); 
+		reg.SetDword(REG_TNS,cfg->EncCfg.useTns); 
+		reg.SetDword(REG_LFE,cfg->EncCfg.useLfe); 
+		reg.SetBool(REG_USEQUALTY,cfg->UseQuality); 
+		reg.SetDword(REG_QUALITY,cfg->EncCfg.quantqual); 
+		reg.SetDword(REG_BITRATE,cfg->EncCfg.bitRate); 
+		reg.SetDword(REG_BANDWIDTH,cfg->EncCfg.bandWidth); 
+		reg.SetDword(REG_HEADER,cfg->EncCfg.outputFormat); 
+
+		reg.SetStr(REG_OutFolder,cfg->OutDir);
+
+		reg.SetByte(REG_TAGON,cfg->TagOn);
+		reg.SetStr(REG_ARTIST,cfg->Tag.artist);
+		reg.SetStr(REG_TITLE,cfg->Tag.title);
+		reg.SetStr(REG_ALBUM,cfg->Tag.album);
+		reg.SetStr(REG_YEAR,cfg->Tag.year);
+		reg.SetStr(REG_GENRE,cfg->Tag.genre);
+		reg.SetStr(REG_WRITER,cfg->Tag.writer);
+		reg.SetStr(REG_COMMENT,cfg->Tag.comment);
+		reg.SetWord(REG_TRACK,cfg->Tag.trackno); 
+		reg.SetWord(REG_NTRACKS,cfg->Tag.ntracks); 
+		reg.SetWord(REG_DISK,cfg->Tag.discno); 
+		reg.SetWord(REG_NDISKS,cfg->Tag.ndiscs); 
+		reg.SetByte(REG_COMPILATION,cfg->Tag.compilation); 
+		reg.SetStr(REG_ARTFILE,cfg->Tag.artFilename);
+	}
+	else
+		MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
+}
+
+// *********************************************************************************************
+//											Cfaac
+// *********************************************************************************************
+
+
+
 Cfaac::Cfaac(HANDLE hOut)
 {
 	if(hOut)
@@ -70,14 +157,9 @@
 		fclose(mo->aacFile);
 		mo->aacFile=0;
 
-	MY_ENC_CFG	cfg;
-		getFaacCfg(&cfg);
-		if(cfg.Tag.On && mo->Filename)
-		{
-			WriteAacTag(mo->Filename,&cfg.Tag);
-			FREE_ARRAY(mo->Filename);
-		}
-		FreeTag(&cfg.Tag);
+	CMyEncCfg cfg(false);
+		if(cfg.TagOn && mo->Filename)
+			cfg.Tag.WriteAacTag(mo->Filename);
 	}
 	else
 	{
@@ -209,144 +291,7 @@
 			break;
 	}
 }
-// *********************************************************************************************
 
-int Cfaac::check_image_header(const char *buf)
-{
-  if (!strncmp(buf, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8))
-    return 1; /* PNG */
-  else if (!strncmp(buf, "\xFF\xD8\xFF\xE0", 4) &&
-	   !strncmp(buf + 6, "JFIF\0", 5))
-    return 1; /* JPEG */
-  else if (!strncmp(buf, "GIF87a", 6) || !strncmp(buf, "GIF89a", 6))
-    return 1; /* GIF */
-  else
-    return 0;
-}
-// -----------------------------------------------------------------------------------------------
-
-int Cfaac::ReadCoverArtFile(char *pCoverArtFile, char **artData)
-{
-FILE *artFile;
-
-	if(!pCoverArtFile || !*pCoverArtFile)
-		return 0;
-
-	if(!(artFile=fopen(pCoverArtFile, "rb")))
-	{
-		MessageBox(NULL,"ReadCoverArtFile: fopen",NULL,MB_OK);
-		return 0;
-	}
-
-int r;
-char *art;
-int	artSize=0;
-
-	fseek(artFile, 0, SEEK_END);
-	artSize=ftell(artFile);
-	fseek(artFile, 0, SEEK_SET);
-
-	if(!(art=(char *)malloc(artSize)))
-	{
-		fclose(artFile);
-		MessageBox(NULL,"ReadCoverArtFile: Memory allocation error!", NULL, MB_OK);
-		return 0;
-	}
-
-	r=fread(art, 1, artSize, artFile);
-	if(r!=artSize)
-	{
-		free(art);
-		fclose(artFile);
-		MessageBox(NULL,"ReadCoverArtFile: Error reading cover art file!", NULL, MB_OK);
-		return 0;
-	}
-	else
-		if(artSize<12 || !check_image_header(art))
-		{
-			// the above expression checks the image signature
-			free(art);
-			fclose(artFile);
-			MessageBox(NULL,"ReadCoverArtFile: Unsupported cover image file format!", NULL, MB_OK);
-			return 0;
-		}
-
-	FREE_ARRAY(*artData);
-	*artData=art;
-	fclose(artFile);
-	return artSize;
-}
-
-void Cfaac::WriteMP4Tag(MP4FileHandle MP4File, MP4TAG *Tag)
-{
-char	*art=NULL;
-DWORD	artSize;
-
-char	buf[512], *faac_id_string, *faac_copyright_string;
-	sprintf(buf, "FAAC v%s", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version");
-	MP4SetMetadataTool(MP4File, buf);
-
-	if(Tag->artist) MP4SetMetadataArtist(MP4File, Tag->artist);
-	if(Tag->writer) MP4SetMetadataWriter(MP4File, Tag->writer);
-	if(Tag->title) MP4SetMetadataName(MP4File, Tag->title);
-	if(Tag->album) MP4SetMetadataAlbum(MP4File, Tag->album);
-	if(Tag->trackno>0) MP4SetMetadataTrack(MP4File, Tag->trackno, Tag->ntracks);
-	if(Tag->discno>0) MP4SetMetadataDisk(MP4File, Tag->discno, Tag->ndiscs);
-	if(Tag->compilation) MP4SetMetadataCompilation(MP4File, Tag->compilation);
-	if(Tag->year) MP4SetMetadataYear(MP4File, Tag->year);
-	if(Tag->genre) MP4SetMetadataGenre(MP4File, Tag->genre);
-	if(Tag->comment) MP4SetMetadataComment(MP4File, Tag->comment);
-	artSize=ReadCoverArtFile(Tag->artFileName,&art);
-	if(artSize)
-	{
-		MP4SetMetadataCoverArt(MP4File, (BYTE *)art, artSize);
-		free(art);
-	}
-}
-
-#define ADD_FIELD(id3Tag,NewFrame,ID3FID,ID3FN,data) \
-{ \
-	ID3_Frame *NewFrame=new ID3_Frame(ID3FID); \
-		NewFrame->Field(ID3FN)=data; \
-		id3Tag.AttachFrame(NewFrame); \
-}
-
-void Cfaac::WriteAacTag(char *Filename, MP4TAG *Tag)
-{
-char	buf[512], *faac_id_string, *faac_copyright_string;
-char	*art=NULL;
-DWORD	artSize;
-ID3_Tag id3Tag;
-ID3_Frame *Frame;
-
-	id3Tag.Link(Filename);
-//	Frame=id3Tag.Find(ID3FID_ALBUM);
-//	if(Frame!=NULL)
-//		myTag.RemoveFrame(Frame);
-
-	sprintf(buf, "FAAC v%s", (faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version");
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_ENCODEDBY,ID3FN_TEXT,buf);
-
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_LEADARTIST,ID3FN_TEXT,Tag->artist);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_COMPOSER,ID3FN_TEXT,Tag->writer);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_TITLE,ID3FN_TEXT,Tag->title);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_ALBUM,ID3FN_TEXT,Tag->album);
-	sprintf(buf,"%d",Tag->trackno);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_TRACKNUM,ID3FN_TEXT,buf);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_YEAR,ID3FN_TEXT,Tag->year);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_CONTENTTYPE,ID3FN_TEXT,Tag->genre);
-	ADD_FIELD(id3Tag,NewFrame,ID3FID_COMMENT,ID3FN_TEXT,Tag->comment);
-	artSize=ReadCoverArtFile(Tag->artFileName,&art);
-	if(artSize)
-	{
-		ADD_FIELD(id3Tag,NewFrame,ID3FID_PICTURE,ID3FN_PICTURETYPE,Tag->artFileName);
-		id3Tag.Update();
-		free(art);
-	}
-	else
-		id3Tag.Update();
-}
-
 // *********************************************************************************************
 //									Main functions
 // *********************************************************************************************
@@ -371,102 +316,10 @@
 }
 // *********************************************************************************************
 
-void Cfaac::FreeTag(MP4TAG *Tag)
-{
-	FREE_ARRAY(Tag->artist);
-	FREE_ARRAY(Tag->title);
-	FREE_ARRAY(Tag->album);
-	FREE_ARRAY(Tag->year);
-	FREE_ARRAY(Tag->genre);
-	FREE_ARRAY(Tag->writer);
-	FREE_ARRAY(Tag->comment);
-	FREE_ARRAY(Tag->artFileName);
-}
-// -----------------------------------------------------------------------------------------------
-
-void Cfaac::getFaacCfg(MY_ENC_CFG *cfg)
-{ 
-CRegistry reg;
-
-	if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAC"))
-	{
-		cfg->AutoCfg=reg.GetSetBool(REG_AUTO,DEF_AUTO);
-		cfg->SaveMP4=reg.GetSetBool(REG_WRITEMP4,DEF_WRITEMP4);
-		cfg->EncCfg.mpegVersion=reg.GetSetDword(REG_MPEGVER,DEF_MPEGVER); 
-		cfg->EncCfg.aacObjectType=reg.GetSetDword(REG_PROFILE,DEF_PROFILE); 
-		cfg->EncCfg.allowMidside=reg.GetSetDword(REG_MIDSIDE,DEF_MIDSIDE); 
-		cfg->EncCfg.useTns=reg.GetSetDword(REG_TNS,DEF_TNS); 
-		cfg->EncCfg.useLfe=reg.GetSetDword(REG_LFE,DEF_LFE);
-		cfg->UseQuality=reg.GetSetBool(REG_USEQUALTY,DEF_USEQUALTY);
-		cfg->EncCfg.quantqual=reg.GetSetDword(REG_QUALITY,DEF_QUALITY); 
-		cfg->EncCfg.bitRate=reg.GetSetDword(REG_BITRATE,DEF_BITRATE); 
-		cfg->EncCfg.bandWidth=reg.GetSetDword(REG_BANDWIDTH,DEF_BANDWIDTH); 
-		cfg->EncCfg.outputFormat=reg.GetSetDword(REG_HEADER,DEF_HEADER); 
-		cfg->OutDir=NULL;
-
-		cfg->Tag.On=reg.GetSetByte(REG_TAGON,0);
-		cfg->Tag.artist=reg.GetSetStr(REG_ARTIST,"");
-		cfg->Tag.title=reg.GetSetStr(REG_TITLE,"");
-		cfg->Tag.album=reg.GetSetStr(REG_ALBUM,"");
-		cfg->Tag.year=reg.GetSetStr(REG_YEAR,"");
-		cfg->Tag.genre=reg.GetSetStr(REG_GENRE,"");
-		cfg->Tag.writer=reg.GetSetStr(REG_WRITER,"");
-		cfg->Tag.comment=reg.GetSetStr(REG_COMMENT,"");
-		cfg->Tag.trackno=reg.GetSetDword(REG_TRACK,0);
-		cfg->Tag.ntracks=reg.GetSetDword(REG_NTRACKS,0);
-		cfg->Tag.discno=reg.GetSetDword(REG_DISK,0);
-		cfg->Tag.ndiscs=reg.GetSetDword(REG_NDISKS,0);
-		cfg->Tag.compilation=reg.GetSetByte(REG_COMPILATION,0);
-		cfg->Tag.artFileName=reg.GetSetStr(REG_ARTFILE,"");
-	}
-	else
-		MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
-}
-// -----------------------------------------------------------------------------------------------
-
-void Cfaac::setFaacCfg(MY_ENC_CFG *cfg)
-{ 
-CRegistry reg;
-
-	if(reg.OpenCreate(HKEY_CURRENT_USER, REGISTRY_PROGRAM_NAME "\\FAAC"))
-	{
-		reg.SetBool(REG_AUTO,cfg->AutoCfg); 
-		reg.SetBool(REG_WRITEMP4,cfg->SaveMP4); 
-		reg.SetDword(REG_MPEGVER,cfg->EncCfg.mpegVersion); 
-		reg.SetDword(REG_PROFILE,cfg->EncCfg.aacObjectType); 
-		reg.SetDword(REG_MIDSIDE,cfg->EncCfg.allowMidside); 
-		reg.SetDword(REG_TNS,cfg->EncCfg.useTns); 
-		reg.SetDword(REG_LFE,cfg->EncCfg.useLfe); 
-		reg.SetBool(REG_USEQUALTY,cfg->UseQuality); 
-		reg.SetDword(REG_QUALITY,cfg->EncCfg.quantqual); 
-		reg.SetDword(REG_BITRATE,cfg->EncCfg.bitRate); 
-		reg.SetDword(REG_BANDWIDTH,cfg->EncCfg.bandWidth); 
-		reg.SetDword(REG_HEADER,cfg->EncCfg.outputFormat); 
-
-		reg.SetByte(REG_TAGON,cfg->Tag.On);
-		reg.SetStr(REG_ARTIST,cfg->Tag.artist);
-		reg.SetStr(REG_TITLE,cfg->Tag.title);
-		reg.SetStr(REG_ALBUM,cfg->Tag.album);
-		reg.SetStr(REG_YEAR,cfg->Tag.year);
-		reg.SetStr(REG_GENRE,cfg->Tag.genre);
-		reg.SetStr(REG_WRITER,cfg->Tag.writer);
-		reg.SetStr(REG_COMMENT,cfg->Tag.comment);
-		reg.SetDword(REG_TRACK,cfg->Tag.trackno); 
-		reg.SetDword(REG_NTRACKS,cfg->Tag.ntracks); 
-		reg.SetDword(REG_DISK,cfg->Tag.discno); 
-		reg.SetDword(REG_NDISKS,cfg->Tag.ndiscs); 
-		reg.SetByte(REG_COMPILATION,cfg->Tag.compilation); 
-		reg.SetStr(REG_ARTFILE,cfg->Tag.artFileName);
-	}
-	else
-		MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
-}
-// *********************************************************************************************
-
 HANDLE Cfaac::Init(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long FileSize)
 {
 MYOUTPUT	*mo;
-MY_ENC_CFG	cfg;
+CMyEncCfg	cfg(false);
 DWORD		samplesInput,
 			maxBytesOutput;
 
@@ -490,8 +343,6 @@
 	if(!(mo->buf32bit=(int32_t *)malloc(samplesInput*sizeof(int32_t))))
 		return ERROR_Init("Memory allocation error: 32 bit buffer");
 
-	getFaacCfg(&cfg);
-
 	if(cfg.SaveMP4)// || cfg.Tag.On)
 		if(!strcmpi(lpstrFilename+lstrlen(lpstrFilename)-4,".aac"))
 		{
@@ -539,16 +390,16 @@
 			CurFormat->bitRate=0;//myFormat->bitRate;
 		}
 		else
-			if(!CurFormat->bitRate)
-				CurFormat->bitRate=myFormat->bitRate;
-			else
-				CurFormat->bitRate*=1000;
+		{
+			CurFormat->bitRate=myFormat->bitRate*1000;
+			CurFormat->quantqual=100;
+		}
 
 		switch(CurFormat->bandWidth)
 		{
-		case 0:
+		case 0: // Auto
 			break;
-		case 0xffffffff:
+		case 0xffffffff: // Full
 			CurFormat->bandWidth=lSamprate/2;
 			break;
 		default:
@@ -605,8 +456,8 @@
 		mo->frameSize=samplesInput/wChannels;
 		mo->ofs=mo->frameSize;
 
-		if(cfg.Tag.On)
-			WriteMP4Tag(mo->MP4File,&cfg.Tag);
+		if(cfg.TagOn)
+			cfg.Tag.WriteMP4Tag(mo->MP4File);
 	}
 	else // Create AAC file -----------------------------------------------------------------------------
 	{
@@ -622,7 +473,6 @@
 
 	showInfo(mo);
 
-	FreeTag(&cfg.Tag);
 	GlobalUnlock(hOutput);
     return hOutput;
 }
@@ -659,7 +509,7 @@
 		if(bytesEncoded>0)
 		{
 			if((bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->aacFile))!=bytesEncoded)
-				return ERROR_processData("fwrite");
+				return ERROR_processData("Write failed!");
 			mo->WrittenSamples=1; // needed into destructor
 		}
 	}
@@ -682,7 +532,7 @@
 		if(bytesEncoded>0)
 		{
 			if(!(bytesWritten=MP4WriteSample(mo->MP4File, mo->MP4track, (unsigned __int8 *)mo->bitbuf, (DWORD)bytesEncoded, dur, mo->ofs, true) ? bytesEncoded : -1))
-				return ERROR_processData("MP4WriteSample");
+				return ERROR_processData("MP4WriteSample()");
 			mo->ofs=0;
 			mo->WrittenSamples+=dur;
 		}
--- a/plugins/winamp/Cfaac.h
+++ b/plugins/winamp/Cfaac.h
@@ -37,8 +37,8 @@
 #endif
 #include <faac.h>
 #include <win32_ver.h>	// mpeg4ip version
-#include <id3/tag.h>	// id3 tag
 #include "CRegistry.h"
+#include "CTag.h"
 #include "Defines.h"	// my defines
 
 // *********************************************************************************************
@@ -75,42 +75,33 @@
 #define REG_HEADER "Header"
 #define DEF_HEADER ADTS
 
-#define REG_TAGON "Tag On"
-#define REG_ARTIST "Tag Artist"
-#define REG_TITLE "Tag Title"
-#define REG_ALBUM "Tag Album"
-#define REG_YEAR "Tag Year"
-#define REG_GENRE "Tag Genre"
-#define REG_WRITER "Tag Writer"
-#define REG_COMMENT "Tag Comment"
-#define REG_TRACK "Tag Track"
-#define REG_NTRACKS "Tag Tracks"
-#define REG_DISK "Tag Disk"
-#define REG_NDISKS "Tag Disks"
-#define REG_COMPILATION "Tag Compilation"
-#define REG_ARTFILE "Tag Art file"
+#define REG_OutFolder "Output folder"
 
 // *********************************************************************************************
 
-typedef struct
+class CMyEncCfg
 {
-BYTE	On;
-char	*artist, *title, *album, *year, *genre, *writer, *comment;
-int		trackno,ntracks, discno,ndiscs;
-BYTE	compilation;
-char	*artFileName;
-} MP4TAG;
-// -----------------------------------------------------------------------------------------------
+private:
 
-typedef struct mec
-{
-bool					AutoCfg,
-						UseQuality,
-						SaveMP4;
-char					*OutDir;
-faacEncConfiguration	EncCfg;
-MP4TAG					Tag;
-} MY_ENC_CFG;
+	bool SaveCfgOnDestroy;
+
+public:
+
+	CMyEncCfg(bool SaveOnDestroy=true) { getCfg(this); SaveCfgOnDestroy=SaveOnDestroy; }
+	virtual ~CMyEncCfg() { if(SaveCfgOnDestroy) setCfg(this); FreeCfg(this); }
+
+	void FreeCfg(CMyEncCfg *cfg) { Tag.FreeTag(); FREE_ARRAY(OutDir); }
+	void getCfg(CMyEncCfg *cfg);
+	void setCfg(CMyEncCfg *cfg);
+
+	bool					AutoCfg,
+							UseQuality,
+							SaveMP4;
+	char					*OutDir;
+	faacEncConfiguration	EncCfg;
+	CMP4Tag					Tag;
+	BYTE					TagOn;
+};
 // -----------------------------------------------------------------------------------------------
 
 typedef struct output_tag  // any special vars associated with output file
@@ -161,18 +152,11 @@
 	virtual void showInfo(MYOUTPUT *mi) {}
 	virtual void showProgress(MYOUTPUT *mi) {}
 	void To32bit(int32_t *buf, BYTE *bufi, int size, BYTE samplebytes, BYTE bigendian);
-	int check_image_header(const char *buf);
-	int ReadCoverArtFile(char *pCoverArtFile, char **artBuf);
 
 public:
     Cfaac(HANDLE hOutput=NULL);
     virtual ~Cfaac();
 
-	static void FreeTag(MP4TAG *Tag);
-	static void getFaacCfg(MY_ENC_CFG *cfg);
-	static void setFaacCfg(MY_ENC_CFG *cfg);
-	virtual void WriteMP4Tag(MP4FileHandle MP4File, MP4TAG *Tag);
-	virtual void WriteAacTag(char *Filename, MP4TAG *Tag);
     virtual HANDLE Init(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long FileSize);
     virtual int processData(HANDLE hOutput, BYTE *bufIn, DWORD len);
 	virtual int processDataBufferized(HANDLE hOutput, BYTE *bufIn, long lBytes);
--- /dev/null
+++ b/plugins/winamp/EncDialog.cpp
@@ -1,0 +1,748 @@
+#include <windows.h>
+#include <shlobj.h>		// Browse
+#include <shellapi.h>	// ShellExecute
+#include <Commdlg.h>
+#include "resource.h"
+#include "Defines.h"	// my defines
+#include "CTag.h"
+#include "Cfaac.h"
+#include "EncDialog.h"
+
+#include <commctrl.h>
+#include <id3v2tag.h>
+//#include <id3\globals.h> // ID3LIB_RELEASE
+
+// *********************************************************************************************
+
+#ifdef IDC_BTN_BROWSE			
+extern char	config_AACoutdir[MAX_PATH];
+#endif
+
+extern HINSTANCE hInstance;
+extern HBITMAP hBmBrowse;
+
+// *********************************************************************************************
+
+/*
+DWORD PackCfg(MY_ENC_CFG *cfg)
+{
+DWORD dwOptions=0;
+
+	if(cfg->AutoCfg)
+		dwOptions=1<<31;
+	dwOptions|=(DWORD)cfg->EncCfg.mpegVersion<<30;
+	dwOptions|=(DWORD)cfg->EncCfg.aacObjectType<<28;
+	dwOptions|=(DWORD)cfg->EncCfg.allowMidside<<27;
+	dwOptions|=(DWORD)cfg->EncCfg.useTns<<26;
+	dwOptions|=(DWORD)cfg->EncCfg.useLfe<<25;
+	dwOptions|=(DWORD)cfg->EncCfg.outputFormat<<24;
+	if(cfg->UseQuality)
+		dwOptions|=(((DWORD)cfg->EncCfg.quantqual>>1)&0xff)<<16; // [2,512]
+	else
+		dwOptions|=(((DWORD)cfg->EncCfg.bitRate>>1)&0xff)<<16; // [2,512]
+	if(cfg->UseQuality)
+		dwOptions|=1<<15;
+	dwOptions|=((DWORD)cfg->EncCfg.bandWidth>>1)&&0x7fff; // [0,65536]
+
+	return dwOptions;
+}
+// -----------------------------------------------------------------------------------------------
+
+void UnpackCfg(MY_ENC_CFG *cfg, DWORD dwOptions)
+{
+	cfg->AutoCfg=dwOptions>>31;
+	cfg->EncCfg.mpegVersion=(dwOptions>>30)&1;
+	cfg->EncCfg.aacObjectType=(dwOptions>>28)&3;
+	cfg->EncCfg.allowMidside=(dwOptions>>27)&1;
+	cfg->EncCfg.useTns=(dwOptions>>26)&1;
+	cfg->EncCfg.useLfe=(dwOptions>>25)&1;
+	cfg->EncCfg.outputFormat=(dwOptions>>24)&1;
+	cfg->EncCfg.bitRate=((dwOptions>>16)&0xff)<<1;
+	cfg->UseQuality=(dwOptions>>15)&1;
+	cfg->EncCfg.bandWidth=(dwOptions&0x7fff)<<1;
+}*/
+// -----------------------------------------------------------------------------------------------
+
+#define INIT_CB(hWnd,nID,list,IdSelected) \
+{ \
+	for(int i=0; list[i]; i++) \
+		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)list[i]); \
+	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
+}
+// -----------------------------------------------------------------------------------------------
+
+#define INIT_CB_GENRES(hWnd,nID,ID3Genres,IdSelected) \
+{ \
+	for(int i=0; i<(sizeof(ID3Genres)/sizeof(ID3Genres[0])); i++) \
+		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)ID3Genres[i].name); \
+	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
+}
+// -----------------------------------------------------------------------------------------------
+
+#define DISABLE_LTP \
+{ \
+	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \
+	   IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \
+	{ \
+		CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); \
+		CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); \
+	} \
+    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \
+}
+// -----------------------------------------------------------------------------------------------
+
+//        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
+//        EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled);
+#define DISABLE_CTRLS_ENC(Enabled) \
+{ \
+	CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_RAW), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_ADTS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_ALLOWMIDSIDE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USETNS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_QUALITY), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_QUALITY), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_BITRATE), Enabled); \
+    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
+    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
+    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
+	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4)) \
+		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
+	else \
+		DISABLE_LTP \
+}
+// -----------------------------------------------------------------------------------------------
+
+#define ENABLE_TAG(Enabled) \
+{ \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTIST), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_TITLE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ALBUM), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_YEAR), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_GENRE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_WRITER), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMMENT), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_COMPILATION), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_TRACK), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTFILE), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), Enabled); \
+}
+// -----------------------------------------------------------------------------------------------
+
+#define ENABLE_AACTAGS(Enabled) \
+{ \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_COMPILATION), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \
+}
+// -----------------------------------------------------------------------------------------------
+
+#ifdef IDC_BTN_BROWSE			
+static int CALLBACK BrowseCallbackProc( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
+{
+	if (uMsg == BFFM_INITIALIZED)
+	{
+		SetWindowText(hwnd,"Select Directory");
+		SendMessage(hwnd,BFFM_SETSELECTION,(WPARAM)1,(LPARAM)config_AACoutdir);
+	}
+	return 0;
+}
+#endif
+// -----------------------------------------------------------------------------------------------
+
+BOOL DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
+{
+	switch(Message)
+	{
+	case WM_INITDIALOG:
+		{
+		char buf[512];
+		char *faac_id_string, *faac_copyright_string;
+
+		sprintf(buf,
+					APP_NAME " plugin " APP_VER " by Antonio Foranna\n\n"
+					"Libraries used:\n"
+					"\tlibfaac v%s\n"
+					"\tFAAD2 v" FAAD2_VERSION "\n"
+					"\t" PACKAGE " v" VERSION "\n"
+					"\tid3v2 \n\n" //"\t %s v %s \n\n"
+					"This code is given with FAAC package and does not contain executables.\n"
+					"This program is free software and can be distributed/modifyed under the terms of the GNU General Public License.\n"
+					"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.\n\n"
+					"Compiled on %s\n",
+				(faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version",
+//					ID3LIB_FULL_NAME, ID3LIB_RELEASE,
+					__DATE__
+					);
+			SetDlgItemText(hWndDlg, IDC_L_ABOUT, buf);
+		}
+		break;
+	case WM_COMMAND:
+		switch(LOWORD(wParam))
+		{
+		case IDOK:
+			EndDialog(hWndDlg, TRUE);
+			break;
+        case IDCANCEL:
+			// Ignore data values entered into the controls and dismiss the dialog window returning FALSE
+			EndDialog(hWndDlg, FALSE);
+			break;
+		case IDC_AUDIOCODING:
+			ShellExecute(hWndDlg, NULL, "http://www.audiocoding.com", NULL, NULL, SW_SHOW);
+			break;
+		case IDC_MPEG4IP:
+			ShellExecute(hWndDlg, NULL, "http://www.mpeg4ip.net", NULL, NULL, SW_SHOW);
+			break;
+		case IDC_ID3:
+			ShellExecute(hWndDlg, NULL, "http://id3lib.sourceforge.net", NULL, NULL, SW_SHOW);
+			break;
+		case IDC_EMAIL:
+			ShellExecute(hWndDlg, NULL, "mailto:ntnfrn_email-temp@yahoo.it", NULL, NULL, SW_SHOW);
+			break;
+		}
+		break;
+	default: 
+		return FALSE;
+	}
+
+	return TRUE;
+}
+// -----------------------------------------------------------------------------------------------
+
+// ripped from id3v2tag.c
+ID3GENRES ID3Genres[]=
+{
+    123,    "Acapella",
+    34,     "Acid",
+    74,     "Acid Jazz",
+    73,     "Acid Punk",
+    99,     "Acoustic",
+    20,     "Alternative",
+    40,     "AlternRock",
+    26,     "Ambient",
+    90,     "Avantgarde",
+    116,    "Ballad",
+    41,     "Bass",
+    85,     "Bebob",
+    96,     "Big Band",
+    89,     "Bluegrass",
+    0,      "Blues",
+    107,    "Booty Bass",
+    65,     "Cabaret",
+    88,     "Celtic",
+    104,    "Chamber Music",
+    102,    "Chanson",
+    97,     "Chorus",
+    61,     "Christian Rap",
+    1,      "Classic Rock",
+    32,     "Classical",
+    112,    "Club",
+    57,     "Comedy",
+    2,      "Country",
+    58,     "Cult",
+    3,      "Dance",
+    125,    "Dance Hall",
+    50,     "Darkwave",
+    254,    "Data",
+    22,     "Death Metal",
+    4,      "Disco",
+    55,     "Dream",
+    122,    "Drum Solo",
+    120,    "Duet",
+    98,     "Easy Listening",
+    52,     "Electronic",
+    48,     "Ethnic",
+    124,    "Euro-House",
+    25,     "Euro-Techno",
+    54,     "Eurodance",
+    84,     "Fast Fusion",
+    80,     "Folk",
+    81,     "Folk-Rock",
+    115,    "Folklore",
+    119,    "Freestyle",
+    5,      "Funk",
+    30,     "Fusion",
+    36,     "Game",
+    59,     "Gangsta",
+    38,     "Gospel",
+    49,     "Gothic",
+    91,     "Gothic Rock",
+    6,      "Grunge",
+    79,     "Hard Rock",
+    7,      "Hip-Hop",
+    35,     "House",
+    100,    "Humour",
+    19,     "Industrial",
+    33,     "Instrumental",
+    46,     "Instrumental Pop",
+    47,     "Instrumental Rock",
+    8,      "Jazz",
+    29,     "Jazz+Funk",
+    63,     "Jungle",
+    86,     "Latin",
+    71,     "Lo-Fi",
+    45,     "Meditative",
+    9,      "Metal",
+    77,     "Musical",
+    82,     "National Folk",
+    64,     "Native American",
+    10,     "New Age",
+    66,     "New Wave",
+    39,     "Noise",
+    255,    "Not Set",
+    11,     "Oldies",
+    103,    "Opera",
+    12,     "Other",
+    75,     "Polka",
+    13,     "Pop",
+    62,     "Pop/Funk",
+    53,     "Pop-Folk",
+    109,    "Porn Groove",
+    117,    "Power Ballad",
+    23,     "Pranks",
+    108,    "Primus",
+    92,     "Progressive Rock",
+    67,     "Psychadelic",
+    93,     "Psychedelic Rock",
+    43,     "Punk",
+    121,    "Punk Rock",
+    14,     "R&B",
+    15,     "Rap",
+    68,     "Rave",
+    16,     "Reggae",
+    76,     "Retro",
+    87,     "Revival",
+    118,    "Rhythmic Soul",
+    17,     "Rock",
+    78,     "Rock & Roll",
+    114,    "Samba",
+    110,    "Satire",
+    69,     "Showtunes",
+    21,     "Ska",
+    111,    "Slow Jam",
+    95,     "Slow Rock",
+    105,    "Sonata",
+    42,     "Soul",
+    37,     "Sound Clip",
+    24,     "Soundtrack",
+    56,     "Southern Rock",
+    44,     "Space",
+    101,    "Speech",
+    83,     "Swing",
+    94,     "Symphonic Rock",
+    106,    "Symphony",
+    113,    "Tango",
+    18,     "Techno",
+    51,     "Techno-Industrial",
+    60,     "Top 40",
+    70,     "Trailer",
+    31,     "Trance",
+    72,     "Tribal",
+    27,     "Trip-Hop",
+    28,     "Vocal"
+};
+
+BOOL CALLBACK DIALOGMsgProcEnc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
+{
+	switch(Message)
+	{
+	case WM_INITDIALOG:
+		{
+		char buf[50];
+		char *Quality[]={"Default","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","200","300","400","500",0};
+		char *BitRate[]={"Auto","8","18","20","24","32","40","48","56","64","96","112","128","160","192","224","256","320","384",0};
+		char *BandWidth[]={"Auto","Full","4000","8000","11025","16000","22050","24000","32000","44100","48000",0};
+		CMyEncCfg cfg(false);
+			
+			SetWindowPos(GetDlgItem(hWndDlg,IDC_CHK_TAG),GetDlgItem(hWndDlg,IDC_GRP_TAG),0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
+
+			INIT_CB(hWndDlg,IDC_CB_QUALITY,Quality,0);
+			INIT_CB(hWndDlg,IDC_CB_BITRATE,BitRate,0);
+			INIT_CB(hWndDlg,IDC_CB_BANDWIDTH,BandWidth,0);
+
+			INIT_CB_GENRES(hWndDlg,IDC_CB_GENRE,ID3Genres,0);
+
+			SendMessage(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
+#ifdef IDC_BTN_BROWSE			
+			SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
+			if(!cfg.OutDir || !*cfg.OutDir)
+			{
+				GetCurrentDirectory(MAX_PATH,config_AACoutdir);
+				FREE_ARRAY(cfg.OutDir);
+				cfg.OutDir=strdup(config_AACoutdir);
+			}
+			else
+				strcpy(config_AACoutdir,cfg.OutDir);
+			SetDlgItemText(hWndDlg, IDC_E_BROWSE, cfg.OutDir);			
+#endif
+			if(cfg.EncCfg.mpegVersion==MPEG4)
+				CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
+			else
+				CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
+			
+			switch(cfg.EncCfg.aacObjectType)
+			{
+			case MAIN:
+				CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+				break;
+			case LOW:
+				CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
+				break;
+			case SSR:
+				CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
+				break;
+			case LTP:
+				CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
+				DISABLE_LTP
+				break;
+			}
+			
+			switch(cfg.EncCfg.outputFormat)
+			{
+			case RAW:
+				CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);
+				break;
+			case ADTS:
+				CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
+				break;
+			}
+			
+			CheckDlgButton(hWndDlg, IDC_CHK_ALLOWMIDSIDE, cfg.EncCfg.allowMidside);
+			CheckDlgButton(hWndDlg, IDC_CHK_USETNS, cfg.EncCfg.useTns);
+			CheckDlgButton(hWndDlg, IDC_CHK_USELFE, cfg.EncCfg.useLfe);
+
+			if(cfg.UseQuality)
+				CheckDlgButton(hWndDlg,IDC_RADIO_QUALITY,TRUE);
+			else
+				CheckDlgButton(hWndDlg,IDC_RADIO_BITRATE,TRUE);
+
+			switch(cfg.EncCfg.quantqual)
+			{
+			case 100:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_QUALITY), CB_SETCURSEL, 0, 0);
+				break;
+			default:
+				if(cfg.EncCfg.quantqual<10)
+					cfg.EncCfg.quantqual=10;
+				if(cfg.EncCfg.quantqual>500)
+					cfg.EncCfg.quantqual=500;
+				sprintf(buf,"%lu",cfg.EncCfg.quantqual);
+				SetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf);
+				break;
+			}
+			switch(cfg.EncCfg.bitRate)
+			{
+			case 0:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 0, 0);
+				break;
+			default:
+				sprintf(buf,"%lu",cfg.EncCfg.bitRate);
+				SetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf);
+				break;
+			}
+			switch(cfg.EncCfg.bandWidth)
+			{
+			case 0:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0);
+				break;
+			case 0xffffffff:
+				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 1, 0);
+				break;
+			default:
+				sprintf(buf,"%lu",cfg.EncCfg.bandWidth);
+				SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf);
+				break;
+			}
+			
+			CheckDlgButton(hWndDlg, IDC_CHK_WRITEMP4, cfg.SaveMP4);
+
+			CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, cfg.AutoCfg);
+			DISABLE_CTRLS_ENC(!cfg.AutoCfg);
+
+			CheckDlgButton(hWndDlg,IDC_CHK_TAG, cfg.TagOn);
+			ENABLE_TAG(cfg.TagOn);
+			ENABLE_AACTAGS(cfg.SaveMP4);
+			SetDlgItemText(hWndDlg, IDC_E_ARTIST, cfg.Tag.artist);
+			SetDlgItemText(hWndDlg, IDC_E_TITLE, cfg.Tag.title);
+			SetDlgItemText(hWndDlg, IDC_E_ALBUM, cfg.Tag.album);
+			SetDlgItemText(hWndDlg, IDC_E_YEAR, cfg.Tag.year);
+			SetDlgItemText(hWndDlg, IDC_CB_GENRE, cfg.Tag.genre);
+			SetDlgItemText(hWndDlg, IDC_E_WRITER, cfg.Tag.writer);
+			SetDlgItemText(hWndDlg, IDC_E_COMMENT, cfg.Tag.comment);
+			SetDlgItemText(hWndDlg, IDC_E_ARTFILE, cfg.Tag.artFilename);
+			SetDlgItemInt(hWndDlg, IDC_E_TRACK, cfg.Tag.trackno, FALSE);
+			SetDlgItemInt(hWndDlg, IDC_E_NTRACKS, cfg.Tag.ntracks, FALSE);
+			SetDlgItemInt(hWndDlg, IDC_E_DISK, cfg.Tag.discno, FALSE);
+			SetDlgItemInt(hWndDlg, IDC_E_NDISKS, cfg.Tag.ndiscs, FALSE);
+			SetDlgItemInt(hWndDlg, IDC_E_COMPILATION, cfg.Tag.compilation, FALSE);
+			CheckDlgButton(hWndDlg, IDC_CHK_COMPILATION, cfg.Tag.compilation);
+		}
+		break; // End of WM_INITDIALOG                                 
+		
+	case WM_CLOSE:
+		// Closing the Dialog behaves the same as Cancel               
+		PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
+		break; // End of WM_CLOSE                                      
+		
+	case WM_COMMAND:
+		switch(LOWORD(wParam))
+		{
+		case IDOK:
+			{
+//			HANDLE hCfg=(HANDLE)lParam;
+			char buf[50];
+			CMyEncCfg cfg;
+
+				cfg.AutoCfg=IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG) ? TRUE : FALSE;
+				cfg.EncCfg.mpegVersion=IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4) ? MPEG4 : MPEG2;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
+					cfg.EncCfg.aacObjectType=MAIN;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
+					cfg.EncCfg.aacObjectType=LOW;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
+					cfg.EncCfg.aacObjectType=SSR;
+				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
+					cfg.EncCfg.aacObjectType=LTP;
+				cfg.EncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_CHK_ALLOWMIDSIDE);
+				cfg.EncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_CHK_USETNS);
+				cfg.EncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_CHK_USELFE);
+				
+				GetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf, 50);
+				switch(*buf)
+				{
+				case 'A': // Auto
+					cfg.EncCfg.bitRate=0;
+					break;
+				default:
+					cfg.EncCfg.bitRate=GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
+				}
+				GetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf, 50);
+				switch(*buf)
+				{
+				case 'A': // Auto
+					cfg.EncCfg.bandWidth=0;
+					break;
+				case 'F': // Full
+					cfg.EncCfg.bandWidth=0xffffffff;
+					break;
+				default:
+					cfg.EncCfg.bandWidth=GetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, 0, FALSE);
+				}
+				cfg.UseQuality=IsDlgButtonChecked(hWndDlg,IDC_RADIO_QUALITY) ? TRUE : FALSE;
+				GetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf, 50);
+				switch(*buf)
+				{
+				case 'D': // Default
+					cfg.EncCfg.quantqual=100;
+					break;
+				default:
+					cfg.EncCfg.quantqual=GetDlgItemInt(hWndDlg, IDC_CB_QUALITY, 0, FALSE);
+				}
+				cfg.EncCfg.outputFormat=IsDlgButtonChecked(hWndDlg,IDC_RADIO_RAW) ? RAW : ADTS;
+#ifdef IDC_E_BROWSE
+				GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir, MAX_PATH);
+				FREE_ARRAY(cfg.OutDir);
+				cfg.OutDir=strdup(config_AACoutdir);
+#endif
+				cfg.SaveMP4=IsDlgButtonChecked(hWndDlg, IDC_CHK_WRITEMP4) ? TRUE : FALSE;
+
+				cfg.TagOn=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG) ? 1 : 0;
+			char buffer[MAX_PATH];
+				GetDlgItemText(hWndDlg, IDC_E_ARTIST, buffer, MAX_PATH);
+				cfg.Tag.artist=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_TITLE, buffer, MAX_PATH);
+				cfg.Tag.title=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_ALBUM, buffer, MAX_PATH);
+				cfg.Tag.album=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_YEAR, buffer, MAX_PATH);
+				cfg.Tag.year=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_CB_GENRE, buffer, MAX_PATH);
+				cfg.Tag.genre=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_WRITER, buffer, MAX_PATH);
+				cfg.Tag.writer=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_COMMENT, buffer, MAX_PATH);
+				cfg.Tag.comment=strdup(buffer);
+				GetDlgItemText(hWndDlg, IDC_E_ARTFILE, buffer, MAX_PATH);
+				cfg.Tag.artFilename=strdup(buffer);
+				cfg.Tag.trackno=GetDlgItemInt(hWndDlg, IDC_E_TRACK, 0, FALSE);
+				cfg.Tag.ntracks=GetDlgItemInt(hWndDlg, IDC_E_NTRACKS, 0, FALSE);
+				cfg.Tag.discno=GetDlgItemInt(hWndDlg, IDC_E_DISK, 0, FALSE);
+				cfg.Tag.ndiscs=GetDlgItemInt(hWndDlg, IDC_E_NDISKS, 0, FALSE);
+				cfg.Tag.compilation=(BYTE)GetDlgItemInt(hWndDlg, IDC_E_COMPILATION, 0, FALSE);
+				cfg.Tag.compilation=IsDlgButtonChecked(hWndDlg, IDC_CHK_COMPILATION) ? 1 : 0;
+
+				EndDialog(hWndDlg, TRUE);//(DWORD)hCfg);
+			}
+			break;
+			
+        case IDCANCEL:
+			// Ignore data values entered into the controls        
+			// and dismiss the dialog window returning FALSE
+			EndDialog(hWndDlg, FALSE);
+			break;
+
+		case IDC_BTN_ABOUT:
+			DialogBox((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_ABOUT), (HWND)hWndDlg, (DLGPROC)DialogMsgProcAbout);
+			break;
+
+		case IDC_BTN_LICENSE:
+			{
+			char *license =
+				"\nPlease note that the use of this software may require the payment of patent royalties.\n"
+				"You need to consider this issue before you start building derivative works.\n"
+				"We are not warranting or indemnifying you in any way for patent royalities!\n"
+				"YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN ACTIONS!\n"
+				"\n"
+				"FAAC is based on the ISO MPEG-4 reference code. For this code base the\n"
+				"following license applies:\n"
+				"\n"
+/*				"This software module was originally developed by\n"
+				"\n"
+				"FirstName LastName (CompanyName)\n"
+				"\n"
+				"and edited by\n"
+				"\n"
+				"FirstName LastName (CompanyName)\n"
+				"FirstName LastName (CompanyName)\n"
+				"\n"
+*/				"in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard\n"
+				"ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an\n"
+				"implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools\n"
+				"as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives\n"
+				"users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this\n"
+				"software module or modifications thereof for use in hardware or\n"
+				"software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio\n"
+				"standards. Those intending to use this software module in hardware or\n"
+				"software products are advised that this use may infringe existing\n"
+				"patents. The original developer of this software module and his/her\n"
+				"company, the subsequent editors and their companies, and ISO/IEC have\n"
+				"no liability for use of this software module or modifications thereof\n"
+				"in an implementation. Copyright is not released for non MPEG-2\n"
+				"NBC/MPEG-4 Audio conforming products. The original developer retains\n"
+				"full right to use the code for his/her own purpose, assign or donate\n"
+				"the code to a third party and to inhibit third party from using the\n"
+				"code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This\n"
+				"copyright notice must be included in all copies or derivative works.\n"
+				"\n"
+				"Copyright (c) 1997.\n"
+				"\n"
+				"For the changes made for the FAAC project the GNU Lesser General Public\n"
+				"License (LGPL), version 2 1991 applies:\n"
+				"\n"
+				"FAAC - Freeware Advanced Audio Coder\n"
+				"Copyright (C) 2001-2004 The individual contributors\n"
+				"\n"
+				"This library is free software; you can redistribute it and/or modify it under the terms of\n"
+				"the GNU Lesser General Public License as published by the Free Software Foundation;\n"
+				"either version 2.1 of the License, or (at your option) any later version.\n"
+				"\n"
+				"This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n"
+				"without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
+				"See the GNU Lesser General Public License for more details.\n"
+				"\n"
+				"You should have received a copy of the GNU Lesser General Public\n"
+				"License along with this library; if not, write to the Free Software\n"
+				"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n";
+
+				MessageBox(hWndDlg,license,"FAAC libray License",MB_OK|MB_ICONINFORMATION);
+			}
+			break;
+
+#ifdef IDC_BTN_BROWSE
+		case IDC_BTN_BROWSE:
+			{
+			char name[MAX_PATH];
+			BROWSEINFO bi;
+			ITEMIDLIST *idlist;
+				bi.hwndOwner = hWndDlg;
+				bi.pidlRoot = 0;
+				bi.pszDisplayName = name;
+				bi.lpszTitle = "Select a directory for AAC-MPEG4 file output:";
+				bi.ulFlags = BIF_RETURNONLYFSDIRS;
+				bi.lpfn = BrowseCallbackProc;
+				bi.lParam = 0;
+				
+				GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir, MAX_PATH);
+				idlist = SHBrowseForFolder( &bi );
+				if(idlist)
+				{
+					SHGetPathFromIDList( idlist, config_AACoutdir);
+					SetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir);
+				}
+			}
+			break;
+#endif			
+		case IDC_BTN_ARTFILE:
+			{
+			OPENFILENAME ofn;
+			char ArtFilename[MAX_PATH]="";
+
+//				GetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename, MAX_PATH);
+
+				ofn.lStructSize			= sizeof(OPENFILENAME);
+				ofn.hwndOwner			= (HWND)hWndDlg;
+				ofn.lpstrFilter			= "Cover art files (*.gif,*jpg,*.png)\0*.gif;*.jpg;*.png\0";
+				ofn.lpstrCustomFilter	= NULL;
+				ofn.nFilterIndex		= 1;
+				ofn.lpstrFile			= ArtFilename;
+				ofn.nMaxFile			= MAX_PATH; //sizeof ArtFilename;
+				ofn.lpstrFileTitle		= NULL;
+				ofn.nMaxFileTitle		= 0;
+				ofn.lpstrInitialDir		= NULL;
+				ofn.lpstrTitle			= "Select cover art file";
+				ofn.Flags				= OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING;
+				ofn.lpstrDefExt			= NULL;//"jpg";
+				ofn.hInstance			= hInstance;
+
+				if(GetOpenFileName(&ofn))
+					SetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename);
+			}
+			break;
+
+		case IDC_RADIO_MPEG4:
+			EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
+			break;
+			
+		case IDC_RADIO_MPEG2:
+			EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
+			DISABLE_LTP
+			break;
+
+		case IDC_CHK_AUTOCFG:
+			{
+			char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG);
+				DISABLE_CTRLS_ENC(Enabled);
+			}
+			break;
+
+		case IDC_CHK_TAG:
+			{
+			char Enabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG);
+				ENABLE_TAG(Enabled);
+			}
+//			break;
+		case IDC_CHK_WRITEMP4:
+			{
+			char Enabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_WRITEMP4) && IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG);
+				ENABLE_AACTAGS(Enabled);
+			}
+			break;
+		}
+		break; // End of WM_COMMAND
+	default: 
+		return FALSE;
+	}
+	
+	return TRUE;
+} // End of DIALOGSMsgProc                                      
--- /dev/null
+++ b/plugins/winamp/EncDialog.h
@@ -1,0 +1,2 @@
+extern BOOL DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam);
+extern BOOL CALLBACK DIALOGMsgProcEnc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam);
--- a/plugins/winamp/FAAC.rc
+++ b/plugins/winamp/FAAC.rc
@@ -59,7 +59,7 @@
     CONTROL         "Bitrate per channel",IDC_RADIO_BITRATE,"Button",
                     BS_AUTORADIOBUTTON,9,105,75,10
     COMBOBOX        IDC_CB_QUALITY,102,86,48,97,CBS_DROPDOWN | WS_VSCROLL | 
-                    WS_TABSTOP
+                    WS_GROUP | WS_TABSTOP
     COMBOBOX        IDC_CB_BITRATE,102,102,48,86,CBS_DROPDOWN | WS_VSCROLL | 
                     WS_TABSTOP
     LTEXT           "Bandwidth",IDC_STATIC,21,126,34,8
@@ -78,16 +78,21 @@
     PUSHBUTTON      "Browse",IDC_BTN_BROWSE,137,167,18,14,BS_BITMAP | 
                     BS_FLAT
     GROUPBOX        "",IDC_GRP_TAG,160,4,174,200
-    CONTROL         "Tag (write .mp4)",IDC_CHK_TAG,"Button",BS_AUTOCHECKBOX | 
-                    WS_TABSTOP,165,3,67,10
+    CONTROL         "Tag",IDC_CHK_TAG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
+                    165,3,29,10
     EDITTEXT        IDC_E_ARTIST,207,20,121,14,ES_AUTOHSCROLL
     EDITTEXT        IDC_E_TITLE,207,35,121,14,ES_AUTOHSCROLL
     EDITTEXT        IDC_E_ALBUM,207,50,121,14,ES_AUTOHSCROLL
     EDITTEXT        IDC_E_YEAR,207,65,121,14,ES_AUTOHSCROLL
+    COMBOBOX        IDC_CB_GENRE,207,80,121,161,CBS_DROPDOWN | WS_VSCROLL | 
+                    WS_TABSTOP
     EDITTEXT        IDC_E_WRITER,207,94,121,14,ES_AUTOHSCROLL
     EDITTEXT        IDC_E_COMMENT,207,109,121,29,ES_MULTILINE | 
                     ES_AUTOHSCROLL
-    EDITTEXT        IDC_E_COMPILATION,207,139,121,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_E_COMPILATION,207,139,121,14,ES_AUTOHSCROLL | NOT 
+                    WS_VISIBLE
+    CONTROL         "Part of a compilation",IDC_CHK_COMPILATION,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,165,141,80,10
     EDITTEXT        IDC_E_TRACK,233,155,40,14,ES_AUTOHSCROLL
     EDITTEXT        IDC_E_NTRACKS,288,155,40,14,ES_AUTOHSCROLL
     EDITTEXT        IDC_E_DISK,233,170,40,14,ES_AUTOHSCROLL
@@ -103,18 +108,15 @@
     LTEXT           "Album",IDC_STATIC,165,52,20,8
     LTEXT           "Year",IDC_STATIC,165,67,16,8
     LTEXT           "Genre",IDC_STATIC,165,82,20,8
-    LTEXT           "Writer",IDC_STATIC,165,97,20,8
-    LTEXT           "Comment\n(ctrl-Enter\nto go down)",IDC_STATIC,165,113,
+    LTEXT           "Writer",IDC_STATIC,165,96,20,8
+    LTEXT           "Comment\n(ctrl-Enter\nto go down)",IDC_STATIC,165,111,
                     37,26
     LTEXT           "Track",IDC_STATIC,165,159,20,8
     LTEXT           "/",IDC_STATIC,277,159,8,8
     LTEXT           "Disk",IDC_STATIC,165,173,15,8
     LTEXT           "/",IDC_STATIC,277,173,8,8
-    LTEXT           "Compilation",IDC_STATIC,165,143,37,8
     LTEXT           "Cover art file",IDC_STATIC,165,188,40,8
     LTEXT           "Output folder",IDC_STATIC,4,169,42,8
-    COMBOBOX        IDC_CB_GENRE,207,80,121,161,CBS_DROPDOWN | WS_VSCROLL | 
-                    WS_TABSTOP
 END
 
 IDD_DECODER DIALOG  0, 0, 141, 105
@@ -219,19 +221,20 @@
 // Dialog
 //
 
-IDD_ABOUT DIALOG  0, 0, 191, 230
+IDD_ABOUT DIALOGEX 0, 0, 191, 230
 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION
 CAPTION "About"
-FONT 8, "MS Sans Serif"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
-    DEFPUSHBUTTON   "&OK",IDOK,134,208,50,14
+    DEFPUSHBUTTON   "&OK",IDOK,142,208,42,14
     CONTROL         104,IDC_AUDIOCODING,"Static",SS_BITMAP | SS_NOTIFY | 
                     SS_SUNKEN,7,7,178,69
     CONTROL         107,IDC_MPEG4IP,"Static",SS_BITMAP | SS_NOTIFY | 
-                    SS_SUNKEN,7,203,59,19
-    CONTROL         106,IDC_EMAIL,"Static",SS_BITMAP | SS_NOTIFY,77,204,43,
+                    SS_SUNKEN,7,202,59,20
+    CONTROL         106,IDC_EMAIL,"Static",SS_BITMAP | SS_NOTIFY,94,204,43,
                     18
     LTEXT           "Text",IDC_L_ABOUT,7,55,177,142
+    ICON            IDI_ID3,IDC_ID3,70,202,20,20,SS_NOTIFY | SS_SUNKEN
 END
 
 
@@ -263,6 +266,53 @@
 IDB_EMAIL               BITMAP                  "Email.bmp"
 IDB_MPEG4IP             BITMAP                  "mpeg4ip-v.bmp"
 IDB_BROWSE              BITMAP                  "Open.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ID3                 ICON                    "id3v2.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,5,0,0
+ PRODUCTVERSION 1,5,0,0
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "041004b0"
+        BEGIN
+            VALUE "FileDescription", "Winamp FAAC"
+            VALUE "FileVersion", "1, 5, 0, 0"
+            VALUE "InternalName", "Out_FAAC"
+            VALUE "LegalCopyright", "Copyright (C) 2004"
+            VALUE "OriginalFilename", "Out_FAAC.dll"
+            VALUE "ProductName", " Out_FAAC Dynamic Link Library"
+            VALUE "ProductVersion", "1, 5, 0, 0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x410, 1200
+    END
+END
+
 #endif    // Italian (Italy) resources
 /////////////////////////////////////////////////////////////////////////////
 
--- a/plugins/winamp/Out_faac.cpp
+++ b/plugins/winamp/Out_faac.cpp
@@ -20,24 +20,14 @@
 */
 
 #include <windows.h>
-#include <shlobj.h>
-#include <stdio.h>		// FILE *
-#include <shellapi.h>	// ShellExecute
-#include <Commdlg.h>
 #include "resource.h"
 #include "out.h"
-/*#include <mp4.h>
-#include <faac.h>
-#include "CRegistry.h"
 #include "defines.h"
-*/
-#include "defines.h"
+#include "EncDialog.h"
 #include "Cfaac.h"
 
-#include <commctrl.h>
-//#include <id3.h>
-#include <id3v2tag.h>
 
+// *********************************************************************************************
 
 
 void Config(HWND);
@@ -59,10 +49,10 @@
 
 
 Cfaac			*Cpcmaac;
-char			OutDir[MAX_PATH]="";
+//char			OutDir[MAX_PATH]="";
 
 HINSTANCE		hInstance=NULL;
-static			HBITMAP hBmBrowse=NULL;
+HBITMAP			hBmBrowse=NULL;
 char			config_AACoutdir[MAX_PATH]="";
 
 static int		srate, numchan, bps;
@@ -174,66 +164,10 @@
 }
 
 // *********************************************************************************************
-//										Interface
-// *********************************************************************************************
 
-static BOOL CALLBACK DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
-{
-	switch(Message)
-	{
-	case WM_INITDIALOG:
-		{
-		char buf[512];
-		char *faac_id_string, *faac_copyright_string;
-
-		sprintf(buf,
-					APP_NAME " plugin " APP_VER " by Antonio Foranna\n\n"
-					"Engines used:\n"
-					"\tlibfaac v%s\n"
-					"\tFAAD2 v" FAAD2_VERSION "\n"
-					"\t" PACKAGE " v" VERSION "\n\n"
-					"This code is given with FAAC package and does not contain executables.\n"
-					"This program is free software and can be distributed/modifyed under the terms of the GNU General Public License.\n"
-					"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.\n\n"
-					"Compiled on %s\n",
-				(faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version",
-					__DATE__
-					);
-			SetDlgItemText(hWndDlg, IDC_L_ABOUT, buf);
-		}
-		break;
-	case WM_COMMAND:
-		switch(LOWORD(wParam))
-		{
-		case IDOK:
-			EndDialog(hWndDlg, TRUE);
-			break;
-        case IDCANCEL:
-			// Ignore data values entered into the controls and dismiss the dialog window returning FALSE
-			EndDialog(hWndDlg, FALSE);
-			break;
-		case IDC_AUDIOCODING:
-			ShellExecute(hWndDlg, NULL, "http://www.audiocoding.com", NULL, NULL, SW_SHOW);
-			break;
-		case IDC_MPEG4IP:
-			ShellExecute(hWndDlg, NULL, "http://www.mpeg4ip.net", NULL, NULL, SW_SHOW);
-			break;
-		case IDC_EMAIL:
-			ShellExecute(hWndDlg, NULL, "mailto:ntnfrn_email-temp@yahoo.it", NULL, NULL, SW_SHOW);
-			break;
-		}
-		break;
-	default: 
-		return FALSE;
-	}
-
-	return TRUE;
-}
-// -----------------------------------------------------------------------------------------------
-
 void About(HWND hWndDlg)
 {
-	DialogBox(out.hDllInstance, MAKEINTRESOURCE(IDD_ABOUT), hWndDlg, DialogMsgProcAbout);
+	DialogBox(out.hDllInstance, MAKEINTRESOURCE(IDD_ABOUT), hWndDlg, (DLGPROC)DialogMsgProcAbout);
 
 /*char buf[256];
   unsigned long samplesInput, maxBytesOutput;
@@ -255,650 +189,9 @@
 }
 // *********************************************************************************************
 
-static int CALLBACK BrowseCallbackProc( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
-{
-	if (uMsg == BFFM_INITIALIZED)
-	{
-		SetWindowText(hwnd,"Select Directory");
-		SendMessage(hwnd,BFFM_SETSELECTION,(WPARAM)1,(LPARAM)config_AACoutdir);
-	}
-	return 0;
-}
-// -----------------------------------------------------------------------------------------------
-
-void ReadCfgEnc()
-{ 
-CRegistry reg;
-
-	if(reg.OpenCreate(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME))
-	{
-	char *tmp=reg.GetSetStr("OutDir","");
-		memcpy(OutDir,tmp,strlen(tmp));
-		free(tmp);
-	}
-	else
-		MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
-}
-// -----------------------------------------------------------------------------------------------
-
-void WriteCfgEnc()
-{ 
-CRegistry reg;
-
-	if(reg.OpenCreate(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME))
-		reg.SetStr("OutDir",OutDir); 
-	else
-		MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
-}
-// -----------------------------------------------------------------------------------------------
-
-#define INIT_CB(hWnd,nID,list,IdSelected) \
-{ \
-	for(int i=0; list[i]; i++) \
-		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)list[i]); \
-	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
-}
-// -----------------------------------------------------------------------------------------------
-
-#define INIT_CB_GENRES(hWnd,nID,ID3Genres,IdSelected) \
-{ \
-	for(int i=0; i<(sizeof(ID3Genres)/sizeof(ID3Genres[0])); i++) \
-		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)ID3Genres[i].name); \
-	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \
-}
-// -----------------------------------------------------------------------------------------------
-
-#define DISABLE_LTP \
-{ \
-	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \
-	   IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \
-	{ \
-		CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); \
-		CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); \
-	} \
-    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \
-}
-// -----------------------------------------------------------------------------------------------
-
-#define DISABLE_CTRL(Enabled) \
-{ \
-	CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_RAW), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_ADTS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_ALLOWMIDSIDE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USETNS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_QUALITY), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_QUALITY), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_BITRATE), Enabled); \
-    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
-    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
-    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
-	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4)) \
-		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
-	else \
-		DISABLE_LTP \
-}
-// -----------------------------------------------------------------------------------------------
-
-#define ENABLE_TAG(Enabled) \
-{ \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTIST), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_TITLE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ALBUM), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_YEAR), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_GENRE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_WRITER), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMMENT), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_TRACK), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTFILE), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), Enabled); \
-}
-// -----------------------------------------------------------------------------------------------
-
-#define ENABLE_AACTAGS(Enabled) \
-{ \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \
-	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \
-}
-// -----------------------------------------------------------------------------------------------
-
-// ripped from id3v2tag.c
-ID3GENRES ID3Genres[]=
-{
-    123,    "Acapella",
-    34,     "Acid",
-    74,     "Acid Jazz",
-    73,     "Acid Punk",
-    99,     "Acoustic",
-    20,     "Alternative",
-    40,     "AlternRock",
-    26,     "Ambient",
-    90,     "Avantgarde",
-    116,    "Ballad",
-    41,     "Bass",
-    85,     "Bebob",
-    96,     "Big Band",
-    89,     "Bluegrass",
-    0,      "Blues",
-    107,    "Booty Bass",
-    65,     "Cabaret",
-    88,     "Celtic",
-    104,    "Chamber Music",
-    102,    "Chanson",
-    97,     "Chorus",
-    61,     "Christian Rap",
-    1,      "Classic Rock",
-    32,     "Classical",
-    112,    "Club",
-    57,     "Comedy",
-    2,      "Country",
-    58,     "Cult",
-    3,      "Dance",
-    125,    "Dance Hall",
-    50,     "Darkwave",
-    254,    "Data",
-    22,     "Death Metal",
-    4,      "Disco",
-    55,     "Dream",
-    122,    "Drum Solo",
-    120,    "Duet",
-    98,     "Easy Listening",
-    52,     "Electronic",
-    48,     "Ethnic",
-    124,    "Euro-House",
-    25,     "Euro-Techno",
-    54,     "Eurodance",
-    84,     "Fast Fusion",
-    80,     "Folk",
-    81,     "Folk-Rock",
-    115,    "Folklore",
-    119,    "Freestyle",
-    5,      "Funk",
-    30,     "Fusion",
-    36,     "Game",
-    59,     "Gangsta",
-    38,     "Gospel",
-    49,     "Gothic",
-    91,     "Gothic Rock",
-    6,      "Grunge",
-    79,     "Hard Rock",
-    7,      "Hip-Hop",
-    35,     "House",
-    100,    "Humour",
-    19,     "Industrial",
-    33,     "Instrumental",
-    46,     "Instrumental Pop",
-    47,     "Instrumental Rock",
-    8,      "Jazz",
-    29,     "Jazz+Funk",
-    63,     "Jungle",
-    86,     "Latin",
-    71,     "Lo-Fi",
-    45,     "Meditative",
-    9,      "Metal",
-    77,     "Musical",
-    82,     "National Folk",
-    64,     "Native American",
-    10,     "New Age",
-    66,     "New Wave",
-    39,     "Noise",
-    255,    "Not Set",
-    11,     "Oldies",
-    103,    "Opera",
-    12,     "Other",
-    75,     "Polka",
-    13,     "Pop",
-    62,     "Pop/Funk",
-    53,     "Pop-Folk",
-    109,    "Porn Groove",
-    117,    "Power Ballad",
-    23,     "Pranks",
-    108,    "Primus",
-    92,     "Progressive Rock",
-    67,     "Psychadelic",
-    93,     "Psychedelic Rock",
-    43,     "Punk",
-    121,    "Punk Rock",
-    14,     "R&B",
-    15,     "Rap",
-    68,     "Rave",
-    16,     "Reggae",
-    76,     "Retro",
-    87,     "Revival",
-    118,    "Rhythmic Soul",
-    17,     "Rock",
-    78,     "Rock & Roll",
-    114,    "Samba",
-    110,    "Satire",
-    69,     "Showtunes",
-    21,     "Ska",
-    111,    "Slow Jam",
-    95,     "Slow Rock",
-    105,    "Sonata",
-    42,     "Soul",
-    37,     "Sound Clip",
-    24,     "Soundtrack",
-    56,     "Southern Rock",
-    44,     "Space",
-    101,    "Speech",
-    83,     "Swing",
-    94,     "Symphonic Rock",
-    106,    "Symphony",
-    113,    "Tango",
-    18,     "Techno",
-    51,     "Techno-Industrial",
-    60,     "Top 40",
-    70,     "Trailer",
-    31,     "Trance",
-    72,     "Tribal",
-    27,     "Trip-Hop",
-    28,     "Vocal"
-};
-
-static BOOL CALLBACK DIALOGMsgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
-{
-	switch(Message)
-	{
-	case WM_INITDIALOG:
-		{
-		char buf[50];
-		char *Quality[]={"Default","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","200","300","400","500",0};
-		char *BitRate[]={"Auto","8","18","20","24","32","40","48","56","64","96","112","128","160","192","224","256","320","384",0};
-		char *BandWidth[]={"Auto","Full","4000","8000","11025","16000","22050","24000","32000","44100","48000",0};
-		MY_ENC_CFG cfg;
-			
-			SetWindowPos(GetDlgItem(hWndDlg,IDC_CHK_TAG),GetDlgItem(hWndDlg,IDC_GRP_TAG),0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
-
-			ReadCfgEnc();
-			Cfaac::getFaacCfg(&cfg);
-			
-			INIT_CB(hWndDlg,IDC_CB_QUALITY,Quality,0);
-			INIT_CB(hWndDlg,IDC_CB_BITRATE,BitRate,0);
-			INIT_CB(hWndDlg,IDC_CB_BANDWIDTH,BandWidth,0);
-
-			INIT_CB_GENRES(hWndDlg,IDC_CB_GENRE,ID3Genres,0);
-			
-			SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
-			SendMessage(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
-			if(!*OutDir)
-				GetCurrentDirectory(MAX_PATH,OutDir);
-			SetDlgItemText(hWndDlg, IDC_E_BROWSE, OutDir);
-			
-			if(cfg.EncCfg.mpegVersion==MPEG4)
-				CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-			else
-				CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
-			
-			switch(cfg.EncCfg.aacObjectType)
-			{
-			case MAIN:
-				CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-				break;
-			case LOW:
-				CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
-				break;
-			case SSR:
-				CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
-				break;
-			case LTP:
-				CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
-				DISABLE_LTP
-				break;
-			}
-			
-			switch(cfg.EncCfg.outputFormat)
-			{
-			case RAW:
-				CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);
-				break;
-			case ADTS:
-				CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
-				break;
-			}
-			
-			CheckDlgButton(hWndDlg, IDC_CHK_ALLOWMIDSIDE, cfg.EncCfg.allowMidside);
-			CheckDlgButton(hWndDlg, IDC_CHK_USETNS, cfg.EncCfg.useTns);
-			CheckDlgButton(hWndDlg, IDC_CHK_USELFE, cfg.EncCfg.useLfe);
-
-			if(cfg.UseQuality)
-				CheckDlgButton(hWndDlg,IDC_RADIO_QUALITY,TRUE);
-			else
-				CheckDlgButton(hWndDlg,IDC_RADIO_BITRATE,TRUE);
-
-			switch(cfg.EncCfg.quantqual)
-			{
-			case 100:
-				SendMessage(GetDlgItem(hWndDlg, IDC_CB_QUALITY), CB_SETCURSEL, 0, 0);
-				break;
-			default:
-				if(cfg.EncCfg.quantqual<10)
-					cfg.EncCfg.quantqual=10;
-				if(cfg.EncCfg.quantqual>500)
-					cfg.EncCfg.quantqual=500;
-				sprintf(buf,"%lu",cfg.EncCfg.quantqual);
-				SetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf);
-				break;
-			}
-			switch(cfg.EncCfg.bitRate)
-			{
-			case 0:
-				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 0, 0);
-				break;
-			default:
-				sprintf(buf,"%lu",cfg.EncCfg.bitRate);
-				SetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf);
-				break;
-			}
-			switch(cfg.EncCfg.bandWidth)
-			{
-			case 0:
-				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0);
-				break;
-			case 0xffffffff:
-				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 1, 0);
-				break;
-			default:
-				sprintf(buf,"%lu",cfg.EncCfg.bandWidth);
-				SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf);
-				break;
-			}
-			
-			CheckDlgButton(hWndDlg, IDC_CHK_WRITEMP4, cfg.SaveMP4);
-
-			CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, cfg.AutoCfg);
-			DISABLE_CTRL(!cfg.AutoCfg);
-
-			CheckDlgButton(hWndDlg,IDC_CHK_TAG, cfg.Tag.On);
-			ENABLE_TAG(cfg.Tag.On);
-			ENABLE_AACTAGS(cfg.SaveMP4);
-			SetDlgItemText(hWndDlg, IDC_E_ARTIST, cfg.Tag.artist);
-			SetDlgItemText(hWndDlg, IDC_E_TITLE, cfg.Tag.title);
-			SetDlgItemText(hWndDlg, IDC_E_ALBUM, cfg.Tag.album);
-			SetDlgItemText(hWndDlg, IDC_E_YEAR, cfg.Tag.year);
-			SetDlgItemText(hWndDlg, IDC_CB_GENRE, cfg.Tag.genre);
-			SetDlgItemText(hWndDlg, IDC_E_WRITER, cfg.Tag.writer);
-			SetDlgItemText(hWndDlg, IDC_E_COMMENT, cfg.Tag.comment);
-			SetDlgItemText(hWndDlg, IDC_E_ARTFILE, cfg.Tag.artFileName);
-			SetDlgItemInt(hWndDlg, IDC_E_TRACK, cfg.Tag.trackno, FALSE);
-			SetDlgItemInt(hWndDlg, IDC_E_NTRACKS, cfg.Tag.ntracks, FALSE);
-			SetDlgItemInt(hWndDlg, IDC_E_DISK, cfg.Tag.discno, FALSE);
-			SetDlgItemInt(hWndDlg, IDC_E_NDISKS, cfg.Tag.ndiscs, FALSE);
-			SetDlgItemInt(hWndDlg, IDC_E_COMPILATION, cfg.Tag.compilation, FALSE);
-			Cfaac::FreeTag(&cfg.Tag);
-		}
-		break; // End of WM_INITDIALOG                                 
-		
-	case WM_CLOSE:
-		// Closing the Dialog behaves the same as Cancel               
-		PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
-		break; // End of WM_CLOSE                                      
-		
-	case WM_COMMAND:
-		switch(LOWORD(wParam))
-		{
-		case IDOK:
-			{
-			HANDLE hCfg=(HANDLE)lParam;
-			char buf[50];
-			MY_ENC_CFG cfg;
-				
-				cfg.AutoCfg=IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG) ? TRUE : FALSE;
-				cfg.EncCfg.mpegVersion=IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4) ? MPEG4 : MPEG2;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
-					cfg.EncCfg.aacObjectType=MAIN;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
-					cfg.EncCfg.aacObjectType=LOW;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
-					cfg.EncCfg.aacObjectType=SSR;
-				if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
-					cfg.EncCfg.aacObjectType=LTP;
-				cfg.EncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_CHK_ALLOWMIDSIDE);
-				cfg.EncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_CHK_USETNS);
-				cfg.EncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_CHK_USELFE);
-				
-				GetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf, 50);
-				switch(*buf)
-				{
-				case 'A': // Auto
-					cfg.EncCfg.bitRate=0;
-					break;
-				default:
-					cfg.EncCfg.bitRate=1000*GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
-				}
-				GetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf, 50);
-				switch(*buf)
-				{
-				case 'A': // Auto
-					cfg.EncCfg.bandWidth=0;
-					break;
-				case 'F': // Full
-					cfg.EncCfg.bandWidth=0xffffffff;
-					break;
-				default:
-					cfg.EncCfg.bandWidth=GetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, 0, FALSE);
-				}
-				cfg.UseQuality=IsDlgButtonChecked(hWndDlg,IDC_RADIO_QUALITY) ? TRUE : FALSE;
-				GetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf, 50);
-				switch(*buf)
-				{
-				case 'D': // Default
-					cfg.EncCfg.quantqual=100;
-					break;
-				default:
-					cfg.EncCfg.quantqual=GetDlgItemInt(hWndDlg, IDC_CB_QUALITY, 0, FALSE);
-				}
-				cfg.EncCfg.outputFormat=IsDlgButtonChecked(hWndDlg,IDC_RADIO_RAW) ? RAW : ADTS;
-				GetDlgItemText(hWndDlg, IDC_E_BROWSE, OutDir, MAX_PATH);
-				
-				cfg.SaveMP4=IsDlgButtonChecked(hWndDlg, IDC_CHK_WRITEMP4) ? TRUE : FALSE;
-
-				cfg.Tag.On=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG) ? 1 : 0;
-			char buffer[MAX_PATH];
-				GetDlgItemText(hWndDlg, IDC_E_ARTIST, buffer, MAX_PATH);
-				cfg.Tag.artist=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_TITLE, buffer, MAX_PATH);
-				cfg.Tag.title=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_ALBUM, buffer, MAX_PATH);
-				cfg.Tag.album=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_YEAR, buffer, MAX_PATH);
-				cfg.Tag.year=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_CB_GENRE, buffer, MAX_PATH);
-				cfg.Tag.genre=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_WRITER, buffer, MAX_PATH);
-				cfg.Tag.writer=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_COMMENT, buffer, MAX_PATH);
-				cfg.Tag.comment=strdup(buffer);
-				GetDlgItemText(hWndDlg, IDC_E_ARTFILE, buffer, MAX_PATH);
-				cfg.Tag.artFileName=strdup(buffer);
-				cfg.Tag.trackno=GetDlgItemInt(hWndDlg, IDC_E_TRACK, 0, FALSE);
-				cfg.Tag.ntracks=GetDlgItemInt(hWndDlg, IDC_E_NTRACKS, 0, FALSE);
-				cfg.Tag.discno=GetDlgItemInt(hWndDlg, IDC_E_DISK, 0, FALSE);
-				cfg.Tag.ndiscs=GetDlgItemInt(hWndDlg, IDC_E_NDISKS, 0, FALSE);
-				cfg.Tag.compilation=(BYTE)GetDlgItemInt(hWndDlg, IDC_E_COMPILATION, 0, FALSE);
-
-				WriteCfgEnc();
-				Cfaac::setFaacCfg(&cfg);
-				Cfaac::FreeTag(&cfg.Tag);
-
-				EndDialog(hWndDlg, (DWORD)hCfg);
-			}
-			break;
-			
-        case IDCANCEL:
-			// Ignore data values entered into the controls        
-			// and dismiss the dialog window returning FALSE
-			EndDialog(hWndDlg, FALSE);
-			break;
-
-		case IDC_BTN_ABOUT:
-			DialogBox((HINSTANCE)hInstance,(LPCSTR)MAKEINTRESOURCE(IDD_ABOUT), (HWND)hWndDlg, (DLGPROC)DialogMsgProcAbout);
-			break;
-
-		case IDC_BTN_LICENSE:
-			{
-			char *license =
-				"\nPlease note that the use of this software may require the payment of patent royalties.\n"
-				"You need to consider this issue before you start building derivative works.\n"
-				"We are not warranting or indemnifying you in any way for patent royalities!\n"
-				"YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN ACTIONS!\n"
-				"\n"
-				"FAAC is based on the ISO MPEG-4 reference code. For this code base the\n"
-				"following license applies:\n"
-				"\n"
-/*				"This software module was originally developed by\n"
-				"\n"
-				"FirstName LastName (CompanyName)\n"
-				"\n"
-				"and edited by\n"
-				"\n"
-				"FirstName LastName (CompanyName)\n"
-				"FirstName LastName (CompanyName)\n"
-				"\n"
-*/				"in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard\n"
-				"ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an\n"
-				"implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools\n"
-				"as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives\n"
-				"users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this\n"
-				"software module or modifications thereof for use in hardware or\n"
-				"software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio\n"
-				"standards. Those intending to use this software module in hardware or\n"
-				"software products are advised that this use may infringe existing\n"
-				"patents. The original developer of this software module and his/her\n"
-				"company, the subsequent editors and their companies, and ISO/IEC have\n"
-				"no liability for use of this software module or modifications thereof\n"
-				"in an implementation. Copyright is not released for non MPEG-2\n"
-				"NBC/MPEG-4 Audio conforming products. The original developer retains\n"
-				"full right to use the code for his/her own purpose, assign or donate\n"
-				"the code to a third party and to inhibit third party from using the\n"
-				"code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This\n"
-				"copyright notice must be included in all copies or derivative works.\n"
-				"\n"
-				"Copyright (c) 1997.\n"
-				"\n"
-				"For the changes made for the FAAC project the GNU Lesser General Public\n"
-				"License (LGPL), version 2 1991 applies:\n"
-				"\n"
-				"FAAC - Freeware Advanced Audio Coder\n"
-				"Copyright (C) 2001-2004 The individual contributors\n"
-				"\n"
-				"This library is free software; you can redistribute it and/or modify it under the terms of\n"
-				"the GNU Lesser General Public License as published by the Free Software Foundation;\n"
-				"either version 2.1 of the License, or (at your option) any later version.\n"
-				"\n"
-				"This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n"
-				"without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
-				"See the GNU Lesser General Public License for more details.\n"
-				"\n"
-				"You should have received a copy of the GNU Lesser General Public\n"
-				"License along with this library; if not, write to the Free Software\n"
-				"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n";
-
-				MessageBox(hWndDlg,license,"FAAC libray License",MB_OK|MB_ICONINFORMATION);
-			}
-			break;
-			
-		case IDC_BTN_BROWSE:
-			{
-			char name[MAX_PATH];
-			BROWSEINFO bi;
-			ITEMIDLIST *idlist;
-				bi.hwndOwner = hWndDlg;
-				bi.pidlRoot = 0;
-				bi.pszDisplayName = name;
-				bi.lpszTitle = "Select a directory for AAC-MPEG4 file output:";
-				bi.ulFlags = BIF_RETURNONLYFSDIRS;
-				bi.lpfn = BrowseCallbackProc;
-				bi.lParam = 0;
-				
-				GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir, MAX_PATH);
-				idlist = SHBrowseForFolder( &bi );
-				if(idlist)
-				{
-					SHGetPathFromIDList( idlist, config_AACoutdir);
-					SetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir);
-				}
-			}
-			break;
-			
-		case IDC_BTN_ARTFILE:
-			{
-			OPENFILENAME ofn;
-			char ArtFilename[MAX_PATH]="";
-
-//				GetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename, MAX_PATH);
-
-				ofn.lStructSize			= sizeof(OPENFILENAME);
-				ofn.hwndOwner			= (HWND)hWndDlg;
-				ofn.lpstrFilter			= "Cover art files (*.gif,*jpg,*.png)\0*.gif;*.jpg;*.png\0";
-				ofn.lpstrCustomFilter	= NULL;
-				ofn.nFilterIndex		= 1;
-				ofn.lpstrFile			= ArtFilename;
-				ofn.nMaxFile			= MAX_PATH; //sizeof ArtFilename;
-				ofn.lpstrFileTitle		= NULL;
-				ofn.nMaxFileTitle		= 0;
-				ofn.lpstrInitialDir		= NULL;
-				ofn.lpstrTitle			= "Select cover art file";
-				ofn.Flags				= OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING;
-				ofn.lpstrDefExt			= NULL;
-				ofn.hInstance			= hInstance;
-
-				if(GetOpenFileName(&ofn))
-					SetDlgItemText(hWndDlg, IDC_E_ARTFILE, ArtFilename);
-			}
-			break;
-
-		case IDC_RADIO_MPEG4:
-			EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			break;
-			
-		case IDC_RADIO_MPEG2:
-			EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
-			DISABLE_LTP
-			break;
-
-		case IDC_CHK_AUTOCFG:
-			{
-			char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG);
-				DISABLE_CTRL(Enabled);
-			}
-			break;
-
-		case IDC_CHK_TAG:
-			{
-			char Enabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG);
-				ENABLE_TAG(Enabled);
-			}
-//			break;
-		case IDC_CHK_WRITEMP4:
-			{
-			char Enabled=IsDlgButtonChecked(hWndDlg,IDC_CHK_WRITEMP4) && IsDlgButtonChecked(hWndDlg,IDC_CHK_TAG);
-				ENABLE_AACTAGS(Enabled);
-			}
-			break;
-		}
-		break; // End of WM_COMMAND
-	default: 
-		return FALSE;
-	}
-	
-	return TRUE;
-} // End of DIALOGSMsgProc                                      
-// *********************************************************************************************
-
 void Config(HWND hWnd)
 {
-	DialogBox(out.hDllInstance, MAKEINTRESOURCE(IDD_ENCODER), hWnd, DIALOGMsgProc);
+	DialogBox(out.hDllInstance, MAKEINTRESOURCE(IDD_ENCODER), hWnd, DIALOGMsgProcEnc);
 //	dwOptions=DialogBoxParam((HINSTANCE)out.hDllInstance,(LPCSTR)MAKEINTRESOURCE(IDD_ENCODER), (HWND)hWnd, (DLGPROC)DIALOGMsgProc, dwOptions);
 }
 
@@ -1002,8 +295,8 @@
 
 int Open(int lSamprate, int wChannels, int wBitsPerSample, int bufferlenms, int prebufferms)
 {
-MY_ENC_CFG		cfg;
-char			lpstrFilename[MAX_PATH];
+CMyEncCfg	cfg;
+char		lpstrFilename[MAX_PATH];
 
 	w_offset = writtentime = 0;
 	numchan = wChannels;
@@ -1010,10 +303,7 @@
 	srate = lSamprate;
 	bps = wBitsPerSample;
 
-	ReadCfgEnc();
-	Cfaac::getFaacCfg(&cfg);
-
-	strcpy(config_AACoutdir,OutDir);
+	strcpy(config_AACoutdir,cfg.OutDir);
 	GetNewFileName(lpstrFilename);
 
 	Cpcmaac=new Cfaac();
--- a/plugins/winamp/RESOURCE.H
+++ b/plugins/winamp/RESOURCE.H
@@ -8,66 +8,69 @@
 #define IDB_AUDIOCODING                 104
 #define IDB_EMAIL                       106
 #define IDB_MPEG4IP                     107
-#define IDB_BITMAP1                     108
 #define IDB_BROWSE                      108
-#define IDC_RADIO_MPEG4                 1000
-#define IDC_RADIO_MPEG2                 1001
-#define IDC_RADIO_LOW                   1002
-#define IDC_RADIO_MAIN                  1003
-#define IDC_RADIO_SSR                   1004
-#define IDC_RADIO_LTP                   1005
-#define IDC_RADIO_RAW                   1006
-#define IDC_RADIO_HE                    1006
-#define IDC_RADIO_ADTS                  1007
-#define IDC_CB_BANDWIDTH                1008
-#define IDC_CB_BITRATE                  1009
-#define IDC_CHK_ALLOWMIDSIDE            1010
-#define IDC_CHK_USETNS                  1011
-#define IDC_CHK_USELFE                  1012
-#define IDC_CHK_AUTOCFG                 1013
-#define IDC_BTN_ABOUT                   1014
-#define IDC_L_ABOUT                     1015
-#define IDC_BTN_ARTFILE                 1015
-#define IDC_AUDIOCODING                 1016
-#define IDC_CHK_USETNS2                 1016
-#define IDC_CHK_MP4                     1016
-#define WRITEMP4                        1016
-#define IDC_EMAIL                       1017
-#define IDC_E_BROWSE                    1017
-#define IDC_MPEG4IP                     1018
-#define IDC_BTN_BROWSE                  1018
-#define IDC_CHK_DEFAULTCFG              1019
-#define IDC_CB_SAMPLERATE               1020
-#define IDC_RADIO_BITRATE               1022
-#define IDC_RADIO_QUALITY               1023
-#define IDC_CB_QUALITY                  1024
-#define IDC_CHK_DOWNMATRIX              1025
-#define IDC_CHK_OLDADTS                 1026
-#define IDC_CHK_WRITEMP4                1027
-#define IDC_E_ARTIST                    1028
-#define IDC_CHK_TAG                     1029
-#define IDC_E_TITLE                     1030
-#define IDC_E_ALBUM                     1031
-#define IDC_E_YEAR                      1032
-#define IDC_CB_GENRE                    1033
-#define IDC_E_WRITER                    1034
-#define IDC_E_COMMENT                   1035
-#define IDC_E_TRACK                     1036
-#define IDC_E_NTRACKS                   1037
-#define IDC_E_DISK                      1038
-#define IDC_E_NDISKS                    1039
-#define IDC_GRP_TAG                     1040
-#define IDC_E_COMPILATION               1041
-#define IDC_E_ARTFILE                   1042
-#define IDC_BTN_LICENSE                 1043
+#define IDI_ICON1                       109
+#define IDI_ID3                         109
+#define IDC_CHK_DEFAULTCFG              1000
+#define IDC_CHK_DOWNMATRIX              1001
+#define IDC_CHK_OLDADTS                 1002
+#define IDC_CB_SAMPLERATE               1003
+#define IDC_AUDIOCODING                 1004
+#define IDC_EMAIL                       1005
+#define IDC_MPEG4IP                     1006
+#define IDC_E_BROWSE                    1007
+#define IDC_BTN_BROWSE                  1008
+#define IDC_RADIO_MPEG4                 1009
+#define IDC_RADIO_MPEG2                 1010
+#define IDC_RADIO_LOW                   1011
+#define IDC_RADIO_MAIN                  1012
+#define IDC_RADIO_SSR                   1013
+#define IDC_RADIO_LTP                   1014
+#define IDC_RADIO_RAW                   1015
+#define IDC_RADIO_HE                    1016
+#define IDC_RADIO_ADTS                  1017
+#define IDC_CB_BANDWIDTH                1018
+#define IDC_CB_BITRATE                  1019
+#define IDC_CHK_ALLOWMIDSIDE            1020
+#define IDC_CHK_USETNS                  1021
+#define IDC_CHK_USELFE                  1022
+#define IDC_CHK_AUTOCFG                 1023
+#define IDC_BTN_ABOUT                   1024
+#define IDC_L_ABOUT                     1025
+#define IDC_BTN_ARTFILE                 1026
+#define IDC_CHK_USETNS2                 1027
+#define IDC_CHK_MP4                     1028
+#define WRITEMP4                        1029
+#define IDC_RADIO_BITRATE               1030
+#define IDC_RADIO_QUALITY               1031
+#define IDC_CB_QUALITY                  1032
+#define IDC_CHK_WRITEMP4                1033
+#define IDC_E_ARTIST                    1034
+#define IDC_CHK_TAG                     1035
+#define IDC_E_TITLE                     1036
+#define IDC_E_ALBUM                     1037
+#define IDC_E_YEAR                      1038
+#define IDC_CB_GENRE                    1039
+#define IDC_E_WRITER                    1040
+#define IDC_E_COMMENT                   1041
+#define IDC_E_TRACK                     1042
+#define IDC_E_NTRACKS                   1043
+#define IDC_E_DISK                      1044
+#define IDC_E_NDISKS                    1045
+#define IDC_GRP_TAG                     1046
+#define IDC_E_COMPILATION               1047
+#define IDC_E_ARTFILE                   1048
+#define IDC_BTN_LICENSE                 1049
+#define IDC_CHK_COMPILATION             1050
+#define IDC_ID3                         1052
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        109
+#define _APS_NEXT_RESOURCE_VALUE        110
 #define _APS_NEXT_COMMAND_VALUE         40001
-#define _APS_NEXT_CONTROL_VALUE         1044
+#define _APS_NEXT_CONTROL_VALUE         1051
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
--- a/plugins/winamp/defines.h
+++ b/plugins/winamp/defines.h
@@ -20,7 +20,7 @@
 */
 
 #define APP_NAME "MPEG4-AAC encoder"
-#define APP_VER "v1.4"
+#define APP_VER "v1.5"
 #define REGISTRY_PROGRAM_NAME "SOFTWARE\\4N\\Winamp\\Out_AAC"
 
 // -----------------------------------------------------------------------------------------------
binary files /dev/null b/plugins/winamp/id3v2.ico differ
binary files a/plugins/winamp/mpeg4ip-v.bmp b/plugins/winamp/mpeg4ip-v.bmp differ
--- a/plugins/winamp/out_FAAC.sln
+++ b/plugins/winamp/out_FAAC.sln
@@ -1,14 +1,14 @@
 Microsoft Visual Studio Solution File, Format Version 7.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Out_FAAC", "Out_FAAC.vcproj", "{D5E38472-E616-414F-AE28-2138AAB73DA7}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Out_FAAC", "Out_FAAC.vcproj", "{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaac", "..\..\libfaac\libfaac.vcproj", "{27812E8E-D771-4C78-8675-FB67C3FF26FD}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaac", "..\..\libfaac\libfaac.vcproj", "{140B72E6-CC42-48D8-97FF-24FFF9A825E9}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmp4v2_st", "..\..\..\faad2\common\mp4v2\libmp4v2_st60.vcproj", "{76B4120C-00C0-4EAE-B2BA-BC930178A391}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmp4v2_st", "..\..\..\faad2\common\mp4v2\libmp4v2_st60.vcproj", "{239FBB04-89E8-4463-BC48-D57E565F08FC}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\faad2\common\id3lib\zlib\prj\zlib.vcproj", "{873DE650-0D25-4EDA-846D-D36408A73E33}"
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "id3lib", "..\..\..\faad2\common\id3lib\libprj\id3lib.vcproj", "{016F36CD-410C-4B47-A527-AF82B848E1EB}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\faad2\common\id3lib\zlib\prj\zlib.vcproj", "{873DE650-0D25-4EDA-846D-D36408A73E33}"
+EndProject
 Global
 	GlobalSection(SolutionConfiguration) = preSolution
 		ConfigName.0 = Debug
@@ -17,44 +17,36 @@
 		ConfigName.3 = Release
 	EndGlobalSection
 	GlobalSection(ProjectDependencies) = postSolution
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.0 = {76B4120C-00C0-4EAE-B2BA-BC930178A391}
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.1 = {27812E8E-D771-4C78-8675-FB67C3FF26FD}
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.2 = {873DE650-0D25-4EDA-846D-D36408A73E33}
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.3 = {016F36CD-410C-4B47-A527-AF82B848E1EB}
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.0 = {239FBB04-89E8-4463-BC48-D57E565F08FC}
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.1 = {873DE650-0D25-4EDA-846D-D36408A73E33}
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.2 = {140B72E6-CC42-48D8-97FF-24FFF9A825E9}
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.3 = {016F36CD-410C-4B47-A527-AF82B848E1EB}
 	EndGlobalSection
 	GlobalSection(ProjectConfiguration) = postSolution
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.Debug.ActiveCfg = Debug|Win32
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.Debug.Build.0 = Debug|Win32
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.NASM Debug.ActiveCfg = Debug|Win32
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.NASM Debug.Build.0 = Debug|Win32
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.NASM Release.ActiveCfg = Release|Win32
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.NASM Release.Build.0 = Release|Win32
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.Release.ActiveCfg = Release|Win32
-		{D5E38472-E616-414F-AE28-2138AAB73DA7}.Release.Build.0 = Release|Win32
-		{27812E8E-D771-4C78-8675-FB67C3FF26FD}.Debug.ActiveCfg = Debug|Win32
-		{27812E8E-D771-4C78-8675-FB67C3FF26FD}.Debug.Build.0 = Debug|Win32
-		{27812E8E-D771-4C78-8675-FB67C3FF26FD}.NASM Debug.ActiveCfg = Debug|Win32
-		{27812E8E-D771-4C78-8675-FB67C3FF26FD}.NASM Debug.Build.0 = Debug|Win32
-		{27812E8E-D771-4C78-8675-FB67C3FF26FD}.NASM Release.ActiveCfg = Release|Win32
-		{27812E8E-D771-4C78-8675-FB67C3FF26FD}.NASM Release.Build.0 = Release|Win32
-		{27812E8E-D771-4C78-8675-FB67C3FF26FD}.Release.ActiveCfg = Release|Win32
-		{27812E8E-D771-4C78-8675-FB67C3FF26FD}.Release.Build.0 = Release|Win32
-		{76B4120C-00C0-4EAE-B2BA-BC930178A391}.Debug.ActiveCfg = Debug|Win32
-		{76B4120C-00C0-4EAE-B2BA-BC930178A391}.Debug.Build.0 = Debug|Win32
-		{76B4120C-00C0-4EAE-B2BA-BC930178A391}.NASM Debug.ActiveCfg = Debug|Win32
-		{76B4120C-00C0-4EAE-B2BA-BC930178A391}.NASM Debug.Build.0 = Debug|Win32
-		{76B4120C-00C0-4EAE-B2BA-BC930178A391}.NASM Release.ActiveCfg = Release|Win32
-		{76B4120C-00C0-4EAE-B2BA-BC930178A391}.NASM Release.Build.0 = Release|Win32
-		{76B4120C-00C0-4EAE-B2BA-BC930178A391}.Release.ActiveCfg = Release|Win32
-		{76B4120C-00C0-4EAE-B2BA-BC930178A391}.Release.Build.0 = Release|Win32
-		{873DE650-0D25-4EDA-846D-D36408A73E33}.Debug.ActiveCfg = Debug|Win32
-		{873DE650-0D25-4EDA-846D-D36408A73E33}.Debug.Build.0 = Debug|Win32
-		{873DE650-0D25-4EDA-846D-D36408A73E33}.NASM Debug.ActiveCfg = NASM Debug|Win32
-		{873DE650-0D25-4EDA-846D-D36408A73E33}.NASM Debug.Build.0 = NASM Debug|Win32
-		{873DE650-0D25-4EDA-846D-D36408A73E33}.NASM Release.ActiveCfg = NASM Release|Win32
-		{873DE650-0D25-4EDA-846D-D36408A73E33}.NASM Release.Build.0 = NASM Release|Win32
-		{873DE650-0D25-4EDA-846D-D36408A73E33}.Release.ActiveCfg = Release|Win32
-		{873DE650-0D25-4EDA-846D-D36408A73E33}.Release.Build.0 = Release|Win32
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.Debug.ActiveCfg = Debug|Win32
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.Debug.Build.0 = Debug|Win32
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.NASM Debug.ActiveCfg = Debug|Win32
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.NASM Debug.Build.0 = Debug|Win32
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.NASM Release.ActiveCfg = Release|Win32
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.NASM Release.Build.0 = Release|Win32
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.Release.ActiveCfg = Release|Win32
+		{D60DE5FC-6DD6-4335-A37A-EC45BD819E7C}.Release.Build.0 = Release|Win32
+		{140B72E6-CC42-48D8-97FF-24FFF9A825E9}.Debug.ActiveCfg = Debug|Win32
+		{140B72E6-CC42-48D8-97FF-24FFF9A825E9}.Debug.Build.0 = Debug|Win32
+		{140B72E6-CC42-48D8-97FF-24FFF9A825E9}.NASM Debug.ActiveCfg = Debug|Win32
+		{140B72E6-CC42-48D8-97FF-24FFF9A825E9}.NASM Debug.Build.0 = Debug|Win32
+		{140B72E6-CC42-48D8-97FF-24FFF9A825E9}.NASM Release.ActiveCfg = Release|Win32
+		{140B72E6-CC42-48D8-97FF-24FFF9A825E9}.NASM Release.Build.0 = Release|Win32
+		{140B72E6-CC42-48D8-97FF-24FFF9A825E9}.Release.ActiveCfg = Release|Win32
+		{140B72E6-CC42-48D8-97FF-24FFF9A825E9}.Release.Build.0 = Release|Win32
+		{239FBB04-89E8-4463-BC48-D57E565F08FC}.Debug.ActiveCfg = Debug|Win32
+		{239FBB04-89E8-4463-BC48-D57E565F08FC}.Debug.Build.0 = Debug|Win32
+		{239FBB04-89E8-4463-BC48-D57E565F08FC}.NASM Debug.ActiveCfg = Debug|Win32
+		{239FBB04-89E8-4463-BC48-D57E565F08FC}.NASM Debug.Build.0 = Debug|Win32
+		{239FBB04-89E8-4463-BC48-D57E565F08FC}.NASM Release.ActiveCfg = Release|Win32
+		{239FBB04-89E8-4463-BC48-D57E565F08FC}.NASM Release.Build.0 = Release|Win32
+		{239FBB04-89E8-4463-BC48-D57E565F08FC}.Release.ActiveCfg = Release|Win32
+		{239FBB04-89E8-4463-BC48-D57E565F08FC}.Release.Build.0 = Release|Win32
 		{016F36CD-410C-4B47-A527-AF82B848E1EB}.Debug.ActiveCfg = Debug|Win32
 		{016F36CD-410C-4B47-A527-AF82B848E1EB}.Debug.Build.0 = Debug|Win32
 		{016F36CD-410C-4B47-A527-AF82B848E1EB}.NASM Debug.ActiveCfg = Debug|Win32
@@ -63,6 +55,14 @@
 		{016F36CD-410C-4B47-A527-AF82B848E1EB}.NASM Release.Build.0 = Release|Win32
 		{016F36CD-410C-4B47-A527-AF82B848E1EB}.Release.ActiveCfg = Release|Win32
 		{016F36CD-410C-4B47-A527-AF82B848E1EB}.Release.Build.0 = Release|Win32
+		{873DE650-0D25-4EDA-846D-D36408A73E33}.Debug.ActiveCfg = Debug|Win32
+		{873DE650-0D25-4EDA-846D-D36408A73E33}.Debug.Build.0 = Debug|Win32
+		{873DE650-0D25-4EDA-846D-D36408A73E33}.NASM Debug.ActiveCfg = NASM Debug|Win32
+		{873DE650-0D25-4EDA-846D-D36408A73E33}.NASM Debug.Build.0 = NASM Debug|Win32
+		{873DE650-0D25-4EDA-846D-D36408A73E33}.NASM Release.ActiveCfg = NASM Release|Win32
+		{873DE650-0D25-4EDA-846D-D36408A73E33}.NASM Release.Build.0 = NASM Release|Win32
+		{873DE650-0D25-4EDA-846D-D36408A73E33}.Release.ActiveCfg = Release|Win32
+		{873DE650-0D25-4EDA-846D-D36408A73E33}.Release.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 	EndGlobalSection
--- a/plugins/winamp/out_FAAC.vcproj
+++ b/plugins/winamp/out_FAAC.vcproj
@@ -16,14 +16,12 @@
 			IntermediateDirectory=".\Release"
 			ConfigurationType="2"
 			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE"
-			CharacterSet="2">
+			ATLMinimizesCRunTimeLibraryUsage="FALSE">
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalOptions=""
 				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="..\..\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OUT_FAAC_EXPORTS"
+				AdditionalIncludeDirectories="..\..\include,../../../faad2/common/mp4v2"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;WIN32_LEAN_AND_MEAN"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="TRUE"
@@ -75,11 +73,9 @@
 			IntermediateDirectory=".\Debug"
 			ConfigurationType="2"
 			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="FALSE"
-			CharacterSet="0">
+			ATLMinimizesCRunTimeLibraryUsage="FALSE">
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalOptions=""
 				Optimization="0"
 				AdditionalIncludeDirectories="../../include,../../../faad2/include,../../../faad2/common/faad,../../../faad2/common/mp4v2,../../../faad2/common/id3lib/include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;WIN32_LEAN_AND_MEAN"
@@ -98,7 +94,7 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalOptions="/MACHINE:I386 &quot;c:\CPP\faad2-2.0\faad2\common\mp4v2\ST_Debug\libmp4v2_st60.lib&quot; &quot;c:\CPP\faad2-2.0\faac\libfaac\Debug\libfaac.lib&quot;"
+				AdditionalOptions="/MACHINE:I386"
 				AdditionalDependencies="ws2_32.lib odbc32.lib odbccp32.lib"
 				OutputFile="C:\Program Files\Audio\Gen\Winamp\Plugins\Out_AAC.dll"
 				LinkIncremental="2"
@@ -138,9 +134,15 @@
 				RelativePath=".\CRegistry.cpp">
 			</File>
 			<File
-				RelativePath="Cfaac.cpp">
+				RelativePath="CTag.cpp">
 			</File>
 			<File
+				RelativePath=".\Cfaac.cpp">
+			</File>
+			<File
+				RelativePath="EncDialog.cpp">
+			</File>
+			<File
 				RelativePath=".\FAAC.rc">
 			</File>
 			<File
@@ -157,9 +159,15 @@
 				RelativePath=".\CRegistry.h">
 			</File>
 			<File
-				RelativePath="Cfaac.h">
+				RelativePath="CTag.h">
 			</File>
 			<File
+				RelativePath=".\Cfaac.h">
+			</File>
+			<File
+				RelativePath="EncDialog.h">
+			</File>
+			<File
 				RelativePath=".\FILTERS.H">
 			</File>
 			<File
@@ -169,6 +177,9 @@
 				RelativePath=".\defines.h">
 			</File>
 			<File
+				RelativePath="..\..\include\faac.h">
+			</File>
+			<File
 				RelativePath=".\resource.h">
 			</File>
 		</Filter>
@@ -176,16 +187,19 @@
 			Name="Resource Files"
 			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
 			<File
-				RelativePath="AudioCoding.bmp">
+				RelativePath=".\AudioCoding.bmp">
 			</File>
 			<File
-				RelativePath="Email.bmp">
+				RelativePath=".\Email.bmp">
 			</File>
 			<File
 				RelativePath=".\Open.bmp">
 			</File>
 			<File
-				RelativePath="mpeg4ip-v.bmp">
+				RelativePath=".\Open.ico">
+			</File>
+			<File
+				RelativePath=".\mpeg4ip-v.bmp">
 			</File>
 		</Filter>
 	</Files>