ref: 5603f1be4bf0e960ccba8fa513594d52cd5ac347
parent: f462a48362fda61eba348d50b22892ca2be6b563
author: menno <menno>
date: Mon Jul 2 03:26:01 EDT 2001
Added CoolEdit filter
--- /dev/null
+++ b/cooledit/.cvsignore
@@ -1,0 +1,13 @@
+*.o
+*.so
+*.a
+*.ncb
+*.plg
+*.aps
+*.opt
+*.aac
+*.wav
+Release
+Debug
+ReleaseGUI
+DebugGUI
\ No newline at end of file
--- /dev/null
+++ b/cooledit/FAAD.rc
@@ -1,0 +1,148 @@
+//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, 199, 118
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "AAC-MPEG4 Format"
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,124,99,36,14
+ PUSHBUTTON "Cancel",IDCANCEL,159,99,36,14
+ COMBOBOX IDC_CB_BANDWIDTH,147,73,48,30,CBS_DROPDOWN | WS_VSCROLL |
+ WS_TABSTOP
+ CONTROL "Allow Mid/Side",IDC_ALLOWMIDSIDE,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,111,7,63,10
+ CONTROL "Use TNS",IDC_USETNS,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,111,19,45,10
+ CONTROL "Use LFE channel",IDC_USELFE,"Button",BS_AUTOCHECKBOX |
+ WS_DISABLED | WS_TABSTOP,111,32,67,10
+ CONTROL "MPEG4",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON |
+ WS_GROUP,61,16,42,10
+ CONTROL "MPEG2",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,61,29,41,
+ 9
+ CONTROL "RAW",IDC_RADIO7,"Button",BS_AUTORADIOBUTTON |
+ WS_DISABLED | WS_GROUP,8,16,33,10
+ CONTROL "ADIF",IDC_RADIO8,"Button",BS_AUTORADIOBUTTON |
+ WS_DISABLED,8,27,32,10
+ CONTROL "ADTS",IDC_RADIO9,"Button",BS_AUTORADIOBUTTON |
+ WS_DISABLED,8,39,31,10
+ CONTROL "Main",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON | WS_GROUP,
+ 12,63,31,10
+ CONTROL "Low",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,12,73,29,10
+ CONTROL "SSR",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON |
+ WS_DISABLED,60,63,31,10
+ CONTROL "LTP",IDC_RADIO6,"Button",BS_AUTORADIOBUTTON,60,73,29,10
+ LTEXT "Bitrate",IDC_STATIC,109,61,21,8
+ LTEXT "Bandwidth",IDC_STATIC,109,78,34,8
+ GROUPBOX "AAC type",IDC_STATIC,57,4,48,49
+ GROUPBOX "Header",IDC_STATIC,4,4,48,49
+ GROUPBOX "Profile",IDC_STATIC,4,55,101,31
+ COMBOBOX IDC_CB_BITRATE,147,56,48,30,CBS_DROPDOWN | WS_VSCROLL |
+ WS_TABSTOP
+ CONTROL 104,IDC_STATIC,"Static",SS_BITMAP,4,90,36,23
+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, 195
+ TOPMARGIN, 4
+ BOTTOMMARGIN, 113
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Italian (Italy) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA)
+#ifdef _WIN32
+LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_LOGO BITMAP DISCARDABLE "Logo.bmp"
+#endif // Italian (Italy) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
binary files /dev/null b/cooledit/Logo.bmp differ
--- /dev/null
+++ b/cooledit/aacinfo.c
@@ -1,0 +1,249 @@
+/*
+ * 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.c,v 1.3 2001/08/03 11:47:03 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, 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(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(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;
+}
--- /dev/null
+++ b/cooledit/aacinfo.h
@@ -1,0 +1,39 @@
+/*
+ * 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.3 2001/08/03 11:47:03 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);
--- /dev/null
+++ b/cooledit/faac.c
@@ -1,0 +1,224 @@
+#include <windows.h>
+#include <stdio.h> // for FILE *
+#include "filters.h" //CoolEdit
+#include "resource.h"
+#include "faac.h"
+
+static faacEncHandle hEncoder;
+faacEncConfiguration faacEncCfg;
+
+typedef struct output_tag // any special vars associated with output file
+{
+ FILE *fFile;
+ long lSize;
+ long lSamprate;
+ WORD wBitsPerSample;
+ WORD wChannels;
+ DWORD dwDataOffset;
+ BOOL bWrittenHeader;
+ char szNAME[256];
+
+ faacEncHandle hEncoder;
+ unsigned char *bitbuf;
+ DWORD maxBytesOutput;
+ long samplesInput;
+ BOOL bStopEnc;
+} MYOUTPUT;
+
+__declspec(dllexport) DWORD FAR PASCAL FilterGetOptions(HWND hWnd, HINSTANCE hInst, long lSamprate, WORD wChannels, WORD wBitsPerSample, DWORD dwOptions) // return 0 if no options box
+{
+long nDialogReturn=0L;
+FARPROC lpfnDIALOGMsgProc;
+
+ lpfnDIALOGMsgProc=GetProcAddress(hInst,(LPCSTR)MAKELONG(20,0));
+ nDialogReturn=(long)DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_COMPRESSION), (HWND)hWnd, (DLGPROC)lpfnDIALOGMsgProc,nDialogReturn);
+
+ return nDialogReturn;
+}
+
+__declspec(dllexport) DWORD FAR PASCAL FilterWriteFirstSpecialData(HANDLE hInput,
+ SPECIALDATA * psp)
+{
+return 0L;
+}
+
+__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)
+ {
+ MYOUTPUT *mo;
+ mo=(MYOUTPUT *)GlobalLock(hOutput);
+
+ if(mo->fFile)
+ {
+ fclose(mo->fFile);
+ mo->fFile=0;
+ }
+
+ faacEncClose(mo->hEncoder);
+
+ if(mo->bitbuf)
+ {
+ free(mo->bitbuf);
+ mo->bitbuf=0;
+ }
+
+ GlobalUnlock(hOutput);
+ GlobalFree(hOutput);
+ }
+}
+
+__declspec(dllexport) HANDLE FAR PASCAL OpenFilterOutput(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long lSize, long far *lpChunkSize, DWORD dwOptions)
+{
+HANDLE hOutput;
+long samplesInput;
+int bytesEncoded;
+
+//faacEncHandle hEncoder;
+FILE *outfile=0;
+short *pcmbuf=0;
+unsigned char *bitbuf=0;
+DWORD maxBytesOutput=0;
+
+ /* open the aac output file */
+ outfile=fopen(lpstrFilename, "wb");
+ if(!outfile)
+ {
+ MessageBox(0, lpstrFilename, "Can't create file", MB_OK);
+ return 0;
+ }
+
+ /* open the encoder library */
+ hEncoder=faacEncOpen(lSamprate, wChannels, &samplesInput, &maxBytesOutput);
+ if(!hEncoder)
+ {
+ MessageBox(0, "Can't init library", "Error", MB_OK);
+ return 0;
+ }
+
+ if(!(pcmbuf=(short*)malloc(samplesInput*sizeof(short))))
+ {
+ MessageBox(0, "PCM buffer", "Memory allocation error", MB_OK);
+ return 0;
+ }
+ if(!(bitbuf=(unsigned char*)malloc(maxBytesOutput*sizeof(unsigned char))))
+ {
+ MessageBox(0, "Output buffer", "Memory allocation error", MB_OK);
+ return 0;
+ }
+
+ bytesEncoded=faacEncEncode(hEncoder, 0, 0, bitbuf, maxBytesOutput); // initializes the flushing process
+ if(bytesEncoded>0)
+ fwrite(bitbuf, 1, bytesEncoded, outfile);
+
+ *lpChunkSize=samplesInput*2;
+
+ hOutput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE,sizeof(MYOUTPUT));
+ if(hOutput)
+ {
+ MYOUTPUT *mo;
+ mo=(MYOUTPUT *)GlobalLock(hOutput);
+ mo->fFile=outfile;
+ mo->lSize=lSize;
+ mo->lSamprate=lSamprate;
+ mo->wBitsPerSample=wBitsPerSample;
+ mo->wChannels=wChannels;
+ mo->dwDataOffset=0; // ??
+ mo->bWrittenHeader=0;
+ strcpy(mo->szNAME,lpstrFilename);
+
+ mo->hEncoder=hEncoder;
+ mo->bitbuf=bitbuf;
+ mo->maxBytesOutput=maxBytesOutput;
+ mo->samplesInput=samplesInput;
+ mo->bStopEnc=0;
+
+ GlobalUnlock(hOutput);
+ }
+ else
+ MessageBox(0, "hOutput=NULL", "FAAC Error", MB_OK);
+
+ if(dwOptions==2)
+ {
+faacEncConfigurationPtr myFormat;
+ myFormat=faacEncGetCurrentConfiguration(hEncoder);
+
+ myFormat->mpegVersion=faacEncCfg.mpegVersion;
+ myFormat->aacObjectType=faacEncCfg.aacObjectType;
+ myFormat->allowMidside=faacEncCfg.allowMidside;
+ myFormat->useLfe=faacEncCfg.useLfe;
+ myFormat->useTns=faacEncCfg.useTns;
+ myFormat->bandWidth=faacEncCfg.bandWidth;
+ myFormat->bitRate=faacEncCfg.bitRate;
+
+ if(!faacEncSetConfiguration(hEncoder, myFormat))
+ {
+ MessageBox(0, "Unsupported parameters\n", "FAAC error", MB_OK);
+ return 0;
+ }
+ }
+
+ return hOutput;
+}
+
+__declspec(dllexport) DWORD FAR PASCAL WriteFilterOutput(HANDLE hOutput, unsigned char far *buf, long lBytes)
+{
+int bytesWritten;
+int bytesEncoded;
+unsigned char *bitbuf;
+
+ if(hOutput)
+ {
+ MYOUTPUT far *mo;
+
+ mo=(MYOUTPUT far *)GlobalLock(hOutput);
+
+ if(!mo->bStopEnc)
+ {
+ bitbuf=mo->bitbuf;
+
+// call the actual encoding routine
+ bytesEncoded=faacEncEncode(mo->hEncoder, (short *)buf, mo->samplesInput, bitbuf, mo->maxBytesOutput);
+ if(!bytesEncoded) // end of flushing process
+ mo->bStopEnc=1;
+ }
+
+ if(!bytesEncoded) // end of flushing process
+ {
+ GlobalUnlock(hOutput);
+ return 0;
+ }
+ else
+ if(bytesEncoded<0)
+ {
+ MessageBox(0, "faacEncEncode() failed", "Error", MB_OK);
+ GlobalUnlock(hOutput);
+ return 0;
+ }
+
+// write bitstream to aac file
+ bytesWritten=fwrite(bitbuf, 1, bytesEncoded, mo->fFile);
+
+ GlobalUnlock(hOutput);
+ }
+
+ if(bytesWritten!=bytesEncoded)
+ {
+ MessageBox(0, "bytesWritten and bytesEncoded are different", "Output error", MB_OK);
+ return 0;
+ }
+
+ return bytesWritten;
+}
--- /dev/null
+++ b/cooledit/faac.h
@@ -1,0 +1,107 @@
+/*
+ * FAAC - Freeware Advanced Audio Coder
+ * 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: faac.h,v 1.1 2001/07/02 07:26:01 menno Exp $
+ */
+
+#ifndef FAACLIB_H
+#define FAACLIB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifdef WIN32
+ #pragma pack(push, 8)
+ #ifndef FAACAPI
+ #define FAACAPI __stdcall
+ #endif
+#else
+ #ifndef FAACAPI
+ #define FAACAPI
+ #endif
+#endif
+
+#define FAACENC_VERSION 1.5
+#define FAACENC_VERSIONB 0 /* If 1 this version is still in beta */
+
+/* MPEG ID's */
+#define MPEG2 1
+#define MPEG4 0
+
+/* AAC object types */
+#define MAIN 0
+#define LOW 1
+#define SSR 2
+#define LTP 3
+
+typedef struct faacEncConfiguration
+{
+ /* MPEG version, 2 or 4 */
+ unsigned int mpegVersion;
+
+ /* AAC object type */
+ unsigned int aacObjectType;
+
+ /* Allow mid/side coding */
+ unsigned int allowMidside;
+
+ /* Use one of the channels as LFE channel */
+ unsigned int useLfe;
+
+ /* Use Temporal Noise Shaping */
+ unsigned int useTns;
+
+ /* bitrate / channel of AAC file */
+ unsigned long bitRate;
+
+ /* AAC file frequency bandwidth */
+ unsigned int bandWidth;
+
+} faacEncConfiguration, *faacEncConfigurationPtr;
+
+typedef void *faacEncHandle;
+
+
+faacEncConfigurationPtr FAACAPI faacEncGetCurrentConfiguration(faacEncHandle hEncoder);
+int FAACAPI faacEncSetConfiguration (faacEncHandle hEncoder, faacEncConfigurationPtr config);
+
+faacEncHandle FAACAPI faacEncOpen(unsigned long sampleRate,
+ unsigned int numChannels,
+ unsigned long *inputSamples,
+ unsigned long *maxOutputBytes);
+
+int FAACAPI faacEncEncode(faacEncHandle hEncoder,
+ short *inputBuffer,
+ unsigned int samplesInput,
+ void *outputBuffer,
+ unsigned int bufferSize
+ );
+
+int FAACAPI faacEncClose(faacEncHandle hEncoder);
+
+
+#ifdef WIN32
+ #pragma pack(pop)
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* FAACLIB_H */
\ No newline at end of file
--- /dev/null
+++ b/cooledit/faacflt.dsp
@@ -1,0 +1,147 @@
+# Microsoft Developer Studio Project File - Name="faacflt" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=faacflt - 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 "faacflt.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 "faacflt.mak" CFG="faacflt - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "faacflt - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "faacflt - 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)" == "faacflt - 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 /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x413 /d "NDEBUG"
+# ADD RSC /l 0x413 /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 odbc32.lib odbccp32.lib /nologo /subsystem:windows /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 /subsystem:windows /dll /machine:I386 /out:"Release/faac.flt"
+
+!ELSEIF "$(CFG)" == "faacflt - 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 /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x413 /d "_DEBUG"
+# ADD RSC /l 0x413 /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 odbc32.lib odbccp32.lib /nologo /subsystem:windows /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 /subsystem:windows /dll /debug /machine:I386 /out:"Debug/faac.flt" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "faacflt - Win32 Release"
+# Name "faacflt - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\AACINFO.C
+# End Source File
+# Begin Source File
+
+SOURCE=.\Faac.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\Faad.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\Main.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\AACINFO.H
+# End Source File
+# Begin Source File
+
+SOURCE=.\FAAC.H
+# End Source File
+# Begin Source File
+
+SOURCE=.\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"
+# Begin Source File
+
+SOURCE=.\FAAD.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\Logo.bmp
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null
+++ b/cooledit/faacflt.dsw
@@ -1,0 +1,59 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "faacflt"=.\faacflt.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
+}}}
+
+###############################################################################
+
+Project: "libfaac"=..\libfaac\libfaac.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "libfaad"=..\..\faad\libfaad\libfaad.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
--- /dev/null
+++ b/cooledit/faad.c
@@ -1,0 +1,406 @@
+#include <windows.h>
+#include <stdlib.h> // for atol conversion
+#include <stdio.h> // for FILE *
+#include "filters.h" //CoolEdit
+#include "resource.h"
+
+#include "faad.h"
+#include "aacinfo.h"
+
+
+#define MAX_CHANNELS 2
+
+
+faacDecHandle hDecoder;
+
+typedef struct input_tag // any special vars associated with input file
+{
+ FILE *fFile;
+ long lSize;
+ DWORD dwFormat;
+ WORD wChannels;
+ DWORD dwSamprate;
+ WORD wBitsPerSample;
+ DWORD dwDataOffset;
+ char szName[256];
+
+ faacDecHandle hDecoder;
+ faadAACInfo file_info;
+ unsigned char *buffer;
+ FILE *infile;
+ long file_len, tagsize, buffercount, fileread, bytecount;
+ char supported;
+ DWORD full_size;
+ DWORD bytes_left;
+} MYINPUT;
+
+/*
+static FILE *infile;
+static char Filename[1024];
+static faadAACInfo file_info;
+static long file_len;
+static char supported;
+DWORD samplerate, channels;
+DWORD full_size;
+*/
+static long tagsize, buffercount, fileread, bytecount, bytesFull;
+//BYTE buffer[768*MAX_CHANNELS];
+
+int id3v2_tag(unsigned char *buffer)
+{
+ if(StringComp(buffer, "ID3", 3) == 0)
+ {
+unsigned long tagsize;
+
+/* high bit is not used */
+ tagsize=(buffer[6] << 21) | (buffer[7] << 14) |
+ (buffer[8] << 7) | (buffer[9] << 0);
+ tagsize += 10;
+ return tagsize;
+ }
+ else
+ return 0;
+}
+
+__declspec(dllexport) BOOL FAR PASCAL FilterUnderstandsFormat(LPSTR filename)
+{
+WORD len;
+ if((len=lstrlen(filename))>4 &&
+ (!strcmpi(filename+len-4,".aac") ||
+ !strcmpi(filename+len-4,".mp4")))
+ return TRUE;
+ return FALSE;
+}
+
+__declspec(dllexport) long FAR PASCAL FilterGetFileSize(HANDLE hInput)
+{
+DWORD full_size;
+//DWORD pos;
+
+ if(hInput)
+ {
+ MYINPUT *mi;
+ mi=(MYINPUT *)GlobalLock(hInput);
+ full_size=mi->full_size;
+
+/* pos=ftell(mi->fFile);
+ fseek(mi->fFile, 0, SEEK_END);
+ fileread=ftell(mi->fFile);
+ fseek(mi->fFile, pos, SEEK_SET);*/
+ GlobalUnlock(hInput);
+ }
+
+ return full_size; //file_len;
+}
+
+__declspec(dllexport) DWORD FAR PASCAL FilterOptions(HANDLE hInput)
+{
+ return 0L;
+/* MYINPUT far *mi;
+ DWORD options;
+ if (!hInput) return 0;
+ mi=(MYINPUT far *)GlobalLock(hInput);
+
+ options=(DWORD)mi->dwFormat;
+ if (options==3)
+ options=2;
+
+ GlobalUnlock(hInput);
+
+ return options;*/
+}
+
+__declspec(dllexport) DWORD FAR PASCAL FilterOptionsString(HANDLE hInput, LPSTR szString)
+{
+char buf[20];
+
+ if(hInput)
+ {
+ MYINPUT *mi;
+ mi=(MYINPUT *)GlobalLock(hInput);
+
+ lstrcpy(szString,"");
+
+ if(mi->file_info.version == 2)
+ lstrcat(szString,"MPEG2 - ");
+ else
+ lstrcat(szString,"MPEG4 - ");
+
+ sprintf(buf,"%lu bps\n",mi->file_info.bitrate);
+ lstrcat(szString,buf);
+
+ switch(mi->file_info.headertype)
+ {
+ case 0: // Headerless
+ lstrcat(szString,"RAW\n");
+ return 0;
+ break;
+ case 1:
+ lstrcat(szString,"ADIF\n");
+ break;
+ case 2:
+ lstrcat(szString,"ADTS\n");
+ break;
+ }
+
+ switch(mi->file_info.object_type)
+ {
+ case 0:
+ lstrcat(szString,"Main");
+ break;
+ case 1:
+ lstrcat(szString,"Low Complexity");
+ break;
+ case 2:
+ lstrcat(szString,"SSR (unsupported)");
+ break;
+ case 3:
+ lstrcat(szString,"Main LTP");
+ break;
+ }
+
+ GlobalUnlock(hInput);
+ }
+ return 1;
+}
+
+__declspec(dllexport) DWORD FAR PASCAL FilterGetFirstSpecialData(HANDLE hInput,
+ SPECIALDATA * psp)
+{
+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)
+ {
+ MYINPUT far *mi;
+ mi=(MYINPUT far *)GlobalLock(hInput);
+
+ if(mi->fFile)
+ {
+ fclose(mi->fFile);
+ mi->fFile=0;
+ }
+
+ GlobalUnlock(hInput);
+ GlobalFree(hInput);
+ }
+}
+
+// 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 hInput;
+DWORD k;
+int shift;
+FILE *infile;
+DWORD samplerate, channels;
+DWORD pos;
+int *seek_table;
+faadAACInfo file_info;
+unsigned char *buffer;
+
+ hInput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(MYINPUT));
+ if(hInput)
+ {
+ MYINPUT *mi;
+ mi=(MYINPUT *)GlobalLock(hInput);
+
+ if(!(infile=fopen(lpstrFilename,"rb")))
+ {
+ GlobalUnlock(hInput);
+ return 0;
+ }
+
+ mi->fFile=infile;
+
+ pos=ftell(infile);
+ fseek(infile, 0, SEEK_END);
+ mi->lSize=ftell(infile);
+ fseek(infile, pos, SEEK_SET);
+
+ if(!(buffer=(unsigned char*)malloc(768*MAX_CHANNELS)))
+ {
+ MessageBox(0, "buffer", "Memory allocation error", MB_OK);
+ GlobalUnlock(hInput);
+ return 0;
+ }
+ mi->buffer=buffer;
+ memset(buffer, 0, 768*MAX_CHANNELS);
+
+ buffercount=bytecount=0;
+ fread(buffer, 1, 768*MAX_CHANNELS, infile);
+
+ tagsize=id3v2_tag(buffer);
+ mi->bytes_left=mi->lSize-tagsize;
+ if(tagsize)
+ {
+ bytecount = tagsize;
+ buffercount = 0;
+ for (k=0; k<(768*MAX_CHANNELS - tagsize); k++)
+ buffer[k]=buffer[k + tagsize];
+ shift=(768*MAX_CHANNELS)-tagsize;
+ fread(buffer+shift, 1, shift, infile);
+ }
+
+ hDecoder = faacDecOpen();
+ if(!hDecoder)
+ {
+ MessageBox(0, "Can't init library", "Error", MB_OK);
+ return 0;
+ }
+ if((buffercount=faacDecInit(hDecoder, buffer, &samplerate, &channels)) < 0)
+ {
+ MessageBox(hWnd, "Error retrieving information form input file", "FAAD Error", MB_OK);
+ return 0;
+ }
+ // bytes will be shifted in ReadFilterInput
+
+ *lSamprate=samplerate;
+ *wBitsPerSample=16;
+ *wChannels=channels;
+ *lChunkSize=sizeof(short)*1024*channels; //16384;
+
+ if(buffercount>0) // faacDecInit reports there is an header to skip
+ {
+// file_len-=buffercount;
+ bytecount+=buffercount;
+ for (k=0; k<(768*MAX_CHANNELS - buffercount); k++)
+ buffer[k]=buffer[k + buffercount];
+ shift=(768*MAX_CHANNELS)-buffercount;
+ fread(buffer+shift, 1, buffercount, infile);
+ buffercount=0;
+ }
+
+ mi->dwFormat=0;
+ mi->wChannels=channels;
+ mi->dwSamprate=samplerate;
+ mi->wBitsPerSample=*wBitsPerSample;
+ mi->dwDataOffset=0;
+ strcpy(mi->szName,lpstrFilename);
+
+ mi->hDecoder=hDecoder;
+ mi->tagsize=tagsize;
+
+ file_info.version=0;
+ if(seek_table=(int*)LocalAlloc(LPTR, 10800*sizeof(int)))
+ {
+ get_AAC_format(mi->szName, &file_info, seek_table);
+ LocalFree(seek_table);
+ }
+ else
+ file_info.version='?';
+ memcpy(&(mi->file_info),&file_info,sizeof(file_info));
+ if(file_info.length)
+ mi->full_size=(DWORD)(file_info.length*((float)samplerate/1000)*channels*(16/8));
+ else
+ {
+ GlobalUnlock(hInput);
+ return 0;
+ }
+
+ if(file_info.object_type==2)
+ mi->supported=0;
+ else
+ mi->supported=1;
+
+ GlobalUnlock(hInput);
+ }
+
+ bytesFull=0;
+
+ return hInput;
+}
+
+__declspec(dllexport) DWORD FAR PASCAL ReadFilterInput(HANDLE hInput, unsigned char far *bufout, long lBytes)
+{
+DWORD read=0,
+ bytesconsumed,
+ bytestot=0,
+ k;
+int result;
+unsigned char *buffer;
+
+// MessageBox(0, "ReadFilterInput", "FAAD Error", MB_OK);
+
+
+ if(hInput)
+ {
+ MYINPUT *mi;
+ mi=(MYINPUT *)GlobalLock(hInput);
+
+ buffer=mi->buffer;
+
+ if(!mi->supported)
+ {
+ MessageBox(0, "ReadFilterInput: format not supported", "FAAD Error", MB_OK);
+ GlobalUnlock(hInput);
+ return 0;
+ }
+
+ if(mi->bytes_left<buffercount)
+ mi->bytes_left=0;
+ else
+ mi->bytes_left-=buffercount;
+
+ if(bytesFull>mi->full_size)
+ {
+// MessageBox(0, "ReadFilterInput: bytesFull>mi->lSize", "FAAD Error", MB_OK);
+ GlobalUnlock(hInput);
+ return 0;
+ }
+
+ if(!mi->bytes_left)
+ {
+ GlobalUnlock(hInput);
+ return 0;
+ }
+
+ if(buffercount>0)
+ {
+ for(k=0; k<(768*MAX_CHANNELS - buffercount); k++)
+ buffer[k]=buffer[k + buffercount];
+
+ read=fread(buffer+(768*MAX_CHANNELS)-buffercount, buffercount, 1, mi->fFile);
+ if(!read)
+ memset(buffer+(768*MAX_CHANNELS)-buffercount, 0, buffercount);
+ buffercount=0;
+ }
+
+ result=faacDecDecode(hDecoder, buffer, &bytesconsumed, (short*)bufout);
+
+ if(result>FAAD_OK_CHUPDATE) // FAAD_FATAL_ERROR or FAAD_ERROR
+ mi->bytes_left=0;
+
+ bytestot=sizeof(short)*1024*mi->wChannels;
+
+ GlobalUnlock(hInput);
+ }
+/*
+ switch(result)
+ {
+ case FAAD_FATAL_ERROR:
+ MessageBox(0, "Fatal error decoding input file\n", "FAAD error", MB_OK);
+ return 0;
+ case FAAD_ERROR:
+ return bytestot;
+ }
+*/
+ buffercount=bytesconsumed;
+ bytecount+=bytesconsumed;
+ bytesFull+=bytestot;
+
+ return bytestot;// read;
+}
--- /dev/null
+++ b/cooledit/faad.h
@@ -1,0 +1,84 @@
+/*
+ * 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: faad.h,v 1.1 2001/07/02 07:26:01 menno Exp $
+ */
+
+#ifndef _AACDEC_H
+#define _AACDEC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifdef WIN32
+ #pragma pack(push, 8)
+ #ifndef FAADAPI
+ #define FAADAPI __stdcall
+ #endif
+#else
+ #ifndef FAADAPI
+ #define FAADAPI
+ #endif
+#endif
+
+#define FAAD_OK 0
+#define FAAD_OK_CHUPDATE 1
+#define FAAD_ERROR 2
+#define FAAD_FATAL_ERROR 3
+
+typedef void *faacDecHandle;
+typedef void *faacProgConfig;
+
+typedef struct faacDecConfiguration
+{
+ unsigned int dummy;
+} faacDecConfiguration, *faacDecConfigurationPtr;
+
+
+faacDecHandle FAADAPI faacDecOpen();
+
+faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDecoder);
+
+int FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder,
+ faacDecConfigurationPtr config);
+
+int FAADAPI faacDecInit(faacDecHandle hDecoder,
+ unsigned char *buffer,
+ unsigned long *samplerate,
+ unsigned long *channels);
+
+int FAADAPI faacDecGetProgConfig(faacDecHandle hDecoder,
+ faacProgConfig *progConfig);
+
+int FAADAPI faacDecDecode(faacDecHandle hDecoder,
+ unsigned char *buffer,
+ unsigned long *bytesconsumed,
+ short *sample_buffer);
+
+void FAADAPI faacDecClose(faacDecHandle hDecoder);
+
+#endif
+
+#ifdef WIN32
+ #pragma pack(pop)
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
--- /dev/null
+++ b/cooledit/filters.h
@@ -1,0 +1,121 @@
+//////////////////////////////////////////////////////
+// GENERAL PURPOSE DEFS FOR CREATING CUSTOM FILTERS //
+//////////////////////////////////////////////////////
+
+
+typedef struct riffspecialdata_t
+{ HANDLE hSpecialData;
+ HANDLE hData; // Actual data handle
+ DWORD dwSize; // size of data in handle
+ DWORD dwExtra; // optional extra data (usually a count)
+ char szListType[8]; // Parent list type (usually "WAVE" or "INFO", or "adtl")
+ char szType[8]; // Usually a four character code for data, but can be up to 7 chars
+} SPECIALDATA;
+
+// "CUE " dwExtra=number of cues, each cue is 8 bytes ([4] name [4] sample offset)
+// "LTXT" dwExtra=number of items, each one is 8 bytes ([4] ltxt len [4] name [4] cue length [4] purpose [n] data)
+// "NOTE" dwExtra=number of strings, each one is n bytes ([4] name [n-4] length zero term)
+// "LABL" dwExtra=number of strings, each one is n bytes ([4] name [n-4] length zero term)
+// "PLST" dwExtra=number if items, each one is 16 bytes ([4] name [4] dwLen [4] dwLoops [4] dwMode)
+
+
+// For special data, .FLT must implement FilterGetFirstSpecialData and FilterGetNextSpecialData
+
+
+typedef DWORD FOURCC; // a four character code
+
+struct cue_type { DWORD dwName;
+ DWORD dwPosition;
+ FOURCC fccChunk;
+ DWORD dwChunkStart;
+ DWORD dwBlockStart;
+ DWORD dwSampleOffset;
+ };
+
+struct play_type {DWORD dwName;
+ DWORD dwLength;
+ DWORD dwLoops;
+ };
+
+
+typedef struct coolquery_tag
+ {char szName[24];
+ char szCopyright[80];
+
+ // rate table, bits are set for modes that can be handled
+ WORD Quad32; // Quads are 3-D encoded
+ WORD Quad16;
+ WORD Quad8;
+ WORD Stereo8; // rates are from lowest bit:
+ WORD Stereo12; // bit 0 set: 5500 (5512.5)
+ WORD Stereo16; // bit 1 set: 11025 (11K)
+ WORD Stereo24; // bit 2 set: 22050 (22K)
+ WORD Stereo32; // bit 3 set: 32075 (32K, or 32000)
+ WORD Mono8; // bit 4 set: 44100 (44K)
+ WORD Mono12; // bit 5 set: 48000 (48K)
+ WORD Mono16; // bit 6 set: 88200 (88K) (future ultra-sonic rates?)
+ WORD Mono24; // bit 7 set: 96000 (96K)
+ WORD Mono32; // bit 8 set: 132300 (132K)
+ // bit 9 set: 176400 (176K)
+ DWORD dwFlags;
+ char szExt[4];
+ long lChunkSize;
+ char szExt2[4];
+ char szExt3[4];
+ char szExt4[4];
+ } COOLQUERY;
+
+#define R_5500 1
+#define R_11025 2
+#define R_22050 4
+#define R_32075 8
+#define R_44100 16
+#define R_48000 32
+#define R_88200 64
+#define R_96000 128
+#define R_132300 256
+#define R_176400 512
+
+#define C_VALIDLIBRARY 1154
+
+#define QF_RATEADJUSTABLE 0x001 // if can handle non-standard sample rates
+ // if not, only rates in bit rate table understood
+#define QF_CANSAVE 0x002
+#define QF_CANLOAD 0x004
+#define QF_UNDERSTANDSALL 0x008 // will read ANYTHING, so it is the last resort if no other
+ // formats match
+#define QF_READSPECIALFIRST 0x010 // read special info before trying to read data
+#define QF_READSPECIALLAST 0x020 // read special info after reading data
+#define QF_WRITESPECIALFIRST 0x040 // when writing a file, special info is sent to DLL before data
+#define QF_WRITESPECIALLAST 0x080 // when writing, special info is sent to DLL after data
+#define QF_HASOPTIONSBOX 0x100 // set if options box implemented
+#define QF_NOASKFORCONVERT 0x200 // set to bypass asking for conversion if original in different rate, auto convert
+#define QF_NOHEADER 0x400 // set if this is a raw data format with no header
+#define QF_CANDO32BITFLOATS 0x800 // set if file format can handle 32-bit sample data for input
+#define QF_CANOPENVIRTUAL 0x1000 // Set if data is in Intel 8-bit or 16-bit sample format, or floats
+ // and the GetDataOffset() function is implemented
+
+// special types are read from and written to DLL in the order below
+/*
+// special types (particular to Windows waveforms)
+#define SP_IART 20
+#define SP_ICMT 21
+#define SP_ICOP 22
+#define SP_ICRD 23
+#define SP_IENG 24
+#define SP_IGNR 25
+#define SP_IKEY 26
+#define SP_IMED 27
+#define SP_INAM 28
+#define SP_ISFT 29
+#define SP_ISRC 30
+#define SP_ITCH 31
+#define SP_ISBJ 32
+#define SP_ISRF 33
+#define SP_DISP 34
+#define SP_CUE 40 // returns number of cues of size cue_type
+#define SP_LTXT 41 // returns number of adtl texts of size 8 (4,id and 4,len)
+#define SP_NOTE 42 // returns LO=size, HI=number of strings (sz sz sz...)
+#define SP_LABL 43 // returns LO=size, HI=number of strings (sz sz sz...)
+#define SP_PLST 44 // returns number of playlist entries size play_type
+*/
\ No newline at end of file
--- /dev/null
+++ b/cooledit/main.c
@@ -1,0 +1,217 @@
+#include <windows.h>
+#include <stdlib.h>
+#include "resource.h"
+#include "filters.h" //CoolEdit
+#include "faac.h"
+
+extern faacEncConfiguration faacEncCfg;
+
+
+BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
+{
+ switch (fdwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ /* Code from LibMain inserted here. Return TRUE to keep the
+ DLL loaded or return FALSE to fail loading the DLL.
+
+ You may have to modify the code in your original LibMain to
+ account for the fact that it may be called more than once.
+ You will get one DLL_PROCESS_ATTACH for each process that
+ loads the DLL. This is different from LibMain which gets
+ called only once when the DLL is loaded. The only time this
+ is critical is when you are using shared data sections.
+ If you are using shared data sections for statically
+ allocated data, you will need to be careful to initialize it
+ only once. Check your code carefully.
+
+ Certain one-time initializations may now need to be done for
+ each process that attaches. You may also not need code from
+ your original LibMain because the operating system may now
+ be doing it for you.
+ */
+ break;
+
+ case DLL_THREAD_ATTACH:
+ /* Called each time a thread is created in a process that has
+ already loaded (attached to) this DLL. Does not get called
+ for each thread that exists in the process before it loaded
+ the DLL.
+
+ Do thread-specific initialization here.
+ */
+ break;
+
+ case DLL_THREAD_DETACH:
+ /* Same as above, but called when a thread in the process
+ exits.
+
+ Do thread-specific cleanup here.
+ */
+ break;
+
+ case DLL_PROCESS_DETACH:
+ /* Code from _WEP inserted here. This code may (like the
+ LibMain) not be necessary. Check to make certain that the
+ operating system is not doing it for you.
+ */
+ break;
+ }
+
+ /* The return value is only used for DLL_PROCESS_ATTACH; all other
+ conditions are ignored. */
+ return TRUE; // successful DLL_PROCESS_ATTACH
+}
+
+// Fill COOLQUERY structure with information regarding this file filter
+
+__declspec(dllexport) short FAR PASCAL QueryCoolFilter(COOLQUERY far * cq)
+{
+ lstrcpy(cq->szName,"MPEG4-AAC Format");
+ lstrcpy(cq->szCopyright,"Freeware AAC-MPEG4 codec");// Compiled on: " __DATE__);
+ lstrcpy(cq->szExt,"AAC");
+ lstrcpy(cq->szExt2,"MP4");
+ cq->lChunkSize=16384;
+ cq->dwFlags=QF_RATEADJUSTABLE|QF_CANLOAD|QF_CANSAVE|QF_HASOPTIONSBOX;
+ cq->Stereo8=0xFF; // supports all rates of stereo 8
+ cq->Stereo16=0xFF;
+ cq->Stereo24=0xFF;
+ cq->Stereo32=0xFF;
+ cq->Mono8=0xFF; // supports all rates of stereo 8
+ cq->Mono16=0xFF;
+ cq->Mono24=0xFF;
+ cq->Mono32=0xFF;
+ cq->Quad32=0xFF;
+ cq->Quad16=0xFF;
+ cq->Quad8=0xFF;
+ return C_VALIDLIBRARY;
+}
+
+__declspec(dllexport) BOOL FAR PASCAL DIALOGMsgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
+{
+ switch(Message)
+ {
+ case WM_INITDIALOG:
+ {
+ 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, 11, 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, 3, 0);
+
+ CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, TRUE);
+ CheckDlgButton(hWndDlg, IDC_USETNS, TRUE);
+ CheckDlgButton(hWndDlg, IDC_USELFE, FALSE);
+
+ switch((long)lParam)
+ {
+ case 1:
+ CheckDlgButton(hWndDlg,IDC_RADIO1,TRUE);
+ break;
+ case 2:
+ CheckDlgButton(hWndDlg,IDC_RADIO2,TRUE);
+ break;
+ case 3:
+ CheckDlgButton(hWndDlg,IDC_RADIO3,TRUE);
+ break;
+ case 4:
+ CheckDlgButton(hWndDlg,IDC_RADIO4,TRUE);
+ break;
+ case 5:
+ CheckDlgButton(hWndDlg,IDC_RADIO5,TRUE);
+ break;
+ case 6:
+ CheckDlgButton(hWndDlg,IDC_RADIO6,TRUE);
+ break;
+ case 7:
+ CheckDlgButton(hWndDlg,IDC_RADIO7,TRUE);
+ break;
+ case 8:
+ CheckDlgButton(hWndDlg,IDC_RADIO8,TRUE);
+ break;
+ case 9:
+ CheckDlgButton(hWndDlg,IDC_RADIO9,TRUE);
+ break;
+ default:
+ CheckDlgButton(hWndDlg,IDC_RADIO1,TRUE);
+ CheckDlgButton(hWndDlg,IDC_RADIO3,TRUE);
+ CheckDlgButton(hWndDlg,IDC_RADIO7,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 IDOK:
+ {
+ char szTemp[10];
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO1))
+ faacEncCfg.mpegVersion=4;
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO2))
+ faacEncCfg.mpegVersion=2;
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO3))
+ faacEncCfg.aacObjectType=0;
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO4))
+ faacEncCfg.aacObjectType=1;
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO5))
+ faacEncCfg.aacObjectType=2;
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO6))
+ faacEncCfg.aacObjectType=3;
+/* if(IsDlgButtonChecked(hWndDlg,IDC_RADIO7))
+ faacEncCfg=;
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO8))
+ faacEncCfg=;
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO9))
+ faacEncCfg=;*/
+
+ faacEncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_ALLOWMIDSIDE) == BST_CHECKED ? 1 : 0;
+ faacEncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_USETNS) == BST_CHECKED ? 1 : 0;
+ faacEncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_USELFE) == BST_CHECKED ? 1 : 0;
+
+ GetDlgItemText(hWndDlg, IDC_CB_BITRATE, szTemp, sizeof(szTemp));
+ faacEncCfg.bitRate=atoi(szTemp);
+ GetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, szTemp, sizeof(szTemp));
+ faacEncCfg.bandWidth=atoi(szTemp);
+
+ EndDialog(hWndDlg, (short)2);
+ }
+ break;
+ case IDCANCEL:
+ // Ignore data values entered into the controls
+ // and dismiss the dialog window returning FALSE
+ EndDialog(hWndDlg, FALSE);
+ break;
+ }
+ break; // End of WM_COMMAND
+ }
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}// End of DIALOGSMsgProc
--- /dev/null
+++ b/cooledit/resource.h
@@ -1,0 +1,31 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by FAAD.rc
+//
+#define IDD_COMPRESSION 101
+#define IDB_LOGO 104
+#define IDC_RADIO1 1000
+#define IDC_RADIO2 1001
+#define IDC_RADIO4 1002
+#define IDC_RADIO3 1003
+#define IDC_RADIO5 1004
+#define IDC_RADIO6 1005
+#define IDC_RADIO7 1006
+#define IDC_RADIO8 1007
+#define IDC_RADIO9 1008
+#define IDC_ALLOWMIDSIDE 1011
+#define IDC_USETNS 1012
+#define IDC_USELFE 1013
+#define IDC_CB_BANDWIDTH 1015
+#define IDC_CB_BITRATE 1017
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1020
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif