shithub: aacenc

Download patch

ref: e01a1562364120f68a8d2f6b3ecc7702cf25474e
parent: c8e0f497f000cdd9c355ed07e9f0ca4484a8a5c2
author: menno <menno>
date: Mon Sep 30 09:35:08 EDT 2002

Latest changes to plugins by 4N

--- a/plugins/cooledit/Aacinfo.cpp
+++ /dev/null
@@ -1,249 +1,0 @@
-/*
- * FAAD - Freeware Advanced Audio Decoder
- * Copyright (C) 2001 Menno Bakker
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * $Id: Aacinfo.cpp,v 1.3 2002/08/22 22:58:57 menno Exp $
- */
-
-#include <windows.h>
-#include "aacinfo.h"
-
-#define ADIF_MAX_SIZE 30 /* Should be enough */
-#define ADTS_MAX_SIZE 10 /* Should be enough */
-
-static const int sample_rates[] = {96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000};
-
-static int read_ADIF_header(HANDLE file, faadAACInfo *info)
-{
-	unsigned long tmp;
-	int bitstream;
-	unsigned char buffer[ADIF_MAX_SIZE];
-	int skip_size = 0;
-	int sf_idx;
-
-	/* Get ADIF header data */
-	
-	info->headertype = 1;
-
-	ReadFile(file, buffer, ADIF_MAX_SIZE, &tmp, 0);
-
-	/* copyright string */	
-	if(buffer[4] & 128)
-		skip_size += 9; /* skip 9 bytes */
-
-	bitstream = buffer[4 + skip_size] & 16;
-	info->bitrate = ((unsigned int)(buffer[4 + skip_size] & 0x0F)<<19)|
-		((unsigned int)buffer[5 + skip_size]<<11)|
-		((unsigned int)buffer[6 + skip_size]<<3)|
-		((unsigned int)buffer[7 + skip_size] & 0xE0);
-
-	if (bitstream == 0) {
-		info->object_type = ((buffer[9 + skip_size]&0x01)<<1)|((buffer[10 + skip_size]&0x80)>>7);
-		sf_idx = (buffer[10 + skip_size]&0x78)>>3;
-		info->channels = ((buffer[10 + skip_size]&0x07)<<1)|((buffer[11 + skip_size]&0x80)>>7);
-	} else {
-		info->object_type = (buffer[7 + skip_size] & 0x18)>>3;
-		sf_idx = ((buffer[7 + skip_size] & 0x07)<<1)|((buffer[8 + skip_size] & 0x80)>>7);
-		info->channels = (buffer[8 + skip_size]&0x78)>>3;
-	}
-	info->sampling_rate = sample_rates[sf_idx];
-
-	return 0;
-}
-
-static int read_ADTS_header(HANDLE file, faadAACInfo *info, int *seek_table,
-							int tagsize)
-{
-	/* Get ADTS header data */
-	unsigned char buffer[ADTS_MAX_SIZE];
-	int frames, t_framelength = 0, frame_length, sr_idx, ID;
-	int second = 0, pos;
-	float frames_per_sec = 0;
-	unsigned long bytes;
-
-	info->headertype = 2;
-
-	/* Seek to the first frame */
-	SetFilePointer(file, tagsize, NULL, FILE_BEGIN);
-
-	/* Read all frames to ensure correct time and bitrate */
-	for(frames=0; /* */; frames++)
-	{
-		/* 12 bit SYNCWORD */
-		ReadFile(file, buffer, ADTS_MAX_SIZE, &bytes, 0);
-		if(bytes != ADTS_MAX_SIZE)
-		{
-			/* Bail out if no syncword found */
-			break;
-		}
-
-		if (!((buffer[0] == 0xFF)&&((buffer[1] & 0xF6) == 0xF0)))
-			break;
-
-		pos = SetFilePointer(file, 0, NULL, FILE_CURRENT) - ADTS_MAX_SIZE;
-
-		if(!frames)
-		{
-			/* fixed ADTS header is the same for every frame, so we read it only once */ 
-			/* Syncword found, proceed to read in the fixed ADTS header */ 
-			ID = buffer[1] & 0x08;
-			info->object_type = (buffer[2]&0xC0)>>6;
-			sr_idx = (buffer[2]&0x3C)>>2;
-			info->channels = ((buffer[2]&0x01)<<2)|((buffer[3]&0xC0)>>6);
-
-			frames_per_sec = sample_rates[sr_idx] / 1024.f;
-		}
-
-		/* ...and the variable ADTS header */
-		if (ID == 0) {
-			info->version = 4;
-			frame_length = (((unsigned int)buffer[4]) << 5) |
-				((unsigned int)buffer[5] >> 3);
-		} else { /* MPEG-2 */
-			info->version = 2;
-			frame_length = ((((unsigned int)buffer[3] & 0x3)) << 11)
-				| (((unsigned int)buffer[4]) << 3) | (buffer[5] >> 5);
-		}
-
-		t_framelength += frame_length;
-
-		if (frames > second*frames_per_sec)
-		{
-			seek_table[second] = pos;
-			second++;
-		}
-
-		SetFilePointer(file, frame_length - ADTS_MAX_SIZE, NULL, FILE_CURRENT);
-	}
-
-	info->sampling_rate = sample_rates[sr_idx];
-	info->bitrate = (int)(((t_framelength / frames) * (info->sampling_rate/1024.0)) +0.5)*8;
-	info->length = (int)((float)(frames/frames_per_sec))*1000;
-
-	return 0;
-}
-
-static int f_id3v2_tag(HANDLE file)
-{
-	unsigned char buffer[10];
-	unsigned long tmp;
-
-	ReadFile(file, buffer, 10, &tmp, 0);
-
-	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;
-
-		SetFilePointer(file, tagsize, NULL, FILE_BEGIN);
-
-		return tagsize;
-	} else {
-		SetFilePointer(file, 0, NULL, FILE_BEGIN);
-
-		return 0;
-	}
-}
-
-int get_AAC_format(char *filename, faadAACInfo *info, int *seek_table)
-{
-	unsigned int tagsize;
-	HANDLE file;
-	unsigned long file_len;
-	unsigned char adxx_id[5];
-	unsigned long tmp;
-
-	if(StringComp(filename, "http://", 7) == 0)
-	{
-		info->version = 2;
-		info->length = 0;
-		info->bitrate = 128000;
-		info->sampling_rate = 44100;
-		info->channels = 2;
-		info->headertype = 0;
-		info->object_type = 1;
-
-		return 0;
-	}
-
-	file = CreateFile(filename, GENERIC_READ,
-		FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
-		OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0);
-	if (file == INVALID_HANDLE_VALUE)
-		return -1;
-
-	file_len = GetFileSize(file, NULL);
-
-	tagsize = f_id3v2_tag(file); /* Skip the tag, if it's there */
-	file_len -= tagsize;
-
-	ReadFile(file, adxx_id, 4, &tmp, 0);
-	SetFilePointer(file, tagsize, NULL, FILE_BEGIN);
-
-	adxx_id[5-1] = 0;
-
-	info->length = 0;
-
-	if(StringComp((const char *)adxx_id, "ADIF", 4) == 0)
-	{
-		read_ADIF_header(file, info);
-	}
-	else
-	{
-		if ((adxx_id[0] == 0xFF)&&((adxx_id[1] & 0xF6) == 0xF0))
-		{
-//			SetFilePointer(file, tagsize, NULL, FILE_BEGIN);
-			read_ADTS_header(file, info, seek_table, tagsize);
-		}
-		else
-		{
-			/* Unknown/headerless AAC file, assume format: */
-			info->version = 2;
-			info->bitrate = 128000;
-			info->sampling_rate = 44100;
-			info->channels = 2;
-			info->headertype = 0;
-			info->object_type = 1;
-		}
-	}
-
-	if (info->length == 0)
-		info->length = (int)((file_len/(((info->bitrate*8)/1024)*16))*1000);
-
-	CloseHandle(file);
-
-	return 0;
-}
-
-int StringComp(char const *str1, char const *str2, unsigned long len)
-{
-	signed int c1 = 0, c2 = 0;
-
-	while (len--) {
-		c1 = *str1++;
-		c2 = *str2++;
-
-		if (c1 == 0 || c1 != c2)
-			break;
-	}
-
-	return c1 - c2;
-}
--- a/plugins/cooledit/Config.cpp
+++ /dev/null
@@ -1,42 +1,0 @@
-#include <windows.h>
-#include <stdio.h>
-
-
-static char app_name[] = "Freeware AAC encoder";
-static char INI_FILE[MAX_PATH];
-
-
-static void _r_s(char *name,char *data, int mlen)
-{
-char buf[2048];
- strcpy(buf,data);
- GetPrivateProfileString(app_name,name,buf,data,mlen,INI_FILE);
-}
-
-#define RS(x) (_r_s(#x,x,sizeof(x)))
-#define WS(x) (WritePrivateProfileString(app_name,#x,x,INI_FILE))
-
-
-void config_init()
-{
-	char *p=INI_FILE;
-	GetModuleFileName(NULL,INI_FILE,sizeof(INI_FILE));
-	while (*p) p++;
-	while (p >= INI_FILE && *p != '\\') p--;
-	strcpy(p+1,"plugins.ini");
-}
-
-void config_read(DWORD *dwOptions)
-{
-char Options[512];
- config_init();
- RS(Options);
- *dwOptions=atoi(Options);
-}
-
-void config_write(DWORD dwOptions)
-{
-char Options[512];
- sprintf(Options,"%lu",dwOptions);
- WS(Options);
-}
--- /dev/null
+++ b/plugins/cooledit/Copying
@@ -1,0 +1,339 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                          675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	Appendix: How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
--- /dev/null
+++ b/plugins/cooledit/FAAC.def
@@ -1,0 +1,16 @@
+LIBRARY
+
+EXPORTS
+	QueryCoolFilter
+	OpenFilterOutput
+	CloseFilterOutput
+	WriteFilterOutput
+	OpenFilterInput
+	CloseFilterInput
+	ReadFilterInput
+	FilterUnderstandsFormat
+	FilterGetFileSize
+	FilterOptionsString
+	FilterGetOptions
+	GetSuggestedSampleType	@16
+	DIALOGMsgProc
--- /dev/null
+++ b/plugins/cooledit/FAAC.dsp
@@ -1,0 +1,152 @@
+# Microsoft Developer Studio Project File - Name="FAAC" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=FAAC - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "FAAC.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "FAAC.mak" CFG="FAAC - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "FAAC - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "FAAC - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "FAAC - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAAC_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "../../../faad2/common/faad" /I "../../include" /I "../../../faad2/include" /I "../../../faad2/common/mp4v2" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAAC_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x410 /d "NDEBUG"
+# ADD RSC /l 0x410 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /machine:I386 /out:"Release/FAAC.flt"
+
+!ELSEIF  "$(CFG)" == "FAAC - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAAC_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../faad2/common/faad" /I "../../include" /I "../../../faad2/include" /I "../../../faad2/common/mp4v2" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAAC_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x410 /d "_DEBUG"
+# ADD RSC /l 0x410 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/FAAC.flt" /pdbtype:sept
+# SUBTRACT LINK32 /nodefaultlib
+
+!ENDIF 
+
+# Begin Target
+
+# Name "FAAC - Win32 Release"
+# Name "FAAC - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\CRegistry.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Faac.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FAAC.def
+# End Source File
+# Begin Source File
+
+SOURCE=.\FAAC.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\Faad.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Main.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\CRegistry.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\defines.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\faac.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\faad2\include\faad.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\FILTERS.H
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
--- /dev/null
+++ b/plugins/cooledit/FAAC.dsw
@@ -1,0 +1,89 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "FAAC"=.\FAAC.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name libfaac
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libfaad
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libmp4v2_st
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name aacInfoLib
+    End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "aacInfoLib"=.\aacInfoLib.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "libfaac"=..\..\libfaac\libfaac.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "libfaad"=..\..\..\faad2\libfaad\libfaad.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "libmp4v2_st"=..\..\..\faad2\common\mp4v2\libmp4v2_st60.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
--- /dev/null
+++ b/plugins/cooledit/FAAC.rc
@@ -1,0 +1,131 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_COMPRESSION DIALOG DISCARDABLE  0, 0, 184, 126
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "MPEG4-AAC options"
+FONT 8, "MS Sans Serif"
+BEGIN
+    CONTROL         "Automatic configuration",IDC_CHK_AUTOCFG,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,4,4,90,10
+    CONTROL         "MPEG4",IDC_RADIO_MPEG4,"Button",BS_AUTORADIOBUTTON | 
+                    WS_GROUP,8,29,42,10
+    CONTROL         "MPEG2",IDC_RADIO_MPEG2,"Button",BS_AUTORADIOBUTTON,8,42,
+                    41,9
+    CONTROL         "Main",IDC_RADIO_MAIN,"Button",BS_AUTORADIOBUTTON | 
+                    WS_GROUP,12,73,31,10
+    CONTROL         "Low",IDC_RADIO_LOW,"Button",BS_AUTORADIOBUTTON,12,85,29,
+                    10
+    CONTROL         "SSR",IDC_RADIO_SSR,"Button",BS_AUTORADIOBUTTON | 
+                    WS_DISABLED,12,97,31,10
+    CONTROL         "LTP",IDC_RADIO_LTP,"Button",BS_AUTORADIOBUTTON,12,109,
+                    29,10
+    CONTROL         "Raw",IDC_RADIO_RAW,"Button",BS_AUTORADIOBUTTON | 
+                    WS_GROUP,59,29,42,10
+    CONTROL         "ADTS",IDC_RADIO_ADTS,"Button",BS_AUTORADIOBUTTON,59,42,
+                    41,9
+    CONTROL         "Allow Mid/Side",IDC_ALLOWMIDSIDE,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,108,21,63,10
+    CONTROL         "Use TNS",IDC_USETNS,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,108,33,45,10
+    CONTROL         "Use LFE channel",IDC_USELFE,"Button",BS_AUTOCHECKBOX | 
+                    WS_DISABLED | WS_TABSTOP,108,46,67,10
+    COMBOBOX        IDC_CB_BITRATE,132,68,48,30,CBS_DROPDOWN | WS_VSCROLL | 
+                    WS_TABSTOP
+    COMBOBOX        IDC_CB_BANDWIDTH,132,85,48,30,CBS_DROPDOWN | WS_VSCROLL | 
+                    WS_TABSTOP
+    DEFPUSHBUTTON   "OK",IDOK,72,107,36,14
+    PUSHBUTTON      "Cancel",IDCANCEL,108,107,36,14
+    PUSHBUTTON      "About",IDC_BTN_ABOUT,144,107,36,14
+    GROUPBOX        "AAC type",IDC_STATIC,4,18,48,38
+    GROUPBOX        "Profile",IDC_STATIC,4,62,48,59
+    LTEXT           "Bitrate per channel",IDC_STATIC,59,73,60,8
+    LTEXT           "Bandwidth",IDC_STATIC,59,89,34,8
+    GROUPBOX        "Header",IDC_STATIC,55,18,48,38
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    IDD_COMPRESSION, DIALOG
+    BEGIN
+        LEFTMARGIN, 4
+        RIGHTMARGIN, 180
+        TOPMARGIN, 4
+        BOTTOMMARGIN, 121
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
--- a/plugins/cooledit/FAAD.DSP
+++ /dev/null
@@ -1,169 +1,0 @@
-# Microsoft Developer Studio Project File - Name="FAAD" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=FAAD - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "FAAD.MAK".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "FAAD.MAK" CFG="FAAD - Win32 Release"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "FAAD - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "FAAD - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=xicl6.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "FAAD - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\Release"
-# PROP BASE Intermediate_Dir ".\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\Release"
-# PROP Intermediate_Dir ".\Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /G4 /W3 /GX /O2 /I "../../include" /I "../../../faad2/include" /I "../../../faad2/common/mp4v2" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=xilink6.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /incremental:yes /machine:I386 /out:"Release\FAAC.flt"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF  "$(CFG)" == "FAAD - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\Debug"
-# PROP BASE Intermediate_Dir ".\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\Debug"
-# PROP Intermediate_Dir ".\Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /G4 /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../../faad2/include" /I "../../../faad2/common/mp4v2" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=xilink6.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"Debug\FAAC.flt"
-# SUBTRACT LINK32 /pdb:none /nodefaultlib
-
-!ENDIF 
-
-# Begin Target
-
-# Name "FAAD - Win32 Release"
-# Name "FAAD - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=.\Aacinfo.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\CRegistry.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Faac.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Faad.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\FAAD.def
-# End Source File
-# Begin Source File
-
-SOURCE=.\FAAD.rc
-# End Source File
-# Begin Source File
-
-SOURCE=.\Main.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\AACINFO.H
-# End Source File
-# Begin Source File
-
-SOURCE=.\CRegistry.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\defines.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\faac.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\faad2\include\faad.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\filters.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\RESOURCE.H
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# Begin Source File
-
-SOURCE=.\bitmap1.bmp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Logo.bmp
-# End Source File
-# End Group
-# End Target
-# End Project
--- a/plugins/cooledit/FAAD.rc
+++ /dev/null
@@ -1,131 +1,0 @@
-//Microsoft Developer Studio generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_COMPRESSION DIALOG DISCARDABLE  0, 0, 184, 126
-STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
-CAPTION "MPEG4-AAC options"
-FONT 8, "MS Sans Serif"
-BEGIN
-    CONTROL         "Automatic configuration",IDC_CHK_AUTOCFG,"Button",
-                    BS_AUTOCHECKBOX | WS_TABSTOP,4,4,90,10
-    CONTROL         "MPEG4",IDC_RADIO_MPEG4,"Button",BS_AUTORADIOBUTTON | 
-                    WS_GROUP,8,29,42,10
-    CONTROL         "MPEG2",IDC_RADIO_MPEG2,"Button",BS_AUTORADIOBUTTON,8,42,
-                    41,9
-    CONTROL         "Main",IDC_RADIO_MAIN,"Button",BS_AUTORADIOBUTTON | 
-                    WS_GROUP,12,73,31,10
-    CONTROL         "Low",IDC_RADIO_LOW,"Button",BS_AUTORADIOBUTTON,12,85,29,
-                    10
-    CONTROL         "SSR",IDC_RADIO_SSR,"Button",BS_AUTORADIOBUTTON | 
-                    WS_DISABLED,12,97,31,10
-    CONTROL         "LTP",IDC_RADIO_LTP,"Button",BS_AUTORADIOBUTTON,12,109,
-                    29,10
-    CONTROL         "Raw",IDC_RADIO_RAW,"Button",BS_AUTORADIOBUTTON | 
-                    WS_GROUP,59,29,42,10
-    CONTROL         "ADTS",IDC_RADIO_ADTS,"Button",BS_AUTORADIOBUTTON,59,42,
-                    41,9
-    CONTROL         "Allow Mid/Side",IDC_ALLOWMIDSIDE,"Button",
-                    BS_AUTOCHECKBOX | WS_TABSTOP,108,21,63,10
-    CONTROL         "Use TNS",IDC_USETNS,"Button",BS_AUTOCHECKBOX | 
-                    WS_TABSTOP,108,33,45,10
-    CONTROL         "Use LFE channel",IDC_USELFE,"Button",BS_AUTOCHECKBOX | 
-                    WS_DISABLED | WS_TABSTOP,108,46,67,10
-    COMBOBOX        IDC_CB_BITRATE,132,68,48,30,CBS_DROPDOWN | WS_VSCROLL | 
-                    WS_TABSTOP
-    COMBOBOX        IDC_CB_BANDWIDTH,132,85,48,30,CBS_DROPDOWN | WS_VSCROLL | 
-                    WS_TABSTOP
-    DEFPUSHBUTTON   "OK",IDOK,72,107,36,14
-    PUSHBUTTON      "Cancel",IDCANCEL,108,107,36,14
-    PUSHBUTTON      "About",IDC_BTN_ABOUT,144,107,36,14
-    GROUPBOX        "AAC type",IDC_STATIC,4,18,48,38
-    GROUPBOX        "Profile",IDC_STATIC,4,62,48,59
-    LTEXT           "Bitrate per channel",IDC_STATIC,59,73,60,8
-    LTEXT           "Bandwidth",IDC_STATIC,59,89,34,8
-    GROUPBOX        "Header",IDC_STATIC,55,18,48,38
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE DISCARDABLE 
-BEGIN
-    "resource.h\0"
-END
-
-2 TEXTINCLUDE DISCARDABLE 
-BEGIN
-    "#include ""afxres.h""\r\n"
-    "\0"
-END
-
-3 TEXTINCLUDE DISCARDABLE 
-BEGIN
-    "\r\n"
-    "\0"
-END
-
-#endif    // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO DISCARDABLE 
-BEGIN
-    IDD_COMPRESSION, DIALOG
-    BEGIN
-        LEFTMARGIN, 4
-        RIGHTMARGIN, 180
-        TOPMARGIN, 4
-        BOTTOMMARGIN, 121
-    END
-END
-#endif    // APSTUDIO_INVOKED
-
-#endif    // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif    // not APSTUDIO_INVOKED
-
--- a/plugins/cooledit/Faac.cpp
+++ b/plugins/cooledit/Faac.cpp
@@ -20,15 +20,17 @@
 */
 
 #include <windows.h>
-#include <stdio.h>  // FILE *
-#include "filters.h" //CoolEdit
+#include <stdio.h>		// FILE *
+#include "filters.h"	// CoolEdit
 #include "resource.h"
 #include "faac.h"
+#include "faad.h"		// FAAD2 version
+#include <win32_ver.h>	// mpeg4ip version
 #include "CRegistry.h"
 #include "defines.h"
 
+// *********************************************************************************************
 
-
 typedef struct output_tag  // any special vars associated with output file
 {
 FILE			*fFile;
@@ -45,8 +47,8 @@
 BYTE			bStopEnc;
 } MYOUTPUT;
 
+// -----------------------------------------------------------------------------------------------
 
-
 typedef struct mc
 {
 bool					AutoCfg;
@@ -53,12 +55,10 @@
 faacEncConfiguration	EncCfg;
 } MYCFG;
 
-
-
 // *********************************************************************************************
+// *********************************************************************************************
+// *********************************************************************************************
 
-
-
 void RD_Cfg(MYCFG *cfg) 
 { 
 CRegistry reg;
@@ -131,11 +131,8 @@
 			DISABLE_LTP \
 }
 
-__declspec(dllexport) BOOL FAR PASCAL DIALOGMsgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
+BOOL DIALOGMsgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 {
-//DWORD dwOptions=(DWORD)lParam;
-
-
 	switch(Message)
 	{
 	case WM_INITDIALOG:
@@ -175,11 +172,11 @@
 			switch(cfg.EncCfg.outputFormat)
 			{
 			case 0:
-              CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);
-		      break;
+				CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);
+				break;
 			case 1:
-              CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
-		      break;
+				CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
+				break;
 			}
 
 			CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, cfg.EncCfg.allowMidside);
@@ -216,7 +213,7 @@
 		break; // End of WM_INITDIALOG                                 
 
 	case WM_CLOSE:
-       // Closing the Dialog behaves the same as Cancel               
+		// Closing the Dialog behaves the same as Cancel               
 		PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
 		break; // End of WM_CLOSE                                      
 
@@ -253,19 +250,19 @@
 				GetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf, 50);
 				switch(*buf)
 				{
-				case 'A': 
-						cfg.EncCfg.bitRate=0;
-						break;
+				case 'A': // Auto
+					cfg.EncCfg.bitRate=0;
+					break;
 				default:
-						cfg.EncCfg.bitRate=1000*GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
+					cfg.EncCfg.bitRate=1000*GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
 				}
 				GetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf, 50);
 				switch(*buf)
 				{
-				case 'A': 
+				case 'A': // Auto
 					cfg.EncCfg.bandWidth=0;
 					break;
-				case 'F':
+				case 'F': // Full
 					cfg.EncCfg.bandWidth=0xffffffff;
 					break;
 				default:
@@ -279,33 +276,35 @@
 			break;
 
         case IDCANCEL:
-             // Ignore data values entered into the controls        
-             // and dismiss the dialog window returning FALSE
-             EndDialog(hWndDlg, FALSE);
-             break;
+			// Ignore data values entered into the controls        
+			// and dismiss the dialog window returning FALSE
+			EndDialog(hWndDlg, FALSE);
+			break;
 
 		case IDC_BTN_ABOUT:
-           	 {
-		     char buf[256];
- 			  sprintf(buf,	APP_NAME " plugin %s by 4N\n"
-							"This plugin uses FAAC encoder engine v%g and FAAD2 decoder engine\n\n"
-							"Compiled on %s\n",
-							APP_VER,
-							FAACENC_VERSION,
-							__DATE__
-						  );
-		      MessageBox(hWndDlg, buf, "About", MB_OK);
-             }
-             break;
-
+			{
+			char buf[512];
+				sprintf(buf,
+						APP_NAME " plugin " APP_VER " by Antonio Foranna\n\n"
+						"This plugin uses:\n"
+						"\tFAAC v%g and FAAD2 v" FAAD2_VERSION " (.aac files),\n"
+						"\t" PACKAGE " v" VERSION " (.mp4 files).\n\n"
+						"Compiled on %s\n",
+						FAACENC_VERSION,
+						__DATE__
+						);
+				MessageBox(hWndDlg, buf, "About", MB_OK);
+			}
+			break;
+			
 		case IDC_RADIO_MPEG4:
-	         EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			 break;
-
+			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;
+			EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
+			DISABLE_LTP
+				break;
 		}
 		break; // End of WM_COMMAND
 	default: 
@@ -316,19 +315,16 @@
 } // End of DIALOGSMsgProc                                      
 // *********************************************************************************************
 
-__declspec(dllexport) DWORD FAR PASCAL FilterGetOptions(HWND hWnd, HINSTANCE hInst, long lSamprate, WORD wChannels, WORD wBitsPerSample, DWORD dwOptions) // return 0 if no options box
+DWORD FAR PASCAL FilterGetOptions(HWND hWnd, HINSTANCE hInst, long lSamprate, WORD wChannels, WORD wBitsPerSample, DWORD dwOptions) // return 0 if no options box
 {
 long nDialogReturn=0;
-FARPROC lpfnDIALOGMsgProc;
-	
-	lpfnDIALOGMsgProc=GetProcAddress(hInst,(LPCSTR)MAKELONG(20,0));			
-	nDialogReturn=(long)DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_COMPRESSION), (HWND)hWnd, (DLGPROC)lpfnDIALOGMsgProc, dwOptions);
+	nDialogReturn=(long)DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_COMPRESSION), (HWND)hWnd, (DLGPROC)DIALOGMsgProc, dwOptions);
 
 	return nDialogReturn;
 }
 // *********************************************************************************************
 
-__declspec(dllexport) void FAR PASCAL GetSuggestedSampleType(LONG *lplSamprate, WORD *lpwBitsPerSample, WORD *wChannels)
+void FAR PASCAL GetSuggestedSampleType(LONG *lplSamprate, WORD *lpwBitsPerSample, WORD *wChannels)
 {
 	*lplSamprate=0; // don't care
 	*lpwBitsPerSample= *lpwBitsPerSample<=24 ? 0: 24;
@@ -336,31 +332,8 @@
 }
 // *********************************************************************************************
 
