ref: 1b925ea392c6b968c6550c4179eade1aed307096
parent: 544c66fe1a1745f06c60635dc047e5ca3e937cb5
author: menno <menno>
date: Fri Apr 16 13:48:13 EDT 2004
New cooledit filter code
--- a/plugins/cooledit/CRegistry.cpp
+++ b/plugins/cooledit/CRegistry.cpp
@@ -1,6 +1,6 @@
/*
FAAC - codec plugin for Cooledit
-Copyright (C) 2002 Antonio Foranna
+Copyright (C) 2002-2004 Antonio Foranna
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author can be contacted at:
-kreel@tiscali.it
+ntnfrn_email-temp@yahoo.it
*/
//#include "stdafx.h"
--- a/plugins/cooledit/CRegistry.h
+++ b/plugins/cooledit/CRegistry.h
@@ -1,3 +1,24 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2002-2004 Antonio Foranna
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
#ifndef registry_h
#define registry_h
--- /dev/null
+++ b/plugins/cooledit/Cfaac.cpp
@@ -1,0 +1,537 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2004 Antonio Foranna
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
+#include "Cfaac.h"
+
+
+
+// *********************************************************************************************
+
+
+
+#define FREE_ARRAY(ptr) \
+{ \
+ if(ptr) \
+ free(ptr); \
+ ptr=0; \
+}
+
+// *********************************************************************************************
+
+Cfaac::Cfaac(HANDLE hOut)
+{
+ if(hOut)
+ {
+ hOutput=hOut;
+ return;
+ }
+
+ if(!(hOutput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(MYOUTPUT))))
+ MessageBox(0, "Memory allocation error: hOutput", APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
+/*
+MYOUTPUT *mo;
+
+ if(!(mo=(MYOUTPUT *)GlobalLock(hOutput)))
+ MessageBox(0, "GlobalLock(hOutput)", APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
+
+ GlobalUnlock(hOutput);*/
+}
+// -----------------------------------------------------------------------------------------------
+
+Cfaac::~Cfaac()
+{
+ if(!hOutput)
+ return;
+
+MYOUTPUT *mo;
+
+ GLOBALLOCK(mo,hOutput,MYOUTPUT,return);
+
+ if(mo->WrittenSamples)
+ {
+ int BytesWritten;
+ if(mo->bytes_into_buffer>0)
+ memset(mo->bufIn+mo->bytes_into_buffer, 0, (mo->samplesInput*(mo->BitsPerSample>>3))-mo->bytes_into_buffer);
+ do
+ {
+ if((BytesWritten=processData(hOutput,mo->bufIn,mo->bytes_into_buffer))<0)
+ MessageBox(0, "~Cfaac: processData", APP_NAME " plugin", MB_OK|MB_ICONSTOP);
+ mo->bytes_into_buffer=0;
+ }while(BytesWritten>0);
+ }
+
+ if(mo->aacFile)
+ {
+ fclose(mo->aacFile);
+ mo->aacFile=0;
+ }
+ else
+ {
+ MP4Close(mo->MP4File);
+ mo->MP4File=0;
+ }
+
+ if(mo->hEncoder)
+ faacEncClose(mo->hEncoder);
+
+ FREE_ARRAY(mo->bitbuf)
+ FREE_ARRAY(mo->buf32bit)
+ FREE_ARRAY(mo->bufIn)
+
+ GlobalUnlock(hOutput);
+ GlobalFree(hOutput);
+}
+
+// *********************************************************************************************
+// Utilities
+// *********************************************************************************************
+
+#define SWAP32(x) (((x & 0xff) << 24) | ((x & 0xff00) << 8) \
+ | ((x & 0xff0000) >> 8) | ((x & 0xff000000) >> 24))
+#define SWAP16(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8))
+
+void Cfaac::To32bit(int32_t *buf, BYTE *bufi, int size, BYTE samplebytes, BYTE bigendian)
+{
+int i;
+
+ switch(samplebytes)
+ {
+ case 1:
+ // this is endian clean
+ for (i = 0; i < size; i++)
+ buf[i] = (bufi[i] - 128) * 65536;
+ break;
+
+ case 2:
+#ifdef WORDS_BIGENDIAN
+ if (!bigendian)
+#else
+ if (bigendian)
+#endif
+ {
+ // swap bytes
+ for (i = 0; i < size; i++)
+ {
+ int16_t s = ((int16_t *)bufi)[i];
+
+ s = SWAP16(s);
+
+ buf[i] = ((u_int32_t)s) << 8;
+ }
+ }
+ else
+ {
+ // no swap
+ for (i = 0; i < size; i++)
+ {
+ int s = ((int16_t *)bufi)[i];
+
+ buf[i] = s << 8;
+ }
+ }
+ break;
+
+ case 3:
+ if (!bigendian)
+ {
+ for (i = 0; i < size; i++)
+ {
+ int s = bufi[3 * i] | (bufi[3 * i + 1] << 8) | (bufi[3 * i + 2] << 16);
+
+ // fix sign
+ if (s & 0x800000)
+ s |= 0xff000000;
+
+ buf[i] = s;
+ }
+ }
+ else // big endian input
+ {
+ for (i = 0; i < size; i++)
+ {
+ int s = (bufi[3 * i] << 16) | (bufi[3 * i + 1] << 8) | bufi[3 * i + 2];
+
+ // fix sign
+ if (s & 0x800000)
+ s |= 0xff000000;
+
+ buf[i] = s;
+ }
+ }
+ break;
+
+ case 4:
+#ifdef WORDS_BIGENDIAN
+ if (!bigendian)
+#else
+ if (bigendian)
+#endif
+ {
+ // swap bytes
+ for (i = 0; i < size; i++)
+ {
+ int s = bufi[i];
+
+ buf[i] = SWAP32(s);
+ }
+ }
+ else
+ memcpy(buf,bufi,size*sizeof(u_int32_t));
+ /*
+ int exponent, mantissa;
+ float *bufo=(float *)buf;
+
+ for (i = 0; i < size; i++)
+ {
+ exponent=bufi[(i<<2)+3]<<1;
+ if(bufi[i*4+2] & 0x80)
+ exponent|=0x01;
+ exponent-=126;
+ mantissa=(DWORD)bufi[(i<<2)+2]<<16;
+ mantissa|=(DWORD)bufi[(i<<2)+1]<<8;
+ mantissa|=bufi[(i<<2)];
+ bufo[i]=(float)ldexp(mantissa,exponent);
+ }*/
+ break;
+ }
+}
+
+// *********************************************************************************************
+// Main functions
+// *********************************************************************************************
+
+void Cfaac::DisplayError(char *ProcName, char *str)
+{
+char buf[100]="";
+
+ if(str && *str)
+ {
+ if(ProcName && *ProcName)
+ sprintf(buf,"%s: ", ProcName);
+ strcat(buf,str);
+ MessageBox(0, buf, APP_NAME " plugin", MB_OK|MB_ICONSTOP);
+ }
+
+MYOUTPUT *mo;
+ GLOBALLOCK(mo,hOutput,MYOUTPUT,return);
+ mo->bytes_into_buffer=-1;
+ GlobalUnlock(hOutput);
+ GlobalUnlock(hOutput);
+}
+// *********************************************************************************************
+
+void Cfaac::getFaacCfg(MY_ENC_CFG *cfg)
+{
+CRegistry reg;
+
+ if(reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAC"))
+ {
+ cfg->AutoCfg=reg.getSetRegBool("Auto",true);
+ cfg->SaveMP4=reg.getSetRegBool("Write MP4",false);
+ cfg->EncCfg.mpegVersion=reg.getSetRegDword("MPEG version",MPEG4);
+ 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->UseQuality=reg.getSetRegBool("Use quality",false);
+ cfg->EncCfg.quantqual=reg.getSetRegDword("Quality",100);
+ cfg->EncCfg.bitRate=reg.getSetRegDword("BitRate",0);
+ cfg->EncCfg.bandWidth=reg.getSetRegDword("BandWidth",0);
+ cfg->EncCfg.outputFormat=reg.getSetRegDword("Header",ADTS);
+ }
+ else
+ MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
+}
+// -----------------------------------------------------------------------------------------------
+
+void Cfaac::setFaacCfg(MY_ENC_CFG *cfg)
+{
+CRegistry reg;
+
+ if(reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAC"))
+ {
+ reg.setRegBool("Auto",cfg->AutoCfg);
+ reg.setRegBool("Write MP4",cfg->SaveMP4);
+ 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.setRegBool("Use quality",cfg->UseQuality);
+ reg.setRegDword("Quality",cfg->EncCfg.quantqual);
+ reg.setRegDword("BitRate",cfg->EncCfg.bitRate);
+ reg.setRegDword("BandWidth",cfg->EncCfg.bandWidth);
+ reg.setRegDword("Header",cfg->EncCfg.outputFormat);
+ }
+ else
+ MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
+}
+// *********************************************************************************************
+
+HANDLE Cfaac::Init(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long FileSize)
+{
+MYOUTPUT *mo;
+MY_ENC_CFG cfg;
+DWORD samplesInput,
+ maxBytesOutput;
+
+// if(wBitsPerSample!=8 && wBitsPerSample!=16) // 32 bit audio from cooledit is in unsupported format
+// return 0;
+ if(wChannels>48) // FAAC supports max 48 tracks!
+ return NULL;
+
+ GLOBALLOCK(mo,hOutput,MYOUTPUT,return NULL);
+
+ // open the encoder library
+ if(!(mo->hEncoder=faacEncOpen(lSamprate, wChannels, &samplesInput, &maxBytesOutput)))
+ return ERROR_Init("Can't open library");
+
+ if(!(mo->bitbuf=(unsigned char *)malloc(maxBytesOutput*sizeof(unsigned char))))
+ return ERROR_Init("Memory allocation error: output buffer");
+
+ if(!(mo->bufIn=(BYTE *)malloc(samplesInput*sizeof(int32_t))))
+ return ERROR_Init("Memory allocation error: input buffer");
+
+ if(!(mo->buf32bit=(int32_t *)malloc(samplesInput*sizeof(int32_t))))
+ return ERROR_Init("Memory allocation error: 32 bit buffer");
+
+
+ getFaacCfg(&cfg);
+
+ if(cfg.SaveMP4)
+ if(!strcmpi(lpstrFilename+lstrlen(lpstrFilename)-4,".aac"))
+ strcpy(lpstrFilename+lstrlen(lpstrFilename)-4,".mp4");
+ else
+ if(strcmpi(lpstrFilename+lstrlen(lpstrFilename)-4,".mp4"))
+ strcat(lpstrFilename,".mp4");
+ mo->WriteMP4=!strcmpi(lpstrFilename+lstrlen(lpstrFilename)-4,".mp4");
+
+ if(cfg.AutoCfg)
+ {
+ faacEncConfigurationPtr myFormat=&cfg.EncCfg;
+ faacEncConfigurationPtr CurFormat=faacEncGetCurrentConfiguration(mo->hEncoder);
+ if(mo->WriteMP4)
+ CurFormat->outputFormat=RAW;
+ CurFormat->useLfe=wChannels>=6 ? 1 : 0;
+ if(!faacEncSetConfiguration(mo->hEncoder, CurFormat))
+ return ERROR_Init("Unsupported parameters!");
+ }
+ else
+ {
+ faacEncConfigurationPtr myFormat=&cfg.EncCfg;
+ faacEncConfigurationPtr CurFormat=faacEncGetCurrentConfiguration(mo->hEncoder);
+
+ if(cfg.UseQuality)
+ {
+ CurFormat->quantqual=myFormat->quantqual;
+ CurFormat->bitRate=myFormat->bitRate;
+ }
+ else
+ if(!CurFormat->bitRate)
+ CurFormat->bitRate=myFormat->bitRate;
+ else
+ CurFormat->bitRate*=1000;
+
+ switch(CurFormat->bandWidth)
+ {
+ case 0:
+ break;
+ case 0xffffffff:
+ CurFormat->bandWidth=lSamprate/2;
+ break;
+ default:
+ CurFormat->bandWidth=myFormat->bandWidth;
+ break;
+ }
+/*
+ switch(wBitsPerSample)
+ {
+ case 16:
+ CurFormat->inputFormat=FAAC_INPUT_16BIT;
+ break;
+ case 24:
+ CurFormat->inputFormat=FAAC_INPUT_24BIT;
+ break;
+ case 32:
+ CurFormat->inputFormat=FAAC_INPUT_32BIT;
+ break;
+ default:
+ CurFormat->inputFormat=FAAC_INPUT_NULL;
+ break;
+ }
+*/
+ CurFormat->mpegVersion=myFormat->mpegVersion;
+ CurFormat->outputFormat=mo->WriteMP4 ? 0 : myFormat->outputFormat;
+ CurFormat->mpegVersion=myFormat->mpegVersion;
+ CurFormat->aacObjectType=myFormat->aacObjectType;
+ CurFormat->allowMidside=myFormat->allowMidside;
+ CurFormat->useTns=myFormat->useTns;
+ CurFormat->useLfe=wChannels>=6 ? 1 : 0;
+
+ if(!faacEncSetConfiguration(mo->hEncoder, CurFormat))
+ return ERROR_Init("Unsupported parameters!");
+ }
+
+// mo->src_size=lSize;
+// mi->dst_name=strdup(lpstrFilename);
+ mo->Samprate=lSamprate;
+ mo->BitsPerSample=wBitsPerSample;
+ mo->Channels=wChannels;
+ mo->samplesInput=samplesInput;
+ mo->samplesInputSize=samplesInput*(mo->BitsPerSample>>3);
+
+ mo->maxBytesOutput=maxBytesOutput;
+
+ if(mo->WriteMP4) // Create MP4 file --------------------------------------------------------------------------
+ {
+ BYTE *ASC=0;
+ DWORD ASCLength=0;
+
+ if((mo->MP4File=MP4Create(lpstrFilename, 0, 0, 0))==MP4_INVALID_FILE_HANDLE)
+ return ERROR_Init("Can't create file");
+ MP4SetTimeScale(mo->MP4File, 90000);
+ mo->MP4track=MP4AddAudioTrack(mo->MP4File, lSamprate, MP4_INVALID_DURATION, MP4_MPEG4_AUDIO_TYPE);
+ MP4SetAudioProfileLevel(mo->MP4File, 0x0F);
+ faacEncGetDecoderSpecificInfo(mo->hEncoder, &ASC, &ASCLength);
+ MP4SetTrackESConfiguration(mo->MP4File, mo->MP4track, (unsigned __int8 *)ASC, ASCLength);
+ mo->frameSize=samplesInput/wChannels;
+ mo->ofs=mo->frameSize;
+ }
+ else // Create AAC file -----------------------------------------------------------------------------
+ {
+ // open the aac output file
+ if(!(mo->aacFile=fopen(lpstrFilename, "wb")))
+ return ERROR_Init("Can't create file");
+
+ // use bufferized stream
+ setvbuf(mo->aacFile,NULL,_IOFBF,32767);
+ }
+
+ showInfo(mo);
+
+ GlobalUnlock(hOutput);
+ return hOutput;
+}
+// *********************************************************************************************
+
+int Cfaac::processData(HANDLE hOutput, BYTE *bufIn, DWORD len)
+{
+ if(!hOutput)
+ return -1;
+
+int bytesWritten=0;
+int bytesEncoded;
+MYOUTPUT far *mo;
+
+ GLOBALLOCK(mo,hOutput,MYOUTPUT,return 0);
+
+int32_t *buf=mo->buf32bit;
+
+ if((int)len<mo->samplesInputSize)
+ {
+ mo->samplesInput=(len<<3)/mo->BitsPerSample;
+ mo->samplesInputSize=mo->samplesInput*(mo->BitsPerSample>>3);
+ }
+ To32bit(buf,bufIn,mo->samplesInput,mo->BitsPerSample>>3,false);
+
+ // call the actual encoding routine
+ if((bytesEncoded=faacEncEncode(mo->hEncoder, (int32_t *)buf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput))<0)
+ return ERROR_processData("faacEncEncode()");
+
+ // write bitstream to aac file
+ if(mo->aacFile)
+ {
+ if(bytesEncoded>0)
+ {
+ if((bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->aacFile))!=bytesEncoded)
+ return ERROR_processData("fwrite");
+ mo->WrittenSamples=1; // needed into destructor
+ }
+ }
+ else
+ // write bitstream to mp4 file
+ {
+ MP4Duration dur,
+ SamplesLeft;
+ if(len>0)
+ {
+ mo->srcSize+=len;
+ dur=mo->frameSize;
+ }
+ else
+ {
+ mo->TotalSamples=(mo->srcSize<<3)/(mo->BitsPerSample*mo->Channels);
+ SamplesLeft=(mo->TotalSamples-mo->WrittenSamples)+mo->frameSize;
+ dur=SamplesLeft>mo->frameSize ? mo->frameSize : SamplesLeft;
+ }
+ if(bytesEncoded>0)
+ {
+ if(!(bytesWritten=MP4WriteSample(mo->MP4File, mo->MP4track, (unsigned __int8 *)mo->bitbuf, (DWORD)bytesEncoded, dur, mo->ofs, true) ? bytesEncoded : -1))
+ return ERROR_processData("MP4WriteSample");
+ mo->ofs=0;
+ mo->WrittenSamples+=dur;
+ }
+ }
+
+ showProgress(mo);
+
+ GlobalUnlock(hOutput);
+ return bytesWritten;
+}
+// -----------------------------------------------------------------------------------------------
+
+int Cfaac::processDataBufferized(HANDLE hOutput, BYTE *bufIn, long lBytes)
+{
+ if(!hOutput)
+ return -1;
+
+int bytesWritten=0, tot=0;
+MYOUTPUT far *mo;
+
+ GLOBALLOCK(mo,hOutput,MYOUTPUT,return 0);
+
+ if(mo->bytes_into_buffer>=0)
+ do
+ {
+ if(mo->bytes_into_buffer+lBytes<mo->samplesInputSize)
+ {
+ memmove(mo->bufIn+mo->bytes_into_buffer, bufIn, lBytes);
+ mo->bytes_into_buffer+=lBytes;
+ lBytes=0;
+ }
+ else
+ {
+ int shift=mo->samplesInputSize-mo->bytes_into_buffer;
+ memmove(mo->bufIn+mo->bytes_into_buffer, bufIn, shift);
+ mo->bytes_into_buffer+=shift;
+ bufIn+=shift;
+ lBytes-=shift;
+
+ tot+=bytesWritten=processData(hOutput,mo->bufIn,mo->bytes_into_buffer);
+ if(bytesWritten<0)
+ return ERROR_processData(0);
+ mo->bytes_into_buffer=0;
+ }
+ }while(lBytes);
+
+ GlobalUnlock(hOutput);
+ return tot;
+}
--- /dev/null
+++ b/plugins/cooledit/Cfaac.h
@@ -1,0 +1,130 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2004 Antonio Foranna
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
+#ifndef _Cfaac_H
+#define _Cfaac_H
+
+// *********************************************************************************************
+
+#include <mp4.h> // int32_t, ...
+#include <faad.h> // FAAD2 version
+#ifdef MAIN
+ #undef MAIN
+#endif
+#ifdef SSR
+ #undef SSR
+#endif
+#ifdef LTP
+ #undef LTP
+#endif
+#include <faac.h>
+#include <win32_ver.h> // mpeg4ip version
+#include "CRegistry.h"
+#include "Defines.h" // my defines
+
+// *********************************************************************************************
+
+#ifdef ADTS
+#undef ADTS
+#define ADTS 1
+#endif
+
+// *********************************************************************************************
+
+typedef struct mec
+{
+bool AutoCfg,
+ UseQuality,
+ SaveMP4;
+faacEncConfiguration EncCfg;
+} MY_ENC_CFG;
+// -----------------------------------------------------------------------------------------------
+
+typedef struct output_tag // any special vars associated with output file
+{
+// MP4
+MP4FileHandle MP4File;
+MP4TrackId MP4track;
+MP4Duration TotalSamples,
+ WrittenSamples,
+ encoded_samples;
+DWORD frameSize,
+ ofs;
+
+// AAC
+FILE *aacFile;
+
+// GLOBAL
+long Samprate;
+WORD BitsPerSample;
+WORD Channels;
+DWORD srcSize;
+//char *dst_name; // name of compressed file
+
+faacEncHandle hEncoder;
+int32_t *buf32bit;
+BYTE *bufIn;
+unsigned char *bitbuf;
+long bytes_into_buffer;
+DWORD maxBytesOutput;
+long samplesInput,
+ samplesInputSize;
+bool WriteMP4;
+} MYOUTPUT;
+
+
+
+// *********************************************************************************************
+
+
+
+class Cfaac
+{
+private:
+ virtual void DisplayError(char *ProcName, char *str);
+ virtual HANDLE ERROR_Init(char *str) { DisplayError("Init", str); return NULL; }
+ virtual int ERROR_processData(char *str) { DisplayError("processData", str); return -1; }
+ virtual void showInfo(MYOUTPUT *mi) {}
+ virtual void showProgress(MYOUTPUT *mi) {}
+ virtual void To32bit(int32_t *buf, BYTE *bufi, int size, BYTE samplebytes, BYTE bigendian);
+
+public:
+ Cfaac(HANDLE hOutput=NULL);
+ virtual ~Cfaac();
+
+ static void getFaacCfg(MY_ENC_CFG *cfg);
+ static void setFaacCfg(MY_ENC_CFG *cfg);
+ virtual HANDLE Init(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long FileSize);
+ virtual int processData(HANDLE hOutput, BYTE *bufIn, DWORD len);
+ virtual int processDataBufferized(HANDLE hOutput, BYTE *bufIn, long lBytes);
+/*
+// AAC
+ bool BlockSeeking;
+
+// GLOBAL
+ long newpos_ms;
+ BOOL IsSeekable;
+ MYINPUT *mi;
+*/
+ HANDLE hOutput;
+};
+
+#endif
--- /dev/null
+++ b/plugins/cooledit/Cfaad.cpp
@@ -1,0 +1,673 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2002-2004 Antonio Foranna
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
+#include "Cfaad.h"
+
+
+
+// *********************************************************************************************
+
+
+
+Cfaad::Cfaad(HANDLE hIn)
+{
+ if(hIn)
+ {
+ hInput=hIn;
+ return;
+ }
+
+MYINPUT *mi;
+
+ if(!(hInput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(MYINPUT))))
+ MessageBox(0, "Memory allocation error: hInput", APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
+ if(!(mi=(MYINPUT *)GlobalLock(hInput)))
+ MessageBox(0, "GlobalLock(hInput)", APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
+/*
+ mi->mp4File=0;
+ mi->aacFile=0;
+ mi->hDecoder=0;
+ mi->buffer=0;
+ mi->bytes_read=0;*/
+ mi->BitsPerSample=16;
+// newpos_ms=-1;
+// seek_table=0;
+// seek_table_length=0;
+ mi->FindBitrate=FALSE;
+// BlockSeeking=false;
+ GlobalUnlock(hInput);
+}
+// -----------------------------------------------------------------------------------------------
+
+Cfaad::~Cfaad()
+{
+MYINPUT *mi;
+
+ if(!hInput)
+ return;
+
+ GLOBALLOCK(mi,hInput,MYINPUT,return);
+
+ if(mi->mp4File)
+ MP4Close(mi->mp4File);
+ if(mi->aacFile)
+ fclose(mi->aacFile);
+ if(mi->hDecoder)
+ faacDecClose(mi->hDecoder);
+ FREE_ARRAY(mi->buffer);
+// FREE_ARRAY(mi->seek_table);
+
+ GlobalUnlock(hInput);
+ GlobalFree(hInput);
+}
+
+// *********************************************************************************************
+// Utilities
+// *********************************************************************************************
+
+int Cfaad::GetAACTrack(MP4FileHandle infile)
+{
+// find AAC track
+int i, rc;
+int numTracks = MP4GetNumberOfTracks(infile, NULL, 0);
+
+ for (i = 0; i < numTracks; i++)
+ {
+ MP4TrackId trackId = MP4FindTrackId(infile, i, NULL, 0);
+ const char* trackType = MP4GetTrackType(infile, trackId);
+
+ if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE))
+ {
+ unsigned char *buff = NULL;
+ unsigned __int32 buff_size = 0;
+ mp4AudioSpecificConfig mp4ASC;
+
+ MP4GetTrackESConfiguration(infile, trackId, (unsigned __int8 **)&buff, &buff_size);
+
+ if (buff)
+ {
+ rc = AudioSpecificConfig(buff, buff_size, &mp4ASC);
+ free(buff);
+
+ if (rc < 0)
+ return -1;
+ return trackId;
+ }
+ }
+ }
+
+ // can't decode this
+ return -1;
+}
+// *********************************************************************************************
+
+int Cfaad::IsMP4(LPSTR lpstrFilename)
+{
+DWORD mp4file = 0;
+FILE *hMP4File = fopen(lpstrFilename, "rb");
+BYTE header[8];
+ if(!hMP4File)
+ return -1;
+ fread(header, 1, 8, hMP4File);
+ fclose(hMP4File);
+ if(header[4]=='f' && header[5]=='t' && header[6]=='y' && header[7]=='p')
+ return 1;
+
+ return 0;
+}
+// *********************************************************************************************
+
+long Cfaad::id3v2_TagSize(aac_buffer *b)
+{
+DWORD tagsize = 0;
+ if (!memcmp(b->buffer, "ID3", 3))
+ {
+ /* high bit is not used */
+ tagsize = (b->buffer[6] << 21) | (b->buffer[7] << 14) |
+ (b->buffer[8] << 7) | (b->buffer[9] << 0);
+
+ tagsize += 10;
+ advance_buffer(b, tagsize);
+ fill_buffer(b);
+ }
+ return tagsize;
+}
+// *********************************************************************************************
+
+int Cfaad::fill_buffer(aac_buffer *b)
+{
+ int bread;
+
+ if (b->bytes_consumed > 0)
+ {
+ if (b->bytes_into_buffer)
+ {
+ memmove((void*)b->buffer, (void*)(b->buffer + b->bytes_consumed),
+ b->bytes_into_buffer*sizeof(unsigned char));
+ }
+
+ if (!b->at_eof)
+ {
+ bread = fread((void*)(b->buffer + b->bytes_into_buffer), 1,
+ b->bytes_consumed, b->infile);
+
+ if (bread != b->bytes_consumed)
+ b->at_eof = 1;
+
+ b->bytes_into_buffer += bread;
+ }
+
+ b->bytes_consumed = 0;
+
+ if (b->bytes_into_buffer > 3)
+ {
+ if (memcmp(b->buffer, "TAG", 3) == 0)
+ b->bytes_into_buffer = 0;
+ }
+ if (b->bytes_into_buffer > 11)
+ {
+ if (memcmp(b->buffer, "LYRICSBEGIN", 11) == 0)
+ b->bytes_into_buffer = 0;
+ }
+ if (b->bytes_into_buffer > 8)
+ {
+ if (memcmp(b->buffer, "APETAGEX", 8) == 0)
+ b->bytes_into_buffer = 0;
+ }
+ }
+
+ return 1;
+}
+// *********************************************************************************************
+
+void Cfaad::advance_buffer(aac_buffer *b, int bytes)
+{
+ b->file_offset += bytes;
+ b->bytes_consumed = bytes;
+ b->bytes_into_buffer -= bytes;
+}
+// *********************************************************************************************
+
+static int adts_sample_rates[] = {96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350,0,0,0};
+
+int Cfaad::adts_parse(aac_buffer *b, int *bitrate, float *length)
+{
+ int frames, frame_length;
+ int t_framelength = 0;
+ int samplerate;
+ float frames_per_sec, bytes_per_frame;
+
+ /* Read all frames to ensure correct time and bitrate */
+ for (frames = 0; /* */; frames++)
+ {
+ fill_buffer(b);
+
+ if (b->bytes_into_buffer > 7)
+ {
+ /* check syncword */
+ if (!((b->buffer[0] == 0xFF)&&((b->buffer[1] & 0xF6) == 0xF0)))
+ break;
+
+ if (frames == 0)
+ samplerate = adts_sample_rates[(b->buffer[2]&0x3c)>>2];
+
+ frame_length = ((((unsigned int)b->buffer[3] & 0x3)) << 11)
+ | (((unsigned int)b->buffer[4]) << 3) | (b->buffer[5] >> 5);
+
+ t_framelength += frame_length;
+
+ if (frame_length > b->bytes_into_buffer)
+ break;
+
+ advance_buffer(b, frame_length);
+ } else {
+ break;
+ }
+ }
+
+ frames_per_sec = (float)samplerate/1024.0f;
+ if (frames != 0)
+ bytes_per_frame = (float)t_framelength/(float)(frames*1000);
+ else
+ bytes_per_frame = 0;
+ *bitrate = (int)(8. * bytes_per_frame * frames_per_sec + 0.5);
+ if (frames_per_sec != 0)
+ *length = (float)frames/frames_per_sec;
+ else
+ *length = 1;
+
+ return 1;
+}
+// *********************************************************************************************
+
+/* get AAC infos for printing */
+void Cfaad::GetAACInfos(aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate, long filesize)
+{
+int bitrate;
+float length;
+int bread;
+long tagsize=id3v2_TagSize(b);
+
+ *header_type = 0;
+ b->file_offset=tagsize;
+
+ if ((b->buffer[0] == 0xFF) && ((b->buffer[1] & 0xF6) == 0xF0))
+ {
+ adts_parse(b, &bitrate, &length);
+ fseek(b->infile, tagsize, SEEK_SET);
+
+ bread = fread(b->buffer, 1, FAAD_MIN_STREAMSIZE*MAX_CHANNELS, b->infile);
+ if (bread != FAAD_MIN_STREAMSIZE*MAX_CHANNELS)
+ b->at_eof = 1;
+ else
+ b->at_eof = 0;
+ b->bytes_into_buffer = bread;
+ b->bytes_consumed = 0;
+ b->file_offset = tagsize;
+
+ *header_type = 1;
+ } else if (memcmp(b->buffer, "ADIF", 4) == 0) {
+ int skip_size = (b->buffer[4] & 0x80) ? 9 : 0;
+ bitrate = ((unsigned int)(b->buffer[4 + skip_size] & 0x0F)<<19) |
+ ((unsigned int)b->buffer[5 + skip_size]<<11) |
+ ((unsigned int)b->buffer[6 + skip_size]<<3) |
+ ((unsigned int)b->buffer[7 + skip_size] & 0xE0);
+
+ length = (float)filesize;
+ if (length != 0)
+ {
+ length = ((float)length*8.f)/((float)bitrate) + 0.5f;
+ }
+
+ bitrate = (int)((float)bitrate/1000.0f + 0.5f);
+
+ *header_type = 2;
+ }
+
+ *song_length = length;
+ *pbitrate=bitrate;
+}
+
+// *********************************************************************************************
+// Main functions
+// *********************************************************************************************
+
+void Cfaad::ReadCfgDec(MY_DEC_CFG *cfg)
+{
+CRegistry reg;
+
+ if(reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAD"))
+ {
+ cfg->DefaultCfg=reg.getSetRegBool("Default",true);
+ cfg->DecCfg.defObjectType=reg.getSetRegByte("Profile",LC);
+ cfg->DecCfg.defSampleRate=reg.getSetRegDword("SampleRate",44100);
+ cfg->DecCfg.outputFormat=reg.getSetRegByte("Bps",FAAD_FMT_16BIT);
+ cfg->DecCfg.downMatrix=reg.getSetRegByte("Downmatrix",0);
+ cfg->DecCfg.useOldADTSFormat=reg.getSetRegByte("Old ADTS",0);
+ cfg->DecCfg.dontUpSampleImplicitSBR=reg.getSetRegByte("Don\'t upsample implicit SBR",1);
+// cfg->Channels=reg.getSetRegByte("Channels",2);
+ }
+ else
+ MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
+}
+// -----------------------------------------------------------------------------------------------
+
+void Cfaad::WriteCfgDec(MY_DEC_CFG *cfg)
+{
+CRegistry reg;
+
+ if(reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAD"))
+ {
+ reg.setRegBool("Default",cfg->DefaultCfg);
+ reg.setRegByte("Profile",cfg->DecCfg.defObjectType);
+ reg.setRegDword("SampleRate",cfg->DecCfg.defSampleRate);
+ reg.setRegByte("Bps",cfg->DecCfg.outputFormat);
+ reg.setRegByte("Downmatrix",cfg->DecCfg.downMatrix);
+ reg.setRegByte("Old ADTS",cfg->DecCfg.useOldADTSFormat);
+ reg.setRegByte("Don\'t upsample implicit SBR",cfg->DecCfg.dontUpSampleImplicitSBR);
+// reg.setRegByte("Channels",cfg->Channels);
+ }
+ else
+ MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
+}
+// *********************************************************************************************
+
+void Cfaad::setFaadCfg(faacDecHandle hDecoder)
+{
+faacDecConfigurationPtr config;
+
+ config=faacDecGetCurrentConfiguration(hDecoder);
+ config->outputFormat = FAAD_FMT_16BIT;
+ config->downMatrix = 0;
+ config->useOldADTSFormat = 0;
+ config->dontUpSampleImplicitSBR = 1;
+ faacDecSetConfiguration(hDecoder, config);
+/*
+ ReadCfgDec(&Cfg);
+ if(!Bitrate4RawAAC)
+ DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_DECODER),(HWND)hWnd, (DLGPROC)DialogMsgProcDecoder, (DWORD)&Cfg);
+ config=faacDecGetCurrentConfiguration(mi->hDecoder);
+ if(Cfg.DefaultCfg)
+ {
+ config->defObjectType=mi->file_info.object_type;
+ config->defSampleRate=mi->file_info.sampling_rate;//*lSamprate; // doesn't work!
+ }
+ else
+ {
+ config->defObjectType=Cfg.DecCfg.defObjectType;
+ config->defSampleRate=Cfg.DecCfg.defSampleRate;
+ }
+ config->outputFormat=FAAD_FMT_16BIT;
+ faacDecSetConfiguration(mi->hDecoder, config);*/
+}
+// -----------------------------------------------------------------------------------------------
+
+void Cfaad::DisplayError(char *ProcName, char *str)
+{
+MYINPUT *mi;
+char buf[100]="";
+
+ GlobalUnlock(hInput); // it wasn't done in getInfos()
+ GLOBALLOCK(mi,hInput,MYINPUT,return);
+
+ if(ProcName && *ProcName)
+ sprintf(buf,"%s: ", ProcName);
+ if(str && *str)
+ strcat(buf,str);
+ if(*buf && str)
+ MessageBox(0, buf, APP_NAME " plugin", MB_OK|MB_ICONSTOP);
+
+ mi->bytes_into_buffer=-1;
+ GlobalUnlock(hInput);
+}
+// *********************************************************************************************
+
+HANDLE Cfaad::getInfos(LPSTR lpstrFilename)
+{
+MYINPUT *mi;
+
+ GLOBALLOCK(mi,hInput,MYINPUT,return 0);
+
+// mi->IsAAC=strcmpi(lpstrFilename+lstrlen(lpstrFilename)-4,".aac")==0;
+ if((mi->IsMP4=IsMP4(lpstrFilename))==-1)
+ return ERROR_getInfos("Error opening file");
+
+ if(mi->IsMP4) // MP4 file ---------------------------------------------------------------------
+ {
+ MP4Duration length;
+ unsigned __int32 buffer_size;
+ DWORD timeScale;
+ BYTE sf;
+ mp4AudioSpecificConfig mp4ASC;
+
+ if(!(mi->mp4File=MP4Read(lpstrFilename, 0)))
+ return ERROR_getInfos("Error opening file");
+
+ if((mi->track=GetAACTrack(mi->mp4File))<0)
+ return ERROR_getInfos(0); //"Unable to find correct AAC sound track");
+
+ if(!(mi->hDecoder=faacDecOpen()))
+ return ERROR_getInfos("Error initializing decoder library");
+
+ MP4GetTrackESConfiguration(mi->mp4File, mi->track, (unsigned __int8 **)&mi->buffer, &buffer_size);
+ if(!mi->buffer)
+ return ERROR_getInfos("MP4GetTrackESConfiguration");
+ AudioSpecificConfig(mi->buffer, buffer_size, &mp4ASC);
+
+ timeScale = mp4ASC.samplingFrequency;
+ mi->Channels=mp4ASC.channelsConfiguration;
+ sf = mp4ASC.samplingFrequencyIndex;
+ mi->type = mp4ASC.objectTypeIndex;
+// mi->SBR=mp4ASC.sbr_present_flag;
+
+ if(faacDecInit2(mi->hDecoder, mi->buffer, buffer_size, &mi->Samprate, &mi->Channels) < 0)
+ return ERROR_getInfos("Error initializing decoder library");
+ FREE_ARRAY(mi->buffer);
+
+ length=MP4GetTrackDuration(mi->mp4File, mi->track);
+ mi->len_ms=(DWORD)MP4ConvertFromTrackDuration(mi->mp4File, mi->track, length, MP4_MSECS_TIME_SCALE);
+ mi->file_info.bitrate=MP4GetTrackBitRate(mi->mp4File, mi->track);
+ mi->file_info.version=MP4GetTrackAudioType(mi->mp4File, mi->track)==MP4_MPEG4_AUDIO_TYPE ? 4 : 2;
+ mi->numSamples=MP4GetTrackNumberOfSamples(mi->mp4File, mi->track);
+ mi->sampleId=1;
+ }
+ else // AAC file ------------------------------------------------------------------------------
+ {
+ DWORD read,
+ tmp;
+ BYTE Channels4Raw=0;
+
+ if(!(mi->aacFile=fopen(lpstrFilename,"rb")))
+ return ERROR_getInfos("Error opening file");
+
+ // use bufferized stream
+ setvbuf(mi->aacFile,NULL,_IOFBF,32767);
+
+ // get size of file
+ fseek(mi->aacFile, 0, SEEK_END);
+ mi->src_size=ftell(mi->aacFile);
+ fseek(mi->aacFile, 0, SEEK_SET);
+
+ if(!(mi->buffer=(BYTE *)malloc(FAAD_STREAMSIZE)))
+ return ERROR_getInfos("Memory allocation error: mi->buffer");
+
+ tmp=mi->src_size<FAAD_STREAMSIZE ? mi->src_size : FAAD_STREAMSIZE;
+ read=fread(mi->buffer, 1, tmp, mi->aacFile);
+ if(read==tmp)
+ {
+ mi->bytes_read=read;
+ mi->bytes_into_buffer=read;
+ }
+ else
+ return ERROR_getInfos("Read failed!");
+
+aac_buffer b;
+float fLength;
+DWORD headertype;
+ b.infile=mi->aacFile;
+ b.buffer=mi->buffer;
+ b.bytes_into_buffer=read;
+ b.bytes_consumed=mi->bytes_consumed;
+// b.file_offset=mi->tagsize;
+ b.at_eof=(read!=tmp) ? 1 : 0;
+ GetAACInfos(&b,&headertype,&fLength,&mi->file_info.bitrate,mi->src_size);
+ mi->file_info.bitrate*=1024;
+ mi->file_info.headertype=headertype;
+ mi->bytes_into_buffer=b.bytes_into_buffer;
+ mi->bytes_consumed=b.bytes_consumed;
+// mi->bytes_read=b.file_offset;
+
+/* IsSeekable=mi->file_info.headertype==ADTS && fLength>0;
+ BlockSeeking=!IsSeekable;
+*/
+ if(!(mi->hDecoder=faacDecOpen()))
+ return ERROR_getInfos("Can't open library");
+
+ if(mi->file_info.headertype==RAW)
+ setFaadCfg(mi->hDecoder);
+ if((mi->bytes_consumed=faacDecInit(mi->hDecoder, mi->buffer, mi->bytes_into_buffer, &mi->Samprate, &mi->Channels))<0)
+ return ERROR_getInfos("faacDecInit failed!");
+ mi->bytes_into_buffer-=mi->bytes_consumed;
+
+// if(mi->file_info.headertype==RAW)
+ if(!mi->FindBitrate)
+ {
+ MYINPUT *miTmp;
+ Cfaad *NewInst;
+ if(!(NewInst=new Cfaad()))
+ return ERROR_getInfos("Memory allocation error: NewInst");
+
+ GLOBALLOCK(miTmp,NewInst->hInput,MYINPUT,return 0);
+ miTmp->FindBitrate=TRUE;
+ if(!NewInst->getInfos(lpstrFilename))
+ return ERROR_getInfos(0);
+ mi->Channels=miTmp->frameInfo.channels;
+ if(mi->file_info.headertype==RAW)
+ mi->file_info.bitrate=miTmp->file_info.bitrate*mi->Channels;
+ mi->Samprate=miTmp->Samprate;
+ mi->file_info.headertype=miTmp->file_info.headertype;
+ mi->file_info.object_type=miTmp->file_info.object_type;
+ mi->file_info.version=miTmp->file_info.version;
+ GlobalUnlock(NewInst->hInput);
+ delete NewInst;
+ }
+ else
+ {
+ DWORD Samples,
+ BytesConsumed;
+
+// if((mi->bytes_consumed=faacDecInit(mi->hDecoder,mi->buffer,mi->bytes_into_buffer,&mi->Samprate,&mi->Channels))<0)
+// return ERROR_getInfos("Can't init library");
+// mi->bytes_into_buffer-=mi->bytes_consumed;
+ if(!processData(hInput,0,0))
+ return ERROR_getInfos(0);
+ Samples=mi->frameInfo.samples/sizeof(short);
+ BytesConsumed=mi->frameInfo.bytesconsumed;
+ processData(hInput,0,0);
+ if(BytesConsumed<mi->frameInfo.bytesconsumed)
+ BytesConsumed=mi->frameInfo.bytesconsumed;
+ if(mi->file_info.headertype==RAW)
+ mi->file_info.bitrate=(BytesConsumed*8*mi->Samprate)/Samples;
+ if(!mi->file_info.bitrate)
+ mi->file_info.bitrate=1000; // try to continue decoding
+ }
+
+ mi->len_ms=(DWORD)((1000*((float)mi->src_size*8))/mi->file_info.bitrate);
+ }
+
+ if(mi->len_ms)
+ mi->dst_size=(DWORD)(mi->len_ms*((float)mi->Samprate/1000)*mi->Channels*(mi->BitsPerSample/8));
+ else
+ mi->dst_size=mi->src_size; // corrupt stream?
+
+ showInfo(mi);
+
+ GlobalUnlock(hInput);
+ return hInput;
+}
+// *********************************************************************************************
+
+int Cfaad::processData(HANDLE hInput, unsigned char far *bufout, long lBytes)
+{
+BYTE *buffer;
+DWORD BytesDecoded=0;
+char *sample_buffer=0;
+int read;
+MYINPUT *mi;
+
+ GLOBALLOCK(mi,hInput,MYINPUT,return 0);
+
+ if(mi->IsMP4) // MP4 file --------------------------------------------------------------------------
+ {
+ unsigned __int32 buffer_size=0;
+ int rc;
+
+ do
+ {
+ buffer=NULL;
+ if(mi->sampleId>=mi->numSamples)
+ return ERROR_processData(0);
+
+ rc=MP4ReadSample(mi->mp4File, mi->track, mi->sampleId++, (unsigned __int8 **)&buffer, &buffer_size, NULL, NULL, NULL, NULL);
+ if(rc==0 || buffer==NULL)
+ {
+ FREE_ARRAY(buffer);
+ return ERROR_processData("MP4ReadSample");
+ }
+
+ sample_buffer=(char *)faacDecDecode(mi->hDecoder,&mi->frameInfo,buffer,buffer_size);
+ BytesDecoded=mi->frameInfo.samples*sizeof(short);
+ if(BytesDecoded>(DWORD)lBytes)
+ BytesDecoded=lBytes;
+ memcpy(bufout,sample_buffer,BytesDecoded);
+ FREE_ARRAY(buffer);
+ }while(!BytesDecoded && !mi->frameInfo.error);
+ }
+ else // AAC file --------------------------------------------------------------------------
+ {
+ buffer=mi->buffer;
+ do
+ {
+ if(mi->bytes_consumed>0)
+ {
+ if(mi->bytes_into_buffer)
+ memmove(buffer,buffer+mi->bytes_consumed,mi->bytes_into_buffer);
+
+ if(mi->bytes_read<mi->src_size)
+ {
+ int tmp;
+ if(mi->bytes_read+mi->bytes_consumed<mi->src_size)
+ tmp=mi->bytes_consumed;
+ else
+ tmp=mi->src_size-mi->bytes_read;
+ read=fread(buffer+mi->bytes_into_buffer, 1, tmp, mi->aacFile);
+ 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>3 && !memcmp(mi->buffer, "TAG", 3)) ||
+ (mi->bytes_into_buffer>11 && !memcmp(mi->buffer, "LYRICSBEGIN", 11)) ||
+ (mi->bytes_into_buffer>8 && !memcmp(mi->buffer, "APETAGEX", 8)))
+ return ERROR_processData(0);
+ }
+
+ if(mi->bytes_into_buffer<1)
+ if(mi->bytes_read<mi->src_size)
+ return ERROR_processData("ReadFilterInput: buffer empty!");
+ else
+ return ERROR_processData(0);
+
+ sample_buffer=(char *)faacDecDecode(mi->hDecoder,&mi->frameInfo,buffer,mi->bytes_into_buffer);
+ BytesDecoded=mi->frameInfo.samples*sizeof(short);
+ if(bufout)
+ {
+ if(BytesDecoded>(DWORD)lBytes)
+ BytesDecoded=lBytes;
+ if(sample_buffer && BytesDecoded && !mi->frameInfo.error)
+ memcpy(bufout,sample_buffer,BytesDecoded);
+ }
+ else // Data needed to decode Raw files
+ {
+ mi->bytesconsumed=mi->frameInfo.bytesconsumed;
+ mi->Channels=mi->frameInfo.channels;
+ mi->file_info.object_type=mi->frameInfo.object_type;
+ }
+ mi->bytes_consumed+=mi->frameInfo.bytesconsumed;
+ mi->bytes_into_buffer-=mi->bytes_consumed;
+ }while(!BytesDecoded && !mi->frameInfo.error);
+ } // END AAC file --------------------------------------------------------------------------
+
+ if(mi->frameInfo.error)
+ return ERROR_processData((char *)faacDecGetErrorMessage(mi->frameInfo.error));
+
+ showProgress(mi);
+
+ GlobalUnlock(hInput);
+ return BytesDecoded;
+}
--- /dev/null
+++ b/plugins/cooledit/Cfaad.h
@@ -1,0 +1,174 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2004 Antonio Foranna
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
+#ifndef _Cfaad_H
+#define _Cfaad_H
+
+#include <mp4.h>
+#include "faac.h"
+
+#ifdef MAIN
+ #undef MAIN
+#endif
+#ifdef SSR
+ #undef SSR
+#endif
+#ifdef LTP
+ #undef LTP
+#endif
+
+#include "faad.h"
+#include "Defines.h"
+#include "CRegistry.h"
+
+#if RAW!=0
+ #undef RAW
+ #define RAW 0
+#endif
+#if ADTS!=1
+ #undef ADTS
+ #define ADTS 1
+#endif
+#if ADIF!=2
+ #undef ADIF
+ #define ADIF 2
+#endif
+
+
+// make this higher to support files with more channels
+#define MAX_CHANNELS 6
+#if FAAD_MIN_STREAMSIZE<2048
+#undef FAAD_MIN_STREAMSIZE
+// 960 for LD or else 1024 (expanded to 2048 for HE-AAC)
+#define FAAD_MIN_STREAMSIZE 2048
+#endif
+
+#define FAAD_STREAMSIZE (FAAD_MIN_STREAMSIZE*MAX_CHANNELS)
+
+
+
+// -----------------------------------------------------------------------------------------------
+
+
+
+/* FAAD file buffering routines */
+typedef struct {
+ long bytes_into_buffer;
+ long bytes_consumed;
+ long file_offset;
+ unsigned char *buffer;
+ int at_eof;
+ FILE *infile;
+} aac_buffer;
+// -----------------------------------------------------------------------------------------------
+
+typedef struct {
+ int version;
+ int channels;
+ int sampling_rate;
+ int bitrate;
+ int length;
+ int object_type;
+ int headertype;
+} faadAACInfo;
+// -----------------------------------------------------------------------------------------------
+
+typedef struct mdc
+{
+bool DefaultCfg;
+BYTE Channels;
+DWORD BitRate;
+faacDecConfiguration DecCfg;
+} MY_DEC_CFG;
+// -----------------------------------------------------------------------------------------------
+
+typedef struct input_tag // any special vars associated with input file
+{
+//MP4
+MP4FileHandle mp4File;
+MP4SampleId sampleId,
+ numSamples;
+int track;
+BYTE type;
+
+//AAC
+FILE *aacFile;
+DWORD src_size; // size of compressed file
+long tagsize;
+DWORD bytes_read; // from file
+long bytes_consumed; // from buffer by faadDecDecode
+long bytes_into_buffer;
+unsigned char *buffer;
+
+// Raw AAC
+DWORD bytesconsumed; // to decode current frame by faadDecDecode
+BOOL FindBitrate;
+
+// GLOBAL
+faacDecHandle hDecoder;
+faadAACInfo file_info;
+faacDecFrameInfo frameInfo;
+DWORD len_ms; // length of file in milliseconds
+BYTE Channels;
+DWORD Samprate;
+WORD BitsPerSample;
+DWORD dst_size; // size of decoded file. Cooledit needs it to update its progress bar
+//char *src_name; // name of compressed file
+int IsMP4;
+} MYINPUT;
+// -----------------------------------------------------------------------------------------------
+
+class Cfaad
+{
+private:
+ virtual int GetAACTrack(MP4FileHandle infile);
+ long id3v2_TagSize(aac_buffer *b);
+ int fill_buffer(aac_buffer *b);
+ void advance_buffer(aac_buffer *b, int bytes);
+ int adts_parse(aac_buffer *b, int *bitrate, float *length);
+ void GetAACInfos(aac_buffer *b, DWORD *header_type, float *song_length, int *pbitrate, long filesize);
+ int IsMP4(LPSTR lpstrFilename);
+
+ virtual void DisplayError(char *ProcName, char *str);
+ virtual HANDLE ERROR_getInfos(char *str) { DisplayError("getInfos", str); return NULL; }
+ virtual int ERROR_processData(char *str) { DisplayError("processData", str); return 0; }
+ virtual void showInfo(MYINPUT *mi) {}
+ virtual void showProgress(MYINPUT *mi) {}
+ virtual void setFaadCfg(faacDecHandle hDecoder);
+
+public:
+ Cfaad(HANDLE hInput=NULL);
+ virtual ~Cfaad();
+
+ static void ReadCfgDec(MY_DEC_CFG *cfg);
+ static void WriteCfgDec(MY_DEC_CFG *cfg);
+ virtual HANDLE getInfos(LPSTR lpstrFilename);
+ virtual int processData(HANDLE hInput, unsigned char far *bufout, long lBytes);
+
+// AAC
+// bool BlockSeeking;
+
+// GLOBAL
+// long newpos_ms;
+// BOOL IsSeekable;
+ HANDLE hInput;
+};
+#endif
--- a/plugins/cooledit/FAAC.dsp
+++ b/plugins/cooledit/FAAC.dsp
@@ -25,7 +25,7 @@
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
-CPP=cl.exe
+CPP=xicl6.exe
MTL=midl.exe
RSC=rc.exe
@@ -51,7 +51,7 @@
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
-LINK32=link.exe
+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 /dll /machine:I386
# ADD LINK32 ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /machine:I386 /out:"Release/FAAC.flt"
@@ -69,7 +69,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" /D "_MBCS" /D "_USRDLL" /D "FAAC_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../faad2/common/faad" /I "../../include" /I "../../../faad2/include" /I "../../../faad2/common/mp4v2" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "WIN32_LEAN_AND_MEAN" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../../faad2/include" /I "../../../faad2/common/faad" /I "../../../faad2/common/mp4v2" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "WIN32_LEAN_AND_MEAN" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x410 /d "_DEBUG"
@@ -77,9 +77,9 @@
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
-LINK32=link.exe
+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 /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\Sound\Wav\CoolPro/FAAC.flt" /pdbtype:sept
+# ADD LINK32 ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Programmi\Adobe\Audition 1.0\FAAC.flt" /pdbtype:sept
# SUBTRACT LINK32 /nodefaultlib /force
!ENDIF
@@ -93,6 +93,14 @@
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
+SOURCE=.\Cfaac.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Cfaad.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\CRegistry.cpp
# End Source File
# Begin Source File
@@ -121,6 +129,14 @@
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
+SOURCE=.\Cfaac.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Cfaad.h
+# End Source File
+# Begin Source File
+
SOURCE=.\CRegistry.h
# End Source File
# Begin Source File
@@ -142,10 +158,6 @@
# Begin Source File
SOURCE=.\resource.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Structs.h
# End Source File
# End Group
# Begin Group "Resource Files"
--- a/plugins/cooledit/FAAC.dsw
+++ b/plugins/cooledit/FAAC.dsw
@@ -3,7 +3,7 @@
###############################################################################
-Project: "FAAC"=.\FAAC.dsp - Package Owner=<4>
+Project: "FAAC"=".\FAAC.dsp" - Package Owner=<4>
Package=<5>
{{{
@@ -20,14 +20,11 @@
Begin Project Dependency
Project_Dep_Name libmp4v2_st
End Project Dependency
- Begin Project Dependency
- Project_Dep_Name aacInfoLib
- End Project Dependency
}}}
###############################################################################
-Project: "aacInfoLib"=.\aacInfoLib.dsp - Package Owner=<4>
+Project: "libfaac"="..\..\libfaac\libfaac.dsp" - Package Owner=<4>
Package=<5>
{{{
@@ -39,7 +36,7 @@
###############################################################################
-Project: "libfaac"=..\..\libfaac\libfaac.dsp - Package Owner=<4>
+Project: "libfaad"="..\..\..\faad2\libfaad\libfaad.dsp" - Package Owner=<4>
Package=<5>
{{{
@@ -51,19 +48,7 @@
###############################################################################
-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>
+Project: "libmp4v2_st"="..\..\..\faad2\common\mp4v2\libmp4v2_st60.dsp" - Package Owner=<4>
Package=<5>
{{{
--- a/plugins/cooledit/FAAC.rc
+++ b/plugins/cooledit/FAAC.rc
@@ -53,11 +53,12 @@
CONTROL "ADTS",IDC_RADIO_ADTS,"Button",BS_AUTORADIOBUTTON,59,42,
41,9
CONTROL "Allow Mid/Side",IDC_CHK_ALLOWMIDSIDE,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,108,21,63,10
+ BS_AUTOCHECKBOX | WS_TABSTOP,109,29,63,10
CONTROL "Use TNS",IDC_CHK_USETNS,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,108,33,45,10
+ WS_TABSTOP,109,41,45,10
CONTROL "Use LFE channel",IDC_CHK_USELFE,"Button",
- BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,108,46,67,10
+ BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED |
+ WS_TABSTOP,4,122,67,10
CONTROL "Quality",IDC_RADIO_QUALITY,"Button",BS_AUTORADIOBUTTON |
WS_GROUP,61,73,37,10
COMBOBOX IDC_CB_QUALITY,138,71,48,97,CBS_DROPDOWN | WS_VSCROLL |
@@ -72,31 +73,39 @@
GROUPBOX "Profile",IDC_STATIC,4,62,48,59
LTEXT "Bandwidth",IDC_STATIC,73,111,34,8
GROUPBOX "Header",IDC_STATIC,55,18,48,38
- GROUPBOX "Encoding mode",IDC_STATIC,56,62,135,42
+ GROUPBOX "Encoding mode",IDC_STATIC,56,62,137,42
+ CONTROL "Write .mp4",IDC_CHK_WRITEMP4,"Button",BS_AUTOCHECKBOX |
+ NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,4,132,50,10
END
-IDD_DECODER DIALOG DISCARDABLE 0, 0, 141, 94
+IDD_DECODER DIALOG DISCARDABLE 0, 0, 141, 105
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Raw .AAC options"
FONT 8, "MS Sans Serif"
BEGIN
- DEFPUSHBUTTON "&OK",IDOK,24,73,36,14
- PUSHBUTTON "&Cancel",IDCANCEL,61,73,36,14
- PUSHBUTTON "&About",IDC_BTN_ABOUT,97,73,36,14
+ DEFPUSHBUTTON "&OK",IDOK,24,84,36,14
+ PUSHBUTTON "&Cancel",IDCANCEL,61,84,36,14
+ PUSHBUTTON "&About",IDC_BTN_ABOUT,97,84,36,14
CONTROL "Main",IDC_RADIO_MAIN,"Button",BS_AUTORADIOBUTTON |
WS_GROUP,93,17,31,10
- CONTROL "Low",IDC_RADIO_LOW,"Button",BS_AUTORADIOBUTTON,93,30,29,
+ CONTROL "Low",IDC_RADIO_LOW,"Button",BS_AUTORADIOBUTTON,93,28,29,
10
CONTROL "SSR",IDC_RADIO_SSR,"Button",BS_AUTORADIOBUTTON |
- WS_DISABLED,93,41,31,10
- CONTROL "LTP",IDC_RADIO_LTP,"Button",BS_AUTORADIOBUTTON,93,54,29,
+ WS_DISABLED,93,40,31,10
+ CONTROL "LTP",IDC_RADIO_LTP,"Button",BS_AUTORADIOBUTTON,93,52,29,
10
- GROUPBOX "Profile",IDC_STATIC,85,7,48,61
- COMBOBOX IDC_CB_SAMPLERATE,13,48,62,87,CBS_DROPDOWN | WS_VSCROLL |
+ GROUPBOX "Profile",IDC_STATIC,85,7,48,70
+ COMBOBOX IDC_CB_SAMPLERATE,13,57,62,87,CBS_DROPDOWN | WS_VSCROLL |
WS_TABSTOP
CONTROL "Default settings",IDC_CHK_DEFAULTCFG,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,11,64,10
- GROUPBOX "Sample rate",IDC_STATIC,7,37,73,31
+ GROUPBOX "Sample rate",IDC_STATIC,7,46,73,31
+ CONTROL "HE",IDC_RADIO_HE,"Button",BS_AUTORADIOBUTTON,93,64,26,
+ 10
+ CONTROL "Downmatrix",IDC_CHK_DOWNMATRIX,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,7,24,53,10
+ CONTROL "Old ADTS",IDC_CHK_OLDADTS,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,7,36,48,10
END
@@ -147,7 +156,7 @@
LEFTMARGIN, 7
RIGHTMARGIN, 133
TOPMARGIN, 7
- BOTTOMMARGIN, 87
+ BOTTOMMARGIN, 98
END
END
#endif // APSTUDIO_INVOKED
@@ -182,7 +191,7 @@
SS_SUNKEN,7,203,59,19
CONTROL 106,IDC_EMAIL,"Static",SS_BITMAP | SS_NOTIFY,77,204,43,
18
- LTEXT "Static",IDC_L_ABOUT,7,55,177,142
+ LTEXT "Text",IDC_L_ABOUT,7,55,177,142
END
--- a/plugins/cooledit/Faac.cpp
+++ b/plugins/cooledit/Faac.cpp
@@ -1,6 +1,6 @@
/*
FAAC - codec plugin for Cooledit
-Copyright (C) 2002 Antonio Foranna
+Copyright (C) 2002-2004 Antonio Foranna
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,174 +16,25 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author can be contacted at:
-kreel@tiscali.it
+ntnfrn_email-temp@yahoo.it
*/
#include <windows.h>
#include <shellapi.h> // ShellExecute
-#include <stdio.h> // FILE *
-#include <stdlib.h> // malloc, free
+//#include <stdio.h> // FILE *
+//#include <stdlib.h> // malloc, free
#include "resource.h"
#include "filters.h" // CoolEdit
-#include <mp4.h> // int32_t, ...
-#include <faac.h>
-#include <faad.h> // FAAD2 version
-#include <win32_ver.h> // mpeg4ip version
-#include "CRegistry.h"
-#include "Defines.h" // my defines
-#include "Structs.h" // my structs
+#include "Cfaac.h"
// *********************************************************************************************
extern HINSTANCE hInst;
-// -----------------------------------------------------------------------------------------------
-
-extern BOOL DialogMsgProcDecoder(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam);
-extern void ReadCfgDec(MY_DEC_CFG *cfg);
-extern void WriteCfgDec(MY_DEC_CFG *cfg);
-
// *********************************************************************************************
-#ifdef ADTS
-#undef ADTS
-#define ADTS 1
-#endif
-// *********************************************************************************************
-typedef struct output_tag // any special vars associated with output file
-{
-FILE *aacFile;
-long Samprate;
-WORD BitsPerSample;
-WORD Channels;
-//DWORD src_size;
-//char *dst_name; // name of compressed file
-
-faacEncHandle hEncoder;
-int32_t *buffer;
-unsigned char *bitbuf;
-DWORD maxBytesOutput;
-long samplesInput;
-} MYOUTPUT;
-
-
-
-// *********************************************************************************************
-
-
-
-#define SWAP32(x) (((x & 0xff) << 24) | ((x & 0xff00) << 8) \
- | ((x & 0xff0000) >> 8) | ((x & 0xff000000) >> 24))
-#define SWAP16(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8))
-
-inline void To32bit(int32_t *buf, BYTE *bufi, int size, BYTE samplebytes, BYTE bigendian)
-{
-int i;
-
- switch(samplebytes)
- {
- case 1:
- // this is endian clean
- for (i = 0; i < size; i++)
- buf[i] = (bufi[i] - 128) * 65536;
- break;
-
- case 2:
-#ifdef WORDS_BIGENDIAN
- if (!bigendian)
-#else
- if (bigendian)
-#endif
- {
- // swap bytes
- for (i = 0; i < size; i++)
- {
- int16_t s = ((int16_t *)bufi)[i];
-
- s = SWAP16(s);
-
- buf[i] = ((u_int32_t)s) << 8;
- }
- }
- else
- {
- // no swap
- for (i = 0; i < size; i++)
- {
- int s = ((int16_t *)bufi)[i];
-
- buf[i] = s << 8;
- }
- }
- break;
-
- case 3:
- if (!bigendian)
- {
- for (i = 0; i < size; i++)
- {
- int s = bufi[3 * i] | (bufi[3 * i + 1] << 8) | (bufi[3 * i + 2] << 16);
-
- // fix sign
- if (s & 0x800000)
- s |= 0xff000000;
-
- buf[i] = s;
- }
- }
- else // big endian input
- {
- for (i = 0; i < size; i++)
- {
- int s = (bufi[3 * i] << 16) | (bufi[3 * i + 1] << 8) | bufi[3 * i + 2];
-
- // fix sign
- if (s & 0x800000)
- s |= 0xff000000;
-
- buf[i] = s;
- }
- }
- break;
-
- case 4:
-#ifdef WORDS_BIGENDIAN
- if (!bigendian)
-#else
- if (bigendian)
-#endif
- {
- // swap bytes
- for (i = 0; i < size; i++)
- {
- int s = bufi[i];
-
- buf[i] = SWAP32(s);
- }
- }
- else
- memcpy(buf,bufi,size*sizeof(u_int32_t));
- /*
- int exponent, mantissa;
- float *bufo=(float *)buf;
-
- for (i = 0; i < size; i++)
- {
- exponent=bufi[(i<<2)+3]<<1;
- if(bufi[i*4+2] & 0x80)
- exponent|=0x01;
- exponent-=126;
- mantissa=(DWORD)bufi[(i<<2)+2]<<16;
- mantissa|=(DWORD)bufi[(i<<2)+1]<<8;
- mantissa|=bufi[(i<<2)];
- bufo[i]=(float)ldexp(mantissa,exponent);
- }*/
- break;
- }
-}
-// *********************************************************************************************
/*
DWORD PackCfg(MY_ENC_CFG *cfg)
{
@@ -224,52 +75,6 @@
}*/
// -----------------------------------------------------------------------------------------------
-void ReadCfgEnc(MY_ENC_CFG *cfg)
-{
-CRegistry reg;
-
- if(reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAC"))
- {
- cfg->AutoCfg=reg.getSetRegBool("Auto",true);
- cfg->EncCfg.mpegVersion=reg.getSetRegDword("MPEG version",MPEG4);
- 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->UseQuality=reg.getSetRegBool("Use quality",false);
- cfg->EncCfg.quantqual=reg.getSetRegDword("Quality",100);
- cfg->EncCfg.bitRate=reg.getSetRegDword("BitRate",0);
- cfg->EncCfg.bandWidth=reg.getSetRegDword("BandWidth",0);
- cfg->EncCfg.outputFormat=reg.getSetRegDword("Header",ADTS);
- }
- else
- MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
-}
-// -----------------------------------------------------------------------------------------------
-
-void WriteCfgEnc(MY_ENC_CFG *cfg)
-{
-CRegistry reg;
-
- if(reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAC"))
- {
- reg.setRegBool("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.setRegBool("Use quality",cfg->UseQuality);
- reg.setRegDword("Quality",cfg->EncCfg.quantqual);
- reg.setRegDword("BitRate",cfg->EncCfg.bitRate);
- reg.setRegDword("BandWidth",cfg->EncCfg.bandWidth);
- reg.setRegDword("Header",cfg->EncCfg.outputFormat);
- }
- else
- MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
-}
-// -----------------------------------------------------------------------------------------------
-
#define INIT_CB(hWnd,nID,list,IdSelected) \
{ \
for(int i=0; list[i]; i++) \
@@ -301,8 +106,12 @@
EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_ADTS), Enabled); \
EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_ALLOWMIDSIDE), Enabled); \
EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USETNS), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_CB_QUALITY), Enabled); \
EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled); \
EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_QUALITY), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_BITRATE), Enabled); \
EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
@@ -337,8 +146,7 @@
"This program is free software and can be distributed/modifyed under the terms of the GNU General Public License.\n"
"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.\n\n"
"Compiled on %s\n",
- (myFormat->version == FAAC_CFG_VERSION)
- ? myFormat->name : " bad version",
+ (myFormat->version == FAAC_CFG_VERSION) ? myFormat->name : " bad version",
__DATE__
);
SetDlgItemText(hWndDlg, IDC_L_ABOUT, buf);
@@ -349,8 +157,12 @@
switch(LOWORD(wParam))
{
case IDOK:
- EndDialog(hWndDlg, 0);
+ EndDialog(hWndDlg, TRUE);
break;
+ case IDCANCEL:
+ // Ignore data values entered into the controls and dismiss the dialog window returning FALSE
+ EndDialog(hWndDlg, FALSE);
+ break;
case IDC_AUDIOCODING:
ShellExecute(hWndDlg, NULL, "http://www.audiocoding.com", NULL, NULL, SW_SHOW);
break;
@@ -358,7 +170,7 @@
ShellExecute(hWndDlg, NULL, "http://www.mpeg4ip.net", NULL, NULL, SW_SHOW);
break;
case IDC_EMAIL:
- ShellExecute(hWndDlg, NULL, "mailto:kreel@tiscali.it", NULL, NULL, SW_SHOW);
+ ShellExecute(hWndDlg, NULL, "mailto:ntnfrn_email-temp@yahoo.it", NULL, NULL, SW_SHOW);
break;
}
break;
@@ -383,7 +195,7 @@
char *BandWidth[]={"Auto","Full","4000","8000","11025","16000","22050","24000","32000","44100","48000",0};
MY_ENC_CFG cfg;
- ReadCfgEnc(&cfg);
+ Cfaac::getFaacCfg(&cfg);
INIT_CB(hWndDlg,IDC_CB_QUALITY,Quality,0);
INIT_CB(hWndDlg,IDC_CB_BITRATE,BitRate,0);
@@ -468,8 +280,9 @@
break;
}
- CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, cfg.AutoCfg);
+ CheckDlgButton(hWndDlg, IDC_CHK_WRITEMP4, cfg.SaveMP4);
+ CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, cfg.AutoCfg);
DISABLE_CTRL(!cfg.AutoCfg);
}
break; // End of WM_INITDIALOG
@@ -541,8 +354,10 @@
}
cfg.EncCfg.outputFormat=IsDlgButtonChecked(hWndDlg,IDC_RADIO_RAW) ? RAW : ADTS;
- WriteCfgEnc(&cfg);
+ cfg.SaveMP4=IsDlgButtonChecked(hWndDlg, IDC_CHK_WRITEMP4) ? TRUE : FALSE;
+ Cfaac::setFaacCfg(&cfg);
+
EndDialog(hWndDlg, 1);
}
break;
@@ -581,7 +396,11 @@
#define ERROR_FGO(msg) \
{ \
if(msg) \
- MessageBox(hWnd, msg, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
+ { \
+ char buf[100]; \
+ sprintf(buf,"FilterGetOptions: %s", msg); \
+ MessageBox(0, buf, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
+ } \
return 0; \
}
// -----------------------------------------------------------------------------------------------
@@ -588,11 +407,11 @@
DWORD FAR PASCAL FilterGetOptions(HWND hWnd, HINSTANCE hInst, long lSamprate, WORD wChannels, WORD wBitsPerSample, DWORD dwOptions)
{
-CRegistry reg;
long retVal;
+/*CRegistry reg;
BOOL OpenDialog=FALSE;
-/* if(!reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAD"))
+ if(!reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAD"))
ERROR_FGO("Can't open registry!")
else
if(OpenDialog=reg.getSetRegBool("OpenDialog",FALSE))
@@ -638,7 +457,7 @@
void FAR PASCAL GetSuggestedSampleType(LONG *lplSamprate, WORD *lpwBitsPerSample, WORD *wChannels)
{
*lplSamprate=0; // don't care
- *lpwBitsPerSample= *lpwBitsPerSample<=16 ? 0: 16;
+ *lpwBitsPerSample= *lpwBitsPerSample<=16 ? 0 : 16;
*wChannels= *wChannels<49 ? 0 : 48;
}
// *********************************************************************************************
@@ -648,177 +467,37 @@
if(!hOutput)
return;
-MYOUTPUT *mo;
-
- GLOBALLOCK(mo,hOutput,MYOUTPUT,return);
-
- if(mo->aacFile)
- {
- fclose(mo->aacFile);
- mo->aacFile=0;
- }
-
- if(mo->hEncoder)
- faacEncClose(mo->hEncoder);
-
- FREE(mo->bitbuf)
- FREE(mo->buffer)
-
-// FREE(mi->dst_name);
-
- GlobalUnlock(hOutput);
- GlobalFree(hOutput);
+Cfaac tmp(hOutput); // this line frees memory
}
// *********************************************************************************************
-#define ERROR_OFO(msg) \
-{ \
- if(msg) \
- MessageBox(0, msg, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
- if(hOutput) \
- { \
- GlobalUnlock(hOutput); \
- CloseFilterOutput(hOutput); \
- } \
- return 0; \
-}
-// -----------------------------------------------------------------------------------------------
-
HANDLE FAR PASCAL OpenFilterOutput(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long lSize, long far *lpChunkSize, DWORD dwOptions)
{
-HANDLE hOutput;
-MYOUTPUT *mo;
-MY_ENC_CFG cfg;
-DWORD samplesInput,
- maxBytesOutput;
+HANDLE hOutput;
+Cfaac tmp;
-// if(wBitsPerSample!=8 && wBitsPerSample!=16) // 32 bit audio from cooledit is in unsupported format
-// return 0;
- if(wChannels>=49) // FAAC supports max 48 tracks!
- return 0;
-
- if(!(hOutput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(MYOUTPUT))))
- ERROR_OFO("Memory allocation error: hOutput");
- if(!(mo=(MYOUTPUT *)GlobalLock(hOutput)))
- ERROR_OFO("GlobalLock(hOutput)");
-
- // open the aac output file
- if(!(mo->aacFile=fopen(lpstrFilename, "wb")))
- ERROR_OFO("Can't create file");
-
- // use bufferized stream
- setvbuf(mo->aacFile,NULL,_IOFBF,32767);
-
- // open the encoder library
- if(!(mo->hEncoder=faacEncOpen(lSamprate, wChannels, &samplesInput, &maxBytesOutput)))
- ERROR_OFO("Can't open library");
-
- if(!(mo->bitbuf=(unsigned char *)malloc(maxBytesOutput*sizeof(unsigned char))))
- ERROR_OFO("Memory allocation error: output buffer");
-
- if(!(mo->buffer=(int32_t *)malloc(samplesInput*sizeof(int32_t))))
- ERROR_OFO("Memory allocation error: input buffer");
-
- ReadCfgEnc(&cfg);
- if(!cfg.AutoCfg)
+ if(hOutput=tmp.Init(lpstrFilename,lSamprate,wBitsPerSample,wChannels,lSize))
{
- faacEncConfigurationPtr myFormat=&cfg.EncCfg;
- faacEncConfigurationPtr CurFormat=faacEncGetCurrentConfiguration(mo->hEncoder);
+ MYOUTPUT *mo;
+ GLOBALLOCK(mo,hOutput,MYOUTPUT,return NULL);
+ *lpChunkSize=mo->samplesInput*(wBitsPerSample>>3); // size of samplesInput
- if(cfg.UseQuality)
- {
- myFormat->quantqual=cfg.EncCfg.quantqual;
- myFormat->bitRate=CurFormat->bitRate;
- }
- else
- if(!myFormat->bitRate)
- myFormat->bitRate=CurFormat->bitRate;
- else
- myFormat->bitRate*=1000;
-
- switch(myFormat->bandWidth)
- {
- case 0:
- myFormat->bandWidth=CurFormat->bandWidth;
- break;
- case 0xffffffff:
- myFormat->bandWidth=lSamprate/2;
- break;
- default: break;
- }
-
- if(!faacEncSetConfiguration(mo->hEncoder, myFormat))
- ERROR_OFO("Unsupported parameters");
+ GlobalUnlock(hOutput);
+ tmp.hOutput=NULL;
}
- *lpChunkSize=samplesInput*(wBitsPerSample>>3);
-
-// mo->src_size=lSize;
- mo->Samprate=lSamprate;
- mo->BitsPerSample=wBitsPerSample;
- mo->Channels=wChannels;
- mo->samplesInput=samplesInput;
- mo->maxBytesOutput=maxBytesOutput;
-// mi->dst_name=strdup(lpstrFilename);
-
- // init flushing process
-int bytesEncoded, tmp;
-
- bytesEncoded=faacEncEncode(mo->hEncoder, 0, 0, mo->bitbuf, maxBytesOutput); // initializes the flushing process
- if(bytesEncoded>0)
- {
- tmp=fwrite(mo->bitbuf, 1, bytesEncoded, mo->aacFile);
- if(tmp!=bytesEncoded)
- ERROR_OFO("fwrite()");
- }
-
- GlobalUnlock(hOutput);
-
- return hOutput;
+ return hOutput;
}
// *********************************************************************************************
-#define ERROR_WFO(msg) \
-{ \
- if(msg) \
- MessageBox(0, msg, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
- if(hOutput) \
- GlobalUnlock(hOutput); \
- return 0; \
-}
-// -----------------------------------------------------------------------------------------------
-
DWORD FAR PASCAL WriteFilterOutput(HANDLE hOutput, unsigned char far *bufIn, long lBytes)
{
if(!hOutput)
return 0;
-int bytesWritten;
-int bytesEncoded;
-MYOUTPUT far *mo;
+Cfaac tmp;
+DWORD bytesWritten;
- GLOBALLOCK(mo,hOutput,MYOUTPUT,return 0);
-
-int32_t *buf=mo->buffer;
-
- To32bit(buf,bufIn,mo->samplesInput,mo->BitsPerSample>>3,false);
-
- // call the actual encoding routine
- bytesEncoded=faacEncEncode(mo->hEncoder, (int32_t *)buf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
- if(bytesEncoded>0)
- {
- // write bitstream to aac file
- bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->aacFile);
- if(bytesWritten!=bytesEncoded)
- ERROR_WFO("bytesWritten and bytesEncoded are different");
- }
- else
- {
- if(bytesEncoded<0)
- ERROR_WFO("faacEncEncode()");
- bytesWritten=lBytes ? 1 : 0; // bytesWritten==0 stops CoolEdit
- }
-
- GlobalUnlock(hOutput);
- return bytesWritten;
+ bytesWritten=tmp.processData(hOutput,bufIn,lBytes);
+ return bytesWritten ? bytesWritten : 0x7fffffff; // bytesWritten<=0 stops CoolEdit
}
--- a/plugins/cooledit/Faad.cpp
+++ b/plugins/cooledit/Faad.cpp
@@ -1,6 +1,6 @@
/*
FAAC - codec plugin for Cooledit
-Copyright (C) 2002 Antonio Foranna
+Copyright (C) 2002-2004 Antonio Foranna
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author can be contacted at:
-kreel@tiscali.it
+ntnfrn_email-temp@yahoo.it
*/
#include <windows.h>
@@ -23,15 +23,9 @@
#include <stdio.h> // FILE *
#include "resource.h"
#include "filters.h" // CoolEdit
-#include <mp4.h>
-#include <faac.h>
-#include <faad.h>
-extern "C" {
-#include <aacinfo.h> // get_AAC_format()
-}
#include "CRegistry.h"
#include "Defines.h" // my defines
-#include "Structs.h" // my structs
+#include "Cfaad.h"
// *********************************************************************************************
@@ -43,45 +37,6 @@
// *********************************************************************************************
-#define MAX_CHANNELS 2
-#define FAAD_STREAMSIZE (FAAD_MIN_STREAMSIZE*MAX_CHANNELS)
-
-// *********************************************************************************************
-
-typedef struct input_tag // any special vars associated with input file
-{
-//MP4
-MP4FileHandle mp4File;
-MP4SampleId sampleId,
- numSamples;
-int track;
-BYTE type;
-
-//AAC
-FILE *aacFile;
-DWORD src_size; // size of compressed file
-DWORD tagsize;
-DWORD bytes_read; // from file
-DWORD bytes_consumed; // from buffer by faadDecDecode
-long bytes_into_buffer;
-unsigned char *buffer;
-
-// Raw AAC
-DWORD bytesconsumed; // to decode current frame by faadDecDecode
-
-// GLOBAL
-faacDecHandle hDecoder;
-faadAACInfo file_info;
-DWORD len_ms; // length of file in milliseconds
-WORD Channels;
-DWORD Samprate;
-WORD BitsPerSample;
-DWORD dst_size; // size of decoded file. Cooledit needs it to update its progress bar
-//char *src_name; // name of compressed file
-bool IsAAC;
-} MYINPUT;
-// -----------------------------------------------------------------------------------------------
-
static const char* mpeg4AudioNames[]=
{
"Raw PCM",
@@ -89,7 +44,7 @@
"AAC LC (Low Complexity)",
"AAC SSR",
"AAC LTP (Long Term Prediction)",
- "Reserved",
+ "AAC HE (High Efficiency)",
"AAC Scalable",
"TwinVQ",
"CELP",
@@ -121,92 +76,6 @@
// *********************************************************************************************
-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;
- }
- return 0;
-}
-// *********************************************************************************************
-
-int GetAACTrack(MP4FileHandle infile)
-{
-// find AAC track
-int i, rc;
-int numTracks = MP4GetNumberOfTracks(infile, NULL, 0);
-
- for (i = 0; i < numTracks; i++)
- {
- MP4TrackId trackId = MP4FindTrackId(infile, i, NULL, 0);
- const char* trackType = MP4GetTrackType(infile, trackId);
-
- if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE))
- {
- unsigned char *buff = NULL;
- unsigned __int32 buff_size = 0;
- mp4AudioSpecificConfig mp4ASC;
-
- MP4GetTrackESConfiguration(infile, trackId, (unsigned __int8 **)&buff, &buff_size);
-
- if (buff)
- {
- rc = AudioSpecificConfig(buff, buff_size, &mp4ASC);
- free(buff);
-
- if (rc < 0)
- return -1;
- return trackId;
- }
- }
- }
-
- // can't decode this
- return -1;
-}
-// *********************************************************************************************
-
-void ReadCfgDec(MY_DEC_CFG *cfg)
-{
-CRegistry reg;
-
- if(reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAD"))
- {
- cfg->DefaultCfg=reg.getSetRegBool("Default",true);
- cfg->DecCfg.defObjectType=reg.getSetRegByte("Profile",LOW);
- cfg->DecCfg.defSampleRate=reg.getSetRegDword("SampleRate",44100);
- cfg->DecCfg.outputFormat=reg.getSetRegByte("Bps",FAAD_FMT_16BIT);
-// cfg->Channels=reg.getSetRegByte("Channels",2);
- }
- else
- MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
-}
-// -----------------------------------------------------------------------------------------------
-
-void WriteCfgDec(MY_DEC_CFG *cfg)
-{
-CRegistry reg;
-
- if(reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAD"))
- {
- reg.setRegBool("Default",cfg->DefaultCfg);
- reg.setRegByte("Profile",cfg->DecCfg.defObjectType);
- reg.setRegDword("SampleRate",cfg->DecCfg.defSampleRate);
- reg.setRegByte("Bps",cfg->DecCfg.outputFormat);
-// reg.setRegByte("Channels",cfg->Channels);
- }
- else
- MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
-}
-// -----------------------------------------------------------------------------------------------
-
#define INIT_CB(hWnd,nID,list,IdSelected) \
{ \
for(int i=0; list[i]; i++) \
@@ -218,10 +87,13 @@
// EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
#define DISABLE_CTRL(Enabled) \
{ \
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
- EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
- EnableWindow(GetDlgItem(hWndDlg, IDC_CB_SAMPLERATE), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_HE), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_DOWNMATRIX), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_OLDADTS), Enabled); \
+ EnableWindow(GetDlgItem(hWndDlg, IDC_CB_SAMPLERATE), Enabled); \
}
// -----------------------------------------------------------------------------------------------
@@ -253,7 +125,7 @@
case MAIN:
CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
break;
- case LOW:
+ case LC:
CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
break;
case SSR:
@@ -262,8 +134,14 @@
case LTP:
CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
break;
+ case HE_AAC:
+ CheckDlgButton(hWndDlg,IDC_RADIO_HE,TRUE);
+ break;
}
+ CheckDlgButton(hWndDlg,IDC_CHK_DOWNMATRIX, CfgDecoder->DefaultCfg);
+ CheckDlgButton(hWndDlg,IDC_CHK_OLDADTS, CfgDecoder->DefaultCfg);
+
CheckDlgButton(hWndDlg,IDC_CHK_DEFAULTCFG, CfgDecoder->DefaultCfg);
DISABLE_CTRL(!CfgDecoder->DefaultCfg);
}
@@ -289,15 +167,19 @@
if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
CfgDecoder->DecCfg.defObjectType=MAIN;
if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
- CfgDecoder->DecCfg.defObjectType=LOW;
+ CfgDecoder->DecCfg.defObjectType=LC;
if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
CfgDecoder->DecCfg.defObjectType=SSR;
if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
CfgDecoder->DecCfg.defObjectType=LTP;
+ if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_HE))
+ CfgDecoder->DecCfg.defObjectType=HE_AAC;
CfgDecoder->DecCfg.defSampleRate=GetDlgItemInt(hWndDlg, IDC_CB_SAMPLERATE, 0, FALSE);
CfgDecoder->DefaultCfg=IsDlgButtonChecked(hWndDlg,IDC_CHK_DEFAULTCFG) ? TRUE : FALSE;
- WriteCfgDec(CfgDecoder);
+ CfgDecoder->DecCfg.downMatrix=IsDlgButtonChecked(hWndDlg,IDC_CHK_DOWNMATRIX) ? TRUE : FALSE;
+ CfgDecoder->DecCfg.useOldADTSFormat=IsDlgButtonChecked(hWndDlg,IDC_CHK_OLDADTS) ? TRUE : FALSE;
+ Cfaad::WriteCfgDec(CfgDecoder);
EndDialog(hWndDlg, (DWORD)CfgDecoder);
}
@@ -366,14 +248,17 @@
GLOBALLOCK(mi,hInput,MYINPUT,return 0);
- sprintf(szString,"MPEG%d - %lu bps\n", mi->file_info.version, mi->file_info.bitrate);
+ sprintf(szString,"MPEG%d - %lu bps\n", mi->file_info.version ? 4 : 2, mi->file_info.bitrate);
- if(mi->IsAAC) // AAC file --------------------------------------------------------------------
+ if(mi->IsMP4) // MP4 file --------------------------------------------------------------------
+ lstrcat(szString,mpeg4AudioNames[mi->type]);
+ else // AAC file -----------------------------------------------------------------------------
{
switch(mi->file_info.headertype)
{
case RAW:
- lstrcpy(szString,"AAC\nRaw");
+ sprintf(szString,"MPEG%d\nRaw\n", mi->file_info.version ? 4 : 2);
+ lstrcat(szString,mpeg4AudioNames[mi->file_info.object_type]);
GlobalUnlock(hInput);
return 1;//0; // call FilterGetOptions()
case ADIF:
@@ -384,12 +269,13 @@
break;
}
- switch(mi->file_info.object_type)
+ lstrcat(szString,mpeg4AudioNames[mi->file_info.object_type]);
+/* switch(mi->file_info.object_type)
{
case MAIN:
lstrcat(szString,"Main");
break;
- case LOW:
+ case LC:
lstrcat(szString,"LC (Low Complexity)");
break;
case SSR:
@@ -398,10 +284,11 @@
case LTP:
lstrcat(szString,"LTP (Long Term Prediction)");
break;
- }
+ case HE_AAC:
+ lstrcat(szString,"HE (High Efficiency)");
+ break;
+ }*/
}
- else // MP4 file -----------------------------------------------------------------------------
- lstrcat(szString,mpeg4AudioNames[mi->type]);
GlobalUnlock(hInput);
return 1; // don't call FilterGetOptions()
@@ -428,12 +315,7 @@
if(!hInput)
return;
-MYINPUT *mi;
-
- GLOBALLOCK(mi,hInput,MYINPUT,return);
-
-// Raw AAC file ----------------------------------------------------------------------------------
- if(mi->file_info.headertype==RAW)
+/* if(mi->file_info.headertype==RAW)
{
CRegistry reg;
@@ -441,26 +323,9 @@
reg.setRegBool("OpenDialog",FALSE);
else
MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
- }
+ }*/
-// AAC file --------------------------------------------------------------------------------------
- if(mi->aacFile)
- fclose(mi->aacFile);
-
- FREE(mi->buffer);
-
-// MP4 file --------------------------------------------------------------------------------------
- if(mi->mp4File)
- MP4Close(mi->mp4File);
-
- if(mi->hDecoder)
- faacDecClose(mi->hDecoder);
-
-// GLOBAL ----------------------------------------------------------------------------------------
-// FREE(mi->src_name);
-
- GlobalUnlock(hInput);
- GlobalFree(hInput);
+Cfaad tmp(hInput);
}
// *********************************************************************************************
@@ -477,364 +342,36 @@
}
// -----------------------------------------------------------------------------------------------
-extern DWORD FAR PASCAL ReadFilterInput(HANDLE hInput, unsigned char far *bufout, long lBytes);
// return handle that will be passed in to close, and write routines
HANDLE FAR PASCAL OpenFilterInput(LPSTR lpstrFilename, long far *lSamprate, WORD far *wBitsPerSample, WORD far *wChannels, HWND hWnd, long far *lChunkSize)
{
-HANDLE hInput;
-MYINPUT *mi;
-faacDecConfigurationPtr config;
-DWORD samplerate;
-BYTE channels,
- BitsPerSample=16;
-DWORD Bitrate4RawAAC=0;
-BYTE Channels4RawAAC=0;
+HANDLE hInput;
+Cfaad tmp;
-start_point:
-
- if(!(hInput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE|GMEM_ZEROINIT,sizeof(MYINPUT))))
- ERROR_OFI("Memory allocation error: hInput");
- if(!(mi=(MYINPUT *)GlobalLock(hInput)))
- ERROR_OFI("GlobalLock(hInput)");
-
- mi->IsAAC=strcmpi(lpstrFilename+lstrlen(lpstrFilename)-4,".aac")==0;
-
- if(!mi->IsAAC) // MP4 file ---------------------------------------------------------------------
+ if(hInput=tmp.getInfos(lpstrFilename))
{
- MP4Duration length;
- int track;
- unsigned __int32 buffer_size;
- DWORD timeScale;
- BYTE sf;
- mp4AudioSpecificConfig mp4ASC;
+ MYINPUT *mi;
+ GLOBALLOCK(mi,hInput,MYINPUT,return NULL);
+
+ if(mi->file_info.headertype!=RAW || mi->IsMP4) // to show dialog asking for samplerate
+ *lSamprate=mi->Samprate;
+ *wBitsPerSample=mi->BitsPerSample;
+ *wChannels=(WORD)mi->Channels;
+ *lChunkSize=(*wBitsPerSample/8)*1024**wChannels*2;
- if(!(mi->mp4File=MP4Read(lpstrFilename, 0)))
- ERROR_OFI("Error opening file");
-
- if ((track=GetAACTrack(mi->mp4File))<0)
- ERROR_OFI(0); //"Unable to find correct AAC sound track");
-
- if(!(mi->hDecoder=faacDecOpen()))
- ERROR_OFI("Error initializing decoder library");
-
- MP4GetTrackESConfiguration(mi->mp4File, track, (unsigned __int8 **)&mi->buffer, &buffer_size);
- if(!mi->buffer)
- ERROR_OFI("MP4GetTrackESConfiguration");
- AudioSpecificConfig(mi->buffer, buffer_size, &mp4ASC);
-
- timeScale = mp4ASC.samplingFrequency;
- channels = mp4ASC.channelsConfiguration;
- sf = mp4ASC.samplingFrequencyIndex;
- mi->type = mp4ASC.objectTypeIndex;
-
- if(faacDecInit2(mi->hDecoder, mi->buffer, buffer_size, &samplerate, &channels) < 0)
- ERROR_OFI("Error initializing decoder library");
- FREE(mi->buffer);
-
- length=MP4GetTrackDuration(mi->mp4File, track);
- mi->len_ms=(DWORD)MP4ConvertFromTrackDuration(mi->mp4File, track, length, MP4_MSECS_TIME_SCALE);
- mi->file_info.bitrate=MP4GetTrackBitRate(mi->mp4File, track);
- mi->file_info.version=MP4GetTrackAudioType(mi->mp4File, track)==MP4_MPEG4_AUDIO_TYPE ? 4 : 2;
- mi->numSamples=MP4GetTrackNumberOfSamples(mi->mp4File, track);
- mi->track=track;
- mi->sampleId=1;
+ GlobalUnlock(hInput);
+ tmp.hInput=NULL;
}
- else // AAC file ------------------------------------------------------------------------------
- {
- DWORD read;
- DWORD *seek_table=0;
- int seek_table_length=0;
- long tagsize;
- DWORD tmp;
-
- if(!(mi->aacFile=fopen(lpstrFilename,"rb")))
- ERROR_OFI("Error opening file");
-
- // use bufferized stream
- setvbuf(mi->aacFile,NULL,_IOFBF,32767);
-
- // get size of file
- fseek(mi->aacFile, 0, SEEK_END);
- mi->src_size=ftell(mi->aacFile);
- fseek(mi->aacFile, 0, SEEK_SET);
-
- if(!(mi->buffer=(BYTE *)malloc(FAAD_STREAMSIZE)))
- ERROR_OFI("Memory allocation error");
- memset(mi->buffer,0,FAAD_STREAMSIZE);
-
- tmp=mi->src_size<FAAD_STREAMSIZE ? mi->src_size : FAAD_STREAMSIZE;
- read=fread(mi->buffer, 1, tmp, mi->aacFile);
- if(read==tmp)
- {
- mi->bytes_read=read;
- mi->bytes_into_buffer=read;
- }
- else
- ERROR_OFI("fread");
-
- if(tagsize=id3v2_tag(mi->buffer))
- {
- if(tagsize>(long)mi->src_size)
- ERROR_OFI("Corrupt stream!");
- if(tagsize<mi->bytes_into_buffer)
- {
- mi->bytes_into_buffer-=tagsize;
- memcpy(mi->buffer,mi->buffer+tagsize,mi->bytes_into_buffer);
- }
- else
- {
- mi->bytes_read=tagsize;
- mi->bytes_into_buffer=0;
- if(tagsize>mi->bytes_into_buffer)
- fseek(mi->aacFile, tagsize, SEEK_SET);
- }
- if(mi->src_size<mi->bytes_read+FAAD_STREAMSIZE-mi->bytes_into_buffer)
- tmp=mi->src_size-mi->bytes_read;
- else
- tmp=FAAD_STREAMSIZE-mi->bytes_into_buffer;
- read=fread(mi->buffer+mi->bytes_into_buffer, 1, tmp, mi->aacFile);
- if(read==tmp)
- {
- mi->bytes_read+=read;
- mi->bytes_into_buffer+=read;
- }
- else
- ERROR_OFI("fread");
-
- mi->tagsize=tagsize;
- }
-
- if(get_AAC_format(lpstrFilename, &mi->file_info, &seek_table, &seek_table_length, 0))
- {
- FREE(seek_table);
- ERROR_OFI("Error retrieving information from input file");
- }
- FREE(seek_table);
-
- if(!(mi->hDecoder=faacDecOpen()))
- ERROR_OFI("Can't open library");
-
- if(mi->file_info.headertype==RAW)
- if(!*lSamprate || !*wBitsPerSample || !*wChannels)
- {
-/* CRegistry reg;
-
- if(reg.openCreateReg(HKEY_LOCAL_MACHINE,REGISTRY_PROGRAM_NAME "\\FAAD"))
- reg.setRegBool("OpenDialog",TRUE);
- else
- ERROR_OFI("Can't open registry!");*/
-
-// CoolEdit ask for format if the following code isn't activated
- *lSamprate=44100;
- *wBitsPerSample=16;
- *wChannels=2;
-
- GlobalUnlock(hInput);
- return hInput;
- }
- else
- {
- MY_DEC_CFG Cfg;
-
- ReadCfgDec(&Cfg);
- if(!Bitrate4RawAAC)
- DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_DECODER),(HWND)hWnd, (DLGPROC)DialogMsgProcDecoder, (DWORD)&Cfg);
- config=faacDecGetCurrentConfiguration(mi->hDecoder);
- if(Cfg.DefaultCfg)
- {
- config->defObjectType=mi->file_info.object_type;
- config->defSampleRate=mi->file_info.sampling_rate;//*lSamprate; // doesn't work!
- }
- else
- {
- config->defObjectType=Cfg.DecCfg.defObjectType;
- config->defSampleRate=Cfg.DecCfg.defSampleRate;
- }
- config->outputFormat=FAAD_FMT_16BIT;
- faacDecSetConfiguration(mi->hDecoder, config);
-
- if(Bitrate4RawAAC)
- mi->file_info.bitrate=Bitrate4RawAAC*Channels4RawAAC;
- else
- {
- DWORD Samples,
- BytesConsumed;
-
- if((mi->bytes_consumed=faacDecInit(mi->hDecoder, mi->buffer, mi->bytes_into_buffer, &samplerate, &channels)) < 0)
- ERROR_OFI("Can't init library");
- mi->bytes_into_buffer-=mi->bytes_consumed;
- if(!(Samples=ReadFilterInput(hInput,0,0)/sizeof(short)))
- ERROR_OFI(0);
- BytesConsumed=mi->bytesconsumed;
- ReadFilterInput(hInput,0,0);
- if(BytesConsumed>mi->bytesconsumed)
- mi->bytesconsumed=BytesConsumed;
- Bitrate4RawAAC=(mi->bytesconsumed*8*Cfg.DecCfg.defSampleRate)/Samples;
- if(!Bitrate4RawAAC)
- Bitrate4RawAAC=1000; // try to continue decoding
- Channels4RawAAC=(BYTE)mi->Channels;
- if(!Channels4RawAAC)
- ERROR_OFI("Channels reported by decoder: 0");
-/* if(Channels4RawAAC!=Cfg.Channels)
- {
- char buf[256]="";
- sprintf(buf,"Channels reported by decoder: %d",mi->Channels);
- MessageBox(0,buf,0,MB_OK|MB_ICONWARNING);
- }*/
- GlobalUnlock(hInput);
- CloseFilterInput(hInput);
- goto start_point;
- }
- }
-
- if((mi->bytes_consumed=faacDecInit(mi->hDecoder, mi->buffer, mi->bytes_into_buffer, &samplerate, &channels)) < 0)
- ERROR_OFI("Can't init library");
- mi->bytes_into_buffer-=mi->bytes_consumed;
-
- if(Channels4RawAAC)
- channels=Channels4RawAAC;
-
- mi->len_ms=(DWORD)((1000*((float)mi->src_size*8))/mi->file_info.bitrate);
- } // END AAC file -----------------------------------------------------------------------------
-
- config=faacDecGetCurrentConfiguration(mi->hDecoder);
- switch(config->outputFormat)
- {
- case FAAD_FMT_16BIT:
- BitsPerSample=16;
- break;
- case FAAD_FMT_24BIT:
- BitsPerSample=24;
- break;
- case FAAD_FMT_32BIT:
- BitsPerSample=32;
- break;
- default:
- ERROR_OFI("Invalid Bps");
- }
-
- if(mi->len_ms)
- mi->dst_size=(DWORD)(mi->len_ms*((float)samplerate/1000)*channels*(BitsPerSample/8));
- else
- mi->dst_size=mi->src_size; // corrupt stream?
-
- *lSamprate=samplerate;
- *wBitsPerSample=BitsPerSample;
- *wChannels=(WORD)channels;
- *lChunkSize=(BitsPerSample/8)*1024*channels;
-
- mi->Channels=(WORD)channels;
- mi->Samprate=samplerate;
- mi->BitsPerSample=*wBitsPerSample;
-// mi->src_name=strdup(lpstrFilename);
-
- GlobalUnlock(hInput);
return hInput;
}
// *********************************************************************************************
-#define ERROR_RFI(msg) \
-{ \
- if(msg) \
- MessageBox(0, msg, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
- if(hInput) \
- GlobalUnlock(hInput); \
- return 0; \
-}
-// -----------------------------------------------------------------------------------------------
-
DWORD FAR PASCAL ReadFilterInput(HANDLE hInput, unsigned char far *bufout, long lBytes)
{
if(!hInput)
return 0;
-
-DWORD read,
- tmp,
- BytesDecoded=0;
-unsigned char *buffer=0;
-faacDecFrameInfo frameInfo;
-char *sample_buffer=0;
-MYINPUT *mi;
- GLOBALLOCK(mi,hInput,MYINPUT,return 0);
+Cfaad tmp;
- if(!mi->IsAAC) // MP4 file --------------------------------------------------------------------------
- {
- unsigned __int32 buffer_size=0;
- int rc;
-
- do
- {
- buffer=NULL;
- if(mi->sampleId>=mi->numSamples)
- ERROR_RFI(0);
-
- rc=MP4ReadSample(mi->mp4File, mi->track, mi->sampleId++, (unsigned __int8 **)&buffer, &buffer_size, NULL, NULL, NULL, NULL);
- if(rc==0 || buffer==NULL)
- {
- FREE(buffer);
- ERROR_RFI("MP4ReadSample")
- }
-
- sample_buffer=(char *)faacDecDecode(mi->hDecoder,&frameInfo,buffer,buffer_size);
- BytesDecoded=frameInfo.samples*sizeof(short);
- memcpy(bufout,sample_buffer,BytesDecoded);
- FREE(buffer);
- }while(!BytesDecoded && !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->src_size)
- {
- if(mi->bytes_read+mi->bytes_consumed<mi->src_size)
- tmp=mi->bytes_consumed;
- else
- tmp=mi->src_size-mi->bytes_read;
- read=fread(buffer+mi->bytes_into_buffer, 1, tmp, mi->aacFile);
- 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->src_size)
- ERROR_RFI("ReadFilterInput: buffer empty!")
- else
- ERROR_RFI(0)
-
- sample_buffer=(char *)faacDecDecode(mi->hDecoder,&frameInfo,buffer,mi->bytes_into_buffer);
- BytesDecoded=frameInfo.samples*sizeof(short);
- if(bufout)
- memcpy(bufout,sample_buffer,BytesDecoded);
- else // Data needed to decode Raw files
- {
- mi->bytesconsumed=frameInfo.bytesconsumed;
- mi->Channels=frameInfo.channels;
- }
- mi->bytes_consumed+=frameInfo.bytesconsumed;
- mi->bytes_into_buffer-=mi->bytes_consumed;
- }while(!BytesDecoded && !frameInfo.error);
- } // END AAC file --------------------------------------------------------------------------
-
- if(frameInfo.error)
- ERROR_RFI((char *)faacDecGetErrorMessage(frameInfo.error));
-
- GlobalUnlock(hInput);
- return BytesDecoded;
+ return tmp.processData(hInput,bufout,lBytes);
}
--- a/plugins/cooledit/Main.cpp
+++ b/plugins/cooledit/Main.cpp
@@ -1,6 +1,6 @@
/*
FAAC - codec plugin for Cooledit
-Copyright (C) 2002 Antonio Foranna
+Copyright (C) 2002-2004 Antonio Foranna
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author can be contacted at:
-kreel@tiscali.it
+ntnfrn_email-temp@yahoo.it
*/
#include <windows.h>
@@ -87,7 +87,7 @@
// Fill COOLQUERY structure with information regarding this file filter
short FAR PASCAL QueryCoolFilter(COOLQUERY far * cq)
{
- lstrcpy(cq->szName, APP_NAME " Format");
+ lstrcpy(cq->szName, APP_NAME);
lstrcpy(cq->szCopyright, APP_NAME " codec");
lstrcpy(cq->szExt,"AAC");
lstrcpy(cq->szExt2,"MP4");
--- a/plugins/cooledit/Readme.txt
+++ b/plugins/cooledit/Readme.txt
@@ -1,7 +1,7 @@
+-----------------------------------------------------------------+
| |
-| FAAC Readme |
-| ----------- |
+| Cooledit/Audition plugin |
+| ------------------------ |
| |
+-----------------------------------------------------------------+
@@ -12,17 +12,21 @@
----------------------------------------------------------------------------
-FAAC is a codec plugin for Cooledit
-to import .aac/.mp4 files and to export in AAC format.
+FAAC is a codec plugin for Cooledit/Audition to import and export .aac/.mp4 files.
-To use it:
-----------
+To compile it:
+--------------
1) put FAAC and FAAD2 packages into the same folder;
2) open the project, set "Active Configuration = FAAC - win32 Release" and compile;
3) copy FAAC.flt into CoolEdit folder and delete flt.dat
+To write .mp4 files:
+--------------------
+
+Append .mp4 extension to the name of file in the "Save waveform as" dialog.
+
----------------------------------------------------------------------------
For suggestions, bugs report, etc., you can contact me at
-kreel@tiscali.it
+ntnfrn_email-temp@yahoo.it
--- a/plugins/cooledit/TypeDef.h
+++ b/plugins/cooledit/TypeDef.h
@@ -1,3 +1,24 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2002-2004 Antonio Foranna
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
//---------------------------------------------------------------------------
#ifndef TypeDefH
#define TypeDefH
--- a/plugins/cooledit/aacInfoLib.dsp
+++ b/plugins/cooledit/aacInfoLib.dsp
@@ -25,7 +25,7 @@
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
-CPP=cl.exe
+CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "aacInfoLib - Win32 Release"
@@ -41,6 +41,7 @@
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
MTL=midl.exe
+F90=df.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../../faad2/common/faad" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE RSC /l 0x410 /d "NDEBUG"
@@ -48,7 +49,7 @@
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
-LIB32=link.exe -lib
+LIB32=xilink6.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
@@ -65,14 +66,15 @@
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
MTL=midl.exe
+F90=df.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../faad2/common/faad" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../../faad2/common/faad" /D "_WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD BASE RSC /l 0x410 /d "_DEBUG"
# ADD RSC /l 0x410 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
-LIB32=link.exe -lib
+LIB32=xilink6.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
--- a/plugins/cooledit/defines.h
+++ b/plugins/cooledit/defines.h
@@ -1,10 +1,31 @@
+/*
+FAAC - codec plugin for Cooledit
+Copyright (C) 2002-2004 Antonio Foranna
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+The author can be contacted at:
+ntnfrn_email-temp@yahoo.it
+*/
+
#define APP_NAME "MPEG4-AAC"
-#define APP_VER "v2.1"
+#define APP_VER "v2.2"
#define REGISTRY_PROGRAM_NAME "SOFTWARE\\4N\\CoolEdit\\AAC-MPEG4"
// -----------------------------------------------------------------------------------------------
-#define FREE(ptr) \
+#define FREE_ARRAY(ptr) \
{ \
if(ptr) \
free(ptr); \
--- a/plugins/cooledit/resource.h
+++ b/plugins/cooledit/resource.h
@@ -15,6 +15,7 @@
#define IDC_RADIO_SSR 1004
#define IDC_RADIO_LTP 1005
#define IDC_RADIO_RAW 1006
+#define IDC_RADIO_HE 1006
#define IDC_RADIO_ADTS 1007
#define IDC_CB_BANDWIDTH 1008
#define IDC_CB_BITRATE 1009
@@ -32,6 +33,9 @@
#define IDC_RADIO_BITRATE 1022
#define IDC_RADIO_QUALITY 1023
#define IDC_CB_QUALITY 1024
+#define IDC_CHK_DOWNMATRIX 1025
+#define IDC_CHK_OLDADTS 1026
+#define IDC_CHK_WRITEMP4 1027
// Next default values for new objects
//
@@ -39,7 +43,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1025
+#define _APS_NEXT_CONTROL_VALUE 1028
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
--
⑨