ref: 86439f26b27ba6ae1a06704181a2dec722001a38
parent: 4041be70bf23c172dda3d107e19d84c2fb58f644
author: menno <menno>
date: Sat Mar 16 14:18:11 EST 2002
Added aacDECdrop made by John33 Thanks a lot!
--- /dev/null
+++ b/aacDECdrop/Script.rc
@@ -1,0 +1,157 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_TF01 BITMAP DISCARDABLE "resource/AAC01.bmp"
+IDB_TF02 BITMAP DISCARDABLE "resource/AAC02.bmp"
+IDB_TF03 BITMAP DISCARDABLE "resource/AAC03.bmp"
+IDB_TF04 BITMAP DISCARDABLE "resource/AAC04.bmp"
+IDB_TF05 BITMAP DISCARDABLE "resource/AAC05.bmp"
+IDB_TF06 BITMAP DISCARDABLE "resource/AAC06.bmp"
+IDB_TF07 BITMAP DISCARDABLE "resource/AAC07.bmp"
+IDB_TF08 BITMAP DISCARDABLE "resource/AAC08.bmp"
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_MENU1 MENU DISCARDABLE
+BEGIN
+ POPUP "Menu"
+ BEGIN
+ MENUITEM "&Decoder Options", IDM_VOLUME
+ MENUITEM SEPARATOR
+ MENUITEM "&Errors to Log File", IDM_LOGERR
+ MENUITEM "&Always on Top", IDM_ONTOP
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit\tAlt+F4", IDM_QUIT
+ END
+ MENUITEM SEPARATOR
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON1 ICON DISCARDABLE "resource/AAC01.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_VOLUME DIALOG DISCARDABLE 0, 0, 255, 218
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Decoder Options"
+FONT 8, "MS Sans Serif"
+BEGIN
+ GROUPBOX "Decoding Settings",IDC_STATIC,7,7,241,23
+ CONTROL "Playback",IDC_PLAYBACK,"Button", BS_AUTORADIOBUTTON | WS_GROUP,15,17,55,10
+ CONTROL "Decode to File",IDC_DECODE,"Button", BS_AUTORADIOBUTTON,125,17,65,10
+ GROUPBOX "Output Format Settings",IDC_STATIC,7,31,241,50
+ CONTROL "Microsoft WAV",IDC_WAV,"Button", BS_AUTORADIOBUTTON | WS_GROUP,15,45,65,10
+ CONTROL "Apple/SGI AIFF",IDC_AIFF,"Button", BS_AUTORADIOBUTTON,125,45,65,10
+ CONTROL "Sun/NeXT AU",IDC_SUNAU,"Button", BS_AUTORADIOBUTTON,15,60,65,10
+ CONTROL "DEC AU",IDC_DECAU,"Button", BS_AUTORADIOBUTTON,125,60,65,10
+ GROUPBOX "Output Sample Format Settings",IDC_STATIC,7,82,241,50
+ CONTROL "16 bit PCM",IDC_16BIT,"Button", BS_AUTORADIOBUTTON | WS_GROUP,15,96,65,10
+ CONTROL "24 bit PCM",IDC_24BIT,"Button", BS_AUTORADIOBUTTON,125,96,65,10
+ CONTROL "32 bit PCM",IDC_32BIT,"Button", BS_AUTORADIOBUTTON,15,111,65,10
+ CONTROL "32 bit floats",IDC_FLOATS,"Button", BS_AUTORADIOBUTTON,125,111,65,10
+ GROUPBOX "Object Type Settings",IDC_STATIC,7,133,241,50
+ CONTROL "Main",IDC_MAIN,"Button", BS_AUTORADIOBUTTON | WS_GROUP,15,147,65,10
+ CONTROL "Low Complexity",IDC_LC,"Button", BS_AUTORADIOBUTTON,125,147,65,10
+ CONTROL "Long Term Prediction",IDC_LTP,"Button", BS_AUTORADIOBUTTON,15,162,85,10
+ CONTROL "Low Delay",IDC_LD,"Button", BS_AUTORADIOBUTTON,125,162,65,10
+ DEFPUSHBUTTON "Accept",IDC_BUTTON1,102,192,50,16
+// PUSHBUTTON "Stop",IDC_BUTTON2,172,192,50,16
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ IDD_QUALITY, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 217
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 101
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
--- /dev/null
+++ b/aacDECdrop/aacDECdrop/aacDECdrop.dsp
@@ -1,0 +1,214 @@
+# Microsoft Developer Studio Project File - Name="aacDECdrop" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=aacDECdrop - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "aacDECdrop.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "aacDECdrop.mak" CFG="aacDECdrop - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "aacDECdrop - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "aacDECdrop - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=xicl6.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "aacDECdrop - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /GX /O2 /I "..\..\include" /I "..\..\common\libsndfile\src" /I "..\..\common\mp4v2" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib ws2_32.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"LIBCMT.lib"
+
+!ELSEIF "$(CFG)" == "aacDECdrop - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "aacDECdrop - Win32 Release"
+# Name "aacDECdrop - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\audio.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\decode.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\decthread.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\main.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\misc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\wave_out.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\audio.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\decode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\decthread.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\faad.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\misc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\common\mp4v2\mp4.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\common\mp4v2\mpeg4ip.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\common\libsndfile\src\sndfile.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\common\mp4v2\systems.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\wave_out.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\common\mp4v2\win32_ver.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=..\resource\AAC01.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=..\resource\AAC01.ico
+# End Source File
+# Begin Source File
+
+SOURCE=..\resource\AAC02.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=..\resource\AAC03.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=..\resource\AAC04.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=..\resource\AAC05.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=..\resource\AAC06.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=..\resource\AAC07.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=..\resource\AAC08.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Script.rc
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null
+++ b/aacDECdrop/aacDECdrop/aacDECdrop.dsw
@@ -1,0 +1,74 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "aacDECdrop"=.\aacDECdrop.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name libfaad
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name libsndfile
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name libmp4v2_st
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "libfaad"=..\..\libfaad\libfaad.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "libmp4v2_st"=..\..\common\mp4v2\libmp4v2_st60.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "libsndfile"=..\..\common\libsndfile\Win32\libsndfile.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
--- /dev/null
+++ b/aacDECdrop/audio.c
@@ -1,0 +1,89 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: audio.c,v 1.2 2002/04/14 16:31:02 menno Exp $
+**/
+
+#include <fcntl.h>
+#include <sndfile.h>
+#include <faad.h>
+#include "audio.h"
+
+
+audio_file *open_audio_file(char *infile, int samplerate, int channels,
+ int outputFormat, int fileType)
+{
+ audio_file *aufile = malloc(sizeof(audio_file));
+
+ aufile->outputFormat = outputFormat;
+
+ aufile->sfinfo.samplerate = samplerate;
+ switch (outputFormat)
+ {
+ case FAAD_FMT_16BIT:
+ aufile->sfinfo.pcmbitwidth = 16;
+ aufile->sfinfo.format = ((1<<(fileType+15)) | SF_FORMAT_PCM);
+ break;
+ case FAAD_FMT_24BIT:
+ aufile->sfinfo.pcmbitwidth = 24;
+ aufile->sfinfo.format = ((1<<(fileType+15)) | SF_FORMAT_PCM);
+ break;
+ case FAAD_FMT_32BIT:
+ aufile->sfinfo.pcmbitwidth = 32;
+ aufile->sfinfo.format = ((1<<(fileType+15)) | SF_FORMAT_PCM);
+ break;
+ case FAAD_FMT_FLOAT:
+ aufile->sfinfo.pcmbitwidth = 32;
+ aufile->sfinfo.format = ((1<<(fileType+15)) | SF_FORMAT_FLOAT);
+ break;
+ }
+ aufile->sfinfo.channels = channels;
+ aufile->sfinfo.samples = 0;
+
+ aufile->sndfile = sf_open_write(infile, &aufile->sfinfo);
+
+ if (aufile->sndfile == NULL)
+ {
+ sf_perror(NULL);
+ if (aufile) free(aufile);
+ return NULL;
+ }
+
+ return aufile;
+}
+
+int write_audio_file(audio_file *aufile, void *sample_buffer, int samples)
+{
+ switch (aufile->outputFormat)
+ {
+ case FAAD_FMT_16BIT:
+ return sf_write_short(aufile->sndfile, (short*)sample_buffer, samples);
+ case FAAD_FMT_24BIT:
+ case FAAD_FMT_32BIT:
+ return sf_write_int(aufile->sndfile, (int*)sample_buffer, samples);
+ case FAAD_FMT_FLOAT:
+ return sf_write_float(aufile->sndfile, (float*)sample_buffer, samples);
+ }
+}
+
+void close_audio_file(audio_file *aufile)
+{
+ sf_close(aufile->sndfile);
+
+ if (aufile) free(aufile);
+}
--- /dev/null
+++ b/aacDECdrop/audio.h
@@ -1,0 +1,45 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: audio.h,v 1.2 2002/04/14 16:31:02 menno Exp $
+**/
+
+#ifndef AUDIO_H_INCLUDED
+#define AUDIO_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct
+{
+ int outputFormat;
+ SF_INFO sfinfo;
+ SNDFILE *sndfile;
+} audio_file;
+
+audio_file *open_audio_file(char *infile, int samplerate, int channels,
+ int outputFormat, int fileType);
+int write_audio_file(audio_file *aufile, void *sample_buffer, int samples);
+void close_audio_file(audio_file *aufile);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- /dev/null
+++ b/aacDECdrop/decode.c
@@ -1,0 +1,493 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: decode.c,v 1.1 2002/03/16 19:18:10 menno Exp $
+** $Id: decode.c,v 1.1 2002/03/16 19:18:10 menno Exp $
+**/
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#else
+#include <time.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <faad.h>
+#include <sndfile.h>
+#include <mp4.h>
+
+#include "audio.h"
+#include "decode.h"
+#include "wave_out.h"
+
+#ifndef min
+#define min(a,b) ( (a) < (b) ? (a) : (b) )
+#endif
+
+#define MAX_CHANNELS 6 /* make this higher to support files with
+ more channels */
+
+/* FAAD file buffering routines */
+/* declare buffering variables */
+#define DEC_BUFF_VARS \
+ int fileread, bytesconsumed, k; \
+ int buffercount = 0, buffer_index = 0; \
+ unsigned char *buffer;
+
+/* initialise buffering */
+#define INIT_BUFF(file) \
+ fseek(file, 0, SEEK_END); \
+ fileread = ftell(file); \
+ fseek(file, 0, SEEK_SET); \
+ buffer = (unsigned char*)malloc(FAAD_MIN_STREAMSIZE*MAX_CHANNELS); \
+ memset(buffer, 0, FAAD_MIN_STREAMSIZE*MAX_CHANNELS); \
+ fread(buffer, 1, FAAD_MIN_STREAMSIZE*MAX_CHANNELS, file);
+
+/* skip bytes in buffer */
+#define UPDATE_BUFF_SKIP(bytes) \
+ fseek(infile, bytes, SEEK_SET); \
+ buffer_index += bytes; \
+ buffercount = 0; \
+ fread(buffer, 1, FAAD_MIN_STREAMSIZE*MAX_CHANNELS, infile);
+
+/* update buffer */
+#define UPDATE_BUFF_READ \
+ if (bytesconsumed > 0) { \
+ for (k = 0; k < (FAAD_MIN_STREAMSIZE*MAX_CHANNELS - bytesconsumed); k++) \
+ buffer[k] = buffer[k + bytesconsumed]; \
+ fread(buffer + (FAAD_MIN_STREAMSIZE*MAX_CHANNELS) - bytesconsumed, 1, bytesconsumed, infile); \
+ bytesconsumed = 0; \
+ }
+
+/* update buffer indices after faacDecDecode */
+#define UPDATE_BUFF_IDX(frame) \
+ bytesconsumed += frame.bytesconsumed; \
+ buffer_index += frame.bytesconsumed;
+
+/* true if decoding has to stop because of EOF */
+#define IS_FILE_END buffer_index >= fileread
+
+/* end buffering */
+#define END_BUFF if (buffer) free(buffer);
+
+
+
+/* globals */
+char *progName;
+
+int id3v2_tag(unsigned char *buffer)
+{
+ if (strncmp(buffer, "ID3", 3) == 0) {
+ unsigned long tagsize;
+
+ /* high bit is not used */
+ tagsize = (buffer[6] << 21) | (buffer[7] << 14) |
+ (buffer[8] << 7) | (buffer[9] << 0);
+
+ tagsize += 10;
+
+ return tagsize;
+ } else {
+ return 0;
+ }
+}
+
+char *file_ext[] =
+{
+ NULL,
+ ".wav",
+ ".aif",
+ ".au",
+ ".au",
+ NULL
+};
+
+int decodeAACfile(char *sndfile, int def_srate, aac_dec_opt *opt)
+{
+ int tagsize;
+ unsigned long samplerate;
+ unsigned char channels;
+ void *sample_buffer;
+
+ FILE *infile;
+
+ audio_file *aufile;
+
+ faacDecHandle hDecoder;
+ faacDecFrameInfo frameInfo;
+ faacDecConfigurationPtr config;
+
+ int first_time = 1;
+ int i;
+
+
+ /* declare variables for buffering */
+ DEC_BUFF_VARS
+
+ infile = fopen(opt->filename, "rb");
+ if (infile == NULL)
+ {
+ /* unable to open file */
+ error_handler("Error opening file: %s\n", opt->filename);
+ return 1;
+ }
+ INIT_BUFF(infile)
+
+ tagsize = id3v2_tag(buffer);
+ if (tagsize)
+ {
+ UPDATE_BUFF_SKIP(tagsize)
+ }
+
+ hDecoder = faacDecOpen();
+
+ /* Set the default object type and samplerate */
+ /* This is useful for RAW AAC files */
+ config = faacDecGetCurrentConfiguration(hDecoder);
+ if (def_srate)
+ config->defSampleRate = def_srate;
+ config->defObjectType = opt->object_type;
+ config->outputFormat = opt->output_format;
+
+ faacDecSetConfiguration(hDecoder, config);
+
+ if((bytesconsumed = faacDecInit(hDecoder, buffer, &samplerate, &channels)) < 0)
+ {
+ /* If some error initializing occured, skip the file */
+ error_handler("Error initializing decoder library.\n");
+ END_BUFF
+ faacDecClose(hDecoder);
+ fclose(infile);
+ return 1;
+ }
+ buffer_index += bytesconsumed;
+
+ do
+ {
+ /* update buffer */
+ UPDATE_BUFF_READ
+
+ sample_buffer = faacDecDecode(hDecoder, &frameInfo, buffer);
+
+ /* update buffer indices */
+ UPDATE_BUFF_IDX(frameInfo)
+
+ if (frameInfo.error > 0)
+ {
+ error_handler("Error: %s\n",
+ faacDecGetErrorMessage(frameInfo.error));
+ }
+
+ opt->progress_update((long)fileread, buffer_index);
+
+ /* open the sound file now that the number of channels are known */
+ if (first_time && !frameInfo.error)
+ {
+ if(opt->decode_mode == 0)
+ {
+ if (Set_WIN_Params (INVALID_FILEDESC, samplerate, SAMPLE_SIZE,
+ frameInfo.channels) < 0)
+ {
+ error_handler("\nCan't access %s\n", "WAVE OUT");
+ END_BUFF
+ faacDecClose(hDecoder);
+ fclose(infile);
+ return (0);
+ }
+ }
+ else
+ {
+ aufile = open_audio_file(sndfile, samplerate, frameInfo.channels,
+ opt->output_format, opt->file_type);
+
+ if (aufile == NULL)
+ {
+ END_BUFF
+ faacDecClose(hDecoder);
+ fclose(infile);
+ return 0;
+ }
+ }
+ first_time = 0;
+ }
+
+ if ((frameInfo.error == 0) && (frameInfo.samples > 0))
+ {
+ if(opt->decode_mode == 0)
+ WIN_Play_Samples((short*)sample_buffer, frameInfo.channels*frameInfo.samples);
+ else
+ write_audio_file(aufile, sample_buffer, frameInfo.samples);
+ }
+
+ if (buffer_index >= fileread)
+ sample_buffer = NULL; /* to make sure it stops now */
+
+ } while (sample_buffer != NULL);
+
+ faacDecClose(hDecoder);
+
+ fclose(infile);
+
+ if(opt->decode_mode == 0)
+ WIN_Audio_close();
+ else
+ {
+ if (!first_time)
+ close_audio_file(aufile);
+ }
+
+ END_BUFF
+
+ return frameInfo.error;
+}
+
+int GetAACTrack(MP4FileHandle infile)
+{
+ /* find AAC track */
+ int i, rc;
+ int numTracks = MP4GetNumberOfTracks(infile, NULL, /* subType */ 0);
+
+ for (i = 0; i < numTracks; i++)
+ {
+ MP4TrackId trackId = MP4FindTrackId(infile, i, NULL, /* subType */ 0);
+ const char* trackType = MP4GetTrackType(infile, trackId);
+
+ if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE))
+ {
+ unsigned char *buff = NULL;
+ int buff_size = 0;
+ unsigned long dummy32; unsigned char dummy8;
+ MP4GetTrackESConfiguration(infile, trackId, &buff, &buff_size);
+
+ if (buff)
+ {
+ rc = AudioSpecificConfig(buff, &dummy32, &dummy8, &dummy8, &dummy8);
+ free(buff);
+
+ if (rc < 0)
+ return -1;
+ return trackId;
+ }
+ }
+ }
+
+ /* can't decode this */
+ return -1;
+}
+
+unsigned long srates[] =
+{
+ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000,
+ 12000, 11025, 8000
+};
+
+int decodeMP4file(char *sndfile, aac_dec_opt *opt)
+{
+ int track;
+ unsigned long samplerate;
+ unsigned char channels;
+ void *sample_buffer;
+
+ MP4FileHandle infile;
+ MP4SampleId sampleId, numSamples;
+
+ audio_file *aufile;
+
+ faacDecHandle hDecoder;
+ faacDecConfigurationPtr config;
+ faacDecFrameInfo frameInfo;
+
+ unsigned char *buffer;
+ int buffer_size;
+
+ int first_time = 1;
+
+ hDecoder = faacDecOpen();
+
+ infile = MP4Read(opt->filename, 0);
+ if (!infile)
+ {
+ /* unable to open file */
+ error_handler("Error opening file: %s\n", opt->filename);
+ return 1;
+ }
+
+ if ((track = GetAACTrack(infile)) < 0)
+ {
+ error_handler("Unable to find correct AAC sound track in the MP4 file.\n");
+ MP4Close(infile);
+ return 1;
+ }
+
+ buffer = NULL;
+ buffer_size = 0;
+ MP4GetTrackESConfiguration(infile, track, &buffer, &buffer_size);
+
+ if(faacDecInit2(hDecoder, buffer, buffer_size, &samplerate, &channels) < 0)
+ {
+ /* If some error initializing occured, skip the file */
+ error_handler("Error initializing decoder library.\n");
+ faacDecClose(hDecoder);
+ MP4Close(infile);
+ return 1;
+ }
+ if (buffer)
+ free(buffer);
+
+ numSamples = MP4GetTrackNumberOfSamples(infile, track);
+
+ for (sampleId = 1; sampleId <= numSamples; sampleId++)
+ {
+ int rc;
+
+ /* get access unit from MP4 file */
+ buffer = NULL;
+ buffer_size = 0;
+
+ rc = MP4ReadSample(infile, track, sampleId, &buffer, &buffer_size, NULL, NULL, NULL, NULL);
+ if (rc == 0)
+ {
+ error_handler("Reading from MP4 file failed.\n");
+ faacDecClose(hDecoder);
+ MP4Close(infile);
+ return 1;
+ }
+
+ sample_buffer = faacDecDecode(hDecoder, &frameInfo, buffer);
+
+ if (buffer)
+ free(buffer);
+
+ opt->progress_update((long)numSamples, sampleId);
+
+ /* open the sound file now that the number of channels are known */
+ if (first_time && !frameInfo.error)
+ {
+ if(opt->decode_mode == 0)
+ {
+ if (Set_WIN_Params (INVALID_FILEDESC, samplerate, SAMPLE_SIZE,
+ frameInfo.channels) < 0)
+ {
+ error_handler("\nCan't access %s\n", "WAVE OUT");
+ faacDecClose(hDecoder);
+ MP4Close(infile);
+ return (0);
+ }
+ }
+ else
+ {
+ aufile = open_audio_file(sndfile, samplerate, frameInfo.channels,
+ opt->output_format, opt->file_type);
+
+ if (aufile == NULL)
+ {
+ faacDecClose(hDecoder);
+ MP4Close(infile);
+ return 0;
+ }
+ }
+ first_time = 0;
+ }
+
+ if ((frameInfo.error == 0) && (frameInfo.samples > 0))
+ {
+ if(opt->decode_mode == 0)
+ WIN_Play_Samples((short*)sample_buffer, frameInfo.channels*frameInfo.samples);
+ else
+ write_audio_file(aufile, sample_buffer, frameInfo.samples);
+ }
+
+ if (frameInfo.error > 0)
+ {
+ error_handler("Error: %s\n",
+ faacDecGetErrorMessage(frameInfo.error));
+ break;
+ }
+ }
+
+
+ faacDecClose(hDecoder);
+
+
+ MP4Close(infile);
+
+ if(opt->decode_mode == 0)
+ WIN_Audio_close();
+ else
+ {
+ if (!first_time)
+ close_audio_file(aufile);
+ }
+
+ return frameInfo.error;
+}
+
+int str_no_case_comp(char const *str1, char const *str2, unsigned long len)
+{
+ signed int c1 = 0, c2 = 0;
+
+ while (len--)
+ {
+ c1 = tolower(*str1++);
+ c2 = tolower(*str2++);
+
+ if (c1 == 0 || c1 != c2)
+ break;
+ }
+
+ return c1 - c2;
+}
+
+int aac_decode(aac_dec_opt *opt)
+{
+ int result;
+ int def_srate = 0;
+ int outfile_set = 0;
+ int mp4file = 0;
+ char *fnp;
+ char audioFileName[MAX_PATH];
+
+
+ /* point to the specified file name */
+ strcpy(audioFileName, opt->filename);
+
+ fnp = (char *)strrchr(audioFileName,'.');
+
+ if (fnp)
+ fnp[0] = '\0';
+
+ strcat(audioFileName, file_ext[opt->file_type]);
+
+ fnp = (char *)strrchr(opt->filename, '.');
+ if (!str_no_case_comp(fnp, ".MP4", 4))
+ mp4file = 1;
+
+ if (mp4file)
+ {
+ result = decodeMP4file(audioFileName, opt);
+ }
+ else
+ {
+ result = decodeAACfile(audioFileName, def_srate, opt);
+ }
+
+ return 0;
+}
--- /dev/null
+++ b/aacDECdrop/decode.h
@@ -1,0 +1,53 @@
+/*
+ * function: Header file for aacDECdrop
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright (C) 2002 John Edwards
+ */
+
+#ifndef __DECODE_H__
+#define __DECODE_H__
+
+#include <stdio.h>
+
+typedef void (*progress_func)(long totalsamples, long samples);
+
+typedef struct
+{
+ progress_func progress_update;
+ int decode_mode;
+ int output_format;
+ int file_type;
+ int object_type;
+ char *filename;
+} aac_dec_opt;
+
+
+int aac_decode(aac_dec_opt *opt);
+
+/*
+ * Put this here for convenience
+ */
+
+typedef struct {
+ char TitleFormat[32];
+ int window_x;
+ int window_y;
+ int always_on_top;
+ int logerr;
+ int decode_mode;
+ int outputFormat;
+ int fileType;
+ int object_type;
+} SettingsAAC;
+
+/*
+ * GLOBALS
+ */
+
+extern SettingsAAC iniSettings;
+
+
+#endif /* __DECODE_H__ */
--- /dev/null
+++ b/aacDECdrop/decthread.c
@@ -1,0 +1,184 @@
+/*
+ * function: Decoding thread for aacDECdrop
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright (C) 2002 John Edwards
+ *
+ * last mod: aacDecdrop decoder last updated 2002-03-14
+ */
+
+#include <windows.h>
+#include <time.h>
+#include <string.h>
+
+#include "wave_out.h"
+#include "decode.h"
+#include "misc.h"
+
+extern int decoding_done;
+extern int animate;
+extern double file_complete;
+extern int totalfiles;
+extern int numfiles;
+int dec_mode;
+int outputFormat;
+int fileType;
+int object_type;
+extern char* fileName;
+
+typedef struct enclist_tag {
+ char *filename;
+ struct enclist_tag *next;
+} enclist_t;
+
+enclist_t *head = NULL;
+
+CRITICAL_SECTION mutex;
+
+DWORD WINAPI decode_thread(LPVOID arg);
+
+void decthread_init(void)
+{
+ int thread_id;
+ HANDLE thand;
+
+ numfiles = 0;
+ totalfiles = 0;
+ file_complete = 0.0;
+
+ InitializeCriticalSection(&mutex);
+
+ thand = CreateThread(NULL, 0, decode_thread, NULL, 0, &thread_id);
+ if (thand == NULL) {
+ // something bad happened, might want to deal with that, maybe...
+ }
+}
+
+void decthread_addfile(char *file)
+{
+ char *filename;
+ enclist_t *entry, *node;
+
+ if (file == NULL) return;
+
+ // create entry
+ filename = strdup(file);
+ entry = (enclist_t *)malloc(sizeof(enclist_t));
+
+ entry->filename = filename;
+ entry->next = NULL;
+
+ EnterCriticalSection(&mutex);
+
+ // insert entry
+ if (head == NULL) {
+ head = entry;
+ } else {
+ node = head;
+ while (node->next != NULL)
+ node = node->next;
+
+ node->next = entry;
+ }
+ numfiles++;
+ totalfiles++;
+
+ LeaveCriticalSection(&mutex);
+}
+
+/*
+ * the caller is responsible for deleting the pointer
+ */
+
+char *_getfile()
+{
+ char *filename;
+ enclist_t *entry;
+
+ EnterCriticalSection(&mutex);
+
+ if (head == NULL) {
+ LeaveCriticalSection(&mutex);
+ return NULL;
+ }
+
+ // pop entry
+ entry = head;
+ head = head->next;
+
+ filename = entry->filename;
+ free(entry);
+
+ LeaveCriticalSection(&mutex);
+
+ return filename;
+}
+
+void decthread_set_decode_mode(int decode_mode)
+{
+ dec_mode = decode_mode;
+}
+
+void decthread_set_outputFormat(int output_format)
+{
+ outputFormat = output_format;
+}
+
+void decthread_set_fileType(int file_type)
+{
+ fileType = file_type;
+}
+
+void decthread_set_object_type(int object_type)
+{
+ object_type = object_type;
+}
+
+void _update(long total, long done)
+{
+ file_complete = (double)done / (double)total;
+}
+
+DWORD WINAPI decode_thread(LPVOID arg)
+{
+ char *in_file;
+
+ while (!decoding_done)
+ {
+ while (in_file = _getfile())
+ {
+ aac_dec_opt dec_opts;
+ animate = 1;
+
+ set_filename(in_file);
+
+ dec_opts.progress_update = _update;
+ dec_opts.filename = in_file;
+ dec_opts.decode_mode = dec_mode;
+ dec_opts.output_format = outputFormat;
+ dec_opts.file_type = fileType;
+ dec_opts.object_type = object_type;
+ fileName = in_file;
+
+ aac_decode(&dec_opts);
+
+ numfiles--;
+ } /* Finished this file, loop around to next... */
+
+ file_complete = 0.0;
+ animate = 0;
+ totalfiles = 0;
+ numfiles = 0;
+
+ Sleep(500);
+ }
+
+ DeleteCriticalSection(&mutex);
+
+ return 0;
+}
+
+/******************************** end of decthread.c ********************************/
+
--- /dev/null
+++ b/aacDECdrop/decthread.h
@@ -1,0 +1,19 @@
+/*
+ * function: Header file for decthread.c
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright (C) 2002 John Edwards
+ */
+#ifndef __DECTHREAD_H__
+#define __DECTHREAD_H__
+
+void decthread_init(void);
+void decthread_addfile(char *file);
+void decthread_set_decode_mode(int decode_mode);
+void decthread_set_outputFormat(int output_format);
+void decthread_set_fileType(int file_type);
+void decthread_set_object_type(int object_type);
+
+#endif /* __DECTHREAD_H__ */
--- /dev/null
+++ b/aacDECdrop/main.c
@@ -1,0 +1,786 @@
+/*
+ * function: Main control program for aacDECdrop
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright (C) 2002 John Edwards
+ *
+ * last mod: aacDECdrop decoder last updated 2002-03-14
+ */
+
+#include <windows.h>
+#include <shellapi.h>
+#include <string.h>
+#include <stdio.h>
+#include <commctrl.h>
+
+#include "resource.h"
+#include "decthread.h"
+#include "decode.h"
+#include "misc.h"
+
+#define LOSHORT(l) ((SHORT)(l))
+#define HISHORT(l) ((SHORT)(((DWORD)(l) >> 16) & 0xFFFF))
+
+#define INI_FILE "aacDECdrop.ini"
+
+#define CREATEFONT(sz) \
+ CreateFont((sz), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ VARIABLE_PITCH | FF_SWISS, "")
+
+HANDLE event = NULL;
+int width = 130, height = 130;
+RECT bar1, bar2, vbrBR;
+int prog1 = 0, prog2 = 0;
+int moving = 0;
+POINT pt;
+HINSTANCE hinst;
+int frame = 0;
+HBITMAP hbm[12], temp;
+HMENU menu;
+int decoding_done = 0;
+double file_complete;
+int totalfiles;
+int numfiles;
+HWND g_hwnd;
+HWND qcwnd;
+HFONT font2;
+char *fileName;
+
+SettingsAAC iniSettings; // iniSettings holds the parameters for the aacDECdrop configuration
+
+int animate = 0;
+
+LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+BOOL CALLBACK QCProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) ;
+
+
+/*
+ * Write the .ini file using the current aacDECdrop settings
+ */
+
+int
+WriteIniFile ( const char* Filename )
+{
+ FILE* fp;
+
+ if ( (fp = fopen (Filename, "w")) == NULL )
+ return EOF; // could not open file
+
+ fprintf (fp, "[aacDECdrop]\n");
+ fprintf (fp, "Window_X=%i\n" , iniSettings.window_x );
+ fprintf (fp, "Window_Y=%i\n" , iniSettings.window_y );
+ fprintf (fp, "Always_on_top=%i\n" , iniSettings.always_on_top);
+ fprintf (fp, "Logerr=%i\n" , iniSettings.logerr );
+ fprintf (fp, "DecodeMode=%i\n" , iniSettings.decode_mode );
+ fprintf (fp, "OutputFormat=%i\n" , iniSettings.outputFormat );
+ fprintf (fp, "FileType=%i\n" , iniSettings.fileType );
+ fprintf (fp, "ObjectType=%i\n" , iniSettings.object_type );
+ return fclose (fp);
+}
+
+/*
+ * Read the .ini file and set the aacDECdrop settings
+ */
+
+int
+ReadIniFile ( FILE* fp )
+{
+ char buff [256];
+ int val;
+
+ rewind ( fp );
+ fgets ( buff, sizeof buff, fp );
+
+ if ( 0 != memcmp ( buff, "[aacDECdrop]", 12 ) )
+ return EOF;
+
+ while ( fgets ( buff, sizeof buff, fp ) != NULL ) {
+ if ( 1 == sscanf ( buff, "Window_X=%d" , &val ) ) iniSettings.window_x = val;
+ else if ( 1 == sscanf ( buff, "Window_Y=%d" , &val ) ) iniSettings.window_y = val;
+ else if ( 1 == sscanf ( buff, "Always_on_top=%d", &val ) ) iniSettings.always_on_top = val;
+ else if ( 1 == sscanf ( buff, "Logerr=%d" , &val ) ) iniSettings.logerr = val;
+ else if ( 1 == sscanf ( buff, "DecodeMode=%d" , &val ) ) iniSettings.decode_mode = val;
+ else if ( 1 == sscanf ( buff, "OutputFormat=%d" , &val ) ) iniSettings.outputFormat = val;
+ else if ( 1 == sscanf ( buff, "FileType=%d" , &val ) ) iniSettings.fileType = val;
+ else if ( 1 == sscanf ( buff, "ObjectType=%d" , &val ) ) iniSettings.object_type = val;
+ }
+
+ return 0;
+}
+
+
+/*
+ * Get aacDECdrop settings at startup, writes .ini file, if not present
+ */
+
+void
+GetAACdecSettings ( void )
+{
+ FILE* fp = NULL;
+ char PathAndName [] = {INI_FILE};
+
+ // set default values
+ iniSettings.window_x = 64; // default box position (x co-ord)
+ iniSettings.window_y = 64; // default box position (y co-ord)
+ iniSettings.always_on_top = 8; // default = on
+ iniSettings.logerr = 0; // default = off
+ iniSettings.decode_mode = 1; // default = 1 (decode to file)
+ iniSettings.outputFormat = 1; // default = 1 (16 bit PCM)
+ iniSettings.fileType = 1; // default = 1 (Microsoft WAV)
+ iniSettings.object_type = 1; // default = 1 (Low Complexity)
+
+ // Read INI_FILE
+ if ( (fp = fopen (PathAndName, "r")) == NULL ) { // file does not exist: write it!
+ WriteIniFile ( PathAndName );
+ }
+ else { // file does exist: read it!
+ ReadIniFile (fp);
+ fclose (fp);
+ }
+
+ return;
+}
+
+void set_always_on_top(HWND hwnd, int v)
+{
+ CheckMenuItem(menu, IDM_ONTOP, v ? MF_CHECKED : MF_UNCHECKED);
+ SetWindowPos(hwnd, v ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOMOVE);
+ iniSettings.always_on_top = v;
+}
+
+void set_logerr(HWND hwnd, int v)
+{
+ CheckMenuItem(menu, IDM_LOGERR, v ? MF_CHECKED : MF_UNCHECKED);
+ iniSettings.logerr = v;
+ set_use_dialogs(v);
+}
+
+void set_decode_mode(int v)
+{
+ decthread_set_decode_mode(v);
+ iniSettings.decode_mode = v;
+}
+
+void set_outputFormat(int v)
+{
+ decthread_set_outputFormat(v);
+ iniSettings.outputFormat = v;
+}
+
+void set_fileType(int v)
+{
+ decthread_set_fileType(v);
+ iniSettings.fileType = v;
+}
+
+void set_object_type(int v)
+{
+ decthread_set_object_type(v);
+ iniSettings.object_type = v;
+}
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
+{
+ static char szAppName[] = "aacDECdrop";
+ HWND hwnd;
+ MSG msg;
+ WNDCLASS wndclass;
+ const int width = 130;
+ const int height = 130;
+ int x;
+ int y;
+
+ hinst = hInstance;
+
+ wndclass.style = CS_HREDRAW | CS_VREDRAW;
+ wndclass.lpfnWndProc = WndProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hInstance;
+ wndclass.hIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON1));
+ wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = szAppName;
+
+ RegisterClass(&wndclass);
+
+ GetAACdecSettings();
+
+ x = max(min(iniSettings.window_x, GetSystemMetrics(SM_CXSCREEN) - width), 0);
+ y = max(min(iniSettings.window_y, GetSystemMetrics(SM_CYSCREEN) - height), 0);
+
+ hwnd = CreateWindow(szAppName, "aacDECdrop", WS_POPUP | WS_DLGFRAME, x, y,
+ width, height, NULL, NULL, hInstance, NULL);
+
+ g_hwnd = hwnd;
+
+ ShowWindow(hwnd, iCmdShow);
+ UpdateWindow(hwnd);
+
+ font2 = CREATEFONT(10);
+
+ SetTimer(hwnd, 1, 80, NULL);
+
+ set_always_on_top(hwnd, iniSettings.always_on_top);
+ set_logerr(hwnd, iniSettings.logerr);
+ set_decode_mode(iniSettings.decode_mode);
+ set_outputFormat(iniSettings.outputFormat);
+ set_fileType(iniSettings.fileType);
+ set_object_type(iniSettings.object_type);
+
+ for (frame = 0; frame < 8; frame++)
+ hbm[frame] = LoadImage(hinst, MAKEINTRESOURCE(IDB_TF01 + frame), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+ frame = 0;
+
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ for (frame = 0; frame < 8; frame++)
+ DeleteObject(hbm[frame]);
+
+ return msg.wParam;
+}
+
+void HandleDrag(HWND hwnd, HDROP hDrop)
+{
+ int cFiles, i;
+ char szFile[MAX_PATH];
+ char *ext;
+ int flag = 0;
+
+ cFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
+ for (i = 0; i < cFiles; i++)
+ {
+ DragQueryFile(hDrop, i, szFile, sizeof(szFile));
+
+ if (ext = strrchr(szFile, '.'))
+ {
+ if (stricmp(ext, ".aac") == 0 || stricmp(ext, ".mp4") == 0)
+ {
+ flag = 1;
+ decthread_addfile(szFile);
+ }
+ }
+ }
+
+ DragFinish(hDrop);
+
+ if (flag)
+ SetEvent(event);
+}
+
+LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ HDC hdc, hmem;
+ static HDC offscreen;
+ PAINTSTRUCT ps;
+ RECT rect, rect2;
+ BITMAP bm;
+ POINT point;
+ static POINT start;
+ static int dragging = 0;
+ HDC desktop;
+ HBITMAP hbitmap;
+ HANDLE hdrop;
+ HFONT dfltFont;
+ int dfltBGMode;
+ double percomp;
+
+ switch (message)
+ {
+ case WM_CREATE:
+ menu = LoadMenu(hinst, MAKEINTRESOURCE(IDR_MENU1));
+ menu = GetSubMenu(menu, 0);
+
+ offscreen = CreateCompatibleDC(NULL);
+ desktop = GetDC(GetDesktopWindow());
+ hbitmap = CreateCompatibleBitmap(desktop, 200, 200);
+ ReleaseDC(GetDesktopWindow(), desktop);
+ SelectObject(offscreen, hbitmap);
+
+ // Start the engines
+ decthread_init();
+
+ // We accept drag&drop
+ DragAcceptFiles(hwnd, TRUE);
+ return 0;
+
+ case WM_PAINT:
+ hdc = BeginPaint(hwnd, &ps);
+ GetClientRect(hwnd, &rect);
+ width = rect.right + 1;
+ height = rect.bottom + 1;
+
+ FillRect(offscreen, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
+ DrawText(offscreen, "Drop Files Here", -1, &rect, DT_SINGLELINE | DT_CENTER);
+ SetRect(&rect2, 0, height - 110, width, height - 25);
+ DrawText(offscreen, "For Decoding", -1, &rect2, DT_SINGLELINE | DT_CENTER);
+
+ hmem = CreateCompatibleDC(offscreen);
+ SelectObject(hmem, hbm[frame]);
+ GetObject(hbm[frame], sizeof(BITMAP), &bm);
+ BitBlt(offscreen, width / 2 - 33, height / 2 - 31, bm.bmWidth, bm.bmHeight, hmem, 0, 0, SRCCOPY);
+ DeleteDC(hmem);
+
+ percomp = ((double)(totalfiles - numfiles) + 1 - (1 - file_complete)) / (double)totalfiles;
+
+ SetRect(&vbrBR, 0, height - 35, width, height - 19);
+
+ dfltBGMode = SetBkMode(offscreen, TRANSPARENT);
+ dfltFont = SelectObject(offscreen, font2);
+
+ SetRect(&bar1, 0, height - 23, (int)(file_complete * width), height - 13);
+ SetRect(&bar2, 0, height - 12, (int)(percomp * width), height - 2);
+
+ FillRect(offscreen, &bar1, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
+ FillRect(offscreen, &bar2, (HBRUSH)GetStockObject(DKGRAY_BRUSH));
+
+ if (fileName)
+ {
+ char* sep;
+ char fileCaption[80];
+
+ if ((sep = strrchr(fileName, '\\')) != 0)
+ fileName = sep+1;
+
+ (void) strcpy(fileCaption, " ");
+ (void) strcat(fileCaption, fileName);
+
+ DrawText(offscreen, fileCaption, -1, &bar1, DT_SINGLELINE | DT_LEFT);
+ }
+
+ SelectObject(offscreen, dfltFont);
+ SetBkMode(offscreen, dfltBGMode);
+
+ BitBlt(hdc, 0, 0, width, height, offscreen, 0, 0, SRCCOPY);
+
+ EndPaint(hwnd, &ps);
+
+ return DefWindowProc(hwnd, message, wParam, lParam);
+ //return 0;
+
+ case WM_TIMER:
+ if (animate || frame)
+ {
+ frame++;
+ if (frame > 7)
+ frame -= 8;
+ }
+ else
+ {
+ frame = 0;
+ }
+ GetClientRect(hwnd, &rect);
+ InvalidateRect(hwnd, &rect, FALSE);
+ return 0;
+
+ case WM_LBUTTONDOWN:
+ start.x = LOWORD(lParam);
+ start.y = HIWORD(lParam);
+ ClientToScreen(hwnd, &start);
+ GetWindowRect(hwnd, &rect);
+ start.x -= rect.left;
+ start.y -= rect.top;
+ dragging = 1;
+ SetCapture(hwnd);
+ return 0;
+
+ case WM_LBUTTONUP:
+ if (dragging)
+ {
+ dragging = 0;
+ ReleaseCapture();
+ }
+ return 0;
+
+ case WM_MOUSEMOVE:
+ if (dragging)
+ {
+ point.x = LOSHORT(lParam);
+ point.y = HISHORT(lParam);
+
+ /* lParam can contain negative coordinates !
+ * point.x = LOWORD(lParam);
+ * point.y = HIWORD(lParam);
+ */
+
+ ClientToScreen(hwnd, &point);
+ SetWindowPos(hwnd, 0, point.x - start.x, point.y - start.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
+ iniSettings.window_x = point.x - start.x;
+ iniSettings.window_y = point.y - start.y;
+ }
+ return 0;
+
+ case WM_CAPTURECHANGED:
+ if (dragging)
+ {
+ dragging = 0;
+ ReleaseCapture();
+ }
+ return 0;
+
+ case WM_RBUTTONUP:
+ point.x = LOWORD(lParam);
+ point.y = HIWORD(lParam);
+ ClientToScreen(hwnd, &point);
+ TrackPopupMenu(menu, TPM_RIGHTBUTTON, point.x, point.y, 0, hwnd, NULL);
+ return 0;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDM_QUIT:
+ WriteIniFile(INI_FILE);
+ decoding_done = 1;
+ PostQuitMessage(0);
+ break;
+ case IDM_ONTOP:
+ set_always_on_top(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED);
+ break;
+ case IDM_LOGERR:
+ set_logerr(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED);
+ break;
+ case IDM_VOLUME:
+ {
+ int value =
+ DialogBox(
+ hinst,
+ MAKEINTRESOURCE(IDD_VOLUME),
+ hwnd, QCProc);
+
+ if (value == -2)
+ break;
+ }
+
+ } // LOWORD(wParam)
+ return 0;
+
+ case WM_DROPFILES:
+ hdrop = (HANDLE)wParam;
+ HandleDrag(hwnd, hdrop);
+ return 0;
+
+ case WM_DESTROY:
+ decoding_done = 1;
+ PostQuitMessage(0);
+ return 0;
+ }
+
+ return DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+/*
+ * Encode parameters dialog procedures.
+ */
+
+BOOL CALLBACK QCProc(HWND hwndDlg, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_INITDIALOG:
+
+ if(iniSettings.decode_mode == 0)
+ {
+ CheckDlgButton(hwndDlg,IDC_PLAYBACK,TRUE);
+ CheckDlgButton(hwndDlg,IDC_DECODE,FALSE);
+ CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ }
+ else if(iniSettings.decode_mode == 1)
+ {
+ CheckDlgButton(hwndDlg,IDC_PLAYBACK,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECODE,TRUE);
+ if(iniSettings.outputFormat == 1)
+ {
+ CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ }
+ else if(iniSettings.outputFormat == 2)
+ {
+ CheckDlgButton(hwndDlg,IDC_16BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,TRUE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ }
+ else if(iniSettings.outputFormat == 3)
+ {
+ CheckDlgButton(hwndDlg,IDC_16BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,TRUE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ }
+ else if(iniSettings.outputFormat == 4)
+ {
+ CheckDlgButton(hwndDlg,IDC_16BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,TRUE);
+ }
+
+ if(iniSettings.fileType == 1)
+ {
+ CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ }
+ else if(iniSettings.fileType == 2)
+ {
+ CheckDlgButton(hwndDlg,IDC_WAV,FALSE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,TRUE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ }
+ else if(iniSettings.fileType == 3)
+ {
+ CheckDlgButton(hwndDlg,IDC_WAV,FALSE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,TRUE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ }
+ else if(iniSettings.fileType == 4)
+ {
+ CheckDlgButton(hwndDlg,IDC_WAV,FALSE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,TRUE);
+ }
+ }
+
+ if(iniSettings.object_type == 0)
+ {
+ CheckDlgButton(hwndDlg,IDC_MAIN,TRUE);
+ CheckDlgButton(hwndDlg,IDC_LC,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LTP,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LD,FALSE);
+ }
+ else if(iniSettings.object_type == 1)
+ {
+ CheckDlgButton(hwndDlg,IDC_MAIN,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LC,TRUE);
+ CheckDlgButton(hwndDlg,IDC_LTP,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LD,FALSE);
+ }
+ else if(iniSettings.object_type == 3)
+ {
+ CheckDlgButton(hwndDlg,IDC_MAIN,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LC,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LTP,TRUE);
+ CheckDlgButton(hwndDlg,IDC_LD,FALSE);
+ }
+ else if(iniSettings.object_type == 23)
+ {
+ CheckDlgButton(hwndDlg,IDC_MAIN,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LC,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LTP,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LD,TRUE);
+ }
+ break;
+
+ case WM_CLOSE:
+ EndDialog(hwndDlg, -1);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDC_BUTTON1:
+ {
+ if (IsDlgButtonChecked(hwndDlg, IDC_PLAYBACK) == BST_CHECKED)
+ set_decode_mode(0); // Playback
+ else if (IsDlgButtonChecked(hwndDlg, IDC_DECODE) == BST_CHECKED)
+ set_decode_mode(1); // Decode to File
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_WAV) == BST_CHECKED)
+ set_fileType(1); // Microsoft WAV
+ else if (IsDlgButtonChecked(hwndDlg, IDC_AIFF) == BST_CHECKED)
+ set_fileType(2); // Apple/SGI AIFF
+ else if (IsDlgButtonChecked(hwndDlg, IDC_SUNAU) == BST_CHECKED)
+ set_fileType(3); // Sun/NeXT AU
+ else if (IsDlgButtonChecked(hwndDlg, IDC_DECAU) == BST_CHECKED)
+ set_fileType(4); // DEC AU
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_16BIT) == BST_CHECKED)
+ set_outputFormat(1); // 16 bit PCM
+ else if (IsDlgButtonChecked(hwndDlg, IDC_24BIT) == BST_CHECKED)
+ set_outputFormat(2); // 24 bit PCM
+ else if (IsDlgButtonChecked(hwndDlg, IDC_32BIT) == BST_CHECKED)
+ set_outputFormat(3); // 32 bit PCM
+ else if (IsDlgButtonChecked(hwndDlg, IDC_FLOATS) == BST_CHECKED)
+ set_outputFormat(4); // 32 bit floats
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_MAIN) == BST_CHECKED)
+ set_object_type(0); // Main
+ else if (IsDlgButtonChecked(hwndDlg, IDC_LC) == BST_CHECKED)
+ set_object_type(1); // Low Complexity
+ else if (IsDlgButtonChecked(hwndDlg, IDC_LTP) == BST_CHECKED)
+ set_object_type(3); // Long Term Prediction
+ else if (IsDlgButtonChecked(hwndDlg, IDC_LD) == BST_CHECKED)
+ set_object_type(23); // Low Delay
+
+ decoding_done = 0;
+ EndDialog(hwndDlg, -2);
+ return TRUE;
+ }
+// case IDC_BUTTON2:
+// break;
+ case IDC_PLAYBACK:
+ CheckDlgButton(hwndDlg,IDC_DECODE,FALSE);
+ CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ break;
+ case IDC_DECODE:
+ CheckDlgButton(hwndDlg,IDC_PLAYBACK,FALSE);
+ break;
+ case IDC_WAV:
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ break;
+ case IDC_AIFF:
+ if (IsDlgButtonChecked(hwndDlg, IDC_DECODE) == BST_CHECKED)
+ {
+ CheckDlgButton(hwndDlg,IDC_WAV,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ }
+ else
+ {
+ CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ }
+ break;
+ case IDC_SUNAU:
+ if (IsDlgButtonChecked(hwndDlg, IDC_DECODE) == BST_CHECKED)
+ {
+ CheckDlgButton(hwndDlg,IDC_WAV,FALSE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ }
+ else
+ {
+ CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ }
+ break;
+ case IDC_DECAU:
+ if (IsDlgButtonChecked(hwndDlg, IDC_DECODE) == BST_CHECKED)
+ {
+ CheckDlgButton(hwndDlg,IDC_WAV,FALSE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ }
+ else
+ {
+ CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
+ CheckDlgButton(hwndDlg,IDC_AIFF,FALSE);
+ CheckDlgButton(hwndDlg,IDC_SUNAU,FALSE);
+ CheckDlgButton(hwndDlg,IDC_DECAU,FALSE);
+ }
+ break;
+ case IDC_16BIT:
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ break;
+ case IDC_24BIT:
+ if (IsDlgButtonChecked(hwndDlg, IDC_DECODE) == BST_CHECKED)
+ {
+ CheckDlgButton(hwndDlg,IDC_16BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ }
+ else
+ {
+ CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ }
+ break;
+ case IDC_32BIT:
+ if (IsDlgButtonChecked(hwndDlg, IDC_DECODE) == BST_CHECKED)
+ {
+ CheckDlgButton(hwndDlg,IDC_16BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ }
+ else
+ {
+ CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ }
+ break;
+ case IDC_FLOATS:
+ if (IsDlgButtonChecked(hwndDlg, IDC_DECODE) == BST_CHECKED)
+ {
+ CheckDlgButton(hwndDlg,IDC_16BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ }
+ else
+ {
+ CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ }
+ break;
+ case IDC_MAIN:
+ CheckDlgButton(hwndDlg,IDC_LC,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LTP,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LD,FALSE);
+ break;
+ case IDC_LC:
+ CheckDlgButton(hwndDlg,IDC_MAIN,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LTP,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LD,FALSE);
+ break;
+ case IDC_LTP:
+ CheckDlgButton(hwndDlg,IDC_MAIN,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LC,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LD,FALSE);
+ break;
+ case IDC_LD:
+ CheckDlgButton(hwndDlg,IDC_MAIN,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LC,FALSE);
+ CheckDlgButton(hwndDlg,IDC_LTP,FALSE);
+ break;
+ default:
+ break;
+ }
+ }
+ return FALSE;
+}
+
+
+/******************************** end of main.c ********************************/
+
--- /dev/null
+++ b/aacDECdrop/misc.c
@@ -1,0 +1,124 @@
+/*
+ * function: Miscellaneous functions for aacDECdrop
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright (C) 2002 John Edwards
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <windows.h>
+#include "misc.h"
+
+static char *_filename;
+void (*error_handler)(const char *fmt, ...) = error_dialog;
+
+/*
+ * Set the current input file name.
+ */
+
+void set_filename(const char *filename)
+{
+ _filename = filename;
+}
+
+/*
+ * Display an error dialog, possibly adding system error information.
+ */
+
+void error_dialog(const char *fmt, ...)
+{
+ va_list ap;
+ char msgbuf[1024];
+ char *bufp = msgbuf;
+
+ /* A really rough sanity check to protect against blatant buffer overrun */
+ if (strlen(fmt) > 750)
+ {
+ sprintf(msgbuf, "%s %s", "<buffer overflow> ", fmt);
+ }
+ else
+ {
+ if (_filename != NULL && strlen(_filename) < 255)
+ {
+ sprintf(msgbuf, "%s: ", _filename);
+ bufp += strlen(msgbuf);
+ }
+
+ va_start(ap, fmt);
+
+ vsprintf(bufp, fmt, ap);
+
+ va_end(ap);
+
+ if (errno != 0)
+ {
+ bufp = msgbuf + strlen(msgbuf);
+ sprintf(bufp, " error is %s (%d)", strerror(errno), errno);
+ errno = 0;
+ }
+ }
+
+ MessageBox(NULL, msgbuf, "Error", 0);
+}
+
+void log_error(const char *fmt, ...)
+{
+ va_list ap;
+ FILE *fp;
+ char msgbuf[1024];
+ char *bufp = msgbuf;
+
+ /* A really rough sanity check to protect against blatant buffer overrun */
+ if (strlen(fmt) > 750)
+ {
+ sprintf(msgbuf, "%s %s", "<buffer overflow> ", fmt);
+ }
+ else
+ {
+ if (_filename != NULL && strlen(_filename) < 255)
+ {
+ sprintf(msgbuf, "%s : ", _filename);
+ bufp += strlen(msgbuf);
+ }
+
+ va_start(ap, fmt);
+
+ vsprintf(bufp, fmt, ap);
+
+ va_end(ap);
+
+ if (errno != 0)
+ {
+ bufp = msgbuf + strlen(msgbuf);
+ sprintf(bufp, " error is: %s (%d)", strerror(errno), errno);
+ errno = 0;
+ }
+ }
+
+ va_start(ap, fmt);
+
+ if ((fp = fopen("oggdrop.log", "a")) == (FILE *)NULL)
+ return;
+
+ fprintf(fp, "%s\n", msgbuf);
+ fflush(fp);
+ fclose(fp);
+
+ va_end(ap);
+}
+
+void set_use_dialogs(int use_dialogs)
+{
+ if (!use_dialogs)
+ error_handler = error_dialog;
+ else
+ error_handler = log_error;
+}
+
+
+/******************************** end of misc.c ********************************/
+
--- /dev/null
+++ b/aacDECdrop/misc.h
@@ -1,0 +1,25 @@
+/*
+ * function: Header file for misc.c
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright (C) 2002 John Edwards
+ */
+
+#ifndef __MISC_H__
+#define __MISC_H__
+
+#include "decode.h"
+#include <stdio.h>
+
+void set_filename(const char *filename);
+
+extern void error_dialog(const char *fmt, ...);
+extern void log_error(const char *fmt, ...);
+extern void set_use_dialogs(int use_dialogs);
+extern void (*error_handler)(const char *fmt, ...);
+
+
+#endif /* __MISC_H__ */
+
--- /dev/null
+++ b/aacDECdrop/resource.h
@@ -1,0 +1,47 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by Script.rc
+//
+#define IDD_VOLUME 101
+#define IDB_TF01 112
+#define IDB_TF02 113
+#define IDB_TF03 114
+#define IDB_TF04 115
+#define IDB_TF05 116
+#define IDB_TF06 117
+#define IDB_TF07 118
+#define IDB_TF08 119
+#define IDR_MENU1 124
+#define IDI_ICON1 130
+#define IDC_BUTTON1 1001
+#define IDC_BUTTON2 1003
+#define IDC_PLAYBACK 1005
+#define IDC_DECODE 1008
+#define IDC_WAV 1014
+#define IDC_AIFF 1015
+#define IDC_SUNAU 1016
+#define IDC_DECAU 1017
+#define IDC_16BIT 1018
+#define IDC_24BIT 1020
+#define IDC_32BIT 1021
+#define IDC_FLOATS 1022
+#define IDC_MAIN 1023
+#define IDC_LC 1024
+#define IDC_LTP 1025
+#define IDC_LD 1026
+#define IDM_VOLUME 40005
+#define IDM_LOGERR 40008
+#define IDM_ONTOP 40015
+#define IDM_QUIT 40019
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC 1
+#define _APS_NEXT_RESOURCE_VALUE 134
+#define _APS_NEXT_COMMAND_VALUE 40018
+#define _APS_NEXT_CONTROL_VALUE 1021
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
binary files /dev/null b/aacDECdrop/resource/AAC01.bmp differ
binary files /dev/null b/aacDECdrop/resource/AAC01.ico differ
binary files /dev/null b/aacDECdrop/resource/AAC02.bmp differ
binary files /dev/null b/aacDECdrop/resource/AAC03.bmp differ
binary files /dev/null b/aacDECdrop/resource/AAC04.bmp differ
binary files /dev/null b/aacDECdrop/resource/AAC05.bmp differ
binary files /dev/null b/aacDECdrop/resource/AAC06.bmp differ
binary files /dev/null b/aacDECdrop/resource/AAC07.bmp differ
binary files /dev/null b/aacDECdrop/resource/AAC08.bmp differ
--- /dev/null
+++ b/aacDECdrop/wave_out.c
@@ -1,0 +1,190 @@
+/*
+ * function: Support for playing wave files - Win32 - ONLY
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright (C) 2002 John Edwards
+ */
+
+#include <string.h>
+#include <errno.h>
+#include "wave_out.h"
+
+#define MAX_WAVEBLOCKS 32
+
+
+static CRITICAL_SECTION cs;
+static HWAVEOUT dev = NULL;
+static int ScheduledBlocks = 0;
+static int PlayedWaveHeadersCount = 0; // free index
+static WAVEHDR* PlayedWaveHeaders [MAX_WAVEBLOCKS];
+
+
+static int
+Box ( const char* msg )
+{
+ MessageBox ( NULL, msg, "Error Message . . .", MB_OK | MB_ICONEXCLAMATION );
+ return -1;
+}
+
+
+/*
+ * This function registers already played WAVE chunks. Freeing is done by free_memory(),
+ */
+
+static void CALLBACK
+wave_callback ( HWAVE hWave, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 )
+{
+ if ( uMsg == WOM_DONE )
+ {
+ EnterCriticalSection ( &cs );
+ PlayedWaveHeaders [PlayedWaveHeadersCount++] = (WAVEHDR*) dwParam1;
+ LeaveCriticalSection ( &cs );
+ }
+}
+
+
+static void
+free_memory ( void )
+{
+ WAVEHDR* wh;
+ HGLOBAL hg;
+
+ EnterCriticalSection ( &cs );
+ wh = PlayedWaveHeaders [--PlayedWaveHeadersCount];
+ ScheduledBlocks--; // decrease the number of USED blocks
+ LeaveCriticalSection ( &cs );
+
+ waveOutUnprepareHeader ( dev, wh, sizeof (WAVEHDR) );
+
+ hg = GlobalHandle ( wh -> lpData ); // Deallocate the buffer memory
+ GlobalUnlock (hg);
+ GlobalFree (hg);
+
+ hg = GlobalHandle ( wh ); // Deallocate the header memory
+ GlobalUnlock (hg);
+ GlobalFree (hg);
+}
+
+
+Int
+Set_WIN_Params ( FILE_T dummyFile ,
+ Ldouble SampleFreq,
+ Uint BitsPerSample,
+ Uint Channels )
+{
+ WAVEFORMATEX outFormat;
+ UINT deviceID = WAVE_MAPPER;
+
+ (void) dummyFile;
+
+ if ( waveOutGetNumDevs () == 0 )
+ return Box ( "No audio device present." );
+
+ outFormat.wFormatTag = WAVE_FORMAT_PCM;
+ outFormat.wBitsPerSample = BitsPerSample;
+ outFormat.nChannels = Channels;
+ outFormat.nSamplesPerSec = (unsigned long)(SampleFreq);
+ outFormat.nBlockAlign = outFormat.nChannels * outFormat.wBitsPerSample/8;
+ outFormat.nAvgBytesPerSec = outFormat.nSamplesPerSec * outFormat.nChannels * outFormat.wBitsPerSample/8;
+
+ switch ( waveOutOpen ( &dev, deviceID, &outFormat, (DWORD)wave_callback, 0, CALLBACK_FUNCTION ) )
+ {
+ case MMSYSERR_ALLOCATED: return Box ( "Device is already open." );
+ case MMSYSERR_BADDEVICEID: return Box ( "The specified device is out of range." );
+ case MMSYSERR_NODRIVER: return Box ( "There is no audio driver in this system." );
+ case MMSYSERR_NOMEM: return Box ( "Unable to allocate sound memory." );
+ case WAVERR_BADFORMAT: return Box ( "This audio format is not supported." );
+ case WAVERR_SYNC: return Box ( "The device is synchronous." );
+ default: return Box ( "Unknown media error." );
+ case MMSYSERR_NOERROR: break;
+ }
+
+ waveOutReset ( dev );
+ InitializeCriticalSection ( &cs );
+ SetPriorityClass ( GetCurrentProcess (), HIGH_PRIORITY_CLASS );
+// SetPriorityClass ( GetCurrentProcess (), REALTIME_PRIORITY_CLASS );
+ return 0;
+}
+
+
+int
+WIN_Play_Samples ( const void* data, size_t len )
+{
+ HGLOBAL hg;
+ HGLOBAL hg2;
+ LPWAVEHDR wh;
+ void* allocptr;
+
+ do
+ {
+ while ( PlayedWaveHeadersCount > 0 ) // free used blocks ...
+ free_memory ();
+
+ if ( ScheduledBlocks < sizeof(PlayedWaveHeaders)/sizeof(*PlayedWaveHeaders) ) // wait for a free block ...
+ break;
+ Sleep (26);
+
+ } while (1);
+
+ if ( (hg2 = GlobalAlloc ( GMEM_MOVEABLE, len )) == NULL ) // allocate some memory for a copy of the buffer
+ return Box ( "GlobalAlloc failed." );
+
+ allocptr = GlobalLock (hg2);
+ CopyMemory ( allocptr, data, len ); // Here we can call any modification output functions we want....
+
+ if ( (hg = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (WAVEHDR))) == NULL ) // now make a header and WRITE IT!
+ return -1;
+
+ wh = GlobalLock (hg);
+ wh->dwBufferLength = len;
+ wh->lpData = allocptr;
+
+ if ( waveOutPrepareHeader ( dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR )
+ {
+ GlobalUnlock (hg);
+ GlobalFree (hg);
+ return -1;
+ }
+
+ if ( waveOutWrite ( dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR )
+ {
+ GlobalUnlock (hg);
+ GlobalFree (hg);
+ return -1;
+ }
+
+ EnterCriticalSection ( &cs );
+ ScheduledBlocks++;
+ LeaveCriticalSection ( &cs );
+
+ return len;
+}
+
+
+int
+WIN_Audio_close ( void )
+{
+ if ( dev != NULL )
+ {
+ while ( ScheduledBlocks > 0 )
+ {
+ Sleep (ScheduledBlocks);
+ while ( PlayedWaveHeadersCount > 0 ) // free used blocks ...
+ free_memory ();
+ }
+
+ waveOutReset (dev); // reset the device
+ waveOutClose (dev); // close the device
+ dev = NULL;
+ }
+
+ DeleteCriticalSection ( &cs );
+ ScheduledBlocks = 0;
+ return 0;
+}
+
+
+/******************************** end of wave_out.c ********************************/
+
--- /dev/null
+++ b/aacDECdrop/wave_out.h
@@ -1,0 +1,50 @@
+/*
+ * function: Header file for wave_out.c
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright (C) 2002 John Edwards
+ */
+
+#ifndef __WAVE_OUT_H__
+#define __WAVE_OUT_H__
+
+
+#include <stdio.h>
+#include <windows.h>
+
+#define Cdecl __cdecl
+#define __attribute__(x)
+#define sleep(__sec) Sleep ((__sec) * 1000)
+#define inline __inline
+#define restrict
+
+/*
+ * constants
+ */
+
+#define CD_SAMPLE_FREQ 44.1e3
+#define SAMPLE_SIZE 16
+#define SAMPLE_SIZE_STRING ""
+#define WINAUDIO_FD ((FILE_T)-128)
+#define FILE_T FILE*
+#define INVALID_FILEDESC NULL
+
+/*
+ * Simple types
+ */
+
+typedef signed int Int; // at least -32767...+32767, fast type
+typedef unsigned int Uint; // at least 0...65535, fast type
+typedef long double Ldouble; // most exact floating point format
+
+/*
+ * functions for wave_out.c
+ */
+
+Int Set_WIN_Params ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
+int WIN_Play_Samples ( const void* buff, size_t len );
+int WIN_Audio_close ( void );
+
+#endif /* __WAVE_OUT_H__ */
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: decoder.c,v 1.12 2002/03/16 13:38:37 menno Exp $
+** $Id: decoder.c,v 1.13 2002/03/16 19:18:11 menno Exp $
**/
#include <stdlib.h>
@@ -127,6 +127,38 @@
return 11;
}
+/* Returns 0 if an object type is decodable, otherwise returns -1 */
+static int8_t can_decode_ot(uint8_t object_type)
+{
+ switch (object_type)
+ {
+ case LC:
+ return 0;
+ case MAIN:
+#ifdef MAIN_DEC
+ return 0;
+#else
+ return -1;
+#endif
+ case SSR:
+ return -1;
+ case LTP:
+#ifdef LTP_DEC
+ return 0;
+#else
+ return -1;
+#endif
+ case LD:
+#ifdef LD_DEC
+ return 0;
+#else
+ return -1;
+#endif
+ }
+
+ return -1;
+}
+
int32_t FAADAPI faacDecInit(faacDecHandle hDecoder, uint8_t *buffer,
uint32_t *samplerate, uint8_t *channels)
{
@@ -175,6 +207,9 @@
}
}
hDecoder->channelConfiguration = *channels;
+
+ if (can_decode_ot(hDecoder->object_type) < 0)
+ return -1;
return bits;
}
--- a/libfaad/tns.c
+++ b/libfaad/tns.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: tns.c,v 1.6 2002/03/16 13:38:36 menno Exp $
+** $Id: tns.c,v 1.7 2002/03/16 19:18:11 menno Exp $
**/
#include "common.h"
@@ -145,8 +145,8 @@
tmp[i] = (coef[i] & s_mask) ? (coef[i] | n_mask) : coef[i];
/* Inverse quantization */
- iqfac = ((1 << (coef_res_bits-1)) - 0.5f) / (M_PI/2.0f);
- iqfac_m = ((1 << (coef_res_bits-1)) + 0.5f) / (M_PI/2.0f);
+ iqfac = ((1 << (coef_res_bits-1)) - 0.5f) / M_PI_2;
+ iqfac_m = ((1 << (coef_res_bits-1)) + 0.5f) / M_PI_2;
for (i = 0; i < order; i++)
tmp2[i] = (real_t)sin(tmp[i] / ((tmp[i] >= 0) ? iqfac : iqfac_m));