-__declspec(dllexport) DWORD FAR PASCAL FilterWriteFirstSpecialData(HANDLE hInput, 
-	SPECIALDATA * psp)
+void FAR PASCAL CloseFilterOutput(HANDLE hOutput)
 {
-	return 0;
-}
-// *********************************************************************************************
-
-__declspec(dllexport) DWORD FAR PASCAL FilterWriteNextSpecialData(HANDLE hInput, SPECIALDATA * psp)
-{	
-	return 0;
-// only has 1 special data!  Otherwise we would use psp->hSpecialData
-// as either a counter to know which item to retrieve next, or as a
-// structure with other state information in it.
-}
-// *********************************************************************************************
-
-__declspec(dllexport) DWORD FAR PASCAL FilterWriteSpecialData(HANDLE hOutput,
-	LPCSTR szListType, LPCSTR szType, char * pData,DWORD dwSize)
-{
-	return 0;
-}
-// *********************************************************************************************
-
-__declspec(dllexport) void FAR PASCAL CloseFilterOutput(HANDLE hOutput)
-{
 	if(!hOutput)
 		return;
 
@@ -392,7 +365,7 @@
 #define ERROR_OFO(msg) \
 { \
 	if(msg) \
-		MessageBox(0, msg, APP_NAME " plugin", MB_OK); \
+		MessageBox(0, msg, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
 	if(hOutput) \
 	{ \
 		GlobalUnlock(hOutput); \
@@ -401,7 +374,7 @@
 	return 0; \
 }
 
-__declspec(dllexport) HANDLE FAR PASCAL OpenFilterOutput(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long lSize, long far *lpChunkSize, DWORD dwOptions)
+HANDLE FAR PASCAL OpenFilterOutput(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long lSize, long far *lpChunkSize, DWORD dwOptions)
 {
 HANDLE			hOutput;
 MYOUTPUT		*mo;
@@ -417,11 +390,14 @@
 	mo=(MYOUTPUT *)GlobalLock(hOutput);
 	memset(mo,0,sizeof(MYOUTPUT));
 
-// open the aac output file 
+	// open the aac output file 
 	if(!(mo->fFile=fopen(lpstrFilename, "wb")))
 		ERROR_OFO("Can't create file");
 
-// open the encoder library
+	// use bufferized stream
+	setvbuf(mo->fFile,NULL,_IOFBF,32767);
+
+	// open the encoder library
 	if(!(mo->hEncoder=faacEncOpen(lSamprate, wChannels, &samplesInput, &maxBytesOutput)))
 		ERROR_OFO("Can't init library");
 
@@ -453,9 +429,8 @@
 
 		if(!faacEncSetConfiguration(mo->hEncoder, myFormat))
 			ERROR_OFO("Unsupported parameters");
-	 }
+	}
 
-	mo->fFile=mo->fFile;
 	mo->lSize=lSize;
 	mo->lSamprate=lSamprate;
 	mo->wBitsPerSample=wBitsPerSample;
@@ -462,13 +437,11 @@
 	mo->wChannels=wChannels;
 	strcpy(mo->szNAME,lpstrFilename);
 
-	mo->hEncoder=mo->hEncoder;
-    mo->bitbuf=mo->bitbuf;
 	mo->maxBytesOutput=maxBytesOutput;
 	mo->samplesInput=samplesInput;
 	mo->bStopEnc=0;
 
-// init flushing process
+	// init flushing process
     bytesEncoded=faacEncEncode(mo->hEncoder, 0, 0, mo->bitbuf, maxBytesOutput); // initializes the flushing process
     if(bytesEncoded>0)
 	{
@@ -486,7 +459,7 @@
 #define ERROR_WFO(msg) \
 { \
 	if(msg) \
-		MessageBox(0, msg, APP_NAME " plugin", MB_OK); \
+		MessageBox(0, msg, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
 	if(hOutput) \
 	{ \
 		mo->bStopEnc=1; \
@@ -495,7 +468,7 @@
 	return 0; \
 }
 
-__declspec(dllexport) DWORD FAR PASCAL WriteFilterOutput(HANDLE hOutput, unsigned char far *buf, long lBytes)
+DWORD FAR PASCAL WriteFilterOutput(HANDLE hOutput, unsigned char far *buf, long lBytes)
 {
 	if(!hOutput)
 		return 0;
--- a/plugins/cooledit/Faad.cpp
+++ b/plugins/cooledit/Faad.cpp
@@ -20,17 +20,27 @@
 */
 
 #include <windows.h>
-#include <stdio.h>  // FILE *
-#include "filters.h" //CoolEdit
-#include "faad.h"
-#include "faac.h"
-#include "aacinfo.h"
-#include "..\..\..\faad2\common\mp4v2\mp4.h"
-#include "defines.h"
+#include <stdio.h>		// FILE *
+#include "filters.h"	// CoolEdit
+#include "defines.h"	// my defines
+#include <faac.h>
+#include <faad.h>
+#include <mp4.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <aacinfo.h>	// get_AAC_format()
+#ifdef __cplusplus
+}
+#endif
 
+// *********************************************************************************************
 
+#define MAX_CHANNELS	2
+#define	FAAD_STREAMSIZE	(FAAD_MIN_STREAMSIZE*MAX_CHANNELS)
 
-#define MAX_CHANNELS 2
+// -----------------------------------------------------------------------------------------------
+
 #define FREE(ptr) \
 { \
 	if(ptr) \
@@ -38,76 +48,96 @@
 	ptr=0; \
 }
 
+// *********************************************************************************************
 
 typedef struct input_tag // any special vars associated with input file
 {
 //AAC
- FILE			*aacFile;
- DWORD			lSize;    
- DWORD			tagsize;
- DWORD			bytes_read;		// from file
- DWORD			bytes_consumed;	// by faadDecDecode
- long			bytes_into_buffer;
- unsigned char	*buffer;
+FILE			*aacFile;
+DWORD			src_size;		// size of compressed file
+DWORD			tagsize;
+DWORD			bytes_read;		// from file
+DWORD			bytes_consumed;	// by faadDecDecode
+long			bytes_into_buffer;
+unsigned char	*buffer;
 
 //MP4
- MP4FileHandle	mp4File;
- MP4SampleId	sampleId, numSamples;
- int			track;
- BYTE			type;
+MP4FileHandle	mp4File;
+MP4SampleId		sampleId,
+				numSamples;
+int				track;
+BYTE			type;
 
 // GLOBAL
- faacDecHandle	hDecoder;
- faadAACInfo	file_info;
- __int32		len_ms;
- BYTE			wChannels;
- DWORD			dwSamprate;
- WORD			wBitsPerSample;
- char			szName[256];
- DWORD			full_size;		// size of decoded file needed to set the length of progress bar
- bool			IsAAC;
+faacDecHandle	hDecoder;
+faadAACInfo		file_info;
+DWORD			len_ms;			// length of file in milliseconds
+WORD			wChannels;
+DWORD			dwSamprate;
+WORD			wBitsPerSample;
+// char			*src_name;		// name of compressed file
+DWORD			dst_size;		// size of decoded file. It's needed to set the length of progress bar
+bool			IsAAC;
 } MYINPUT;
+// -----------------------------------------------------------------------------------------------
 
 static const char* mpeg4AudioNames[]=
 {
- "Raw PCM",
- "AAC Main",
- "AAC Low Complexity",
- "AAC SSR",
- "AAC LTP",
- "Reserved",
- "AAC Scalable",
- "TwinVQ",
- "CELP",
- "HVXC",
- "Reserved",
- "Reserved",
- "TTSI",
- "Wavetable synthesis",
- "General MIDI",
- "Algorithmic Synthesis and Audio FX",
- "Reserved"
+	"Raw PCM",
+	"AAC Main",
+	"AAC Low Complexity",
+	"AAC SSR",
+	"AAC LTP",
+	"Reserved",
+	"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",
+	"Reserved",
+	"ER AAC LTP",
+	"ER AAC Scalable",
+	"ER TwinVQ",
+	"ER BSAC",
+	"ER AAC LD",
+	"ER CELP",
+	"ER HVXC",
+	"ER HILN",
+	"ER Parametric",
+	"Reserved",
+	"Reserved",
+	"Reserved",
+	"Reserved"
 };
+// *********************************************************************************************
 
 int id3v2_tag(unsigned char *buffer)
 {
-	if(StringComp((const char *)buffer, "ID3", 3) == 0) 
+	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);
+	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;
 }
+// *********************************************************************************************
 
 int GetAACTrack(MP4FileHandle infile)
 {
-    /* find AAC track */
+    // find AAC track
     int i, rc;
 	int numTracks = MP4GetNumberOfTracks(infile, NULL, 0);
 
@@ -119,11 +149,11 @@
         if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE))
         {
             unsigned char *buff = NULL;
-            int buff_size = 0;
+            unsigned __int32 buff_size = 0;
             unsigned char dummy2_8, dummy3_8, dummy4_8, dummy5_8, dummy6_8,
                 dummy7_8, dummy8_8;
-            unsigned int dummy1_32;
-            MP4GetTrackESConfiguration(infile, trackId, &buff, &buff_size);
+            unsigned long dummy1_32;
+            MP4GetTrackESConfiguration(infile, trackId, (unsigned __int8 **)&buff, &buff_size);
 
             if (buff)
             {
@@ -138,16 +168,15 @@
         }
     }
 
-    /* can't decode this */
+    // can't decode this
     return -1;
 }
 
-
 // *********************************************************************************************
+// *********************************************************************************************
+// *********************************************************************************************
 
-
-
-__declspec(dllexport) BOOL FAR PASCAL FilterUnderstandsFormat(LPSTR filename)
+BOOL FAR PASCAL FilterUnderstandsFormat(LPSTR filename)
 {
 WORD len;
 
@@ -159,24 +188,24 @@
 }
 // *********************************************************************************************
 
-__declspec(dllexport) long FAR PASCAL FilterGetFileSize(HANDLE hInput)
+long FAR PASCAL FilterGetFileSize(HANDLE hInput)
 {
-DWORD full_size;
+DWORD dst_size;
 
 	if(hInput)  
 	{
 		MYINPUT *mi;
 		mi=(MYINPUT *)GlobalLock(hInput);
-		full_size=mi->full_size;
+		dst_size=mi->dst_size;
 		
 		GlobalUnlock(hInput);
 	}
 
-	return full_size;
+	return dst_size;
 }
 // *********************************************************************************************
 
-__declspec(dllexport) DWORD FAR PASCAL FilterOptionsString(HANDLE hInput, LPSTR szString)
+DWORD FAR PASCAL FilterOptionsString(HANDLE hInput, LPSTR szString)
 {
 	if(!hInput)
 	{
@@ -188,10 +217,10 @@
 MYINPUT *mi;
 
 mi=(MYINPUT *)GlobalLock(hInput);
-	
+
 	lstrcpy(szString,"");
 	
-	if(mi->file_info.version == 2)
+	if(mi->file_info.version==2)
 		lstrcat(szString,"MPEG2 - ");
 	else
 		lstrcat(szString,"MPEG4 - ");
@@ -205,7 +234,7 @@
 		{
 		case 0:
 			lstrcat(szString,"RAW\n");
-			return 0L;
+			break;
 		case 1:
 			lstrcat(szString,"ADIF\n");
 			break;
@@ -231,12 +260,7 @@
 		}
 	}
 	else  // MP4 file -----------------------------------------------------------------------------
-    {
-        if (mi->type > 16)
-            lstrcat(szString,"Type not known");
-        else
-            lstrcat(szString,mpeg4AudioNames[mi->type]);
-    }
+		lstrcat(szString,mpeg4AudioNames[mi->type]);
 	
 	GlobalUnlock(hInput);
 
@@ -244,22 +268,8 @@
 }
 // *********************************************************************************************
 
-__declspec(dllexport) DWORD FAR PASCAL FilterGetFirstSpecialData(HANDLE hInput, 
-	SPECIALDATA * psp)
+void FAR PASCAL CloseFilterInput(HANDLE hInput)
 {
-	return 0L;
-}
-// *********************************************************************************************
-    
-__declspec(dllexport) DWORD FAR PASCAL FilterGetNextSpecialData(HANDLE hInput, SPECIALDATA * psp)
-{	return 0; // only has 1 special data!  Otherwise we would use psp->hSpecialData
-			  // as either a counter to know which item to retrieve next, or as a
-			  // structure with other state information in it.
-}
-// *********************************************************************************************
-
-__declspec(dllexport) void FAR PASCAL CloseFilterInput(HANDLE hInput)
-{
 	if(!hInput)
 		return;
 
@@ -267,13 +277,13 @@
 
 	mi=(MYINPUT far *)GlobalLock(hInput);
 	
-// AAC file ---------------------------------------------------------------------
+// AAC file --------------------------------------------------------------------------------------
 	if(mi->aacFile)
 		fclose(mi->aacFile);
 	
 	FREE(mi->buffer);
 	
-// MP4 file ---------------------------------------------------------------------
+// MP4 file --------------------------------------------------------------------------------------
 	if(mi->mp4File)
 		MP4Close(mi->mp4File);
 	
@@ -280,6 +290,9 @@
 	if(mi->hDecoder)
 		faacDecClose(mi->hDecoder);
 	
+// GLOBAL ----------------------------------------------------------------------------------------
+//	FREE(mi->src_name);
+
 	GlobalUnlock(hInput);
 	GlobalFree(hInput);
 }
@@ -288,7 +301,7 @@
 #define ERROR_OFI(msg) \
 { \
 	if(msg) \
-		MessageBox(0, msg, APP_NAME " plugin", MB_OK); \
+		MessageBox(0, msg, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
 	if(hInput) \
 	{ \
 		GlobalUnlock(hInput); \
@@ -298,15 +311,14 @@
 }
 
 // return handle that will be passed in to close, and write routines
-__declspec(dllexport) HANDLE FAR PASCAL OpenFilterInput(LPSTR lpstrFilename, long far *lSamprate, WORD far *wBitsPerSample, WORD far *wChannels, HWND hWnd, long far *lChunkSize)
+HANDLE FAR PASCAL OpenFilterInput(LPSTR lpstrFilename, long far *lSamprate, WORD far *wBitsPerSample, WORD far *wChannels, HWND hWnd, long far *lChunkSize)
 {
 HANDLE					hInput;
 MYINPUT					*mi;
 faacDecConfigurationPtr	config;
 DWORD					samplerate;
-BYTE channels;
-DWORD					tmp;
-BYTE					BitsPerSample=16;
+BYTE					channels,
+						BitsPerSample=16;
 
 	hInput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(MYINPUT));
 	if(!hInput)
@@ -322,69 +334,60 @@
 	MP4Duration			length;
 	int					track;
 	unsigned __int32	buffer_size;
-	unsigned long		timeScale;
-    BYTE sf;
-    BYTE dummy1, dummy2, dummy3, dummy4;
+	DWORD				timeScale;
+	BYTE				sf, dummy8;
 
-		if(!(mi->mp4File = MP4Read(lpstrFilename, 0)))
+		if(!(mi->mp4File=MP4Read(lpstrFilename, 0)))
 		    ERROR_OFI("Error opening file");
 
-		if ((track = GetAACTrack(mi->mp4File)) < 0)
-			ERROR_OFI("Unable to find correct AAC sound track in the MP4 file");
+		if ((track=GetAACTrack(mi->mp4File))<0)
+			ERROR_OFI(0); //"Unable to find correct AAC sound track");
 
 		if(!(mi->hDecoder=faacDecOpen()))
-			ERROR_OFI("Can't init library");
+			ERROR_OFI("Error initializing decoder library");
 
-		mi->buffer = NULL;
-		buffer_size = 0;
-		MP4GetTrackESConfiguration(mi->mp4File, track, &mi->buffer, &buffer_size);
+		MP4GetTrackESConfiguration(mi->mp4File, track, (unsigned __int8 **)&mi->buffer, &buffer_size);
 	    if(!mi->buffer)
 			ERROR_OFI("MP4GetTrackESConfiguration");
-
-		AudioSpecificConfig(mi->buffer, &timeScale, &channels, &sf, &mi->type, &dummy1, &dummy2,
-            &dummy3, &dummy4);
-        if (mi->type <= 16)
-        {
-            if(memcmp(mpeg4AudioNames[mi->type],"AAC",3))
-                ERROR_OFI(0);
-        } else
-            ERROR_OFI(0);
+		AudioSpecificConfig(mi->buffer, &timeScale, &channels, &sf, &mi->type, &dummy8, &dummy8, &dummy8, &dummy8);
 		if(faacDecInit2(mi->hDecoder, mi->buffer, buffer_size, &samplerate, &channels) < 0)
 			ERROR_OFI("Error initializing decoder library");
-
 	    FREE(mi->buffer);
 
-		length = MP4GetTrackDuration(mi->mp4File, track);
-		mi->len_ms=(DWORD) MP4ConvertFromTrackDuration(mi->mp4File, track, length, MP4_MSECS_TIME_SCALE);
-		mi->file_info.bitrate=(int)MP4GetTrackIntegerProperty(mi->mp4File, track, "mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.avgBitrate");
-		mi->numSamples = MP4GetTrackNumberOfSamples(mi->mp4File, track);
-
+		length=MP4GetTrackDuration(mi->mp4File, track);
+		mi->len_ms=(DWORD)MP4ConvertFromTrackDuration(mi->mp4File, track, length, MP4_MSECS_TIME_SCALE);
+//		mi->file_info.bitrate=(int)MP4GetTrackIntegerProperty(mi->mp4File, track, "mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.avgBitrate");
+		mi->file_info.bitrate=MP4GetTrackBitRate(mi->mp4File, track);
+		mi->file_info.version=MP4GetTrackAudioType(mi->mp4File, track)==MP4_MPEG4_AUDIO_TYPE ? 4 : 2;
+		mi->numSamples=MP4GetTrackNumberOfSamples(mi->mp4File, track);
 		mi->track=track;
 		mi->sampleId=1;
 	}
 	else // AAC file ------------------------------------------------------------------------------
 	{   
-	DWORD	pos; // into the file. Needed to obtain length of file
 	DWORD	read;
-	int		*seek_table;
+	DWORD	*seek_table=0;
+	int		seek_table_length=0;
 	long	tagsize;
+	DWORD	tmp;
 
 		if(!(mi->aacFile=fopen(lpstrFilename,"rb")))
 			ERROR_OFI("Error opening file"); 
 
-		pos=ftell(mi->aacFile);
+		// use bufferized stream
+		setvbuf(mi->aacFile,NULL,_IOFBF,32767);
+
+		// get size of file
+		tmp=ftell(mi->aacFile);
 		fseek(mi->aacFile, 0, SEEK_END);
-		mi->lSize=ftell(mi->aacFile);
-		fseek(mi->aacFile, pos, SEEK_SET);
+		mi->src_size=ftell(mi->aacFile);
+		fseek(mi->aacFile, tmp, SEEK_SET);
 
-		if(!(mi->buffer=(BYTE *)malloc(768*MAX_CHANNELS)))
+		if(!(mi->buffer=(BYTE *)malloc(FAAD_STREAMSIZE)))
 			ERROR_OFI("Memory allocation error"); 
-		memset(mi->buffer, 0, 768*MAX_CHANNELS);
+		memset(mi->buffer,0,FAAD_STREAMSIZE);
 
-		if(mi->lSize<768*MAX_CHANNELS)
-			tmp=mi->lSize;
-		else
-			tmp=768*MAX_CHANNELS;
+		tmp=mi->src_size<FAAD_STREAMSIZE ? mi->src_size : FAAD_STREAMSIZE;
 		read=fread(mi->buffer, 1, tmp, mi->aacFile);
 		if(read==tmp)
 		{
@@ -394,15 +397,26 @@
 		else
 			ERROR_OFI("fread");
 
-		tagsize=id3v2_tag(mi->buffer);
-		if(tagsize)
+		if(tagsize=id3v2_tag(mi->buffer))
 		{
-			memcpy(mi->buffer,mi->buffer+tagsize,768*MAX_CHANNELS - tagsize);
-
-			if(mi->bytes_read+tagsize<mi->lSize)
-				tmp=tagsize;
+			if(tagsize>(long)mi->src_size)
+				ERROR_OFI("Corrupt stream!");
+			if(tagsize<mi->bytes_into_buffer)
+			{
+				mi->bytes_into_buffer-=tagsize;
+				memcpy(mi->buffer,mi->buffer+tagsize,mi->bytes_into_buffer);
+			}
 			else
-				tmp=mi->lSize-mi->bytes_read;
+			{
+				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)
 			{
@@ -411,23 +425,25 @@
 			}
 			else
 				ERROR_OFI("fread");
+
+			mi->tagsize=tagsize;
 		}
-		mi->tagsize=tagsize;
 
 		if(!(mi->hDecoder=faacDecOpen()))
 			ERROR_OFI("Can't open library");
 
-		if(seek_table=(int *)malloc(sizeof(int)*10800))
+		if(get_AAC_format(lpstrFilename, &mi->file_info, &seek_table, &seek_table_length, 0))
 		{
-			if(get_AAC_format(lpstrFilename, &(mi->file_info), seek_table)<0)
-				ERROR_OFI("Error retrieving information form input file");
 			FREE(seek_table);
+			ERROR_OFI("Error retrieving information form input file");
 		}
+		FREE(seek_table);
+
 		if(mi->file_info.headertype==0)
 		{
-			config = faacDecGetCurrentConfiguration(mi->hDecoder);
-			config->defObjectType = mi->file_info.object_type;
-			config->defSampleRate = mi->file_info.sampling_rate;
+			config=faacDecGetCurrentConfiguration(mi->hDecoder);
+			config->defObjectType=mi->file_info.object_type;
+			config->defSampleRate=mi->file_info.sampling_rate;
 			config->outputFormat=FAAD_FMT_16BIT;
 			faacDecSetConfiguration(mi->hDecoder, config);
 		}
@@ -435,13 +451,15 @@
 		if((mi->bytes_consumed=faacDecInit(mi->hDecoder, mi->buffer, &samplerate, &channels)) < 0)
 			ERROR_OFI("Can't init library");
 		mi->bytes_into_buffer-=mi->bytes_consumed;
-// if(mi->bytes_consumed>0) faacDecInit reports there is an header to skip
-// this operation will be done in ReadFilterInput
-
-		mi->len_ms=(DWORD)((1000*((float)mi->lSize*8))/mi->file_info.bitrate);
+/*
+		if(mi->bytes_consumed>0)
+			faacDecInit reports there is an header to skip
+		this operation will be done in ReadFilterInput
+*/
+		mi->len_ms=(DWORD)((1000*((float)mi->src_size*8))/mi->file_info.bitrate);
 	} // END AAC file -----------------------------------------------------------------------------
 
-	config = faacDecGetCurrentConfiguration(mi->hDecoder);
+	config=faacDecGetCurrentConfiguration(mi->hDecoder);
 	switch(config->outputFormat)
 	{
 	case FAAD_FMT_16BIT:
@@ -458,9 +476,9 @@
 	}
 
 	if(mi->len_ms)
-		mi->full_size=(DWORD)(mi->len_ms*((float)samplerate/1000)*channels*(BitsPerSample/8));
+		mi->dst_size=(DWORD)(mi->len_ms*((float)samplerate/1000)*channels*(BitsPerSample/8));
 	else
-		mi->full_size=mi->lSize; // corrupted stream?
+		mi->dst_size=mi->src_size; // corrupt stream?
 
 	*lSamprate=samplerate;
 	*wBitsPerSample=BitsPerSample;
@@ -470,7 +488,7 @@
 	mi->wChannels=(WORD)channels;
 	mi->dwSamprate=samplerate;
 	mi->wBitsPerSample=*wBitsPerSample;
-	strcpy(mi->szName,lpstrFilename);
+//	mi->src_name=strdup(lpstrFilename);
 
 	GlobalUnlock(hInput);
 
@@ -481,13 +499,13 @@
 #define ERROR_RFI(msg) \
 { \
 	if(msg) \
-		MessageBox(0, msg, APP_NAME " plugin", MB_OK); \
+		MessageBox(0, msg, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
 	if(hInput) \
 		GlobalUnlock(hInput); \
 	return 0; \
 }
 
-__declspec(dllexport) DWORD FAR PASCAL ReadFilterInput(HANDLE hInput, unsigned char far *bufout, long lBytes)
+DWORD FAR PASCAL ReadFilterInput(HANDLE hInput, unsigned char far *bufout, long lBytes)
 {
 	if(!hInput)
 		ERROR_RFI("Memory allocation error: hInput");
@@ -513,7 +531,7 @@
 			if(mi->sampleId>=mi->numSamples)
 				ERROR_RFI(0);
 
-			rc=MP4ReadSample(mi->mp4File, mi->track, mi->sampleId++, &buffer, &buffer_size, NULL, NULL, NULL, NULL);
+			rc=MP4ReadSample(mi->mp4File, mi->track, mi->sampleId++, (unsigned __int8 **)&buffer, &buffer_size, NULL, NULL, NULL, NULL);
 			if(rc==0 || buffer==NULL)
 			{
 				FREE(buffer);
@@ -536,12 +554,12 @@
 				if(mi->bytes_into_buffer)
 					memcpy(buffer,buffer+mi->bytes_consumed,mi->bytes_into_buffer);
 
-				if(mi->bytes_read<mi->lSize)
+				if(mi->bytes_read<mi->src_size)
 				{
-					if(mi->bytes_read+mi->bytes_consumed<mi->lSize)
+					if(mi->bytes_read+mi->bytes_consumed<mi->src_size)
 						tmp=mi->bytes_consumed;
 					else
-						tmp=mi->lSize-mi->bytes_read;
+						tmp=mi->src_size-mi->bytes_read;
 					read=fread(buffer+mi->bytes_into_buffer, 1, tmp, mi->aacFile);
 					if(read==tmp)
 					{
@@ -557,7 +575,7 @@
 			}
 
 			if(mi->bytes_into_buffer<1)
-				if(mi->bytes_read<mi->lSize)
+				if(mi->bytes_read<mi->src_size)
 					ERROR_RFI("ReadFilterInput: buffer empty!")
 				else
 					return 0;
@@ -573,7 +591,7 @@
 	GlobalUnlock(hInput);
 
 	if(frameInfo.error)
-		ERROR_RFI(faacDecGetErrorMessage(frameInfo.error));
+		ERROR_RFI((char *)faacDecGetErrorMessage(frameInfo.error));
 
 	return shorts_decoded;
 }
--- a/plugins/cooledit/Main.cpp
+++ b/plugins/cooledit/Main.cpp
@@ -82,7 +82,7 @@
 }
 
 // Fill COOLQUERY structure with information regarding this file filter
-__declspec(dllexport) short FAR PASCAL QueryCoolFilter(COOLQUERY far * cq)
+short FAR PASCAL QueryCoolFilter(COOLQUERY far * cq)
 {
 	lstrcpy(cq->szName, APP_NAME " Format");		
 	lstrcpy(cq->szCopyright, APP_NAME " codec");
@@ -90,11 +90,11 @@
 	lstrcpy(cq->szExt2,"MP4"); 
 	cq->lChunkSize=16384; 
 	cq->dwFlags=QF_RATEADJUSTABLE|QF_CANLOAD|QF_CANSAVE|QF_HASOPTIONSBOX;
- 	cq->Mono8=0xFF;
+ 	cq->Mono8=0xFF;		// supports all rates ???
  	cq->Mono16=0xFF;
  	cq->Mono24=0xFF;
  	cq->Mono32=0xFF;
- 	cq->Stereo8=0xFF; // supports all rates ???
+ 	cq->Stereo8=0xFF;
  	cq->Stereo16=0xFF;
  	cq->Stereo24=0xFF;
  	cq->Stereo32=0xFF;
--- /dev/null
+++ b/plugins/cooledit/aacInfoLib.dsp
@@ -1,0 +1,108 @@
+# Microsoft Developer Studio Project File - Name="aacInfoLib" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=aacInfoLib - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "aacInfoLib.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "aacInfoLib.mak" CFG="aacInfoLib - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "aacInfoLib - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "aacInfoLib - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "aacInfoLib - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "aacInfoLib___Win32_Release"
+# PROP BASE Intermediate_Dir "aacInfoLib___Win32_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /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"
+# ADD RSC /l 0x410 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF  "$(CFG)" == "aacInfoLib - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "aacInfoLib___Win32_Debug"
+# PROP BASE Intermediate_Dir "aacInfoLib___Win32_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /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
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF 
+
+# Begin Target
+
+# Name "aacInfoLib - Win32 Release"
+# Name "aacInfoLib - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\faad2\common\faad\aacinfo.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\faad2\common\faad\filestream.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\faad2\common\faad\aacinfo.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\faad2\common\faad\filestream.h
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null
+++ b/plugins/cooledit/aacInfoLib.dsw
@@ -1,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "aacInfoLib"=.\aacInfoLib.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
--- a/plugins/cooledit/aacinfo.h
+++ /dev/null
@@ -1,39 +1,0 @@
-/*
- * FAAD - Freeware Advanced Audio Decoder
- * Copyright (C) 2001 Menno Bakker
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * $Id: aacinfo.h,v 1.7 2002/08/22 22:58:57 menno Exp $
- */
-
-typedef struct {
-	int version;
-	int channels;
-	int sampling_rate;
-	int bitrate;
-	int length;
-	int object_type;
-	int headertype;
-} faadAACInfo;
-
-
-int get_AAC_format(char *filename, faadAACInfo *info, int *seek_table);
-
-static int f_id3v2_tag(HANDLE file);
-static int read_ADIF_header(HANDLE file, faadAACInfo *info);
-static int read_ADTS_header(HANDLE file, faadAACInfo *info, int *seek_table,
-							int tagsize);
-int StringComp(char const *str1, char const *str2, unsigned long len);
--- a/plugins/cooledit/defines.h
+++ b/plugins/cooledit/defines.h
@@ -1,3 +1,3 @@
 #define APP_NAME "MPEG4-AAC"
-#define APP_VER "v2.0 beta2"
+#define APP_VER "v2.0 beta4"
 #define REGISTRY_PROGRAM_NAME "SOFTWARE\\4N\\CoolEdit\\AAC-MPEG4"
--- a/plugins/cooledit/faad.def
+++ /dev/null
@@ -1,17 +1,0 @@
-EXPORTS
-	QueryCoolFilter	   @2
-	OpenFilterOutput   @3
-	CloseFilterOutput  @4
-	WriteFilterOutput  @5
-	OpenFilterInput    @6
-	CloseFilterInput   @7
-	ReadFilterInput    @8
-	FilterUnderstandsFormat @9
-	FilterGetOptions		@14 
-	FilterGetFileSize		@16
-	FilterOptionsString		@17
-	DIALOGMsgProc 			@20
-	FilterGetFirstSpecialData	@31
-	FilterGetNextSpecialData	@32
-	FilterWriteSpecialData		@33
-	GetSuggestedSampleType
--- a/plugins/cooledit/faad.dsw
+++ /dev/null
@@ -1,89 +1,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "FAAD"=.\FAAD.DSP - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-    Begin Project Dependency
-    Project_Dep_Name id3lib
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name libfaad
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name libfaac
-    End Project Dependency
-    Begin Project Dependency
-    Project_Dep_Name libmp4v2_st
-    End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "id3lib"=..\..\..\faad2\common\id3lib\libprj\id3lib.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "libfaac"=..\..\libfaac\libfaac.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "libfaad"=..\..\..\faad2\libfaad\libfaad.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "libmp4v2_st"=..\..\..\faad2\common\mp4v2\libmp4v2_st60.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
--- a/plugins/winamp/AACINFO.Cpp
+++ /dev/null
@@ -1,249 +1,0 @@
-/*
- * FAAC - Freeware Advanced Audio Decoder
- * Copyright (C) 2001 Menno Bakker
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * $Id: AACINFO.Cpp,v 1.1 2002/05/26 18:31:22 menno Exp $
- */
-
-#include <windows.h>
-#include "aacinfo.h"
-
-#define ADIF_MAX_SIZE 30 /* Should be enough */
-#define ADTS_MAX_SIZE 10 /* Should be enough */
-
-const int sample_rates[] = {96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000};
-
-static int read_ADIF_header(HANDLE file, FAACAACInfo *info)
-{
-	unsigned long tmp;
-	int bitstream;
-	unsigned char buffer[ADIF_MAX_SIZE];
-	int skip_size = 0;
-	int sf_idx;
-
-	/* Get ADIF header data */
-	
-	info->headertype = 1;
-
-	ReadFile(file, buffer, ADIF_MAX_SIZE, &tmp, 0);
-
-	/* copyright string */	
-	if(buffer[4] & 128)
-		skip_size += 9; /* skip 9 bytes */
-
-	bitstream = buffer[4 + skip_size] & 16;
-	info->bitrate = ((unsigned int)(buffer[4 + skip_size] & 0x0F)<<19)|
-		((unsigned int)buffer[5 + skip_size]<<11)|
-		((unsigned int)buffer[6 + skip_size]<<3)|
-		((unsigned int)buffer[7 + skip_size] & 0xE0);
-
-	if (bitstream == 0) {
-		info->object_type = ((buffer[9 + skip_size]&0x01)<<1)|((buffer[10 + skip_size]&0x80)>>7);
-		sf_idx = (buffer[10 + skip_size]&0x78)>>3;
-		info->channels = ((buffer[10 + skip_size]&0x07)<<1)|((buffer[11 + skip_size]&0x80)>>7);
-	} else {
-		info->object_type = (buffer[7 + skip_size] & 0x18)>>3;
-		sf_idx = ((buffer[7 + skip_size] & 0x07)<<1)|((buffer[8 + skip_size] & 0x80)>>7);
-		info->channels = (buffer[8 + skip_size]&0x78)>>3;
-	}
-	info->sampling_rate = sample_rates[sf_idx];
-
-	return 0;
-}
-
-static int read_ADTS_header(HANDLE file, FAACAACInfo *info, int *seek_table,
-							int tagsize)
-{
-	/* Get ADTS header data */
-	unsigned char buffer[ADTS_MAX_SIZE];
-	int frames, t_framelength = 0, frame_length, sr_idx, ID;
-	int second = 0, pos;
-	float frames_per_sec = 0;
-	unsigned long bytes;
-
-	info->headertype = 2;
-
-	/* Seek to the first frame */
-	SetFilePointer(file, tagsize, NULL, FILE_BEGIN);
-
-	/* Read all frames to ensure correct time and bitrate */
-	for(frames=0; /* */; frames++)
-	{
-		/* 12 bit SYNCWORD */
-		ReadFile(file, buffer, ADTS_MAX_SIZE, &bytes, 0);
-		if(bytes != ADTS_MAX_SIZE)
-		{
-			/* Bail out if no syncword found */
-			break;
-		}
-
-		if (!((buffer[0] == 0xFF)&&((buffer[1] & 0xF6) == 0xF0)))
-			break;
-
-		pos = SetFilePointer(file, 0, NULL, FILE_CURRENT) - ADTS_MAX_SIZE;
-
-		if(!frames)
-		{
-			/* fixed ADTS header is the same for every frame, so we read it only once */ 
-			/* Syncword found, proceed to read in the fixed ADTS header */ 
-			ID = buffer[1] & 0x08;
-			info->object_type = (buffer[2]&0xC0)>>6;
-			sr_idx = (buffer[2]&0x3C)>>2;
-			info->channels = ((buffer[2]&0x01)<<2)|((buffer[3]&0xC0)>>6);
-
-			frames_per_sec = sample_rates[sr_idx] / 1024.f;
-		}
-
-		/* ...and the variable ADTS header */
-		if (ID == 0) {
-			info->version = 4;
-			frame_length = (((unsigned int)buffer[4]) << 5) |
-				((unsigned int)buffer[5] >> 3);
-		} else { /* MPEG-2 */
-			info->version = 2;
-			frame_length = ((((unsigned int)buffer[3] & 0x3)) << 11)
-				| (((unsigned int)buffer[4]) << 3) | (buffer[5] >> 5);
-		}
-
-		t_framelength += frame_length;
-
-		if (frames > second*frames_per_sec)
-		{
-			seek_table[second] = pos;
-			second++;
-		}
-
-		SetFilePointer(file, frame_length - ADTS_MAX_SIZE, NULL, FILE_CURRENT);
-	}
-
-	info->sampling_rate = sample_rates[sr_idx];
-	info->bitrate = (int)(((t_framelength / frames) * (info->sampling_rate/1024.0)) +0.5)*8;
-	info->length = (int)((float)(frames/frames_per_sec))*1000;
-
-	return 0;
-}
-
-static int f_id3v2_tag(HANDLE file)
-{
-	unsigned char buffer[10];
-	unsigned long tmp;
-
-	ReadFile(file, buffer, 10, &tmp, 0);
-
-	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;
-
-		SetFilePointer(file, tagsize, NULL, FILE_BEGIN);
-
-		return tagsize;
-	} else {
-		SetFilePointer(file, 0, NULL, FILE_BEGIN);
-
-		return 0;
-	}
-}
-
-int get_AAC_format(char *filename, FAACAACInfo *info, int *seek_table)
-{
-	unsigned int tagsize;
-	HANDLE file;
-	unsigned long file_len;
-	unsigned char adxx_id[5];
-	unsigned long tmp;
-
-	if(StringComp(filename, "http://", 7) == 0)
-	{
-		info->version = 2;
-		info->length = 0;
-		info->bitrate = 128000;
-		info->sampling_rate = 44100;
-		info->channels = 2;
-		info->headertype = 0;
-		info->object_type = 1;
-
-		return 0;
-	}
-
-	file = CreateFile(filename, GENERIC_READ,
-		FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
-		OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0);
-	if (file == INVALID_HANDLE_VALUE)
-		return -1;
-
-	file_len = GetFileSize(file, NULL);
-
-	tagsize = f_id3v2_tag(file); /* Skip the tag, if it's there */
-	file_len -= tagsize;
-
-	ReadFile(file, adxx_id, 4, &tmp, 0);
-	SetFilePointer(file, tagsize, NULL, FILE_BEGIN);
-
-	adxx_id[5-1] = 0;
-
-	info->length = 0;
-
-	if(StringComp((const char *)adxx_id, "ADIF", 4) == 0)
-	{
-		read_ADIF_header(file, info);
-	}
-	else
-	{
-		if ((adxx_id[0] == 0xFF)&&((adxx_id[1] & 0xF6) == 0xF0))
-		{
-//			SetFilePointer(file, tagsize, NULL, FILE_BEGIN);
-			read_ADTS_header(file, info, seek_table, tagsize);
-		}
-		else
-		{
-			/* Unknown/headerless AAC file, assume format: */
-			info->version = 2;
-			info->bitrate = 128000;
-			info->sampling_rate = 44100;
-			info->channels = 2;
-			info->headertype = 0;
-			info->object_type = 1;
-		}
-	}
-
-	if (info->length == 0)
-		info->length = (int)((file_len/(((info->bitrate*8)/1024)*16))*1000);
-
-	CloseHandle(file);
-
-	return 0;
-}
-
-int StringComp(char const *str1, char const *str2, unsigned long len)
-{
-	signed int c1 = 0, c2 = 0;
-
-	while (len--) {
-		c1 = *str1++;
-		c2 = *str2++;
-
-		if (c1 == 0 || c1 != c2)
-			break;
-	}
-
-	return c1 - c2;
-}
--- a/plugins/winamp/AACINFO.H
+++ /dev/null
@@ -1,39 +1,0 @@
-/*
- * FAAC - Freeware Advanced Audio Decoder
- * Copyright (C) 2001 Menno Bakker
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * $Id: AACINFO.H,v 1.2 2001/10/16 13:24:28 menno Exp $
- */
-
-typedef struct {
-	int version;
-	int channels;
-	int sampling_rate;
-	int bitrate;
-	int length;
-	int object_type;
-	int headertype;
-} FAACAACInfo;
-
-
-int get_AAC_format(char *filename, FAACAACInfo *info, int *seek_table);
-
-static int f_id3v2_tag(HANDLE file);
-static int read_ADIF_header(HANDLE file, FAACAACInfo *info);
-static int read_ADTS_header(HANDLE file, FAACAACInfo *info, int *seek_table,
-							int tagsize);
-int StringComp(char const *str1, char const *str2, unsigned long len);
--- /dev/null
+++ b/plugins/winamp/CRegistry.cpp
@@ -1,0 +1,331 @@
+/*
+FAAC - encoder plugin for Winamp 2
+Copyright (C) 2002 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:
+kreel@interfree.it
+*/
+
+//#include "stdafx.h"
+#include <windows.h>
+#include <string.h>
+#include <memory.h>
+#include "CRegistry.h"
+
+CRegistry::CRegistry()
+{
+	regKey=NULL;
+	path=NULL;
+}
+
+CRegistry::~CRegistry()
+{
+	if(regKey)
+		RegCloseKey(regKey);
+	if(path)
+		free(path);
+}
+// *****************************************************************************
+// *****************************************************************************
+// *****************************************************************************
+
+#define setPath(SubKey) \
+	if(path) \
+		free(path); \
+	path=strdup(SubKey);
+
+BOOL CRegistry::openReg(HKEY hKey, char *SubKey)
+{
+	if(regKey)
+		RegCloseKey(regKey);
+	if(RegOpenKeyEx(hKey, SubKey, NULL , KEY_ALL_ACCESS , &regKey)==ERROR_SUCCESS)
+	{
+		setPath(SubKey);
+		return TRUE;
+	}
+	else // can't open the key -> error
+	{
+		regKey=0;
+		setPath("");
+		return FALSE;
+	}
+}
+// *****************************************************************************
+
+BOOL CRegistry::openCreateReg(HKEY hKey, char *SubKey)
+{
+	if(regKey)
+		RegCloseKey(regKey);
+	if(RegOpenKeyEx(hKey, SubKey, NULL , KEY_ALL_ACCESS , &regKey)==ERROR_SUCCESS)
+	{
+		setPath(SubKey);
+		return TRUE;
+	}
+	else // open failed -> create the key
+	{
+	DWORD disp;
+		RegCreateKeyEx(hKey , SubKey, NULL , NULL, REG_OPTION_NON_VOLATILE , KEY_ALL_ACCESS , NULL , &regKey , &disp );
+		if(disp==REG_CREATED_NEW_KEY) 
+		{
+			setPath(SubKey);
+			return TRUE;
+		}
+		else // can't create the key -> error
+		{
+			regKey=0;
+			setPath("");
+			return FALSE;
+		}
+	}
+}
+// *****************************************************************************
+
+void CRegistry::closeReg()
+{
+	if(regKey)
+		RegCloseKey(regKey);
+	regKey=NULL;
+	if(path) 
+		delete path; 
+	path=NULL;
+}
+// *****************************************************************************
+// *****************************************************************************
+// *****************************************************************************
+
+void CRegistry::DeleteRegVal(char *SubKey)
+{
+	RegDeleteValue(regKey,SubKey);
+}
+// *****************************************************************************
+
+void CRegistry::DeleteRegKey(char *SubKey)
+{
+	RegDeleteKey(regKey,SubKey);
+}
+
+// *****************************************************************************
+// *****************************************************************************
+// *****************************************************************************
+
+void CRegistry::setRegBool(char *keyStr , BOOL val)
+{
+BOOL tempVal;
+DWORD len;
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)&tempVal , &len )!=ERROR_SUCCESS ||
+		tempVal!=val)
+		RegSetValueEx(regKey , keyStr , NULL , REG_BINARY , (BYTE *)&val , sizeof(BOOL));
+}
+// *****************************************************************************
+
+void CRegistry::setRegByte(char *keyStr , BYTE val)
+{
+DWORD	t=val;
+DWORD	tempVal;
+DWORD	len;
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)&tempVal , &len )!=ERROR_SUCCESS ||
+		tempVal!=val)
+		RegSetValueEx(regKey , keyStr , NULL , REG_DWORD , (BYTE *)&t , sizeof(DWORD));
+}
+// *****************************************************************************
+
+void CRegistry::setRegWord(char *keyStr , WORD val)
+{
+DWORD	t=val;
+DWORD	tempVal;
+DWORD	len;
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)&tempVal , &len )!=ERROR_SUCCESS ||
+		tempVal!=val)
+		RegSetValueEx(regKey , keyStr , NULL , REG_DWORD , (BYTE *)&t , sizeof(DWORD));
+}
+// *****************************************************************************
+
+void CRegistry::setRegDword(char *keyStr , DWORD val)
+{
+DWORD tempVal;
+DWORD len;
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)&tempVal , &len )!=ERROR_SUCCESS ||
+		tempVal!=val)
+		RegSetValueEx(regKey , keyStr , NULL , REG_DWORD , (BYTE *)&val , sizeof(DWORD));
+}
+// *****************************************************************************
+
+void CRegistry::setRegFloat(char *keyStr , float val)
+{
+float tempVal;
+DWORD len;
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)&tempVal , &len )!=ERROR_SUCCESS ||
+		tempVal!=val)
+		RegSetValueEx(regKey , keyStr , NULL , REG_BINARY , (BYTE *)&val , sizeof(float));
+}
+// *****************************************************************************
+
+void CRegistry::setRegStr(char *keyStr , char *valStr)
+{
+DWORD len;
+DWORD slen=strlen(valStr)+1;
+
+	if(!valStr || !*valStr)
+		return;
+
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, NULL , &len )!=ERROR_SUCCESS ||
+		len!=slen)
+		RegSetValueEx(regKey , keyStr , NULL , REG_SZ , (BYTE *)valStr , slen);
+	else
+	{
+	char *tempVal=new char[slen];
+		if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)tempVal , &len )!=ERROR_SUCCESS ||
+			strcmpi(tempVal,valStr))
+			RegSetValueEx(regKey , keyStr , NULL , REG_SZ , (BYTE *)valStr , slen);
+		delete tempVal;
+	}
+}
+// *****************************************************************************
+
+void CRegistry::setRegValN(char *keyStr , BYTE *addr,  DWORD size)
+{
+DWORD len;
+	if(!addr || !size)
+		return;
+
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, NULL , &len )!=ERROR_SUCCESS ||
+		len!=size)
+		RegSetValueEx(regKey , keyStr , NULL , REG_BINARY , addr , size);
+	else
+	{
+	BYTE *tempVal=new BYTE[size];
+		if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)tempVal , &len )!=ERROR_SUCCESS ||
+			memcmp(tempVal,addr,len))
+			RegSetValueEx(regKey , keyStr , NULL , REG_BINARY , addr , size);
+		delete tempVal;
+	}
+}
+
+
+
+// *****************************************************************************
+// *****************************************************************************
+// *****************************************************************************
+
+
+
+BOOL CRegistry::getSetRegBool(char *keyStr, BOOL val)
+{
+BOOL tempVal;
+DWORD len=sizeof(BOOL);
+
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)&tempVal , &len )!=ERROR_SUCCESS)
+	{
+		RegSetValueEx(regKey , keyStr , NULL , REG_BINARY , (BYTE *)&val , sizeof(BOOL));
+		return val;
+	}
+	return tempVal;
+}
+// *****************************************************************************
+
+BYTE CRegistry::getSetRegByte(char *keyStr, BYTE val)
+{
+DWORD tempVal;
+DWORD len=sizeof(DWORD);
+
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)&tempVal , &len )!=ERROR_SUCCESS)
+	{
+		tempVal=val;
+		RegSetValueEx(regKey , keyStr , NULL , REG_DWORD , (BYTE *)&tempVal , sizeof(DWORD));
+		return val;
+	}
+	return (BYTE)tempVal;
+}
+// *****************************************************************************
+
+WORD CRegistry::getSetRegWord(char *keyStr, WORD val)
+{
+DWORD tempVal;
+DWORD len=sizeof(DWORD);
+
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)&tempVal , &len )!=ERROR_SUCCESS)
+	{
+		tempVal=val;
+		RegSetValueEx(regKey , keyStr , NULL , REG_DWORD , (BYTE *)&tempVal , sizeof(DWORD));
+		return val;
+	}
+	return (WORD)tempVal;
+}
+// *****************************************************************************
+
+DWORD CRegistry::getSetRegDword(char *keyStr, DWORD val)
+{
+DWORD tempVal;
+DWORD len=sizeof(DWORD);
+
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)&tempVal , &len )!=ERROR_SUCCESS)
+	{
+		RegSetValueEx(regKey , keyStr , NULL , REG_DWORD , (BYTE *)&val , sizeof(DWORD));
+		return val;
+	}
+	return (DWORD)tempVal;
+}
+// *****************************************************************************
+
+float CRegistry::getSetRegFloat(char *keyStr, float val)
+{
+float tempVal;
+DWORD len=sizeof(float);
+
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)&tempVal , &len )!=ERROR_SUCCESS)
+	{
+		RegSetValueEx(regKey , keyStr , NULL , REG_BINARY , (BYTE *)&val , sizeof(float));
+		return val;
+	}
+	return tempVal;
+}
+// *****************************************************************************
+
+int CRegistry::getSetRegStr(char *keyStr, char *tempString, char *dest, int maxLen)
+{
+DWORD tempLen=maxLen;
+	
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *) dest , &tempLen )!=ERROR_SUCCESS)
+	{
+		if(!tempString)
+		{
+			*dest=0;
+			return 0;
+		}
+		strcpy(dest,tempString);
+		tempLen=strlen(tempString)+1;
+		RegSetValueEx(regKey , keyStr , NULL , REG_SZ , (BYTE *)tempString , tempLen);
+	}
+	return tempLen;
+}
+// *****************************************************************************
+
+int CRegistry::getSetRegValN(char *keyStr, BYTE *tempAddr, BYTE *addr, DWORD size)
+{
+DWORD tempLen=size;
+
+	if(RegQueryValueEx(regKey , keyStr , NULL , NULL, (BYTE *)addr , &tempLen )!=ERROR_SUCCESS)
+	{
+		if(!tempAddr)
+		{
+			*addr=0;
+			return 0;
+		}
+		memcpy(addr,tempAddr,size);
+		RegSetValueEx(regKey , keyStr , NULL , REG_BINARY , (BYTE *)addr , size);
+	}
+	return tempLen;
+}
--- /dev/null
+++ b/plugins/winamp/CRegistry.h
@@ -1,0 +1,35 @@
+#ifndef registry_h
+#define registry_h
+
+class CRegistry 
+{
+public:
+			CRegistry();
+			~CRegistry();
+
+	BOOL	openReg(HKEY hKey, char *SubKey);
+	BOOL	openCreateReg(HKEY hKey, char *SubKey);
+	void	closeReg();
+	void	DeleteRegVal(char *SubKey);
+	void	DeleteRegKey(char *SubKey);
+
+	void	setRegBool(char *keyStr , BOOL val);
+	void	setRegByte(char *keyStr , BYTE val);
+	void	setRegWord(char *keyStr , WORD val);
+	void	setRegDword(char *keyStr , DWORD val);
+	void	setRegFloat(char *keyStr , float val);
+	void	setRegStr(char *keyStr , char *valStr);
+	void	setRegValN(char *keyStr , BYTE *addr,  DWORD size);
+
+	BOOL	getSetRegBool(char *keyStr, BOOL var);
+	BYTE	getSetRegByte(char *keyStr, BYTE var);
+	WORD	getSetRegWord(char *keyStr, WORD var);
+	DWORD	getSetRegDword(char *keyStr, DWORD var);
+	float	getSetRegFloat(char *keyStr, float var);
+	int		getSetRegStr(char *keyStr, char *tempString, char *dest, int maxLen);
+	int		getSetRegValN(char *keyStr, BYTE *tempAddr, BYTE *addr, DWORD size);
+
+	HKEY	regKey;
+	char	*path;
+};
+#endif
\ No newline at end of file
--- a/plugins/winamp/Config.cpp
+++ /dev/null
@@ -1,47 +1,0 @@
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-
-static char app_name[] = "Freeware AAC encoder";
-static char INI_FILE[MAX_PATH];
-extern char config_AACoutdir[MAX_PATH];
-extern DWORD dwOptions;
-
-static void _r_s(char *name,char *data, int mlen)
-{
-char buf[2048];
- strcpy(buf,data);
- GetPrivateProfileString(app_name,name,buf,data,mlen,INI_FILE);
-}
-
-#define RS(x) (_r_s(#x,x,sizeof(x)))
-#define WS(x) (WritePrivateProfileString(app_name,#x,x,INI_FILE))
-
-
-
-static void config_init()
-{
-	char *p=INI_FILE;
-	GetModuleFileName(NULL,INI_FILE,sizeof(INI_FILE));
-	while (*p) p++;
-	while (p >= INI_FILE && *p != '.') p--;
-	strcpy(p+1,"ini");
-}
-
-void config_read()
-{
-char Options[512];
- config_init();
- RS(config_AACoutdir);
- RS(Options);
- dwOptions=atoi(Options);
-}
-
-void config_write()
-{
-char Options[512];
- WS(config_AACoutdir);
- sprintf(Options,"%lu",dwOptions);
- WS(Options);
-}
--- /dev/null
+++ b/plugins/winamp/Copying
@@ -1,0 +1,339 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                          675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	Appendix: How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
--- a/plugins/winamp/OUT_FAAC.DEF
+++ b/plugins/winamp/OUT_FAAC.DEF
@@ -1,2 +1,4 @@
+LIBRARY
+
 EXPORTS
 	winampGetOutModule
binary files a/plugins/winamp/Open.bmp b/plugins/winamp/Open.bmp differ
--- a/plugins/winamp/Out_faac.cpp
+++ b/plugins/winamp/Out_faac.cpp
@@ -1,22 +1,35 @@
+/*
+FAAC - encoder plugin for Winamp 2
+Copyright (C) 2002 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:
+kreel@interfree.it
+*/
+
 #include <windows.h>
 #include <shlobj.h>
 #include <stdio.h>  // FILE *
 #include "resource.h"
-#include "..\..\include\faac.h"
 #include "out.h"
+#include "faac.h"
+#include "CRegistry.h"
+#include "defines.h"
 
 
-#define PI_VER "v1.0 beta2"
 
-extern void config_read();
-extern void config_write();
-/*
-#ifdef __cplusplus
-extern "C" {
-#endif
-*/
-
-	
 void Config(HWND);
 void About(HWND);
 void Init();
@@ -32,13 +45,9 @@
 void Flush(int);
 int GetOutputTime();
 int GetWrittenTime();
-/*
-#ifdef __cplusplus
-}
-#endif
-*/
 
 
+
 typedef struct output_tag  // any special vars associated with output file
 {
  FILE  *fFile;         
@@ -59,26 +68,36 @@
  unsigned char *inbuf;
  DWORD full_size; // size of decoded file needed to set the length of progress bar
  DWORD tagsize;
- DWORD bytes_read; // from file
- DWORD bytes_consumed; // by faadDecDecode
+ DWORD bytes_read;		// from file
+ DWORD bytes_consumed;	// by faadDecDecode
  DWORD bytes_into_buffer;
  DWORD bytes_Enc;
 } MYOUTPUT;
 
