ref: a929acdf788d7899bf2631e0f8b9a2acdae09ef7
parent: 0557336a25dd337e46f5462c75aad68b77803cba
author: menno <menno>
date: Sat Apr 20 11:09:56 EDT 2002
Updated cooledit code plugin now supports MP4 files
--- /dev/null
+++ b/plugins/cooledit/Aacinfo.cpp
@@ -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.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.c
+++ /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/Config.cpp
@@ -1,0 +1,42 @@
+#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);
+}
--- a/plugins/cooledit/FAAD.DSP
+++ b/plugins/cooledit/FAAD.DSP
@@ -43,7 +43,7 @@
# 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 /MT /W3 /GX /O2 /I "../../include" /I "../../../faad2/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /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"
@@ -53,7 +53,7 @@
# 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 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\FAAD2.flt"
+# 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"
@@ -70,7 +70,7 @@
# 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 /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../../faad2/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /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"
@@ -80,7 +80,7 @@
# 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 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\FAAD2.flt"
+# 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
@@ -94,31 +94,31 @@
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
# Begin Source File
-SOURCE=.\aacinfo.c
+SOURCE=.\Aacinfo.cpp
# End Source File
# Begin Source File
-SOURCE=.\Config.c
+SOURCE=.\Faac.cpp
# End Source File
# Begin Source File
-SOURCE=.\FAAC.c
+SOURCE=.\Faad.cpp
# End Source File
# Begin Source File
-SOURCE=.\FAAD.C
+SOURCE=.\FAAD.def
# End Source File
# Begin Source File
-SOURCE=.\FAAD.def
+SOURCE=.\FAAD.rc
# End Source File
# Begin Source File
-SOURCE=.\FAAD.rc
+SOURCE=.\Main.cpp
# End Source File
# Begin Source File
-SOURCE=.\Main.c
+SOURCE=.\Registry.cpp
# End Source File
# End Group
# Begin Group "Header Files"
@@ -135,6 +135,10 @@
# Begin Source File
SOURCE=.\filters.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Registry.h
# End Source File
# Begin Source File
--- a/plugins/cooledit/FAAD.rc
+++ b/plugins/cooledit/FAAD.rc
@@ -26,7 +26,7 @@
// Dialog
//
-IDD_COMPRESSION DIALOG DISCARDABLE 0, 0, 176, 127
+IDD_COMPRESSION DIALOG DISCARDABLE 0, 0, 184, 126
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "AAC-MPEG4 options"
FONT 8, "MS Sans Serif"
@@ -45,23 +45,28 @@
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,59,21,63,10
+ BS_AUTOCHECKBOX | WS_TABSTOP,108,21,63,10
CONTROL "Use TNS",IDC_USETNS,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,59,33,45,10
+ WS_TABSTOP,108,33,45,10
CONTROL "Use LFE channel",IDC_USELFE,"Button",BS_AUTOCHECKBOX |
- WS_DISABLED | WS_TABSTOP,59,46,67,10
- COMBOBOX IDC_CB_BITRATE,124,68,48,30,CBS_DROPDOWNLIST |
+ WS_DISABLED | WS_TABSTOP,108,46,67,10
+ COMBOBOX IDC_CB_BITRATE,132,68,48,30,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
- COMBOBOX IDC_CB_BANDWIDTH,124,85,48,30,CBS_DROPDOWN | WS_VSCROLL |
+ COMBOBOX IDC_CB_BANDWIDTH,132,85,48,30,CBS_DROPDOWN | WS_VSCROLL |
WS_TABSTOP
- DEFPUSHBUTTON "OK",IDOK,64,108,36,14
- PUSHBUTTON "Cancel",IDCANCEL,100,108,36,14
- PUSHBUTTON "About",IDC_BTN_ABOUT,136,108,36,14
+ 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,63,48,59
+ GROUPBOX "Profile",IDC_STATIC,4,62,48,59
LTEXT "Bitrate per channel",IDC_STATIC,59,73,60,8
LTEXT "Bandwidth (0=full)",IDC_STATIC,59,89,57,8
+ GROUPBOX "Header",IDC_STATIC,55,18,48,38
END
@@ -102,9 +107,9 @@
IDD_COMPRESSION, DIALOG
BEGIN
LEFTMARGIN, 4
- RIGHTMARGIN, 172
+ RIGHTMARGIN, 180
TOPMARGIN, 4
- BOTTOMMARGIN, 122
+ BOTTOMMARGIN, 121
END
END
#endif // APSTUDIO_INVOKED
--- /dev/null
+++ b/plugins/cooledit/Faac.cpp
@@ -1,0 +1,479 @@
+#include <windows.h>
+#include <stdio.h> // FILE *
+#include "filters.h" //CoolEdit
+#include "resource.h"
+#include "faac.h"
+#include "registry.h"
+
+
+
+#define PI_VER "v2.0 beta1"
+#define REGISTRY_PROGRAM_NAME "SOFTWARE\\4N\\CoolEdit\\AAC-MPEG4"
+
+
+
+typedef struct output_tag // any special vars associated with output file
+{
+ FILE *fFile;
+ DWORD lSize;
+ long lSamprate;
+ WORD wBitsPerSample;
+ WORD wChannels;
+ char szNAME[256];
+
+ faacEncHandle hEncoder;
+ unsigned char *bitbuf;
+ DWORD maxBytesOutput;
+ long samplesInput;
+ BYTE bStopEnc;
+} MYOUTPUT;
+
+
+
+typedef struct mc
+{
+bool AutoCfg;
+faacEncConfiguration EncCfg;
+} MYCFG;
+
+void RD_Cfg(MYCFG *cfg)
+{
+registryClass *reg=new registryClass();
+
+ 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);
+ delete reg;
+}
+
+void WR_Cfg(MYCFG *cfg)
+{
+registryClass *reg=new registryClass();
+
+ 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);
+ delete reg;
+}
+
+#define DISABLE_LTP \
+{ \
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \
+ IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \
+ { \
+ CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); \
+ CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); \
+ } \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \
+}
+
+// EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
+// EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
+#define DISABLE_CTRL(Enabled) \
+{ \
+ CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_RAW), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_ADTS), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled); \
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4)) \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
+ else \
+ DISABLE_LTP \
+}
+
+__declspec(dllexport) BOOL FAR PASCAL DIALOGMsgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
+{
+//DWORD dwOptions=(DWORD)lParam;
+
+
+ switch(Message)
+ {
+ case WM_INITDIALOG:
+ {
+ char buf[10];
+ MYCFG cfg;
+
+ RD_Cfg(&cfg);
+
+ 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(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);
+ sprintf(buf,"%lu",cfg.EncCfg.bitRate);
+ SetDlgItemText(hWndDlg, IDC_CB_BITRATE, buf);
+ sprintf(buf,"%lu",cfg.EncCfg.bandWidth);
+ SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf);
+
+ CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, cfg.AutoCfg);
+
+ DISABLE_CTRL(!cfg.AutoCfg);
+ }
+ 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 IDOK:
+ {
+ HANDLE hCfg=(HANDLE)lParam;
+ MYCFG far *cfg=0;
+
+ if(!(hCfg=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE,sizeof(MYCFG))))
+ return TRUE;
+ cfg=(MYCFG *)GlobalLock(hCfg);
+
+ 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);
+ cfg->EncCfg.bitRate=1000*GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
+ cfg->EncCfg.bandWidth=GetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, 0, FALSE);
+ cfg->EncCfg.outputFormat=IsDlgButtonChecked(hWndDlg,IDC_RADIO_RAW) ? 0 : 1;
+ WR_Cfg(cfg);
+
+ GlobalUnlock(hCfg);
+// dwOptions=(DWORD)hCfg;
+
+ EndDialog(hWndDlg, (DWORD)hCfg);
+ }
+ break;
+
+ case IDCANCEL:
+ // Ignore data values entered into the controls
+ // and dismiss the dialog window returning FALSE
+ EndDialog(hWndDlg, FALSE);
+ break;
+
+ case IDC_BTN_ABOUT:
+ {
+ char buf[256];
+ sprintf(buf, "AAC-MPEG4 plugin %s by 4N\n"
+ "This plugin uses FAAC encoder engine v%g and FAAD2 decoder engine\n\n"
+ "Compiled on %s\n",
+ PI_VER,
+ 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;
+
+ case IDC_RADIO_MPEG2:
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
+ DISABLE_LTP
+ break;
+ }
+ break; // End of WM_COMMAND
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+} // 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
+{
+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);
+
+ return nDialogReturn;
+}
+
+__declspec(dllexport) DWORD FAR PASCAL FilterWriteFirstSpecialData(HANDLE hInput,
+ SPECIALDATA * psp)
+{
+ 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)
+ {
+ MYOUTPUT *mo;
+ mo=(MYOUTPUT *)GlobalLock(hOutput);
+
+ if(mo->fFile)
+ {
+ fclose(mo->fFile);
+ mo->fFile=0;
+ }
+
+ if(mo->hEncoder)
+ 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;
+faacEncHandle hEncoder;
+FILE *outfile;
+unsigned char *bitbuf;
+DWORD maxBytesOutput;
+DWORD samplesInput;
+int bytesEncoded;
+
+// if(!((dwOptions>>23)&1))
+/* {
+ config_init();
+ config_read(&dwOptions);
+ }
+*/
+// open the aac output file
+ if(!(outfile=fopen(lpstrFilename, "wb")))
+ {
+ MessageBox(0, "Can't create file", "FAAC interface", MB_OK);
+ return 0;
+ }
+
+// open the encoder library
+ if(!(hEncoder=faacEncOpen(lSamprate, wChannels, &samplesInput, &maxBytesOutput)))
+ {
+ MessageBox(0, "Can't init library", "FAAC interface", MB_OK);
+ fclose(outfile);
+ return 0;
+ }
+
+ if(!(bitbuf=(unsigned char*)malloc(maxBytesOutput*sizeof(unsigned char))))
+ {
+ MessageBox(0, "Memory allocation error: output buffer", "FAAC interface", MB_OK);
+ faacEncClose(hEncoder);
+ fclose(outfile);
+ return 0;
+ }
+
+ *lpChunkSize=samplesInput*2;
+
+ hOutput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE,sizeof(MYOUTPUT));
+ if(hOutput)
+ {
+ MYCFG cfg;
+ MYOUTPUT *mo;
+ mo=(MYOUTPUT *)GlobalLock(hOutput);
+
+ RD_Cfg(&cfg);
+ if(!cfg.AutoCfg)
+ {
+ faacEncConfigurationPtr myFormat=&cfg.EncCfg;
+// myFormat=faacEncGetCurrentConfiguration(hEncoder);
+
+ if(!myFormat->bandWidth)
+ myFormat->bandWidth=lSamprate/2;
+
+ if(!faacEncSetConfiguration(hEncoder, myFormat))
+ {
+ MessageBox(0, "Unsupported parameters", "FAAC interface", MB_OK);
+ faacEncClose(hEncoder);
+ fclose(outfile);
+ free(bitbuf);
+ GlobalFree(hOutput);
+ return 0;
+ }
+ }
+
+ 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;
+
+ GlobalUnlock(hOutput);
+ }
+ else
+ {
+ MessageBox(0, "hOutput=NULL", "FAAC interface", MB_OK);
+ faacEncClose(hEncoder);
+ fclose(outfile);
+ free(bitbuf);
+ return 0;
+ }
+
+
+// init flushing process
+ bytesEncoded=faacEncEncode(hEncoder, 0, 0, bitbuf, maxBytesOutput); // initializes the flushing process
+ if(bytesEncoded>0)
+ fwrite(bitbuf, 1, bytesEncoded, outfile);
+
+ return hOutput;
+}
+
+__declspec(dllexport) DWORD FAR PASCAL WriteFilterOutput(HANDLE hOutput, unsigned char far *buf, long lBytes)
+{
+int bytesWritten;
+int bytesEncoded;
+
+ if(hOutput)
+ {
+ MYOUTPUT far *mo;
+ mo=(MYOUTPUT far *)GlobalLock(hOutput);
+
+ if(!mo->bStopEnc)
+ {
+// call the actual encoding routine
+ bytesEncoded=faacEncEncode(mo->hEncoder, (short *)buf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
+ if(bytesEncoded<1) // end of flushing process
+ {
+ if(bytesEncoded<0)
+ {
+ MessageBox(0, "faacEncEncode() failed", "FAAC interface", MB_OK);
+ mo->bStopEnc=1;
+ }
+ bytesWritten=lBytes ? 1 : 0; // bytesWritten==0 stops CoolEdit...
+ GlobalUnlock(hOutput);
+ return bytesWritten;
+ }
+// write bitstream to aac file
+ bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
+ if(bytesWritten!=bytesEncoded)
+ {
+ MessageBox(0, "bytesWritten and bytesEncoded are different", "FAAC interface", MB_OK);
+ mo->bStopEnc=1;
+ GlobalUnlock(hOutput);
+ return 0;
+ }
+
+ GlobalUnlock(hOutput);
+ }
+ }
+
+ return bytesWritten;
+}
--- /dev/null
+++ b/plugins/cooledit/Faad.cpp
@@ -1,0 +1,533 @@
+#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"
+
+
+#define MAX_CHANNELS 2
+#define QWORD __int32
+
+
+typedef struct input_tag // any special vars associated with input file
+{
+//AAC
+ FILE *fFile;
+ DWORD lSize;
+ 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;
+ unsigned char type;
+
+// GENERAL
+ faacDecHandle hDecoder;
+ faadAACInfo file_info;
+ QWORD len_ms;
+ WORD 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;
+} 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"
+};
+
+int id3v2_tag(unsigned char *buffer)
+{
+ if(StringComp((const char *)buffer, "ID3", 3) == 0)
+ {
+unsigned long tagsize;
+
+// high bit is not used
+ tagsize=(buffer[6] << 21) | (buffer[7] << 14) |
+ (buffer[8] << 7) | (buffer[9] << 0);
+ tagsize += 10;
+ return tagsize;
+ }
+ else
+ return 0;
+}
+
+int GetAACTrack(MP4FileHandle infile)
+{
+ /* find AAC track */
+ int i, rc;
+ int numTracks = MP4GetNumberOfTracks(infile, NULL);
+
+ for (i = 0; i < numTracks; i++)
+ {
+ MP4TrackId trackId = MP4FindTrackId(infile, i, NULL);
+ const char* trackType = MP4GetTrackType(infile, trackId);
+
+ if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE))
+ {
+ unsigned char *buff = NULL;
+ unsigned __int32 buff_size = 0;
+ DWORD dummy;
+ unsigned char ch_dummy;
+ MP4GetTrackESConfiguration(infile, trackId, &buff, &buff_size);
+
+ if (buff)
+ {
+ rc = AudioSpecificConfig(buff, &dummy, &ch_dummy, &ch_dummy, &ch_dummy);
+ free(buff);
+
+ if (rc < 0)
+ return -1;
+ return trackId;
+ }
+ }
+ }
+
+ /* can't decode this */
+ return -1;
+}
+
+
+
+// *********************************************************************************************
+
+
+
+__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;
+
+ if(hInput)
+ {
+ MYINPUT *mi;
+ mi=(MYINPUT *)GlobalLock(hInput);
+ full_size=mi->full_size;
+
+ GlobalUnlock(hInput);
+ }
+
+ return full_size;
+}
+
+
+__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);
+
+ if(mi->IsAAC)
+ {
+ switch(mi->file_info.headertype)
+ {
+ case 0:
+ lstrcat(szString,"RAW\n");
+ return 0L;
+ case 1:
+ lstrcat(szString,"ADIF\n");
+ break;
+ case 2:
+ lstrcat(szString,"ADTS\n");
+ break;
+ }
+
+ switch(mi->file_info.object_type)
+ {
+ case MAIN:
+ lstrcat(szString,"Main");
+ break;
+ case LOW:
+ lstrcat(szString,"Low Complexity");
+ break;
+ case SSR:
+ lstrcat(szString,"SSR (unsupported)");
+ break;
+ case LTP:
+ lstrcat(szString,"Main LTP");
+ break;
+ }
+ }
+ else
+ lstrcat(szString,mpeg4AudioNames[mi->type]);
+
+ 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);
+
+ if(mi->buffer)
+ free(mi->buffer);
+
+ if(mi->hDecoder)
+ faacDecClose(mi->hDecoder);
+
+ GlobalUnlock(hInput);
+ GlobalFree(hInput);
+ }
+}
+
+
+#define ERROR_ON_OPEN_MP4(msg) \
+{ \
+ MessageBox(0, msg, "FAAD interface", MB_OK); \
+ if(infile) \
+ MP4Close(infile); \
+ if(hDecoder) \
+ faacDecClose(hDecoder); \
+ GlobalUnlock(hInput); \
+ return 0; \
+}
+#define ERROR_ON_OPEN_AAC(msg) \
+{ \
+ MessageBox(0, msg, "FAAD interface", MB_OK); \
+ fclose(infile); \
+ if(buffer) \
+ free(buffer); \
+ if(hDecoder) \
+ faacDecClose(hDecoder); \
+ GlobalUnlock(hInput); \
+ return 0; \
+}
+
+// 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;
+MYINPUT *mi;
+faacDecHandle hDecoder=0;
+faacDecConfigurationPtr config;
+DWORD tmp;
+DWORD samplerate;
+unsigned char channels;
+unsigned char *buffer=0;
+
+ hInput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(MYINPUT));
+ if(!hInput)
+ return 0;
+ mi=(MYINPUT *)GlobalLock(hInput);
+ memset(mi,0,sizeof(MYINPUT));
+
+
+ mi->IsAAC=strcmpi(lpstrFilename+lstrlen(lpstrFilename)-4,".aac")==0;
+
+ if(!mi->IsAAC) // MP4 file ---------------------------------------------------------------------
+ {
+// faacDecFrameInfo frameInfo;
+ MP4FileHandle infile;
+ MP4SampleId numSamples;
+ MP4Duration length;
+ int fileType=FAAD_FMT_16BIT; // default
+ int track;
+ unsigned __int32 buffer_size;
+ unsigned long timeScale;
+ unsigned char sf;
+
+ if(!(infile = MP4Read(lpstrFilename, 0)))
+ ERROR_ON_OPEN_MP4("Error opening file");
+ mi->mp4File=infile;
+
+ if ((track = GetAACTrack(infile)) < 0)
+ ERROR_ON_OPEN_MP4("Unable to find correct AAC sound track in the MP4 file");
+
+ length = MP4GetTrackDuration(infile, track);
+ mi->len_ms=(DWORD) MP4ConvertFromTrackDuration(infile, track, length, MP4_MSECS_TIME_SCALE);
+
+ if(!(hDecoder=faacDecOpen()))
+ ERROR_ON_OPEN_MP4("Can't init library");
+ buffer = NULL;
+ buffer_size = 0;
+ MP4GetTrackESConfiguration(infile, track, &buffer, &buffer_size);
+ if(buffer)
+ AudioSpecificConfig(buffer, &timeScale, &channels, &sf, &mi->type);
+ mi->file_info.bitrate=(int)MP4GetTrackIntegerProperty(infile, track, "mdia.minf.stbl.stsd.mp4a.esds.decConfigDescr.avgBitrate");
+ numSamples = MP4GetTrackNumberOfSamples(infile, track);
+
+ if(faacDecInit2(hDecoder, buffer, buffer_size, &samplerate, &channels) < 0)
+ ERROR_ON_OPEN_MP4("Error initializing decoder library");
+
+ if (buffer) free(buffer);
+
+ mi->numSamples=numSamples;
+ mi->track=track;
+ mi->sampleId=1;
+ }
+ else // AAC file ------------------------------------------------------------------------------
+ {
+ FILE *infile;
+ DWORD pos; // into the file. Needed to obtain length of file
+ DWORD read;
+ int *seek_table;
+ long tagsize;
+
+ if(!(infile=fopen(lpstrFilename,"rb")))
+ ERROR_ON_OPEN_AAC("Error opening file");
+
+ mi->fFile=infile;
+ pos=ftell(infile);
+ fseek(infile, 0, SEEK_END);
+ mi->lSize=ftell(infile);
+ fseek(infile, pos, SEEK_SET);
+
+ if(!(buffer=(BYTE *)malloc(768*MAX_CHANNELS)))
+ {
+ MessageBox(0, "Memory allocation error: buffer", "FAAD interface", MB_OK);
+ GlobalUnlock(hInput);
+ return 0;
+ }
+ mi->buffer=buffer;
+ memset(buffer, 0, 768*MAX_CHANNELS);
+
+ if(mi->lSize<768*MAX_CHANNELS)
+ tmp=mi->lSize;
+ else
+ tmp=768*MAX_CHANNELS;
+ read=fread(buffer, 1, tmp, infile);
+ if(read==tmp)
+ {
+ mi->bytes_read=read;
+ mi->bytes_into_buffer=read;
+ }
+ else
+ ERROR_ON_OPEN_AAC("fread");
+
+ tagsize=id3v2_tag(buffer);
+ if(tagsize)
+ {
+ memcpy(buffer,buffer+tagsize,768*MAX_CHANNELS - tagsize);
+
+ if(mi->bytes_read+tagsize<mi->lSize)
+ tmp=tagsize;
+ else
+ tmp=mi->lSize-mi->bytes_read;
+ read=fread(buffer+mi->bytes_into_buffer, 1, tmp, mi->fFile);
+ if(read==tmp)
+ {
+ mi->bytes_read+=read;
+ mi->bytes_into_buffer+=read;
+ }
+ else
+ ERROR_ON_OPEN_AAC("fread");
+ }
+ mi->tagsize=tagsize;
+
+ if(!(hDecoder=faacDecOpen()))
+ ERROR_ON_OPEN_AAC("Can't init library");
+
+ config = faacDecGetCurrentConfiguration(hDecoder);
+// config->defObjectType = MAIN;
+ config->defSampleRate = 44100;
+ config->outputFormat=FAAD_FMT_16BIT;
+ faacDecSetConfiguration(hDecoder, config);
+
+ if((mi->bytes_consumed=faacDecInit(hDecoder, buffer, &samplerate, &channels)) < 0)
+ ERROR_ON_OPEN_AAC("Error retrieving information form input file");
+ 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
+
+
+ if(seek_table=(int *)malloc(sizeof(int)*10800))
+ {
+ get_AAC_format(lpstrFilename, &(mi->file_info), seek_table);
+ free(seek_table);
+ }
+ if(!mi->file_info.version)
+ ERROR_ON_OPEN_AAC("Error retrieving information form input file");
+
+ mi->len_ms=(DWORD)((1000*((float)mi->lSize*8))/mi->file_info.bitrate);
+ } // END AAC file -----------------------------------------------------------------------------
+
+ if(mi->len_ms)
+ mi->full_size=(DWORD)(mi->len_ms*((float)samplerate/1000)*channels*(16/8));
+ else
+ mi->full_size=mi->lSize; // corrupted stream?
+
+ mi->hDecoder=hDecoder;
+ *lSamprate=samplerate;
+ *wBitsPerSample=16;
+ *wChannels=(WORD)channels;
+ *lChunkSize=sizeof(short)*1024*channels;
+
+ mi->wChannels=(WORD)channels;
+ mi->dwSamprate=samplerate;
+ mi->wBitsPerSample=*wBitsPerSample;
+ strcpy(mi->szName,lpstrFilename);
+
+ GlobalUnlock(hInput);
+
+ return hInput;
+}
+
+#define ERROR_ReadFilterInput(msg) \
+ { \
+ if(msg) \
+ MessageBox(0, msg, "FAAD interface", MB_OK); \
+ GlobalUnlock(hInput); \
+ return 0; \
+ } \
+
+__declspec(dllexport) DWORD FAR PASCAL ReadFilterInput(HANDLE hInput, unsigned char far *bufout, long lBytes)
+{
+DWORD read,
+ tmp,
+ shorts_decoded=0;
+unsigned char *buffer=0;
+faacDecFrameInfo frameInfo;
+char *sample_buffer=0;
+MYINPUT *mi;
+
+ if(!hInput)
+ return 0;
+ mi=(MYINPUT *)GlobalLock(hInput);
+
+ if(!mi->IsAAC) // MP4 file --------------------------------------------------------------------------
+ {
+ unsigned __int32 buffer_size=0;
+ int rc;
+
+ do
+ {
+ buffer=NULL;
+ if(mi->sampleId>=mi->numSamples)
+ ERROR_ReadFilterInput(0);
+
+ rc=MP4ReadSample(mi->mp4File, mi->track, mi->sampleId++, &buffer, &buffer_size, NULL, NULL, NULL, NULL);
+ if(rc==0 || buffer==NULL)
+ {
+ if(buffer) free(buffer);
+ ERROR_ReadFilterInput("MP4ReadSample")
+ }
+
+ sample_buffer=(char *)faacDecDecode(mi->hDecoder,&frameInfo,buffer);
+ shorts_decoded=frameInfo.samples*sizeof(short);
+ memcpy(bufout,sample_buffer,shorts_decoded);
+ if (buffer) free(buffer);
+ }while(!shorts_decoded && !frameInfo.error);
+ }
+ else // AAC file --------------------------------------------------------------------------
+ {
+ buffer=mi->buffer;
+ do
+ {
+ if(mi->bytes_consumed>0)
+ {
+ 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->bytes_consumed<mi->lSize)
+ tmp=mi->bytes_consumed;
+ else
+ tmp=mi->lSize-mi->bytes_read;
+ read=fread(buffer+mi->bytes_into_buffer, 1, tmp, mi->fFile);
+ if(read==tmp)
+ {
+ mi->bytes_read+=read;
+ mi->bytes_into_buffer+=read;
+ }
+ }
+ else
+ if(mi->bytes_into_buffer)
+ memset(buffer+mi->bytes_into_buffer, 0, mi->bytes_consumed);
+
+ mi->bytes_consumed=0;
+ }
+
+ if(mi->bytes_into_buffer<1)
+ if(mi->bytes_read<mi->lSize)
+ ERROR_ReadFilterInput("ReadFilterInput: buffer empty!")
+ else
+ return 0;
+
+ sample_buffer=(char *)faacDecDecode(mi->hDecoder,&frameInfo,buffer);
+ shorts_decoded=frameInfo.samples*sizeof(short);
+ memcpy(bufout,sample_buffer,shorts_decoded);
+ mi->bytes_consumed +=frameInfo.bytesconsumed;
+ mi->bytes_into_buffer-=mi->bytes_consumed;
+ }while(!shorts_decoded && !frameInfo.error);
+ } // END AAC file --------------------------------------------------------------------------
+
+ GlobalUnlock(hInput);
+
+ if(frameInfo.error)
+ ERROR_ReadFilterInput(faacDecGetErrorMessage(frameInfo.error));
+
+ return shorts_decoded;
+}
--- /dev/null
+++ b/plugins/cooledit/Main.cpp
@@ -1,0 +1,84 @@
+#include <windows.h>
+#include "filters.h" //CoolEdit
+
+
+
+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");
+ 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 ???
+ cq->Stereo16=0xFF;
+ cq->Stereo24=0xFF;
+ cq->Stereo32=0xFF;
+ cq->Mono8=0xFF;
+ cq->Mono16=0xFF;
+ cq->Mono24=0xFF;
+ cq->Mono32=0xFF;
+ cq->Quad32=0xFF;
+ cq->Quad16=0xFF;
+ cq->Quad8=0xFF;
+ return C_VALIDLIBRARY;
+}
--- a/plugins/cooledit/Readme.txt
+++ b/plugins/cooledit/Readme.txt
@@ -1,5 +1,10 @@
-Set Active Configuration = FAAD - win32 Release,
-compile,
+Cooledit plugin by Antonio Foranna
+This plugin is free software and is released WITHOUT ANY WARRANTY;
+you can redistribute it and/or modify it freely.
+
+To use it:
+
+In visual studio set "Active Configuration = FAAD - win32 Release" and compile,
copy FAAC.flt into CoolEdit folder
delete flt.dat
--- /dev/null
+++ b/plugins/cooledit/Registry.cpp
@@ -1,0 +1,75 @@
+//#include "stdafx.h"
+#include <windows.h>
+//#include <memory.h>
+#include "Registry.h"
+
+registryClass::registryClass()
+{
+ regKey=NULL;
+ path=NULL;
+}
+
+registryClass::~registryClass()
+{
+ if(regKey)
+ RegCloseKey(regKey);
+ if(path)
+ delete path;
+}
+
+#define setPath(SubKey) \
+ if(path) \
+ delete path; \
+ path=strdup(SubKey);
+
+// *****************************************************************************
+
+BOOL registryClass::openCreateReg(HKEY hKey, char *SubKey)
+{
+ if(regKey)
+ RegCloseKey(regKey);
+ if(RegOpenKeyEx(hKey, SubKey, NULL , KEY_ALL_ACCESS , ®Key)==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 , ®Key , &disp );
+ if(disp==REG_CREATED_NEW_KEY)
+ {
+ setPath(SubKey);
+ return TRUE;
+ }
+ else
+ {
+ setPath("");
+ return FALSE;
+ }
+ }
+}
+// *****************************************************************************
+
+void registryClass::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));
+}
+// *****************************************************************************
+
+DWORD registryClass::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;
+}
--- /dev/null
+++ b/plugins/cooledit/Registry.h
@@ -1,0 +1,17 @@
+#ifndef registry_h
+#define registry_h
+
+class registryClass
+{
+public:
+ registryClass();
+ ~registryClass();
+
+ BOOL openCreateReg(HKEY hKey, char *SubKey);
+ void setRegDword(char *keyStr , DWORD val);
+ DWORD getSetRegDword(char *keyStr, DWORD var);
+
+ HKEY regKey;
+ char *path;
+};
+#endif
\ No newline at end of file
--- a/plugins/cooledit/aacinfo.c
+++ /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.c,v 1.4 2002/04/17 18:43:24 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(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;
-}
--- a/plugins/cooledit/faac.c
+++ /dev/null
@@ -1,551 +1,0 @@
-#include <windows.h>
-#include <stdio.h> // FILE *
-#include "filters.h" //CoolEdit
-#include "resource.h"
-#include "faac.h"
-
-
-#define PI_VER "v2.0 beta1"
-
-extern void config_init();
-extern void config_read(DWORD *dwOptions);
-extern void config_write(DWORD dwOptions);
-
-
-typedef struct output_tag // any special vars associated with output file
-{
- FILE *fFile;
- DWORD lSize;
- long lSamprate;
- WORD wBitsPerSample;
- WORD wChannels;
-// DWORD dwDataOffset;
-// BOOL bWrittenHeader;
- char szNAME[256];
-
- faacEncHandle hEncoder;
- unsigned char *bitbuf;
- DWORD maxBytesOutput;
- long samplesInput;
- BYTE bStopEnc;
-} MYOUTPUT;
-
-
-#define DISABLE_LTP \
-{ \
- if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \
- IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \
- { \
- CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); \
- CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); \
- } \
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \
-}
-
-__declspec(dllexport) BOOL FAR PASCAL DIALOGMsgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
-{
-DWORD dwOptions=(DWORD)lParam;
-
- switch(Message)
- {
- case WM_INITDIALOG:
- {
- char buf[10];
-
- 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>>23)&1))
- {
- config_init();
- config_read(&dwOptions);
- }
-
- if(dwOptions)
- {
- char Enabled=!(dwOptions&1);
- CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, dwOptions&1);
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled);
-// EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled);
-// EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled);
-
- if(((dwOptions>>29)&7)==MPEG4)
- CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
- else
- CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
-
- switch((dwOptions>>27)&3)
- {
- 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;
- }
-
- 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>>1)&0x0000ffff, 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);
- 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);
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled);
-// EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled);
-// EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled);
- EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled);
- if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4))
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
- else
- DISABLE_LTP
- break;
- }
- break;
-
- case IDOK:
- {
- DWORD retVal=0;
- faacEncConfiguration faacEncCfg;
-
- 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)&0x0000ffff)<<1;
- retVal|=(faacEncCfg.bandWidth&0x0000ffff)<<1;
-
- if(IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG))
- retVal|=1;
-
- config_write(retVal);
-
-// retVal|=1<<23; // CFG has been written
-
- EndDialog(hWndDlg, retVal);
- }
- break;
-
- case IDCANCEL:
- // Ignore data values entered into the controls
- // and dismiss the dialog window returning FALSE
- EndDialog(hWndDlg, FALSE);
- break;
-
- case IDC_BTN_ABOUT:
- {
- char buf[256];
- sprintf(buf, "AAC-MPEG4 plugin %s by 4N\n"
- "This plugin uses FAAC encoder engine v%g and FAAD2 decoder engine\n\n"
- "Compiled on %s\n",
- PI_VER,
- 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;
-
- case IDC_RADIO_MPEG2:
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
- DISABLE_LTP
- break;
- }
- break; // End of WM_COMMAND
- default: return FALSE;
- }
- return TRUE;
-} // 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
-{
-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);
-
- return nDialogReturn;
-}
-
-__declspec(dllexport) DWORD FAR PASCAL FilterWriteFirstSpecialData(HANDLE hInput,
- SPECIALDATA * psp)
-{
- 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)
- {
- MYOUTPUT *mo;
- mo=(MYOUTPUT *)GlobalLock(hOutput);
-
- if(mo->fFile)
- {
- fclose(mo->fFile);
- mo->fFile=0;
- }
-
- if(mo->hEncoder)
- 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;
-faacEncHandle hEncoder;
-FILE *outfile;
-unsigned char *bitbuf;
-DWORD maxBytesOutput;
-long samplesInput;
-int bytesEncoded;
-
-// if(!((dwOptions>>23)&1))
- {
- config_init();
- config_read(&dwOptions);
- }
-
-// open the aac output file
- if(!(outfile=fopen(lpstrFilename, "wb")))
- {
- MessageBox(0, "Can't create file", "FAAC interface", MB_OK);
- return 0;
- }
-
-// open the encoder library
- if(!(hEncoder=faacEncOpen(lSamprate, wChannels, &samplesInput, &maxBytesOutput)))
- {
- MessageBox(0, "Can't init library", "FAAC interface", MB_OK);
- fclose(outfile);
- return 0;
- }
-
- if(!(bitbuf=(unsigned char*)malloc(maxBytesOutput*sizeof(unsigned char))))
- {
- MessageBox(0, "Memory allocation error: output buffer", "FAAC interface", MB_OK);
- faacEncClose(hEncoder);
- fclose(outfile);
- return 0;
- }
-
- *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 interface", MB_OK);
- faacEncClose(hEncoder);
- fclose(outfile);
- free(bitbuf);
- return 0;
- }
-
- if(dwOptions && !(dwOptions&1))
- {
- faacEncConfigurationPtr myFormat;
- myFormat=faacEncGetCurrentConfiguration(hEncoder);
-
- 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=lSamprate/2;
-
- if(!faacEncSetConfiguration(hEncoder, myFormat))
- {
- MessageBox(0, "Unsupported parameters", "FAAC interface", MB_OK);
- faacEncClose(hEncoder);
- fclose(outfile);
- free(bitbuf);
- GlobalFree(hOutput);
- return 0;
- }
- }
-
-// init flushing process
- bytesEncoded=faacEncEncode(hEncoder, 0, 0, bitbuf, maxBytesOutput); // initializes the flushing process
- if(bytesEncoded>0)
- fwrite(bitbuf, 1, bytesEncoded, outfile);
-
- return hOutput;
-}
-
-__declspec(dllexport) DWORD FAR PASCAL WriteFilterOutput(HANDLE hOutput, unsigned char far *buf, long lBytes)
-{
-int bytesWritten;
-int bytesEncoded;
-
- if(hOutput)
- {
- MYOUTPUT far *mo;
- mo=(MYOUTPUT far *)GlobalLock(hOutput);
-
- if(!mo->bStopEnc)
- {
-// call the actual encoding routine
- bytesEncoded=faacEncEncode(mo->hEncoder, (short *)buf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
- if(bytesEncoded<1) // end of flushing process
- {
- if(bytesEncoded<0)
- {
- MessageBox(0, "faacEncEncode() failed", "FAAC interface", MB_OK);
- mo->bStopEnc=1;
- }
- bytesWritten=lBytes ? 1 : 0; // bytesWritten==0 stops CoolEdit...
- GlobalUnlock(hOutput);
- return bytesWritten;
- }
-// write bitstream to aac file
- bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
- if(bytesWritten!=bytesEncoded)
- {
- MessageBox(0, "bytesWritten and bytesEncoded are different", "FAAC interface", MB_OK);
- mo->bStopEnc=1;
- GlobalUnlock(hOutput);
- return 0;
- }
-
- GlobalUnlock(hOutput);
- }
- }
-
- return bytesWritten;
-}
--- a/plugins/cooledit/faad.c
+++ /dev/null
@@ -1,405 +1,0 @@
-#include <windows.h>
-#include <stdio.h> // FILE *
-#include "filters.h" //CoolEdit
-#include "faad.h"
-#include "faac.h"
-#include "aacinfo.h"
-
-
-#define MAX_CHANNELS 2
-#define QWORD __int32
-
-typedef struct input_tag // any special vars associated with input file
-{
- FILE *fFile;
- DWORD lSize;
- QWORD len_ms;
- WORD wChannels;
- DWORD dwSamprate;
- WORD wBitsPerSample;
- char szName[256];
-
- faacDecHandle hDecoder;
- faadAACInfo file_info;
- unsigned char *buffer;
- 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
- long bytes_into_buffer;
-} MYINPUT;
-
-
-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;
-
- if(hInput)
- {
- MYINPUT *mi;
- mi=(MYINPUT *)GlobalLock(hInput);
- full_size=mi->full_size;
-
- GlobalUnlock(hInput);
- }
-
- return full_size;
-}
-
-
-__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:
- lstrcat(szString,"RAW\n");
- return 0L;
- case 1:
- lstrcat(szString,"ADIF\n");
- break;
- case 2:
- lstrcat(szString,"ADTS\n");
- break;
- }
-
- switch(mi->file_info.object_type)
- {
- case MAIN:
- lstrcat(szString,"Main");
- break;
- case LOW:
- lstrcat(szString,"Low Complexity");
- break;
- case SSR:
- lstrcat(szString,"SSR (unsupported)");
- break;
- case LTP:
- 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);
-
- if(mi->buffer)
- free(mi->buffer);
-
- if(mi->hDecoder)
- faacDecClose(mi->hDecoder);
-
- 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;
-faacDecHandle hDecoder;
-DWORD tmp;
-//int shift;
-FILE *infile;
-DWORD samplerate;
-unsigned char channels;
-DWORD pos; // into the file. Needed to obtain length of file
-DWORD read;
-int *seek_table;
-//faadAACInfo file_info;
-unsigned char *buffer;
-long tagsize;
-faacDecConfigurationPtr config;
-
- if(!(infile=fopen(lpstrFilename,"rb")))
- return 0;
-
- hInput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(MYINPUT));
- if(!hInput)
- {
- fclose(infile);
- return 0;
- }
- else
- {
- MYINPUT *mi;
- mi=(MYINPUT *)GlobalLock(hInput);
-
- mi->fFile=infile;
- pos=ftell(infile);
- fseek(infile, 0, SEEK_END);
- mi->lSize=ftell(infile);
- fseek(infile, pos, SEEK_SET);
- if(!(buffer=(BYTE *)malloc(768*MAX_CHANNELS)))
- {
- MessageBox(0, "Memory allocation error: buffer", "FAAD interface", MB_OK);
- fclose(infile);
- GlobalUnlock(hInput);
- return 0;
- }
- mi->buffer=buffer;
- memset(buffer, 0, 768*MAX_CHANNELS);
-
- if(mi->lSize<768*MAX_CHANNELS)
- tmp=mi->lSize;
- else
- tmp=768*MAX_CHANNELS;
- read=fread(buffer, 1, tmp, infile);
- if(read==tmp)
- {
- mi->bytes_read=read;
- mi->bytes_into_buffer=read;
- }
- else
- {
- MessageBox(0, "fread", "FAAD interface", MB_OK);
- fclose(mi->fFile);
- free(mi->buffer);
- GlobalUnlock(hInput);
- return 0;
- }
-
- tagsize=id3v2_tag(buffer);
- if(tagsize)
- {
- memcpy(buffer,buffer+tagsize,768*MAX_CHANNELS - tagsize);
-
- if(mi->bytes_read+tagsize<mi->lSize)
- tmp=tagsize;
- else
- tmp=mi->lSize-mi->bytes_read;
- read=fread(buffer+mi->bytes_into_buffer, 1, tmp, mi->fFile);
- if(read==tmp)
- {
- mi->bytes_read+=read;
- mi->bytes_into_buffer+=read;
- }
- else
- {
- MessageBox(0, "fread", "FAAD interface", MB_OK);
- fclose(mi->fFile);
- free(mi->buffer);
- GlobalUnlock(hInput);
- return 0;
- }
- }
- mi->tagsize=tagsize;
-
- hDecoder = faacDecOpen();
- if(!hDecoder)
- {
- MessageBox(0, "Can't init library", "FAAD interface", MB_OK);
- fclose(mi->fFile);
- free(mi->buffer);
- GlobalUnlock(hInput);
- return 0;
- }
- mi->hDecoder=hDecoder;
-
- config = faacDecGetCurrentConfiguration(hDecoder);
-// config->defObjectType = MAIN;
- config->defSampleRate = 44100;
- config->outputFormat=FAAD_FMT_16BIT;
- faacDecSetConfiguration(hDecoder, config);
-
- if((mi->bytes_consumed=faacDecInit(hDecoder, buffer, &samplerate, &channels)) < 0)
- {
- MessageBox(hWnd, "Error retrieving information form input file", "FAAD interface", MB_OK);
- fclose(mi->fFile);
- free(mi->buffer);
- faacDecClose(mi->hDecoder);
- GlobalUnlock(hInput);
- return 0;
- }
- 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
-
- *lSamprate=samplerate;
- *wBitsPerSample=16;
- *wChannels=(WORD)channels;
- *lChunkSize=sizeof(short)*1024*channels;
-
- mi->wChannels=(WORD)channels;
- mi->dwSamprate=samplerate;
- mi->wBitsPerSample=*wBitsPerSample;
- strcpy(mi->szName,lpstrFilename);
-
- if(seek_table=(int *)malloc(sizeof(int)*10800))
- {
- get_AAC_format(mi->szName, &(mi->file_info), seek_table);
- free(seek_table);
- }
- else
- if(!mi->file_info.version)
- {
- fclose(mi->fFile);
- free(mi->buffer);
- faacDecClose(hDecoder);
- GlobalUnlock(hInput);
- return 0;
- }
-
- mi->len_ms=(DWORD)((1000*((float)mi->lSize*8))/mi->file_info.bitrate);
- if(mi->len_ms)
- mi->full_size=(DWORD)(mi->len_ms*((float)mi->dwSamprate/1000)*mi->wChannels*(16/8));
- else
- mi->full_size=mi->lSize; // corrupted stream?
-/* {
- fclose(mi->fFile);
- free(mi->buffer);
- faacDecClose(hDecoder);
- GlobalUnlock(hInput);
- return 0;
- }*/
-
- GlobalUnlock(hInput);
- }
-
- return hInput;
-}
-
-#define ERROR_ReadFilterInput(msg) \
- { \
- if(msg) \
- MessageBox(0, msg, "FAAD interface", MB_OK); \
- GlobalUnlock(hInput); \
- return 0; \
- } \
-
-__declspec(dllexport) DWORD FAR PASCAL ReadFilterInput(HANDLE hInput, unsigned char far *bufout, long lBytes)
-{
-DWORD read,
- tmp,
- shorts_decoded=0;
-unsigned char *buffer;
-faacDecFrameInfo frameInfo;
-char *sample_buffer=0;
-
- if(hInput)
- {
- MYINPUT *mi;
- mi=(MYINPUT *)GlobalLock(hInput);
-
- buffer=mi->buffer;
-
- do
- {
- if(mi->bytes_consumed>0)
- {
- 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->bytes_consumed<mi->lSize)
- tmp=mi->bytes_consumed;
- else
- tmp=mi->lSize-mi->bytes_read;
- read=fread(buffer+mi->bytes_into_buffer, 1, tmp, mi->fFile);
- if(read==tmp)
- {
- mi->bytes_read+=read;
- mi->bytes_into_buffer+=read;
- }
- }
- else
- if(mi->bytes_into_buffer)
- memset(buffer+mi->bytes_into_buffer, 0, mi->bytes_consumed);
-
- mi->bytes_consumed=0;
- }
-
- if(mi->bytes_into_buffer<1)
- if(mi->bytes_read<mi->lSize)
- ERROR_ReadFilterInput("ReadFilterInput: buffer empty!")
- else
- return 0;
-
- sample_buffer=(char *)faacDecDecode(mi->hDecoder,&frameInfo,buffer);
- shorts_decoded=frameInfo.samples*sizeof(short);
- memcpy(bufout,sample_buffer,shorts_decoded);
- mi->bytes_consumed +=frameInfo.bytesconsumed;
- mi->bytes_into_buffer-=mi->bytes_consumed;
- }while(!shorts_decoded && !frameInfo.error);
-
- GlobalUnlock(hInput);
- }
-
- if(frameInfo.error)
- ERROR_ReadFilterInput(faacDecGetErrorMessage(frameInfo.error));
-
- return shorts_decoded;
-}
--- a/plugins/cooledit/faad.dsw
+++ b/plugins/cooledit/faad.dsw
@@ -20,11 +20,14 @@
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\prj\id3lib.dsp - Package Owner=<4>
+Project: "id3lib"=..\..\..\faad2\common\id3lib\libprj\id3lib.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -36,7 +39,7 @@
###############################################################################
-Project: "libfaac"=..\..\faac\libfaac\libfaac.dsp - Package Owner=<4>
+Project: "libfaac"=..\..\libfaac\libfaac.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -49,6 +52,18 @@
###############################################################################
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>
{{{
--- a/plugins/cooledit/main.c
+++ /dev/null
@@ -1,84 +1,0 @@
-#include <windows.h>
-#include "filters.h" //CoolEdit
-
-
-
-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");
- 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 ???
- cq->Stereo16=0xFF;
- cq->Stereo24=0xFF;
- cq->Stereo32=0xFF;
- cq->Mono8=0xFF;
- cq->Mono16=0xFF;
- cq->Mono24=0xFF;
- cq->Mono32=0xFF;
- cq->Quad32=0xFF;
- cq->Quad16=0xFF;
- cq->Quad8=0xFF;
- return C_VALIDLIBRARY;
-}
--- a/plugins/cooledit/resource.h
+++ b/plugins/cooledit/resource.h
@@ -18,6 +18,8 @@
#define IDC_CHK_AUTOCFG 1011
#define IDC_BTN_ABOUT 1012
#define IDC_IMG_LOGO 1013
+#define IDC_RADIO_RAW 1013
+#define IDC_RADIO_ADTS 1014
// Next default values for new objects
//