-char config_AACoutdir[MAX_PATH]="";
-DWORD dwOptions;
+
+
+typedef struct mc
+{
+bool					AutoCfg;
+faacEncConfiguration	EncCfg;
+char					OutDir[MAX_PATH];
+} MYCFG;
+
+
+
 static MYOUTPUT mo0,
-                *mo=&mo0; // this is done to copy'n'paste code from CoolEdit plugin
-static HBITMAP hBmBrowse=NULL;
-static int srate, numchan, bps;
-volatile int writtentime, w_offset;
-static int last_pause=0;
+				*mo=&mo0; // this is done to copy'n'paste code from CoolEdit plugin
+static			HBITMAP hBmBrowse=NULL;
+char			config_AACoutdir[MAX_PATH]="";
+static int		srate, numchan, bps;
+volatile int	writtentime, w_offset;
+static int		last_pause=0;
 
 
 Out_Module out = {
 	OUT_VER,
-	"Freeware AAC encoder " PI_VER,
-	33,
+	APP_NAME APP_VER,
+	NULL,
     NULL, // hmainwindow
     NULL, // hdllinstance
     Config,
@@ -104,14 +123,12 @@
 
 
 
-//__declspec(dllexport) Out_Module * __cdecl winampGetOutModule()
-__declspec(dllexport) Out_Module * winampGetOutModule()
+Out_Module *winampGetOutModule()
 {
 	return &out;
 }
 // *********************************************************************************************
 
-//BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ulReason, LPVOID lpReserved)
 BOOL WINAPI DllMain (HANDLE hInst, DWORD ulReason, LPVOID lpReserved)
 {
    switch(ulReason)
@@ -187,6 +204,47 @@
 	return 0;
 }
 
+void RD_Cfg(MYCFG *cfg) 
+{ 
+CRegistry reg;
+
+	reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME);
+	cfg->AutoCfg=reg.getSetRegDword("Auto",true) ? true : false; 
+	cfg->EncCfg.mpegVersion=reg.getSetRegDword("MPEG version",MPEG2); 
+	cfg->EncCfg.aacObjectType=reg.getSetRegDword("Profile",LOW); 
+	cfg->EncCfg.allowMidside=reg.getSetRegDword("MidSide",true); 
+	cfg->EncCfg.useTns=reg.getSetRegDword("TNS",true); 
+	cfg->EncCfg.useLfe=reg.getSetRegDword("LFE",false);
+	cfg->EncCfg.bitRate=reg.getSetRegDword("BitRate",128000); 
+	cfg->EncCfg.bandWidth=reg.getSetRegDword("BandWidth",0); 
+	cfg->EncCfg.outputFormat=reg.getSetRegDword("Header",1); 
+	reg.getSetRegStr("OutDir","",cfg->OutDir,MAX_PATH); 
+}
+
+void WR_Cfg(MYCFG *cfg) 
+{ 
+CRegistry reg;
+
+	reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME);
+	reg.setRegDword("Auto",cfg->AutoCfg); 
+	reg.setRegDword("MPEG version",cfg->EncCfg.mpegVersion); 
+	reg.setRegDword("Profile",cfg->EncCfg.aacObjectType); 
+	reg.setRegDword("MidSide",cfg->EncCfg.allowMidside); 
+	reg.setRegDword("TNS",cfg->EncCfg.useTns); 
+	reg.setRegDword("LFE",cfg->EncCfg.useLfe); 
+	reg.setRegDword("BitRate",cfg->EncCfg.bitRate); 
+	reg.setRegDword("BandWidth",cfg->EncCfg.bandWidth); 
+	reg.setRegDword("Header",cfg->EncCfg.outputFormat); 
+	reg.setRegStr("OutDir",cfg->OutDir); 
+}
+
+#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 DISABLE_LTP \
 { \
 	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \
@@ -220,257 +278,205 @@
 
 static BOOL CALLBACK DIALOGMsgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 {
- switch(Message)
- {
-  case WM_INITDIALOG:
-	  {
-      char buf[10];
-
-		SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
-		if(!*config_AACoutdir)
-			GetCurrentDirectory(MAX_PATH,config_AACoutdir);
-		SetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir);
-
-	   SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"8");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"18");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"20");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"24");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"32");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"40");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"48");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"56");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"64");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"96");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"112");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"128");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"160");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"192");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"256");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 8, 0);
-
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"0");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"4000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"8000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"16000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"22050");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"24000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0);
-
-	   if(dwOptions)
-	   {
-       char Enabled=!(dwOptions&1);
-		CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, dwOptions&1);
-		DISABLE_CTRL(Enabled);
-
-	    if(((dwOptions>>29)&7)==MPEG4)
-	     CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-		else
-		 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
-
-		switch((dwOptions>>27)&3)
+	switch(Message)
+	{
+	case WM_INITDIALOG:
 		{
-		 case 0:
-              CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-		      break;
-		 case 1:
-              CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
-		      break;
-		 case 2:
-              CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
-		      break;
-		  case 3:
-               CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
-			   DISABLE_LTP
-		       break;
+		char buf[50];
+		char *BitRate[]={"Auto","8","18","20","24","32","40","48","56","64","96","112","128","160","192","256",0};
+		char *BandWidth[]={"Auto","Full","4000","8000","16000","22050","24000","48000",0};
+		MYCFG cfg;
+			
+			RD_Cfg(&cfg);
+			
+			INIT_CB(hWndDlg,IDC_CB_BITRATE,BitRate,0);
+			INIT_CB(hWndDlg,IDC_CB_BANDWIDTH,BandWidth,0);
+			
+			SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
+			if(!*cfg.OutDir)
+				GetCurrentDirectory(MAX_PATH,cfg.OutDir);
+			SetDlgItemText(hWndDlg, IDC_E_BROWSE, cfg.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 0:
+				CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);
+				break;
+			case 1:
+				CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
+				break;
+			}
+			
+			CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, cfg.EncCfg.allowMidside);
+			CheckDlgButton(hWndDlg, IDC_USETNS, cfg.EncCfg.useTns);
+			CheckDlgButton(hWndDlg, IDC_USELFE, cfg.EncCfg.useLfe);
+			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_AUTOCFG, cfg.AutoCfg);
+			
+			DISABLE_CTRL(!cfg.AutoCfg);
 		}
-
-		switch((dwOptions>>31)&1)
+		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 0:
-              CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);
-		      break;
-		case 1:
-              CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
-		      break;
-		}
-
-		CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, (dwOptions>>26)&1);
-        CheckDlgButton(hWndDlg, IDC_USETNS, (dwOptions>>25)&1);
-        CheckDlgButton(hWndDlg, IDC_USELFE, (dwOptions>>24)&1);
-
-        SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, (dwOptions>>19)&31, 0);
-//        SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, (dwOptions>>6)&31, 0);
-		sprintf(buf,"%lu",(dwOptions>>1)&0x0000ffff);
-        SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf);
-		break;
-	   } // End dwOptions
-
-	   CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, TRUE);
-       CheckDlgButton(hWndDlg, IDC_USETNS, TRUE);
-       CheckDlgButton(hWndDlg, IDC_USELFE, FALSE);
-       
-	   switch((long)lParam)
-	   {
-	    case IDC_RADIO_MPEG4:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-	         EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			 break;
-		case IDC_RADIO_MPEG2:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
-	         DISABLE_LTP
-			 break;
-		case IDC_RADIO_MAIN:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-			 break;
-		case IDC_RADIO_LOW:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
-			 break;
-		case IDC_RADIO_SSR:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
-			 break;
-		case IDC_RADIO_LTP:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
-			 break;
 		case IDC_CHK_AUTOCFG:
-			 CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			 break;
-		default:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-			 CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);
-			 break;
-	   }         
-	  }
-      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 IDC_CHK_AUTOCFG:
 			{
 			char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG);
 				DISABLE_CTRL(Enabled);
 			}
-            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;
-	          idlist = SHBrowseForFolder( &bi );
-	          if (idlist) 
-	           SHGetPathFromIDList( idlist, config_AACoutdir );
-
-              SetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir);
-			 }
-			 break;
-
-		case IDC_E_BROWSE:
-             GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir,256);
-			 break;
-
-	    case IDOK:
-           	 {
-			 DWORD retVal=0;
-             faacEncConfiguration faacEncCfg;
-
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_ADTS))
-			  {
-               faacEncCfg.mpegVersion=1;
-			   retVal|=1<<31;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4))
-			  {
-               faacEncCfg.mpegVersion=MPEG4;
-			   retVal|=MPEG4<<29;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2))
-			  {
-               faacEncCfg.mpegVersion=MPEG2;
-			   retVal|=MPEG2<<29;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
-			  {
-               faacEncCfg.aacObjectType=MAIN;
-			   retVal|=MAIN<<27;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
-			  {
-               faacEncCfg.aacObjectType=LOW;
-			   retVal|=LOW<<27;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
-			  {
-               faacEncCfg.aacObjectType=SSR;
-			   retVal|=SSR<<27;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
-			  {
-               faacEncCfg.aacObjectType=LTP;
-			   retVal|=LTP<<27;
-			  }
-
-              faacEncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_ALLOWMIDSIDE) == BST_CHECKED ? 1 : 0;
-              retVal|=faacEncCfg.allowMidside<<26;
-              faacEncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_USETNS) == BST_CHECKED ? 1 : 0;
-              retVal|=faacEncCfg.useTns<<25;
-              faacEncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_USELFE) == BST_CHECKED ? 1 : 0;
-              retVal|=faacEncCfg.useLfe<<24;
-			  
-			  faacEncCfg.bitRate=GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
-			  retVal|=(SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_GETCURSEL, 0, 0)&31)<<19;
-              //retVal|=faacEncCfg.bitRate;
-			  faacEncCfg.bandWidth=GetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, 0, FALSE);
-//			  retVal|=(SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_GETCURSEL, 0, 0)&31)<<6;
-			  retVal|=(faacEncCfg.bandWidth&0x0000ffff)<<1;
-
-			  if(IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG))
-			   retVal|=1;
-
-			  EndDialog(hWndDlg, retVal);
-             }
-             break;
-
+			break;
+			
+		case IDOK:
+			{
+			char buf[50];
+			HANDLE hCfg=(HANDLE)lParam;
+			MYCFG 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_ALLOWMIDSIDE);
+				cfg.EncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_USETNS);
+				cfg.EncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_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.EncCfg.outputFormat=IsDlgButtonChecked(hWndDlg,IDC_RADIO_RAW) ? 0 : 1;
+				GetDlgItemText(hWndDlg, IDC_E_BROWSE, cfg.OutDir, MAX_PATH);
+				
+				WR_Cfg(&cfg);
+				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;
-
+			// Ignore data values entered into the controls        
+			// and dismiss the dialog window returning FALSE
+			EndDialog(hWndDlg, FALSE);
+			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_RADIO_MPEG4:
-	         EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			 break;
-
+			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;
-       }
-       break; // End of WM_COMMAND                                 
-  default: return FALSE;
- }
- return TRUE;
+			EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
+			DISABLE_LTP
+				break;
+		}
+		break; // End of WM_COMMAND
+	default: 
+		return FALSE;
+	}
+	
+	return TRUE;
 } // End of DIALOGSMsgProc                                      
 // *********************************************************************************************
 
 void Config(HWND hWnd)
 {
- dwOptions=DialogBox(out.hDllInstance, MAKEINTRESOURCE(IDD_COMPRESSION), hWnd, DIALOGMsgProc);
-// dwOptions=DialogBoxParam((HINSTANCE)out.hDllInstance,(LPCSTR)MAKEINTRESOURCE(IDD_COMPRESSION), (HWND)hWnd, (DLGPROC)DIALOGMsgProc, dwOptions);
- config_write();
+	DialogBox(out.hDllInstance, MAKEINTRESOURCE(IDD_COMPRESSION), hWnd, DIALOGMsgProc);
+//	dwOptions=DialogBoxParam((HINSTANCE)out.hDllInstance,(LPCSTR)MAKEINTRESOURCE(IDD_COMPRESSION), (HWND)hWnd, (DLGPROC)DIALOGMsgProc, dwOptions);
 }
 // *********************************************************************************************
 
@@ -477,18 +483,20 @@
 void About(HWND hwnd)
 {
 char buf[256];
- sprintf(buf,"AAC-MPEG4 encoder plug-in %s by 4N\n"
-	 "This plugin uses FAAC encoder engine v" FAACENC_VERSION "\n\n"
+	sprintf(buf,
+			APP_NAME " encoder plug-in %s by Antonio Foranna\n\n"
+			"This plugin uses FAAC encoder engine v%g\n\n"
 			"Compiled on %s\n",
-	         PI_VER,
-			 __DATE__);
- MessageBox(hwnd, buf, "About", MB_OK);
+			 APP_VER,
+			 FAACENC_VERSION,
+			 __DATE__
+			 );
+	MessageBox(hwnd, buf, "About", MB_OK);
 }
 // *********************************************************************************************
 
 void Init()
 {
- config_read();
 }
 // *********************************************************************************************
 
@@ -499,7 +507,8 @@
 
 static char *scanstr_back(char *str, char *toscan, char *defval)
 {
-	char *s=str+strlen(str)-1;
+char *s=str+strlen(str)-1;
+
 	if (strlen(str) < 1) return defval;
 	if (strlen(toscan) < 1) return defval;
 	while (1)
@@ -513,34 +522,17 @@
 	}
 }
 
-#define ERROR_O(msg) \
-{ \
-	if(msg) \
-		MessageBox(0, msg, "FAAC plugin", MB_OK); \
-	Close(); \
-	return -1; \
-}
-
-int Open(int lSamprate, int wChannels, int wBitsPerSample, int bufferlenms, int prebufferms)
+void GetNewFileName(char *lpstrFilename)
 {
-//HANDLE        hOutput;
-//faacEncHandle hEncoder;
-//FILE          *outfile;
-//unsigned char *bitbuf;
-DWORD         maxBytesOutput;
-unsigned long samplesInput;
-int           bytesEncoded;
-int				tmp;
+char temp2[MAX_PATH];
+char *t,*p;
 
-
-	char *t,*p;
-	char temp2[MAX_PATH],lpstrFilename[MAX_PATH];
 	GetWindowText(out.hMainWindow,temp2,sizeof(temp2));
 	t=temp2;
-
+	
 	t=scanstr_back(temp2,"-",NULL);
 	if (t) t[-1]=0;
-
+	
 	if (temp2[0] && temp2[1] == '.')
 	{
 		char *p1,*p2;
@@ -571,10 +563,10 @@
 			*p == '\'' || *p == '|' || *p == '<' || *p == '>') *p = '_';
 		p=CharNext(p);
 	}
-
+	
 	p=config_AACoutdir;
 	if (p[0]) while (p[1]) p++;
-
+	
 	if (!config_AACoutdir[0] || config_AACoutdir[0] == ' ')
 		Config(out.hMainWindow);
 	if (!config_AACoutdir[0])
@@ -583,111 +575,87 @@
 		wsprintf(lpstrFilename,"%s%s.aac",config_AACoutdir,temp2);
 	else
 		wsprintf(lpstrFilename,"%s\\%s.aac",config_AACoutdir,temp2);
+}
 
- 	w_offset = writtentime = 0;
+#define ERROR_O(msg) \
+{ \
+	if(msg) \
+		MessageBox(0, msg, "FAAC plugin", MB_OK); \
+	Close(); \
+	return -1; \
+}
+
+int Open(int lSamprate, int wChannels, int wBitsPerSample, int bufferlenms, int prebufferms)
+{
+MYCFG			cfg;
+DWORD			maxBytesOutput;
+unsigned long	samplesInput;
+int				bytesEncoded;
+int				tmp;
+char			lpstrFilename[MAX_PATH];
+
+	w_offset = writtentime = 0;
 	numchan = wChannels;
 	srate = lSamprate;
 	bps = wBitsPerSample;
 
+	RD_Cfg(&cfg);
 
+	strcpy(config_AACoutdir,cfg.OutDir);
+	GetNewFileName(lpstrFilename);
 
 	memset(mo,0,sizeof(MYOUTPUT));
-
-	/* open the aac output file */
+	
+	// open the aac output file
 	if(!(mo->fFile=fopen(lpstrFilename, "wb")))
 		ERROR_O("Can't create file");
+	
+	// use bufferized stream
+	setvbuf(mo->fFile,NULL,_IOFBF,32767);
 
-	/* open the encoder library */
+	// open the encoder library
 	if(!(mo->hEncoder=faacEncOpen(lSamprate, wChannels, &samplesInput, &maxBytesOutput)))
 		ERROR_O("Can't init library");
-
+	
 	if(!(mo->bitbuf=(unsigned char*)malloc(maxBytesOutput*sizeof(unsigned char))))
 		ERROR_O("Memory allocation error: output buffer");
-
+	
 	if(!(mo->inbuf=(unsigned char*)malloc(samplesInput*sizeof(short))))
 		ERROR_O("Memory allocation error: input buffer");
-
-//	 mo->fFile=outfile;
-//	 mo->lSize=lSize;
-	 mo->lSamprate=lSamprate;
-	 mo->wBitsPerSample=wBitsPerSample;
-	 mo->wChannels=wChannels;
-	 strcpy(mo->szNAME,lpstrFilename);
-
-//	 mo->hEncoder=hEncoder;
-     //mo->bitbuf=bitbuf;
-	 mo->maxBytesOutput=maxBytesOutput;
-	 mo->samplesInput=samplesInput;
-	 mo->bStopEnc=0;
-
-
-	if(dwOptions && !(dwOptions&1))
+	
+	if(!cfg.AutoCfg)
 	{
-    faacEncConfigurationPtr myFormat;
-     myFormat=faacEncGetCurrentConfiguration(mo->hEncoder);
-
-	 myFormat->outputFormat=(dwOptions>>31)&1;
-	 myFormat->mpegVersion=(dwOptions>>29)&7;
-	 myFormat->aacObjectType=(dwOptions>>27)&3;
-	 myFormat->allowMidside=(dwOptions>>26)&1;
-	 myFormat->useTns=(dwOptions>>25)&1;
-	 myFormat->useLfe=(dwOptions>>24)&1;
-	 switch((dwOptions>>19)&31)
-	 {
-	  case 0:
-           myFormat->bitRate=8000;
-		   break;
-	  case 1:
-           myFormat->bitRate=18000;
-		   break;
-	  case 2:
-           myFormat->bitRate=20000;
-		   break;
-	  case 3:
-           myFormat->bitRate=24000;
-		   break;
-	  case 4:
-           myFormat->bitRate=32000;
-		   break;
-	  case 5:
-           myFormat->bitRate=40000;
-		   break;
-	  case 6:
-           myFormat->bitRate=48000;
-		   break;
-	  case 7:
-           myFormat->bitRate=56000;
-		   break;
-	  case 8:
-           myFormat->bitRate=64000;
-		   break;
-	  case 9:
-           myFormat->bitRate=96000;
-		   break;
-	  case 10:
-           myFormat->bitRate=112000;
-		   break;
-	  case 11:
-           myFormat->bitRate=128000;
-		   break;
-	  case 12:
-           myFormat->bitRate=160000;
-		   break;
-	  case 13:
-           myFormat->bitRate=192000;
-		   break;
-	  case 14:
-           myFormat->bitRate=256000;
-		   break;
-	 }
-     myFormat->bandWidth=(dwOptions>>1)&0x0000ffff;
-     if(!myFormat->bandWidth)
-	  myFormat->bandWidth=mo->lSamprate/2;
-
-	 if(!faacEncSetConfiguration(mo->hEncoder, myFormat))
-		ERROR_O("Unsupported parameters");
+	faacEncConfigurationPtr myFormat=&cfg.EncCfg;
+	faacEncConfigurationPtr CurFormat=faacEncGetCurrentConfiguration(mo->hEncoder);
+		
+		if(!myFormat->bitRate)
+			myFormat->bitRate=CurFormat->bitRate;
+		
+		switch(myFormat->bandWidth)
+		{
+		case 0:
+			myFormat->bandWidth=CurFormat->bandWidth;
+			break;
+		case 0xffffffff:
+			myFormat->bandWidth=lSamprate/2;
+			break;
+		default: break;
+		}
+		
+		if(!faacEncSetConfiguration(mo->hEncoder, myFormat))
+			ERROR_O("Unsupported parameters");
 	}
-
+	
+	mo->lSamprate=lSamprate;
+	mo->wBitsPerSample=wBitsPerSample;
+	mo->wChannels=wChannels;
+	strcpy(mo->szNAME,lpstrFilename);
+	
+	mo->maxBytesOutput=maxBytesOutput;
+	mo->samplesInput=samplesInput;
+	mo->bStopEnc=0;
+	
+	// init flushing process
     bytesEncoded=faacEncEncode(mo->hEncoder, 0, 0, mo->bitbuf, maxBytesOutput); // initializes the flushing process
     if(bytesEncoded>0)
 	{
@@ -695,7 +663,7 @@
 		if(tmp!=bytesEncoded)
 			ERROR_O("fwrite");
 	}
-
+	
 	return 0;
 }
 // *********************************************************************************************
@@ -704,36 +672,36 @@
 {
 // Following code crashes winamp. why???
 
-if(mo->bytes_into_buffer)
- {
-int bytesEncoded;
-  bytesEncoded=faacEncEncode(mo->hEncoder, (short *)mo->inbuf, mo->bytes_into_buffer/sizeof(short), mo->bitbuf, mo->maxBytesOutput);
-  if(bytesEncoded>0)
-   fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
- }
-
- if(mo->fFile)
- {
-  fclose(mo->fFile);
-  mo->fFile=0;
- }
-
- if(mo->hEncoder)
-  faacEncClose(mo->hEncoder);
-
- if(mo->bitbuf)
- {
-  free(mo->bitbuf);
-  mo->bitbuf=0;
- }
-
- if(mo->inbuf)
- {
-  free(mo->inbuf);
-  mo->inbuf=0;
- }
-
-// CloseHandle(outfile);
+	if(mo->bytes_into_buffer)
+	{
+	int bytesEncoded;
+		bytesEncoded=faacEncEncode(mo->hEncoder, (short *)mo->inbuf, mo->bytes_into_buffer/sizeof(short), mo->bitbuf, mo->maxBytesOutput);
+		if(bytesEncoded>0)
+			fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
+	}
+	
+	if(mo->fFile)
+	{
+		fclose(mo->fFile);
+		mo->fFile=0;
+	}
+	
+	if(mo->hEncoder)
+		faacEncClose(mo->hEncoder);
+	
+	if(mo->bitbuf)
+	{
+		free(mo->bitbuf);
+		mo->bitbuf=0;
+	}
+	
+	if(mo->inbuf)
+	{
+		free(mo->inbuf);
+		mo->inbuf=0;
+	}
+	
+//	CloseHandle(outfile);
 }
 // *********************************************************************************************
 
@@ -751,63 +719,63 @@
 int bytesEncoded;
 int k,i,shift=0;
 
-  writtentime += len;
-  
-  if(!mo->bStopEnc)
-  {
+	writtentime += len;
 
-   if(mo->bytes_into_buffer+len<mo->samplesInput*sizeof(short))
-   {
-    memcpy(mo->inbuf+mo->bytes_into_buffer, buf, len);
-	mo->bytes_into_buffer+=len;
-	return 0;
-   }
-   else
-    if(mo->bytes_into_buffer)
-    {
-     shift=mo->samplesInput*sizeof(short)-mo->bytes_into_buffer;
-     memcpy(mo->inbuf+mo->bytes_into_buffer, buf, shift);
-     mo->bytes_into_buffer+=shift;
-     buf+=shift;
-	 len-=shift;
-
-     bytesEncoded=faacEncEncode(mo->hEncoder, (short *)mo->inbuf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
-	 mo->bytes_into_buffer=0;
-     if(bytesEncoded<1) // end of flushing process
-     {
-      if(bytesEncoded<0)
-		  ERROR_W("faacEncEncode() failed");
-      return 0;
-     }
-// write bitstream to aac file 
-     bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
-     if(bytesWritten!=bytesEncoded)
-		  ERROR_W("bytesWritten and bytesEncoded are different");
+	if(!mo->bStopEnc)
+	{
+		
+		if(mo->bytes_into_buffer+len<mo->samplesInput*sizeof(short))
+		{
+			memcpy(mo->inbuf+mo->bytes_into_buffer, buf, len);
+			mo->bytes_into_buffer+=len;
+			return 0;
+		}
+		else
+			if(mo->bytes_into_buffer)
+			{
+				shift=mo->samplesInput*sizeof(short)-mo->bytes_into_buffer;
+				memcpy(mo->inbuf+mo->bytes_into_buffer, buf, shift);
+				mo->bytes_into_buffer+=shift;
+				buf+=shift;
+				len-=shift;
+				
+				bytesEncoded=faacEncEncode(mo->hEncoder, (short *)mo->inbuf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
+				mo->bytes_into_buffer=0;
+				if(bytesEncoded<1) // end of flushing process
+				{
+					if(bytesEncoded<0)
+						ERROR_W("faacEncEncode() failed");
+					return 0;
+				}
+				// write bitstream to aac file 
+				bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
+				if(bytesWritten!=bytesEncoded)
+					ERROR_W("bytesWritten and bytesEncoded are different");
+			}
+			
+			// call the actual encoding routine
+			k=len/(mo->samplesInput*sizeof(short));
+			for(i=0; i<k; i++)
+			{
+				bytesEncoded+=faacEncEncode(mo->hEncoder, ((short *)buf)+i*mo->samplesInput, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
+				if(bytesEncoded<1) // end of flushing process
+				{
+					if(bytesEncoded<0)
+						ERROR_W("faacEncEncode() failed");
+					return 0;
+				}
+				// write bitstream to aac file 
+				bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
+				if(bytesWritten!=bytesEncoded)
+					ERROR_W("bytesWritten and bytesEncoded are different");
+			}
+			
+			mo->bytes_into_buffer=len%(mo->samplesInput*sizeof(short));
+			memcpy(mo->inbuf, buf+k*mo->samplesInput*sizeof(short), mo->bytes_into_buffer);
 	}
 
-// call the actual encoding routine
-   k=len/(mo->samplesInput*sizeof(short));
-   for(i=0; i<k; i++)
-   {
-    bytesEncoded+=faacEncEncode(mo->hEncoder, ((short *)buf)+i*mo->samplesInput, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
-    if(bytesEncoded<1) // end of flushing process
-    {
-      if(bytesEncoded<0)
-		  ERROR_W("faacEncEncode() failed");
-      return 0;
-    }
-// write bitstream to aac file 
-    bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
-    if(bytesWritten!=bytesEncoded)
-		  ERROR_W("bytesWritten and bytesEncoded are different");
-   }
-
-   mo->bytes_into_buffer=len%(mo->samplesInput*sizeof(short));
-   memcpy(mo->inbuf, buf+k*mo->samplesInput*sizeof(short), mo->bytes_into_buffer);
-  }
-
-  Sleep(0);
-  return 0;
+	Sleep(0);
+	return 0;
 }
 // *********************************************************************************************
 
@@ -844,23 +812,23 @@
 
 void Flush(int t)
 {
-  int a;
-  w_offset=0;
-  a = t - GetWrittenTime();
-  w_offset=a;
+int a;
+
+	  w_offset=0;
+	  a = t - GetWrittenTime();
+	  w_offset=a;
 }
 // *********************************************************************************************
 	
 int GetWrittenTime()
 {
-	int t=srate*numchan,l;
-	int ms=writtentime;
+int t=srate*numchan,l;
+int ms=writtentime;
 
 	l=ms%t;
 	ms /= t;
 	ms *= 1000;
 	ms += (l*1000)/t;
-
 	if (bps == 16) ms/=2;
 
 	return ms + w_offset;
--- a/plugins/winamp/ReadMe.txt
+++ b/plugins/winamp/ReadMe.txt
@@ -1,1 +1,26 @@
-mail: kreel@interfree.it
++-----------------------------------------------------------------+
+|                                                                 |
+|                          out_FAAC Readme                        |
+|                          ---------------                        |
+|                                                                 |
++-----------------------------------------------------------------+
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.
+
+----------------------------------------------------------------------------
+
+out_AAC is an encoder plugin for Winamp 2.
+
+To use it:
+----------
+
+In visual studio set "Active Configuration = out_FAAC - win32 Release" and compile then
+copy out_AAC.dll into Winamp\plugins folder.
+
+----------------------------------------------------------------------------
+
+For suggestions, bugs report, etc., you can contact me at
+kreel@interfree.it
--- /dev/null
+++ b/plugins/winamp/defines.h
@@ -1,0 +1,3 @@
+#define APP_NAME "Freeware AAC encoder"
+#define APP_VER "v1.0 beta3"
+#define REGISTRY_PROGRAM_NAME "SOFTWARE\\4N\\Winamp\\Out_AAC"
--- a/plugins/winamp/out_FAAC.dsp
+++ b/plugins/winamp/out_FAAC.dsp
@@ -1,24 +1,24 @@
-# Microsoft Developer Studio Project File - Name="out_faac" - Package Owner=<4>
+# Microsoft Developer Studio Project File - Name="Out_FAAC" - Package Owner=<4>
 # Microsoft Developer Studio Generated Build File, Format Version 6.00
 # ** DO NOT EDIT **
 
 # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
 
-CFG=out_faac - Win32 Debug
+CFG=Out_FAAC - Win32 Debug
 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
 !MESSAGE use the Export Makefile command and run
 !MESSAGE 
-!MESSAGE NMAKE /f "out_faac.mak".
+!MESSAGE NMAKE /f "Out_FAAC.mak".
 !MESSAGE 
 !MESSAGE You can specify a configuration when running NMAKE
 !MESSAGE by defining the macro CFG on the command line. For example:
 !MESSAGE 
-!MESSAGE NMAKE /f "out_faac.mak" CFG="out_faac - Win32 Debug"
+!MESSAGE NMAKE /f "Out_FAAC.mak" CFG="Out_FAAC - Win32 Debug"
 !MESSAGE 
 !MESSAGE Possible choices for configuration are:
 !MESSAGE 
-!MESSAGE "out_faac - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "out_faac - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "Out_FAAC - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "Out_FAAC - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
 !MESSAGE 
 
 # Begin Project
@@ -25,11 +25,11 @@
 # PROP AllowPerConfigDependencies 0
 # PROP Scc_ProjName ""
 # PROP Scc_LocalPath ""
-CPP=xicl6.exe
+CPP=cl.exe
 MTL=midl.exe
 RSC=rc.exe
 
-!IF  "$(CFG)" == "out_faac - Win32 Release"
+!IF  "$(CFG)" == "Out_FAAC - Win32 Release"
 
 # PROP BASE Use_MFC 0
 # PROP BASE Use_Debug_Libraries 0
@@ -42,8 +42,8 @@
 # PROP Intermediate_Dir "Release"
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "out_faac_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "out_faac_EXPORTS" /YX /FD /c
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_FAAC_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_FAAC_EXPORTS" /YX /FD /c
 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
 # ADD BASE RSC /l 0x410 /d "NDEBUG"
@@ -51,11 +51,11 @@
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=xilink6.exe
+LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/out_AAC.dll"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/Out_AAC.dll"
 
-!ELSEIF  "$(CFG)" == "out_faac - Win32 Debug"
+!ELSEIF  "$(CFG)" == "Out_FAAC - Win32 Debug"
 
 # PROP BASE Use_MFC 0
 # PROP BASE Use_Debug_Libraries 1
@@ -68,8 +68,8 @@
 # PROP Intermediate_Dir "Debug"
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "out_faac_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "out_faac_EXPORTS" /YX /FD /GZ /c
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_FAAC_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUT_FAAC_EXPORTS" /YX /FD /GZ /c
 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
 # ADD BASE RSC /l 0x410 /d "_DEBUG"
@@ -77,29 +77,25 @@
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=xilink6.exe
+LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug\out_AAC.dll" /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/Out_AAC.dll" /pdbtype:sept
 
 !ENDIF 
 
 # Begin Target
 
-# Name "out_faac - Win32 Release"
-# Name "out_faac - Win32 Debug"
+# Name "Out_FAAC - Win32 Release"
+# Name "Out_FAAC - Win32 Debug"
 # Begin Group "Source Files"
 
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
 # Begin Source File
 
-SOURCE=.\AACINFO.Cpp
+SOURCE=.\CRegistry.cpp
 # End Source File
 # Begin Source File
 
-SOURCE=.\Config.cpp
-# End Source File
-# Begin Source File
-
 SOURCE=.\FAAC.rc
 # End Source File
 # Begin Source File
@@ -108,7 +104,7 @@
 # End Source File
 # Begin Source File
 
-SOURCE=.\OUT_FAAC.DEF
+SOURCE=.\Out_FAAC.def
 # End Source File
 # End Group
 # Begin Group "Header Files"
@@ -116,10 +112,14 @@
 # PROP Default_Filter "h;hpp;hxx;hm;inl"
 # Begin Source File
 
-SOURCE=.\AACINFO.H
+SOURCE=.\CRegistry.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\defines.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\FILTERS.H
 # End Source File
 # Begin Source File
@@ -128,7 +128,7 @@
 # End Source File
 # Begin Source File
 
-SOURCE=.\RESOURCE.H
+SOURCE=.\resource.h
 # End Source File
 # End Group
 # Begin Group "Resource Files"
@@ -136,7 +136,7 @@
 # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
 # Begin Source File
 
-SOURCE=.\Logo.bmp
+SOURCE=.\Open.bmp
 # End Source File
 # End Group
 # End Target
--- a/plugins/winamp/out_FAAC.dsw
+++ b/plugins/winamp/out_FAAC.dsw
@@ -3,7 +3,7 @@
 
 ###############################################################################
 
-Project: "libfaac"=..\..\libfaac\libfaac.dsp - Package Owner=<4>
+Project: "Out_FAAC"=.\Out_FAAC.dsp - Package Owner=<4>
 
 Package=<5>
 {{{
@@ -11,11 +11,14 @@
 
 Package=<4>
 {{{
+    Begin Project Dependency
+    Project_Dep_Name libfaac
+    End Project Dependency
 }}}
 
 ###############################################################################
 
-Project: "out_faac"=.\out_faac.dsp - Package Owner=<4>
+Project: "libfaac"=..\..\libfaac\libfaac.dsp - Package Owner=<4>
 
 Package=<5>
 {{{
@@ -23,9 +26,6 @@
 
 Package=<4>
 {{{
-    Begin Project Dependency
-    Project_Dep_Name libfaac
-    End Project Dependency
 }}}
 
 ###############################################################################