summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Cichoń <michcic@gmail.com>2012-06-26 20:35:30 +0200
committerMichał Cichoń <michcic@gmail.com>2012-06-26 20:35:30 +0200
commitcc2160de5cc05dc3aa77f3a34358e66f6193c8c9 (patch)
treeb93dd2dbdf7ea5ca4d6647c58dbe504824ac419f
parenta9c5f408fdc10f9fd1da6e5cf6f6376f1f591e10 (diff)
downloadpianobar-windows-build-cc2160de5cc05dc3aa77f3a34358e66f6193c8c9.tar.gz
pianobar-windows-build-cc2160de5cc05dc3aa77f3a34358e66f6193c8c9.tar.bz2
pianobar-windows-build-cc2160de5cc05dc3aa77f3a34358e66f6193c8c9.zip
Add support for AAC.
m---------build0
-rw-r--r--faad2/faad2.vcproj1284
-rw-r--r--faad2/src/AUTHORS17
-rw-r--r--faad2/src/COPYING350
-rw-r--r--faad2/src/ChangeLog7
-rw-r--r--faad2/src/Makefile.am8
-rw-r--r--faad2/src/NEWS7
-rw-r--r--faad2/src/README97
-rw-r--r--faad2/src/README.linux15
-rw-r--r--faad2/src/TODO2
-rw-r--r--faad2/src/aacDECdrop/Script.rc214
-rw-r--r--faad2/src/aacDECdrop/aacDECdrop/aacDECdrop.sln33
-rw-r--r--faad2/src/aacDECdrop/aacDECdrop/aacDECdrop.vcproj335
-rw-r--r--faad2/src/aacDECdrop/audio.c494
-rw-r--r--faad2/src/aacDECdrop/audio.h71
-rw-r--r--faad2/src/aacDECdrop/decode.c566
-rw-r--r--faad2/src/aacDECdrop/decode.h55
-rw-r--r--faad2/src/aacDECdrop/decthread.c194
-rw-r--r--faad2/src/aacDECdrop/decthread.h19
-rw-r--r--faad2/src/aacDECdrop/main.c678
-rw-r--r--faad2/src/aacDECdrop/misc.c124
-rw-r--r--faad2/src/aacDECdrop/misc.h25
-rw-r--r--faad2/src/aacDECdrop/resource.h54
-rw-r--r--faad2/src/aacDECdrop/resource/AAC01.bmpbin0 -> 2134 bytes
-rw-r--r--faad2/src/aacDECdrop/resource/AAC01.icobin0 -> 2238 bytes
-rw-r--r--faad2/src/aacDECdrop/resource/AAC02.bmpbin0 -> 2134 bytes
-rw-r--r--faad2/src/aacDECdrop/resource/AAC03.bmpbin0 -> 2134 bytes
-rw-r--r--faad2/src/aacDECdrop/resource/AAC04.bmpbin0 -> 2134 bytes
-rw-r--r--faad2/src/aacDECdrop/resource/AAC05.bmpbin0 -> 2134 bytes
-rw-r--r--faad2/src/aacDECdrop/resource/AAC06.bmpbin0 -> 2134 bytes
-rw-r--r--faad2/src/aacDECdrop/resource/AAC07.bmpbin0 -> 2134 bytes
-rw-r--r--faad2/src/aacDECdrop/resource/AAC08.bmpbin0 -> 2134 bytes
-rw-r--r--faad2/src/aacDECdrop/wave_out.c190
-rw-r--r--faad2/src/aacDECdrop/wave_out.h50
-rw-r--r--faad2/src/bootstrap17
-rw-r--r--faad2/src/common/Makefile.am1
-rw-r--r--faad2/src/common/faad/aacinfo.c372
-rw-r--r--faad2/src/common/faad/aacinfo.h53
-rw-r--r--faad2/src/common/faad/aacinfo.sln19
-rw-r--r--faad2/src/common/faad/aacinfo.vcproj224
-rw-r--r--faad2/src/common/faad/filestream.c470
-rw-r--r--faad2/src/common/faad/filestream.h57
-rw-r--r--faad2/src/common/faad/getopt.c755
-rw-r--r--faad2/src/common/faad/getopt.h130
-rw-r--r--faad2/src/common/faad/id3v2tag.c1124
-rw-r--r--faad2/src/common/faad/id3v2tag.h54
-rw-r--r--faad2/src/common/mp4ff/Makefile.am7
-rw-r--r--faad2/src/common/mp4ff/mp4atom.c689
-rw-r--r--faad2/src/common/mp4ff/mp4ff.c475
-rw-r--r--faad2/src/common/mp4ff/mp4ff.h138
-rw-r--r--faad2/src/common/mp4ff/mp4ff.vcproj326
-rw-r--r--faad2/src/common/mp4ff/mp4ff_int_types.h27
-rw-r--r--faad2/src/common/mp4ff/mp4ffint.h344
-rw-r--r--faad2/src/common/mp4ff/mp4meta.c461
-rw-r--r--faad2/src/common/mp4ff/mp4sample.c155
-rw-r--r--faad2/src/common/mp4ff/mp4tagupdate.c656
-rw-r--r--faad2/src/common/mp4ff/mp4util.c191
-rw-r--r--faad2/src/configure.in168
-rw-r--r--faad2/src/docs/Ahead AAC Decoder library documentation.docbin0 -> 95744 bytes
-rw-r--r--faad2/src/docs/Ahead AAC Decoder library documentation.pdfbin0 -> 29697 bytes
-rw-r--r--faad2/src/faad2.spec.in182
-rw-r--r--faad2/src/frontend/Makefile.am12
-rw-r--r--faad2/src/frontend/audio.c500
-rw-r--r--faad2/src/frontend/audio.h75
-rw-r--r--faad2/src/frontend/faad.man85
-rw-r--r--faad2/src/frontend/faad.sln36
-rw-r--r--faad2/src/frontend/faad.vcproj256
-rw-r--r--faad2/src/frontend/main.c1270
-rw-r--r--faad2/src/in_mpeg4aac.nsi21
-rw-r--r--faad2/src/include/faad.h35
-rw-r--r--faad2/src/include/neaacdec.h258
-rw-r--r--faad2/src/libfaad/Makefile.am30
-rw-r--r--faad2/src/libfaad/analysis.h52
-rw-r--r--faad2/src/libfaad/bits.c271
-rw-r--r--faad2/src/libfaad/bits.h452
-rw-r--r--faad2/src/libfaad/cfft.c1005
-rw-r--r--faad2/src/libfaad/cfft.h56
-rw-r--r--faad2/src/libfaad/cfft_tab.h1823
-rw-r--r--faad2/src/libfaad/codebook/hcb.h145
-rw-r--r--faad2/src/libfaad/codebook/hcb_1.h186
-rw-r--r--faad2/src/libfaad/codebook/hcb_10.h312
-rw-r--r--faad2/src/libfaad/codebook/hcb_11.h415
-rw-r--r--faad2/src/libfaad/codebook/hcb_2.h185
-rw-r--r--faad2/src/libfaad/codebook/hcb_3.h196
-rw-r--r--faad2/src/libfaad/codebook/hcb_4.h199
-rw-r--r--faad2/src/libfaad/codebook/hcb_5.h196
-rw-r--r--faad2/src/libfaad/codebook/hcb_6.h182
-rw-r--r--faad2/src/libfaad/codebook/hcb_7.h162
-rw-r--r--faad2/src/libfaad/codebook/hcb_8.h173
-rw-r--r--faad2/src/libfaad/codebook/hcb_9.h372
-rw-r--r--faad2/src/libfaad/codebook/hcb_sf.h276
-rw-r--r--faad2/src/libfaad/common.c522
-rw-r--r--faad2/src/libfaad/common.h450
-rw-r--r--faad2/src/libfaad/decoder.c1223
-rw-r--r--faad2/src/libfaad/drc.c173
-rw-r--r--faad2/src/libfaad/drc.h49
-rw-r--r--faad2/src/libfaad/drm_dec.c965
-rw-r--r--faad2/src/libfaad/drm_dec.h100
-rw-r--r--faad2/src/libfaad/error.c70
-rw-r--r--faad2/src/libfaad/error.h44
-rw-r--r--faad2/src/libfaad/filtbank.c406
-rw-r--r--faad2/src/libfaad/filtbank.h61
-rw-r--r--faad2/src/libfaad/fixed.h287
-rw-r--r--faad2/src/libfaad/hcr.c432
-rw-r--r--faad2/src/libfaad/huffman.c559
-rw-r--r--faad2/src/libfaad/huffman.h47
-rw-r--r--faad2/src/libfaad/ic_predict.c271
-rw-r--r--faad2/src/libfaad/ic_predict.h252
-rw-r--r--faad2/src/libfaad/iq_table.h16458
-rw-r--r--faad2/src/libfaad/is.c109
-rw-r--r--faad2/src/libfaad/is.h67
-rw-r--r--faad2/src/libfaad/kbd_win.h2297
-rw-r--r--faad2/src/libfaad/libfaad.sln20
-rw-r--r--faad2/src/libfaad/libfaad.vcproj1300
-rw-r--r--faad2/src/libfaad/libfaad2.def14
-rw-r--r--faad2/src/libfaad/libfaad2_dll.sln19
-rw-r--r--faad2/src/libfaad/libfaad2_dll.vcproj487
-rw-r--r--faad2/src/libfaad/lt_predict.c215
-rw-r--r--faad2/src/libfaad/lt_predict.h66
-rw-r--r--faad2/src/libfaad/mdct.c301
-rw-r--r--faad2/src/libfaad/mdct.h48
-rw-r--r--faad2/src/libfaad/mdct_tab.h3655
-rw-r--r--faad2/src/libfaad/mp4.c309
-rw-r--r--faad2/src/libfaad/mp4.h52
-rw-r--r--faad2/src/libfaad/ms.c77
-rw-r--r--faad2/src/libfaad/ms.h44
-rw-r--r--faad2/src/libfaad/output.c559
-rw-r--r--faad2/src/libfaad/output.h48
-rw-r--r--faad2/src/libfaad/pns.c271
-rw-r--r--faad2/src/libfaad/pns.h57
-rw-r--r--faad2/src/libfaad/ps_dec.c2013
-rw-r--r--faad2/src/libfaad/ps_dec.h152
-rw-r--r--faad2/src/libfaad/ps_syntax.c551
-rw-r--r--faad2/src/libfaad/ps_tables.h550
-rw-r--r--faad2/src/libfaad/pulse.c58
-rw-r--r--faad2/src/libfaad/pulse.h43
-rw-r--r--faad2/src/libfaad/rvlc.c533
-rw-r--r--faad2/src/libfaad/rvlc.h56
-rw-r--r--faad2/src/libfaad/sbr_dct.c2279
-rw-r--r--faad2/src/libfaad/sbr_dct.h52
-rw-r--r--faad2/src/libfaad/sbr_dec.c690
-rw-r--r--faad2/src/libfaad/sbr_dec.h254
-rw-r--r--faad2/src/libfaad/sbr_e_nf.c510
-rw-r--r--faad2/src/libfaad/sbr_e_nf.h50
-rw-r--r--faad2/src/libfaad/sbr_fbt.c764
-rw-r--r--faad2/src/libfaad/sbr_fbt.h55
-rw-r--r--faad2/src/libfaad/sbr_hfadj.c1748
-rw-r--r--faad2/src/libfaad/sbr_hfadj.h57
-rw-r--r--faad2/src/libfaad/sbr_hfgen.c668
-rw-r--r--faad2/src/libfaad/sbr_hfgen.h49
-rw-r--r--faad2/src/libfaad/sbr_huff.c360
-rw-r--r--faad2/src/libfaad/sbr_huff.h46
-rw-r--r--faad2/src/libfaad/sbr_noise.h564
-rw-r--r--faad2/src/libfaad/sbr_qmf.c636
-rw-r--r--faad2/src/libfaad/sbr_qmf.h55
-rw-r--r--faad2/src/libfaad/sbr_qmf_c.h368
-rw-r--r--faad2/src/libfaad/sbr_syntax.c910
-rw-r--r--faad2/src/libfaad/sbr_syntax.h68
-rw-r--r--faad2/src/libfaad/sbr_tf_grid.c261
-rw-r--r--faad2/src/libfaad/sbr_tf_grid.h47
-rw-r--r--faad2/src/libfaad/sine_win.h4304
-rw-r--r--faad2/src/libfaad/specrec.c1330
-rw-r--r--faad2/src/libfaad/specrec.h49
-rw-r--r--faad2/src/libfaad/ssr.c175
-rw-r--r--faad2/src/libfaad/ssr.h59
-rw-r--r--faad2/src/libfaad/ssr_fb.c185
-rw-r--r--faad2/src/libfaad/ssr_fb.h53
-rw-r--r--faad2/src/libfaad/ssr_ipqf.c191
-rw-r--r--faad2/src/libfaad/ssr_ipqf.h46
-rw-r--r--faad2/src/libfaad/ssr_win.h635
-rw-r--r--faad2/src/libfaad/structs.h445
-rw-r--r--faad2/src/libfaad/syntax.c2634
-rw-r--r--faad2/src/libfaad/syntax.h129
-rw-r--r--faad2/src/libfaad/tns.c309
-rw-r--r--faad2/src/libfaad/tns.h51
-rw-r--r--faad2/src/plugins/Makefile.am13
-rw-r--r--faad2/src/plugins/QCD/QCDFAAD.c1030
-rw-r--r--faad2/src/plugins/QCD/QCDFAAD.sln29
-rw-r--r--faad2/src/plugins/QCD/QCDFAAD.vcproj348
-rw-r--r--faad2/src/plugins/QCD/QCDInputDLL.h50
-rw-r--r--faad2/src/plugins/QCD/QCDModDefs.h340
-rw-r--r--faad2/src/plugins/QCD/QCDModInput.h117
-rw-r--r--faad2/src/plugins/QCD/ReadMe.txt11
-rw-r--r--faad2/src/plugins/QCD/logo.bmpbin0 -> 87614 bytes
-rw-r--r--faad2/src/plugins/QCD/plugin_dlg.rc141
-rw-r--r--faad2/src/plugins/QCD/resource.h33
-rw-r--r--faad2/src/plugins/QCDMp4/QCDInputDLL.h46
-rw-r--r--faad2/src/plugins/QCDMp4/QCDModDefs.h413
-rw-r--r--faad2/src/plugins/QCDMp4/QCDModInput.h117
-rw-r--r--faad2/src/plugins/QCDMp4/QCDModTagEditor.h84
-rw-r--r--faad2/src/plugins/QCDMp4/QCDMp4.c2992
-rw-r--r--faad2/src/plugins/QCDMp4/QCDMp4.rc191
-rw-r--r--faad2/src/plugins/QCDMp4/QCDMp4.sln35
-rw-r--r--faad2/src/plugins/QCDMp4/QCDMp4.vcproj285
-rw-r--r--faad2/src/plugins/QCDMp4/QCDMp4Tag.cpp839
-rw-r--r--faad2/src/plugins/QCDMp4/QCDTagsDLL.h14
-rw-r--r--faad2/src/plugins/QCDMp4/aac2mp4.cpp319
-rw-r--r--faad2/src/plugins/QCDMp4/aac2mp4.h42
-rw-r--r--faad2/src/plugins/QCDMp4/aacinfo.c224
-rw-r--r--faad2/src/plugins/QCDMp4/aacinfo.h46
-rw-r--r--faad2/src/plugins/QCDMp4/config.c48
-rw-r--r--faad2/src/plugins/QCDMp4/config.h42
-rw-r--r--faad2/src/plugins/QCDMp4/mbs.h81
-rw-r--r--faad2/src/plugins/QCDMp4/resource.h67
-rw-r--r--faad2/src/plugins/QCDMp4/utils.c153
-rw-r--r--faad2/src/plugins/QCDMp4/utils.h40
-rw-r--r--faad2/src/plugins/mpeg4ip/Makefile.am22
-rw-r--r--faad2/src/plugins/mpeg4ip/README_WIN32.txt11
-rw-r--r--faad2/src/plugins/mpeg4ip/aa_file.cpp130
-rw-r--r--faad2/src/plugins/mpeg4ip/aa_file.h26
-rw-r--r--faad2/src/plugins/mpeg4ip/faad2.cpp388
-rw-r--r--faad2/src/plugins/mpeg4ip/faad2.h92
-rw-r--r--faad2/src/plugins/xmms/AUTHORS3
-rw-r--r--faad2/src/plugins/xmms/ChangeLog43
-rw-r--r--faad2/src/plugins/xmms/INSTALL2
-rw-r--r--faad2/src/plugins/xmms/Makefile.am2
-rw-r--r--faad2/src/plugins/xmms/NEWS21
-rw-r--r--faad2/src/plugins/xmms/README23
-rw-r--r--faad2/src/plugins/xmms/TODO6
-rw-r--r--faad2/src/plugins/xmms/src/Makefile.am14
-rw-r--r--faad2/src/plugins/xmms/src/aac_utils.c104
-rw-r--r--faad2/src/plugins/xmms/src/libmp4.c586
-rw-r--r--faad2/src/plugins/xmms/src/mp4_utils.c469
-rw-r--r--pianobar.sln7
-rw-r--r--pianobar/pianobar.vcproj4
225 files changed, 88787 insertions, 2 deletions
diff --git a/build b/build
-Subproject cda0a797e4573c54edb268b1f05a2bdfdc29f6b
+Subproject e5bc2b6c73e45385666add67f4fea1f4ea2d1d3
diff --git a/faad2/faad2.vcproj b/faad2/faad2.vcproj
new file mode 100644
index 0000000..1fe86d2
--- /dev/null
+++ b/faad2/faad2.vcproj
@@ -0,0 +1,1284 @@
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="faad2"
+ ProjectGUID="{8F4036C9-0BD5-4373-B59E-E75E8AB72398}"
+ RootNamespace="faad2"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)build\temp\lib\"
+ IntermediateDirectory="$(SolutionDir)build\temp\obj\$(ProjectName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="$(ProjectDir)src\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS"
+ MinimalRebuild="false"
+ ExceptionHandling="0"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)\vc90.pdb"
+ WarningLevel="3"
+ DebugInformationFormat="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile="$(OutDir)\$(ProjectName)-mt-debug.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="xcopy &quot;$(ProjectDir)src\include\faad.h&quot; &quot;$(SolutionDir)build\temp\include\&quot; /I /Y /D&#x0D;&#x0A;xcopy &quot;$(ProjectDir)src\include\neaacdec.h&quot; &quot;$(SolutionDir)build\temp\include\&quot; /I /Y /D&#x0D;&#x0A;"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)build\temp\lib\"
+ IntermediateDirectory="$(SolutionDir)build\temp\obj\$(ProjectName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="0"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="$(ProjectDir)src\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS"
+ ExceptionHandling="0"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)\vc90.pdb"
+ WarningLevel="3"
+ DebugInformationFormat="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile="$(OutDir)\$(ProjectName)-mt.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="xcopy &quot;$(ProjectDir)src\include\faad.h&quot; &quot;$(SolutionDir)build\temp\include\&quot; /I /Y /D&#x0D;&#x0A;xcopy &quot;$(ProjectDir)src\include\neaacdec.h&quot; &quot;$(SolutionDir)build\temp\include\&quot; /I /Y /D&#x0D;&#x0A;"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath="src\libfaad\bits.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\cfft.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\common.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\decoder.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\drc.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\.\drm_dec.c"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\error.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\filtbank.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\hcr.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\huffman.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\ic_predict.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\is.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\lt_predict.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\mdct.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\mp4.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\ms.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\output.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\pns.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\.\ps_dec.c"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\.\ps_syntax.c"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\pulse.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\rvlc.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_dct.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_dec.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_e_nf.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_fbt.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_hfadj.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_hfgen.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_huff.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_qmf.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_syntax.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_tf_grid.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\specrec.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\ssr.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\ssr_fb.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\ssr_ipqf.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\syntax.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="src\libfaad\tns.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="2"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath="src\libfaad\analysis.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\bits.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\cfft.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\cfft_tab.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\common.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\decoder.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\drc.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\.\drm_dec.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\error.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\filtbank.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\fixed.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\huffman.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\ic_predict.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\iq_table.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\is.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\kbd_win.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\lt_predict.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\mdct.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\mp4.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\ms.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\output.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\pns.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\.\ps_dec.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\.\ps_tables.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\pulse.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\rvlc.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_dct.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_dec.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_e_nf.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_fbt.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_hfadj.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_hfgen.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_huff.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_noise.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_qmf.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_syntax.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sbr_tf_grid.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\sine_win.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\specrec.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\ssr.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\structs.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\syntax.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\tns.h"
+ >
+ </File>
+ <Filter
+ Name="codebook"
+ >
+ <File
+ RelativePath="src\libfaad\codebook\hcb_1.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_10.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_11.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_2.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_3.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_4.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_5.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_6.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_7.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_8.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_9.h"
+ >
+ </File>
+ <File
+ RelativePath="src\libfaad\codebook\hcb_sf.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/faad2/src/AUTHORS b/faad2/src/AUTHORS
new file mode 100644
index 0000000..0daddd2
--- /dev/null
+++ b/faad2/src/AUTHORS
@@ -0,0 +1,17 @@
+
+M. Bakker (mbakker(at)nero.com)
+ - complete library
+
+Alexander Kurpiers (a.kurpiers(at)nt.tu-darmstadt.de)
+ - HCR code
+ - DRM stuff
+ - lot's of bug fixes
+
+Volker Fischer (v.fischer(at)nt.tu-darmstadt.de)
+ - DRM code
+ - lot's of bug fixes
+
+Gian-Carlo Pascutto (gpascutto(at)nero.com)
+ - DRM PS code
+ - bugfixes
+ \ No newline at end of file
diff --git a/faad2/src/COPYING b/faad2/src/COPYING
new file mode 100644
index 0000000..2459c58
--- /dev/null
+++ b/faad2/src/COPYING
@@ -0,0 +1,350 @@
+
+Any non-GPL usage of this software or parts of this software is strictly
+forbidden.
+
+Commercial non-GPL licensing of this software is possible.
+For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+
+
+
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/faad2/src/ChangeLog b/faad2/src/ChangeLog
new file mode 100644
index 0000000..774ce31
--- /dev/null
+++ b/faad2/src/ChangeLog
@@ -0,0 +1,7 @@
+2009-02-02 - Version 2.7
+ * DAB+ support
+ * Use public headers internally to prevent duplicate declarations
+ * Explicitly typedef all types as signed
+ * Made sure MAIN prediction can't be started after the first frame
+ * Lot's of compilation issues solved
+ * Bugfix in SBR envelope border calculation
diff --git a/faad2/src/Makefile.am b/faad2/src/Makefile.am
new file mode 100644
index 0000000..4f58d5a
--- /dev/null
+++ b/faad2/src/Makefile.am
@@ -0,0 +1,8 @@
+SUBDIRS = libfaad common frontend plugins
+
+EXTRA_DIST = faad2.spec
+
+rpm: Makefile
+ make dist
+ $(RPMBUILD) -ta $(PACKAGE)-$(VERSION).tar.gz
+ rm $(PACKAGE)-$(VERSION).tar.gz
diff --git a/faad2/src/NEWS b/faad2/src/NEWS
new file mode 100644
index 0000000..f557d63
--- /dev/null
+++ b/faad2/src/NEWS
@@ -0,0 +1,7 @@
+
+6 February 2004
+ - FAAD2 version 2.0 released
+
+25 July 2003
+ - Release version with SBR decoding
+
diff --git a/faad2/src/README b/faad2/src/README
new file mode 100644
index 0000000..03cb175
--- /dev/null
+++ b/faad2/src/README
@@ -0,0 +1,97 @@
+
+Freeware Advanced Audio (AAC) Decoder including SBR decoding
+http://www.audiocoding.com/
+
+FAAD2 is a HE, LC, MAIN and LTP profile, MPEG2 and MPEG-4 AAC decoder.
+FAAD2 includes code for SBR (HE AAC) decoding.
+FAAD2 is licensed under the GPL.
+
+
+__________
+COPYRIGHTS
+
+For FAAD2 the following license applies:
+
+******************************************************************************
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+******************************************************************************
+
+
+Please note that the use of this software may require the payment of
+patent royalties. You need to consider this issue before you start
+building derivative works. We are not warranting or indemnifying you in
+any way for patent royalities! YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN
+ACTIONS!
+
+
+______
+PEOPLE
+
+FAAD2 is written by:
+ - M. Bakker (mbakker(at)nero.com).
+
+
+_______________
+VERSION HISTORY
+
+Sorry, try building a ChangeLog from CVS.
+
+___________________
+DIRECTORY STRUCTURE
+
+faad2 - top level directory.
+
+ aacDECdrop - windows decoder/player with drag'n'drop functionality
+
+ common - generally used libraries and code.
+
+ faad - general common functions like filereading and streaming
+ as well as getting info from aac files.
+
+ mp4ff - Small MP4 file format library (includes tagging abilities).
+
+ frontend - command line frontend to the FAAD2 library, also supports
+ MPEG-4 file decoding.
+
+ include - inlude file for the FAAD2 library.
+
+ libfaad - the FAAD2 AAC decoder library including SBR.
+
+ codebook - Huffman codebooks
+
+ plugins - plugins for all kinds of pograms.
+
+ in_mp4 - winamp MPEG-4 AAC file input plugin.
+
+ QCD - Quintessential player AAC plugin.
+
+ QCDMp4 - Quintessential player MP4 plugin.
+
+ xmms - xmms AAC plugin
+
+ mpeg4ip - plugin for the mpeg4ip player
+
diff --git a/faad2/src/README.linux b/faad2/src/README.linux
new file mode 100644
index 0000000..fe46f90
--- /dev/null
+++ b/faad2/src/README.linux
@@ -0,0 +1,15 @@
+To compile under Linux.
+----------------------
+just run :
+
+./configure --with-mp4v2
+make
+sudo make install
+
+
+about the xmms plugin.
+---------------------
+ The xmms plugin need to be build after the install of the faad project.
+so after you have installed correctly faad (--with-xmms options) you need
+to configure and build the xmms plugin part in the plugins/xmms directory.
+Read the README and INSTALL files into the xmms directory.
diff --git a/faad2/src/TODO b/faad2/src/TODO
new file mode 100644
index 0000000..2ab6883
--- /dev/null
+++ b/faad2/src/TODO
@@ -0,0 +1,2 @@
+
+- Not much...
diff --git a/faad2/src/aacDECdrop/Script.rc b/faad2/src/aacDECdrop/Script.rc
new file mode 100644
index 0000000..d771f73
--- /dev/null
+++ b/faad2/src/aacDECdrop/Script.rc
@@ -0,0 +1,214 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_TF01 BITMAP "resource/AAC01.bmp"
+IDB_TF02 BITMAP "resource/AAC02.bmp"
+IDB_TF03 BITMAP "resource/AAC03.bmp"
+IDB_TF04 BITMAP "resource/AAC04.bmp"
+IDB_TF05 BITMAP "resource/AAC05.bmp"
+IDB_TF06 BITMAP "resource/AAC06.bmp"
+IDB_TF07 BITMAP "resource/AAC07.bmp"
+IDB_TF08 BITMAP "resource/AAC08.bmp"
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""winres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_MENU1 MENU
+BEGIN
+ POPUP "Menu"
+ BEGIN
+ MENUITEM "&Decoder Options", IDM_VOLUME
+ MENUITEM "&Stop Decoding", IDM_STOP_DEC
+ MENUITEM "&About", IDM_ABOUT
+ 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 "resource/AAC01.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_VOLUME DIALOGEX 0, 0, 255, 257
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Decoder Options V1.2"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+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 |
+ WS_DISABLED,125,45,65,10
+ CONTROL "Sun/NeXT AU",IDC_SUNAU,"Button",BS_AUTORADIOBUTTON |
+ WS_DISABLED,15,60,65,10
+ CONTROL "DEC AU",IDC_DECAU,"Button",BS_AUTORADIOBUTTON |
+ WS_DISABLED,125,60,65,10
+ GROUPBOX "Output Sample Format Settings",IDC_STATIC,7,82,241,91
+ 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
+ CONTROL "16 bit PCM - Dithered",IDC_16BIT_DITHER,"Button",
+ BS_AUTORADIOBUTTON,15,126,83,10
+ CONTROL "16 bit PCM - Dithered with",IDC_16BIT_L_SHAPE,"Button",
+ BS_AUTORADIOBUTTON,125,126,98,10
+ CONTROL "16 bit PCM - Dithered with",IDC_16BIT_M_SHAPE,"Button",
+ BS_AUTORADIOBUTTON,15,146,98,10
+ CONTROL "16 bit PCM - Dithered with",IDC_16BIT_H_SHAPE,"Button",
+ BS_AUTORADIOBUTTON,125,146,98,10
+ LTEXT "LIGHT Noise Shaping",IDC_STATIC,138,136,70,8
+ LTEXT "HEAVY Noise Shaping",IDC_STATIC,138,156,73,8
+ LTEXT "MEDIUM Noise Shaping",IDC_STATIC,28,156,78,8
+ GROUPBOX "Object Type Settings",IDC_STATIC,7,174,241,50
+ CONTROL "Main",IDC_MAIN,"Button",BS_AUTORADIOBUTTON | WS_GROUP,
+ 15,188,65,10
+ CONTROL "Low Complexity",IDC_LC,"Button",BS_AUTORADIOBUTTON,125,
+ 188,65,10
+ CONTROL "Long Term Prediction",IDC_LTP,"Button",
+ BS_AUTORADIOBUTTON,15,203,85,10
+ CONTROL "Low Delay",IDC_LD,"Button",BS_AUTORADIOBUTTON,125,203,
+ 65,10
+ DEFPUSHBUTTON "Accept",IDC_BUTTON1,102,233,50,16
+END
+
+IDD_ABOUT DIALOGEX 0, 0, 255, 194
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "About aacDECdrop V1.22"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+ GROUPBOX "",IDC_STATIC,7,5,241,157
+ CTEXT "A decoder to decode/playback aac/Mpeg4 files.",
+ IDC_STATIC,70,13,155,8
+ CTEXT "Copyright 2002 John Edwards.",IDC_STATIC,70,30,97,8
+ CTEXT "Utilises standard libfaad2 from Menno Bakker.",
+ IDC_STATIC,70,46,145,8
+ LTEXT "This program is free software; you can redistribute it and/or modify it",
+ IDC_STATIC,13,62,212,8
+ LTEXT "under the terms of the GNU Public Licence as published by the Free",
+ IDC_STATIC,13,72,215,8
+ LTEXT "Software Foundation; either version 2 of the Licence, or (at your option)",
+ IDC_STATIC,13,82,224,8
+ LTEXT "any later version.",IDC_STATIC,13,92,54,8
+ LTEXT "This program is distributed in the hope that it will be useful, but",
+ IDC_STATIC,13,112,195,8
+ LTEXT "WITHOUT ANY WARRANTY; without even the implied warranty of",
+ IDC_STATIC,13,122,213,8
+ LTEXT "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.",
+ IDC_STATIC,13,132,218,8
+ LTEXT "See the GNU General Public Licence for more details.",
+ IDC_STATIC,13,142,170,8
+ DEFPUSHBUTTON "OK",IDC_BUTTON6,102,171,50,16
+ CONTROL 112,IDC_STATIC,"Static",SS_BITMAP | SS_SUNKEN,12,13,43,
+ 40
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_VOLUME, DIALOG
+ BEGIN
+ BOTTOMMARGIN, 256
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/faad2/src/aacDECdrop/aacDECdrop/aacDECdrop.sln b/faad2/src/aacDECdrop/aacDECdrop/aacDECdrop.sln
new file mode 100644
index 0000000..47a5572
--- /dev/null
+++ b/faad2/src/aacDECdrop/aacDECdrop/aacDECdrop.sln
@@ -0,0 +1,33 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual C++ Express 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aacDECdrop", "aacDECdrop.vcproj", "{C23A88D7-4997-4026-BBDB-5B0B2B22FDFF}"
+ ProjectSection(ProjectDependencies) = postProject
+ {F470BB4A-7675-4D6A-B310-41F33AC6F987} = {F470BB4A-7675-4D6A-B310-41F33AC6F987}
+ {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114} = {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaad", "..\..\libfaad\libfaad.vcproj", "{BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4ff", "..\..\common\mp4ff\mp4ff.vcproj", "{F470BB4A-7675-4D6A-B310-41F33AC6F987}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C23A88D7-4997-4026-BBDB-5B0B2B22FDFF}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C23A88D7-4997-4026-BBDB-5B0B2B22FDFF}.Debug|Win32.Build.0 = Debug|Win32
+ {C23A88D7-4997-4026-BBDB-5B0B2B22FDFF}.Release|Win32.ActiveCfg = Release|Win32
+ {C23A88D7-4997-4026-BBDB-5B0B2B22FDFF}.Release|Win32.Build.0 = Release|Win32
+ {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}.Debug|Win32.ActiveCfg = Debug|Win32
+ {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}.Release|Win32.ActiveCfg = Release|Win32
+ {F470BB4A-7675-4D6A-B310-41F33AC6F987}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F470BB4A-7675-4D6A-B310-41F33AC6F987}.Debug|Win32.Build.0 = Debug|Win32
+ {F470BB4A-7675-4D6A-B310-41F33AC6F987}.Release|Win32.ActiveCfg = Release|Win32
+ {F470BB4A-7675-4D6A-B310-41F33AC6F987}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/faad2/src/aacDECdrop/aacDECdrop/aacDECdrop.vcproj b/faad2/src/aacDECdrop/aacDECdrop/aacDECdrop.vcproj
new file mode 100644
index 0000000..6487e15
--- /dev/null
+++ b/faad2/src/aacDECdrop/aacDECdrop/aacDECdrop.vcproj
@@ -0,0 +1,335 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="aacDECdrop"
+ ProjectGUID="{C23A88D7-4997-4026-BBDB-5B0B2B22FDFF}"
+ RootNamespace="aacDECdrop"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/aacDECdrop.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="..\..\include;..\..\common\mp4ff"
+ PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
+ StringPooling="true"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderFile=".\Release/aacDECdrop.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="2057"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="advapi32.lib shell32.lib gdi32.lib odbc32.lib odbccp32.lib winmm.lib ws2_32.lib user32.lib"
+ OutputFile=".\Release/aacDECdrop.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ IgnoreDefaultLibraryNames=""
+ ProgramDatabaseFile=".\Release/aacDECdrop.pdb"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ Description="Compressing using UPX..."
+ CommandLine="upx --best .\release\aacDECdrop.exe"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/aacDECdrop.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include;..\..\common\mp4ff"
+ PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderFile=".\Debug/aacDECdrop.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="2057"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="advapi32.lib shell32.lib gdi32.lib odbc32.lib odbccp32.lib winmm.lib ws2_32.lib user32.lib"
+ OutputFile=".\Debug/aacDECdrop.exe"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/aacDECdrop.pdb"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath="..\audio.c"
+ >
+ </File>
+ <File
+ RelativePath="..\decode.c"
+ >
+ </File>
+ <File
+ RelativePath="..\decthread.c"
+ >
+ </File>
+ <File
+ RelativePath="..\main.c"
+ >
+ </File>
+ <File
+ RelativePath="..\misc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\wave_out.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath="..\audio.h"
+ >
+ </File>
+ <File
+ RelativePath="..\decode.h"
+ >
+ </File>
+ <File
+ RelativePath="..\decthread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\misc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\resource.h"
+ >
+ </File>
+ <File
+ RelativePath="..\wave_out.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ <File
+ RelativePath="..\resource\AAC01.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\resource\AAC01.ico"
+ >
+ </File>
+ <File
+ RelativePath="..\resource\AAC02.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\resource\AAC03.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\resource\AAC04.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\resource\AAC05.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\resource\AAC06.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\resource\AAC07.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\resource\AAC08.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\Script.rc"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="\aac\cvsrep\faad2\aacDECdrop;$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="\aac\cvsrep\faad2\aacDECdrop;$(NoInherit)"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/faad2/src/aacDECdrop/audio.c b/faad2/src/aacDECdrop/audio.c
new file mode 100644
index 0000000..843d650
--- /dev/null
+++ b/faad2/src/aacDECdrop/audio.c
@@ -0,0 +1,494 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: audio.c,v 1.11 2004/02/06 10:23:27 menno Exp $
+**/
+
+#ifdef _WIN32
+#include <io.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <math.h>
+#include <faad.h>
+#include "audio.h"
+
+
+audio_file *open_audio_file(char *infile, int samplerate, int channels,
+ int outputFormat, int fileType, long channelMask)
+{
+ audio_file *aufile = malloc(sizeof(audio_file));
+
+ aufile->outputFormat = outputFormat;
+
+ aufile->samplerate = samplerate;
+ aufile->channels = channels;
+ aufile->total_samples = 0;
+ aufile->fileType = fileType;
+ aufile->channelMask = channelMask;
+
+ switch (outputFormat)
+ {
+ case FAAD_FMT_16BIT:
+ aufile->bits_per_sample = 16;
+ break;
+ case FAAD_FMT_24BIT:
+ aufile->bits_per_sample = 24;
+ break;
+ case FAAD_FMT_32BIT:
+ case FAAD_FMT_FLOAT:
+ aufile->bits_per_sample = 32;
+ break;
+ default:
+ if (aufile) free(aufile);
+ return NULL;
+ }
+
+ if(infile[0] == '-')
+ {
+#ifdef _WIN32
+ setmode(fileno(stdout), O_BINARY);
+#endif
+ aufile->sndfile = stdout;
+ } else {
+ aufile->sndfile = fopen(infile, "wb");
+ }
+
+ if (aufile->sndfile == NULL)
+ {
+ if (aufile) free(aufile);
+ return NULL;
+ }
+
+ if (aufile->fileType == OUTPUT_WAV)
+ {
+ if (aufile->channelMask)
+ write_wav_extensible_header(aufile, aufile->channelMask);
+ else
+ write_wav_header(aufile);
+ }
+
+ return aufile;
+}
+
+int write_audio_file(audio_file *aufile, void *sample_buffer, int samples, int offset)
+{
+ char *buf = (char *)sample_buffer;
+ switch (aufile->outputFormat)
+ {
+ case FAAD_FMT_16BIT:
+ return write_audio_16bit(aufile, buf + offset*2, samples);
+ case FAAD_FMT_24BIT:
+ return write_audio_24bit(aufile, buf + offset*4, samples);
+ case FAAD_FMT_32BIT:
+ return write_audio_32bit(aufile, buf + offset*4, samples);
+ case FAAD_FMT_FLOAT:
+ return write_audio_float(aufile, buf + offset*4, samples);
+ default:
+ return 0;
+ }
+
+ return 0;
+}
+
+void close_audio_file(audio_file *aufile)
+{
+ if (aufile->fileType == OUTPUT_WAV)
+ {
+ fseek(aufile->sndfile, 0, SEEK_SET);
+
+ if (aufile->channelMask)
+ write_wav_extensible_header(aufile, aufile->channelMask);
+ else
+ write_wav_header(aufile);
+ }
+
+ fclose(aufile->sndfile);
+
+ if (aufile) free(aufile);
+}
+
+static int write_wav_header(audio_file *aufile)
+{
+ unsigned char header[44];
+ unsigned char* p = header;
+ unsigned int bytes = (aufile->bits_per_sample + 7) / 8;
+ float data_size = (float)bytes * aufile->total_samples;
+ unsigned long word32;
+
+ *p++ = 'R'; *p++ = 'I'; *p++ = 'F'; *p++ = 'F';
+
+ word32 = (data_size + (44 - 8) < (float)MAXWAVESIZE) ?
+ (unsigned long)data_size + (44 - 8) : (unsigned long)MAXWAVESIZE;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ *p++ = 'W'; *p++ = 'A'; *p++ = 'V'; *p++ = 'E';
+
+ *p++ = 'f'; *p++ = 'm'; *p++ = 't'; *p++ = ' ';
+
+ *p++ = 0x10; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+
+ if (aufile->outputFormat == FAAD_FMT_FLOAT)
+ {
+ *p++ = 0x03; *p++ = 0x00;
+ } else {
+ *p++ = 0x01; *p++ = 0x00;
+ }
+
+ *p++ = (unsigned char)(aufile->channels >> 0);
+ *p++ = (unsigned char)(aufile->channels >> 8);
+
+ word32 = (unsigned long)(aufile->samplerate + 0.5);
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ word32 = aufile->samplerate * bytes * aufile->channels;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ word32 = bytes * aufile->channels;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 0);
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 8);
+
+ *p++ = 'd'; *p++ = 'a'; *p++ = 't'; *p++ = 'a';
+
+ word32 = data_size < MAXWAVESIZE ?
+ (unsigned long)data_size : (unsigned long)MAXWAVESIZE;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ return fwrite(header, sizeof(header), 1, aufile->sndfile);
+}
+
+static int write_wav_extensible_header(audio_file *aufile, long channelMask)
+{
+ unsigned char header[68];
+ unsigned char* p = header;
+ unsigned int bytes = (aufile->bits_per_sample + 7) / 8;
+ float data_size = (float)bytes * aufile->total_samples;
+ unsigned long word32;
+
+ *p++ = 'R'; *p++ = 'I'; *p++ = 'F'; *p++ = 'F';
+
+ word32 = (data_size + (68 - 8) < (float)MAXWAVESIZE) ?
+ (unsigned long)data_size + (68 - 8) : (unsigned long)MAXWAVESIZE;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ *p++ = 'W'; *p++ = 'A'; *p++ = 'V'; *p++ = 'E';
+
+ *p++ = 'f'; *p++ = 'm'; *p++ = 't'; *p++ = ' ';
+
+ *p++ = /*0x10*/0x28; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+
+ /* WAVE_FORMAT_EXTENSIBLE */
+ *p++ = 0xFE; *p++ = 0xFF;
+
+ *p++ = (unsigned char)(aufile->channels >> 0);
+ *p++ = (unsigned char)(aufile->channels >> 8);
+
+ word32 = (unsigned long)(aufile->samplerate + 0.5);
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ word32 = aufile->samplerate * bytes * aufile->channels;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ word32 = bytes * aufile->channels;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 0);
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 8);
+
+ /* cbSize */
+ *p++ = (unsigned char)(22);
+ *p++ = (unsigned char)(0);
+
+ /* WAVEFORMATEXTENSIBLE */
+
+ /* wValidBitsPerSample */
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 0);
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 8);
+
+ /* dwChannelMask */
+ word32 = channelMask;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ /* SubFormat */
+ if (aufile->outputFormat == FAAD_FMT_FLOAT)
+ {
+ /* KSDATAFORMAT_SUBTYPE_IEEE_FLOAT: 00000003-0000-0010-8000-00aa00389b71 */
+ *p++ = 0x03;
+ *p++ = 0x00;
+ *p++ = 0x00;
+ *p++ = 0x00;
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x10; *p++ = 0x00; *p++ = 0x80; *p++ = 0x00;
+ *p++ = 0x00; *p++ = 0xaa; *p++ = 0x00; *p++ = 0x38; *p++ = 0x9b; *p++ = 0x71;
+ } else {
+ /* KSDATAFORMAT_SUBTYPE_PCM: 00000001-0000-0010-8000-00aa00389b71 */
+ *p++ = 0x01;
+ *p++ = 0x00;
+ *p++ = 0x00;
+ *p++ = 0x00;
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x10; *p++ = 0x00; *p++ = 0x80; *p++ = 0x00;
+ *p++ = 0x00; *p++ = 0xaa; *p++ = 0x00; *p++ = 0x38; *p++ = 0x9b; *p++ = 0x71;
+ }
+
+ /* end WAVEFORMATEXTENSIBLE */
+
+ *p++ = 'd'; *p++ = 'a'; *p++ = 't'; *p++ = 'a';
+
+ word32 = data_size < MAXWAVESIZE ?
+ (unsigned long)data_size : (unsigned long)MAXWAVESIZE;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ return fwrite(header, sizeof(header), 1, aufile->sndfile);
+}
+
+static int write_audio_16bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples)
+{
+ int ret;
+ unsigned int i;
+ short *sample_buffer16 = (short*)sample_buffer;
+ char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
+
+ aufile->total_samples += samples;
+
+ if (aufile->channels == 6 && aufile->channelMask)
+ {
+ for (i = 0; i < samples; i += aufile->channels)
+ {
+ short r1, r2, r3, r4, r5, r6;
+ r1 = sample_buffer16[i];
+ r2 = sample_buffer16[i+1];
+ r3 = sample_buffer16[i+2];
+ r4 = sample_buffer16[i+3];
+ r5 = sample_buffer16[i+4];
+ r6 = sample_buffer16[i+5];
+ sample_buffer16[i] = r2;
+ sample_buffer16[i+1] = r3;
+ sample_buffer16[i+2] = r1;
+ sample_buffer16[i+3] = r6;
+ sample_buffer16[i+4] = r4;
+ sample_buffer16[i+5] = r5;
+ }
+ }
+
+ for (i = 0; i < samples; i++)
+ {
+ data[i*2] = (char)(sample_buffer16[i] & 0xFF);
+ data[i*2+1] = (char)((sample_buffer16[i] >> 8) & 0xFF);
+ }
+
+ ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
+
+ if (data) free(data);
+
+ return ret;
+}
+
+static int write_audio_24bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples)
+{
+ int ret;
+ unsigned int i;
+ long *sample_buffer24 = (long*)sample_buffer;
+ char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
+
+ aufile->total_samples += samples;
+
+ if (aufile->channels == 6 && aufile->channelMask)
+ {
+ for (i = 0; i < samples; i += aufile->channels)
+ {
+ long r1, r2, r3, r4, r5, r6;
+ r1 = sample_buffer24[i];
+ r2 = sample_buffer24[i+1];
+ r3 = sample_buffer24[i+2];
+ r4 = sample_buffer24[i+3];
+ r5 = sample_buffer24[i+4];
+ r6 = sample_buffer24[i+5];
+ sample_buffer24[i] = r2;
+ sample_buffer24[i+1] = r3;
+ sample_buffer24[i+2] = r1;
+ sample_buffer24[i+3] = r6;
+ sample_buffer24[i+4] = r4;
+ sample_buffer24[i+5] = r5;
+ }
+ }
+
+ for (i = 0; i < samples; i++)
+ {
+ data[i*3] = (char)(sample_buffer24[i] & 0xFF);
+ data[i*3+1] = (char)((sample_buffer24[i] >> 8) & 0xFF);
+ data[i*3+2] = (char)((sample_buffer24[i] >> 16) & 0xFF);
+ }
+
+ ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
+
+ if (data) free(data);
+
+ return ret;
+}
+
+static int write_audio_32bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples)
+{
+ int ret;
+ unsigned int i;
+ long *sample_buffer32 = (long*)sample_buffer;
+ char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
+
+ aufile->total_samples += samples;
+
+ if (aufile->channels == 6 && aufile->channelMask)
+ {
+ for (i = 0; i < samples; i += aufile->channels)
+ {
+ long r1, r2, r3, r4, r5, r6;
+ r1 = sample_buffer32[i];
+ r2 = sample_buffer32[i+1];
+ r3 = sample_buffer32[i+2];
+ r4 = sample_buffer32[i+3];
+ r5 = sample_buffer32[i+4];
+ r6 = sample_buffer32[i+5];
+ sample_buffer32[i] = r2;
+ sample_buffer32[i+1] = r3;
+ sample_buffer32[i+2] = r1;
+ sample_buffer32[i+3] = r6;
+ sample_buffer32[i+4] = r4;
+ sample_buffer32[i+5] = r5;
+ }
+ }
+
+ for (i = 0; i < samples; i++)
+ {
+ data[i*4] = (char)(sample_buffer32[i] & 0xFF);
+ data[i*4+1] = (char)((sample_buffer32[i] >> 8) & 0xFF);
+ data[i*4+2] = (char)((sample_buffer32[i] >> 16) & 0xFF);
+ data[i*4+3] = (char)((sample_buffer32[i] >> 24) & 0xFF);
+ }
+
+ ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
+
+ if (data) free(data);
+
+ return ret;
+}
+
+static int write_audio_float(audio_file *aufile, void *sample_buffer,
+ unsigned int samples)
+{
+ int ret;
+ unsigned int i;
+ float *sample_buffer_f = (float*)sample_buffer;
+ unsigned char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
+
+ aufile->total_samples += samples;
+
+ if (aufile->channels == 6 && aufile->channelMask)
+ {
+ for (i = 0; i < samples; i += aufile->channels)
+ {
+ float r1, r2, r3, r4, r5, r6;
+ r1 = sample_buffer_f[i];
+ r2 = sample_buffer_f[i+1];
+ r3 = sample_buffer_f[i+2];
+ r4 = sample_buffer_f[i+3];
+ r5 = sample_buffer_f[i+4];
+ r6 = sample_buffer_f[i+5];
+ sample_buffer_f[i] = r2;
+ sample_buffer_f[i+1] = r3;
+ sample_buffer_f[i+2] = r1;
+ sample_buffer_f[i+3] = r6;
+ sample_buffer_f[i+4] = r4;
+ sample_buffer_f[i+5] = r5;
+ }
+ }
+
+ for (i = 0; i < samples; i++)
+ {
+ int exponent, mantissa, negative = 0 ;
+ float in = sample_buffer_f[i];
+
+ data[i*4] = 0; data[i*4+1] = 0; data[i*4+2] = 0; data[i*4+3] = 0;
+ if (in == 0.0)
+ continue;
+
+ if (in < 0.0)
+ {
+ in *= -1.0;
+ negative = 1;
+ }
+ in = (float)frexp(in, &exponent);
+ exponent += 126;
+ in *= (float)0x1000000;
+ mantissa = (((int)in) & 0x7FFFFF);
+
+ if (negative)
+ data[i*4+3] |= 0x80;
+
+ if (exponent & 0x01)
+ data[i*4+2] |= 0x80;
+
+ data[i*4] = mantissa & 0xFF;
+ data[i*4+1] = (mantissa >> 8) & 0xFF;
+ data[i*4+2] |= (mantissa >> 16) & 0x7F;
+ data[i*4+3] |= (exponent >> 1) & 0x7F;
+ }
+
+ ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
+
+ if (data) free(data);
+
+ return ret;
+}
diff --git a/faad2/src/aacDECdrop/audio.h b/faad2/src/aacDECdrop/audio.h
new file mode 100644
index 0000000..941c6ec
--- /dev/null
+++ b/faad2/src/aacDECdrop/audio.h
@@ -0,0 +1,71 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: audio.h,v 1.9 2004/02/06 10:23:27 menno Exp $
+**/
+
+#ifndef AUDIO_H_INCLUDED
+#define AUDIO_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAXWAVESIZE 4294967040LU
+
+#define OUTPUT_WAV 1
+#define OUTPUT_RAW 2
+
+typedef struct
+{
+ int outputFormat;
+ FILE *sndfile;
+ unsigned int fileType;
+ unsigned long samplerate;
+ unsigned int bits_per_sample;
+ unsigned int channels;
+ unsigned long total_samples;
+ long channelMask;
+} audio_file;
+
+audio_file *open_audio_file(char *infile, int samplerate, int channels,
+ int outputFormat, int fileType, long channelMask);
+int write_audio_file(audio_file *aufile, void *sample_buffer, int samples, int offset);
+void close_audio_file(audio_file *aufile);
+static int write_wav_header(audio_file *aufile);
+static int write_wav_extensible_header(audio_file *aufile, long channelMask);
+static int write_audio_16bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples);
+static int write_audio_24bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples);
+static int write_audio_32bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples);
+static int write_audio_float(audio_file *aufile, void *sample_buffer,
+ unsigned int samples);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/faad2/src/aacDECdrop/decode.c b/faad2/src/aacDECdrop/decode.c
new file mode 100644
index 0000000..8eca01c
--- /dev/null
+++ b/faad2/src/aacDECdrop/decode.c
@@ -0,0 +1,566 @@
+/*
+** 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.16 2004/04/03 19:08:37 menno Exp $
+** $Id: decode.c,v 1.16 2004/04/03 19:08:37 menno Exp $
+**/
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#define off_t __int64
+#else
+#include <time.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <neaacdec.h>
+#include <mp4ff.h>
+
+#include "audio.h"
+#include "decode.h"
+#include "misc.h"
+#include "wave_out.h"
+
+#ifndef min
+#define min(a,b) ( (a) < (b) ? (a) : (b) )
+#endif
+
+#define MAX_CHANNELS 8 /* 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; \
+ unsigned int bytes_in_buffer = 0;
+
+/* 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); \
+ bytes_in_buffer = 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; \
+ bytes_in_buffer = 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]; \
+ bytes_in_buffer += fread(buffer + (FAAD_MIN_STREAMSIZE*MAX_CHANNELS) - bytesconsumed, 1, bytesconsumed, infile); \
+ bytesconsumed = 0; \
+ }
+
+/* update buffer indices after NeAACDecDecode */
+#define UPDATE_BUFF_IDX(frame) \
+ bytesconsumed += frame.bytesconsumed; \
+ buffer_index += frame.bytesconsumed; \
+ bytes_in_buffer -= 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;
+extern int stop_decoding;
+
+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
+};
+
+/* MicroSoft channel definitions */
+#define SPEAKER_FRONT_LEFT 0x1
+#define SPEAKER_FRONT_RIGHT 0x2
+#define SPEAKER_FRONT_CENTER 0x4
+#define SPEAKER_LOW_FREQUENCY 0x8
+#define SPEAKER_BACK_LEFT 0x10
+#define SPEAKER_BACK_RIGHT 0x20
+#define SPEAKER_FRONT_LEFT_OF_CENTER 0x40
+#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
+#define SPEAKER_BACK_CENTER 0x100
+#define SPEAKER_SIDE_LEFT 0x200
+#define SPEAKER_SIDE_RIGHT 0x400
+#define SPEAKER_TOP_CENTER 0x800
+#define SPEAKER_TOP_FRONT_LEFT 0x1000
+#define SPEAKER_TOP_FRONT_CENTER 0x2000
+#define SPEAKER_TOP_FRONT_RIGHT 0x4000
+#define SPEAKER_TOP_BACK_LEFT 0x8000
+#define SPEAKER_TOP_BACK_CENTER 0x10000
+#define SPEAKER_TOP_BACK_RIGHT 0x20000
+#define SPEAKER_RESERVED 0x80000000
+
+long aacChannelConfig2wavexChannelMask(NeAACDecFrameInfo *hInfo)
+{
+ if (hInfo->channels == 6 && hInfo->num_lfe_channels)
+ {
+ return SPEAKER_FRONT_LEFT + SPEAKER_FRONT_RIGHT +
+ SPEAKER_FRONT_CENTER + SPEAKER_LOW_FREQUENCY +
+ SPEAKER_BACK_LEFT + SPEAKER_BACK_RIGHT;
+ } else {
+ return 0;
+ }
+}
+
+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;
+
+ NeAACDecHandle hDecoder;
+ NeAACDecFrameInfo frameInfo;
+ NeAACDecConfigurationPtr config;
+
+ int first_time = 1;
+
+
+ /* 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 = NeAACDecOpen();
+
+ /* Set the default object type and samplerate */
+ /* This is useful for RAW AAC files */
+ config = NeAACDecGetCurrentConfiguration(hDecoder);
+ if (def_srate)
+ config->defSampleRate = def_srate;
+ config->defObjectType = opt->object_type;
+ config->outputFormat = opt->output_format;
+
+ NeAACDecSetConfiguration(hDecoder, config);
+
+ if ((bytesconsumed = NeAACDecInit(hDecoder, buffer, bytes_in_buffer,
+ &samplerate, &channels)) < 0)
+ {
+ /* If some error initializing occured, skip the file */
+ error_handler("Error initializing decoder library.\n");
+ END_BUFF
+ NeAACDecClose(hDecoder);
+ fclose(infile);
+ return 1;
+ }
+ buffer_index += bytesconsumed;
+
+ do
+ {
+ /* update buffer */
+ UPDATE_BUFF_READ
+
+ sample_buffer = NeAACDecDecode(hDecoder, &frameInfo, buffer, bytes_in_buffer);
+
+ /* update buffer indices */
+ UPDATE_BUFF_IDX(frameInfo)
+
+ if (frameInfo.error > 0)
+ {
+ error_handler("Error: %s\n",
+ NeAACDecGetErrorMessage(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
+ NeAACDecClose(hDecoder);
+ fclose(infile);
+ return (0);
+ }
+ }
+ else
+ {
+ aufile = open_audio_file(sndfile, samplerate, frameInfo.channels,
+ opt->output_format, opt->file_type, aacChannelConfig2wavexChannelMask(&frameInfo));
+
+ if (aufile == NULL)
+ {
+ END_BUFF
+ NeAACDecClose(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, 0);
+ }
+
+ if (buffer_index >= fileread)
+ sample_buffer = NULL; /* to make sure it stops now */
+
+ if(stop_decoding)
+ break;
+
+ } while (sample_buffer != NULL);
+
+ NeAACDecClose(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(mp4ff_t *infile)
+{
+ /* find AAC track */
+ int i, rc;
+ int numTracks = mp4ff_total_tracks(infile);
+
+ for (i = 0; i < numTracks; i++)
+ {
+ unsigned char *buff = NULL;
+ int buff_size = 0;
+ mp4AudioSpecificConfig mp4ASC;
+
+ mp4ff_get_decoder_config(infile, i, &buff, &buff_size);
+
+ if (buff)
+ {
+ rc = NeAACDecAudioSpecificConfig(buff, buff_size, &mp4ASC);
+ free(buff);
+
+ if (rc < 0)
+ continue;
+ return i;
+ }
+ }
+
+ /* can't decode this */
+ return -1;
+}
+
+unsigned long srates[] =
+{
+ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000,
+ 12000, 11025, 8000
+};
+
+uint32_t read_callback(void *user_data, void *buffer, uint32_t length)
+{
+ return fread(buffer, 1, length, (FILE*)user_data);
+}
+
+uint32_t seek_callback(void *user_data, uint64_t position)
+{
+ return fseek((FILE*)user_data, position, SEEK_SET);
+}
+
+int decodeMP4file(char *sndfile, aac_dec_opt *opt)
+{
+ int track;
+ unsigned long samplerate;
+ unsigned char channels;
+ void *sample_buffer;
+
+ mp4ff_t *infile;
+ FILE *mp4File;
+ int sampleId, numSamples;
+
+ audio_file *aufile;
+
+ NeAACDecHandle hDecoder;
+ NeAACDecFrameInfo frameInfo;
+
+ unsigned char *buffer;
+ int buffer_size;
+
+ int first_time = 1;
+
+ /* initialise the callback structure */
+ mp4ff_callback_t *mp4cb = malloc(sizeof(mp4ff_callback_t));
+
+ mp4File = fopen(opt->filename, "rb");
+ mp4cb->read = read_callback;
+ mp4cb->seek = seek_callback;
+ mp4cb->user_data = mp4File;
+
+ infile = mp4ff_open_read(mp4cb);
+ 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");
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+ return 1;
+ }
+
+ buffer = NULL;
+ buffer_size = 0;
+ mp4ff_get_decoder_config(infile, track, &buffer, &buffer_size);
+
+ hDecoder = NeAACDecOpen();
+
+ if(NeAACDecInit2(hDecoder, buffer, buffer_size, &samplerate, &channels) < 0)
+ {
+ /* If some error initializing occured, skip the file */
+ error_handler("Error initializing decoder library.\n");
+ NeAACDecClose(hDecoder);
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+ return 1;
+ }
+ if (buffer)
+ free(buffer);
+
+ numSamples = mp4ff_num_samples(infile, track);
+
+ for (sampleId = 0; sampleId < numSamples; sampleId++)
+ {
+ int rc;
+
+ /* get access unit from MP4 file */
+ buffer = NULL;
+ buffer_size = 0;
+
+ rc = mp4ff_read_sample(infile, track, sampleId, &buffer, &buffer_size);
+ if (rc == 0)
+ {
+ error_handler("Reading from MP4 file failed.\n");
+ NeAACDecClose(hDecoder);
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+ return 1;
+ }
+
+ sample_buffer = NeAACDecDecode(hDecoder, &frameInfo, buffer, buffer_size);
+
+ 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");
+ NeAACDecClose(hDecoder);
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+ return (0);
+ }
+ }
+ else
+ {
+ aufile = open_audio_file(sndfile, samplerate, frameInfo.channels,
+ opt->output_format, opt->file_type, aacChannelConfig2wavexChannelMask(&frameInfo));
+
+ if (aufile == NULL)
+ {
+ NeAACDecClose(hDecoder);
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+ 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, 0);
+ }
+
+ if (frameInfo.error > 0)
+ {
+ error_handler("Error: %s\n",
+ NeAACDecGetErrorMessage(frameInfo.error));
+ break;
+ }
+ if(stop_decoding)
+ break;
+ }
+
+
+ NeAACDecClose(hDecoder);
+
+
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+
+ 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];
+ unsigned char header[8];
+ FILE *hMP4File;
+
+
+ /* 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]);
+
+ mp4file = 0;
+ hMP4File = fopen(opt->filename, "rb");
+ if (!hMP4File)
+ {
+ return 1;
+ }
+ fread(header, 1, 8, hMP4File);
+ fclose(hMP4File);
+ if (header[4] == 'f' && header[5] == 't' && header[6] == 'y' && header[7] == 'p')
+ mp4file = 1;
+
+ if (mp4file)
+ {
+ result = decodeMP4file(audioFileName, opt);
+ }
+ else
+ {
+ result = decodeAACfile(audioFileName, def_srate, opt);
+ }
+
+ return 0;
+}
diff --git a/faad2/src/aacDECdrop/decode.h b/faad2/src/aacDECdrop/decode.h
new file mode 100644
index 0000000..fda27a0
--- /dev/null
+++ b/faad2/src/aacDECdrop/decode.h
@@ -0,0 +1,55 @@
+/*
+ * 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 void (*error_func)(char *errormessage);
+
+typedef struct
+{
+ progress_func progress_update;
+ error_func error;
+ 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__ */
diff --git a/faad2/src/aacDECdrop/decthread.c b/faad2/src/aacDECdrop/decthread.c
new file mode 100644
index 0000000..7ffc3dc
--- /dev/null
+++ b/faad2/src/aacDECdrop/decthread.c
@@ -0,0 +1,194 @@
+/*
+ * 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;
+int stop_decoding;
+
+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 _error(char *errormessage)
+{
+ // do nothing
+}
+
+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;
+
+ if(stop_decoding){
+ numfiles--;
+ break;
+ }
+ 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 ********************************/
+
diff --git a/faad2/src/aacDECdrop/decthread.h b/faad2/src/aacDECdrop/decthread.h
new file mode 100644
index 0000000..90ef374
--- /dev/null
+++ b/faad2/src/aacDECdrop/decthread.h
@@ -0,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__ */
diff --git a/faad2/src/aacDECdrop/main.c b/faad2/src/aacDECdrop/main.c
new file mode 100644
index 0000000..ca5f0c4
--- /dev/null
+++ b/faad2/src/aacDECdrop/main.c
@@ -0,0 +1,678 @@
+/*
+ * 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;
+int stop_decoding = 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 ||
+ stricmp(ext, ".m4a") == 0 || stricmp(ext, ".m4p") == 0)
+ {
+ flag = 1;
+ decthread_addfile(szFile);
+ stop_decoding = 0;
+ }
+ }
+ }
+
+ 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_STOP_DEC:
+ {
+ int v = ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED;
+ if(v == 8)
+ stop_decoding = 1;
+ break;
+ }
+ case IDM_VOLUME:
+ {
+ int value =
+ DialogBox(
+ hinst,
+ MAKEINTRESOURCE(IDD_VOLUME),
+ hwnd, QCProc);
+
+ if (value == -2)
+ break;
+ break;
+ }
+ case IDM_ABOUT:
+ {
+ int value = DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUT), hwnd, QCProc);
+ if (value == -7)
+ break;
+ 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_WAV,TRUE);
+ if(iniSettings.outputFormat != 1
+ && iniSettings.outputFormat != 5
+ && iniSettings.outputFormat != 6
+ && iniSettings.outputFormat != 7
+ && iniSettings.outputFormat != 8)
+ CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
+ else if(iniSettings.outputFormat == 1)
+ CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
+ else if(iniSettings.outputFormat == 5)
+ CheckDlgButton(hwndDlg,IDC_16BIT_DITHER,TRUE);
+ else if(iniSettings.outputFormat == 6)
+ CheckDlgButton(hwndDlg,IDC_16BIT_L_SHAPE,TRUE);
+ else if(iniSettings.outputFormat == 7)
+ CheckDlgButton(hwndDlg,IDC_16BIT_M_SHAPE,TRUE);
+ else if(iniSettings.outputFormat == 8)
+ CheckDlgButton(hwndDlg,IDC_16BIT_H_SHAPE,TRUE);
+ CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_AIFF), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SUNAU), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DECAU), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_24BIT), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_32BIT), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FLOATS), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_DITHER), TRUE);
+ }
+ else if(iniSettings.decode_mode == 1)
+ {
+ CheckDlgButton(hwndDlg,IDC_PLAYBACK,FALSE);
+ if(iniSettings.outputFormat == 1)
+ CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
+ else if(iniSettings.outputFormat == 2)
+ CheckDlgButton(hwndDlg,IDC_24BIT,TRUE);
+ else if(iniSettings.outputFormat == 3)
+ CheckDlgButton(hwndDlg,IDC_32BIT,TRUE);
+ else if(iniSettings.outputFormat == 4)
+ CheckDlgButton(hwndDlg,IDC_FLOATS,TRUE);
+ else if(iniSettings.outputFormat == 5)
+ CheckDlgButton(hwndDlg,IDC_16BIT_DITHER,TRUE);
+ else if(iniSettings.outputFormat == 6)
+ CheckDlgButton(hwndDlg,IDC_16BIT_L_SHAPE,TRUE);
+ else if(iniSettings.outputFormat == 7)
+ CheckDlgButton(hwndDlg,IDC_16BIT_M_SHAPE,TRUE);
+ else if(iniSettings.outputFormat == 8)
+ CheckDlgButton(hwndDlg,IDC_16BIT_H_SHAPE,TRUE);
+
+ if(iniSettings.fileType == 1)
+ CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
+ else if(iniSettings.fileType == 2)
+ CheckDlgButton(hwndDlg,IDC_AIFF,TRUE);
+ else if(iniSettings.fileType == 3)
+ CheckDlgButton(hwndDlg,IDC_SUNAU,TRUE);
+ else if(iniSettings.fileType == 4)
+ CheckDlgButton(hwndDlg,IDC_DECAU,TRUE);
+ }
+
+ if(iniSettings.object_type == 0)
+ CheckDlgButton(hwndDlg,IDC_MAIN,TRUE);
+ else if(iniSettings.object_type == 1)
+ CheckDlgButton(hwndDlg,IDC_LC,TRUE);
+ else if(iniSettings.object_type == 3)
+ CheckDlgButton(hwndDlg,IDC_LTP,TRUE);
+ else if(iniSettings.object_type == 23)
+ 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
+ else if (IsDlgButtonChecked(hwndDlg, IDC_16BIT_DITHER) == BST_CHECKED)
+ set_outputFormat(5); // 16 bit PCM dithered
+ else if (IsDlgButtonChecked(hwndDlg, IDC_16BIT_L_SHAPE) == BST_CHECKED)
+ set_outputFormat(6); // dithered LIGHT noise shaping
+ else if (IsDlgButtonChecked(hwndDlg, IDC_16BIT_M_SHAPE) == BST_CHECKED)
+ set_outputFormat(7); // dithered MEDIUM noise shaping
+ else if (IsDlgButtonChecked(hwndDlg, IDC_16BIT_H_SHAPE) == BST_CHECKED)
+ set_outputFormat(8); // dithered HEAVY noise shaping
+
+ 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
+
+ EndDialog(hwndDlg, -2);
+ return TRUE;
+ }
+ case IDC_BUTTON6:
+ EndDialog(hwndDlg, -7);
+ return TRUE;
+
+ case IDC_PLAYBACK:
+ CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_AIFF), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SUNAU), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DECAU), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_24BIT), FALSE);
+ CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_32BIT), FALSE);
+ CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FLOATS), FALSE);
+ CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_DITHER), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_L_SHAPE), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_M_SHAPE), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_H_SHAPE), TRUE);
+ if (IsDlgButtonChecked(hwndDlg, IDC_16BIT_DITHER) != BST_CHECKED
+ && IsDlgButtonChecked(hwndDlg, IDC_16BIT_L_SHAPE) != BST_CHECKED
+ && IsDlgButtonChecked(hwndDlg, IDC_16BIT_M_SHAPE) != BST_CHECKED
+ && IsDlgButtonChecked(hwndDlg, IDC_16BIT_H_SHAPE) != BST_CHECKED)
+ CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
+ break;
+ case IDC_DECODE:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_AIFF), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SUNAU), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DECAU), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_24BIT), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_32BIT), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FLOATS), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_DITHER), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_L_SHAPE), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_M_SHAPE), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_H_SHAPE), TRUE);
+ break;
+ default:
+ break;
+ }
+ }
+ return FALSE;
+}
+
+
+/******************************** end of main.c ********************************/
+
diff --git a/faad2/src/aacDECdrop/misc.c b/faad2/src/aacDECdrop/misc.c
new file mode 100644
index 0000000..cf5b9af
--- /dev/null
+++ b/faad2/src/aacDECdrop/misc.c
@@ -0,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(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 ********************************/
+
diff --git a/faad2/src/aacDECdrop/misc.h b/faad2/src/aacDECdrop/misc.h
new file mode 100644
index 0000000..800f21c
--- /dev/null
+++ b/faad2/src/aacDECdrop/misc.h
@@ -0,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(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__ */
+
diff --git a/faad2/src/aacDECdrop/resource.h b/faad2/src/aacDECdrop/resource.h
new file mode 100644
index 0000000..5a7fad6
--- /dev/null
+++ b/faad2/src/aacDECdrop/resource.h
@@ -0,0 +1,54 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Script.rc
+//
+#define IDD_VOLUME 101
+#define IDD_ABOUT 102
+#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_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 IDC_16BIT_DITHER 1027
+#define IDC_16BIT_L_SHAPE 1028
+#define IDC_16BIT_M_SHAPE 1029
+#define IDC_16BIT_H_SHAPE 1030
+#define IDC_BUTTON6 1033
+#define IDM_VOLUME 40005
+#define IDM_STOP_DEC 40006
+#define IDM_ABOUT 40007
+#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 1031
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/faad2/src/aacDECdrop/resource/AAC01.bmp b/faad2/src/aacDECdrop/resource/AAC01.bmp
new file mode 100644
index 0000000..7d85aac
--- /dev/null
+++ b/faad2/src/aacDECdrop/resource/AAC01.bmp
Binary files differ
diff --git a/faad2/src/aacDECdrop/resource/AAC01.ico b/faad2/src/aacDECdrop/resource/AAC01.ico
new file mode 100644
index 0000000..b382866
--- /dev/null
+++ b/faad2/src/aacDECdrop/resource/AAC01.ico
Binary files differ
diff --git a/faad2/src/aacDECdrop/resource/AAC02.bmp b/faad2/src/aacDECdrop/resource/AAC02.bmp
new file mode 100644
index 0000000..33a8a28
--- /dev/null
+++ b/faad2/src/aacDECdrop/resource/AAC02.bmp
Binary files differ
diff --git a/faad2/src/aacDECdrop/resource/AAC03.bmp b/faad2/src/aacDECdrop/resource/AAC03.bmp
new file mode 100644
index 0000000..a9258fe
--- /dev/null
+++ b/faad2/src/aacDECdrop/resource/AAC03.bmp
Binary files differ
diff --git a/faad2/src/aacDECdrop/resource/AAC04.bmp b/faad2/src/aacDECdrop/resource/AAC04.bmp
new file mode 100644
index 0000000..efa68ef
--- /dev/null
+++ b/faad2/src/aacDECdrop/resource/AAC04.bmp
Binary files differ
diff --git a/faad2/src/aacDECdrop/resource/AAC05.bmp b/faad2/src/aacDECdrop/resource/AAC05.bmp
new file mode 100644
index 0000000..a29c248
--- /dev/null
+++ b/faad2/src/aacDECdrop/resource/AAC05.bmp
Binary files differ
diff --git a/faad2/src/aacDECdrop/resource/AAC06.bmp b/faad2/src/aacDECdrop/resource/AAC06.bmp
new file mode 100644
index 0000000..82af819
--- /dev/null
+++ b/faad2/src/aacDECdrop/resource/AAC06.bmp
Binary files differ
diff --git a/faad2/src/aacDECdrop/resource/AAC07.bmp b/faad2/src/aacDECdrop/resource/AAC07.bmp
new file mode 100644
index 0000000..ca418e8
--- /dev/null
+++ b/faad2/src/aacDECdrop/resource/AAC07.bmp
Binary files differ
diff --git a/faad2/src/aacDECdrop/resource/AAC08.bmp b/faad2/src/aacDECdrop/resource/AAC08.bmp
new file mode 100644
index 0000000..ce60f19
--- /dev/null
+++ b/faad2/src/aacDECdrop/resource/AAC08.bmp
Binary files differ
diff --git a/faad2/src/aacDECdrop/wave_out.c b/faad2/src/aacDECdrop/wave_out.c
new file mode 100644
index 0000000..02131ab
--- /dev/null
+++ b/faad2/src/aacDECdrop/wave_out.c
@@ -0,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 ********************************/
+
diff --git a/faad2/src/aacDECdrop/wave_out.h b/faad2/src/aacDECdrop/wave_out.h
new file mode 100644
index 0000000..9dceea7
--- /dev/null
+++ b/faad2/src/aacDECdrop/wave_out.h
@@ -0,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__ */
diff --git a/faad2/src/bootstrap b/faad2/src/bootstrap
new file mode 100644
index 0000000..79748cd
--- /dev/null
+++ b/faad2/src/bootstrap
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+case $OSTYPE in
+ darwin*)
+ LIBTOOLIZE=glibtoolize
+ ;;
+ *)
+ LIBTOOLIZE=libtoolize
+ ;;
+esac
+
+aclocal -I . && \
+autoheader && \
+$LIBTOOLIZE --automake --copy && \
+automake --add-missing --copy && \
+autoconf && \
+echo "Ready to run ./configure"
diff --git a/faad2/src/common/Makefile.am b/faad2/src/common/Makefile.am
new file mode 100644
index 0000000..dd8b9ca
--- /dev/null
+++ b/faad2/src/common/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = mp4ff
diff --git a/faad2/src/common/faad/aacinfo.c b/faad2/src/common/faad/aacinfo.c
new file mode 100644
index 0000000..1cfbab2
--- /dev/null
+++ b/faad2/src/common/faad/aacinfo.c
@@ -0,0 +1,372 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: aacinfo.c,v 1.4 2003/07/29 08:20:11 menno Exp $
+**/
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+#include <malloc.h>
+#include "filestream.h"
+#include "aacinfo.h"
+
+#define ADIF_MAX_SIZE 30 /* Should be enough */
+#define ADTS_MAX_SIZE 10 /* Should be enough */
+
+static int sample_rates[] = {96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000};
+
+static int read_ADIF_header(FILE_STREAM *file, faadAACInfo *info)
+{
+ int bitstream;
+ unsigned char buffer[ADIF_MAX_SIZE];
+ int skip_size = 0;
+ int sf_idx;
+
+ /* Get ADIF header data */
+ info->headertype = 1;
+
+ if(read_buffer_filestream(file, buffer, ADIF_MAX_SIZE) < 0)
+ return -1;
+
+ /* copyright string */
+ if(buffer[0] & 0x80)
+ skip_size += 9; /* skip 9 bytes */
+
+ bitstream = buffer[0 + skip_size] & 0x10;
+ info->bitrate = ((unsigned int)(buffer[0 + skip_size] & 0x0F)<<19)|
+ ((unsigned int)buffer[1 + skip_size]<<11)|
+ ((unsigned int)buffer[2 + skip_size]<<3)|
+ ((unsigned int)buffer[3 + skip_size] & 0xE0);
+
+ if (bitstream == 0)
+ {
+ info->object_type = ((buffer[6 + skip_size]&0x01)<<1)|((buffer[7 + skip_size]&0x80)>>7);
+ sf_idx = (buffer[7 + skip_size]&0x78)>>3;
+ } else {
+ info->object_type = (buffer[4 + skip_size] & 0x18)>>3;
+ sf_idx = ((buffer[4 + skip_size] & 0x07)<<1)|((buffer[5 + skip_size] & 0x80)>>7);
+ }
+ info->sampling_rate = sample_rates[sf_idx];
+
+ return 0;
+}
+
+static int read_ADTS_header(FILE_STREAM *file, faadAACInfo *info,
+ unsigned long **seek_table, int *seek_table_len,
+ int tagsize, int no_seek_table)
+{
+ /* Get ADTS header data */
+ unsigned char buffer[ADTS_MAX_SIZE];
+ int frames, framesinsec=0, t_framelength = 0, frame_length, sr_idx, ID;
+ int second = 0, pos;
+ int i;
+ float frames_per_sec = 0;
+ unsigned long bytes;
+ unsigned long *tmp_seek_table = NULL;
+
+ info->headertype = 2;
+
+ /* Read all frames to ensure correct time and bitrate */
+ for(frames=0; /* */; frames++, framesinsec++)
+ {
+ /* If streaming, only go until we hit 5 seconds worth */
+ if(file->http)
+ {
+ if(frames >= 43 * 5)
+ {
+ break;
+ }
+ }
+
+ pos = tell_filestream(file);
+
+ /* 12 bit SYNCWORD */
+ bytes = read_buffer_filestream(file, buffer, ADTS_MAX_SIZE);
+
+ if(bytes != ADTS_MAX_SIZE)
+ {
+ /* Bail out if no syncword found */
+ break;
+ }
+
+ /* check syncword */
+ if (!((buffer[0] == 0xFF)&&((buffer[1] & 0xF6) == 0xF0)))
+ break;
+
+ if(!frames)
+ {
+ /* fixed ADTS header is the same for every frame, so we read it only once */
+ /* Syncword found, proceed to read in the fixed ADTS header */
+ ID = buffer[1] & 0x08;
+ info->object_type = (buffer[2]&0xC0)>>6;
+ sr_idx = (buffer[2]&0x3C)>>2;
+ info->channels = ((buffer[2]&0x01)<<2)|((buffer[3]&0xC0)>>6);
+
+ frames_per_sec = sample_rates[sr_idx] / 1024.f;
+ }
+
+ /* ...and the variable ADTS header */
+ if (ID == 0) {
+ info->version = 4;
+ } else { /* MPEG-2 */
+ info->version = 2;
+ }
+ frame_length = ((((unsigned int)buffer[3] & 0x3)) << 11)
+ | (((unsigned int)buffer[4]) << 3) | (buffer[5] >> 5);
+
+ t_framelength += frame_length;
+
+ if(!file->http)
+ {
+ if(framesinsec == 43)
+ framesinsec = 0;
+
+ if(framesinsec == 0 && seek_table_len)
+ {
+ tmp_seek_table = (unsigned long *) realloc(tmp_seek_table, (second + 1) * sizeof(unsigned long));
+ tmp_seek_table[second] = pos;
+ }
+ if(framesinsec == 0)
+ second++;
+ }
+
+ /* NOTE: While simply skipping ahead by reading may seem to be more work than seeking,
+ it is actually much faster, and keeps compatibility with streaming */
+ for(i=0; i < frame_length - ADTS_MAX_SIZE; i++)
+ {
+ if(read_byte_filestream(file) < 0)
+ break;
+ }
+ }
+
+ if(seek_table_len)
+ {
+ *seek_table_len = second;
+ *seek_table = tmp_seek_table;
+ }
+
+ info->sampling_rate = sample_rates[sr_idx];
+ info->bitrate = (int)(((t_framelength / frames) * (info->sampling_rate/1024.0)) +0.5)*8;
+
+ if(file->http)
+ {
+ /* Since we only use 5 seconds of aac data to get a rough bitrate, we must use a different
+ method of calculating the overall length */
+ if(filelength_filestream(file))
+ {
+ info->length = (int)((filelength_filestream(file)/(((info->bitrate*8)/1024)*16))*1000);
+ }
+ else
+ {
+ /* Since the server didnt tell us how long the file is,
+ we have no way of determining length */
+ info->length = 0;
+ }
+ }
+ else
+ {
+ info->length = (int)((float)(frames/frames_per_sec))*1000;
+ }
+
+ return 0;
+}
+
+int get_AAC_format(char *filename, faadAACInfo *info,
+ unsigned long **seek_table, int *seek_table_len,
+ int no_seek_table)
+{
+ unsigned long tagsize;
+ FILE_STREAM *file;
+ char buffer[10];
+ unsigned long file_len;
+ unsigned char adxx_id[5];
+ unsigned long tmp;
+
+ memset(info, 0, sizeof(faadAACInfo));
+
+ file = open_filestream(filename);
+
+ if(file == NULL)
+ return -1;
+
+ file_len = filelength_filestream(file);
+
+ /* Skip the tag, if it's there */
+ tmp = read_buffer_filestream(file, buffer, 10);
+
+ if (StringComp(buffer, "ID3", 3) == 0)
+ {
+ unsigned int i;
+
+ /* high bit is not used */
+ tagsize = (buffer[6] << 21) | (buffer[7] << 14) |
+ (buffer[8] << 7) | (buffer[9] << 0);
+
+ for(i=0; i < tagsize; i++)
+ if(read_byte_filestream(file) < 0)
+ return -1;
+
+ tagsize += 10;
+ }
+ else
+ {
+ tagsize = 0;
+
+ /* Simple hack to reset to the beginning */
+ file->buffer_offset = 0;
+ file->file_offset = 0;
+ }
+
+ if(file_len)
+ file_len -= tagsize;
+
+ tmp = read_buffer_filestream(file, adxx_id, 2);
+ //seek_filestream(file, tagsize, FILE_BEGIN);
+
+ adxx_id[5-1] = 0;
+ info->length = 0;
+
+ /* Determine the header type of the file, check the first two bytes */
+ if(StringComp(adxx_id, "AD", 2) == 0)
+ {
+ /* We think its an ADIF header, but check the rest just to make sure */
+ tmp = read_buffer_filestream(file, adxx_id + 2, 2);
+
+ if(StringComp(adxx_id, "ADIF", 4) == 0)
+ {
+ read_ADIF_header(file, info);
+ }
+ }
+ else
+ {
+ /* No ADIF, check for ADTS header */
+ if ((adxx_id[0] == 0xFF)&&((adxx_id[1] & 0xF6) == 0xF0))
+ {
+ /* ADTS header located */
+ /* Since this routine must work for streams, we can't use the seek function to go backwards, thus
+ we have to use a quick hack as seen below to go back where we need to. */
+
+ if(file->buffer_offset >= 2)
+ {
+ // simple seeking hack, though not really safe, the probability of it causing a problem is low.
+ file->buffer_offset -= 2;
+ file->file_offset -= 2;
+ }
+
+ read_ADTS_header(file, info, seek_table, seek_table_len, tagsize,
+ no_seek_table);
+ }
+ else
+ {
+ /* Unknown/headerless AAC file, assume format: */
+ info->version = 2;
+ info->bitrate = 128000;
+ info->sampling_rate = 44100;
+ info->channels = 2;
+ info->headertype = 0;
+ info->object_type = 1;
+ }
+ }
+
+ close_filestream(file);
+
+ return 0;
+}
+
+int StringComp(char const *str1, char const *str2, unsigned long len)
+{
+ signed int c1 = 0, c2 = 0;
+
+ while (len--) {
+ c1 = *str1++;
+ c2 = *str2++;
+
+ if (c1 == 0 || c1 != c2)
+ break;
+ }
+
+ return c1 - c2;
+}
+
+#ifdef TEST
+/* Program to test aacinfo functionality */
+
+#include <stdio.h>
+
+void main(int argc, char *argv[])
+{
+ faadAACInfo info;
+ unsigned long *seek_table = NULL;
+ int seek_table_len = 0;
+ char *header, *object;
+
+ if (argc < 2)
+ {
+ fprintf(stderr, "USAGE: aacinfo aacfile.aac\n");
+ return;
+ }
+
+ get_AAC_format(argv[1], &info, &seek_table, &seek_table_len, 0);
+
+ fprintf(stdout, "MPEG version: %d\n", info.version);
+ fprintf(stdout, "channels: %d\n", info.channels);
+ fprintf(stdout, "sampling_rate: %d\n", info.sampling_rate);
+ fprintf(stdout, "bitrate: %d\n", info.bitrate);
+ fprintf(stdout, "length: %.3f\n", (float)info.length/1000.0);
+
+ switch (info.object_type)
+ {
+ case 0:
+ object = "MAIN";
+ break;
+ case 1:
+ object = "LC";
+ break;
+ case 2:
+ object = "SSR";
+ break;
+ case 3:
+ object = "LTP";
+ break;
+ }
+ fprintf(stdout, "object_type: %s\n", object);
+
+ switch (info.headertype)
+ {
+ case 0:
+ header = "RAW";
+ break;
+ case 1:
+ header = "ADIF";
+ break;
+ case 2:
+ header = "ADTS";
+ break;
+ }
+ fprintf(stdout, "headertype: %s\n", header);
+}
+
+#endif \ No newline at end of file
diff --git a/faad2/src/common/faad/aacinfo.h b/faad2/src/common/faad/aacinfo.h
new file mode 100644
index 0000000..c0257a8
--- /dev/null
+++ b/faad2/src/common/faad/aacinfo.h
@@ -0,0 +1,53 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: aacinfo.h,v 1.3 2003/07/29 08:20:11 menno Exp $
+**/
+
+#ifndef AACINFO_H__
+#define AACINFO_H__
+
+#include "filestream.h"
+
+typedef struct {
+ int version;
+ int channels;
+ int sampling_rate;
+ int bitrate;
+ int length;
+ int object_type;
+ int headertype;
+} faadAACInfo;
+
+int get_AAC_format(char *filename, faadAACInfo *info,
+ unsigned long **seek_table, int *seek_table_len,
+ int no_seek_table);
+
+static int read_ADIF_header(FILE_STREAM *file, faadAACInfo *info);
+static int read_ADTS_header(FILE_STREAM *file, faadAACInfo *info,
+ unsigned long **seek_table, int *seek_table_len,
+ int tagsize, int no_seek_table);
+int StringComp(char const *str1, char const *str2, unsigned long len);
+
+#endif
diff --git a/faad2/src/common/faad/aacinfo.sln b/faad2/src/common/faad/aacinfo.sln
new file mode 100644
index 0000000..68a8a36
--- /dev/null
+++ b/faad2/src/common/faad/aacinfo.sln
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aacinfo", "aacinfo.vcproj", "{FE985E4D-79DB-4DD3-BFED-824B4677A161}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {FE985E4D-79DB-4DD3-BFED-824B4677A161}.Debug|Win32.ActiveCfg = Debug|Win32
+ {FE985E4D-79DB-4DD3-BFED-824B4677A161}.Debug|Win32.Build.0 = Debug|Win32
+ {FE985E4D-79DB-4DD3-BFED-824B4677A161}.Release|Win32.ActiveCfg = Release|Win32
+ {FE985E4D-79DB-4DD3-BFED-824B4677A161}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/faad2/src/common/faad/aacinfo.vcproj b/faad2/src/common/faad/aacinfo.vcproj
new file mode 100644
index 0000000..bb0984c
--- /dev/null
+++ b/faad2/src/common/faad/aacinfo.vcproj
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="aacinfo"
+ ProjectGUID="{FE985E4D-79DB-4DD3-BFED-824B4677A161}"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Debug/aacinfo.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE,TEST"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderFile=".\Debug/aacinfo.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1043"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="ws2_32.lib odbc32.lib odbccp32.lib"
+ OutputFile=".\Debug/aacinfo.exe"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/aacinfo.pdb"
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Release/aacinfo.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE,TEST"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderFile=".\Release/aacinfo.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1043"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="ws2_32.lib odbc32.lib odbccp32.lib"
+ OutputFile=".\Release/aacinfo.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ProgramDatabaseFile=".\Release/aacinfo.pdb"
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath=".\aacinfo.c"
+ >
+ </File>
+ <File
+ RelativePath=".\filestream.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath=".\aacinfo.h"
+ >
+ </File>
+ <File
+ RelativePath=".\filestream.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/faad2/src/common/faad/filestream.c b/faad2/src/common/faad/filestream.c
new file mode 100644
index 0000000..0f82bdf
--- /dev/null
+++ b/faad2/src/common/faad/filestream.c
@@ -0,0 +1,470 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: filestream.c,v 1.3 2003/07/29 08:20:11 menno Exp $
+**/
+
+/* Not very portable yet */
+
+#include <winsock2.h> // Note: Must be *before* windows.h
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+#include "filestream.h"
+#include "aacinfo.h"
+
+/* TEMPROARY HACK */
+#define CommonExit(A) MessageBox(NULL, A, "FAAD Plugin", MB_OK)
+
+int winsock_init=0; // 0=winsock not initialized, 1=success
+long m_local_buffer_size = 64;
+long m_stream_buffer_size = 128;
+
+FILE_STREAM *open_filestream(char *filename)
+{
+ FILE_STREAM *fs;
+
+ if(StringComp(filename,"http://", 7) == 0)
+ {
+ fs = (FILE_STREAM *)LocalAlloc(LPTR, sizeof(FILE_STREAM) + m_stream_buffer_size * 1024);
+
+ if(fs == NULL)
+ return NULL;
+
+ fs->data = (unsigned char *)&fs[1];
+
+ if(http_file_open(filename, fs) < 0)
+ {
+ LocalFree(fs);
+ return NULL;
+ }
+
+ fs->http = 1;
+ }
+ else
+ {
+ fs = (FILE_STREAM*)LocalAlloc(LPTR, sizeof(FILE_STREAM) + m_local_buffer_size * 1024);
+
+ if(fs == NULL)
+ return NULL;
+
+ fs->data = (unsigned char *)&fs[1];
+
+ fs->stream = CreateFile(filename, GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
+ OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0);
+ if (fs->stream == INVALID_HANDLE_VALUE)
+ {
+ LocalFree(fs);
+ return NULL;
+ }
+
+ fs->http = 0;
+ }
+
+ fs->buffer_length = 0;
+ fs->buffer_offset = 0;
+ fs->file_offset = 0;
+
+ return fs;
+}
+
+int read_byte_filestream(FILE_STREAM *fs)
+{
+ if(fs->buffer_offset == fs->buffer_length)
+ {
+ fs->buffer_offset = 0;
+
+ if(fs->http)
+ fs->buffer_length = recv(fs->inetStream, fs->data, m_stream_buffer_size * 1024, 0);
+ else
+ ReadFile(fs->stream, fs->data, m_local_buffer_size * 1024, &fs->buffer_length, 0);
+
+ if(fs->buffer_length <= 0)
+ {
+ if(fs->http)
+ {
+ int x;
+ x = WSAGetLastError();
+
+ if(x == 0)
+ {
+ /* Equivalent of a successful EOF for HTTP */
+ }
+ }
+
+ fs->buffer_length = 0;
+ return -1;
+ }
+ }
+
+ fs->file_offset++;
+
+ return fs->data[fs->buffer_offset++];
+}
+
+int read_buffer_filestream(FILE_STREAM *fs, void *data, int length)
+{
+ int i, tmp;
+ unsigned char *data2 = (unsigned char *)data;
+
+ for(i=0; i < length; i++)
+ {
+ if((tmp = read_byte_filestream(fs)) < 0)
+ {
+ if(i)
+ {
+ break;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ data2[i] = tmp;
+ }
+
+ return i;
+}
+
+unsigned long filelength_filestream(FILE_STREAM *fs)
+{
+ unsigned long fsize;
+
+ if (fs->http)
+ {
+ fsize = fs->http_file_length;
+ }
+ else
+ {
+ fsize = GetFileSize(fs->stream, NULL);
+ }
+
+ return fsize;
+}
+
+void seek_filestream(FILE_STREAM *fs, unsigned long offset, int mode)
+{
+ if(fs->http)
+ {
+ return;
+ }
+
+ SetFilePointer(fs->stream, offset, NULL, mode);
+
+ if(mode == FILE_CURRENT)
+ fs->file_offset += offset;
+ else if(mode == FILE_END)
+ fs->file_offset = filelength_filestream(fs) + offset;
+ else
+ fs->file_offset = offset;
+
+ fs->buffer_length = 0;
+ fs->buffer_offset = 0;
+}
+
+unsigned long tell_filestream(FILE_STREAM *fs)
+{
+ return fs->file_offset;
+}
+
+void close_filestream(FILE_STREAM *fs)
+{
+ if(fs)
+ {
+ if (fs->http)
+ {
+ if (fs->inetStream)
+ {
+ /* The 'proper' way to close a TCP connection */
+ if(fs->inetStream)
+ {
+ CloseTCP(fs->inetStream);
+ }
+ }
+ }
+ else
+ {
+ if(fs->stream)
+ CloseHandle(fs->stream);
+ }
+
+ LocalFree(fs);
+ fs = NULL;
+ }
+}
+
+int WinsockInit()
+{
+ /* Before using winsock, you must load the DLL... */
+ WSADATA wsaData;
+
+ /* Load version 2.0 */
+ if (WSAStartup( MAKEWORD( 2, 0 ), &wsaData ))
+ {
+ /* Disable streaming */
+ return -1;
+ }
+
+ winsock_init = 1;
+
+ return 0;
+}
+
+void WinsockDeInit()
+{
+ /* Unload the DLL */
+
+ if(winsock_init)
+ WSACleanup();
+}
+
+int FindCRLF(char *str)
+{
+ int i;
+
+ for(i=0; i != lstrlen(str) && str[i] != '\r'; i++);
+
+ return i;
+}
+
+void CloseTCP(int s)
+{
+ char tempbuf[1024];
+
+ /* Set the socket to ignore any new incoming data */
+ shutdown(s, 1);
+
+ /* Get any old remaining data */
+ while(recv(s, tempbuf, 1024, 0) > 0);
+
+ /* Deallocate the socket */
+ closesocket(s);
+}
+
+int resolve_host(char *host, SOCKADDR_IN *sck_addr, unsigned short remote_port)
+{
+ HOSTENT *hp;
+
+ if (isalpha(host[0]))
+ {
+ /* server address is a name */
+ hp = gethostbyname(host);
+ }
+ else
+ {
+ unsigned long addr;
+ /* Convert nnn.nnn address to a usable one */
+ addr = inet_addr(host);
+ hp = gethostbyaddr((char *)&addr, 4, AF_INET);
+ }
+
+ if (hp == NULL)
+ {
+ char tmp[128];
+ wsprintf(tmp, "Error resolving host address [%s]!\n", host);
+ CommonExit(tmp);
+ return -1;
+ }
+
+ ZeroMemory(sck_addr, sizeof(SOCKADDR_IN));
+ sck_addr->sin_family = AF_INET;
+ sck_addr->sin_port = htons(remote_port);
+ CopyMemory(&sck_addr->sin_addr, hp->h_addr, hp->h_length);
+
+ return 0;
+}
+
+int http_file_open(char *url, FILE_STREAM *fs)
+{
+ SOCKET sck;
+ SOCKADDR_IN host;
+ char server[1024], file[1024], request[1024], *temp = NULL, *tmpfile = NULL;
+ int i, j, port = 80, bytes_recv, http_code;
+
+ /* No winsock, no streaming */
+ if(!winsock_init)
+ {
+ return -1;
+ }
+
+ url += 7; // Skip over http://
+
+ /* Extract data from the URL */
+ for(i=0; url[i] != '/' && url[i] != ':' && url[i] != 0; i++);
+
+ ZeroMemory(server, 1024);
+ CopyMemory(server, url, i);
+
+ if(url[i] == ':')
+ {
+ /* A certain port was specified */
+ port = atol(url + (i + 1));
+ }
+
+ for(; url[i] != '/' && url[i] != 0; i++);
+
+ ZeroMemory(file, 1024);
+
+ CopyMemory(file, url + i, lstrlen(url));
+
+ /* END OF URL PARSING */
+
+ /* Create a TCP/IP socket */
+ sck = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+ if(sck == INVALID_SOCKET)
+ {
+ CommonExit("Error creating TCP/IP new socket");
+ return -1;
+ }
+
+ /* Resolve the host address (turn www.blah.com into an IP) */
+ if(resolve_host(server, &host, (unsigned short)port))
+ {
+ CommonExit("Error resolving host address");
+ CloseTCP(sck);
+ return -1;
+ }
+
+ /* Connect to the server */
+ if(connect(sck, (SOCKADDR *)&host, sizeof(SOCKADDR)) == SOCKET_ERROR)
+ {
+ CommonExit("Error connecting to remote server");
+ CloseTCP(sck);
+ return -1;
+ }
+
+ tmpfile = calloc(1, (strlen(file) * 3) + 1);
+
+ /* Encode URL */
+ for(i=0, j=0; i < (int)strlen(file); i++)
+ {
+ if((unsigned char)file[i] <= 31 || (unsigned char)file[i] >= 127)
+ {
+ /* encode ASCII-control characters */
+ wsprintf(tmpfile + j, "%%%X", (unsigned char)file[i]);
+ j += 3;
+ continue;
+ }
+ else
+ {
+ switch(file[i])
+ {
+ /* encode characters that could confuse some servers */
+ case ' ':
+ case '"':
+ case '>':
+ case '<':
+ case '#':
+ case '%':
+ case '{':
+ case '}':
+ case '|':
+ case '\\':
+ case '^':
+ case '~':
+ case '[':
+ case ']':
+ case '`':
+
+ wsprintf(tmpfile + j, "%%%X", (unsigned char)file[i]);
+ j += 3;
+ continue;
+ }
+ }
+
+ tmpfile[j] = file[i];
+ j++;
+ }
+
+ wsprintf(request, "GET %s\r\n\r\n", tmpfile);
+
+ free(tmpfile);
+
+ /* Send the request */
+ if(send(sck, request, lstrlen(request), 0) <= 0)
+ {
+ /* Error sending data */
+ CloseTCP(sck);
+ return -1;
+ }
+
+ ZeroMemory(request, 1024);
+
+ /* Send the request */
+ if((bytes_recv = recv(sck, request, 1024, 0)) <= 0)
+ {
+ /* Error sending data */
+ CloseTCP(sck);
+ return -1;
+ }
+
+ if(StringComp(request,"HTTP/1.", 7) != 0)
+ {
+ /* Invalid header */
+ CloseTCP(sck);
+ return -1;
+ }
+
+ http_code = atol(request + 9);
+
+ if(http_code < 200 || http_code > 299)
+ {
+ /* HTTP error */
+ CloseTCP(sck);
+ return -1;
+ }
+
+ // Search for a length field
+ fs->http_file_length = 0;
+
+ /* Limit search to only 20 loops */
+ if((temp = strstr(request, "Content-Length: ")) != NULL)
+ {
+ /* Has a content-length field, copy into structure */
+ fs->http_file_length = atol(temp + 16);
+ }
+
+ /* Copy the handle data into the structure */
+ fs->inetStream = sck;
+
+ /* Copy any excess data beyond the header into the filestream buffers */
+ temp = strstr(request, "\r\n\r\n");
+
+ if(temp)
+ {
+ temp += 4;
+ }
+
+ if(temp - request < bytes_recv)
+ {
+ memcpy(fs->data, temp, (temp - request) - bytes_recv);
+ fs->buffer_length = (temp - request) - bytes_recv;
+ fs->buffer_offset = 0;
+ }
+
+ return 0;
+}
diff --git a/faad2/src/common/faad/filestream.h b/faad2/src/common/faad/filestream.h
new file mode 100644
index 0000000..58e40b9
--- /dev/null
+++ b/faad2/src/common/faad/filestream.h
@@ -0,0 +1,57 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: filestream.h,v 1.3 2003/07/29 08:20:11 menno Exp $
+**/
+
+#ifndef FILESTREAM_H
+#define FILESTREAM_H
+
+typedef struct {
+ HANDLE stream;
+ unsigned short inetStream;
+ unsigned char *data;
+ int http;
+ int buffer_offset;
+ int buffer_length;
+ int file_offset;
+ int http_file_length;
+} FILE_STREAM;
+
+extern long m_local_buffer_size;
+extern long m_stream_buffer_size;
+
+FILE_STREAM *open_filestream(char *filename);
+int read_byte_filestream(FILE_STREAM *fs);
+int read_buffer_filestream(FILE_STREAM *fs, void *data, int length);
+unsigned long filelength_filestream(FILE_STREAM *fs);
+void close_filestream(FILE_STREAM *fs);
+void seek_filestream(FILE_STREAM *fs, unsigned long offset, int mode);
+unsigned long tell_filestream(FILE_STREAM *fs);
+int http_file_open(char *url, FILE_STREAM *fs);
+
+int WinsockInit();
+void WinsockDeInit();
+void CloseTCP(int s);
+#endif \ No newline at end of file
diff --git a/faad2/src/common/faad/getopt.c b/faad2/src/common/faad/getopt.c
new file mode 100644
index 0000000..6c21d73
--- /dev/null
+++ b/faad2/src/common/faad/getopt.c
@@ -0,0 +1,755 @@
+/* Getopt for GNU.
+ NOTE: getopt is now part of the C library, so if you don't know what
+ "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
+ before changing it!
+
+ Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
+ Free Software Foundation, Inc.
+
+ 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, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef __STDC__
+# ifndef const
+# define const
+# endif
+#endif
+
+/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
+#ifndef _NO_PROTO
+#define _NO_PROTO
+#endif
+
+#include <stdio.h>
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself. This code is part of the GNU C
+ Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand `configure --with-gnu-libc' and omit the object files,
+ it is simpler to just do this in the source for each such file. */
+
+#if defined (_LIBC) || !defined (__GNU_LIBRARY__) || !__MacOSX__
+
+
+/* This needs to come after some library #include
+ to get __GNU_LIBRARY__ defined. */
+#ifdef __GNU_LIBRARY__
+/* Don't include stdlib.h for non-GNU C libraries because some of them
+ contain conflicting prototypes for getopt. */
+#include <stdlib.h>
+#endif /* GNU C library. */
+
+/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
+ long-named option. Because this is not POSIX.2 compliant, it is
+ being phased out. */
+/* #define GETOPT_COMPAT */
+
+/* This version of `getopt' appears to the caller like standard Unix `getopt'
+ but it behaves differently for the user, since it allows the user
+ to intersperse the options with the other arguments.
+
+ As `getopt' works, it permutes the elements of ARGV so that,
+ when it is done, all the options precede everything else. Thus
+ all application programs are extended to handle flexible argument order.
+
+ Setting the environment variable POSIXLY_CORRECT disables permutation.
+ Then the behavior is completely standard.
+
+ GNU application programs can use a third alternative mode in which
+ they can distinguish the relative order of options and other arguments. */
+
+#include "getopt.h"
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+char *optarg = 0;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns EOF, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+/* XXX 1003.2 says this must be 1 before any call. */
+int optind = 0;
+
+/* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+
+static char *nextchar;
+
+/* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+ This must be initialized on some systems to avoid linking in the
+ system's own getopt implementation. */
+
+#define BAD_OPTION '\0'
+int optopt = BAD_OPTION;
+
+/* Describe how to deal with options that follow non-option ARGV-elements.
+
+ If the caller did not specify anything,
+ the default is REQUIRE_ORDER if the environment variable
+ POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+ REQUIRE_ORDER means don't recognize them as options;
+ stop option processing when the first non-option is seen.
+ This is what Unix does.
+ This mode of operation is selected by either setting the environment
+ variable POSIXLY_CORRECT, or using `+' as the first character
+ of the list of option characters.
+
+ PERMUTE is the default. We permute the contents of ARGV as we scan,
+ so that eventually all the non-options are at the end. This allows options
+ to be given in any order, even with programs that were not written to
+ expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were written
+ to expect options and other ARGV-elements in any order and that care about
+ the ordering of the two. We describe each non-option ARGV-element
+ as if it were the argument of an option with character code 1.
+ Using `-' as the first character of the list of option characters
+ selects this mode of operation.
+
+ The special argument `--' forces an end of option-scanning regardless
+ of the value of `ordering'. In the case of RETURN_IN_ORDER, only
+ `--' can cause `getopt' to return EOF with `optind' != ARGC. */
+
+static enum
+{
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+} ordering;
+
+#ifdef __GNU_LIBRARY__
+/* We want to avoid inclusion of string.h with non-GNU libraries
+ because there are many ways it can cause trouble.
+ On some systems, it contains special magic macros that don't work
+ in GCC. */
+#include <string.h>
+#define my_index strchr
+#define my_strlen strlen
+#else
+
+/* Avoid depending on library functions or files
+ whose names are inconsistent. */
+
+#if __STDC__ || defined(PROTO)
+extern char *getenv(const char *name);
+extern int strcmp (const char *s1, const char *s2);
+extern int strncmp(const char *s1, const char *s2, unsigned int n);
+
+static int my_strlen(const char *s);
+static char *my_index (const char *str, int chr);
+#else
+extern char *getenv ();
+#endif
+
+static int
+my_strlen (str)
+ const char *str;
+{
+ int n = 0;
+ while (*str++)
+ n++;
+ return n;
+}
+
+static char *
+my_index (str, chr)
+ const char *str;
+ int chr;
+{
+ while (*str)
+ {
+ if (*str == chr)
+ return (char *) str;
+ str++;
+ }
+ return 0;
+}
+
+#endif /* GNU C library. */
+
+/* Handle permutation of arguments. */
+
+/* Describe the part of ARGV that contains non-options that have
+ been skipped. `first_nonopt' is the index in ARGV of the first of them;
+ `last_nonopt' is the index after the last of them. */
+
+static int first_nonopt;
+static int last_nonopt;
+
+/* Exchange two adjacent subsequences of ARGV.
+ One subsequence is elements [first_nonopt,last_nonopt)
+ which contains all the non-options that have been skipped so far.
+ The other is elements [last_nonopt,optind), which contains all
+ the options processed since those non-options were skipped.
+
+ `first_nonopt' and `last_nonopt' are relocated so that they describe
+ the new indices of the non-options in ARGV after they are moved.
+
+ To perform the swap, we first reverse the order of all elements. So
+ all options now come before all non options, but they are in the
+ wrong order. So we put back the options and non options in original
+ order by reversing them again. For example:
+ original input: a b c -x -y
+ reverse all: -y -x c b a
+ reverse options: -x -y c b a
+ reverse non options: -x -y a b c
+*/
+
+#if __STDC__ || defined(PROTO)
+static void exchange (char **argv);
+#endif
+
+static void
+exchange (argv)
+ char **argv;
+{
+ char *temp, **first, **last;
+
+ /* Reverse all the elements [first_nonopt, optind) */
+ first = &argv[first_nonopt];
+ last = &argv[optind-1];
+ while (first < last) {
+ temp = *first; *first = *last; *last = temp; first++; last--;
+ }
+ /* Put back the options in order */
+ first = &argv[first_nonopt];
+ first_nonopt += (optind - last_nonopt);
+ last = &argv[first_nonopt - 1];
+ while (first < last) {
+ temp = *first; *first = *last; *last = temp; first++; last--;
+ }
+
+ /* Put back the non options in order */
+ first = &argv[first_nonopt];
+ last_nonopt = optind;
+ last = &argv[last_nonopt-1];
+ while (first < last) {
+ temp = *first; *first = *last; *last = temp; first++; last--;
+ }
+}
+
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+ given in OPTSTRING.
+
+ If an element of ARGV starts with '-', and is not exactly "-" or "--",
+ then it is an option element. The characters of this element
+ (aside from the initial '-') are option characters. If `getopt'
+ is called repeatedly, it returns successively each of the option characters
+ from each of the option elements.
+
+ If `getopt' finds another option character, it returns that character,
+ updating `optind' and `nextchar' so that the next call to `getopt' can
+ resume the scan with the following option character or ARGV-element.
+
+ If there are no more option characters, `getopt' returns `EOF'.
+ Then `optind' is the index in ARGV of the first ARGV-element
+ that is not an option. (The ARGV-elements have been permuted
+ so that those that are not options now come last.)
+
+ OPTSTRING is a string containing the legitimate option characters.
+ If an option character is seen that is not listed in OPTSTRING,
+ return BAD_OPTION after printing an error message. If you set `opterr' to
+ zero, the error message is suppressed but we still return BAD_OPTION.
+
+ If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+ so the following text in the same ARGV-element, or the text of the following
+ ARGV-element, is returned in `optarg'. Two colons mean an option that
+ wants an optional arg; if there is text in the current ARGV-element,
+ it is returned in `optarg', otherwise `optarg' is set to zero.
+
+ If OPTSTRING starts with `-' or `+', it requests different methods of
+ handling the non-option ARGV-elements.
+ See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
+ Long-named options begin with `--' instead of `-'.
+ Their names may be abbreviated as long as the abbreviation is unique
+ or is an exact match for some defined option. If they have an
+ argument, it follows the option name in the same ARGV-element, separated
+ from the option name by a `=', or else the in next ARGV-element.
+ When `getopt' finds a long-named option, it returns 0 if that option's
+ `flag' field is nonzero, the value of the option's `val' field
+ if the `flag' field is zero.
+
+ The elements of ARGV aren't really const, because we permute them.
+ But we pretend they're const in the prototype to be compatible
+ with other systems.
+
+ LONGOPTS is a vector of `struct option' terminated by an
+ element containing a name which is zero.
+
+ LONGIND returns the index in LONGOPT of the long-named option found.
+ It is only valid when a long-named option has been found by the most
+ recent call.
+
+ If LONG_ONLY is nonzero, '-' as well as '--' can introduce
+ long-named options. */
+
+int
+_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+ const struct option *longopts;
+ int *longind;
+ int long_only;
+{
+ int option_index;
+
+ optarg = 0;
+
+ /* Initialize the internal data when the first call is made.
+ Start processing options with ARGV-element 1 (since ARGV-element 0
+ is the program name); the sequence of previously skipped
+ non-option ARGV-elements is empty. */
+
+ if (optind == 0)
+ {
+ first_nonopt = last_nonopt = optind = 1;
+
+ nextchar = NULL;
+
+ /* Determine how to handle the ordering of options and nonoptions. */
+
+ if (optstring[0] == '-')
+ {
+ ordering = RETURN_IN_ORDER;
+ ++optstring;
+ }
+ else if (optstring[0] == '+')
+ {
+ ordering = REQUIRE_ORDER;
+ ++optstring;
+ }
+ else if (getenv ("POSIXLY_CORRECT") != NULL)
+ ordering = REQUIRE_ORDER;
+ else
+ ordering = PERMUTE;
+ }
+
+ if (nextchar == NULL || *nextchar == '\0')
+ {
+ if (ordering == PERMUTE)
+ {
+ /* If we have just processed some options following some non-options,
+ exchange them so that the options come first. */
+
+ if (first_nonopt != last_nonopt && last_nonopt != optind)
+ exchange ((char **) argv);
+ else if (last_nonopt != optind)
+ first_nonopt = optind;
+
+ /* Now skip any additional non-options
+ and extend the range of non-options previously skipped. */
+
+ while (optind < argc
+ && (argv[optind][0] != '-' || argv[optind][1] == '\0')
+#ifdef GETOPT_COMPAT
+ && (longopts == NULL
+ || argv[optind][0] != '+' || argv[optind][1] == '\0')
+#endif /* GETOPT_COMPAT */
+ )
+ optind++;
+ last_nonopt = optind;
+ }
+
+ /* Special ARGV-element `--' means premature end of options.
+ Skip it like a null option,
+ then exchange with previous non-options as if it were an option,
+ then skip everything else like a non-option. */
+
+ if (optind != argc && !strcmp (argv[optind], "--"))
+ {
+ optind++;
+
+ if (first_nonopt != last_nonopt && last_nonopt != optind)
+ exchange ((char **) argv);
+ else if (first_nonopt == last_nonopt)
+ first_nonopt = optind;
+ last_nonopt = argc;
+
+ optind = argc;
+ }
+
+ /* If we have done all the ARGV-elements, stop the scan
+ and back over any non-options that we skipped and permuted. */
+
+ if (optind == argc)
+ {
+ /* Set the next-arg-index to point at the non-options
+ that we previously skipped, so the caller will digest them. */
+ if (first_nonopt != last_nonopt)
+ optind = first_nonopt;
+ return EOF;
+ }
+
+ /* If we have come to a non-option and did not permute it,
+ either stop the scan or describe it to the caller and pass it by. */
+
+ if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
+#ifdef GETOPT_COMPAT
+ && (longopts == NULL
+ || argv[optind][0] != '+' || argv[optind][1] == '\0')
+#endif /* GETOPT_COMPAT */
+ )
+ {
+ if (ordering == REQUIRE_ORDER)
+ return EOF;
+ optarg = argv[optind++];
+ return 1;
+ }
+
+ /* We have found another option-ARGV-element.
+ Start decoding its characters. */
+
+ nextchar = (argv[optind] + 1
+ + (longopts != NULL && argv[optind][1] == '-'));
+ }
+
+ if (longopts != NULL
+ && ((argv[optind][0] == '-'
+ && (argv[optind][1] == '-' || long_only))
+#ifdef GETOPT_COMPAT
+ || argv[optind][0] == '+'
+#endif /* GETOPT_COMPAT */
+ ))
+ {
+ const struct option *p;
+ char *s = nextchar;
+ int exact = 0;
+ int ambig = 0;
+ const struct option *pfound = NULL;
+ int indfound = 0;
+
+ while (*s && *s != '=')
+ s++;
+
+ /* Test all options for either exact match or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name;
+ p++, option_index++)
+ if (!strncmp (p->name, nextchar, s - nextchar))
+ {
+ if (s - nextchar == my_strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second nonexact match found. */
+ ambig = 1;
+ }
+
+ if (ambig && !exact)
+ {
+ if (opterr)
+ fprintf (stderr, "%s: option `%s' is ambiguous\n",
+ argv[0], argv[optind]);
+ nextchar += my_strlen (nextchar);
+ optind++;
+ return BAD_OPTION;
+ }
+
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ optind++;
+ if (*s)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ optarg = s + 1;
+ else
+ {
+ if (opterr)
+ {
+ if (argv[optind - 1][1] == '-')
+ /* --option */
+ fprintf (stderr,
+ "%s: option `--%s' doesn't allow an argument\n",
+ argv[0], pfound->name);
+ else
+ /* +option or -option */
+ fprintf (stderr,
+ "%s: option `%c%s' doesn't allow an argument\n",
+ argv[0], argv[optind - 1][0], pfound->name);
+ }
+ nextchar += my_strlen (nextchar);
+ return BAD_OPTION;
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (optind < argc)
+ optarg = argv[optind++];
+ else
+ {
+ if (opterr)
+ fprintf (stderr, "%s: option `%s' requires an argument\n",
+ argv[0], argv[optind - 1]);
+ nextchar += my_strlen (nextchar);
+ return optstring[0] == ':' ? ':' : BAD_OPTION;
+ }
+ }
+ nextchar += my_strlen (nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+ /* Can't find it as a long option. If this is not getopt_long_only,
+ or the option starts with '--' or is not a valid short
+ option, then it's an error.
+ Otherwise interpret it as a short option. */
+ if (!long_only || argv[optind][1] == '-'
+#ifdef GETOPT_COMPAT
+ || argv[optind][0] == '+'
+#endif /* GETOPT_COMPAT */
+ || my_index (optstring, *nextchar) == NULL)
+ {
+ if (opterr)
+ {
+ if (argv[optind][1] == '-')
+ /* --option */
+ fprintf (stderr, "%s: unrecognized option `--%s'\n",
+ argv[0], nextchar);
+ else
+ /* +option or -option */
+ fprintf (stderr, "%s: unrecognized option `%c%s'\n",
+ argv[0], argv[optind][0], nextchar);
+ }
+ nextchar = (char *) "";
+ optind++;
+ return BAD_OPTION;
+ }
+ }
+
+ /* Look at and handle the next option-character. */
+
+ {
+ char c = *nextchar++;
+ char *temp = my_index (optstring, c);
+
+ /* Increment `optind' when we start to process its last character. */
+ if (*nextchar == '\0')
+ ++optind;
+
+ if (temp == NULL || c == ':')
+ {
+ if (opterr)
+ {
+#if 0
+ if (c < 040 || c >= 0177)
+ fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
+ argv[0], c);
+ else
+ fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
+#else
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
+#endif
+ }
+ optopt = c;
+ return BAD_OPTION;
+ }
+ if (temp[1] == ':')
+ {
+ if (temp[2] == ':')
+ {
+ /* This is an option that accepts an argument optionally. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ optind++;
+ }
+ else
+ optarg = 0;
+ nextchar = NULL;
+ }
+ else
+ {
+ /* This is an option that requires an argument. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ optind++;
+ }
+ else if (optind == argc)
+ {
+ if (opterr)
+ {
+#if 0
+ fprintf (stderr, "%s: option `-%c' requires an argument\n",
+ argv[0], c);
+#else
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr, "%s: option requires an argument -- %c\n",
+ argv[0], c);
+#endif
+ }
+ optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = BAD_OPTION;
+ }
+ else
+ /* We already incremented `optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ optarg = argv[optind++];
+ nextchar = NULL;
+ }
+ }
+ return c;
+ }
+}
+
+int
+getopt (argc, argv, optstring)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+{
+ return _getopt_internal (argc, argv, optstring,
+ (const struct option *) 0,
+ (int *) 0,
+ 0);
+}
+
+int
+getopt_long (argc, argv, options, long_options, opt_index)
+ int argc;
+ char *const *argv;
+ const char *options;
+ const struct option *long_options;
+ int *opt_index;
+{
+ return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
+}
+
+#endif /* _LIBC or not __GNU_LIBRARY__. */
+
+#ifdef TEST
+
+/* Compile with -DTEST to make an executable for use in testing
+ the above definition of `getopt'. */
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+
+ c = getopt (argc, argv, "abc:d:0123456789");
+ if (c == EOF)
+ break;
+
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case BAD_OPTION:
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
diff --git a/faad2/src/common/faad/getopt.h b/faad2/src/common/faad/getopt.h
new file mode 100644
index 0000000..ea03d28
--- /dev/null
+++ b/faad2/src/common/faad/getopt.h
@@ -0,0 +1,130 @@
+/* Declarations for getopt.
+ Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+
+ 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, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifndef _GETOPT_H
+#define _GETOPT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MacOSX__
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns EOF, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+ for unrecognized options. */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized. */
+
+extern int optopt;
+#endif
+
+/* Describe the long-named options requested by the application.
+ The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+ of `struct option' terminated by an element containing a name which is
+ zero.
+
+ The field `has_arg' is:
+ no_argument (or 0) if the option does not take an argument,
+ required_argument (or 1) if the option requires an argument,
+ optional_argument (or 2) if the option takes an optional argument.
+
+ If the field `flag' is not NULL, it points to a variable that is set
+ to the value given in the field `val' when the option is found, but
+ left unchanged if the option is not found.
+
+ To have a long-named option do something other than set an `int' to
+ a compiled-in constant, such as set a value from `optarg', set the
+ option's `flag' field to zero and its `val' field to a nonzero
+ value (the equivalent single-letter option character, if there is
+ one). For long options that have a zero `flag' field, `getopt'
+ returns the contents of the `val' field. */
+
+struct option
+{
+#if __STDC__
+ const char *name;
+#else
+ char *name;
+#endif
+ /* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'. */
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+//#if __STDC__ || defined(PROTO)
+#if defined(__GNU_LIBRARY__)
+/* Many other libraries have conflicting prototypes for getopt, with
+ differences in the consts, in stdlib.h. To avoid compilation
+ errors, only prototype getopt for the GNU C library. */
+extern int getopt (int argc, char *const *argv, const char *shortopts);
+#endif /* not __GNU_LIBRARY__ */
+extern int getopt_long (int argc, char *const *argv, const char *shortopts,
+ const struct option *longopts, int *longind);
+extern int getopt_long_only (int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind);
+
+/* Internal only. Users should not call this directly. */
+extern int _getopt_internal (int argc, char *const *argv,
+ const char *shortopts,
+ const struct option *longopts, int *longind,
+ int long_only);
+//#else /* not __STDC__ */
+extern int getopt (int argc, char *const *argv, const char *shortopts);
+//extern int getopt_long ();
+//extern int getopt_long_only ();
+
+//extern int _getopt_internal ();
+//#endif /* not __STDC__ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GETOPT_H */
diff --git a/faad2/src/common/faad/id3v2tag.c b/faad2/src/common/faad/id3v2tag.c
new file mode 100644
index 0000000..ec4af9f
--- /dev/null
+++ b/faad2/src/common/faad/id3v2tag.c
@@ -0,0 +1,1124 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: id3v2tag.c,v 1.4 2003/07/29 08:20:11 menno Exp $
+**/
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <commctrl.h>
+#include <resource.h>
+
+#include <id3.h>
+
+#include <id3v2tag.h>
+
+HWND m_hwndList;
+
+LPSTR ID3Frames[] =
+{
+ "No known frame",
+ "Audio encryption",
+ "Attached picture",
+ "Comments",
+ "Commercial frame",
+ "Encryption method registration",
+ "Equalization",
+ "Event timing codes",
+ "General encapsulated object",
+ "Group identification registration",
+ "Involved people list",
+ "Linked information",
+ "Music CD identifier",
+ "MPEG location lookup table",
+ "Ownership frame",
+ "Private frame",
+ "Play counter",
+ "Popularimeter",
+ "Position synchronisation frame",
+ "Recommended buffer size",
+ "Relative volume adjustment",
+ "Reverb",
+ "Synchronized lyric",
+ "Synchronized tempo codes",
+ "Album title",
+ "BPM (beats per minute)",
+ "Composer",
+ "Genre", //"Content type",
+ "Copyright message",
+ "Date",
+ "Playlist delay",
+ "Encoded by",
+ "Lyricist",
+ "File type",
+ "Time",
+ "Content group description",
+ "Title",
+ "Subtitle",
+ "Initial key",
+ "Language(s)",
+ "Length",
+ "Media type",
+ "Original album title",
+ "Original filename",
+ "Original lyricist(s)",
+ "Original artist(s)",
+ "Original release year",
+ "File owner",
+ "Lead performer(s)",
+ "Band/orchestra/accompaniment",
+ "Conductor/performer refinement",
+ "Interpreted, remixed, or otherwise modified by",
+ "Part of a set",
+ "Publisher",
+ "Track number",
+ "Recording dates",
+ "Internet radio station name",
+ "Internet radio station owner",
+ "Size",
+ "ISRC (international standard recording code)",
+ "Software/Hardware and settings used for encoding",
+ "User defined text information",
+ "Year",
+ "Unique file identifier",
+ "Terms of use",
+ "Unsynchronized lyric",
+ "Commercial information",
+ "Copyright/Legal information",
+ "Official audio file webpage",
+ "Official artist webpage",
+ "Official audio source webpage",
+ "Official internet radio station homepage",
+ "Payment",
+ "Official publisher webpage",
+ "User defined URL link",
+ "Encrypted meta frame (id3v2.2.x)",
+ "Compressed meta frame (id3v2.2.1)"
+};
+
+ID3GENRES ID3Genres[]=
+{
+ 123, "Acapella",
+ 34, "Acid",
+ 74, "Acid Jazz",
+ 73, "Acid Punk",
+ 99, "Acoustic",
+ 20, "Alternative",
+ 40, "AlternRock",
+ 26, "Ambient",
+ 90, "Avantgarde",
+ 116, "Ballad",
+ 41, "Bass",
+ 85, "Bebob",
+ 96, "Big Band",
+ 89, "Bluegrass",
+ 0, "Blues",
+ 107, "Booty Bass",
+ 65, "Cabaret",
+ 88, "Celtic",
+ 104, "Chamber Music",
+ 102, "Chanson",
+ 97, "Chorus",
+ 61, "Christian Rap",
+ 1, "Classic Rock",
+ 32, "Classical",
+ 112, "Club",
+ 57, "Comedy",
+ 2, "Country",
+ 58, "Cult",
+ 3, "Dance",
+ 125, "Dance Hall",
+ 50, "Darkwave",
+ 254, "Data",
+ 22, "Death Metal",
+ 4, "Disco",
+ 55, "Dream",
+ 122, "Drum Solo",
+ 120, "Duet",
+ 98, "Easy Listening",
+ 52, "Electronic",
+ 48, "Ethnic",
+ 124, "Euro-House",
+ 25, "Euro-Techno",
+ 54, "Eurodance",
+ 84, "Fast Fusion",
+ 80, "Folk",
+ 81, "Folk-Rock",
+ 115, "Folklore",
+ 119, "Freestyle",
+ 5, "Funk",
+ 30, "Fusion",
+ 36, "Game",
+ 59, "Gangsta",
+ 38, "Gospel",
+ 49, "Gothic",
+ 91, "Gothic Rock",
+ 6, "Grunge",
+ 79, "Hard Rock",
+ 7, "Hip-Hop",
+ 35, "House",
+ 100, "Humour",
+ 19, "Industrial",
+ 33, "Instrumental",
+ 46, "Instrumental Pop",
+ 47, "Instrumental Rock",
+ 8, "Jazz",
+ 29, "Jazz+Funk",
+ 63, "Jungle",
+ 86, "Latin",
+ 71, "Lo-Fi",
+ 45, "Meditative",
+ 9, "Metal",
+ 77, "Musical",
+ 82, "National Folk",
+ 64, "Native American",
+ 10, "New Age",
+ 66, "New Wave",
+ 39, "Noise",
+ 255, "Not Set",
+ 11, "Oldies",
+ 103, "Opera",
+ 12, "Other",
+ 75, "Polka",
+ 13, "Pop",
+ 62, "Pop/Funk",
+ 53, "Pop-Folk",
+ 109, "Porn Groove",
+ 117, "Power Ballad",
+ 23, "Pranks",
+ 108, "Primus",
+ 92, "Progressive Rock",
+ 67, "Psychadelic",
+ 93, "Psychedelic Rock",
+ 43, "Punk",
+ 121, "Punk Rock",
+ 14, "R&B",
+ 15, "Rap",
+ 68, "Rave",
+ 16, "Reggae",
+ 76, "Retro",
+ 87, "Revival",
+ 118, "Rhythmic Soul",
+ 17, "Rock",
+ 78, "Rock & Roll",
+ 114, "Samba",
+ 110, "Satire",
+ 69, "Showtunes",
+ 21, "Ska",
+ 111, "Slow Jam",
+ 95, "Slow Rock",
+ 105, "Sonata",
+ 42, "Soul",
+ 37, "Sound Clip",
+ 24, "Soundtrack",
+ 56, "Southern Rock",
+ 44, "Space",
+ 101, "Speech",
+ 83, "Swing",
+ 94, "Symphonic Rock",
+ 106, "Symphony",
+ 113, "Tango",
+ 18, "Techno",
+ 51, "Techno-Industrial",
+ 60, "Top 40",
+ 70, "Trailer",
+ 31, "Trance",
+ 72, "Tribal",
+ 27, "Trip-Hop",
+ 28, "Vocal"
+};
+
+const int NUMFRAMES = sizeof(ID3Frames)/sizeof(ID3Frames[0]);
+const int NUMGENRES = sizeof(ID3Genres)/sizeof(ID3Genres[0]);
+
+
+LPSTR DupString(LPSTR lpsz)
+{
+ int cb = lstrlen(lpsz) + 1;
+ LPSTR lpszNew = LocalAlloc(LMEM_FIXED, cb);
+ if (lpszNew != NULL)
+ CopyMemory(lpszNew, lpsz, cb);
+ return lpszNew;
+}
+
+LPSTR GetFrameDesc(ID3_FrameID id)
+{
+ return DupString(ID3Frames[id]);
+}
+
+LPSTR GetGenre(LPSTR lpsz)
+{
+ int id = atoi(lpsz + 1);
+ int i;
+
+ if ((*(lpsz + 1) > '0') && (*(lpsz + 1) < '9'))
+ {
+ for (i = 0; i < NUMGENRES; i++)
+ {
+ if (id == ID3Genres[i].id)
+ return DupString(ID3Genres[i].name);
+ }
+ }
+ return DupString(lpsz);
+}
+
+void FillID3List(HWND hwndDlg, HWND hwndList, char *filename)
+{
+ ID3Tag *tag;
+ ID3Frame *frame;
+ ID3Field *field;
+ ID3_FrameID eFrameID;
+ char info[1024];
+ int numFrames;
+ int i;
+ int iItem = 0;
+
+
+ if ((tag = ID3Tag_New()) != NULL)
+ {
+ ID3Tag_Link(tag, filename);
+
+ numFrames = ID3Tag_NumFrames(tag);
+
+ for (i = 0; i < numFrames; i++)
+ {
+ iItem++;
+
+ frame = ID3Tag_GetFrameNum(tag, i);
+ eFrameID = ID3Frame_GetID(frame);
+
+ switch (eFrameID)
+ {
+ case ID3FID_ALBUM: case ID3FID_BPM:
+ case ID3FID_COMPOSER: case ID3FID_CONTENTTYPE:
+ case ID3FID_COPYRIGHT: case ID3FID_DATE:
+ case ID3FID_PLAYLISTDELAY: case ID3FID_ENCODEDBY:
+ case ID3FID_LYRICIST: case ID3FID_FILETYPE:
+ case ID3FID_TIME: case ID3FID_CONTENTGROUP:
+ case ID3FID_TITLE: case ID3FID_SUBTITLE:
+ case ID3FID_INITIALKEY: case ID3FID_LANGUAGE:
+ case ID3FID_SONGLEN: case ID3FID_MEDIATYPE:
+ case ID3FID_ORIGALBUM: case ID3FID_ORIGFILENAME:
+ case ID3FID_ORIGLYRICIST: case ID3FID_ORIGARTIST:
+ case ID3FID_ORIGYEAR: case ID3FID_FILEOWNER:
+ case ID3FID_LEADARTIST: case ID3FID_BAND:
+ case ID3FID_CONDUCTOR: case ID3FID_MIXARTIST:
+ case ID3FID_PARTINSET: case ID3FID_PUBLISHER:
+ case ID3FID_TRACKNUM: case ID3FID_RECORDINGDATES:
+ case ID3FID_NETRADIOSTATION: case ID3FID_NETRADIOOWNER:
+ case ID3FID_SIZE: case ID3FID_ISRC:
+ case ID3FID_ENCODERSETTINGS: case ID3FID_YEAR:
+ {
+ LV_ITEM lvi;
+ ID3ITEM *pItem = LocalAlloc(LPTR, sizeof(ID3ITEM));
+
+ /* Initialize LV_ITEM members that are common to all items. */
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
+ lvi.state = 0;
+ lvi.stateMask = 0;
+ lvi.pszText = LPSTR_TEXTCALLBACK; /* app. maintains text */
+ lvi.iImage = 0;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+
+ pItem->frameId = eFrameID;
+ pItem->aCols[0] = GetFrameDesc(eFrameID);
+
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ ID3Field_GetASCII(field, info, 1024, 1);
+ if (eFrameID == ID3FID_CONTENTTYPE)
+ pItem->aCols[1] = GetGenre(info);
+ else
+ pItem->aCols[1] = DupString(info);
+
+ lvi.lParam = (LPARAM)pItem; /* item data */
+
+ /* Add the item. */
+ ListView_InsertItem(hwndList, &lvi);
+
+ break;
+ }
+ case ID3FID_USERTEXT:
+ case ID3FID_COMMENT: /* Can also contain an extra language field (but not used now) */
+ case ID3FID_UNSYNCEDLYRICS: /* Can also contain an extra language field (but not used now) */
+ {
+ LV_ITEM lvi;
+ ID3ITEM *pItem = LocalAlloc(LPTR, sizeof(ID3ITEM));
+
+ /* Initialize LV_ITEM members that are common to all items. */
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
+ lvi.state = 0;
+ lvi.stateMask = 0;
+ lvi.pszText = LPSTR_TEXTCALLBACK; /* app. maintains text */
+ lvi.iImage = 0;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+
+ pItem->frameId = eFrameID;
+
+ field = ID3Frame_GetField(frame, ID3FN_DESCRIPTION);
+ ID3Field_GetASCII(field, info, 1024, 1);
+ pItem->aCols[0] = DupString(info);
+
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ ID3Field_GetASCII(field, info, 1024, 1);
+ pItem->aCols[1] = DupString(info);
+
+ lvi.lParam = (LPARAM)pItem; /* item data */
+
+ /* Add the item. */
+ ListView_InsertItem(hwndList, &lvi);
+
+ break;
+ }
+ case ID3FID_WWWAUDIOFILE: case ID3FID_WWWARTIST:
+ case ID3FID_WWWAUDIOSOURCE: case ID3FID_WWWCOMMERCIALINFO:
+ case ID3FID_WWWCOPYRIGHT: case ID3FID_WWWPUBLISHER:
+ case ID3FID_WWWPAYMENT: case ID3FID_WWWRADIOPAGE:
+ {
+ LV_ITEM lvi;
+ ID3ITEM *pItem = LocalAlloc(LPTR, sizeof(ID3ITEM));
+
+ /* Initialize LV_ITEM members that are common to all items. */
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
+ lvi.state = 0;
+ lvi.stateMask = 0;
+ lvi.pszText = LPSTR_TEXTCALLBACK; /* app. maintains text */
+ lvi.iImage = 0;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+
+ pItem->frameId = eFrameID;
+
+ pItem->aCols[0] = GetFrameDesc(eFrameID);
+
+ field = ID3Frame_GetField(frame, ID3FN_URL);
+ ID3Field_GetASCII(field, info, 1024, 1);
+ pItem->aCols[1] = DupString(info);
+
+ lvi.lParam = (LPARAM)pItem; /* item data */
+
+ /* Add the item. */
+ ListView_InsertItem(hwndList, &lvi);
+
+ break;
+ }
+ case ID3FID_WWWUSER:
+ {
+ LV_ITEM lvi;
+ ID3ITEM *pItem = LocalAlloc(LPTR, sizeof(ID3ITEM));
+
+ /* Initialize LV_ITEM members that are common to all items. */
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
+ lvi.state = 0;
+ lvi.stateMask = 0;
+ lvi.pszText = LPSTR_TEXTCALLBACK; /* app. maintains text */
+ lvi.iImage = 0;
+ lvi.iItem = iItem;
+ lvi.iSubItem = 0;
+
+ pItem->frameId = eFrameID;
+
+ field = ID3Frame_GetField(frame, ID3FN_DESCRIPTION);
+ ID3Field_GetASCII(field, info, 1024, 1);
+ pItem->aCols[0] = DupString(info);
+
+ field = ID3Frame_GetField(frame, ID3FN_URL);
+ ID3Field_GetASCII(field, info, 1024, 1);
+ pItem->aCols[1] = DupString(info);
+
+ lvi.lParam = (LPARAM)pItem; /* item data */
+
+ /* Add the item. */
+ ListView_InsertItem(hwndList, &lvi);
+
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ ID3Tag_Delete(tag);
+ }
+}
+
+BOOL CALLBACK AddFrameProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int i, cursel;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COL0), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
+
+ /* Note: FRAMEID is the index in the combo box + 1 */
+ for (i = 1; i < NUMFRAMES; i++)
+ {
+ SendMessage(GetDlgItem(hwndDlg, IDC_FRAMETYPE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)ID3Frames[i]);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_FRAMETYPE:
+ if (HIWORD(wParam) == CBN_SELCHANGE)
+ {
+ cursel = SendMessage(GetDlgItem(hwndDlg, IDC_FRAMETYPE), CB_GETCURSEL, 0, 0);
+
+ switch (cursel + 1)
+ {
+ case ID3FID_ALBUM: case ID3FID_BPM:
+ case ID3FID_COMPOSER: case ID3FID_COPYRIGHT:
+ case ID3FID_DATE: case ID3FID_PLAYLISTDELAY:
+ case ID3FID_ENCODEDBY: case ID3FID_LYRICIST:
+ case ID3FID_FILETYPE: case ID3FID_TIME:
+ case ID3FID_CONTENTGROUP: case ID3FID_TITLE:
+ case ID3FID_SUBTITLE: case ID3FID_INITIALKEY:
+ case ID3FID_LANGUAGE: case ID3FID_SONGLEN:
+ case ID3FID_MEDIATYPE: case ID3FID_ORIGALBUM:
+ case ID3FID_ORIGFILENAME: case ID3FID_ORIGLYRICIST:
+ case ID3FID_ORIGARTIST: case ID3FID_ORIGYEAR:
+ case ID3FID_FILEOWNER: case ID3FID_LEADARTIST:
+ case ID3FID_BAND: case ID3FID_CONDUCTOR:
+ case ID3FID_MIXARTIST: case ID3FID_PARTINSET:
+ case ID3FID_PUBLISHER: case ID3FID_TRACKNUM:
+ case ID3FID_RECORDINGDATES: case ID3FID_NETRADIOSTATION:
+ case ID3FID_NETRADIOOWNER: case ID3FID_SIZE:
+ case ID3FID_ISRC: case ID3FID_ENCODERSETTINGS:
+ case ID3FID_YEAR: case ID3FID_WWWAUDIOFILE:
+ case ID3FID_WWWARTIST: case ID3FID_WWWAUDIOSOURCE:
+ case ID3FID_WWWCOMMERCIALINFO: case ID3FID_WWWCOPYRIGHT:
+ case ID3FID_WWWPUBLISHER: case ID3FID_WWWPAYMENT:
+ case ID3FID_WWWRADIOPAGE: case ID3FID_CONTENTTYPE:
+ {
+ SetDlgItemText(hwndDlg, IDC_COL0, ID3Frames[cursel+1]);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COL0), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE);
+ break;
+ }
+ case ID3FID_USERTEXT: case ID3FID_COMMENT:
+ case ID3FID_UNSYNCEDLYRICS: case ID3FID_WWWUSER:
+ {
+ SetDlgItemText(hwndDlg, IDC_COL0, ID3Frames[cursel+1]);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COL0), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE);
+ break;
+ }
+ default:
+ MessageBox(hwndDlg, "Sorry, this frame type cannot be added (yet).", "Sorry", MB_OK);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COL0), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
+ break;
+ }
+ }
+ return TRUE;
+ case IDOK:
+ {
+ LV_ITEM lvi;
+ ID3ITEM *pItem = LocalAlloc(LPTR, sizeof(ID3ITEM));
+ char *col0 = LocalAlloc(LPTR, 1024);
+ char *col1 = LocalAlloc(LPTR, 1024);
+
+ /* Initialize LV_ITEM members that are common to all items. */
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
+ lvi.state = 0;
+ lvi.stateMask = 0;
+ lvi.pszText = LPSTR_TEXTCALLBACK; /* app. maintains text */
+ lvi.iImage = 0;
+ lvi.iItem = ListView_GetItemCount(m_hwndList) + 1;
+ lvi.iSubItem = 0;
+
+ cursel = SendMessage(GetDlgItem(hwndDlg, IDC_FRAMETYPE), CB_GETCURSEL, 0, 0);
+ pItem->frameId = cursel + 1;
+ GetDlgItemText(hwndDlg, IDC_COL0, col0, 1024);
+ GetDlgItemText(hwndDlg, IDC_COL1, col1, 1024);
+ pItem->aCols[0] = col0;
+ pItem->aCols[1] = col1;
+
+ lvi.lParam = (LPARAM)pItem; /* item data */
+
+ /* Add the item. */
+ ListView_InsertItem(m_hwndList, &lvi);
+ ListView_Update(m_hwndList, lvi.iItem);
+ }
+ case IDCANCEL:
+ EndDialog(hwndDlg, wParam);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+BOOL List_AddFrame(HWND hwndApp, HWND hwndList)
+{
+ int result;
+
+ m_hwndList = hwndList;
+
+ result = DialogBox(hInstance_for_id3editor, MAKEINTRESOURCE(IDD_ADDFRAME),
+ hwndApp, AddFrameProc);
+
+ if (LOWORD(result) == IDOK)
+ return TRUE;
+ return FALSE;
+}
+
+
+void InsertTextFrame(HWND dlg, HWND list, int control, int item, int frame_id)
+{
+ LV_ITEM lvi;
+ ID3ITEM *pItem = LocalAlloc(LPTR, sizeof(ID3ITEM));
+
+ /* Initialize LV_ITEM members that are common to all items. */
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
+ lvi.state = 0;
+ lvi.stateMask = 0;
+ lvi.pszText = LPSTR_TEXTCALLBACK; /* app. maintains text */
+ lvi.iImage = 0;
+ lvi.iItem = item;
+ lvi.iSubItem = 0;
+
+ pItem->frameId = frame_id;
+ pItem->aCols[0] = GetFrameDesc(frame_id);
+
+ pItem->aCols[1] = LocalAlloc(LPTR, 1024);
+ GetDlgItemText(dlg, control, pItem->aCols[1], 1024);
+
+ lvi.lParam = (LPARAM)pItem; /* item data */
+
+ /* Add the item. */
+ ListView_InsertItem(list, &lvi);
+}
+
+void AddFrameFromRAWData(HWND hwndList, int frameId, LPSTR data1, LPSTR data2)
+{
+ LV_ITEM lvi;
+ ID3ITEM *pItem = LocalAlloc(LPTR, sizeof(ID3ITEM));
+ int nextItem;
+
+ nextItem = ListView_GetItemCount(hwndList);
+
+ /* Initialize LV_ITEM members that are common to all items. */
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
+ lvi.state = 0;
+ lvi.stateMask = 0;
+ lvi.pszText = LPSTR_TEXTCALLBACK; /* app. maintains text */
+ lvi.iImage = 0;
+ lvi.iItem = nextItem;
+ lvi.iSubItem = 0;
+
+ pItem->frameId = frameId;
+
+ pItem->aCols[0] = LocalAlloc(LPTR, 1024);
+ pItem->aCols[1] = LocalAlloc(LPTR, 1024);
+
+ lstrcpy(pItem->aCols[0], data1);
+ lstrcpy(pItem->aCols[1], data2);
+
+ lvi.lParam = (LPARAM)pItem; /* item data */
+
+ /* Add the item. */
+ ListView_InsertItem(hwndList, &lvi);
+}
+
+HWND m_hwndDlg;
+int changed;
+
+BOOL CALLBACK AddStandardProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int added = 0;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ changed = 0;
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ {
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_TRACK)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_TRACK, ListView_GetItemCount(m_hwndList)+1, ID3FID_TRACKNUM);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_TITLE)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_TITLE, ListView_GetItemCount(m_hwndList)+1, ID3FID_TITLE);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_ARTIST)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_ARTIST, ListView_GetItemCount(m_hwndList)+1, ID3FID_LEADARTIST);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_ALBUM)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_ALBUM, ListView_GetItemCount(m_hwndList)+1, ID3FID_ALBUM);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_YEAR)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_YEAR, ListView_GetItemCount(m_hwndList)+1, ID3FID_YEAR);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_GENRE)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_GENRE, ListView_GetItemCount(m_hwndList)+1, ID3FID_CONTENTTYPE);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_COMMENT)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_COMMENT, ListView_GetItemCount(m_hwndList)+1, ID3FID_COMMENT);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_COMPOSER)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_COMPOSER, ListView_GetItemCount(m_hwndList)+1, ID3FID_COMPOSER);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_ORIGARTIST)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_ORIGARTIST, ListView_GetItemCount(m_hwndList)+1, ID3FID_ORIGARTIST);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_COPYRIGHT)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_COPYRIGHT, ListView_GetItemCount(m_hwndList)+1, ID3FID_COPYRIGHT);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URL)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_URL, ListView_GetItemCount(m_hwndList)+1, ID3FID_WWWARTIST);
+ added++;
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_ENCBY)) > 0) {
+ InsertTextFrame(hwndDlg, m_hwndList, IDC_ENCBY, ListView_GetItemCount(m_hwndList)+1, ID3FID_ENCODEDBY);
+ added++;
+ }
+
+ if (added > 0)
+ changed = 1;
+ }
+ case IDCANCEL:
+ EndDialog(hwndDlg, changed);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+BOOL List_AddStandardFrames(HWND hwndApp, HWND hwndList)
+{
+ int result;
+
+ m_hwndList = hwndList;
+ m_hwndDlg = hwndApp;
+
+ result = DialogBox(hInstance_for_id3editor, MAKEINTRESOURCE(IDD_ADDSTANDARD),
+ hwndApp, AddStandardProc);
+
+ return result?TRUE:FALSE;
+}
+
+
+/* List_OnGetDispInfo - processes the LVN_GETDISPINFO */
+/* notification message. */
+/* pnmv - value of lParam (points to an LV_DISPINFO structure) */
+void List_OnGetDispInfo(LV_DISPINFO *pnmv)
+{
+ /* Provide the item or subitem's text, if requested. */
+ if (pnmv->item.mask & LVIF_TEXT) {
+ ID3ITEM *pItem = (ID3ITEM *) (pnmv->item.lParam);
+ lstrcpy(pnmv->item.pszText,
+ pItem->aCols[pnmv->item.iSubItem]);
+ }
+}
+
+ID3ITEM *pItem;
+int editItemIndex;
+
+BOOL CALLBACK EditTextFrameProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LV_ITEM lvi;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ SetDlgItemText(hwndDlg, IDC_TEXTFRAMENAME, pItem->aCols[0]);
+ SetDlgItemText(hwndDlg, IDC_EDITTEXTFRAME, pItem->aCols[1]);
+
+ switch (pItem->frameId)
+ {
+ case ID3FID_ALBUM: case ID3FID_BPM:
+ case ID3FID_COMPOSER: case ID3FID_COPYRIGHT:
+ case ID3FID_DATE: case ID3FID_PLAYLISTDELAY:
+ case ID3FID_ENCODEDBY: case ID3FID_LYRICIST:
+ case ID3FID_FILETYPE: case ID3FID_TIME:
+ case ID3FID_CONTENTGROUP: case ID3FID_TITLE:
+ case ID3FID_SUBTITLE: case ID3FID_INITIALKEY:
+ case ID3FID_LANGUAGE: case ID3FID_SONGLEN:
+ case ID3FID_MEDIATYPE: case ID3FID_ORIGALBUM:
+ case ID3FID_ORIGFILENAME: case ID3FID_ORIGLYRICIST:
+ case ID3FID_ORIGARTIST: case ID3FID_ORIGYEAR:
+ case ID3FID_FILEOWNER: case ID3FID_LEADARTIST:
+ case ID3FID_BAND: case ID3FID_CONDUCTOR:
+ case ID3FID_MIXARTIST: case ID3FID_PARTINSET:
+ case ID3FID_PUBLISHER: case ID3FID_TRACKNUM:
+ case ID3FID_RECORDINGDATES: case ID3FID_NETRADIOSTATION:
+ case ID3FID_NETRADIOOWNER: case ID3FID_SIZE:
+ case ID3FID_ISRC: case ID3FID_ENCODERSETTINGS:
+ case ID3FID_YEAR: case ID3FID_WWWAUDIOFILE:
+ case ID3FID_WWWARTIST: case ID3FID_WWWAUDIOSOURCE:
+ case ID3FID_WWWCOMMERCIALINFO: case ID3FID_WWWCOPYRIGHT:
+ case ID3FID_WWWPUBLISHER: case ID3FID_WWWPAYMENT:
+ case ID3FID_WWWRADIOPAGE: case ID3FID_CONTENTTYPE:
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TEXTFRAMENAME), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EDITTEXTFRAME), TRUE);
+ break;
+ }
+ case ID3FID_USERTEXT: case ID3FID_COMMENT:
+ case ID3FID_UNSYNCEDLYRICS: case ID3FID_WWWUSER:
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TEXTFRAMENAME), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EDITTEXTFRAME), TRUE);
+ break;
+ }
+ default:
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TEXTFRAMENAME), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EDITTEXTFRAME), FALSE);
+ break;
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ {
+ GetDlgItemText(hwndDlg, IDC_TEXTFRAMENAME, pItem->aCols[0], 1024);
+ GetDlgItemText(hwndDlg, IDC_EDITTEXTFRAME, pItem->aCols[1], 1024);
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
+ lvi.state = 0;
+ lvi.stateMask = 0;
+ lvi.pszText = LPSTR_TEXTCALLBACK; /* app. maintains text */
+ lvi.iImage = 0;
+ lvi.iItem = editItemIndex;
+ lvi.iSubItem = 0;
+ lvi.lParam = (LPARAM)pItem; /* item data */
+
+ /* Add the item. */
+ ListView_SetItem(m_hwndList, &lvi);
+ ListView_Update(m_hwndList, editItemIndex);
+ } /* Fall through */
+ case IDCANCEL:
+ EndDialog(hwndDlg, wParam);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+/* Double clicking means editing a frame */
+BOOL List_EditData(HWND hwndApp, HWND hwndList)
+{
+ LV_ITEM lvi;
+ BOOL result;
+
+ /* First get the selected item */
+ int index = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED);
+
+ m_hwndList = hwndList;
+
+ if (index != -1)
+ {
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = index;
+ lvi.iSubItem = 0;
+
+ if (ListView_GetItem(hwndList, &lvi) == TRUE)
+ {
+ pItem = (ID3ITEM*)lvi.lParam;
+ editItemIndex = lvi.iItem;
+
+ result = DialogBox(hInstance_for_id3editor, MAKEINTRESOURCE(IDD_EDITTEXTFRAME),
+ hwndApp, EditTextFrameProc);
+ if (LOWORD(result) == IDOK)
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+/* Delete the selected frame */
+BOOL List_DeleteSelected(HWND hwndApp, HWND hwndList)
+{
+ int items;
+
+ /* First get the selected item */
+ int index = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED);
+
+ if (index != -1)
+ ListView_DeleteItem(hwndList, index);
+
+ items = ListView_GetItemCount(hwndList);
+ if (index != -1) return TRUE;
+ else return FALSE;
+}
+
+
+/* Save the ID3 to the file */
+void List_SaveID3(HWND hwndApp, HWND hwndList, char *filename)
+{
+ LV_ITEM lvi;
+ ID3ITEM *pItem1;
+ int i, items;
+ ID3Tag *tag;
+ ID3Frame *frame;
+ ID3Field *field;
+
+ /* Strip the tag first, before completely rewriting it */
+ if ((tag = ID3Tag_New()) != NULL)
+ {
+ ID3Tag_Link(tag, filename);
+ ID3Tag_Strip(tag, ID3TT_ALL);
+ ID3Tag_Clear(tag);
+
+ if (SendMessage(GetDlgItem(hwndApp, IDC_ID3V2TAG), BM_GETCHECK, 0, 0) == BST_UNCHECKED)
+ {
+ /* No frames saved */
+ ID3Tag_Delete(tag);
+ EnableWindow(GetDlgItem(hwndApp, IDC_ID3V2TAG), FALSE);
+ ListView_DeleteAllItems(hwndList);
+ return;
+ }
+
+ /* First get the number of items */
+ items = ListView_GetItemCount(hwndList);
+
+ if (items > 0)
+ {
+ for (i = 0; i < items; i++)
+ {
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = i;
+ lvi.iSubItem = 0;
+
+ if (ListView_GetItem(hwndList, &lvi) == TRUE)
+ {
+ pItem1 = (ID3ITEM*)lvi.lParam;
+
+ frame = ID3Frame_NewID(pItem1->frameId);
+
+ switch (pItem1->frameId)
+ {
+ case ID3FID_ALBUM: case ID3FID_BPM:
+ case ID3FID_COMPOSER: case ID3FID_CONTENTTYPE:
+ case ID3FID_COPYRIGHT: case ID3FID_DATE:
+ case ID3FID_PLAYLISTDELAY: case ID3FID_ENCODEDBY:
+ case ID3FID_LYRICIST: case ID3FID_FILETYPE:
+ case ID3FID_TIME: case ID3FID_CONTENTGROUP:
+ case ID3FID_TITLE: case ID3FID_SUBTITLE:
+ case ID3FID_INITIALKEY: case ID3FID_LANGUAGE:
+ case ID3FID_SONGLEN: case ID3FID_MEDIATYPE:
+ case ID3FID_ORIGALBUM: case ID3FID_ORIGFILENAME:
+ case ID3FID_ORIGLYRICIST: case ID3FID_ORIGARTIST:
+ case ID3FID_ORIGYEAR: case ID3FID_FILEOWNER:
+ case ID3FID_LEADARTIST: case ID3FID_BAND:
+ case ID3FID_CONDUCTOR: case ID3FID_MIXARTIST:
+ case ID3FID_PARTINSET: case ID3FID_PUBLISHER:
+ case ID3FID_TRACKNUM: case ID3FID_RECORDINGDATES:
+ case ID3FID_NETRADIOSTATION: case ID3FID_NETRADIOOWNER:
+ case ID3FID_SIZE: case ID3FID_ISRC:
+ case ID3FID_ENCODERSETTINGS: case ID3FID_YEAR:
+ {
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ ID3Field_SetASCII(field, pItem1->aCols[1]);
+ ID3Tag_AddFrame(tag, frame);
+ break;
+ }
+ case ID3FID_USERTEXT:
+ case ID3FID_COMMENT: /* Can also contain an extra language field (but not used now) */
+ case ID3FID_UNSYNCEDLYRICS: /* Can also contain an extra language field (but not used now) */
+ {
+ field = ID3Frame_GetField(frame, ID3FN_DESCRIPTION);
+ ID3Field_SetASCII(field, pItem1->aCols[0]);
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ ID3Field_SetASCII(field, pItem1->aCols[1]);
+ ID3Tag_AddFrame(tag, frame);
+ break;
+ }
+ case ID3FID_WWWAUDIOFILE: case ID3FID_WWWARTIST:
+ case ID3FID_WWWAUDIOSOURCE: case ID3FID_WWWCOMMERCIALINFO:
+ case ID3FID_WWWCOPYRIGHT: case ID3FID_WWWPUBLISHER:
+ case ID3FID_WWWPAYMENT: case ID3FID_WWWRADIOPAGE:
+ {
+ field = ID3Frame_GetField(frame, ID3FN_URL);
+ ID3Field_SetASCII(field, pItem1->aCols[1]);
+ ID3Tag_AddFrame(tag, frame);
+ break;
+ }
+ case ID3FID_WWWUSER:
+ {
+ field = ID3Frame_GetField(frame, ID3FN_DESCRIPTION);
+ ID3Field_SetASCII(field, pItem1->aCols[0]);
+ field = ID3Frame_GetField(frame, ID3FN_URL);
+ ID3Field_SetASCII(field, pItem1->aCols[1]);
+ ID3Tag_AddFrame(tag, frame);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ ID3Tag_UpdateByTagType(tag, ID3TT_ID3V2);
+ }
+
+ ID3Tag_Delete(tag);
+ }
+}
+
+/* Get the title from the file */
+void GetID3FileTitle(char *filename, char *title, char *format)
+{
+ ID3Tag *tag;
+ ID3Frame *frame;
+ ID3Field *field;
+ char buffer[255];
+ int some_info = 0;
+ char *in = format;
+ char *out = title;
+ char *bound = out + (MAX_PATH - 10 - 1);
+
+
+ if ((tag = ID3Tag_New()) != NULL)
+ {
+ ID3Tag_Link(tag, filename);
+
+ while (*in && out < bound)
+ {
+ switch (*in) {
+ case '%':
+ ++in;
+ break;
+
+ default:
+ *out++ = *in++;
+ continue;
+ }
+
+ /* handle % escape sequence */
+ switch (*in++) {
+ case '0':
+ if ((frame = ID3Tag_FindFrameWithID(tag, ID3FID_TRACKNUM)) != NULL) {
+ int size;
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ size = ID3Field_GetASCII(field, buffer, 255, 1);
+ lstrcpy(out, buffer); out += size;
+ some_info = 1;
+ }
+ break;
+ case '1':
+ if ((frame = ID3Tag_FindFrameWithID(tag, ID3FID_LEADARTIST)) != NULL) {
+ int size;
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ size = ID3Field_GetASCII(field, buffer, 255, 1);
+ lstrcpy(out, buffer); out += size;
+ some_info = 1;
+ }
+ break;
+ case '2':
+ if ((frame = ID3Tag_FindFrameWithID(tag, ID3FID_TITLE)) != NULL) {
+ int size;
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ size = ID3Field_GetASCII(field, buffer, 255, 1);
+ lstrcpy(out, buffer); out += size;
+ some_info = 1;
+ }
+ break;
+ case '3':
+ if ((frame = ID3Tag_FindFrameWithID(tag, ID3FID_ALBUM)) != NULL) {
+ int size;
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ size = ID3Field_GetASCII(field, buffer, 255, 1);
+ lstrcpy(out, buffer); out += size;
+ some_info = 1;
+ }
+ break;
+ case '4':
+ if ((frame = ID3Tag_FindFrameWithID(tag, ID3FID_YEAR)) != NULL) {
+ int size;
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ size = ID3Field_GetASCII(field, buffer, 255, 1);
+ lstrcpy(out, buffer); out += size;
+ some_info = 1;
+ }
+ break;
+ case '5':
+ if ((frame = ID3Tag_FindFrameWithID(tag, ID3FID_COMMENT)) != NULL) {
+ int size;
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ size = ID3Field_GetASCII(field, buffer, 255, 1);
+ lstrcpy(out, buffer); out += size;
+ some_info = 1;
+ }
+ break;
+ case '6':
+ if ((frame = ID3Tag_FindFrameWithID(tag, ID3FID_CONTENTTYPE)) != NULL) {
+ int size; char *tmp;
+ field = ID3Frame_GetField(frame, ID3FN_TEXT);
+ size = ID3Field_GetASCII(field, buffer, 255, 1);
+ tmp = GetGenre(buffer);
+ lstrcpy(out, tmp); out += size;
+ some_info = 1;
+ }
+ break;
+ case '7':
+ {
+ char *p=filename+lstrlen(filename);
+ int len = 0;
+ while (*p != '\\' && p >= filename) { p--; len++; }
+ lstrcpy(out, ++p); out += len;
+ some_info = 1;
+ break;
+ }
+ }
+ }
+
+ *out = '\0';
+ ID3Tag_Delete(tag);
+ }
+
+ if (!some_info)
+ {
+ char *p=filename+lstrlen(filename);
+ while (*p != '\\' && p >= filename) p--;
+ lstrcpy(title,++p);
+ }
+}
+
diff --git a/faad2/src/common/faad/id3v2tag.h b/faad2/src/common/faad/id3v2tag.h
new file mode 100644
index 0000000..041f524
--- /dev/null
+++ b/faad2/src/common/faad/id3v2tag.h
@@ -0,0 +1,54 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: id3v2tag.h,v 1.3 2003/07/29 08:20:11 menno Exp $
+**/
+
+#ifndef __ID3V2TAG_H__
+#define __ID3V2TAG_H__
+
+void GetID3FileTitle(char *filename, char *title, char *format);
+void FillID3List(HWND hwndDlg, HWND hwndList, char *filename);
+void List_OnGetDispInfo(LV_DISPINFO *pnmv);
+BOOL List_EditData(HWND hwndApp, HWND hwndList);
+void List_SaveID3(HWND hwndApp, HWND hwndList, char *filename);
+BOOL List_DeleteSelected(HWND hwndApp, HWND hwndList);
+BOOL List_AddFrame(HWND hwndApp, HWND hwndList);
+BOOL List_AddStandardFrames(HWND hwndApp, HWND hwndList);
+void AddFrameFromRAWData(HWND hwndList, int frameId, LPSTR data1, LPSTR data2);
+
+HINSTANCE hInstance_for_id3editor;
+
+typedef struct ID3GENRES_TAG
+{
+ BYTE id;
+ char name[30];
+} ID3GENRES;
+
+typedef struct id3item_tag {
+ int frameId;
+ LPSTR aCols[2];
+} ID3ITEM;
+
+#endif \ No newline at end of file
diff --git a/faad2/src/common/mp4ff/Makefile.am b/faad2/src/common/mp4ff/Makefile.am
new file mode 100644
index 0000000..abb8021
--- /dev/null
+++ b/faad2/src/common/mp4ff/Makefile.am
@@ -0,0 +1,7 @@
+lib_LIBRARIES = libmp4ff.a
+include_HEADERS = mp4ff.h mp4ffint.h
+
+libmp4ff_a_CFLAGS = -DUSE_TAGGING=1
+
+libmp4ff_a_SOURCES = mp4ff.c mp4atom.c mp4meta.c mp4sample.c mp4util.c \
+ mp4tagupdate.c mp4ff.h mp4ffint.h mp4ff_int_types.h
diff --git a/faad2/src/common/mp4ff/mp4atom.c b/faad2/src/common/mp4ff/mp4atom.c
new file mode 100644
index 0000000..8acd9b3
--- /dev/null
+++ b/faad2/src/common/mp4ff/mp4atom.c
@@ -0,0 +1,689 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mp4atom.c,v 1.29 2009/01/19 23:56:30 menno Exp $
+**/
+
+#include <stdlib.h>
+#ifndef _WIN32
+#include "config.h"
+#else
+#include <tchar.h>
+#include <windows.h>
+#endif
+#ifdef HAVE_GETPWUID
+# include <pwd.h>
+#endif
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+#include "mp4ffint.h"
+
+#define COPYRIGHT_SYMBOL ((int8_t)0xA9)
+
+/* parse atom header size */
+static int32_t mp4ff_atom_get_size(const int8_t *data)
+{
+ uint32_t result;
+ uint32_t a, b, c, d;
+
+ a = (uint8_t)data[0];
+ b = (uint8_t)data[1];
+ c = (uint8_t)data[2];
+ d = (uint8_t)data[3];
+
+ result = (a<<24) | (b<<16) | (c<<8) | d;
+ //if (result > 0 && result < 8) result = 8;
+
+ return (int32_t)result;
+}
+
+/* comnapre 2 atom names, returns 1 for equal, 0 for unequal */
+static int32_t mp4ff_atom_compare(const int8_t a1, const int8_t b1, const int8_t c1, const int8_t d1,
+ const int8_t a2, const int8_t b2, const int8_t c2, const int8_t d2)
+{
+ if (a1 == a2 && b1 == b2 && c1 == c2 && d1 == d2)
+ return 1;
+ else
+ return 0;
+}
+
+static uint8_t mp4ff_atom_name_to_type(const int8_t a, const int8_t b,
+ const int8_t c, const int8_t d)
+{
+ if (a == 'm')
+ {
+ if (mp4ff_atom_compare(a,b,c,d, 'm','o','o','v'))
+ return ATOM_MOOV;
+ else if (mp4ff_atom_compare(a,b,c,d, 'm','i','n','f'))
+ return ATOM_MINF;
+ else if (mp4ff_atom_compare(a,b,c,d, 'm','d','i','a'))
+ return ATOM_MDIA;
+ else if (mp4ff_atom_compare(a,b,c,d, 'm','d','a','t'))
+ return ATOM_MDAT;
+ else if (mp4ff_atom_compare(a,b,c,d, 'm','d','h','d'))
+ return ATOM_MDHD;
+ else if (mp4ff_atom_compare(a,b,c,d, 'm','v','h','d'))
+ return ATOM_MVHD;
+ else if (mp4ff_atom_compare(a,b,c,d, 'm','p','4','a'))
+ return ATOM_MP4A;
+ else if (mp4ff_atom_compare(a,b,c,d, 'm','p','4','v'))
+ return ATOM_MP4V;
+ else if (mp4ff_atom_compare(a,b,c,d, 'm','p','4','s'))
+ return ATOM_MP4S;
+ else if (mp4ff_atom_compare(a,b,c,d, 'm','e','t','a'))
+ return ATOM_META;
+ } else if (a == 't') {
+ if (mp4ff_atom_compare(a,b,c,d, 't','r','a','k'))
+ return ATOM_TRAK;
+ else if (mp4ff_atom_compare(a,b,c,d, 't','k','h','d'))
+ return ATOM_TKHD;
+ else if (mp4ff_atom_compare(a,b,c,d, 't','r','e','f'))
+ return ATOM_TREF;
+ else if (mp4ff_atom_compare(a,b,c,d, 't','r','k','n'))
+ return ATOM_TRACK;
+ else if (mp4ff_atom_compare(a,b,c,d, 't','m','p','o'))
+ return ATOM_TEMPO;
+ else if (mp4ff_atom_compare(a,b,c,d, 't','v','n','n'))
+ return ATOM_NETWORK;
+ else if (mp4ff_atom_compare(a,b,c,d, 't','v','s','h'))
+ return ATOM_SHOW;
+ else if (mp4ff_atom_compare(a,b,c,d, 't','v','e','n'))
+ return ATOM_EPISODENAME;
+ else if (mp4ff_atom_compare(a,b,c,d, 't','v','s','n'))
+ return ATOM_SEASON;
+ else if (mp4ff_atom_compare(a,b,c,d, 't','v','e','s'))
+ return ATOM_EPISODE;
+ } else if (a == 's') {
+ if (mp4ff_atom_compare(a,b,c,d, 's','t','b','l'))
+ return ATOM_STBL;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','m','h','d'))
+ return ATOM_SMHD;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','t','s','d'))
+ return ATOM_STSD;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','t','t','s'))
+ return ATOM_STTS;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','t','c','o'))
+ return ATOM_STCO;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','t','s','c'))
+ return ATOM_STSC;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','t','s','z'))
+ return ATOM_STSZ;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','t','z','2'))
+ return ATOM_STZ2;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','k','i','p'))
+ return ATOM_SKIP;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','i','n','f'))
+ return ATOM_SINF;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','c','h','i'))
+ return ATOM_SCHI;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','o','n','m'))
+ return ATOM_SORTTITLE;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','o','a','l'))
+ return ATOM_SORTALBUM;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','o','a','r'))
+ return ATOM_SORTARTIST;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','o','a','a'))
+ return ATOM_SORTALBUMARTIST;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','o','c','o'))
+ return ATOM_SORTWRITER;
+ else if (mp4ff_atom_compare(a,b,c,d, 's','o','s','n'))
+ return ATOM_SORTSHOW;
+ } else if (a == COPYRIGHT_SYMBOL) {
+ if (mp4ff_atom_compare(a,b,c,d, COPYRIGHT_SYMBOL,'n','a','m'))
+ return ATOM_TITLE;
+ else if (mp4ff_atom_compare(a,b,c,d, COPYRIGHT_SYMBOL,'A','R','T'))
+ return ATOM_ARTIST;
+ else if (mp4ff_atom_compare(a,b,c,d, COPYRIGHT_SYMBOL,'w','r','t'))
+ return ATOM_WRITER;
+ else if (mp4ff_atom_compare(a,b,c,d, COPYRIGHT_SYMBOL,'a','l','b'))
+ return ATOM_ALBUM;
+ else if (mp4ff_atom_compare(a,b,c,d, COPYRIGHT_SYMBOL,'d','a','y'))
+ return ATOM_DATE;
+ else if (mp4ff_atom_compare(a,b,c,d, COPYRIGHT_SYMBOL,'t','o','o'))
+ return ATOM_TOOL;
+ else if (mp4ff_atom_compare(a,b,c,d, COPYRIGHT_SYMBOL,'c','m','t'))
+ return ATOM_COMMENT;
+ else if (mp4ff_atom_compare(a,b,c,d, COPYRIGHT_SYMBOL,'g','e','n'))
+ return ATOM_GENRE1;
+ else if (mp4ff_atom_compare(a,b,c,d, COPYRIGHT_SYMBOL,'g','r','p'))
+ return ATOM_CONTENTGROUP;
+ else if (mp4ff_atom_compare(a,b,c,d, COPYRIGHT_SYMBOL,'l','y','r'))
+ return ATOM_LYRICS;
+ }
+
+ if (mp4ff_atom_compare(a,b,c,d, 'e','d','t','s'))
+ return ATOM_EDTS;
+ else if (mp4ff_atom_compare(a,b,c,d, 'e','s','d','s'))
+ return ATOM_ESDS;
+ else if (mp4ff_atom_compare(a,b,c,d, 'f','t','y','p'))
+ return ATOM_FTYP;
+ else if (mp4ff_atom_compare(a,b,c,d, 'f','r','e','e'))
+ return ATOM_FREE;
+ else if (mp4ff_atom_compare(a,b,c,d, 'h','m','h','d'))
+ return ATOM_HMHD;
+ else if (mp4ff_atom_compare(a,b,c,d, 'v','m','h','d'))
+ return ATOM_VMHD;
+ else if (mp4ff_atom_compare(a,b,c,d, 'u','d','t','a'))
+ return ATOM_UDTA;
+ else if (mp4ff_atom_compare(a,b,c,d, 'i','l','s','t'))
+ return ATOM_ILST;
+ else if (mp4ff_atom_compare(a,b,c,d, 'n','a','m','e'))
+ return ATOM_NAME;
+ else if (mp4ff_atom_compare(a,b,c,d, 'd','a','t','a'))
+ return ATOM_DATA;
+ else if (mp4ff_atom_compare(a,b,c,d, 'd','i','s','k'))
+ return ATOM_DISC;
+ else if (mp4ff_atom_compare(a,b,c,d, 'g','n','r','e'))
+ return ATOM_GENRE2;
+ else if (mp4ff_atom_compare(a,b,c,d, 'c','o','v','r'))
+ return ATOM_COVER;
+ else if (mp4ff_atom_compare(a,b,c,d, 'c','p','i','l'))
+ return ATOM_COMPILATION;
+ else if (mp4ff_atom_compare(a,b,c,d, 'c','t','t','s'))
+ return ATOM_CTTS;
+ else if (mp4ff_atom_compare(a,b,c,d, 'd','r','m','s'))
+ return ATOM_DRMS;
+ else if (mp4ff_atom_compare(a,b,c,d, 'f','r','m','a'))
+ return ATOM_FRMA;
+ else if (mp4ff_atom_compare(a,b,c,d, 'p','r','i','v'))
+ return ATOM_PRIV;
+ else if (mp4ff_atom_compare(a,b,c,d, 'i','v','i','v'))
+ return ATOM_IVIV;
+ else if (mp4ff_atom_compare(a,b,c,d, 'u','s','e','r'))
+ return ATOM_USER;
+ else if (mp4ff_atom_compare(a,b,c,d, 'k','e','y',' '))
+ return ATOM_KEY;
+ else if (mp4ff_atom_compare(a,b,c,d, 'a','A','R','T'))
+ return ATOM_ALBUM_ARTIST;
+ else if (mp4ff_atom_compare(a,b,c,d, 'd','e','s','c'))
+ return ATOM_DESCRIPTION;
+ else if (mp4ff_atom_compare(a,b,c,d, 'p','c','s','t'))
+ return ATOM_PODCAST;
+ else
+ return ATOM_UNKNOWN;
+}
+
+/* read atom header, return atom size, atom size is with header included */
+uint64_t mp4ff_atom_read_header(mp4ff_t *f, uint8_t *atom_type, uint8_t *header_size)
+{
+ uint64_t size;
+ int32_t ret;
+ int8_t atom_header[8];
+
+ ret = mp4ff_read_data(f, atom_header, 8);
+ if (ret != 8)
+ return 0;
+
+ size = mp4ff_atom_get_size(atom_header);
+ *header_size = 8;
+
+ /* check for 64 bit atom size */
+ if (size == 1)
+ {
+ *header_size = 16;
+ size = mp4ff_read_int64(f);
+ }
+
+ //printf("%c%c%c%c\n", atom_header[4], atom_header[5], atom_header[6], atom_header[7]);
+
+ *atom_type = mp4ff_atom_name_to_type(atom_header[4], atom_header[5], atom_header[6], atom_header[7]);
+
+ return size;
+}
+
+static int32_t mp4ff_read_stsz(mp4ff_t *f)
+{
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+ f->track[f->total_tracks - 1]->stsz_sample_size = mp4ff_read_int32(f);
+ f->track[f->total_tracks - 1]->stsz_sample_count = mp4ff_read_int32(f);
+
+ if (f->track[f->total_tracks - 1]->stsz_sample_size == 0)
+ {
+ int32_t i;
+ f->track[f->total_tracks - 1]->stsz_table =
+ (int32_t*)malloc(f->track[f->total_tracks - 1]->stsz_sample_count*sizeof(int32_t));
+
+ for (i = 0; i < f->track[f->total_tracks - 1]->stsz_sample_count; i++)
+ {
+ f->track[f->total_tracks - 1]->stsz_table[i] = mp4ff_read_int32(f);
+ }
+ }
+
+ return 0;
+}
+
+static int32_t mp4ff_read_esds(mp4ff_t *f)
+{
+ uint8_t tag;
+ uint32_t temp;
+
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+
+ /* get and verify ES_DescrTag */
+ tag = mp4ff_read_char(f);
+ if (tag == 0x03)
+ {
+ /* read length */
+ if (mp4ff_read_mp4_descr_length(f) < 5 + 15)
+ {
+ return 1;
+ }
+ /* skip 3 bytes */
+ mp4ff_read_int24(f);
+ } else {
+ /* skip 2 bytes */
+ mp4ff_read_int16(f);
+ }
+
+ /* get and verify DecoderConfigDescrTab */
+ if (mp4ff_read_char(f) != 0x04)
+ {
+ return 1;
+ }
+
+ /* read length */
+ temp = mp4ff_read_mp4_descr_length(f);
+ if (temp < 13) return 1;
+
+ f->track[f->total_tracks - 1]->audioType = mp4ff_read_char(f);
+ mp4ff_read_int32(f);//0x15000414 ????
+ f->track[f->total_tracks - 1]->maxBitrate = mp4ff_read_int32(f);
+ f->track[f->total_tracks - 1]->avgBitrate = mp4ff_read_int32(f);
+
+ /* get and verify DecSpecificInfoTag */
+ if (mp4ff_read_char(f) != 0x05)
+ {
+ return 1;
+ }
+
+ /* read length */
+ f->track[f->total_tracks - 1]->decoderConfigLen = mp4ff_read_mp4_descr_length(f);
+
+ if (f->track[f->total_tracks - 1]->decoderConfig)
+ free(f->track[f->total_tracks - 1]->decoderConfig);
+ f->track[f->total_tracks - 1]->decoderConfig = malloc(f->track[f->total_tracks - 1]->decoderConfigLen);
+ if (f->track[f->total_tracks - 1]->decoderConfig)
+ {
+ mp4ff_read_data(f, f->track[f->total_tracks - 1]->decoderConfig, f->track[f->total_tracks - 1]->decoderConfigLen);
+ } else {
+ f->track[f->total_tracks - 1]->decoderConfigLen = 0;
+ }
+
+ /* will skip the remainder of the atom */
+ return 0;
+}
+
+static int32_t mp4ff_read_mp4a(mp4ff_t *f)
+{
+ uint64_t size;
+ int32_t i;
+ uint8_t atom_type = 0;
+ uint8_t header_size = 0;
+
+ for (i = 0; i < 6; i++)
+ {
+ mp4ff_read_char(f); /* reserved */
+ }
+ /* data_reference_index */ mp4ff_read_int16(f);
+
+ mp4ff_read_int32(f); /* reserved */
+ mp4ff_read_int32(f); /* reserved */
+
+ f->track[f->total_tracks - 1]->channelCount = mp4ff_read_int16(f);
+ f->track[f->total_tracks - 1]->sampleSize = mp4ff_read_int16(f);
+
+ mp4ff_read_int16(f);
+ mp4ff_read_int16(f);
+
+ f->track[f->total_tracks - 1]->sampleRate = mp4ff_read_int16(f);
+
+ mp4ff_read_int16(f);
+
+ size = mp4ff_atom_read_header(f, &atom_type, &header_size);
+ if (atom_type == ATOM_ESDS)
+ {
+ mp4ff_read_esds(f);
+ }
+
+ return 0;
+}
+
+static int32_t mp4ff_read_stsd(mp4ff_t *f)
+{
+ int32_t i;
+ uint8_t header_size = 0;
+
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+
+ f->track[f->total_tracks - 1]->stsd_entry_count = mp4ff_read_int32(f);
+
+ for (i = 0; i < f->track[f->total_tracks - 1]->stsd_entry_count; i++)
+ {
+ uint64_t skip = mp4ff_position(f);
+ uint64_t size;
+ uint8_t atom_type = 0;
+ size = mp4ff_atom_read_header(f, &atom_type, &header_size);
+ skip += size;
+
+ if (atom_type == ATOM_MP4A)
+ {
+ f->track[f->total_tracks - 1]->type = TRACK_AUDIO;
+ mp4ff_read_mp4a(f);
+ } else if (atom_type == ATOM_MP4V) {
+ f->track[f->total_tracks - 1]->type = TRACK_VIDEO;
+ } else if (atom_type == ATOM_MP4S) {
+ f->track[f->total_tracks - 1]->type = TRACK_SYSTEM;
+ } else {
+ f->track[f->total_tracks - 1]->type = TRACK_UNKNOWN;
+ }
+
+ mp4ff_set_position(f, skip);
+ }
+
+ return 0;
+}
+
+static int32_t mp4ff_read_stsc(mp4ff_t *f)
+{
+ int32_t i;
+
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+ f->track[f->total_tracks - 1]->stsc_entry_count = mp4ff_read_int32(f);
+
+ f->track[f->total_tracks - 1]->stsc_first_chunk =
+ (int32_t*)malloc(f->track[f->total_tracks - 1]->stsc_entry_count*sizeof(int32_t));
+ f->track[f->total_tracks - 1]->stsc_samples_per_chunk =
+ (int32_t*)malloc(f->track[f->total_tracks - 1]->stsc_entry_count*sizeof(int32_t));
+ f->track[f->total_tracks - 1]->stsc_sample_desc_index =
+ (int32_t*)malloc(f->track[f->total_tracks - 1]->stsc_entry_count*sizeof(int32_t));
+
+ for (i = 0; i < f->track[f->total_tracks - 1]->stsc_entry_count; i++)
+ {
+ f->track[f->total_tracks - 1]->stsc_first_chunk[i] = mp4ff_read_int32(f);
+ f->track[f->total_tracks - 1]->stsc_samples_per_chunk[i] = mp4ff_read_int32(f);
+ f->track[f->total_tracks - 1]->stsc_sample_desc_index[i] = mp4ff_read_int32(f);
+ }
+
+ return 0;
+}
+
+static int32_t mp4ff_read_stco(mp4ff_t *f)
+{
+ int32_t i;
+
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+ f->track[f->total_tracks - 1]->stco_entry_count = mp4ff_read_int32(f);
+
+ f->track[f->total_tracks - 1]->stco_chunk_offset =
+ (int32_t*)malloc(f->track[f->total_tracks - 1]->stco_entry_count*sizeof(int32_t));
+
+ for (i = 0; i < f->track[f->total_tracks - 1]->stco_entry_count; i++)
+ {
+ f->track[f->total_tracks - 1]->stco_chunk_offset[i] = mp4ff_read_int32(f);
+ }
+
+ return 0;
+}
+
+static int32_t mp4ff_read_ctts(mp4ff_t *f)
+{
+ int32_t i;
+ mp4ff_track_t * p_track = f->track[f->total_tracks - 1];
+
+ if (p_track->ctts_entry_count) return 0;
+
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+ p_track->ctts_entry_count = mp4ff_read_int32(f);
+
+ p_track->ctts_sample_count = (int32_t*)malloc(p_track->ctts_entry_count * sizeof(int32_t));
+ p_track->ctts_sample_offset = (int32_t*)malloc(p_track->ctts_entry_count * sizeof(int32_t));
+
+ if (p_track->ctts_sample_count == 0 || p_track->ctts_sample_offset == 0)
+ {
+ if (p_track->ctts_sample_count) {free(p_track->ctts_sample_count);p_track->ctts_sample_count=0;}
+ if (p_track->ctts_sample_offset) {free(p_track->ctts_sample_offset);p_track->ctts_sample_offset=0;}
+ p_track->ctts_entry_count = 0;
+ return 0;
+ }
+ else
+ {
+ for (i = 0; i < f->track[f->total_tracks - 1]->ctts_entry_count; i++)
+ {
+ p_track->ctts_sample_count[i] = mp4ff_read_int32(f);
+ p_track->ctts_sample_offset[i] = mp4ff_read_int32(f);
+ }
+ return 1;
+ }
+}
+
+static int32_t mp4ff_read_stts(mp4ff_t *f)
+{
+ int32_t i;
+ mp4ff_track_t * p_track = f->track[f->total_tracks - 1];
+
+ if (p_track->stts_entry_count) return 0;
+
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+ p_track->stts_entry_count = mp4ff_read_int32(f);
+
+ p_track->stts_sample_count = (int32_t*)malloc(p_track->stts_entry_count * sizeof(int32_t));
+ p_track->stts_sample_delta = (int32_t*)malloc(p_track->stts_entry_count * sizeof(int32_t));
+
+ if (p_track->stts_sample_count == 0 || p_track->stts_sample_delta == 0)
+ {
+ if (p_track->stts_sample_count) {free(p_track->stts_sample_count);p_track->stts_sample_count=0;}
+ if (p_track->stts_sample_delta) {free(p_track->stts_sample_delta);p_track->stts_sample_delta=0;}
+ p_track->stts_entry_count = 0;
+ return 0;
+ }
+ else
+ {
+ for (i = 0; i < f->track[f->total_tracks - 1]->stts_entry_count; i++)
+ {
+ p_track->stts_sample_count[i] = mp4ff_read_int32(f);
+ p_track->stts_sample_delta[i] = mp4ff_read_int32(f);
+ }
+ return 1;
+ }
+}
+
+static int32_t mp4ff_read_mvhd(mp4ff_t *f)
+{
+ int32_t i;
+
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+ /* creation_time */ mp4ff_read_int32(f);
+ /* modification_time */ mp4ff_read_int32(f);
+ f->time_scale = mp4ff_read_int32(f);
+ f->duration = mp4ff_read_int32(f);
+ /* preferred_rate */ mp4ff_read_int32(f); /*mp4ff_read_fixed32(f);*/
+ /* preferred_volume */ mp4ff_read_int16(f); /*mp4ff_read_fixed16(f);*/
+ for (i = 0; i < 10; i++)
+ {
+ /* reserved */ mp4ff_read_char(f);
+ }
+ for (i = 0; i < 9; i++)
+ {
+ mp4ff_read_int32(f); /* matrix */
+ }
+ /* preview_time */ mp4ff_read_int32(f);
+ /* preview_duration */ mp4ff_read_int32(f);
+ /* poster_time */ mp4ff_read_int32(f);
+ /* selection_time */ mp4ff_read_int32(f);
+ /* selection_duration */ mp4ff_read_int32(f);
+ /* current_time */ mp4ff_read_int32(f);
+ /* next_track_id */ mp4ff_read_int32(f);
+
+ return 0;
+}
+
+#if 0
+static int32_t mp4ff_read_tkhd(mp4ff_t *f)
+{
+ uint8_t version;
+ uint32_t flags;
+ version = mp4ff_read_char(f); /* version */
+ flags = mp4ff_read_int24(f); /* flags */
+ if (version==1)
+ {
+ mp4ff_read_int64(f);//creation-time
+ mp4ff_read_int64(f);//modification-time
+ mp4ff_read_int32(f);//track-id
+ mp4ff_read_int32(f);//reserved
+ f->track[f->total_tracks - 1]->duration = mp4ff_read_int64(f);//duration
+ }
+ else //version == 0
+ {
+ mp4ff_read_int32(f);//creation-time
+ mp4ff_read_int32(f);//modification-time
+ mp4ff_read_int32(f);//track-id
+ mp4ff_read_int32(f);//reserved
+ f->track[f->total_tracks - 1]->duration = mp4ff_read_int32(f);//duration
+ if (f->track[f->total_tracks - 1]->duration == 0xFFFFFFFF)
+ f->track[f->total_tracks - 1]->duration = 0xFFFFFFFFFFFFFFFF;
+
+ }
+ mp4ff_read_int32(f);//reserved
+ mp4ff_read_int32(f);//reserved
+ mp4ff_read_int16(f);//layer
+ mp4ff_read_int16(f);//pre-defined
+ mp4ff_read_int16(f);//volume
+ mp4ff_read_int16(f);//reserved
+
+ //matrix
+ mp4ff_read_int32(f); mp4ff_read_int32(f); mp4ff_read_int32(f);
+ mp4ff_read_int32(f); mp4ff_read_int32(f); mp4ff_read_int32(f);
+ mp4ff_read_int32(f); mp4ff_read_int32(f); mp4ff_read_int32(f);
+ mp4ff_read_int32(f);//width
+ mp4ff_read_int32(f);//height
+ return 1;
+}
+#endif
+
+static int32_t mp4ff_read_mdhd(mp4ff_t *f)
+{
+ uint32_t version;
+
+ version = mp4ff_read_int32(f);
+ if (version==1)
+ {
+ mp4ff_read_int64(f);//creation-time
+ mp4ff_read_int64(f);//modification-time
+ f->track[f->total_tracks - 1]->timeScale = mp4ff_read_int32(f);//timescale
+ f->track[f->total_tracks - 1]->duration = mp4ff_read_int64(f);//duration
+ }
+ else //version == 0
+ {
+ uint32_t temp;
+
+ mp4ff_read_int32(f);//creation-time
+ mp4ff_read_int32(f);//modification-time
+ f->track[f->total_tracks - 1]->timeScale = mp4ff_read_int32(f);//timescale
+ temp = mp4ff_read_int32(f);
+ f->track[f->total_tracks - 1]->duration = (temp == (uint32_t)(-1)) ? (uint64_t)(-1) : (uint64_t)(temp);
+ }
+ mp4ff_read_int16(f);
+ mp4ff_read_int16(f);
+ return 1;
+}
+#ifdef USE_TAGGING
+static int32_t mp4ff_read_meta(mp4ff_t *f, const uint64_t size)
+{
+ uint64_t subsize, sumsize = 0;
+ uint8_t atom_type;
+ uint8_t header_size = 0;
+
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+
+ while (sumsize < (size-(header_size+4)))
+ {
+ subsize = mp4ff_atom_read_header(f, &atom_type, &header_size);
+ if (subsize <= header_size+4)
+ return 1;
+ if (atom_type == ATOM_ILST)
+ {
+ mp4ff_parse_metadata(f, (uint32_t)(subsize-(header_size+4)));
+ } else {
+ mp4ff_set_position(f, mp4ff_position(f)+subsize-header_size);
+ }
+ sumsize += subsize;
+ }
+
+ return 0;
+}
+#endif
+
+int32_t mp4ff_atom_read(mp4ff_t *f, const int32_t size, const uint8_t atom_type)
+{
+ uint64_t dest_position = mp4ff_position(f)+size-8;
+ if (atom_type == ATOM_STSZ)
+ {
+ /* sample size box */
+ mp4ff_read_stsz(f);
+ } else if (atom_type == ATOM_STTS) {
+ /* time to sample box */
+ mp4ff_read_stts(f);
+ } else if (atom_type == ATOM_CTTS) {
+ /* composition offset box */
+ mp4ff_read_ctts(f);
+ } else if (atom_type == ATOM_STSC) {
+ /* sample to chunk box */
+ mp4ff_read_stsc(f);
+ } else if (atom_type == ATOM_STCO) {
+ /* chunk offset box */
+ mp4ff_read_stco(f);
+ } else if (atom_type == ATOM_STSD) {
+ /* sample description box */
+ mp4ff_read_stsd(f);
+ } else if (atom_type == ATOM_MVHD) {
+ /* movie header box */
+ mp4ff_read_mvhd(f);
+ } else if (atom_type == ATOM_MDHD) {
+ /* track header */
+ mp4ff_read_mdhd(f);
+#ifdef USE_TAGGING
+ } else if (atom_type == ATOM_META) {
+ /* iTunes Metadata box */
+ mp4ff_read_meta(f, size);
+#endif
+ }
+
+ mp4ff_set_position(f, dest_position);
+
+
+ return 0;
+}
diff --git a/faad2/src/common/mp4ff/mp4ff.c b/faad2/src/common/mp4ff/mp4ff.c
new file mode 100644
index 0000000..f513e86
--- /dev/null
+++ b/faad2/src/common/mp4ff/mp4ff.c
@@ -0,0 +1,475 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mp4ff.c,v 1.22 2009/01/26 23:01:40 menno Exp $
+**/
+
+#include <stdlib.h>
+#include <string.h>
+#include "mp4ffint.h"
+
+mp4ff_t *mp4ff_open_read(mp4ff_callback_t *f)
+{
+ mp4ff_t *ff = malloc(sizeof(mp4ff_t));
+
+ memset(ff, 0, sizeof(mp4ff_t));
+
+ ff->stream = f;
+
+ parse_atoms(ff,0);
+
+ return ff;
+}
+
+mp4ff_t *mp4ff_open_read_metaonly(mp4ff_callback_t *f)
+{
+ mp4ff_t *ff = malloc(sizeof(mp4ff_t));
+
+ memset(ff, 0, sizeof(mp4ff_t));
+
+ ff->stream = f;
+
+ parse_atoms(ff,1);
+
+ return ff;
+}
+
+void mp4ff_close(mp4ff_t *ff)
+{
+ int32_t i;
+
+ for (i = 0; i < ff->total_tracks; i++)
+ {
+ if (ff->track[i])
+ {
+ if (ff->track[i]->stsz_table)
+ free(ff->track[i]->stsz_table);
+ if (ff->track[i]->stts_sample_count)
+ free(ff->track[i]->stts_sample_count);
+ if (ff->track[i]->stts_sample_delta)
+ free(ff->track[i]->stts_sample_delta);
+ if (ff->track[i]->stsc_first_chunk)
+ free(ff->track[i]->stsc_first_chunk);
+ if (ff->track[i]->stsc_samples_per_chunk)
+ free(ff->track[i]->stsc_samples_per_chunk);
+ if (ff->track[i]->stsc_sample_desc_index)
+ free(ff->track[i]->stsc_sample_desc_index);
+ if (ff->track[i]->stco_chunk_offset)
+ free(ff->track[i]->stco_chunk_offset);
+ if (ff->track[i]->decoderConfig)
+ free(ff->track[i]->decoderConfig);
+ if (ff->track[i]->ctts_sample_count)
+ free(ff->track[i]->ctts_sample_count);
+ if (ff->track[i]->ctts_sample_offset)
+ free(ff->track[i]->ctts_sample_offset);
+#ifdef ITUNES_DRM
+ if (ff->track[i]->p_drms)
+ drms_free(ff->track[i]->p_drms);
+#endif
+ free(ff->track[i]);
+ }
+ }
+
+#ifdef USE_TAGGING
+ mp4ff_tag_delete(&(ff->tags));
+#endif
+
+ if (ff) free(ff);
+}
+
+void mp4ff_track_add(mp4ff_t *f)
+{
+ f->total_tracks++;
+
+ f->track[f->total_tracks - 1] = malloc(sizeof(mp4ff_track_t));
+
+ memset(f->track[f->total_tracks - 1], 0, sizeof(mp4ff_track_t));
+}
+
+static int need_parse_when_meta_only(uint8_t atom_type)
+{
+ switch(atom_type)
+ {
+ case ATOM_EDTS:
+// case ATOM_MDIA:
+// case ATOM_MINF:
+ case ATOM_DRMS:
+ case ATOM_SINF:
+ case ATOM_SCHI:
+// case ATOM_STBL:
+// case ATOM_STSD:
+ case ATOM_STTS:
+ case ATOM_STSZ:
+ case ATOM_STZ2:
+ case ATOM_STCO:
+ case ATOM_STSC:
+// case ATOM_CTTS:
+ case ATOM_FRMA:
+ case ATOM_IVIV:
+ case ATOM_PRIV:
+ return 0;
+ default:
+ return 1;
+ }
+}
+
+/* parse atoms that are sub atoms of other atoms */
+int32_t parse_sub_atoms(mp4ff_t *f, const uint64_t total_size,int meta_only)
+{
+ uint64_t size;
+ uint8_t atom_type = 0;
+ uint64_t counted_size = 0;
+ uint8_t header_size = 0;
+
+ while (counted_size < total_size)
+ {
+ size = mp4ff_atom_read_header(f, &atom_type, &header_size);
+ counted_size += size;
+
+ /* check for end of file */
+ if (size == 0)
+ break;
+
+ /* we're starting to read a new track, update index,
+ * so that all data and tables get written in the right place
+ */
+ if (atom_type == ATOM_TRAK)
+ {
+ mp4ff_track_add(f);
+ }
+
+ /* parse subatoms */
+ if (meta_only && !need_parse_when_meta_only(atom_type))
+ {
+ mp4ff_set_position(f, mp4ff_position(f)+size-header_size);
+ } else if (atom_type < SUBATOMIC)
+ {
+ parse_sub_atoms(f, size-header_size,meta_only);
+ } else {
+ mp4ff_atom_read(f, (uint32_t)size, atom_type);
+ }
+ }
+
+ return 0;
+}
+
+/* parse root atoms */
+int32_t parse_atoms(mp4ff_t *f,int meta_only)
+{
+ uint64_t size;
+ uint8_t atom_type = 0;
+ uint8_t header_size = 0;
+
+ f->file_size = 0;
+
+ while ((size = mp4ff_atom_read_header(f, &atom_type, &header_size)) != 0)
+ {
+ f->file_size += size;
+ f->last_atom = atom_type;
+
+ if (atom_type == ATOM_MDAT && f->moov_read)
+ {
+ /* moov atom is before mdat, we can stop reading when mdat is encountered */
+ /* file position will stay at beginning of mdat data */
+// break;
+ }
+
+ if (atom_type == ATOM_MOOV && size > header_size)
+ {
+ f->moov_read = 1;
+ f->moov_offset = mp4ff_position(f)-header_size;
+ f->moov_size = size;
+ }
+
+ /* parse subatoms */
+ if (meta_only && !need_parse_when_meta_only(atom_type))
+ {
+ mp4ff_set_position(f, mp4ff_position(f)+size-header_size);
+ } else if (atom_type < SUBATOMIC)
+ {
+ parse_sub_atoms(f, size-header_size,meta_only);
+ } else {
+ /* skip this atom */
+ mp4ff_set_position(f, mp4ff_position(f)+size-header_size);
+ }
+ }
+
+ return 0;
+}
+
+int32_t mp4ff_get_decoder_config(const mp4ff_t *f, const int32_t track,
+ uint8_t** ppBuf, uint32_t* pBufSize)
+{
+ if (track >= f->total_tracks)
+ {
+ *ppBuf = NULL;
+ *pBufSize = 0;
+ return 1;
+ }
+
+ if (f->track[track]->decoderConfig == NULL || f->track[track]->decoderConfigLen == 0)
+ {
+ *ppBuf = NULL;
+ *pBufSize = 0;
+ } else {
+ *ppBuf = malloc(f->track[track]->decoderConfigLen);
+ if (*ppBuf == NULL)
+ {
+ *pBufSize = 0;
+ return 1;
+ }
+ memcpy(*ppBuf, f->track[track]->decoderConfig, f->track[track]->decoderConfigLen);
+ *pBufSize = f->track[track]->decoderConfigLen;
+ }
+
+ return 0;
+}
+
+int32_t mp4ff_get_track_type(const mp4ff_t *f, const int track)
+{
+ return f->track[track]->type;
+}
+
+int32_t mp4ff_total_tracks(const mp4ff_t *f)
+{
+ return f->total_tracks;
+}
+
+int32_t mp4ff_time_scale(const mp4ff_t *f, const int32_t track)
+{
+ return f->track[track]->timeScale;
+}
+
+uint32_t mp4ff_get_avg_bitrate(const mp4ff_t *f, const int32_t track)
+{
+ return f->track[track]->avgBitrate;
+}
+
+uint32_t mp4ff_get_max_bitrate(const mp4ff_t *f, const int32_t track)
+{
+ return f->track[track]->maxBitrate;
+}
+
+int64_t mp4ff_get_track_duration(const mp4ff_t *f, const int32_t track)
+{
+ return f->track[track]->duration;
+}
+
+int64_t mp4ff_get_track_duration_use_offsets(const mp4ff_t *f, const int32_t track)
+{
+ int64_t duration = mp4ff_get_track_duration(f,track);
+ if (duration!=-1)
+ {
+ int64_t offset = mp4ff_get_sample_offset(f,track,0);
+ if (offset > duration) duration = 0;
+ else duration -= offset;
+ }
+ return duration;
+}
+
+
+int32_t mp4ff_num_samples(const mp4ff_t *f, const int32_t track)
+{
+ int32_t i;
+ int32_t total = 0;
+
+ for (i = 0; i < f->track[track]->stts_entry_count; i++)
+ {
+ total += f->track[track]->stts_sample_count[i];
+ }
+ return total;
+}
+
+
+
+
+uint32_t mp4ff_get_sample_rate(const mp4ff_t *f, const int32_t track)
+{
+ return f->track[track]->sampleRate;
+}
+
+uint32_t mp4ff_get_channel_count(const mp4ff_t * f,const int32_t track)
+{
+ return f->track[track]->channelCount;
+}
+
+uint32_t mp4ff_get_audio_type(const mp4ff_t * f,const int32_t track)
+{
+ return f->track[track]->audioType;
+}
+
+int32_t mp4ff_get_sample_duration_use_offsets(const mp4ff_t *f, const int32_t track, const int32_t sample)
+{
+ int32_t d,o;
+ d = mp4ff_get_sample_duration(f,track,sample);
+ if (d!=-1)
+ {
+ o = mp4ff_get_sample_offset(f,track,sample);
+ if (o>d) d = 0;
+ else d -= o;
+ }
+ return d;
+}
+
+int32_t mp4ff_get_sample_duration(const mp4ff_t *f, const int32_t track, const int32_t sample)
+{
+ int32_t i, co = 0;
+
+ for (i = 0; i < f->track[track]->stts_entry_count; i++)
+ {
+ int32_t delta = f->track[track]->stts_sample_count[i];
+ if (sample < co + delta)
+ return f->track[track]->stts_sample_delta[i];
+ co += delta;
+ }
+ return (int32_t)(-1);
+}
+
+int64_t mp4ff_get_sample_position(const mp4ff_t *f, const int32_t track, const int32_t sample)
+{
+ int32_t i, co = 0;
+ int64_t acc = 0;
+
+ for (i = 0; i < f->track[track]->stts_entry_count; i++)
+ {
+ int32_t delta = f->track[track]->stts_sample_count[i];
+ if (sample < co + delta)
+ {
+ acc += f->track[track]->stts_sample_delta[i] * (sample - co);
+ return acc;
+ }
+ else
+ {
+ acc += f->track[track]->stts_sample_delta[i] * delta;
+ }
+ co += delta;
+ }
+ return (int64_t)(-1);
+}
+
+int32_t mp4ff_get_sample_offset(const mp4ff_t *f, const int32_t track, const int32_t sample)
+{
+ int32_t i, co = 0;
+
+ for (i = 0; i < f->track[track]->ctts_entry_count; i++)
+ {
+ int32_t delta = f->track[track]->ctts_sample_count[i];
+ if (sample < co + delta)
+ return f->track[track]->ctts_sample_offset[i];
+ co += delta;
+ }
+ return 0;
+}
+
+int32_t mp4ff_find_sample(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip)
+{
+ int32_t i, co = 0;
+ int64_t offset_total = 0;
+ mp4ff_track_t * p_track = f->track[track];
+
+ for (i = 0; i < p_track->stts_entry_count; i++)
+ {
+ int32_t sample_count = p_track->stts_sample_count[i];
+ int32_t sample_delta = p_track->stts_sample_delta[i];
+ int64_t offset_delta = (int64_t)sample_delta * (int64_t)sample_count;
+ if (offset < offset_total + offset_delta)
+ {
+ int64_t offset_fromstts = offset - offset_total;
+ if (toskip) *toskip = (int32_t)(offset_fromstts % sample_delta);
+ return co + (int32_t)(offset_fromstts / sample_delta);
+ }
+ else
+ {
+ offset_total += offset_delta;
+ }
+ co += sample_count;
+ }
+ return (int32_t)(-1);
+}
+
+int32_t mp4ff_find_sample_use_offsets(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip)
+{
+ return mp4ff_find_sample(f,track,offset + mp4ff_get_sample_offset(f,track,0),toskip);
+}
+
+int32_t mp4ff_read_sample(mp4ff_t *f, const int32_t track, const int32_t sample,
+ uint8_t **audio_buffer, uint32_t *bytes)
+{
+ int32_t result = 0;
+
+ *bytes = mp4ff_audio_frame_size(f, track, sample);
+
+ if (*bytes==0) return 0;
+
+ *audio_buffer = (uint8_t*)malloc(*bytes);
+
+ mp4ff_set_sample_position(f, track, sample);
+
+ result = mp4ff_read_data(f, *audio_buffer, *bytes);
+
+ if (!result)
+ {
+ free(*audio_buffer);
+ *audio_buffer = 0;
+ return 0;
+ }
+
+#ifdef ITUNES_DRM
+ if (f->track[track]->p_drms != NULL)
+ {
+ drms_decrypt(f->track[track]->p_drms, (uint32_t*)*audio_buffer, *bytes);
+ }
+#endif
+
+ return *bytes;
+}
+
+
+int32_t mp4ff_read_sample_v2(mp4ff_t *f, const int track, const int sample,unsigned char *buffer)
+{
+ int32_t result = 0;
+ int32_t size = mp4ff_audio_frame_size(f,track,sample);
+ if (size<=0) return 0;
+ mp4ff_set_sample_position(f, track, sample);
+ result = mp4ff_read_data(f,buffer,size);
+
+#ifdef ITUNES_DRM
+ if (f->track[track]->p_drms != NULL)
+ {
+ drms_decrypt(f->track[track]->p_drms, (uint32_t*)buffer, size);
+ }
+#endif
+
+ return result;
+}
+
+int32_t mp4ff_read_sample_getsize(mp4ff_t *f, const int track, const int sample)
+{
+ int32_t temp = mp4ff_audio_frame_size(f, track, sample);
+ if (temp<0) temp = 0;
+ return temp;
+}
diff --git a/faad2/src/common/mp4ff/mp4ff.h b/faad2/src/common/mp4ff/mp4ff.h
new file mode 100644
index 0000000..7e68428
--- /dev/null
+++ b/faad2/src/common/mp4ff/mp4ff.h
@@ -0,0 +1,138 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mp4ff.h,v 1.27 2009/01/29 00:41:08 menno Exp $
+**/
+
+#ifndef MP4FF_H
+#define MP4FF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#else
+#include "mp4ff_int_types.h"
+#endif
+
+/* file callback structure */
+typedef struct
+{
+ uint32_t (*read)(void *user_data, void *buffer, uint32_t length);
+ uint32_t (*write)(void *udata, void *buffer, uint32_t length);
+ uint32_t (*seek)(void *user_data, uint64_t position);
+ uint32_t (*truncate)(void *user_data);
+ void *user_data;
+} mp4ff_callback_t;
+
+/* mp4 main file structure */
+typedef void* mp4ff_t;
+
+
+/* API */
+
+mp4ff_t *mp4ff_open_read(mp4ff_callback_t *f);
+mp4ff_t *mp4ff_open_read_metaonly(mp4ff_callback_t *f);
+void mp4ff_close(mp4ff_t *f);
+int32_t mp4ff_get_sample_duration(const mp4ff_t *f, const int32_t track, const int32_t sample);
+int32_t mp4ff_get_sample_duration_use_offsets(const mp4ff_t *f, const int32_t track, const int32_t sample);
+int64_t mp4ff_get_sample_position(const mp4ff_t *f, const int32_t track, const int32_t sample);
+int32_t mp4ff_get_sample_offset(const mp4ff_t *f, const int32_t track, const int32_t sample);
+int32_t mp4ff_find_sample(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip);
+int32_t mp4ff_find_sample_use_offsets(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip);
+
+int32_t mp4ff_read_sample(mp4ff_t *f, const int track, const int sample,
+ unsigned char **audio_buffer, unsigned int *bytes);
+
+int32_t mp4ff_read_sample_v2(mp4ff_t *f, const int track, const int sample,unsigned char *buffer);//returns 0 on error, number of bytes read on success, use mp4ff_read_sample_getsize() to check buffer size needed
+int32_t mp4ff_read_sample_getsize(mp4ff_t *f, const int track, const int sample);//returns 0 on error, buffer size needed for mp4ff_read_sample_v2() on success
+
+
+
+int32_t mp4ff_get_decoder_config(const mp4ff_t *f, const int track,
+ unsigned char** ppBuf, unsigned int* pBufSize);
+int32_t mp4ff_get_track_type(const mp4ff_t *f, const int track);
+int32_t mp4ff_total_tracks(const mp4ff_t *f);
+int32_t mp4ff_num_samples(const mp4ff_t *f, const int track);
+int32_t mp4ff_time_scale(const mp4ff_t *f, const int track);
+
+uint32_t mp4ff_get_avg_bitrate(const mp4ff_t *f, const int32_t track);
+uint32_t mp4ff_get_max_bitrate(const mp4ff_t *f, const int32_t track);
+int64_t mp4ff_get_track_duration(const mp4ff_t *f, const int32_t track); //returns (-1) if unknown
+int64_t mp4ff_get_track_duration_use_offsets(const mp4ff_t *f, const int32_t track); //returns (-1) if unknown
+uint32_t mp4ff_get_sample_rate(const mp4ff_t *f, const int32_t track);
+uint32_t mp4ff_get_channel_count(const mp4ff_t * f,const int32_t track);
+uint32_t mp4ff_get_audio_type(const mp4ff_t * f,const int32_t track);
+
+
+/* metadata */
+int mp4ff_meta_get_num_items(const mp4ff_t *f);
+int mp4ff_meta_get_by_index(const mp4ff_t *f, unsigned int index,
+ char **item, char **value);
+int mp4ff_meta_get_title(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_artist(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_writer(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_album(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_date(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_tool(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_comment(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_genre(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_track(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_disc(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_totaltracks(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_totaldiscs(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_compilation(const mp4ff_t *f, char **value);
+int mp4ff_meta_get_tempo(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_coverart(const mp4ff_t *f, char **value);
+#ifdef USE_TAGGING
+
+/* metadata tag structure */
+typedef struct
+{
+ char *item;
+ char *value;
+} mp4ff_tag_t;
+
+/* metadata list structure */
+typedef struct
+{
+ mp4ff_tag_t *tags;
+ uint32_t count;
+} mp4ff_metadata_t;
+
+int32_t mp4ff_meta_update(mp4ff_callback_t *f,const mp4ff_metadata_t * data);
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/faad2/src/common/mp4ff/mp4ff.vcproj b/faad2/src/common/mp4ff/mp4ff.vcproj
new file mode 100644
index 0000000..db1e8d1
--- /dev/null
+++ b/faad2/src/common/mp4ff/mp4ff.vcproj
@@ -0,0 +1,326 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="mp4ff"
+ ProjectGUID="{F470BB4A-7675-4D6A-B310-41F33AC6F987}"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="4"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="USE_TAGGING"
+ StringPooling="true"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderFile=".\Release/mp4ff.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ Detect64BitPortabilityProblems="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1043"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ AdditionalOptions=""
+ OutputFile=".\Release\mp4ff.lib"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="4"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions="USE_TAGGING"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderFile=".\Debug/mp4ff.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1043"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ AdditionalOptions=""
+ OutputFile=".\Debug\mp4ff.lib"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath="mp4atom.c"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="1"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="mp4ff.c"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="1"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="mp4meta.c"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="1"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="mp4sample.c"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="1"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\mp4tagupdate.c"
+ >
+ </File>
+ <File
+ RelativePath="mp4util.c"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="1"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath=".\drmstables.h"
+ >
+ </File>
+ <File
+ RelativePath=".\mp4ff.h"
+ >
+ </File>
+ <File
+ RelativePath=".\mp4ff_int_types.h"
+ >
+ </File>
+ <File
+ RelativePath="mp4ffint.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/faad2/src/common/mp4ff/mp4ff_int_types.h b/faad2/src/common/mp4ff/mp4ff_int_types.h
new file mode 100644
index 0000000..3d3089c
--- /dev/null
+++ b/faad2/src/common/mp4ff/mp4ff_int_types.h
@@ -0,0 +1,27 @@
+#ifndef _MP4FF_INT_TYPES_H_
+#define _MP4FF_INT_TYPES_H_
+
+#if defined (_WIN32)
+
+#ifdef __MINGW32__
+#include <stdlib.h>
+#endif /* #ifdef __MINGW32__ */
+
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+typedef signed long int32_t;
+typedef unsigned long uint32_t;
+
+typedef signed __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+
+#else
+
+#include <stdint.h>
+
+#endif
+
+
+#endif
diff --git a/faad2/src/common/mp4ff/mp4ffint.h b/faad2/src/common/mp4ff/mp4ffint.h
new file mode 100644
index 0000000..8052d43
--- /dev/null
+++ b/faad2/src/common/mp4ff/mp4ffint.h
@@ -0,0 +1,344 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mp4ffint.h,v 1.26 2009/01/25 20:14:34 menno Exp $
+**/
+
+#ifndef MP4FF_INTERNAL_H
+#define MP4FF_INTERNAL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "mp4ff_int_types.h"
+#include <stdlib.h>
+
+#define MAX_TRACKS 1024
+#define TRACK_UNKNOWN 0
+#define TRACK_AUDIO 1
+#define TRACK_VIDEO 2
+#define TRACK_SYSTEM 3
+
+
+#define SUBATOMIC 128
+
+/* atoms without subatoms */
+#define ATOM_FTYP 129
+#define ATOM_MDAT 130
+#define ATOM_MVHD 131
+#define ATOM_TKHD 132
+#define ATOM_TREF 133
+#define ATOM_MDHD 134
+#define ATOM_VMHD 135
+#define ATOM_SMHD 136
+#define ATOM_HMHD 137
+#define ATOM_STSD 138
+#define ATOM_STTS 139
+#define ATOM_STSZ 140
+#define ATOM_STZ2 141
+#define ATOM_STCO 142
+#define ATOM_STSC 143
+#define ATOM_MP4A 144
+#define ATOM_MP4V 145
+#define ATOM_MP4S 146
+#define ATOM_ESDS 147
+#define ATOM_META 148 /* iTunes Metadata box */
+#define ATOM_NAME 149 /* iTunes Metadata name box */
+#define ATOM_DATA 150 /* iTunes Metadata data box */
+#define ATOM_CTTS 151
+#define ATOM_FRMA 152
+#define ATOM_IVIV 153
+#define ATOM_PRIV 154
+#define ATOM_USER 155
+#define ATOM_KEY 156
+
+#define ATOM_ALBUM_ARTIST 157
+#define ATOM_CONTENTGROUP 158
+#define ATOM_LYRICS 159
+#define ATOM_DESCRIPTION 160
+#define ATOM_NETWORK 161
+#define ATOM_SHOW 162
+#define ATOM_EPISODENAME 163
+#define ATOM_SORTTITLE 164
+#define ATOM_SORTALBUM 165
+#define ATOM_SORTARTIST 166
+#define ATOM_SORTALBUMARTIST 167
+#define ATOM_SORTWRITER 168
+#define ATOM_SORTSHOW 169
+#define ATOM_SEASON 170
+#define ATOM_EPISODE 171
+#define ATOM_PODCAST 172
+
+#define ATOM_UNKNOWN 255
+#define ATOM_FREE ATOM_UNKNOWN
+#define ATOM_SKIP ATOM_UNKNOWN
+
+/* atoms with subatoms */
+#define ATOM_MOOV 1
+#define ATOM_TRAK 2
+#define ATOM_EDTS 3
+#define ATOM_MDIA 4
+#define ATOM_MINF 5
+#define ATOM_STBL 6
+#define ATOM_UDTA 7
+#define ATOM_ILST 8 /* iTunes Metadata list */
+#define ATOM_TITLE 9
+#define ATOM_ARTIST 10
+#define ATOM_WRITER 11
+#define ATOM_ALBUM 12
+#define ATOM_DATE 13
+#define ATOM_TOOL 14
+#define ATOM_COMMENT 15
+#define ATOM_GENRE1 16
+#define ATOM_TRACK 17
+#define ATOM_DISC 18
+#define ATOM_COMPILATION 19
+#define ATOM_GENRE2 20
+#define ATOM_TEMPO 21
+#define ATOM_COVER 22
+#define ATOM_DRMS 23
+#define ATOM_SINF 24
+#define ATOM_SCHI 25
+
+#ifdef HAVE_CONFIG_H
+#include "../../config.h"
+#endif
+
+#if !(defined(_WIN32) || defined(_WIN32_WCE))
+#define stricmp strcasecmp
+#else
+#define stricmp _stricmp
+#define strdup _strdup
+#endif
+
+/* file callback structure */
+typedef struct
+{
+ uint32_t (*read)(void *user_data, void *buffer, uint32_t length);
+ uint32_t (*write)(void *udata, void *buffer, uint32_t length);
+ uint32_t (*seek)(void *user_data, uint64_t position);
+ uint32_t (*truncate)(void *user_data);
+ void *user_data;
+} mp4ff_callback_t;
+
+
+/* metadata tag structure */
+typedef struct
+{
+ char *item;
+ char *value;
+} mp4ff_tag_t;
+
+/* metadata list structure */
+typedef struct
+{
+ mp4ff_tag_t *tags;
+ uint32_t count;
+} mp4ff_metadata_t;
+
+
+typedef struct
+{
+ int32_t type;
+ int32_t channelCount;
+ int32_t sampleSize;
+ uint16_t sampleRate;
+ int32_t audioType;
+
+ /* stsd */
+ int32_t stsd_entry_count;
+
+ /* stsz */
+ int32_t stsz_sample_size;
+ int32_t stsz_sample_count;
+ int32_t *stsz_table;
+
+ /* stts */
+ int32_t stts_entry_count;
+ int32_t *stts_sample_count;
+ int32_t *stts_sample_delta;
+
+ /* stsc */
+ int32_t stsc_entry_count;
+ int32_t *stsc_first_chunk;
+ int32_t *stsc_samples_per_chunk;
+ int32_t *stsc_sample_desc_index;
+
+ /* stsc */
+ int32_t stco_entry_count;
+ int32_t *stco_chunk_offset;
+
+ /* ctts */
+ int32_t ctts_entry_count;
+ int32_t *ctts_sample_count;
+ int32_t *ctts_sample_offset;
+
+ /* esde */
+ uint8_t *decoderConfig;
+ int32_t decoderConfigLen;
+
+ uint32_t maxBitrate;
+ uint32_t avgBitrate;
+
+ uint32_t timeScale;
+ uint64_t duration;
+
+} mp4ff_track_t;
+
+/* mp4 main file structure */
+typedef struct
+{
+ /* stream to read from */
+ mp4ff_callback_t *stream;
+ int64_t current_position;
+
+ int32_t moov_read;
+ uint64_t moov_offset;
+ uint64_t moov_size;
+ uint8_t last_atom;
+ uint64_t file_size;
+
+ /* mvhd */
+ int32_t time_scale;
+ int32_t duration;
+
+ /* incremental track index while reading the file */
+ int32_t total_tracks;
+
+ /* track data */
+ mp4ff_track_t *track[MAX_TRACKS];
+
+ /* metadata */
+ mp4ff_metadata_t tags;
+} mp4ff_t;
+
+
+
+
+/* mp4util.c */
+int32_t mp4ff_read_data(mp4ff_t *f, int8_t *data, uint32_t size);
+int32_t mp4ff_write_data(mp4ff_t *f, int8_t *data, uint32_t size);
+uint64_t mp4ff_read_int64(mp4ff_t *f);
+uint32_t mp4ff_read_int32(mp4ff_t *f);
+uint32_t mp4ff_read_int24(mp4ff_t *f);
+uint16_t mp4ff_read_int16(mp4ff_t *f);
+uint8_t mp4ff_read_char(mp4ff_t *f);
+int32_t mp4ff_write_int32(mp4ff_t *f,const uint32_t data);
+uint32_t mp4ff_read_mp4_descr_length(mp4ff_t *f);
+int64_t mp4ff_position(const mp4ff_t *f);
+int32_t mp4ff_set_position(mp4ff_t *f, const int64_t position);
+int32_t mp4ff_truncate(mp4ff_t * f);
+char * mp4ff_read_string(mp4ff_t * f,uint32_t length);
+
+/* mp4atom.c */
+static int32_t mp4ff_atom_get_size(const int8_t *data);
+static int32_t mp4ff_atom_compare(const int8_t a1, const int8_t b1, const int8_t c1, const int8_t d1,
+ const int8_t a2, const int8_t b2, const int8_t c2, const int8_t d2);
+static uint8_t mp4ff_atom_name_to_type(const int8_t a, const int8_t b, const int8_t c, const int8_t d);
+uint64_t mp4ff_atom_read_header(mp4ff_t *f, uint8_t *atom_type, uint8_t *header_size);
+static int32_t mp4ff_read_stsz(mp4ff_t *f);
+static int32_t mp4ff_read_esds(mp4ff_t *f);
+static int32_t mp4ff_read_mp4a(mp4ff_t *f);
+static int32_t mp4ff_read_stsd(mp4ff_t *f);
+static int32_t mp4ff_read_stsc(mp4ff_t *f);
+static int32_t mp4ff_read_stco(mp4ff_t *f);
+static int32_t mp4ff_read_stts(mp4ff_t *f);
+#ifdef USE_TAGGING
+static int32_t mp4ff_read_meta(mp4ff_t *f, const uint64_t size);
+#endif
+int32_t mp4ff_atom_read(mp4ff_t *f, const int32_t size, const uint8_t atom_type);
+
+/* mp4sample.c */
+static int32_t mp4ff_chunk_of_sample(const mp4ff_t *f, const int32_t track, const int32_t sample,
+ int32_t *chunk_sample, int32_t *chunk);
+static int32_t mp4ff_chunk_to_offset(const mp4ff_t *f, const int32_t track, const int32_t chunk);
+static int32_t mp4ff_sample_range_size(const mp4ff_t *f, const int32_t track,
+ const int32_t chunk_sample, const int32_t sample);
+static int32_t mp4ff_sample_to_offset(const mp4ff_t *f, const int32_t track, const int32_t sample);
+int32_t mp4ff_audio_frame_size(const mp4ff_t *f, const int32_t track, const int32_t sample);
+int32_t mp4ff_set_sample_position(mp4ff_t *f, const int32_t track, const int32_t sample);
+
+#ifdef USE_TAGGING
+/* mp4meta.c */
+static int32_t mp4ff_tag_add_field(mp4ff_metadata_t *tags, const char *item, const char *value);
+static int32_t mp4ff_tag_set_field(mp4ff_metadata_t *tags, const char *item, const char *value);
+static int32_t mp4ff_set_metadata_name(mp4ff_t *f, const uint8_t atom_type, char **name);
+static int32_t mp4ff_parse_tag(mp4ff_t *f, const uint8_t parent_atom_type, const int32_t size);
+static int32_t mp4ff_meta_find_by_name(const mp4ff_t *f, const char *item, char **value);
+int32_t mp4ff_parse_metadata(mp4ff_t *f, const int32_t size);
+int32_t mp4ff_tag_delete(mp4ff_metadata_t *tags);
+int32_t mp4ff_meta_get_num_items(const mp4ff_t *f);
+int32_t mp4ff_meta_get_by_index(const mp4ff_t *f, uint32_t index,
+ char **item, char **value);
+int32_t mp4ff_meta_get_title(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_artist(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_writer(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_album(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_date(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_tool(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_comment(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_genre(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_track(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_disc(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_compilation(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_tempo(const mp4ff_t *f, char **value);
+int32_t mp4ff_meta_get_coverart(const mp4ff_t *f, char **value);
+#endif
+
+/* mp4ff.c */
+mp4ff_t *mp4ff_open_read(mp4ff_callback_t *f);
+#ifdef USE_TAGGING
+mp4ff_t *mp4ff_open_edit(mp4ff_callback_t *f);
+#endif
+void mp4ff_close(mp4ff_t *ff);
+//void mp4ff_track_add(mp4ff_t *f);
+int32_t parse_sub_atoms(mp4ff_t *f, const uint64_t total_size,int meta_only);
+int32_t parse_atoms(mp4ff_t *f,int meta_only);
+
+int32_t mp4ff_get_sample_duration(const mp4ff_t *f, const int32_t track, const int32_t sample);
+int64_t mp4ff_get_sample_position(const mp4ff_t *f, const int32_t track, const int32_t sample);
+int32_t mp4ff_get_sample_offset(const mp4ff_t *f, const int32_t track, const int32_t sample);
+int32_t mp4ff_find_sample(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip);
+
+int32_t mp4ff_read_sample(mp4ff_t *f, const int32_t track, const int32_t sample,
+ uint8_t **audio_buffer, uint32_t *bytes);
+int32_t mp4ff_get_decoder_config(const mp4ff_t *f, const int32_t track,
+ uint8_t** ppBuf, uint32_t* pBufSize);
+int32_t mp4ff_total_tracks(const mp4ff_t *f);
+int32_t mp4ff_time_scale(const mp4ff_t *f, const int32_t track);
+int32_t mp4ff_num_samples(const mp4ff_t *f, const int32_t track);
+
+uint32_t mp4ff_meta_genre_to_index(const char * genrestr);//returns 1-based index, 0 if not found
+const char * mp4ff_meta_index_to_genre(uint32_t idx);//returns pointer to static string
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/faad2/src/common/mp4ff/mp4meta.c b/faad2/src/common/mp4ff/mp4meta.c
new file mode 100644
index 0000000..4e75862
--- /dev/null
+++ b/faad2/src/common/mp4ff/mp4meta.c
@@ -0,0 +1,461 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mp4meta.c,v 1.21 2009/01/19 23:56:30 menno Exp $
+**/
+
+#ifdef USE_TAGGING
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "mp4ffint.h"
+
+
+
+static int32_t mp4ff_tag_add_field(mp4ff_metadata_t *tags, const char *item, const char *value)
+{
+ void *backup = (void *)tags->tags;
+
+ if (!item || (item && !*item) || !value) return 0;
+
+ tags->tags = (mp4ff_tag_t*)realloc(tags->tags, (tags->count+1) * sizeof(mp4ff_tag_t));
+ if (!tags->tags)
+ {
+ if (backup) free(backup);
+ return 0;
+ } else {
+ tags->tags[tags->count].item = strdup(item);
+ tags->tags[tags->count].value = strdup(value);
+
+ if (!tags->tags[tags->count].item || !tags->tags[tags->count].value)
+ {
+ if (!tags->tags[tags->count].item) free (tags->tags[tags->count].item);
+ if (!tags->tags[tags->count].value) free (tags->tags[tags->count].value);
+ tags->tags[tags->count].item = NULL;
+ tags->tags[tags->count].value = NULL;
+ return 0;
+ }
+
+ tags->count++;
+ return 1;
+ }
+}
+
+static int32_t mp4ff_tag_set_field(mp4ff_metadata_t *tags, const char *item, const char *value)
+{
+ unsigned int i;
+
+ if (!item || (item && !*item) || !value) return 0;
+
+ for (i = 0; i < tags->count; i++)
+ {
+ if (!stricmp(tags->tags[i].item, item))
+ {
+ free(tags->tags[i].value);
+ tags->tags[i].value = strdup(value);
+ return 1;
+ }
+ }
+
+ return mp4ff_tag_add_field(tags, item, value);
+}
+
+int32_t mp4ff_tag_delete(mp4ff_metadata_t *tags)
+{
+ uint32_t i;
+
+ for (i = 0; i < tags->count; i++)
+ {
+ if (tags->tags[i].item) free(tags->tags[i].item);
+ if (tags->tags[i].value) free(tags->tags[i].value);
+ }
+
+ if (tags->tags) free(tags->tags);
+
+ tags->tags = NULL;
+ tags->count = 0;
+
+ return 0;
+}
+
+static const char* ID3v1GenreList[] = {
+ "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk",
+ "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies",
+ "Other", "Pop", "R&B", "Rap", "Reggae", "Rock",
+ "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks",
+ "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk",
+ "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House",
+ "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass",
+ "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock",
+ "Ethnic", "Gothic", "Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk",
+ "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta",
+ "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret",
+ "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi",
+ "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical",
+ "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", "Swing",
+ "Fast-Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde",
+ "Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band",
+ "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson",
+ "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus",
+ "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba",
+ "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet",
+ "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall",
+ "Goa", "Drum & Bass", "Club House", "Hardcore", "Terror",
+ "Indie", "BritPop", "NegerPunk", "Polsk Punk", "Beat",
+ "Christian Gangsta", "Heavy Metal", "Black Metal", "Crossover", "Contemporary C",
+ "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "JPop",
+ "SynthPop",
+};
+
+uint32_t mp4ff_meta_genre_to_index(const char * genrestr)
+{
+ unsigned n;
+ for(n=0;n<sizeof(ID3v1GenreList)/sizeof(ID3v1GenreList[0]);n++)
+ {
+ if (!stricmp(genrestr,ID3v1GenreList[n])) return n+1;
+ }
+ return 0;
+}
+
+const char * mp4ff_meta_index_to_genre(uint32_t idx)
+{
+ if (idx>0 && idx<=sizeof(ID3v1GenreList)/sizeof(ID3v1GenreList[0]))
+ {
+ return ID3v1GenreList[idx-1];
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+
+static int32_t TrackToString(char** str, const uint16_t track, const uint16_t totalTracks)
+{
+ char temp[32];
+ sprintf(temp, "%.5u of %.5u", track, totalTracks);
+ *str = strdup(temp);
+ return 0;
+}
+
+static int32_t mp4ff_set_metadata_name(mp4ff_t *f, const uint8_t atom_type, char **name)
+{
+ static char *tag_names[] = {
+ "unknown", "title", "artist", "writer", "album",
+ "date", "tool", "comment", "genre", "track",
+ "disc", "compilation", "genre", "tempo", "cover",
+ "album_artist", "contentgroup", "lyrics", "description",
+ "network", "show", "episodename",
+ "sorttitle", "sortalbum", "sortartist", "sortalbumartist",
+ "sortwriter", "sortshow",
+ "season", "episode", "podcast"
+
+ };
+ uint8_t tag_idx = 0;
+
+ switch (atom_type)
+ {
+ case ATOM_TITLE: tag_idx = 1; break;
+ case ATOM_ARTIST: tag_idx = 2; break;
+ case ATOM_WRITER: tag_idx = 3; break;
+ case ATOM_ALBUM: tag_idx = 4; break;
+ case ATOM_DATE: tag_idx = 5; break;
+ case ATOM_TOOL: tag_idx = 6; break;
+ case ATOM_COMMENT: tag_idx = 7; break;
+ case ATOM_GENRE1: tag_idx = 8; break;
+ case ATOM_TRACK: tag_idx = 9; break;
+ case ATOM_DISC: tag_idx = 10; break;
+ case ATOM_COMPILATION: tag_idx = 11; break;
+ case ATOM_GENRE2: tag_idx = 12; break;
+ case ATOM_TEMPO: tag_idx = 13; break;
+ case ATOM_COVER: tag_idx = 14; break;
+ case ATOM_ALBUM_ARTIST: tag_idx = 15; break;
+ case ATOM_CONTENTGROUP: tag_idx = 16; break;
+ case ATOM_LYRICS: tag_idx = 17; break;
+ case ATOM_DESCRIPTION: tag_idx = 18; break;
+ case ATOM_NETWORK: tag_idx = 19; break;
+ case ATOM_SHOW: tag_idx = 20; break;
+ case ATOM_EPISODENAME: tag_idx = 21; break;
+ case ATOM_SORTTITLE: tag_idx = 22; break;
+ case ATOM_SORTALBUM: tag_idx = 23; break;
+ case ATOM_SORTARTIST: tag_idx = 24; break;
+ case ATOM_SORTALBUMARTIST: tag_idx = 25; break;
+ case ATOM_SORTWRITER: tag_idx = 26; break;
+ case ATOM_SORTSHOW: tag_idx = 27; break;
+ case ATOM_SEASON: tag_idx = 28; break;
+ case ATOM_EPISODE: tag_idx = 29; break;
+ case ATOM_PODCAST: tag_idx = 30; break;
+ default: tag_idx = 0; break;
+ }
+
+ *name = strdup(tag_names[tag_idx]);
+
+ return 0;
+}
+
+static int32_t mp4ff_parse_tag(mp4ff_t *f, const uint8_t parent_atom_type, const int32_t size)
+{
+ uint8_t atom_type;
+ uint8_t header_size = 0;
+ uint64_t subsize, sumsize = 0;
+ char * name = NULL;
+ char * data = NULL;
+ uint32_t done = 0;
+
+
+ while (sumsize < size)
+ {
+ uint64_t destpos;
+ subsize = mp4ff_atom_read_header(f, &atom_type, &header_size);
+ destpos = mp4ff_position(f)+subsize-header_size;
+ if (!done)
+ {
+ if (atom_type == ATOM_DATA)
+ {
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+ mp4ff_read_int32(f); /* reserved */
+
+ /* some need special attention */
+ if (parent_atom_type == ATOM_GENRE2 || parent_atom_type == ATOM_TEMPO)
+ {
+ if (subsize - header_size >= 8 + 2)
+ {
+ uint16_t val = mp4ff_read_int16(f);
+
+ if (parent_atom_type == ATOM_TEMPO)
+ {
+ char temp[16];
+ sprintf(temp, "%.5u BPM", val);
+ mp4ff_tag_add_field(&(f->tags), "tempo", temp);
+ }
+ else
+ {
+ const char * temp = mp4ff_meta_index_to_genre(val);
+ if (temp)
+ {
+ mp4ff_tag_add_field(&(f->tags), "genre", temp);
+ }
+ }
+ done = 1;
+ }
+ } else if (parent_atom_type == ATOM_TRACK || parent_atom_type == ATOM_DISC) {
+ /* if (!done && subsize - header_size >= 8 + 8) */
+ /* modified by AJS */
+ if ( !done && (subsize - header_size) >=
+ (sizeof(char) + sizeof(uint8_t)*3 + sizeof(uint32_t) + /* version + flags + reserved */
+ + sizeof(uint16_t) /* leading uint16_t */
+ + sizeof(uint16_t) /* track / disc */
+ + sizeof(uint16_t)) /* totaltracks / totaldiscs */
+ )
+ {
+ uint16_t index,total;
+ char temp[32];
+ mp4ff_read_int16(f);
+ index = mp4ff_read_int16(f);
+ total = mp4ff_read_int16(f);
+ /* modified by AJS */
+ /* mp4ff_read_int16(f); */
+
+ sprintf(temp,"%d",index);
+ mp4ff_tag_add_field(&(f->tags), parent_atom_type == ATOM_TRACK ? "track" : "disc", temp);
+ if (total>0)
+ {
+ sprintf(temp,"%d",total);
+ mp4ff_tag_add_field(&(f->tags), parent_atom_type == ATOM_TRACK ? "totaltracks" : "totaldiscs", temp);
+ }
+ done = 1;
+ }
+ } else
+ {
+ if (data) {free(data);data = NULL;}
+ data = mp4ff_read_string(f,(uint32_t)(subsize-(header_size+8)));
+ }
+ } else if (atom_type == ATOM_NAME) {
+ if (!done)
+ {
+ mp4ff_read_char(f); /* version */
+ mp4ff_read_int24(f); /* flags */
+ if (name) free(name);
+ name = mp4ff_read_string(f,(uint32_t)(subsize-(header_size+4)));
+ }
+ }
+ mp4ff_set_position(f, destpos);
+ sumsize += subsize;
+ }
+ }
+
+ if (data)
+ {
+ if (!done)
+ {
+ if (name == NULL) mp4ff_set_metadata_name(f, parent_atom_type, &name);
+ if (name) mp4ff_tag_add_field(&(f->tags), name, data);
+ }
+
+ free(data);
+ }
+ if (name) free(name);
+ return 1;
+}
+
+int32_t mp4ff_parse_metadata(mp4ff_t *f, const int32_t size)
+{
+ uint64_t subsize, sumsize = 0;
+ uint8_t atom_type;
+ uint8_t header_size = 0;
+
+ while (sumsize < size)
+ {
+ subsize = mp4ff_atom_read_header(f, &atom_type, &header_size);
+ if (subsize == 0)
+ break;
+ mp4ff_parse_tag(f, atom_type, (uint32_t)(subsize-header_size));
+ sumsize += subsize;
+ }
+
+ return 0;
+}
+
+/* find a metadata item by name */
+/* returns 0 if item found, 1 if no such item */
+static int32_t mp4ff_meta_find_by_name(const mp4ff_t *f, const char *item, char **value)
+{
+ uint32_t i;
+
+ for (i = 0; i < f->tags.count; i++)
+ {
+ if (!stricmp(f->tags.tags[i].item, item))
+ {
+ *value = strdup(f->tags.tags[i].value);
+ return 1;
+ }
+ }
+
+ *value = NULL;
+
+ /* not found */
+ return 0;
+}
+
+int32_t mp4ff_meta_get_num_items(const mp4ff_t *f)
+{
+ return f->tags.count;
+}
+
+int32_t mp4ff_meta_get_by_index(const mp4ff_t *f, uint32_t index,
+ char **item, char **value)
+{
+ if (index >= f->tags.count)
+ {
+ *item = NULL;
+ *value = NULL;
+ return 0;
+ } else {
+ *item = strdup(f->tags.tags[index].item);
+ *value = strdup(f->tags.tags[index].value);
+ return 1;
+ }
+}
+
+int32_t mp4ff_meta_get_title(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "title", value);
+}
+
+int32_t mp4ff_meta_get_artist(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "artist", value);
+}
+
+int32_t mp4ff_meta_get_writer(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "writer", value);
+}
+
+int32_t mp4ff_meta_get_album(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "album", value);
+}
+
+int32_t mp4ff_meta_get_date(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "date", value);
+}
+
+int32_t mp4ff_meta_get_tool(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "tool", value);
+}
+
+int32_t mp4ff_meta_get_comment(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "comment", value);
+}
+
+int32_t mp4ff_meta_get_genre(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "genre", value);
+}
+
+int32_t mp4ff_meta_get_track(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "track", value);
+}
+
+int32_t mp4ff_meta_get_totaltracks(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "totaltracks", value);
+}
+
+int32_t mp4ff_meta_get_disc(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "disc", value);
+}
+
+int32_t mp4ff_meta_get_totaldiscs(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "totaldiscs", value);
+}
+
+int32_t mp4ff_meta_get_compilation(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "compilation", value);
+}
+
+int32_t mp4ff_meta_get_tempo(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "tempo", value);
+}
+
+int32_t mp4ff_meta_get_coverart(const mp4ff_t *f, char **value)
+{
+ return mp4ff_meta_find_by_name(f, "cover", value);
+}
+
+#endif \ No newline at end of file
diff --git a/faad2/src/common/mp4ff/mp4sample.c b/faad2/src/common/mp4ff/mp4sample.c
new file mode 100644
index 0000000..5bed06e
--- /dev/null
+++ b/faad2/src/common/mp4ff/mp4sample.c
@@ -0,0 +1,155 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mp4sample.c,v 1.20 2007/11/01 12:33:29 menno Exp $
+**/
+
+#include <stdlib.h>
+#include "mp4ffint.h"
+
+
+static int32_t mp4ff_chunk_of_sample(const mp4ff_t *f, const int32_t track, const int32_t sample,
+ int32_t *chunk_sample, int32_t *chunk)
+{
+ int32_t total_entries = 0;
+ int32_t chunk2entry;
+ int32_t chunk1, chunk2, chunk1samples, range_samples, total = 0;
+
+ if (f->track[track] == NULL)
+ {
+ return -1;
+ }
+
+ total_entries = f->track[track]->stsc_entry_count;
+
+ chunk1 = 1;
+ chunk1samples = 0;
+ chunk2entry = 0;
+
+ do
+ {
+ chunk2 = f->track[track]->stsc_first_chunk[chunk2entry];
+ *chunk = chunk2 - chunk1;
+ range_samples = *chunk * chunk1samples;
+
+ if (sample < total + range_samples) break;
+
+ chunk1samples = f->track[track]->stsc_samples_per_chunk[chunk2entry];
+ chunk1 = chunk2;
+
+ if(chunk2entry < total_entries)
+ {
+ chunk2entry++;
+ total += range_samples;
+ }
+ } while (chunk2entry < total_entries);
+
+ if (chunk1samples)
+ *chunk = (sample - total) / chunk1samples + chunk1;
+ else
+ *chunk = 1;
+
+ *chunk_sample = total + (*chunk - chunk1) * chunk1samples;
+
+ return 0;
+}
+
+static int32_t mp4ff_chunk_to_offset(const mp4ff_t *f, const int32_t track, const int32_t chunk)
+{
+ const mp4ff_track_t * p_track = f->track[track];
+
+ if (p_track->stco_entry_count && (chunk > p_track->stco_entry_count))
+ {
+ return p_track->stco_chunk_offset[p_track->stco_entry_count - 1];
+ } else if (p_track->stco_entry_count) {
+ return p_track->stco_chunk_offset[chunk - 1];
+ } else {
+ return 8;
+ }
+
+ return 0;
+}
+
+static int32_t mp4ff_sample_range_size(const mp4ff_t *f, const int32_t track,
+ const int32_t chunk_sample, const int32_t sample)
+{
+ int32_t i, total;
+ const mp4ff_track_t * p_track = f->track[track];
+
+ if (p_track->stsz_sample_size)
+ {
+ return (sample - chunk_sample) * p_track->stsz_sample_size;
+ }
+ else
+ {
+ if (sample>=p_track->stsz_sample_count) return 0;//error
+
+ for(i = chunk_sample, total = 0; i < sample; i++)
+ {
+ total += p_track->stsz_table[i];
+ }
+ }
+
+ return total;
+}
+
+static int32_t mp4ff_sample_to_offset(const mp4ff_t *f, const int32_t track, const int32_t sample)
+{
+ int32_t chunk, chunk_sample, chunk_offset1, chunk_offset2;
+
+ mp4ff_chunk_of_sample(f, track, sample, &chunk_sample, &chunk);
+
+ chunk_offset1 = mp4ff_chunk_to_offset(f, track, chunk);
+ chunk_offset2 = chunk_offset1 + mp4ff_sample_range_size(f, track, chunk_sample, sample);
+
+ return chunk_offset2;
+}
+
+int32_t mp4ff_audio_frame_size(const mp4ff_t *f, const int32_t track, const int32_t sample)
+{
+ int32_t bytes;
+ const mp4ff_track_t * p_track = f->track[track];
+
+ if (p_track->stsz_sample_size)
+ {
+ bytes = p_track->stsz_sample_size;
+ } else {
+ bytes = p_track->stsz_table[sample];
+ }
+
+ return bytes;
+}
+
+int32_t mp4ff_set_sample_position(mp4ff_t *f, const int32_t track, const int32_t sample)
+{
+ int32_t offset;
+
+ offset = mp4ff_sample_to_offset(f, track, sample);
+ mp4ff_set_position(f, offset);
+
+ return 0;
+}
diff --git a/faad2/src/common/mp4ff/mp4tagupdate.c b/faad2/src/common/mp4ff/mp4tagupdate.c
new file mode 100644
index 0000000..ae29e12
--- /dev/null
+++ b/faad2/src/common/mp4ff/mp4tagupdate.c
@@ -0,0 +1,656 @@
+#include <stdlib.h>
+#include <string.h>
+#include "mp4ffint.h"
+
+#ifdef USE_TAGGING
+
+static uint32_t fix_byte_order_32(uint32_t src)
+{
+ uint32_t result;
+ uint32_t a, b, c, d;
+ int8_t data[4];
+
+ memcpy(data,&src,sizeof(src));
+ a = (uint8_t)data[0];
+ b = (uint8_t)data[1];
+ c = (uint8_t)data[2];
+ d = (uint8_t)data[3];
+
+ result = (a<<24) | (b<<16) | (c<<8) | d;
+ return (uint32_t)result;
+}
+
+static uint16_t fix_byte_order_16(uint16_t src)
+{
+ uint16_t result;
+ uint16_t a, b;
+ int8_t data[2];
+
+ memcpy(data,&src,sizeof(src));
+ a = (uint8_t)data[0];
+ b = (uint8_t)data[1];
+
+ result = (a<<8) | b;
+ return (uint16_t)result;
+}
+
+
+typedef struct
+{
+ void * data;
+ unsigned written;
+ unsigned allocated;
+ unsigned error;
+} membuffer;
+
+unsigned membuffer_write(membuffer * buf,const void * ptr,unsigned bytes)
+{
+ unsigned dest_size = buf->written + bytes;
+
+ if (buf->error) return 0;
+ if (dest_size > buf->allocated)
+ {
+ do
+ {
+ buf->allocated <<= 1;
+ } while(dest_size > buf->allocated);
+
+ {
+ void * newptr = realloc(buf->data,buf->allocated);
+ if (newptr==0)
+ {
+ free(buf->data);
+ buf->data = 0;
+ buf->error = 1;
+ return 0;
+ }
+ buf->data = newptr;
+ }
+ }
+
+ if (ptr) memcpy((char*)buf->data + buf->written,ptr,bytes);
+ buf->written += bytes;
+ return bytes;
+}
+
+#define membuffer_write_data membuffer_write
+
+unsigned membuffer_write_int32(membuffer * buf,uint32_t data)
+{
+ uint8_t temp[4] = {(uint8_t)(data>>24),(uint8_t)(data>>16),(uint8_t)(data>>8),(uint8_t)data};
+ return membuffer_write_data(buf,temp,4);
+}
+
+unsigned membuffer_write_int24(membuffer * buf,uint32_t data)
+{
+ uint8_t temp[3] = {(uint8_t)(data>>16),(uint8_t)(data>>8),(uint8_t)data};
+ return membuffer_write_data(buf,temp,3);
+}
+
+unsigned membuffer_write_int16(membuffer * buf,uint16_t data)
+{
+ uint8_t temp[2] = {(uint8_t)(data>>8),(uint8_t)data};
+ return membuffer_write_data(buf,temp,2);
+}
+
+unsigned membuffer_write_atom_name(membuffer * buf,const char * data)
+{
+ return membuffer_write_data(buf,data,4)==4 ? 1 : 0;
+}
+
+void membuffer_write_atom(membuffer * buf,const char * name,unsigned size,const void * data)
+{
+ membuffer_write_int32(buf,size + 8);
+ membuffer_write_atom_name(buf,name);
+ membuffer_write_data(buf,data,size);
+}
+
+unsigned membuffer_write_string(membuffer * buf,const char * data)
+{
+ return membuffer_write_data(buf,data,strlen(data));
+}
+
+unsigned membuffer_write_int8(membuffer * buf,uint8_t data)
+{
+ return membuffer_write_data(buf,&data,1);
+}
+
+void * membuffer_get_ptr(const membuffer * buf)
+{
+ return buf->data;
+}
+
+unsigned membuffer_get_size(const membuffer * buf)
+{
+ return buf->written;
+}
+
+unsigned membuffer_error(const membuffer * buf)
+{
+ return buf->error;
+}
+
+void membuffer_set_error(membuffer * buf) {buf->error = 1;}
+
+unsigned membuffer_transfer_from_file(membuffer * buf,mp4ff_t * src,unsigned bytes)
+{
+ unsigned oldsize;
+ void * bufptr;
+
+ oldsize = membuffer_get_size(buf);
+ if (membuffer_write_data(buf,0,bytes) != bytes) return 0;
+
+ bufptr = membuffer_get_ptr(buf);
+ if (bufptr==0) return 0;
+
+ if ((unsigned)mp4ff_read_data(src,(char*)bufptr + oldsize,bytes)!=bytes)
+ {
+ membuffer_set_error(buf);
+ return 0;
+ }
+
+ return bytes;
+}
+
+
+membuffer * membuffer_create()
+{
+ const unsigned initial_size = 256;
+
+ membuffer * buf = (membuffer *) malloc(sizeof(membuffer));
+ buf->data = malloc(initial_size);
+ buf->written = 0;
+ buf->allocated = initial_size;
+ buf->error = buf->data == 0 ? 1 : 0;
+
+ return buf;
+}
+
+void membuffer_free(membuffer * buf)
+{
+ if (buf->data) free(buf->data);
+ free(buf);
+}
+
+void * membuffer_detach(membuffer * buf)
+{
+ void * ret;
+
+ if (buf->error) return 0;
+
+ ret = realloc(buf->data,buf->written);
+
+ if (ret == 0) free(buf->data);
+
+ buf->data = 0;
+ buf->error = 1;
+
+ return ret;
+}
+
+#if 0
+/* metadata tag structure */
+typedef struct
+{
+ char *item;
+ char *value;
+} mp4ff_tag_t;
+
+/* metadata list structure */
+typedef struct
+{
+ mp4ff_tag_t *tags;
+ uint32_t count;
+} mp4ff_metadata_t;
+#endif
+
+typedef struct
+{
+ const char * atom;
+ const char * name;
+} stdmeta_entry;
+
+static stdmeta_entry stdmetas[] =
+{
+ {"\xA9" "nam","title"},
+ {"\xA9" "ART","artist"},
+ {"\xA9" "wrt","writer"},
+ {"\xA9" "alb","album"},
+ {"\xA9" "day","date"},
+ {"\xA9" "too","tool"},
+ {"\xA9" "cmt","comment"},
+// {"\xA9" "gen","genre"},
+ {"cpil","compilation"},
+// {"trkn","track"},
+// {"disk","disc"},
+// {"gnre","genre"},
+ {"covr","cover"},
+ /* added by AJS */
+ {"aART","album_artist"},
+};
+
+
+static const char* find_standard_meta(const char * name) //returns atom name if found, 0 if not
+{
+ unsigned n;
+ for(n=0;n<sizeof(stdmetas)/sizeof(stdmetas[0]);n++)
+ {
+ if (!stricmp(name,stdmetas[n].name)) return stdmetas[n].atom;
+ }
+ return 0;
+}
+
+static void membuffer_write_track_tag(membuffer * buf,const char * name,uint32_t index,uint32_t total)
+{
+ membuffer_write_int32(buf,8 /*atom header*/ + 8 /*data atom header*/ + 8 /*flags + reserved*/ + 8 /*actual data*/ );
+ membuffer_write_atom_name(buf,name);
+ membuffer_write_int32(buf,8 /*data atom header*/ + 8 /*flags + reserved*/ + 8 /*actual data*/ );
+ membuffer_write_atom_name(buf,"data");
+ membuffer_write_int32(buf,0);//flags
+ membuffer_write_int32(buf,0);//reserved
+ membuffer_write_int16(buf,0);
+ membuffer_write_int16(buf,(uint16_t)index);//track number
+ membuffer_write_int16(buf,(uint16_t)total);//total tracks
+ membuffer_write_int16(buf,0);
+}
+
+static void membuffer_write_int16_tag(membuffer * buf,const char * name,uint16_t value)
+{
+ membuffer_write_int32(buf,8 /*atom header*/ + 8 /*data atom header*/ + 8 /*flags + reserved*/ + 2 /*actual data*/ );
+ membuffer_write_atom_name(buf,name);
+ membuffer_write_int32(buf,8 /*data atom header*/ + 8 /*flags + reserved*/ + 2 /*actual data*/ );
+ membuffer_write_atom_name(buf,"data");
+ membuffer_write_int32(buf,0);//flags
+ membuffer_write_int32(buf,0);//reserved
+ membuffer_write_int16(buf,value);//value
+}
+
+static void membuffer_write_std_tag(membuffer * buf,const char * name,const char * value)
+{
+ /* added by AJS */
+ uint32_t flags = 1;
+
+ /* special check for compilation flag */
+ if ( strcmp(name, "cpil") == 0)
+ {
+ flags = 21;
+ }
+
+ membuffer_write_int32(buf,8 /*atom header*/ + 8 /*data atom header*/ + 8 /*flags + reserved*/ + strlen(value) );
+ membuffer_write_atom_name(buf,name);
+ membuffer_write_int32(buf,8 /*data atom header*/ + 8 /*flags + reserved*/ + strlen(value));
+ membuffer_write_atom_name(buf,"data");
+ membuffer_write_int32(buf,flags);//flags
+ membuffer_write_int32(buf,0);//reserved
+ membuffer_write_data(buf,value,strlen(value));
+}
+
+static void membuffer_write_custom_tag(membuffer * buf,const char * name,const char * value)
+{
+ membuffer_write_int32(buf,8 /*atom header*/ + 0x1C /*weirdo itunes atom*/ + 12 /*name atom header*/ + strlen(name) + 16 /*data atom header + flags*/ + strlen(value) );
+ membuffer_write_atom_name(buf,"----");
+ membuffer_write_int32(buf,0x1C);//weirdo itunes atom
+ membuffer_write_atom_name(buf,"mean");
+ membuffer_write_int32(buf,0);
+ membuffer_write_data(buf,"com.apple.iTunes",16);
+ membuffer_write_int32(buf,12 + strlen(name));
+ membuffer_write_atom_name(buf,"name");
+ membuffer_write_int32(buf,0);
+ membuffer_write_data(buf,name,strlen(name));
+ membuffer_write_int32(buf,8 /*data atom header*/ + 8 /*flags + reserved*/ + strlen(value));
+ membuffer_write_atom_name(buf,"data");
+ membuffer_write_int32(buf,1);//flags
+ membuffer_write_int32(buf,0);//reserved
+ membuffer_write_data(buf,value,strlen(value));
+
+}
+
+static uint32_t myatoi(const char * param)
+{
+ return param ? atoi(param) : 0;
+}
+
+static uint32_t create_ilst(const mp4ff_metadata_t * data,void ** out_buffer,uint32_t * out_size)
+{
+ membuffer * buf = membuffer_create();
+ unsigned metaptr;
+ char * mask = (char*)malloc(data->count);
+ memset(mask,0,data->count);
+
+ {
+ const char * tracknumber_ptr = 0, * totaltracks_ptr = 0;
+ const char * discnumber_ptr = 0, * totaldiscs_ptr = 0;
+ const char * genre_ptr = 0, * tempo_ptr = 0;
+ for(metaptr = 0; metaptr < data->count; metaptr++)
+ {
+ mp4ff_tag_t * tag = &data->tags[metaptr];
+ if (!stricmp(tag->item,"tracknumber") || !stricmp(tag->item,"track"))
+ {
+ if (tracknumber_ptr==0) tracknumber_ptr = tag->value;
+ mask[metaptr] = 1;
+ }
+ else if (!stricmp(tag->item,"totaltracks"))
+ {
+ if (totaltracks_ptr==0) totaltracks_ptr = tag->value;
+ mask[metaptr] = 1;
+ }
+ else if (!stricmp(tag->item,"discnumber") || !stricmp(tag->item,"disc"))
+ {
+ if (discnumber_ptr==0) discnumber_ptr = tag->value;
+ mask[metaptr] = 1;
+ }
+ else if (!stricmp(tag->item,"totaldiscs"))
+ {
+ if (totaldiscs_ptr==0) totaldiscs_ptr = tag->value;
+ mask[metaptr] = 1;
+ }
+ else if (!stricmp(tag->item,"genre"))
+ {
+ if (genre_ptr==0) genre_ptr = tag->value;
+ mask[metaptr] = 1;
+ }
+ else if (!stricmp(tag->item,"tempo"))
+ {
+ if (tempo_ptr==0) tempo_ptr = tag->value;
+ mask[metaptr] = 1;
+ }
+
+ }
+
+ if (tracknumber_ptr) membuffer_write_track_tag(buf,"trkn",myatoi(tracknumber_ptr),myatoi(totaltracks_ptr));
+ if (discnumber_ptr) membuffer_write_track_tag(buf,"disk",myatoi(discnumber_ptr),myatoi(totaldiscs_ptr));
+ if (tempo_ptr) membuffer_write_int16_tag(buf,"tmpo",(uint16_t)myatoi(tempo_ptr));
+
+ if (genre_ptr)
+ {
+ uint32_t index = mp4ff_meta_genre_to_index(genre_ptr);
+ if (index==0)
+ membuffer_write_std_tag(buf,"gen",genre_ptr);
+ else
+ membuffer_write_int16_tag(buf,"gnre",(uint16_t)index);
+ }
+ }
+
+ for(metaptr = 0; metaptr < data->count; metaptr++)
+ {
+ if (!mask[metaptr])
+ {
+ mp4ff_tag_t * tag = &data->tags[metaptr];
+ const char * std_meta_atom = find_standard_meta(tag->item);
+ if (std_meta_atom)
+ {
+ membuffer_write_std_tag(buf,std_meta_atom,tag->value);
+ }
+ else
+ {
+ membuffer_write_custom_tag(buf,tag->item,tag->value);
+ }
+ }
+ }
+
+ free(mask);
+
+ if (membuffer_error(buf))
+ {
+ membuffer_free(buf);
+ return 0;
+ }
+
+ *out_size = membuffer_get_size(buf);
+ *out_buffer = membuffer_detach(buf);
+ membuffer_free(buf);
+
+ return 1;
+}
+
+static uint32_t find_atom(mp4ff_t * f,uint64_t base,uint32_t size,const char * name)
+{
+ uint32_t remaining = size;
+ uint64_t atom_offset = base;
+ for(;;)
+ {
+ char atom_name[4];
+ uint32_t atom_size;
+
+ mp4ff_set_position(f,atom_offset);
+
+ if (remaining < 8) break;
+ atom_size = mp4ff_read_int32(f);
+ if (atom_size > remaining || atom_size < 8) break;
+ mp4ff_read_data(f,atom_name,4);
+
+ if (!memcmp(atom_name,name,4))
+ {
+ mp4ff_set_position(f,atom_offset);
+ return 1;
+ }
+
+ remaining -= atom_size;
+ atom_offset += atom_size;
+ }
+ return 0;
+}
+
+static uint32_t find_atom_v2(mp4ff_t * f,uint64_t base,uint32_t size,const char * name,uint32_t extraheaders,const char * name_inside)
+{
+ uint64_t first_base = (uint64_t)(-1);
+ while(find_atom(f,base,size,name))//try to find atom <name> with atom <name_inside> in it
+ {
+ uint64_t mybase = mp4ff_position(f);
+ uint32_t mysize = mp4ff_read_int32(f);
+
+ if (first_base == (uint64_t)(-1)) first_base = mybase;
+
+ if (mysize < 8 + extraheaders) break;
+
+ if (find_atom(f,mybase+(8+extraheaders),mysize-(8+extraheaders),name_inside))
+ {
+ mp4ff_set_position(f,mybase);
+ return 2;
+ }
+ base += mysize;
+ if (size<=mysize) {size=0;break;}
+ size -= mysize;
+ }
+
+ if (first_base != (uint64_t)(-1))//wanted atom inside not found
+ {
+ mp4ff_set_position(f,first_base);
+ return 1;
+ }
+ else return 0;
+}
+
+static uint32_t create_meta(const mp4ff_metadata_t * data,void ** out_buffer,uint32_t * out_size)
+{
+ membuffer * buf;
+ uint32_t ilst_size;
+ void * ilst_buffer;
+
+ if (!create_ilst(data,&ilst_buffer,&ilst_size)) return 0;
+
+ buf = membuffer_create();
+
+ membuffer_write_int32(buf,0);
+ membuffer_write_atom(buf,"ilst",ilst_size,ilst_buffer);
+ free(ilst_buffer);
+
+ *out_size = membuffer_get_size(buf);
+ *out_buffer = membuffer_detach(buf);
+ membuffer_free(buf);
+ return 1;
+}
+
+static uint32_t create_udta(const mp4ff_metadata_t * data,void ** out_buffer,uint32_t * out_size)
+{
+ membuffer * buf;
+ uint32_t meta_size;
+ void * meta_buffer;
+
+ if (!create_meta(data,&meta_buffer,&meta_size)) return 0;
+
+ buf = membuffer_create();
+
+ membuffer_write_atom(buf,"meta",meta_size,meta_buffer);
+
+ free(meta_buffer);
+
+ *out_size = membuffer_get_size(buf);
+ *out_buffer = membuffer_detach(buf);
+ membuffer_free(buf);
+ return 1;
+}
+
+static uint32_t modify_moov(mp4ff_t * f,const mp4ff_metadata_t * data,void ** out_buffer,uint32_t * out_size)
+{
+ uint64_t total_base = f->moov_offset + 8;
+ uint32_t total_size = (uint32_t)(f->moov_size - 8);
+
+ uint64_t udta_offset,meta_offset,ilst_offset;
+ uint32_t udta_size, meta_size, ilst_size;
+
+ uint32_t new_ilst_size;
+ void * new_ilst_buffer;
+
+ uint8_t * p_out;
+ int32_t size_delta;
+
+
+ if (!find_atom_v2(f,total_base,total_size,"udta",0,"meta"))
+ {
+ membuffer * buf;
+ void * new_udta_buffer;
+ uint32_t new_udta_size;
+ if (!create_udta(data,&new_udta_buffer,&new_udta_size)) return 0;
+
+ buf = membuffer_create();
+ mp4ff_set_position(f,total_base);
+ membuffer_transfer_from_file(buf,f,total_size);
+
+ membuffer_write_atom(buf,"udta",new_udta_size,new_udta_buffer);
+
+ free(new_udta_buffer);
+
+ *out_size = membuffer_get_size(buf);
+ *out_buffer = membuffer_detach(buf);
+ membuffer_free(buf);
+ return 1;
+ }
+ else
+ {
+ udta_offset = mp4ff_position(f);
+ udta_size = mp4ff_read_int32(f);
+ if (!find_atom_v2(f,udta_offset+8,udta_size-8,"meta",4,"ilst"))
+ {
+ membuffer * buf;
+ void * new_meta_buffer;
+ uint32_t new_meta_size;
+ if (!create_meta(data,&new_meta_buffer,&new_meta_size)) return 0;
+
+ buf = membuffer_create();
+ mp4ff_set_position(f,total_base);
+ membuffer_transfer_from_file(buf,f,(uint32_t)(udta_offset - total_base));
+
+ membuffer_write_int32(buf,udta_size + 8 + new_meta_size);
+ membuffer_write_atom_name(buf,"udta");
+ membuffer_transfer_from_file(buf,f,udta_size);
+
+ membuffer_write_atom(buf,"meta",new_meta_size,new_meta_buffer);
+ free(new_meta_buffer);
+
+ *out_size = membuffer_get_size(buf);
+ *out_buffer = membuffer_detach(buf);
+ membuffer_free(buf);
+ return 1;
+ }
+ meta_offset = mp4ff_position(f);
+ meta_size = mp4ff_read_int32(f);
+ if (!find_atom(f,meta_offset+12,meta_size-12,"ilst")) return 0;//shouldn't happen, find_atom_v2 above takes care of it
+ ilst_offset = mp4ff_position(f);
+ ilst_size = mp4ff_read_int32(f);
+
+ if (!create_ilst(data,&new_ilst_buffer,&new_ilst_size)) return 0;
+
+ size_delta = new_ilst_size - (ilst_size - 8);
+
+ *out_size = total_size + size_delta;
+ *out_buffer = malloc(*out_size);
+ if (*out_buffer == 0)
+ {
+ free(new_ilst_buffer);
+ return 0;
+ }
+
+ p_out = (uint8_t*)*out_buffer;
+
+ mp4ff_set_position(f,total_base);
+ mp4ff_read_data(f,p_out,(uint32_t)(udta_offset - total_base )); p_out += (uint32_t)(udta_offset - total_base );
+ *(uint32_t*)p_out = fix_byte_order_32(mp4ff_read_int32(f) + size_delta); p_out += 4;
+ mp4ff_read_data(f,p_out,4); p_out += 4;
+ mp4ff_read_data(f,p_out,(uint32_t)(meta_offset - udta_offset - 8)); p_out += (uint32_t)(meta_offset - udta_offset - 8);
+ *(uint32_t*)p_out = fix_byte_order_32(mp4ff_read_int32(f) + size_delta); p_out += 4;
+ mp4ff_read_data(f,p_out,4); p_out += 4;
+ mp4ff_read_data(f,p_out,(uint32_t)(ilst_offset - meta_offset - 8)); p_out += (uint32_t)(ilst_offset - meta_offset - 8);
+ *(uint32_t*)p_out = fix_byte_order_32(mp4ff_read_int32(f) + size_delta); p_out += 4;
+ mp4ff_read_data(f,p_out,4); p_out += 4;
+
+ memcpy(p_out,new_ilst_buffer,new_ilst_size);
+ p_out += new_ilst_size;
+
+ mp4ff_set_position(f,ilst_offset + ilst_size);
+ mp4ff_read_data(f,p_out,(uint32_t)(total_size - (ilst_offset - total_base) - ilst_size));
+
+ free(new_ilst_buffer);
+ }
+ return 1;
+
+}
+
+int32_t mp4ff_meta_update(mp4ff_callback_t *f,const mp4ff_metadata_t * data)
+{
+ void * new_moov_data;
+ uint32_t new_moov_size;
+
+ mp4ff_t *ff = malloc(sizeof(mp4ff_t));
+
+ memset(ff, 0, sizeof(mp4ff_t));
+ ff->stream = f;
+ mp4ff_set_position(ff,0);
+
+ parse_atoms(ff,1);
+
+
+ if (!modify_moov(ff,data,&new_moov_data,&new_moov_size))
+ {
+ mp4ff_close(ff);
+ return 0;
+ }
+
+ /* copy moov atom to end of the file */
+ if (ff->last_atom != ATOM_MOOV)
+ {
+ char *free_data = "free";
+
+ /* rename old moov to free */
+ mp4ff_set_position(ff, ff->moov_offset + 4);
+ mp4ff_write_data(ff, free_data, 4);
+
+ mp4ff_set_position(ff, ff->file_size);
+ mp4ff_write_int32(ff,new_moov_size + 8);
+ mp4ff_write_data(ff,"moov",4);
+ mp4ff_write_data(ff, new_moov_data, new_moov_size);
+ }
+ else
+ {
+ mp4ff_set_position(ff, ff->moov_offset);
+ mp4ff_write_int32(ff,new_moov_size + 8);
+ mp4ff_write_data(ff,"moov",4);
+ mp4ff_write_data(ff, new_moov_data, new_moov_size);
+ }
+
+ mp4ff_truncate(ff);
+
+ mp4ff_close(ff);
+ return 1;
+}
+#endif
diff --git a/faad2/src/common/mp4ff/mp4util.c b/faad2/src/common/mp4ff/mp4util.c
new file mode 100644
index 0000000..8acfcfe
--- /dev/null
+++ b/faad2/src/common/mp4ff/mp4util.c
@@ -0,0 +1,191 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mp4util.c,v 1.20 2007/11/01 12:33:29 menno Exp $
+**/
+
+#include "mp4ffint.h"
+#include <stdlib.h>
+
+int32_t mp4ff_read_data(mp4ff_t *f, int8_t *data, uint32_t size)
+{
+ int32_t result = 1;
+
+ result = f->stream->read(f->stream->user_data, data, size);
+
+ f->current_position += size;
+
+ return result;
+}
+
+int32_t mp4ff_truncate(mp4ff_t * f)
+{
+ return f->stream->truncate(f->stream->user_data);
+}
+
+int32_t mp4ff_write_data(mp4ff_t *f, int8_t *data, uint32_t size)
+{
+ int32_t result = 1;
+
+ result = f->stream->write(f->stream->user_data, data, size);
+
+ f->current_position += size;
+
+ return result;
+}
+
+int32_t mp4ff_write_int32(mp4ff_t *f,const uint32_t data)
+{
+ uint32_t result;
+ uint32_t a, b, c, d;
+ int8_t temp[4];
+
+ *(uint32_t*)temp = data;
+ a = (uint8_t)temp[0];
+ b = (uint8_t)temp[1];
+ c = (uint8_t)temp[2];
+ d = (uint8_t)temp[3];
+
+ result = (a<<24) | (b<<16) | (c<<8) | d;
+
+ return mp4ff_write_data(f,(uint8_t*)&result,sizeof(result));
+}
+
+int32_t mp4ff_set_position(mp4ff_t *f, const int64_t position)
+{
+ f->stream->seek(f->stream->user_data, position);
+ f->current_position = position;
+
+ return 0;
+}
+
+int64_t mp4ff_position(const mp4ff_t *f)
+{
+ return f->current_position;
+}
+
+uint64_t mp4ff_read_int64(mp4ff_t *f)
+{
+ uint8_t data[8];
+ uint64_t result = 0;
+ int8_t i;
+
+ mp4ff_read_data(f, data, 8);
+
+ for (i = 0; i < 8; i++)
+ {
+ result |= ((uint64_t)data[i]) << ((7 - i) * 8);
+ }
+
+ return result;
+}
+
+uint32_t mp4ff_read_int32(mp4ff_t *f)
+{
+ uint32_t result;
+ uint32_t a, b, c, d;
+ int8_t data[4];
+
+ mp4ff_read_data(f, data, 4);
+ a = (uint8_t)data[0];
+ b = (uint8_t)data[1];
+ c = (uint8_t)data[2];
+ d = (uint8_t)data[3];
+
+ result = (a<<24) | (b<<16) | (c<<8) | d;
+ return (uint32_t)result;
+}
+
+uint32_t mp4ff_read_int24(mp4ff_t *f)
+{
+ uint32_t result;
+ uint32_t a, b, c;
+ int8_t data[4];
+
+ mp4ff_read_data(f, data, 3);
+ a = (uint8_t)data[0];
+ b = (uint8_t)data[1];
+ c = (uint8_t)data[2];
+
+ result = (a<<16) | (b<<8) | c;
+ return (uint32_t)result;
+}
+
+uint16_t mp4ff_read_int16(mp4ff_t *f)
+{
+ uint32_t result;
+ uint32_t a, b;
+ int8_t data[2];
+
+ mp4ff_read_data(f, data, 2);
+ a = (uint8_t)data[0];
+ b = (uint8_t)data[1];
+
+ result = (a<<8) | b;
+ return (uint16_t)result;
+}
+
+char * mp4ff_read_string(mp4ff_t * f,uint32_t length)
+{
+ char * str = (char*)malloc(length + 1);
+ if (str!=0)
+ {
+ if ((uint32_t)mp4ff_read_data(f,str,length)!=length)
+ {
+ free(str);
+ str = 0;
+ }
+ else
+ {
+ str[length] = 0;
+ }
+ }
+ return str;
+}
+
+uint8_t mp4ff_read_char(mp4ff_t *f)
+{
+ uint8_t output;
+ mp4ff_read_data(f, &output, 1);
+ return output;
+}
+
+uint32_t mp4ff_read_mp4_descr_length(mp4ff_t *f)
+{
+ uint8_t b;
+ uint8_t numBytes = 0;
+ uint32_t length = 0;
+
+ do
+ {
+ b = mp4ff_read_char(f);
+ numBytes++;
+ length = (length << 7) | (b & 0x7F);
+ } while ((b & 0x80) && numBytes < 4);
+
+ return length;
+}
diff --git a/faad2/src/configure.in b/faad2/src/configure.in
new file mode 100644
index 0000000..9b88d52
--- /dev/null
+++ b/faad2/src/configure.in
@@ -0,0 +1,168 @@
+dnl
+dnl This is the configure.in for faad2 related to unix creation
+
+dnl - libfaad.so
+dnl - libmp4ff.a (only static for moment)
+dnl - faad
+dnl - xmms input mp4/aac plugin
+dnl - mpeg4ip plugin (requires mpeg4ip's libmp4v2 to be installed)
+
+AC_INIT
+AC_CONFIG_AUX_DIR(.)
+AM_INIT_AUTOMAKE(faad2, 2.7.0)
+
+AC_PROG_LIBTOOL
+AC_SUBST(LIBTOOL_DEPS)
+
+dnl Checks for programs.
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_CPP
+dnl disable for mpeg4ip plugin
+AC_PROG_CXX
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_CHECK_PROGS(RPMBUILD, rpmbuild, rpm)
+
+AM_CONFIG_HEADER(config.h)
+
+AC_ARG_WITH(xmms,[ --with-xmms compile XMMS-1 plugin],
+ WITHXMMS=$withval, WITHXMMS=no)
+
+AC_ARG_WITH(drm,[ --with-drm compile libfaad with DRM support],
+ WITHDRM=$withval, WITHDRM=no)
+
+AC_ARG_WITH(mpeg4ip, [ --with-mpeg4ip compile mpeg4ip plugin],
+ WITHMPEG4IP=$withval, WITHMPEG4IP=no)
+
+dnl Checks for header files required for mp4.h
+AC_HEADER_STDC
+AC_CHECK_HEADERS(stdint.h inttypes.h)
+AC_CHECK_HEADERS(mathf.h)
+AC_CHECK_HEADERS(float.h)
+AC_CHECK_FUNCS(strchr memcpy)
+AC_CHECK_HEADERS(sys/time.h)
+AC_HEADER_TIME
+
+dnl DRMS
+AC_CHECK_HEADERS(errno.h sys/stat.h sys/types.h limits.h)
+AC_CHECK_HEADERS(sysfs/libsysfs.h)
+AC_CHECK_HEADERS(IOKit/IOKitLib.h,
+ [AC_CHECK_LIB(IOKit, main,
+ [AC_DEFINE(HAVE_IOKIT_IOKITLIB_H, 1, [Define if you have the IOKit API])
+ MP4FF_LIBS="-lIOKit"
+ AC_SUBST(MP4FF_LIBS)])])
+AC_CHECK_FUNCS(getpwuid)
+
+AC_C_INLINE
+AC_C_BIGENDIAN
+
+AC_TYPE_OFF_T
+
+AC_DEFUN([MY_CHECK_TYPEDEF_FROM_INCLUDE],
+[
+ AC_MSG_CHECKING([for $1])
+ AC_TRY_COMPILE([$2],
+ [$1;],
+ libfaad_ok=yes, libfaad_ok=no)
+ if test $libfaad_ok = yes; then
+ AC_DEFINE($3, 1, [Define if needed])
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+fi
+])
+
+dnl @synopsis AC_C99_FUNC_LRINTF
+dnl
+dnl Check whether C99's lrintf function is available.
+dnl @version 1.3 Feb 12 2002
+dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this file for any
+dnl purpose is hereby granted without fee, provided that the above copyright
+dnl and this permission notice appear in all copies. No representations are
+dnl made about the suitability of this software for any purpose. It is
+dnl provided "as is" without express or implied warranty.
+dnl
+AC_DEFUN([AC_C99_FUNC_LRINTF],
+[AC_CACHE_CHECK(for lrintf,
+ ac_cv_c99_lrintf,
+[
+lrintf_save_CFLAGS=$CFLAGS
+CFLAGS="-O -lm"
+AC_TRY_LINK([
+#define _ISOC9X_SOURCE 1
+#define _ISOC99_SOURCE 1
+#define __USE_ISOC99 1
+#define __USE_ISOC9X 1
+
+#include <math.h>
+], if (!lrintf(3.14159)) lrintf(2.7183);, ac_cv_c99_lrintf=yes, ac_cv_c99_lrintf=no)
+
+CFLAGS=$lrintf_save_CFLAGS
+
+])
+
+if test "$ac_cv_c99_lrintf" = yes; then
+ AC_DEFINE(HAVE_LRINTF, 1,
+ [Define if you have C99's lrintf function.])
+fi
+])# AC_C99_FUNC_LRINTF
+AC_C99_FUNC_LRINTF
+
+MY_CHECK_TYPEDEF_FROM_INCLUDE([float32_t temp],
+ [#include <sys/types.h>,
+ #include <sys/float.h>], [HAVE_FLOAT32_T])
+
+AC_CHECK_FUNCS(strsep)
+
+AC_CHECK_PROG(external_mp4v2, mpeg4ip-config, yes, no)
+AM_CONDITIONAL(HAVE_MPEG4IP_PLUG, false)
+if test x$WITHMPEG4IP = xyes; then
+ if test x$external_mp4v2 = xyes; then
+ AM_CONDITIONAL(HAVE_MPEG4IP_PLUG, true)
+ AC_MSG_NOTICE("Building MPEG4IP plugin")
+ else
+ AC_MSG_NOTICE("MPEG4IP libmp4v2 is required for MPEG4IP plugin")
+ fi
+fi
+
+if test x$WITHXMMS = xyes; then
+ AC_CHECK_PROGS(XMMS_CONFIG, xmms-config,"not_found")
+ if test "$XMMS_CONFIG" = "not_found"; then
+ AC_MSG_ERROR("*** xmms-config not found - xmms plugin can't be build")
+ fi
+ AC_CHECK_HEADER(pthread.h,,
+ AC_MSG_ERROR(*** pthread headers support not installed or not found))
+ AC_CHECK_HEADER(id3.h,,
+ AC_MSG_ERROR(*** id3lib headers support not installed or not found))
+ AC_CHECK_PROGS(GTK_CONFIG, gtk-config, "not_found")
+ if test "$XGTK_CONFIG" = "not_found"; then
+ AC_MSG_ERROR("*** gtk-config not found - xmms plugin can't be build without")
+ fi
+
+ AM_CONDITIONAL(HAVE_XMMS, true)
+else
+ AC_MSG_NOTICE(no xmms build configured)
+ AM_CONDITIONAL(HAVE_XMMS, false)
+fi
+
+if test x$WITHDRM = xyes; then
+ AC_DEFINE(DRM, 1, [Define if you want to use libfaad together with Digital Radio Mondiale (DRM)])
+ AC_DEFINE(DRM_PS, 1, [Define if you want support for Digital Radio Mondiale (DRM) parametric stereo])
+fi
+
+AC_CONFIG_FILES(libfaad/Makefile)
+AC_CONFIG_FILES(common/Makefile)
+AC_CONFIG_FILES(common/mp4ff/Makefile)
+AC_CONFIG_FILES(plugins/Makefile)
+AC_CONFIG_FILES(plugins/xmms/Makefile)
+AC_CONFIG_FILES(plugins/xmms/src/Makefile)
+AC_CONFIG_FILES(plugins/mpeg4ip/Makefile)
+AC_CONFIG_FILES(faad2.spec)
+AC_CONFIG_FILES(frontend/Makefile)
+AC_CONFIG_FILES(Makefile)
+
+AC_OUTPUT
diff --git a/faad2/src/docs/Ahead AAC Decoder library documentation.doc b/faad2/src/docs/Ahead AAC Decoder library documentation.doc
new file mode 100644
index 0000000..d0946c2
--- /dev/null
+++ b/faad2/src/docs/Ahead AAC Decoder library documentation.doc
Binary files differ
diff --git a/faad2/src/docs/Ahead AAC Decoder library documentation.pdf b/faad2/src/docs/Ahead AAC Decoder library documentation.pdf
new file mode 100644
index 0000000..c69e638
--- /dev/null
+++ b/faad2/src/docs/Ahead AAC Decoder library documentation.pdf
Binary files differ
diff --git a/faad2/src/faad2.spec.in b/faad2/src/faad2.spec.in
new file mode 100644
index 0000000..a7dc87c
--- /dev/null
+++ b/faad2/src/faad2.spec.in
@@ -0,0 +1,182 @@
+# option to compile without XMMS plugin
+%if %{?without_xmms:1}%{!?without_xmms:0}
+ %define _without_xmms --without-xmms
+%else
+ %define _with_xmms --with-xmms
+%endif
+# this has been taken from http://www.hyperborea.org/software/dillo/dillo.spec
+#################################################################################
+# Identify which distribution we're building on.
+# This will determine any changes in menu structure or release number (i.e. .mdk)
+# Eventually, need to make this configurable from the rpmbuild command line.
+
+%define freedesktop %(if [ -e /usr/share/applications ]; then echo 1; else echo 0; fi;)
+%define conectiva %(if [ -e /etc/conectiva-release ]; then echo 1; else echo 0; fi;)
+%define mdk %(if [ -e /etc/mandrake-release ]; then echo 1; else echo 0; fi;)
+%define suse %(if [ -e /etc/SuSE-release ]; then echo 1; else echo 0; fi;)
+%define oldsuse 0
+%if %{suse}
+ %define oldsuse %(if [ `grep VERSION /etc/SuSE-release | sed -e "s/VERSION = //"` \\< 8.0 ]; then echo 1; else echo 0; fi;)
+%endif
+
+%define oldredhat %(if [ -e /etc/redhat-release ]; then echo 1; else echo 0; fi;) && !%{mdk} && !%{suse} && !%{conectiva} && !%{freedesktop}
+%define plain !%{mdk} && !%{suse} && !%{conectiva} && !%{oldredhat} && !%{freedesktop}
+
+Summary: C library and frontend for decoding MPEG2/4 AAC
+Name: faad2
+Version: @VERSION@
+Release: 1
+License: GPL
+Group: Applications/Multimedia
+Source0: http://download.sourceforge.net/faad/%{name}-%{version}.tar.gz
+#Patch: faad2-%{version}.patch
+BuildRequires: autoconf, automake, libtool, gcc-c++
+
+%if %{?_with_xmms:1}%{!?_with_xmms:0}
+BuildRequires: xmms-devel
+%endif
+
+URL: http://www.audiocoding.com/
+#################################################################################
+%if %{?_with_xmms:1}%{!?_with_xmms:0}
+# GTK Dependencies
+%if %{mdk}
+BuildRequires: libgtk+-devel >= 1.2.0
+%endif
+%if %{suse}
+BuildRequires: gtk-devel >= 1.2.0
+%endif
+%if !%{suse} && !%{mdk}
+BuildRequires: gtk+-devel >= 1.2.0
+%endif
+%endif
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+Packager: a.kurpiers@nt.tu-darmstadt.de
+
+%description
+FAAD 2 is a LC, MAIN and LTP profile, MPEG2 and MPEG-4 AAC decoder, completely
+written from scratch. FAAD 2 is licensed under the GPL.
+
+Includes libmp4ff, a Quicktime library for UNIX in a freely redistributable,
+statically linkable library.
+
+%package devel
+Summary: Development libraries the FAAD 2 AAC decoder.
+Group: Development/Libraries
+Requires: %{name}
+
+%description devel
+Header files and development documentation for libfaad.
+
+%if %{?_with_xmms:1}%{!?_with_xmms:0}
+%package xmms
+Group: Applications/Multimedia
+Summary: AAC and MP4 input plugin for xmms
+Requires: %{name}, xmms
+
+
+%description xmms
+The AAC xmms input plugin for xmms recognizes AAC files by an
+.aac extension.
+This MP4 xmms plugin reads AAC files with and without ID3 tags (version 2.x).
+AAC files are MPEG2 or MPEG4 files that can be found in MPEG4 audio files
+(.mp4). MPEG4 files with AAC inside can be read by RealPlayer or Quicktime.
+%endif
+
+%prep
+#%setup -n %{name}
+%setup -n %{name}-%{version}
+#%patch -p0
+
+%build
+#sh bootstrap
+./configure --with-drm %{?_with_xmms} %{?_without_xmms} --prefix=/usr
+make
+
+%install
+rm -rf %{buildroot}
+# Hack to work around a problem with DESTDIR in libtool 1.4.x
+LIBRARY_PATH="%{buildroot}/usr/lib:${LIBRARY_PATH}" make install DESTDIR=%{buildroot}
+# install libmp4ff
+install -m 755 common/mp4ff/libmp4ff.a %{buildroot}%{_libdir}
+install common/mp4ff/mp4ff.h %{buildroot}%{_includedir}
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-, root, root)
+%doc AUTHORS COPYING ChangeLog NEWS README TODO
+%{_bindir}/*
+%{_libdir}/libfaad.so*
+
+%files devel
+%defattr(-, root, root)
+%{_libdir}/libfaad.a
+%{_libdir}/libfaad.la
+%{_includedir}/faad.h
+%{_includedir}/neaacdec.h
+%{_includedir}/mp4ff.h
+%{_libdir}/libmp4ff.a
+
+%if %{?_with_xmms:1}%{!?_with_xmms:0}
+%files xmms
+%defattr(-,root,root)
+%doc plugins/xmms/README
+%_libdir/xmms/Input/*
+%endif
+
+%changelog
+* Tue Jan 24 2006 Alexander Kurpiers <a.kurpiers@nt.tu-darmstadt.de>
+- fix wrong function declaration in mp4ffint.h
+
+* Wed Nov 15 2005 Alexander Kurpiers <a.kurpiers@nt.tu-darmstadt.de>
+- fix requirements for xmms plugin
+- add libmp4ff to devel package (only static library)
+
+* Sat Aug 13 2005 Alexander Kurpiers <a.kurpiers@nt.tu-darmstadt.de>
+- fix dependencies for xmms plugin. libmp4v2/id3lib no longer needed
+
+* Sun Apr 24 2005 Alexander Kurpiers <a.kurpiers@nt.tu-darmstadt.de>
+- make xmms plugin generation optional. Build with '--define "without_xmms 1"'
+
+* Tue Nov 02 2004 Alexander Kurpiers <a.kurpiers@nt.tu-darmstadt.de>
+- remove libmp4ff and libmp4v2 from RPM
+- changes for new version of faad2
+
+* Sat Apr 17 2004 Alexander Kurpiers <a.kurpiers@nt.tu-darmstadt.de>
+- apply fix to make DRM support work
+- use "platform-independant" dependencies (taken from dillo.spec)
+
+* Fri Feb 06 2004 Alexander Kurpiers <a.kurpiers@nt.tu-darmstadt.de>
+- remove seperate libmp4ff target
+
+* Wed Nov 05 2003 Alexander Kurpiers <a.kurpiers@nt.tu-darmstadt.de>
+- include xmms plugins/libmp4v2/libmp4ff into RPM
+
+* Tue Aug 12 2003 Matthias Saou <matthias.saou@est.une.marmotte.net>
+- Update to 2.0rc1.
+- Introduced LD_LIBRARY_PATH workaround.
+- Removed optional xmms plugin build, it seems mandatory now.
+- Added gtk+ build dep for the xmms plugin.
+
+* Wed May 14 2003 Matthias Saou <matthias.saou@est.une.marmotte.net>
+- Added xmms plugin build.
+
+* Wed Apr 9 2003 Matthias Saou <matthias.saou@est.une.marmotte.net>
+- Spec file cleanup.
+- Now exclude .la file.
+- Update to latest CVS checkout to fix compile problem.
+
+
+* Fri Aug 10 2002 Alexander Kurpiers <a.kurpiers@nt.tu-darmstadt.de>
+- changes to compile v1.1 release
+
+* Tue Jun 18 2002 Alexander Kurpiers <a.kurpiers@nt.tu-darmstadt.de>
+- First RPM.
+
diff --git a/faad2/src/frontend/Makefile.am b/faad2/src/frontend/Makefile.am
new file mode 100644
index 0000000..8bda787
--- /dev/null
+++ b/faad2/src/frontend/Makefile.am
@@ -0,0 +1,12 @@
+bin_PROGRAMS = faad
+man_MANS = faad.man
+
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/common/faad \
+ -I$(top_srcdir)/common/mp4ff
+
+faad_LDADD = $(top_builddir)/libfaad/libfaad.la \
+ $(top_builddir)/common/mp4ff/libmp4ff.a
+
+faad_SOURCES = main.c \
+ audio.c audio.h \
+ $(top_srcdir)/common/faad/getopt.c
diff --git a/faad2/src/frontend/audio.c b/faad2/src/frontend/audio.c
new file mode 100644
index 0000000..7691ce9
--- /dev/null
+++ b/faad2/src/frontend/audio.c
@@ -0,0 +1,500 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: audio.c,v 1.29 2008/09/19 22:50:17 menno Exp $
+**/
+
+#ifdef _WIN32
+#include <io.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <math.h>
+#include <neaacdec.h>
+#include "audio.h"
+
+
+audio_file *open_audio_file(char *infile, int samplerate, int channels,
+ int outputFormat, int fileType, long channelMask)
+{
+ audio_file *aufile = malloc(sizeof(audio_file));
+
+ aufile->outputFormat = outputFormat;
+
+ aufile->samplerate = samplerate;
+ aufile->channels = channels;
+ aufile->total_samples = 0;
+ aufile->fileType = fileType;
+ aufile->channelMask = channelMask;
+
+ switch (outputFormat)
+ {
+ case FAAD_FMT_16BIT:
+ aufile->bits_per_sample = 16;
+ break;
+ case FAAD_FMT_24BIT:
+ aufile->bits_per_sample = 24;
+ break;
+ case FAAD_FMT_32BIT:
+ case FAAD_FMT_FLOAT:
+ aufile->bits_per_sample = 32;
+ break;
+ default:
+ if (aufile) free(aufile);
+ return NULL;
+ }
+
+ if(infile[0] == '-')
+ {
+#ifdef _WIN32
+ setmode(fileno(stdout), O_BINARY);
+#endif
+ aufile->sndfile = stdout;
+ aufile->toStdio = 1;
+ } else {
+ aufile->toStdio = 0;
+ aufile->sndfile = fopen(infile, "wb");
+ }
+
+ if (aufile->sndfile == NULL)
+ {
+ if (aufile) free(aufile);
+ return NULL;
+ }
+
+ if (aufile->fileType == OUTPUT_WAV)
+ {
+ if (aufile->channelMask)
+ write_wav_extensible_header(aufile, aufile->channelMask);
+ else
+ write_wav_header(aufile);
+ }
+
+ return aufile;
+}
+
+int write_audio_file(audio_file *aufile, void *sample_buffer, int samples, int offset)
+{
+ char *buf = (char *)sample_buffer;
+ switch (aufile->outputFormat)
+ {
+ case FAAD_FMT_16BIT:
+ return write_audio_16bit(aufile, buf + offset*2, samples);
+ case FAAD_FMT_24BIT:
+ return write_audio_24bit(aufile, buf + offset*4, samples);
+ case FAAD_FMT_32BIT:
+ return write_audio_32bit(aufile, buf + offset*4, samples);
+ case FAAD_FMT_FLOAT:
+ return write_audio_float(aufile, buf + offset*4, samples);
+ default:
+ return 0;
+ }
+
+ return 0;
+}
+
+void close_audio_file(audio_file *aufile)
+{
+ if ((aufile->fileType == OUTPUT_WAV) && (aufile->toStdio == 0))
+ {
+ fseek(aufile->sndfile, 0, SEEK_SET);
+
+ if (aufile->channelMask)
+ write_wav_extensible_header(aufile, aufile->channelMask);
+ else
+ write_wav_header(aufile);
+ }
+
+ if (aufile->toStdio == 0)
+ fclose(aufile->sndfile);
+
+ if (aufile) free(aufile);
+}
+
+static int write_wav_header(audio_file *aufile)
+{
+ unsigned char header[44];
+ unsigned char* p = header;
+ unsigned int bytes = (aufile->bits_per_sample + 7) / 8;
+ float data_size = (float)bytes * aufile->total_samples;
+ unsigned long word32;
+
+ *p++ = 'R'; *p++ = 'I'; *p++ = 'F'; *p++ = 'F';
+
+ word32 = (data_size + (44 - 8) < (float)MAXWAVESIZE) ?
+ (unsigned long)data_size + (44 - 8) : (unsigned long)MAXWAVESIZE;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ *p++ = 'W'; *p++ = 'A'; *p++ = 'V'; *p++ = 'E';
+
+ *p++ = 'f'; *p++ = 'm'; *p++ = 't'; *p++ = ' ';
+
+ *p++ = 0x10; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+
+ if (aufile->outputFormat == FAAD_FMT_FLOAT)
+ {
+ *p++ = 0x03; *p++ = 0x00;
+ } else {
+ *p++ = 0x01; *p++ = 0x00;
+ }
+
+ *p++ = (unsigned char)(aufile->channels >> 0);
+ *p++ = (unsigned char)(aufile->channels >> 8);
+
+ word32 = (unsigned long)(aufile->samplerate + 0.5);
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ word32 = aufile->samplerate * bytes * aufile->channels;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ word32 = bytes * aufile->channels;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 0);
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 8);
+
+ *p++ = 'd'; *p++ = 'a'; *p++ = 't'; *p++ = 'a';
+
+ word32 = data_size < MAXWAVESIZE ?
+ (unsigned long)data_size : (unsigned long)MAXWAVESIZE;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ return fwrite(header, sizeof(header), 1, aufile->sndfile);
+}
+
+static int write_wav_extensible_header(audio_file *aufile, long channelMask)
+{
+ unsigned char header[68];
+ unsigned char* p = header;
+ unsigned int bytes = (aufile->bits_per_sample + 7) / 8;
+ float data_size = (float)bytes * aufile->total_samples;
+ unsigned long word32;
+
+ *p++ = 'R'; *p++ = 'I'; *p++ = 'F'; *p++ = 'F';
+
+ word32 = (data_size + (68 - 8) < (float)MAXWAVESIZE) ?
+ (unsigned long)data_size + (68 - 8) : (unsigned long)MAXWAVESIZE;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ *p++ = 'W'; *p++ = 'A'; *p++ = 'V'; *p++ = 'E';
+
+ *p++ = 'f'; *p++ = 'm'; *p++ = 't'; *p++ = ' ';
+
+ *p++ = /*0x10*/0x28; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
+
+ /* WAVE_FORMAT_EXTENSIBLE */
+ *p++ = 0xFE; *p++ = 0xFF;
+
+ *p++ = (unsigned char)(aufile->channels >> 0);
+ *p++ = (unsigned char)(aufile->channels >> 8);
+
+ word32 = (unsigned long)(aufile->samplerate + 0.5);
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ word32 = aufile->samplerate * bytes * aufile->channels;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ word32 = bytes * aufile->channels;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 0);
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 8);
+
+ /* cbSize */
+ *p++ = (unsigned char)(22);
+ *p++ = (unsigned char)(0);
+
+ /* WAVEFORMATEXTENSIBLE */
+
+ /* wValidBitsPerSample */
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 0);
+ *p++ = (unsigned char)(aufile->bits_per_sample >> 8);
+
+ /* dwChannelMask */
+ word32 = channelMask;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ /* SubFormat */
+ if (aufile->outputFormat == FAAD_FMT_FLOAT)
+ {
+ /* KSDATAFORMAT_SUBTYPE_IEEE_FLOAT: 00000003-0000-0010-8000-00aa00389b71 */
+ *p++ = 0x03;
+ *p++ = 0x00;
+ *p++ = 0x00;
+ *p++ = 0x00;
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x10; *p++ = 0x00; *p++ = 0x80; *p++ = 0x00;
+ *p++ = 0x00; *p++ = 0xaa; *p++ = 0x00; *p++ = 0x38; *p++ = 0x9b; *p++ = 0x71;
+ } else {
+ /* KSDATAFORMAT_SUBTYPE_PCM: 00000001-0000-0010-8000-00aa00389b71 */
+ *p++ = 0x01;
+ *p++ = 0x00;
+ *p++ = 0x00;
+ *p++ = 0x00;
+ *p++ = 0x00; *p++ = 0x00; *p++ = 0x10; *p++ = 0x00; *p++ = 0x80; *p++ = 0x00;
+ *p++ = 0x00; *p++ = 0xaa; *p++ = 0x00; *p++ = 0x38; *p++ = 0x9b; *p++ = 0x71;
+ }
+
+ /* end WAVEFORMATEXTENSIBLE */
+
+ *p++ = 'd'; *p++ = 'a'; *p++ = 't'; *p++ = 'a';
+
+ word32 = data_size < MAXWAVESIZE ?
+ (unsigned long)data_size : (unsigned long)MAXWAVESIZE;
+ *p++ = (unsigned char)(word32 >> 0);
+ *p++ = (unsigned char)(word32 >> 8);
+ *p++ = (unsigned char)(word32 >> 16);
+ *p++ = (unsigned char)(word32 >> 24);
+
+ return fwrite(header, sizeof(header), 1, aufile->sndfile);
+}
+
+static int write_audio_16bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples)
+{
+ int ret;
+ unsigned int i;
+ short *sample_buffer16 = (short*)sample_buffer;
+ char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
+
+ aufile->total_samples += samples;
+
+ if (aufile->channels == 6 && aufile->channelMask)
+ {
+ for (i = 0; i < samples; i += aufile->channels)
+ {
+ short r1, r2, r3, r4, r5, r6;
+ r1 = sample_buffer16[i];
+ r2 = sample_buffer16[i+1];
+ r3 = sample_buffer16[i+2];
+ r4 = sample_buffer16[i+3];
+ r5 = sample_buffer16[i+4];
+ r6 = sample_buffer16[i+5];
+ sample_buffer16[i] = r2;
+ sample_buffer16[i+1] = r3;
+ sample_buffer16[i+2] = r1;
+ sample_buffer16[i+3] = r6;
+ sample_buffer16[i+4] = r4;
+ sample_buffer16[i+5] = r5;
+ }
+ }
+
+ for (i = 0; i < samples; i++)
+ {
+ data[i*2] = (char)(sample_buffer16[i] & 0xFF);
+ data[i*2+1] = (char)((sample_buffer16[i] >> 8) & 0xFF);
+ }
+
+ ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
+
+ if (data) free(data);
+
+ return ret;
+}
+
+static int write_audio_24bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples)
+{
+ int ret;
+ unsigned int i;
+ long *sample_buffer24 = (long*)sample_buffer;
+ char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
+
+ aufile->total_samples += samples;
+
+ if (aufile->channels == 6 && aufile->channelMask)
+ {
+ for (i = 0; i < samples; i += aufile->channels)
+ {
+ long r1, r2, r3, r4, r5, r6;
+ r1 = sample_buffer24[i];
+ r2 = sample_buffer24[i+1];
+ r3 = sample_buffer24[i+2];
+ r4 = sample_buffer24[i+3];
+ r5 = sample_buffer24[i+4];
+ r6 = sample_buffer24[i+5];
+ sample_buffer24[i] = r2;
+ sample_buffer24[i+1] = r3;
+ sample_buffer24[i+2] = r1;
+ sample_buffer24[i+3] = r6;
+ sample_buffer24[i+4] = r4;
+ sample_buffer24[i+5] = r5;
+ }
+ }
+
+ for (i = 0; i < samples; i++)
+ {
+ data[i*3] = (char)(sample_buffer24[i] & 0xFF);
+ data[i*3+1] = (char)((sample_buffer24[i] >> 8) & 0xFF);
+ data[i*3+2] = (char)((sample_buffer24[i] >> 16) & 0xFF);
+ }
+
+ ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
+
+ if (data) free(data);
+
+ return ret;
+}
+
+static int write_audio_32bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples)
+{
+ int ret;
+ unsigned int i;
+ long *sample_buffer32 = (long*)sample_buffer;
+ char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
+
+ aufile->total_samples += samples;
+
+ if (aufile->channels == 6 && aufile->channelMask)
+ {
+ for (i = 0; i < samples; i += aufile->channels)
+ {
+ long r1, r2, r3, r4, r5, r6;
+ r1 = sample_buffer32[i];
+ r2 = sample_buffer32[i+1];
+ r3 = sample_buffer32[i+2];
+ r4 = sample_buffer32[i+3];
+ r5 = sample_buffer32[i+4];
+ r6 = sample_buffer32[i+5];
+ sample_buffer32[i] = r2;
+ sample_buffer32[i+1] = r3;
+ sample_buffer32[i+2] = r1;
+ sample_buffer32[i+3] = r6;
+ sample_buffer32[i+4] = r4;
+ sample_buffer32[i+5] = r5;
+ }
+ }
+
+ for (i = 0; i < samples; i++)
+ {
+ data[i*4] = (char)(sample_buffer32[i] & 0xFF);
+ data[i*4+1] = (char)((sample_buffer32[i] >> 8) & 0xFF);
+ data[i*4+2] = (char)((sample_buffer32[i] >> 16) & 0xFF);
+ data[i*4+3] = (char)((sample_buffer32[i] >> 24) & 0xFF);
+ }
+
+ ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
+
+ if (data) free(data);
+
+ return ret;
+}
+
+static int write_audio_float(audio_file *aufile, void *sample_buffer,
+ unsigned int samples)
+{
+ int ret;
+ unsigned int i;
+ float *sample_buffer_f = (float*)sample_buffer;
+ unsigned char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
+
+ aufile->total_samples += samples;
+
+ if (aufile->channels == 6 && aufile->channelMask)
+ {
+ for (i = 0; i < samples; i += aufile->channels)
+ {
+ float r1, r2, r3, r4, r5, r6;
+ r1 = sample_buffer_f[i];
+ r2 = sample_buffer_f[i+1];
+ r3 = sample_buffer_f[i+2];
+ r4 = sample_buffer_f[i+3];
+ r5 = sample_buffer_f[i+4];
+ r6 = sample_buffer_f[i+5];
+ sample_buffer_f[i] = r2;
+ sample_buffer_f[i+1] = r3;
+ sample_buffer_f[i+2] = r1;
+ sample_buffer_f[i+3] = r6;
+ sample_buffer_f[i+4] = r4;
+ sample_buffer_f[i+5] = r5;
+ }
+ }
+
+ for (i = 0; i < samples; i++)
+ {
+ int exponent, mantissa, negative = 0 ;
+ float in = sample_buffer_f[i];
+
+ data[i*4] = 0; data[i*4+1] = 0; data[i*4+2] = 0; data[i*4+3] = 0;
+ if (in == 0.0)
+ continue;
+
+ if (in < 0.0)
+ {
+ in *= -1.0;
+ negative = 1;
+ }
+ in = (float)frexp(in, &exponent);
+ exponent += 126;
+ in *= (float)0x1000000;
+ mantissa = (((int)in) & 0x7FFFFF);
+
+ if (negative)
+ data[i*4+3] |= 0x80;
+
+ if (exponent & 0x01)
+ data[i*4+2] |= 0x80;
+
+ data[i*4] = mantissa & 0xFF;
+ data[i*4+1] = (mantissa >> 8) & 0xFF;
+ data[i*4+2] |= (mantissa >> 16) & 0x7F;
+ data[i*4+3] |= (exponent >> 1) & 0x7F;
+ }
+
+ ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
+
+ if (data) free(data);
+
+ return ret;
+}
diff --git a/faad2/src/frontend/audio.h b/faad2/src/frontend/audio.h
new file mode 100644
index 0000000..b4d3a67
--- /dev/null
+++ b/faad2/src/frontend/audio.h
@@ -0,0 +1,75 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: audio.h,v 1.19 2007/11/01 12:33:29 menno Exp $
+**/
+
+#ifndef AUDIO_H_INCLUDED
+#define AUDIO_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAXWAVESIZE 4294967040LU
+
+#define OUTPUT_WAV 1
+#define OUTPUT_RAW 2
+
+typedef struct
+{
+ int toStdio;
+ int outputFormat;
+ FILE *sndfile;
+ unsigned int fileType;
+ unsigned long samplerate;
+ unsigned int bits_per_sample;
+ unsigned int channels;
+ unsigned long total_samples;
+ long channelMask;
+} audio_file;
+
+audio_file *open_audio_file(char *infile, int samplerate, int channels,
+ int outputFormat, int fileType, long channelMask);
+int write_audio_file(audio_file *aufile, void *sample_buffer, int samples, int offset);
+void close_audio_file(audio_file *aufile);
+static int write_wav_header(audio_file *aufile);
+static int write_wav_extensible_header(audio_file *aufile, long channelMask);
+static int write_audio_16bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples);
+static int write_audio_24bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples);
+static int write_audio_32bit(audio_file *aufile, void *sample_buffer,
+ unsigned int samples);
+static int write_audio_float(audio_file *aufile, void *sample_buffer,
+ unsigned int samples);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/faad2/src/frontend/faad.man b/faad2/src/frontend/faad.man
new file mode 100644
index 0000000..83727c7
--- /dev/null
+++ b/faad2/src/frontend/faad.man
@@ -0,0 +1,85 @@
+.TH FAAD "1" "October 2006" "faad 2.5" ""
+.SH NAME
+faad \(em Process an Advanced Audio Codec stream
+
+.SH "SYNOPSIS"
+.B faad
+[options] [\-w | \-o <output_filename> | \-a <output_filename>] input_filename
+
+.SH "DESCRIPTION"
+This utility provides a command line interface to libfaad2. This program reads in MPEG\(hy4 AAC files, processes, and outputs them in either Microsoft WAV, MPEG\(hy4 AAC ADTS, or standard PCM formats.
+
+.SH "OPTIONS"
+.TP
+.BI \-a " <filename>" ", \-\^\-adtsout" " <filename>"
+Sets the processing to output to the specified file in MPEG\(hy4 AAC ADTS format
+.TP
+.BI \-b " <number>" ", \-\^\-bits" " <number>"
+Set the output (individual) sample format. The number takes one of the following values:
+.RS
+.RS
+1: 16\(hybit PCM data (default).
+.br
+2: 24\(hybit PCM data.
+.br
+3: 32\(hybit PCM data.
+.br
+4: 32\(hybit floating\hy(point data.
+.br
+5: 64\(hybit floating\hy(point data.
+.RE
+.RE
+.TP
+.B \-d ", \-\^\-downmix"
+Set the processing to downsample from 5.1 (surround sound and bass) channels to 2 channels (stereo).
+.TP
+.BI \-f " <number>" ", \-\^\-format" " <number>"
+Set the output file format. The number takes one of the following values:
+.RS
+.RS
+1: Microsoft WAV format (default).
+.br
+2: Raw PCM data.
+.RE
+.RE
+.TP
+.BI \-g
+Set the processing to not perform gapless decoding.
+.TP
+.B \-h ", \-\^\-help"
+Shows a usage summary.
+.TP
+.B \-i ", \-\^\-info"
+Shows information about the about the input file.
+.TP
+.BI \-l " <number>" ", \-\^\-objecttype" " <number>"
+Sets the MPEG\hy(4 profile and object type for the processing to use. The number takes one of the following values:
+.RS
+.RS
+1: Main object type.
+.br
+2: Low Complexity (LC) object type (default).
+.br
+4: Long Term Prediction (LTP) object type.
+.br
+23: Low Delay (LD) object type.
+.RE
+.RE
+.TP
+.BI \-o " <filename>" ", \-\^\-outfile" " <number>"
+Sets the filename for processing output.
+.TP
+.B \-q ", \-\^\-quiet"
+Quiet \- Suppresses status messages during processing.
+.TP
+.B \-t ", \-\^\-oldformat"
+Sets the processing to use the old MPEG\(hy4 AAC ADTS format when outputting in said format.
+.TP
+.B \-w ", \-\^\-stdio"
+Sets the processing output to be sent to the standard out.
+
+.SH "AUTHOR"
+Matthew W. S. Bell <matthew (at) bells23.org.uk>
+
+.SH "SEE ALSO"
+\fBfaac\fP(1) \ No newline at end of file
diff --git a/faad2/src/frontend/faad.sln b/faad2/src/frontend/faad.sln
new file mode 100644
index 0000000..f8f1596
--- /dev/null
+++ b/faad2/src/frontend/faad.sln
@@ -0,0 +1,36 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "faad", "faad.vcproj", "{2BD8CBB3-DFC9-4A6A-9B7A-07ED749BED58}"
+ ProjectSection(ProjectDependencies) = postProject
+ {F470BB4A-7675-4D6A-B310-41F33AC6F987} = {F470BB4A-7675-4D6A-B310-41F33AC6F987}
+ {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114} = {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfaad", "..\libfaad\libfaad.vcproj", "{BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4ff", "..\common\mp4ff\mp4ff.vcproj", "{F470BB4A-7675-4D6A-B310-41F33AC6F987}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2BD8CBB3-DFC9-4A6A-9B7A-07ED749BED58}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2BD8CBB3-DFC9-4A6A-9B7A-07ED749BED58}.Debug|Win32.Build.0 = Debug|Win32
+ {2BD8CBB3-DFC9-4A6A-9B7A-07ED749BED58}.Release|Win32.ActiveCfg = Release|Win32
+ {2BD8CBB3-DFC9-4A6A-9B7A-07ED749BED58}.Release|Win32.Build.0 = Release|Win32
+ {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}.Debug|Win32.ActiveCfg = Debug|Win32
+ {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}.Debug|Win32.Build.0 = Debug|Win32
+ {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}.Release|Win32.ActiveCfg = Release|Win32
+ {BC3EFE27-9015-4C9C-AD3C-72B3B7ED2114}.Release|Win32.Build.0 = Release|Win32
+ {F470BB4A-7675-4D6A-B310-41F33AC6F987}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F470BB4A-7675-4D6A-B310-41F33AC6F987}.Debug|Win32.Build.0 = Debug|Win32
+ {F470BB4A-7675-4D6A-B310-41F33AC6F987}.Release|Win32.ActiveCfg = Release|Win32
+ {F470BB4A-7675-4D6A-B310-41F33AC6F987}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/faad2/src/frontend/faad.vcproj b/faad2/src/frontend/faad.vcproj
new file mode 100644
index 0000000..b33f6f4
--- /dev/null
+++ b/faad2/src/frontend/faad.vcproj
@@ -0,0 +1,256 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="faad"
+ ProjectGUID="{2BD8CBB3-DFC9-4A6A-9B7A-07ED749BED58}"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Debug/faad.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="0"
+ AdditionalIncludeDirectories="../include,../common/mp4ff,../common/faad"
+ PreprocessorDefinitions="WIN32,_DEBUG,_CONSOLE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderFile=".\Debug/faad.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1043"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="ws2_32.lib odbc32.lib odbccp32.lib Advapi32.lib"
+ OutputFile=".\Debug/faad.exe"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/faad.pdb"
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Release/faad.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=""
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="../include,../common/mp4ff,../common/faad"
+ PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE"
+ StringPooling="true"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderFile=".\Release/faad.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1043"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="ws2_32.lib Advapi32.lib"
+ OutputFile=".\Release/faad.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath=".\audio.c"
+ >
+ </File>
+ <File
+ RelativePath="..\common\faad\getopt.c"
+ >
+ </File>
+ <File
+ RelativePath=".\main.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath=".\audio.h"
+ >
+ </File>
+ <File
+ RelativePath="..\common\faad\getopt.h"
+ >
+ </File>
+ <File
+ RelativePath="..\common\mp4v2\mp4.h"
+ >
+ </File>
+ <File
+ RelativePath="..\common\mp4v2\mpeg4ip.h"
+ >
+ </File>
+ <File
+ RelativePath="..\include\neaacdec.h"
+ >
+ </File>
+ <File
+ RelativePath="..\common\mp4v2\systems.h"
+ >
+ </File>
+ <File
+ RelativePath="..\common\mp4v2\win32_ver.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/faad2/src/frontend/main.c b/faad2/src/frontend/main.c
new file mode 100644
index 0000000..2f97c07
--- /dev/null
+++ b/faad2/src/frontend/main.c
@@ -0,0 +1,1270 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: main.c,v 1.85 2008/09/22 17:55:09 menno Exp $
+**/
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#define off_t __int64
+#else
+#include <time.h>
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+
+#include <neaacdec.h>
+#include <mp4ff.h>
+
+#include "audio.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 */
+
+
+static int quiet = 0;
+
+static void faad_fprintf(FILE *stream, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (!quiet)
+ {
+ va_start(ap, fmt);
+
+ vfprintf(stream, fmt, ap);
+
+ va_end(ap);
+ }
+}
+
+/* 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;
+
+
+static int 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;
+}
+
+static void advance_buffer(aac_buffer *b, int bytes)
+{
+ b->file_offset += bytes;
+ b->bytes_consumed = bytes;
+ b->bytes_into_buffer -= bytes;
+ if (b->bytes_into_buffer < 0)
+ b->bytes_into_buffer = 0;
+}
+
+static int adts_sample_rates[] = {96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350,0,0,0};
+
+static int 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;
+}
+
+
+
+uint32_t read_callback(void *user_data, void *buffer, uint32_t length)
+{
+ return fread(buffer, 1, length, (FILE*)user_data);
+}
+
+uint32_t seek_callback(void *user_data, uint64_t position)
+{
+ return fseek((FILE*)user_data, position, SEEK_SET);
+}
+
+/* MicroSoft channel definitions */
+#define SPEAKER_FRONT_LEFT 0x1
+#define SPEAKER_FRONT_RIGHT 0x2
+#define SPEAKER_FRONT_CENTER 0x4
+#define SPEAKER_LOW_FREQUENCY 0x8
+#define SPEAKER_BACK_LEFT 0x10
+#define SPEAKER_BACK_RIGHT 0x20
+#define SPEAKER_FRONT_LEFT_OF_CENTER 0x40
+#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
+#define SPEAKER_BACK_CENTER 0x100
+#define SPEAKER_SIDE_LEFT 0x200
+#define SPEAKER_SIDE_RIGHT 0x400
+#define SPEAKER_TOP_CENTER 0x800
+#define SPEAKER_TOP_FRONT_LEFT 0x1000
+#define SPEAKER_TOP_FRONT_CENTER 0x2000
+#define SPEAKER_TOP_FRONT_RIGHT 0x4000
+#define SPEAKER_TOP_BACK_LEFT 0x8000
+#define SPEAKER_TOP_BACK_CENTER 0x10000
+#define SPEAKER_TOP_BACK_RIGHT 0x20000
+#define SPEAKER_RESERVED 0x80000000
+
+static long aacChannelConfig2wavexChannelMask(NeAACDecFrameInfo *hInfo)
+{
+ if (hInfo->channels == 6 && hInfo->num_lfe_channels)
+ {
+ return SPEAKER_FRONT_LEFT + SPEAKER_FRONT_RIGHT +
+ SPEAKER_FRONT_CENTER + SPEAKER_LOW_FREQUENCY +
+ SPEAKER_BACK_LEFT + SPEAKER_BACK_RIGHT;
+ } else {
+ return 0;
+ }
+}
+
+static char *position2string(int position)
+{
+ switch (position)
+ {
+ case FRONT_CHANNEL_CENTER: return "Center front";
+ case FRONT_CHANNEL_LEFT: return "Left front";
+ case FRONT_CHANNEL_RIGHT: return "Right front";
+ case SIDE_CHANNEL_LEFT: return "Left side";
+ case SIDE_CHANNEL_RIGHT: return "Right side";
+ case BACK_CHANNEL_LEFT: return "Left back";
+ case BACK_CHANNEL_RIGHT: return "Right back";
+ case BACK_CHANNEL_CENTER: return "Center back";
+ case LFE_CHANNEL: return "LFE";
+ case UNKNOWN_CHANNEL: return "Unknown";
+ default: return "";
+ }
+
+ return "";
+}
+
+static void print_channel_info(NeAACDecFrameInfo *frameInfo)
+{
+ /* print some channel info */
+ int i;
+ long channelMask = aacChannelConfig2wavexChannelMask(frameInfo);
+
+ faad_fprintf(stderr, " ---------------------\n");
+ if (frameInfo->num_lfe_channels > 0)
+ {
+ faad_fprintf(stderr, " | Config: %2d.%d Ch |", frameInfo->channels-frameInfo->num_lfe_channels, frameInfo->num_lfe_channels);
+ } else {
+ faad_fprintf(stderr, " | Config: %2d Ch |", frameInfo->channels);
+ }
+ if (channelMask)
+ faad_fprintf(stderr, " WARNING: channels are reordered according to\n");
+ else
+ faad_fprintf(stderr, "\n");
+ faad_fprintf(stderr, " ---------------------");
+ if (channelMask)
+ faad_fprintf(stderr, " MS defaults defined in WAVE_FORMAT_EXTENSIBLE\n");
+ else
+ faad_fprintf(stderr, "\n");
+ faad_fprintf(stderr, " | Ch | Position |\n");
+ faad_fprintf(stderr, " ---------------------\n");
+ for (i = 0; i < frameInfo->channels; i++)
+ {
+ faad_fprintf(stderr, " | %.2d | %-14s |\n", i, position2string((int)frameInfo->channel_position[i]));
+ }
+ faad_fprintf(stderr, " ---------------------\n");
+ faad_fprintf(stderr, "\n");
+}
+
+static int FindAdtsSRIndex(int sr)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ {
+ if (sr == adts_sample_rates[i])
+ return i;
+ }
+ return 16 - 1;
+}
+
+static unsigned char *MakeAdtsHeader(int *dataSize, NeAACDecFrameInfo *hInfo, int old_format)
+{
+ unsigned char *data;
+ int profile = (hInfo->object_type - 1) & 0x3;
+ int sr_index = ((hInfo->sbr == SBR_UPSAMPLED) || (hInfo->sbr == NO_SBR_UPSAMPLED)) ?
+ FindAdtsSRIndex(hInfo->samplerate / 2) : FindAdtsSRIndex(hInfo->samplerate);
+ int skip = (old_format) ? 8 : 7;
+ int framesize = skip + hInfo->bytesconsumed;
+
+ if (hInfo->header_type == ADTS)
+ framesize -= skip;
+
+ *dataSize = 7;
+
+ data = malloc(*dataSize * sizeof(unsigned char));
+ memset(data, 0, *dataSize * sizeof(unsigned char));
+
+ data[0] += 0xFF; /* 8b: syncword */
+
+ data[1] += 0xF0; /* 4b: syncword */
+ /* 1b: mpeg id = 0 */
+ /* 2b: layer = 0 */
+ data[1] += 1; /* 1b: protection absent */
+
+ data[2] += ((profile << 6) & 0xC0); /* 2b: profile */
+ data[2] += ((sr_index << 2) & 0x3C); /* 4b: sampling_frequency_index */
+ /* 1b: private = 0 */
+ data[2] += ((hInfo->channels >> 2) & 0x1); /* 1b: channel_configuration */
+
+ data[3] += ((hInfo->channels << 6) & 0xC0); /* 2b: channel_configuration */
+ /* 1b: original */
+ /* 1b: home */
+ /* 1b: copyright_id */
+ /* 1b: copyright_id_start */
+ data[3] += ((framesize >> 11) & 0x3); /* 2b: aac_frame_length */
+
+ data[4] += ((framesize >> 3) & 0xFF); /* 8b: aac_frame_length */
+
+ data[5] += ((framesize << 5) & 0xE0); /* 3b: aac_frame_length */
+ data[5] += ((0x7FF >> 6) & 0x1F); /* 5b: adts_buffer_fullness */
+
+ data[6] += ((0x7FF << 2) & 0x3F); /* 6b: adts_buffer_fullness */
+ /* 2b: num_raw_data_blocks */
+
+ return data;
+}
+
+/* globals */
+char *progName;
+
+static const char *file_ext[] =
+{
+ NULL,
+ ".wav",
+ ".aif",
+ ".au",
+ ".au",
+ ".pcm",
+ NULL
+};
+
+static void usage(void)
+{
+ faad_fprintf(stdout, "\nUsage:\n");
+ faad_fprintf(stdout, "%s [options] infile.aac\n", progName);
+ faad_fprintf(stdout, "Options:\n");
+ faad_fprintf(stdout, " -h Shows this help screen.\n");
+ faad_fprintf(stdout, " -i Shows info about the input file.\n");
+ faad_fprintf(stdout, " -a X Write MPEG-4 AAC ADTS output file.\n");
+ faad_fprintf(stdout, " -t Assume old ADTS format.\n");
+ faad_fprintf(stdout, " -o X Set output filename.\n");
+ faad_fprintf(stdout, " -f X Set output format. Valid values for X are:\n");
+ faad_fprintf(stdout, " 1: Microsoft WAV format (default).\n");
+ faad_fprintf(stdout, " 2: RAW PCM data.\n");
+ faad_fprintf(stdout, " -b X Set output sample format. Valid values for X are:\n");
+ faad_fprintf(stdout, " 1: 16 bit PCM data (default).\n");
+ faad_fprintf(stdout, " 2: 24 bit PCM data.\n");
+ faad_fprintf(stdout, " 3: 32 bit PCM data.\n");
+ faad_fprintf(stdout, " 4: 32 bit floating point data.\n");
+ faad_fprintf(stdout, " 5: 64 bit floating point data.\n");
+ faad_fprintf(stdout, " -s X Force the samplerate to X (for RAW files).\n");
+ faad_fprintf(stdout, " -l X Set object type. Supported object types:\n");
+ faad_fprintf(stdout, " 1: Main object type.\n");
+ faad_fprintf(stdout, " 2: LC (Low Complexity) object type.\n");
+ faad_fprintf(stdout, " 4: LTP (Long Term Prediction) object type.\n");
+ faad_fprintf(stdout, " 23: LD (Low Delay) object type.\n");
+ faad_fprintf(stdout, " -d Down matrix 5.1 to 2 channels\n");
+ faad_fprintf(stdout, " -w Write output to stdio instead of a file.\n");
+ faad_fprintf(stdout, " -g Disable gapless decoding.\n");
+ faad_fprintf(stdout, " -q Quiet - suppresses status messages.\n");
+ faad_fprintf(stdout, "Example:\n");
+ faad_fprintf(stdout, " %s infile.aac\n", progName);
+ faad_fprintf(stdout, " %s infile.mp4\n", progName);
+ faad_fprintf(stdout, " %s -o outfile.wav infile.aac\n", progName);
+ faad_fprintf(stdout, " %s -w infile.aac > outfile.wav\n", progName);
+ faad_fprintf(stdout, " %s -a outfile.aac infile.aac\n", progName);
+ return;
+}
+
+static int decodeAACfile(char *aacfile, char *sndfile, char *adts_fn, int to_stdout,
+ int def_srate, int object_type, int outputFormat, int fileType,
+ int downMatrix, int infoOnly, int adts_out, int old_format,
+ float *song_length)
+{
+ int tagsize;
+ unsigned long samplerate;
+ unsigned char channels;
+ void *sample_buffer;
+
+ audio_file *aufile;
+
+ FILE *adtsFile;
+ unsigned char *adtsData;
+ int adtsDataSize;
+
+ NeAACDecHandle hDecoder;
+ NeAACDecFrameInfo frameInfo;
+ NeAACDecConfigurationPtr config;
+
+ char percents[200];
+ int percent, old_percent = -1;
+ int bread, fileread;
+ int header_type = 0;
+ int bitrate = 0;
+ float length = 0;
+
+ int first_time = 1;
+
+ aac_buffer b;
+
+ memset(&b, 0, sizeof(aac_buffer));
+
+ if (adts_out)
+ {
+ adtsFile = fopen(adts_fn, "wb");
+ if (adtsFile == NULL)
+ {
+ faad_fprintf(stderr, "Error opening file: %s\n", adts_fn);
+ return 1;
+ }
+ }
+
+ b.infile = fopen(aacfile, "rb");
+ if (b.infile == NULL)
+ {
+ /* unable to open file */
+ faad_fprintf(stderr, "Error opening file: %s\n", aacfile);
+ return 1;
+ }
+
+ fseek(b.infile, 0, SEEK_END);
+ fileread = ftell(b.infile);
+ fseek(b.infile, 0, SEEK_SET);
+
+ if (!(b.buffer = (unsigned char*)malloc(FAAD_MIN_STREAMSIZE*MAX_CHANNELS)))
+ {
+ faad_fprintf(stderr, "Memory allocation error\n");
+ return 0;
+ }
+ memset(b.buffer, 0, FAAD_MIN_STREAMSIZE*MAX_CHANNELS);
+
+ bread = fread(b.buffer, 1, FAAD_MIN_STREAMSIZE*MAX_CHANNELS, b.infile);
+ b.bytes_into_buffer = bread;
+ b.bytes_consumed = 0;
+ b.file_offset = 0;
+
+ if (bread != FAAD_MIN_STREAMSIZE*MAX_CHANNELS)
+ b.at_eof = 1;
+
+ 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);
+ }
+
+ hDecoder = NeAACDecOpen();
+
+ /* Set the default object type and samplerate */
+ /* This is useful for RAW AAC files */
+ config = NeAACDecGetCurrentConfiguration(hDecoder);
+ if (def_srate)
+ config->defSampleRate = def_srate;
+ config->defObjectType = object_type;
+ config->outputFormat = outputFormat;
+ config->downMatrix = downMatrix;
+ config->useOldADTSFormat = old_format;
+ //config->dontUpSampleImplicitSBR = 1;
+ NeAACDecSetConfiguration(hDecoder, config);
+
+ /* get AAC infos for printing */
+ header_type = 0;
+ 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)fileread;
+ 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;
+
+ fill_buffer(&b);
+ if ((bread = NeAACDecInit(hDecoder, b.buffer,
+ b.bytes_into_buffer, &samplerate, &channels)) < 0)
+ {
+ /* If some error initializing occured, skip the file */
+ faad_fprintf(stderr, "Error initializing decoder library.\n");
+ if (b.buffer)
+ free(b.buffer);
+ NeAACDecClose(hDecoder);
+ fclose(b.infile);
+ return 1;
+ }
+ advance_buffer(&b, bread);
+ fill_buffer(&b);
+
+ /* print AAC file info */
+ faad_fprintf(stderr, "%s file info:\n", aacfile);
+ switch (header_type)
+ {
+ case 0:
+ faad_fprintf(stderr, "RAW\n\n");
+ break;
+ case 1:
+ faad_fprintf(stderr, "ADTS, %.3f sec, %d kbps, %d Hz\n\n",
+ length, bitrate, samplerate);
+ break;
+ case 2:
+ faad_fprintf(stderr, "ADIF, %.3f sec, %d kbps, %d Hz\n\n",
+ length, bitrate, samplerate);
+ break;
+ }
+
+ if (infoOnly)
+ {
+ NeAACDecClose(hDecoder);
+ fclose(b.infile);
+ if (b.buffer)
+ free(b.buffer);
+ return 0;
+ }
+
+ do
+ {
+ sample_buffer = NeAACDecDecode(hDecoder, &frameInfo,
+ b.buffer, b.bytes_into_buffer);
+
+ if (adts_out == 1)
+ {
+ int skip = (old_format) ? 8 : 7;
+ adtsData = MakeAdtsHeader(&adtsDataSize, &frameInfo, old_format);
+
+ /* write the adts header */
+ fwrite(adtsData, 1, adtsDataSize, adtsFile);
+
+ /* write the frame data */
+ if (frameInfo.header_type == ADTS)
+ fwrite(b.buffer + skip, 1, frameInfo.bytesconsumed - skip, adtsFile);
+ else
+ fwrite(b.buffer, 1, frameInfo.bytesconsumed, adtsFile);
+ }
+
+ /* update buffer indices */
+ advance_buffer(&b, frameInfo.bytesconsumed);
+
+ if (frameInfo.error > 0)
+ {
+ faad_fprintf(stderr, "Error: %s\n",
+ NeAACDecGetErrorMessage(frameInfo.error));
+ }
+
+ /* open the sound file now that the number of channels are known */
+ if (first_time && !frameInfo.error)
+ {
+ /* print some channel info */
+ print_channel_info(&frameInfo);
+
+ if (!adts_out)
+ {
+ /* open output file */
+ if (!to_stdout)
+ {
+ aufile = open_audio_file(sndfile, frameInfo.samplerate, frameInfo.channels,
+ outputFormat, fileType, aacChannelConfig2wavexChannelMask(&frameInfo));
+ } else {
+ aufile = open_audio_file("-", frameInfo.samplerate, frameInfo.channels,
+ outputFormat, fileType, aacChannelConfig2wavexChannelMask(&frameInfo));
+ }
+ if (aufile == NULL)
+ {
+ if (b.buffer)
+ free(b.buffer);
+ NeAACDecClose(hDecoder);
+ fclose(b.infile);
+ return 0;
+ }
+ } else {
+ faad_fprintf(stderr, "Writing output MPEG-4 AAC ADTS file.\n\n");
+ }
+ first_time = 0;
+ }
+
+ percent = min((int)(b.file_offset*100)/fileread, 100);
+ if (percent > old_percent)
+ {
+ old_percent = percent;
+ sprintf(percents, "%d%% decoding %s.", percent, aacfile);
+ faad_fprintf(stderr, "%s\r", percents);
+#ifdef _WIN32
+ SetConsoleTitle(percents);
+#endif
+ }
+
+ if ((frameInfo.error == 0) && (frameInfo.samples > 0) && (!adts_out))
+ {
+ if (write_audio_file(aufile, sample_buffer, frameInfo.samples, 0) == 0)
+ break;
+ }
+
+ /* fill buffer */
+ fill_buffer(&b);
+
+ if (b.bytes_into_buffer == 0)
+ sample_buffer = NULL; /* to make sure it stops now */
+
+ } while (sample_buffer != NULL);
+
+ NeAACDecClose(hDecoder);
+
+ if (adts_out == 1)
+ {
+ fclose(adtsFile);
+ }
+
+ fclose(b.infile);
+
+ if (!first_time && !adts_out)
+ close_audio_file(aufile);
+
+ if (b.buffer)
+ free(b.buffer);
+
+ return frameInfo.error;
+}
+
+static int GetAACTrack(mp4ff_t *infile)
+{
+ /* find AAC track */
+ int i, rc;
+ int numTracks = mp4ff_total_tracks(infile);
+
+ for (i = 0; i < numTracks; i++)
+ {
+ unsigned char *buff = NULL;
+ int buff_size = 0;
+ mp4AudioSpecificConfig mp4ASC;
+
+ mp4ff_get_decoder_config(infile, i, &buff, &buff_size);
+
+ if (buff)
+ {
+ rc = NeAACDecAudioSpecificConfig(buff, buff_size, &mp4ASC);
+ free(buff);
+
+ if (rc < 0)
+ continue;
+ return i;
+ }
+ }
+
+ /* can't decode this */
+ return -1;
+}
+
+static const unsigned long srates[] =
+{
+ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000,
+ 12000, 11025, 8000
+};
+
+static int decodeMP4file(char *mp4file, char *sndfile, char *adts_fn, int to_stdout,
+ int outputFormat, int fileType, int downMatrix, int noGapless,
+ int infoOnly, int adts_out, float *song_length)
+{
+ int track;
+ unsigned long samplerate;
+ unsigned char channels;
+ void *sample_buffer;
+
+ mp4ff_t *infile;
+ long sampleId, numSamples;
+
+ audio_file *aufile;
+
+ FILE *mp4File;
+ FILE *adtsFile;
+ unsigned char *adtsData;
+ int adtsDataSize;
+
+ NeAACDecHandle hDecoder;
+ NeAACDecConfigurationPtr config;
+ NeAACDecFrameInfo frameInfo;
+ mp4AudioSpecificConfig mp4ASC;
+
+ unsigned char *buffer;
+ int buffer_size;
+
+ char percents[200];
+ int percent, old_percent = -1;
+
+ int first_time = 1;
+
+ /* for gapless decoding */
+ unsigned int useAacLength = 1;
+ unsigned int initial = 1;
+ unsigned int framesize;
+ unsigned long timescale;
+
+
+ /* initialise the callback structure */
+ mp4ff_callback_t *mp4cb = malloc(sizeof(mp4ff_callback_t));
+
+ mp4File = fopen(mp4file, "rb");
+ mp4cb->read = read_callback;
+ mp4cb->seek = seek_callback;
+ mp4cb->user_data = mp4File;
+
+
+ hDecoder = NeAACDecOpen();
+
+ /* Set configuration */
+ config = NeAACDecGetCurrentConfiguration(hDecoder);
+ config->outputFormat = outputFormat;
+ config->downMatrix = downMatrix;
+ //config->dontUpSampleImplicitSBR = 1;
+ NeAACDecSetConfiguration(hDecoder, config);
+
+ if (adts_out)
+ {
+ adtsFile = fopen(adts_fn, "wb");
+ if (adtsFile == NULL)
+ {
+ faad_fprintf(stderr, "Error opening file: %s\n", adts_fn);
+ return 1;
+ }
+ }
+
+ infile = mp4ff_open_read(mp4cb);
+ if (!infile)
+ {
+ /* unable to open file */
+ faad_fprintf(stderr, "Error opening file: %s\n", mp4file);
+ return 1;
+ }
+
+ if ((track = GetAACTrack(infile)) < 0)
+ {
+ faad_fprintf(stderr, "Unable to find correct AAC sound track in the MP4 file.\n");
+ NeAACDecClose(hDecoder);
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+ return 1;
+ }
+
+ buffer = NULL;
+ buffer_size = 0;
+ mp4ff_get_decoder_config(infile, track, &buffer, &buffer_size);
+
+ if(NeAACDecInit2(hDecoder, buffer, buffer_size,
+ &samplerate, &channels) < 0)
+ {
+ /* If some error initializing occured, skip the file */
+ faad_fprintf(stderr, "Error initializing decoder library.\n");
+ NeAACDecClose(hDecoder);
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+ return 1;
+ }
+
+ timescale = mp4ff_time_scale(infile, track);
+ framesize = 1024;
+ useAacLength = 0;
+
+ if (buffer)
+ {
+ if (NeAACDecAudioSpecificConfig(buffer, buffer_size, &mp4ASC) >= 0)
+ {
+ if (mp4ASC.frameLengthFlag == 1) framesize = 960;
+ if (mp4ASC.sbr_present_flag == 1) framesize *= 2;
+ }
+ free(buffer);
+ }
+
+ /* print some mp4 file info */
+ faad_fprintf(stderr, "%s file info:\n\n", mp4file);
+ {
+ char *tag = NULL, *item = NULL;
+ int k, j;
+ char *ot[6] = { "NULL", "MAIN AAC", "LC AAC", "SSR AAC", "LTP AAC", "HE AAC" };
+ long samples = mp4ff_num_samples(infile, track);
+ float f = 1024.0;
+ float seconds;
+ if (mp4ASC.sbr_present_flag == 1)
+ {
+ f = f * 2.0;
+ }
+ seconds = (float)samples*(float)(f-1.0)/(float)mp4ASC.samplingFrequency;
+
+ *song_length = seconds;
+
+ faad_fprintf(stderr, "%s\t%.3f secs, %d ch, %d Hz\n\n", ot[(mp4ASC.objectTypeIndex > 5)?0:mp4ASC.objectTypeIndex],
+ seconds, mp4ASC.channelsConfiguration, mp4ASC.samplingFrequency);
+
+#define PRINT_MP4_METADATA
+#ifdef PRINT_MP4_METADATA
+ j = mp4ff_meta_get_num_items(infile);
+ for (k = 0; k < j; k++)
+ {
+ if (mp4ff_meta_get_by_index(infile, k, &item, &tag))
+ {
+ if (item != NULL && tag != NULL)
+ {
+ faad_fprintf(stderr, "%s: %s\n", item, tag);
+ free(item); item = NULL;
+ free(tag); tag = NULL;
+ }
+ }
+ }
+ if (j > 0) faad_fprintf(stderr, "\n");
+#endif
+ }
+
+ if (infoOnly)
+ {
+ NeAACDecClose(hDecoder);
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+ return 0;
+ }
+
+ numSamples = mp4ff_num_samples(infile, track);
+
+ for (sampleId = 0; sampleId < numSamples; sampleId++)
+ {
+ int rc;
+ long dur;
+ unsigned int sample_count;
+ unsigned int delay = 0;
+
+ /* get acces unit from MP4 file */
+ buffer = NULL;
+ buffer_size = 0;
+
+ dur = mp4ff_get_sample_duration(infile, track, sampleId);
+ rc = mp4ff_read_sample(infile, track, sampleId, &buffer, &buffer_size);
+ if (rc == 0)
+ {
+ faad_fprintf(stderr, "Reading from MP4 file failed.\n");
+ NeAACDecClose(hDecoder);
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+ return 1;
+ }
+
+ sample_buffer = NeAACDecDecode(hDecoder, &frameInfo, buffer, buffer_size);
+
+ if (adts_out == 1)
+ {
+ adtsData = MakeAdtsHeader(&adtsDataSize, &frameInfo, 0);
+
+ /* write the adts header */
+ fwrite(adtsData, 1, adtsDataSize, adtsFile);
+
+ fwrite(buffer, 1, frameInfo.bytesconsumed, adtsFile);
+ }
+
+ if (buffer) free(buffer);
+
+ if (!noGapless)
+ {
+ if (sampleId == 0) dur = 0;
+
+ if (useAacLength || (timescale != samplerate)) {
+ sample_count = frameInfo.samples;
+ } else {
+ sample_count = (unsigned int)(dur * frameInfo.channels);
+ if (sample_count > frameInfo.samples)
+ sample_count = frameInfo.samples;
+
+ if (!useAacLength && !initial && (sampleId < numSamples/2) && (sample_count != frameInfo.samples))
+ {
+ faad_fprintf(stderr, "MP4 seems to have incorrect frame duration, using values from AAC data.\n");
+ useAacLength = 1;
+ sample_count = frameInfo.samples;
+ }
+ }
+
+ if (initial && (sample_count < framesize*frameInfo.channels) && (frameInfo.samples > sample_count))
+ delay = frameInfo.samples - sample_count;
+ } else {
+ sample_count = frameInfo.samples;
+ }
+
+ /* open the sound file now that the number of channels are known */
+ if (first_time && !frameInfo.error)
+ {
+ /* print some channel info */
+ print_channel_info(&frameInfo);
+
+ if (!adts_out)
+ {
+ /* open output file */
+ if(!to_stdout)
+ {
+ aufile = open_audio_file(sndfile, frameInfo.samplerate, frameInfo.channels,
+ outputFormat, fileType, aacChannelConfig2wavexChannelMask(&frameInfo));
+ } else {
+#ifdef _WIN32
+ setmode(fileno(stdout), O_BINARY);
+#endif
+ aufile = open_audio_file("-", frameInfo.samplerate, frameInfo.channels,
+ outputFormat, fileType, aacChannelConfig2wavexChannelMask(&frameInfo));
+ }
+ if (aufile == NULL)
+ {
+ NeAACDecClose(hDecoder);
+ mp4ff_close(infile);
+ free(mp4cb);
+ fclose(mp4File);
+ return 0;
+ }
+ }
+ first_time = 0;
+ }
+
+ if (sample_count > 0) initial = 0;
+
+ percent = min((int)(sampleId*100)/numSamples, 100);
+ if (percent > old_percent)
+ {
+ old_percent = percent;
+ sprintf(percents, "%d%% decoding %s.", percent, mp4file);
+ faad_fprintf(stderr, "%s\r", percents);
+#ifdef _WIN32
+ SetConsoleTitle(percents);
+#endif
+ }
+
+ if ((frameInfo.error == 0) && (sample_count > 0) && (!adts_out))
+ {
+ if (write_audio_file(aufile, sample_buffer, sample_count, delay) == 0)
+ break;
+ }
+
+ if (frameInfo.error > 0)
+ {
+ faad_fprintf(stderr, "Warning: %s\n",
+ NeAACDecGetErrorMessage(frameInfo.error));
+ }
+ }
+
+ NeAACDecClose(hDecoder);
+
+ if (adts_out == 1)
+ {
+ fclose(adtsFile);
+ }
+
+ mp4ff_close(infile);
+
+ if (!first_time && !adts_out)
+ close_audio_file(aufile);
+
+ free(mp4cb);
+ fclose(mp4File);
+
+ return frameInfo.error;
+}
+
+int main(int argc, char *argv[])
+{
+ int result;
+ int infoOnly = 0;
+ int writeToStdio = 0;
+ int object_type = LC;
+ int def_srate = 0;
+ int downMatrix = 0;
+ int format = 1;
+ int outputFormat = FAAD_FMT_16BIT;
+ int outfile_set = 0;
+ int adts_out = 0;
+ int old_format = 0;
+ int showHelp = 0;
+ int mp4file = 0;
+ int noGapless = 0;
+ char *fnp;
+ char aacFileName[255];
+ char audioFileName[255];
+ char adtsFileName[255];
+ unsigned char header[8];
+ float length = 0;
+ FILE *hMP4File;
+
+/* System dependant types */
+#ifdef _WIN32
+ long begin;
+#else
+ clock_t begin;
+#endif
+
+ unsigned long cap = NeAACDecGetCapabilities();
+
+
+ /* begin process command line */
+ progName = argv[0];
+ while (1) {
+ int c = -1;
+ int option_index = 0;
+ static struct option long_options[] = {
+ { "quiet", 0, 0, 'q' },
+ { "outfile", 0, 0, 'o' },
+ { "adtsout", 0, 0, 'a' },
+ { "oldformat", 0, 0, 't' },
+ { "format", 0, 0, 'f' },
+ { "bits", 0, 0, 'b' },
+ { "samplerate", 0, 0, 's' },
+ { "objecttype", 0, 0, 'l' },
+ { "downmix", 0, 0, 'd' },
+ { "info", 0, 0, 'i' },
+ { "stdio", 0, 0, 'w' },
+ { "stdio", 0, 0, 'g' },
+ { "help", 0, 0, 'h' },
+ { 0, 0, 0, 0 }
+ };
+
+ c = getopt_long(argc, argv, "o:a:s:f:b:l:wgdhitq",
+ long_options, &option_index);
+
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 'o':
+ if (optarg)
+ {
+ outfile_set = 1;
+ strcpy(audioFileName, optarg);
+ }
+ break;
+ case 'a':
+ if (optarg)
+ {
+ adts_out = 1;
+ strcpy(adtsFileName, optarg);
+ }
+ break;
+ case 's':
+ if (optarg)
+ {
+ char dr[10];
+ if (sscanf(optarg, "%s", dr) < 1) {
+ def_srate = 0;
+ } else {
+ def_srate = atoi(dr);
+ }
+ }
+ break;
+ case 'f':
+ if (optarg)
+ {
+ char dr[10];
+ if (sscanf(optarg, "%s", dr) < 1)
+ {
+ format = 1;
+ } else {
+ format = atoi(dr);
+ if ((format < 1) || (format > 2))
+ showHelp = 1;
+ }
+ }
+ break;
+ case 'b':
+ if (optarg)
+ {
+ char dr[10];
+ if (sscanf(optarg, "%s", dr) < 1)
+ {
+ outputFormat = FAAD_FMT_16BIT; /* just use default */
+ } else {
+ outputFormat = atoi(dr);
+ if ((outputFormat < 1) || (outputFormat > 5))
+ showHelp = 1;
+ }
+ }
+ break;
+ case 'l':
+ if (optarg)
+ {
+ char dr[10];
+ if (sscanf(optarg, "%s", dr) < 1)
+ {
+ object_type = LC; /* default */
+ } else {
+ object_type = atoi(dr);
+ if ((object_type != LC) &&
+ (object_type != MAIN) &&
+ (object_type != LTP) &&
+ (object_type != LD))
+ {
+ showHelp = 1;
+ }
+ }
+ }
+ break;
+ case 't':
+ old_format = 1;
+ break;
+ case 'd':
+ downMatrix = 1;
+ break;
+ case 'w':
+ writeToStdio = 1;
+ break;
+ case 'g':
+ noGapless = 1;
+ break;
+ case 'i':
+ infoOnly = 1;
+ break;
+ case 'h':
+ showHelp = 1;
+ break;
+ case 'q':
+ quiet = 1;
+ break;
+ default:
+ break;
+ }
+ }
+
+
+ faad_fprintf(stderr, " *********** Ahead Software MPEG-4 AAC Decoder V%s ******************\n\n", FAAD2_VERSION);
+ faad_fprintf(stderr, " Build: %s\n", __DATE__);
+ faad_fprintf(stderr, " Copyright 2002-2004: Ahead Software AG\n");
+ faad_fprintf(stderr, " http://www.audiocoding.com\n");
+ if (cap & FIXED_POINT_CAP)
+ faad_fprintf(stderr, " Fixed point version\n");
+ else
+ faad_fprintf(stderr, " Floating point version\n");
+ faad_fprintf(stderr, "\n");
+ faad_fprintf(stderr, " This program is free software; you can redistribute it and/or modify\n");
+ faad_fprintf(stderr, " it under the terms of the GNU General Public License.\n");
+ faad_fprintf(stderr, "\n");
+ faad_fprintf(stderr, " **************************************************************************\n\n");
+
+
+ /* check that we have at least two non-option arguments */
+ /* Print help if requested */
+ if (((argc - optind) < 1) || showHelp)
+ {
+ usage();
+ return 1;
+ }
+
+#if 0
+ /* only allow raw data on stdio */
+ if (writeToStdio == 1)
+ {
+ format = 2;
+ }
+#endif
+
+ /* point to the specified file name */
+ strcpy(aacFileName, argv[optind]);
+
+#ifdef _WIN32
+ begin = GetTickCount();
+#else
+ begin = clock();
+#endif
+
+ /* Only calculate the path and open the file for writing if
+ we are not writing to stdout.
+ */
+ if(!writeToStdio && !outfile_set)
+ {
+ strcpy(audioFileName, aacFileName);
+
+ fnp = (char *)strrchr(audioFileName,'.');
+
+ if (fnp)
+ fnp[0] = '\0';
+
+ strcat(audioFileName, file_ext[format]);
+ }
+
+ /* check for mp4 file */
+ mp4file = 0;
+ hMP4File = fopen(aacFileName, "rb");
+ if (!hMP4File)
+ {
+ faad_fprintf(stderr, "Error opening file: %s\n", aacFileName);
+ return 1;
+ }
+ fread(header, 1, 8, hMP4File);
+ fclose(hMP4File);
+ if (header[4] == 'f' && header[5] == 't' && header[6] == 'y' && header[7] == 'p')
+ mp4file = 1;
+
+ if (mp4file)
+ {
+ result = decodeMP4file(aacFileName, audioFileName, adtsFileName, writeToStdio,
+ outputFormat, format, downMatrix, noGapless, infoOnly, adts_out, &length);
+ } else {
+ result = decodeAACfile(aacFileName, audioFileName, adtsFileName, writeToStdio,
+ def_srate, object_type, outputFormat, format, downMatrix, infoOnly, adts_out,
+ old_format, &length);
+ }
+
+ if (!result && !infoOnly)
+ {
+#ifdef _WIN32
+ float dec_length = (float)(GetTickCount()-begin)/1000.0;
+ SetConsoleTitle("FAAD");
+#else
+ /* clock() grabs time since the start of the app but when we decode
+ multiple files, each file has its own starttime (begin).
+ */
+ float dec_length = (float)(clock() - begin)/(float)CLOCKS_PER_SEC;
+#endif
+ faad_fprintf(stderr, "Decoding %s took: %5.2f sec. %5.2fx real-time.\n", aacFileName,
+ dec_length, length/dec_length);
+ }
+
+ return 0;
+}
diff --git a/faad2/src/in_mpeg4aac.nsi b/faad2/src/in_mpeg4aac.nsi
new file mode 100644
index 0000000..1ea57ec
--- /dev/null
+++ b/faad2/src/in_mpeg4aac.nsi
@@ -0,0 +1,21 @@
+Name "AudioCoding.com MP4 Winamp plugin"
+OutFile in_mp4.exe
+CRCCheck on
+LicenseText "You must read the following license before installing."
+LicenseData COPYING
+ComponentText "This will install the AudioCoding.com MP4 Winamp plugin on your computer."
+InstType Normal
+AutoCloseWindow true
+SetOverwrite on
+SetDateSave on
+
+InstallDir $PROGRAMFILES\Winamp
+InstallDirRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" "UninstallString"
+;DirShow
+DirText "The installer has detected the path to Winamp. If it is not correct, please change."
+
+Section "AudioCoding.com MP4 Winamp plugin"
+SectionIn 1
+SetOutPath $INSTDIR\Plugins
+File plugins\in_mp4\Release\in_mp4.dll
+SectionEnd
diff --git a/faad2/src/include/faad.h b/faad2/src/include/faad.h
new file mode 100644
index 0000000..5bffc99
--- /dev/null
+++ b/faad2/src/include/faad.h
@@ -0,0 +1,35 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: faad.h,v 1.51 2007/11/01 12:33:29 menno Exp $
+**/
+
+/* warn people for update */
+#pragma message("please update faad2 include filename and function names!")
+
+/* Backwards compatible link */
+#include "neaacdec.h"
diff --git a/faad2/src/include/neaacdec.h b/faad2/src/include/neaacdec.h
new file mode 100644
index 0000000..8290fac
--- /dev/null
+++ b/faad2/src/include/neaacdec.h
@@ -0,0 +1,258 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: neaacdec.h,v 1.13 2009/01/26 23:51:15 menno Exp $
+**/
+
+#ifndef __NEAACDEC_H__
+#define __NEAACDEC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#if 1
+/* MACROS FOR BACKWARDS COMPATIBILITY */
+/* structs */
+#define faacDecHandle NeAACDecHandle
+#define faacDecConfiguration NeAACDecConfiguration
+#define faacDecConfigurationPtr NeAACDecConfigurationPtr
+#define faacDecFrameInfo NeAACDecFrameInfo
+/* functions */
+#define faacDecGetErrorMessage NeAACDecGetErrorMessage
+#define faacDecSetConfiguration NeAACDecSetConfiguration
+#define faacDecGetCurrentConfiguration NeAACDecGetCurrentConfiguration
+#define faacDecInit NeAACDecInit
+#define faacDecInit2 NeAACDecInit2
+#define faacDecInitDRM NeAACDecInitDRM
+#define faacDecPostSeekReset NeAACDecPostSeekReset
+#define faacDecOpen NeAACDecOpen
+#define faacDecClose NeAACDecClose
+#define faacDecDecode NeAACDecDecode
+#define AudioSpecificConfig NeAACDecAudioSpecificConfig
+#endif
+
+
+#ifdef _WIN32
+ #pragma pack(push, 8)
+ #ifndef NEAACDECAPI
+ #define NEAACDECAPI __cdecl
+ #endif
+#else
+ #ifndef NEAACDECAPI
+ #define NEAACDECAPI
+ #endif
+#endif
+
+#define FAAD2_VERSION "2.7"
+
+/* object types for AAC */
+#define MAIN 1
+#define LC 2
+#define SSR 3
+#define LTP 4
+#define HE_AAC 5
+#define ER_LC 17
+#define ER_LTP 19
+#define LD 23
+#define DRM_ER_LC 27 /* special object type for DRM */
+
+/* header types */
+#define RAW 0
+#define ADIF 1
+#define ADTS 2
+#define LATM 3
+
+/* SBR signalling */
+#define NO_SBR 0
+#define SBR_UPSAMPLED 1
+#define SBR_DOWNSAMPLED 2
+#define NO_SBR_UPSAMPLED 3
+
+/* library output formats */
+#define FAAD_FMT_16BIT 1
+#define FAAD_FMT_24BIT 2
+#define FAAD_FMT_32BIT 3
+#define FAAD_FMT_FLOAT 4
+#define FAAD_FMT_FIXED FAAD_FMT_FLOAT
+#define FAAD_FMT_DOUBLE 5
+
+/* Capabilities */
+#define LC_DEC_CAP (1<<0) /* Can decode LC */
+#define MAIN_DEC_CAP (1<<1) /* Can decode MAIN */
+#define LTP_DEC_CAP (1<<2) /* Can decode LTP */
+#define LD_DEC_CAP (1<<3) /* Can decode LD */
+#define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */
+#define FIXED_POINT_CAP (1<<5) /* Fixed point */
+
+/* Channel definitions */
+#define FRONT_CHANNEL_CENTER (1)
+#define FRONT_CHANNEL_LEFT (2)
+#define FRONT_CHANNEL_RIGHT (3)
+#define SIDE_CHANNEL_LEFT (4)
+#define SIDE_CHANNEL_RIGHT (5)
+#define BACK_CHANNEL_LEFT (6)
+#define BACK_CHANNEL_RIGHT (7)
+#define BACK_CHANNEL_CENTER (8)
+#define LFE_CHANNEL (9)
+#define UNKNOWN_CHANNEL (0)
+
+/* DRM channel definitions */
+#define DRMCH_MONO 1
+#define DRMCH_STEREO 2
+#define DRMCH_SBR_MONO 3
+#define DRMCH_SBR_STEREO 4
+#define DRMCH_SBR_PS_STEREO 5
+
+
+/* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
+ so at least so much bytes per channel should be available in this stream */
+#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */
+
+
+typedef void *NeAACDecHandle;
+
+typedef struct mp4AudioSpecificConfig
+{
+ /* Audio Specific Info */
+ unsigned char objectTypeIndex;
+ unsigned char samplingFrequencyIndex;
+ unsigned long samplingFrequency;
+ unsigned char channelsConfiguration;
+
+ /* GA Specific Info */
+ unsigned char frameLengthFlag;
+ unsigned char dependsOnCoreCoder;
+ unsigned short coreCoderDelay;
+ unsigned char extensionFlag;
+ unsigned char aacSectionDataResilienceFlag;
+ unsigned char aacScalefactorDataResilienceFlag;
+ unsigned char aacSpectralDataResilienceFlag;
+ unsigned char epConfig;
+
+ char sbr_present_flag;
+ char forceUpSampling;
+ char downSampledSBR;
+} mp4AudioSpecificConfig;
+
+typedef struct NeAACDecConfiguration
+{
+ unsigned char defObjectType;
+ unsigned long defSampleRate;
+ unsigned char outputFormat;
+ unsigned char downMatrix;
+ unsigned char useOldADTSFormat;
+ unsigned char dontUpSampleImplicitSBR;
+} NeAACDecConfiguration, *NeAACDecConfigurationPtr;
+
+typedef struct NeAACDecFrameInfo
+{
+ unsigned long bytesconsumed;
+ unsigned long samples;
+ unsigned char channels;
+ unsigned char error;
+ unsigned long samplerate;
+
+ /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
+ unsigned char sbr;
+
+ /* MPEG-4 ObjectType */
+ unsigned char object_type;
+
+ /* AAC header type; MP4 will be signalled as RAW also */
+ unsigned char header_type;
+
+ /* multichannel configuration */
+ unsigned char num_front_channels;
+ unsigned char num_side_channels;
+ unsigned char num_back_channels;
+ unsigned char num_lfe_channels;
+ unsigned char channel_position[64];
+
+ /* PS: 0: off, 1: on */
+ unsigned char ps;
+} NeAACDecFrameInfo;
+
+char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode);
+
+unsigned long NEAACDECAPI NeAACDecGetCapabilities(void);
+
+NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);
+
+NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder);
+
+unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
+ NeAACDecConfigurationPtr config);
+
+/* Init the library based on info from the AAC file (ADTS/ADIF) */
+long NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder,
+ unsigned char *buffer,
+ unsigned long buffer_size,
+ unsigned long *samplerate,
+ unsigned char *channels);
+
+/* Init the library using a DecoderSpecificInfo */
+char NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder,
+ unsigned char *pBuffer,
+ unsigned long SizeOfDecoderSpecificInfo,
+ unsigned long *samplerate,
+ unsigned char *channels);
+
+/* Init the library for DRM */
+char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate,
+ unsigned char channels);
+
+void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame);
+
+void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder);
+
+void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
+ NeAACDecFrameInfo *hInfo,
+ unsigned char *buffer,
+ unsigned long buffer_size);
+
+void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder,
+ NeAACDecFrameInfo *hInfo,
+ unsigned char *buffer,
+ unsigned long buffer_size,
+ void **sample_buffer,
+ unsigned long sample_buffer_size);
+
+char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer,
+ unsigned long buffer_size,
+ mp4AudioSpecificConfig *mp4ASC);
+
+#ifdef _WIN32
+ #pragma pack(pop)
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/faad2/src/libfaad/Makefile.am b/faad2/src/libfaad/Makefile.am
new file mode 100644
index 0000000..13ee5b5
--- /dev/null
+++ b/faad2/src/libfaad/Makefile.am
@@ -0,0 +1,30 @@
+lib_LTLIBRARIES = libfaad.la
+
+AM_CFLAGS = -iquote $(top_srcdir)/include
+include_HEADERS = $(top_srcdir)/include/faad.h \
+ $(top_srcdir)/include/neaacdec.h
+
+libfaad_la_LDFLAGS = -version-info 2:0:0
+libfaad_la_LIBADD = -lm
+
+libfaad_la_SOURCES = bits.c cfft.c decoder.c drc.c \
+ drm_dec.c error.c filtbank.c \
+ ic_predict.c is.c lt_predict.c mdct.c mp4.c ms.c output.c pns.c \
+ ps_dec.c ps_syntax.c \
+ pulse.c specrec.c syntax.c tns.c hcr.c huffman.c \
+ rvlc.c ssr.c ssr_fb.c ssr_ipqf.c common.c \
+ sbr_dct.c sbr_e_nf.c sbr_fbt.c sbr_hfadj.c sbr_hfgen.c \
+ sbr_huff.c sbr_qmf.c sbr_syntax.c sbr_tf_grid.c sbr_dec.c \
+ analysis.h bits.h cfft.h cfft_tab.h common.h \
+ decoder.h drc.h drm_dec.h error.h fixed.h filtbank.h \
+ huffman.h ic_predict.h iq_table.h is.h kbd_win.h lt_predict.h \
+ mdct.h mdct_tab.h mp4.h ms.h output.h pns.h ps_dec.h ps_tables.h \
+ pulse.h rvlc.h \
+ sbr_dct.h sbr_dec.h sbr_e_nf.h sbr_fbt.h sbr_hfadj.h sbr_hfgen.h \
+ sbr_huff.h sbr_noise.h sbr_qmf.h sbr_syntax.h sbr_tf_grid.h \
+ sine_win.h specrec.h ssr.h ssr_fb.h ssr_ipqf.h \
+ ssr_win.h syntax.h structs.h tns.h \
+ sbr_qmf_c.h codebook/hcb.h \
+ codebook/hcb_1.h codebook/hcb_2.h codebook/hcb_3.h codebook/hcb_4.h \
+ codebook/hcb_5.h codebook/hcb_6.h codebook/hcb_7.h codebook/hcb_8.h \
+ codebook/hcb_9.h codebook/hcb_10.h codebook/hcb_11.h codebook/hcb_sf.h
diff --git a/faad2/src/libfaad/analysis.h b/faad2/src/libfaad/analysis.h
new file mode 100644
index 0000000..c884c86
--- /dev/null
+++ b/faad2/src/libfaad/analysis.h
@@ -0,0 +1,52 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: analysis.h,v 1.18 2007/11/01 12:33:29 menno Exp $
+**/
+
+#ifndef __ANALYSIS_H__
+#define __ANALYSIS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef ANALYSIS
+#define DEBUGDEC ,uint8_t print,uint16_t var,uint8_t *dbg
+#define DEBUGVAR(A,B,C) ,A,B,C
+extern uint16_t dbg_count;
+#else
+#define DEBUGDEC
+#define DEBUGVAR(A,B,C)
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/faad2/src/libfaad/bits.c b/faad2/src/libfaad/bits.c
new file mode 100644
index 0000000..66c6a13
--- /dev/null
+++ b/faad2/src/libfaad/bits.c
@@ -0,0 +1,271 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: bits.c,v 1.44 2007/11/01 12:33:29 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#include <stdlib.h>
+#include "bits.h"
+
+/* initialize buffer, call once before first getbits or showbits */
+void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size)
+{
+ uint32_t tmp;
+
+ if (ld == NULL)
+ return;
+
+ // useless
+ //memset(ld, 0, sizeof(bitfile));
+
+ if (buffer_size == 0 || _buffer == NULL)
+ {
+ ld->error = 1;
+ return;
+ }
+
+ ld->buffer = _buffer;
+
+ ld->buffer_size = buffer_size;
+ ld->bytes_left = buffer_size;
+
+ if (ld->bytes_left >= 4)
+ {
+ tmp = getdword((uint32_t*)ld->buffer);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n((uint32_t*)ld->buffer, ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufa = tmp;
+
+ if (ld->bytes_left >= 4)
+ {
+ tmp = getdword((uint32_t*)ld->buffer + 1);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n((uint32_t*)ld->buffer + 1, ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufb = tmp;
+
+ ld->start = (uint32_t*)ld->buffer;
+ ld->tail = ((uint32_t*)ld->buffer + 2);
+
+ ld->bits_left = 32;
+
+ ld->error = 0;
+}
+
+void faad_endbits(bitfile *ld)
+{
+ // void
+}
+
+uint32_t faad_get_processed_bits(bitfile *ld)
+{
+ return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left));
+}
+
+uint8_t faad_byte_align(bitfile *ld)
+{
+ int remainder = (32 - ld->bits_left) & 0x7;
+
+ if (remainder)
+ {
+ faad_flushbits(ld, 8 - remainder);
+ return (uint8_t)(8 - remainder);
+ }
+ return 0;
+}
+
+void faad_flushbits_ex(bitfile *ld, uint32_t bits)
+{
+ uint32_t tmp;
+
+ ld->bufa = ld->bufb;
+ if (ld->bytes_left >= 4)
+ {
+ tmp = getdword(ld->tail);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n(ld->tail, ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufb = tmp;
+ ld->tail++;
+ ld->bits_left += (32 - bits);
+ //ld->bytes_left -= 4;
+// if (ld->bytes_left == 0)
+// ld->no_more_reading = 1;
+// if (ld->bytes_left < 0)
+// ld->error = 1;
+}
+
+/* rewind to beginning */
+void faad_rewindbits(bitfile *ld)
+{
+ uint32_t tmp;
+
+ ld->bytes_left = ld->buffer_size;
+
+ if (ld->bytes_left >= 4)
+ {
+ tmp = getdword((uint32_t*)&ld->start[0]);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n((uint32_t*)&ld->start[0], ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufa = tmp;
+
+ if (ld->bytes_left >= 4)
+ {
+ tmp = getdword((uint32_t*)&ld->start[1]);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n((uint32_t*)&ld->start[1], ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufb = tmp;
+
+ ld->bits_left = 32;
+ ld->tail = &ld->start[2];
+}
+
+/* reset to a certain point */
+void faad_resetbits(bitfile *ld, int bits)
+{
+ uint32_t tmp;
+ int words = bits >> 5;
+ int remainder = bits & 0x1F;
+
+ ld->bytes_left = ld->buffer_size - words*4;
+
+ if (ld->bytes_left >= 4)
+ {
+ tmp = getdword(&ld->start[words]);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n(&ld->start[words], ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufa = tmp;
+
+ if (ld->bytes_left >= 4)
+ {
+ tmp = getdword(&ld->start[words+1]);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n(&ld->start[words+1], ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufb = tmp;
+
+ ld->bits_left = 32 - remainder;
+ ld->tail = &ld->start[words+2];
+
+ /* recheck for reading too many bytes */
+ ld->error = 0;
+// if (ld->bytes_left == 0)
+// ld->no_more_reading = 1;
+// if (ld->bytes_left < 0)
+// ld->error = 1;
+}
+
+uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
+ DEBUGDEC)
+{
+ int i;
+ unsigned int temp;
+ int bytes = bits >> 3;
+ int remainder = bits & 0x7;
+
+ uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t));
+
+ for (i = 0; i < bytes; i++)
+ {
+ buffer[i] = (uint8_t)faad_getbits(ld, 8 DEBUGVAR(print,var,dbg));
+ }
+
+ if (remainder)
+ {
+ temp = faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder);
+
+ buffer[bytes] = (uint8_t)temp;
+ }
+
+ return buffer;
+}
+
+#ifdef DRM
+/* return the original data buffer */
+void *faad_origbitbuffer(bitfile *ld)
+{
+ return (void*)ld->start;
+}
+
+/* return the original data buffer size */
+uint32_t faad_origbitbuffer_size(bitfile *ld)
+{
+ return ld->buffer_size;
+}
+#endif
+
+/* reversed bit reading routines, used for RVLC and HCR */
+void faad_initbits_rev(bitfile *ld, void *buffer,
+ uint32_t bits_in_buffer)
+{
+ uint32_t tmp;
+ int32_t index;
+
+ ld->buffer_size = bit2byte(bits_in_buffer);
+
+ index = (bits_in_buffer+31)/32 - 1;
+
+ ld->start = (uint32_t*)buffer + index - 2;
+
+ tmp = getdword((uint32_t*)buffer + index);
+ ld->bufa = tmp;
+
+ tmp = getdword((uint32_t*)buffer + index - 1);
+ ld->bufb = tmp;
+
+ ld->tail = (uint32_t*)buffer + index;
+
+ ld->bits_left = bits_in_buffer % 32;
+ if (ld->bits_left == 0)
+ ld->bits_left = 32;
+
+ ld->bytes_left = ld->buffer_size;
+ ld->error = 0;
+}
+
+/* EOF */
diff --git a/faad2/src/libfaad/bits.h b/faad2/src/libfaad/bits.h
new file mode 100644
index 0000000..3a6b0bb
--- /dev/null
+++ b/faad2/src/libfaad/bits.h
@@ -0,0 +1,452 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: bits.h,v 1.45 2007/11/01 12:33:29 menno Exp $
+**/
+
+#ifndef __BITS_H__
+#define __BITS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "analysis.h"
+#ifdef ANALYSIS
+#include <stdio.h>
+#endif
+
+#define BYTE_NUMBIT 8
+#define BYTE_NUMBIT_LD 3
+//#define bit2byte(a) ((a+7)/BYTE_NUMBIT)
+#define bit2byte(a) ((a+7)>>BYTE_NUMBIT_LD)
+
+typedef struct _bitfile
+{
+ /* bit input */
+ uint32_t bufa;
+ uint32_t bufb;
+ uint32_t bits_left;
+ uint32_t buffer_size; /* size of the buffer in bytes */
+ uint32_t bytes_left;
+ uint8_t error;
+ uint32_t *tail;
+ uint32_t *start;
+ const void *buffer;
+} bitfile;
+
+
+#if 0
+static uint32_t const bitmask[] = {
+ 0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF,
+ 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF,
+ 0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF,
+ 0x7FFFFF, 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF,
+ 0xFFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF
+ /* added bitmask 32, correct?!?!?! */
+ , 0xFFFFFFFF
+};
+#endif
+
+void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size);
+void faad_endbits(bitfile *ld);
+void faad_initbits_rev(bitfile *ld, void *buffer,
+ uint32_t bits_in_buffer);
+uint8_t faad_byte_align(bitfile *ld);
+uint32_t faad_get_processed_bits(bitfile *ld);
+void faad_flushbits_ex(bitfile *ld, uint32_t bits);
+void faad_rewindbits(bitfile *ld);
+void faad_resetbits(bitfile *ld, int bits);
+uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
+ DEBUGDEC);
+#ifdef DRM
+void *faad_origbitbuffer(bitfile *ld);
+uint32_t faad_origbitbuffer_size(bitfile *ld);
+#endif
+
+/* circumvent memory alignment errors on ARM */
+static INLINE uint32_t getdword(void *mem)
+{
+ uint32_t tmp;
+#ifndef ARCH_IS_BIG_ENDIAN
+ ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[3];
+ ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[2];
+ ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[1];
+ ((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[0];
+#else
+ ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[0];
+ ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[1];
+ ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[2];
+ ((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[3];
+#endif
+
+ return tmp;
+}
+
+/* reads only n bytes from the stream instead of the standard 4 */
+static /*INLINE*/ uint32_t getdword_n(void *mem, int n)
+{
+ uint32_t tmp = 0;
+#ifndef ARCH_IS_BIG_ENDIAN
+ switch (n)
+ {
+ case 3:
+ ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[2];
+ case 2:
+ ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[1];
+ case 1:
+ ((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[0];
+ default:
+ break;
+ }
+#else
+ switch (n)
+ {
+ case 3:
+ ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[2];
+ case 2:
+ ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[1];
+ case 1:
+ ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[0];
+ default:
+ break;
+ }
+#endif
+
+ return tmp;
+}
+
+static INLINE uint32_t faad_showbits(bitfile *ld, uint32_t bits)
+{
+ if (bits <= ld->bits_left)
+ {
+ //return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
+ return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits);
+ }
+
+ bits -= ld->bits_left;
+ //return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
+ return ((ld->bufa & ((1<<ld->bits_left)-1)) << bits) | (ld->bufb >> (32 - bits));
+}
+
+static INLINE void faad_flushbits(bitfile *ld, uint32_t bits)
+{
+ /* do nothing if error */
+ if (ld->error != 0)
+ return;
+
+ if (bits < ld->bits_left)
+ {
+ ld->bits_left -= bits;
+ } else {
+ faad_flushbits_ex(ld, bits);
+ }
+}
+
+/* return next n bits (right adjusted) */
+static /*INLINE*/ uint32_t faad_getbits(bitfile *ld, uint32_t n DEBUGDEC)
+{
+ uint32_t ret;
+
+ if (n == 0)
+ return 0;
+
+ ret = faad_showbits(ld, n);
+ faad_flushbits(ld, n);
+
+#ifdef ANALYSIS
+ if (print)
+ fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg);
+#endif
+
+ return ret;
+}
+
+static INLINE uint8_t faad_get1bit(bitfile *ld DEBUGDEC)
+{
+ uint8_t r;
+
+ if (ld->bits_left > 0)
+ {
+ ld->bits_left--;
+ r = (uint8_t)((ld->bufa >> ld->bits_left) & 1);
+ return r;
+ }
+
+ /* bits_left == 0 */
+#if 0
+ r = (uint8_t)(ld->bufb >> 31);
+ faad_flushbits_ex(ld, 1);
+#else
+ r = (uint8_t)faad_getbits(ld, 1);
+#endif
+ return r;
+}
+
+/* reversed bitreading routines */
+static INLINE uint32_t faad_showbits_rev(bitfile *ld, uint32_t bits)
+{
+ uint8_t i;
+ uint32_t B = 0;
+
+ if (bits <= ld->bits_left)
+ {
+ for (i = 0; i < bits; i++)
+ {
+ if (ld->bufa & (1 << (i + (32 - ld->bits_left))))
+ B |= (1 << (bits - i - 1));
+ }
+ return B;
+ } else {
+ for (i = 0; i < ld->bits_left; i++)
+ {
+ if (ld->bufa & (1 << (i + (32 - ld->bits_left))))
+ B |= (1 << (bits - i - 1));
+ }
+ for (i = 0; i < bits - ld->bits_left; i++)
+ {
+ if (ld->bufb & (1 << (i + (32-ld->bits_left))))
+ B |= (1 << (bits - ld->bits_left - i - 1));
+ }
+ return B;
+ }
+}
+
+static INLINE void faad_flushbits_rev(bitfile *ld, uint32_t bits)
+{
+ /* do nothing if error */
+ if (ld->error != 0)
+ return;
+
+ if (bits < ld->bits_left)
+ {
+ ld->bits_left -= bits;
+ } else {
+ uint32_t tmp;
+
+ ld->bufa = ld->bufb;
+ tmp = getdword(ld->start);
+ ld->bufb = tmp;
+ ld->start--;
+ ld->bits_left += (32 - bits);
+
+ if (ld->bytes_left < 4)
+ {
+ ld->error = 1;
+ ld->bytes_left = 0;
+ } else {
+ ld->bytes_left -= 4;
+ }
+// if (ld->bytes_left == 0)
+// ld->no_more_reading = 1;
+ }
+}
+
+static /*INLINE*/ uint32_t faad_getbits_rev(bitfile *ld, uint32_t n
+ DEBUGDEC)
+{
+ uint32_t ret;
+
+ if (n == 0)
+ return 0;
+
+ ret = faad_showbits_rev(ld, n);
+ faad_flushbits_rev(ld, n);
+
+#ifdef ANALYSIS
+ if (print)
+ fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg);
+#endif
+
+ return ret;
+}
+
+#ifdef DRM
+/* CRC lookup table for G8 polynome in DRM standard */
+static const uint8_t crc_table_G8[256] = {
+ 0x0, 0x1d, 0x3a, 0x27, 0x74, 0x69, 0x4e, 0x53,
+ 0xe8, 0xf5, 0xd2, 0xcf, 0x9c, 0x81, 0xa6, 0xbb,
+ 0xcd, 0xd0, 0xf7, 0xea, 0xb9, 0xa4, 0x83, 0x9e,
+ 0x25, 0x38, 0x1f, 0x2, 0x51, 0x4c, 0x6b, 0x76,
+ 0x87, 0x9a, 0xbd, 0xa0, 0xf3, 0xee, 0xc9, 0xd4,
+ 0x6f, 0x72, 0x55, 0x48, 0x1b, 0x6, 0x21, 0x3c,
+ 0x4a, 0x57, 0x70, 0x6d, 0x3e, 0x23, 0x4, 0x19,
+ 0xa2, 0xbf, 0x98, 0x85, 0xd6, 0xcb, 0xec, 0xf1,
+ 0x13, 0xe, 0x29, 0x34, 0x67, 0x7a, 0x5d, 0x40,
+ 0xfb, 0xe6, 0xc1, 0xdc, 0x8f, 0x92, 0xb5, 0xa8,
+ 0xde, 0xc3, 0xe4, 0xf9, 0xaa, 0xb7, 0x90, 0x8d,
+ 0x36, 0x2b, 0xc, 0x11, 0x42, 0x5f, 0x78, 0x65,
+ 0x94, 0x89, 0xae, 0xb3, 0xe0, 0xfd, 0xda, 0xc7,
+ 0x7c, 0x61, 0x46, 0x5b, 0x8, 0x15, 0x32, 0x2f,
+ 0x59, 0x44, 0x63, 0x7e, 0x2d, 0x30, 0x17, 0xa,
+ 0xb1, 0xac, 0x8b, 0x96, 0xc5, 0xd8, 0xff, 0xe2,
+ 0x26, 0x3b, 0x1c, 0x1, 0x52, 0x4f, 0x68, 0x75,
+ 0xce, 0xd3, 0xf4, 0xe9, 0xba, 0xa7, 0x80, 0x9d,
+ 0xeb, 0xf6, 0xd1, 0xcc, 0x9f, 0x82, 0xa5, 0xb8,
+ 0x3, 0x1e, 0x39, 0x24, 0x77, 0x6a, 0x4d, 0x50,
+ 0xa1, 0xbc, 0x9b, 0x86, 0xd5, 0xc8, 0xef, 0xf2,
+ 0x49, 0x54, 0x73, 0x6e, 0x3d, 0x20, 0x7, 0x1a,
+ 0x6c, 0x71, 0x56, 0x4b, 0x18, 0x5, 0x22, 0x3f,
+ 0x84, 0x99, 0xbe, 0xa3, 0xf0, 0xed, 0xca, 0xd7,
+ 0x35, 0x28, 0xf, 0x12, 0x41, 0x5c, 0x7b, 0x66,
+ 0xdd, 0xc0, 0xe7, 0xfa, 0xa9, 0xb4, 0x93, 0x8e,
+ 0xf8, 0xe5, 0xc2, 0xdf, 0x8c, 0x91, 0xb6, 0xab,
+ 0x10, 0xd, 0x2a, 0x37, 0x64, 0x79, 0x5e, 0x43,
+ 0xb2, 0xaf, 0x88, 0x95, 0xc6, 0xdb, 0xfc, 0xe1,
+ 0x5a, 0x47, 0x60, 0x7d, 0x2e, 0x33, 0x14, 0x9,
+ 0x7f, 0x62, 0x45, 0x58, 0xb, 0x16, 0x31, 0x2c,
+ 0x97, 0x8a, 0xad, 0xb0, 0xe3, 0xfe, 0xd9, 0xc4,
+};
+
+static uint8_t faad_check_CRC(bitfile *ld, uint16_t len)
+{
+ int bytes, rem;
+ unsigned int CRC;
+ unsigned int r=255; /* Initialize to all ones */
+
+ /* CRC polynome used x^8 + x^4 + x^3 + x^2 +1 */
+#define GPOLY 0435
+
+ faad_rewindbits(ld);
+
+ CRC = (unsigned int) ~faad_getbits(ld, 8
+ DEBUGVAR(1,999,"faad_check_CRC(): CRC")) & 0xFF; /* CRC is stored inverted */
+
+ bytes = len >> 3;
+ rem = len & 0x7;
+
+ for (; bytes > 0; bytes--)
+ {
+ r = crc_table_G8[( r ^ faad_getbits(ld, 8 DEBUGVAR(1,998,"")) ) & 0xFF];
+ }
+ for (; rem > 0; rem--)
+ {
+ r = ( (r << 1) ^ (( ( faad_get1bit(ld
+ DEBUGVAR(1,998,"")) & 1) ^ ((r >> 7) & 1)) * GPOLY )) & 0xFF;
+ }
+
+ if (r != CRC)
+ // if (0)
+ {
+ return 28;
+ } else {
+ return 0;
+ }
+}
+
+static uint8_t tabFlipbits[256] = {
+ 0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,
+ 8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,
+ 4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,
+ 12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,
+ 2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,
+ 10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,
+ 6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,
+ 14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,
+ 1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,
+ 9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,
+ 5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,
+ 13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,
+ 3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,
+ 11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,
+ 7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,
+ 15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255
+};
+#endif
+
+#ifdef ERROR_RESILIENCE
+
+/* Modified bit reading functions for HCR */
+
+typedef struct
+{
+ /* bit input */
+ uint32_t bufa;
+ uint32_t bufb;
+ int8_t len;
+} bits_t;
+
+
+static INLINE uint32_t showbits_hcr(bits_t *ld, uint8_t bits)
+{
+ if (bits == 0) return 0;
+ if (ld->len <= 32)
+ {
+ /* huffman_spectral_data_2 needs to read more than may be available, bits maybe
+ > ld->len, deliver 0 than */
+ if (ld->len >= bits)
+ return ((ld->bufa >> (ld->len - bits)) & (0xFFFFFFFF >> (32 - bits)));
+ else
+ return ((ld->bufa << (bits - ld->len)) & (0xFFFFFFFF >> (32 - bits)));
+ } else {
+ if ((ld->len - bits) < 32)
+ {
+ return ( (ld->bufb & (0xFFFFFFFF >> (64 - ld->len))) << (bits - ld->len + 32)) |
+ (ld->bufa >> (ld->len - bits));
+ } else {
+ return ((ld->bufb >> (ld->len - bits - 32)) & (0xFFFFFFFF >> (32 - bits)));
+ }
+ }
+}
+
+/* return 1 if position is outside of buffer, 0 otherwise */
+static INLINE int8_t flushbits_hcr( bits_t *ld, uint8_t bits)
+{
+ ld->len -= bits;
+
+ if (ld->len <0)
+ {
+ ld->len = 0;
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+static INLINE int8_t getbits_hcr(bits_t *ld, uint8_t n, uint32_t *result)
+{
+ *result = showbits_hcr(ld, n);
+ return flushbits_hcr(ld, n);
+}
+
+static INLINE int8_t get1bit_hcr(bits_t *ld, uint8_t *result)
+{
+ uint32_t res;
+ int8_t ret;
+
+ ret = getbits_hcr(ld, 1, &res);
+ *result = (int8_t)(res & 1);
+ return ret;
+}
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/faad2/src/libfaad/cfft.c b/faad2/src/libfaad/cfft.c
new file mode 100644
index 0000000..4235c11
--- /dev/null
+++ b/faad2/src/libfaad/cfft.c
@@ -0,0 +1,1005 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: cfft.c,v 1.35 2007/11/01 12:33:29 menno Exp $
+**/
+
+/*
+ * Algorithmically based on Fortran-77 FFTPACK
+ * by Paul N. Swarztrauber(Version 4, 1985).
+ *
+ * Does even sized fft only
+ */
+
+/* isign is +1 for backward and -1 for forward transforms */
+
+#include "common.h"
+#include "structs.h"
+
+#include <stdlib.h>
+
+#include "cfft.h"
+#include "cfft_tab.h"
+
+
+/* static function declarations */
+static void passf2pos(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa);
+static void passf2neg(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa);
+static void passf3(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa1, const complex_t *wa2, const int8_t isign);
+static void passf4pos(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
+ const complex_t *wa1, const complex_t *wa2, const complex_t *wa3);
+static void passf4neg(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
+ const complex_t *wa1, const complex_t *wa2, const complex_t *wa3);
+static void passf5(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
+ const complex_t *wa1, const complex_t *wa2, const complex_t *wa3,
+ const complex_t *wa4, const int8_t isign);
+INLINE void cfftf1(uint16_t n, complex_t *c, complex_t *ch,
+ const uint16_t *ifac, const complex_t *wa, const int8_t isign);
+static void cffti1(uint16_t n, complex_t *wa, uint16_t *ifac);
+
+
+/*----------------------------------------------------------------------
+ passf2, passf3, passf4, passf5. Complex FFT passes fwd and bwd.
+ ----------------------------------------------------------------------*/
+
+static void passf2pos(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa)
+{
+ uint16_t i, k, ah, ac;
+
+ if (ido == 1)
+ {
+ for (k = 0; k < l1; k++)
+ {
+ ah = 2*k;
+ ac = 4*k;
+
+ RE(ch[ah]) = RE(cc[ac]) + RE(cc[ac+1]);
+ RE(ch[ah+l1]) = RE(cc[ac]) - RE(cc[ac+1]);
+ IM(ch[ah]) = IM(cc[ac]) + IM(cc[ac+1]);
+ IM(ch[ah+l1]) = IM(cc[ac]) - IM(cc[ac+1]);
+ }
+ } else {
+ for (k = 0; k < l1; k++)
+ {
+ ah = k*ido;
+ ac = 2*k*ido;
+
+ for (i = 0; i < ido; i++)
+ {
+ complex_t t2;
+
+ RE(ch[ah+i]) = RE(cc[ac+i]) + RE(cc[ac+i+ido]);
+ RE(t2) = RE(cc[ac+i]) - RE(cc[ac+i+ido]);
+
+ IM(ch[ah+i]) = IM(cc[ac+i]) + IM(cc[ac+i+ido]);
+ IM(t2) = IM(cc[ac+i]) - IM(cc[ac+i+ido]);
+
+#if 1
+ ComplexMult(&IM(ch[ah+i+l1*ido]), &RE(ch[ah+i+l1*ido]),
+ IM(t2), RE(t2), RE(wa[i]), IM(wa[i]));
+#else
+ ComplexMult(&RE(ch[ah+i+l1*ido]), &IM(ch[ah+i+l1*ido]),
+ RE(t2), IM(t2), RE(wa[i]), IM(wa[i]));
+#endif
+ }
+ }
+ }
+}
+
+static void passf2neg(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa)
+{
+ uint16_t i, k, ah, ac;
+
+ if (ido == 1)
+ {
+ for (k = 0; k < l1; k++)
+ {
+ ah = 2*k;
+ ac = 4*k;
+
+ RE(ch[ah]) = RE(cc[ac]) + RE(cc[ac+1]);
+ RE(ch[ah+l1]) = RE(cc[ac]) - RE(cc[ac+1]);
+ IM(ch[ah]) = IM(cc[ac]) + IM(cc[ac+1]);
+ IM(ch[ah+l1]) = IM(cc[ac]) - IM(cc[ac+1]);
+ }
+ } else {
+ for (k = 0; k < l1; k++)
+ {
+ ah = k*ido;
+ ac = 2*k*ido;
+
+ for (i = 0; i < ido; i++)
+ {
+ complex_t t2;
+
+ RE(ch[ah+i]) = RE(cc[ac+i]) + RE(cc[ac+i+ido]);
+ RE(t2) = RE(cc[ac+i]) - RE(cc[ac+i+ido]);
+
+ IM(ch[ah+i]) = IM(cc[ac+i]) + IM(cc[ac+i+ido]);
+ IM(t2) = IM(cc[ac+i]) - IM(cc[ac+i+ido]);
+
+#if 1
+ ComplexMult(&RE(ch[ah+i+l1*ido]), &IM(ch[ah+i+l1*ido]),
+ RE(t2), IM(t2), RE(wa[i]), IM(wa[i]));
+#else
+ ComplexMult(&IM(ch[ah+i+l1*ido]), &RE(ch[ah+i+l1*ido]),
+ IM(t2), RE(t2), RE(wa[i]), IM(wa[i]));
+#endif
+ }
+ }
+ }
+}
+
+
+static void passf3(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa1, const complex_t *wa2,
+ const int8_t isign)
+{
+ static real_t taur = FRAC_CONST(-0.5);
+ static real_t taui = FRAC_CONST(0.866025403784439);
+ uint16_t i, k, ac, ah;
+ complex_t c2, c3, d2, d3, t2;
+
+ if (ido == 1)
+ {
+ if (isign == 1)
+ {
+ for (k = 0; k < l1; k++)
+ {
+ ac = 3*k+1;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac+1]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+1]);
+ RE(c2) = RE(cc[ac-1]) + MUL_F(RE(t2),taur);
+ IM(c2) = IM(cc[ac-1]) + MUL_F(IM(t2),taur);
+
+ RE(ch[ah]) = RE(cc[ac-1]) + RE(t2);
+ IM(ch[ah]) = IM(cc[ac-1]) + IM(t2);
+
+ RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac+1])), taui);
+ IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac+1])), taui);
+
+ RE(ch[ah+l1]) = RE(c2) - IM(c3);
+ IM(ch[ah+l1]) = IM(c2) + RE(c3);
+ RE(ch[ah+2*l1]) = RE(c2) + IM(c3);
+ IM(ch[ah+2*l1]) = IM(c2) - RE(c3);
+ }
+ } else {
+ for (k = 0; k < l1; k++)
+ {
+ ac = 3*k+1;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac+1]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+1]);
+ RE(c2) = RE(cc[ac-1]) + MUL_F(RE(t2),taur);
+ IM(c2) = IM(cc[ac-1]) + MUL_F(IM(t2),taur);
+
+ RE(ch[ah]) = RE(cc[ac-1]) + RE(t2);
+ IM(ch[ah]) = IM(cc[ac-1]) + IM(t2);
+
+ RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac+1])), taui);
+ IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac+1])), taui);
+
+ RE(ch[ah+l1]) = RE(c2) + IM(c3);
+ IM(ch[ah+l1]) = IM(c2) - RE(c3);
+ RE(ch[ah+2*l1]) = RE(c2) - IM(c3);
+ IM(ch[ah+2*l1]) = IM(c2) + RE(c3);
+ }
+ }
+ } else {
+ if (isign == 1)
+ {
+ for (k = 0; k < l1; k++)
+ {
+ for (i = 0; i < ido; i++)
+ {
+ ac = i + (3*k+1)*ido;
+ ah = i + k * ido;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac+ido]);
+ RE(c2) = RE(cc[ac-ido]) + MUL_F(RE(t2),taur);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+ido]);
+ IM(c2) = IM(cc[ac-ido]) + MUL_F(IM(t2),taur);
+
+ RE(ch[ah]) = RE(cc[ac-ido]) + RE(t2);
+ IM(ch[ah]) = IM(cc[ac-ido]) + IM(t2);
+
+ RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac+ido])), taui);
+ IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac+ido])), taui);
+
+ RE(d2) = RE(c2) - IM(c3);
+ IM(d3) = IM(c2) - RE(c3);
+ RE(d3) = RE(c2) + IM(c3);
+ IM(d2) = IM(c2) + RE(c3);
+
+#if 1
+ ComplexMult(&IM(ch[ah+l1*ido]), &RE(ch[ah+l1*ido]),
+ IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah+2*l1*ido]), &RE(ch[ah+2*l1*ido]),
+ IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+#else
+ ComplexMult(&RE(ch[ah+l1*ido]), &IM(ch[ah+l1*ido]),
+ RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah+2*l1*ido]), &IM(ch[ah+2*l1*ido]),
+ RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+#endif
+ }
+ }
+ } else {
+ for (k = 0; k < l1; k++)
+ {
+ for (i = 0; i < ido; i++)
+ {
+ ac = i + (3*k+1)*ido;
+ ah = i + k * ido;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac+ido]);
+ RE(c2) = RE(cc[ac-ido]) + MUL_F(RE(t2),taur);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+ido]);
+ IM(c2) = IM(cc[ac-ido]) + MUL_F(IM(t2),taur);
+
+ RE(ch[ah]) = RE(cc[ac-ido]) + RE(t2);
+ IM(ch[ah]) = IM(cc[ac-ido]) + IM(t2);
+
+ RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac+ido])), taui);
+ IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac+ido])), taui);
+
+ RE(d2) = RE(c2) + IM(c3);
+ IM(d3) = IM(c2) + RE(c3);
+ RE(d3) = RE(c2) - IM(c3);
+ IM(d2) = IM(c2) - RE(c3);
+
+#if 1
+ ComplexMult(&RE(ch[ah+l1*ido]), &IM(ch[ah+l1*ido]),
+ RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah+2*l1*ido]), &IM(ch[ah+2*l1*ido]),
+ RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+#else
+ ComplexMult(&IM(ch[ah+l1*ido]), &RE(ch[ah+l1*ido]),
+ IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah+2*l1*ido]), &RE(ch[ah+2*l1*ido]),
+ IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+#endif
+ }
+ }
+ }
+ }
+}
+
+
+static void passf4pos(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa1, const complex_t *wa2,
+ const complex_t *wa3)
+{
+ uint16_t i, k, ac, ah;
+
+ if (ido == 1)
+ {
+ for (k = 0; k < l1; k++)
+ {
+ complex_t t1, t2, t3, t4;
+
+ ac = 4*k;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac+2]);
+ RE(t1) = RE(cc[ac]) - RE(cc[ac+2]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+2]);
+ IM(t1) = IM(cc[ac]) - IM(cc[ac+2]);
+ RE(t3) = RE(cc[ac+1]) + RE(cc[ac+3]);
+ IM(t4) = RE(cc[ac+1]) - RE(cc[ac+3]);
+ IM(t3) = IM(cc[ac+3]) + IM(cc[ac+1]);
+ RE(t4) = IM(cc[ac+3]) - IM(cc[ac+1]);
+
+ RE(ch[ah]) = RE(t2) + RE(t3);
+ RE(ch[ah+2*l1]) = RE(t2) - RE(t3);
+
+ IM(ch[ah]) = IM(t2) + IM(t3);
+ IM(ch[ah+2*l1]) = IM(t2) - IM(t3);
+
+ RE(ch[ah+l1]) = RE(t1) + RE(t4);
+ RE(ch[ah+3*l1]) = RE(t1) - RE(t4);
+
+ IM(ch[ah+l1]) = IM(t1) + IM(t4);
+ IM(ch[ah+3*l1]) = IM(t1) - IM(t4);
+ }
+ } else {
+ for (k = 0; k < l1; k++)
+ {
+ ac = 4*k*ido;
+ ah = k*ido;
+
+ for (i = 0; i < ido; i++)
+ {
+ complex_t c2, c3, c4, t1, t2, t3, t4;
+
+ RE(t2) = RE(cc[ac+i]) + RE(cc[ac+i+2*ido]);
+ RE(t1) = RE(cc[ac+i]) - RE(cc[ac+i+2*ido]);
+ IM(t2) = IM(cc[ac+i]) + IM(cc[ac+i+2*ido]);
+ IM(t1) = IM(cc[ac+i]) - IM(cc[ac+i+2*ido]);
+ RE(t3) = RE(cc[ac+i+ido]) + RE(cc[ac+i+3*ido]);
+ IM(t4) = RE(cc[ac+i+ido]) - RE(cc[ac+i+3*ido]);
+ IM(t3) = IM(cc[ac+i+3*ido]) + IM(cc[ac+i+ido]);
+ RE(t4) = IM(cc[ac+i+3*ido]) - IM(cc[ac+i+ido]);
+
+ RE(c2) = RE(t1) + RE(t4);
+ RE(c4) = RE(t1) - RE(t4);
+
+ IM(c2) = IM(t1) + IM(t4);
+ IM(c4) = IM(t1) - IM(t4);
+
+ RE(ch[ah+i]) = RE(t2) + RE(t3);
+ RE(c3) = RE(t2) - RE(t3);
+
+ IM(ch[ah+i]) = IM(t2) + IM(t3);
+ IM(c3) = IM(t2) - IM(t3);
+
+#if 1
+ ComplexMult(&IM(ch[ah+i+l1*ido]), &RE(ch[ah+i+l1*ido]),
+ IM(c2), RE(c2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah+i+2*l1*ido]), &RE(ch[ah+i+2*l1*ido]),
+ IM(c3), RE(c3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&IM(ch[ah+i+3*l1*ido]), &RE(ch[ah+i+3*l1*ido]),
+ IM(c4), RE(c4), RE(wa3[i]), IM(wa3[i]));
+#else
+ ComplexMult(&RE(ch[ah+i+l1*ido]), &IM(ch[ah+i+l1*ido]),
+ RE(c2), IM(c2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah+i+2*l1*ido]), &IM(ch[ah+i+2*l1*ido]),
+ RE(c3), IM(c3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&RE(ch[ah+i+3*l1*ido]), &IM(ch[ah+i+3*l1*ido]),
+ RE(c4), IM(c4), RE(wa3[i]), IM(wa3[i]));
+#endif
+ }
+ }
+ }
+}
+
+static void passf4neg(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa1, const complex_t *wa2,
+ const complex_t *wa3)
+{
+ uint16_t i, k, ac, ah;
+
+ if (ido == 1)
+ {
+ for (k = 0; k < l1; k++)
+ {
+ complex_t t1, t2, t3, t4;
+
+ ac = 4*k;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac+2]);
+ RE(t1) = RE(cc[ac]) - RE(cc[ac+2]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+2]);
+ IM(t1) = IM(cc[ac]) - IM(cc[ac+2]);
+ RE(t3) = RE(cc[ac+1]) + RE(cc[ac+3]);
+ IM(t4) = RE(cc[ac+1]) - RE(cc[ac+3]);
+ IM(t3) = IM(cc[ac+3]) + IM(cc[ac+1]);
+ RE(t4) = IM(cc[ac+3]) - IM(cc[ac+1]);
+
+ RE(ch[ah]) = RE(t2) + RE(t3);
+ RE(ch[ah+2*l1]) = RE(t2) - RE(t3);
+
+ IM(ch[ah]) = IM(t2) + IM(t3);
+ IM(ch[ah+2*l1]) = IM(t2) - IM(t3);
+
+ RE(ch[ah+l1]) = RE(t1) - RE(t4);
+ RE(ch[ah+3*l1]) = RE(t1) + RE(t4);
+
+ IM(ch[ah+l1]) = IM(t1) - IM(t4);
+ IM(ch[ah+3*l1]) = IM(t1) + IM(t4);
+ }
+ } else {
+ for (k = 0; k < l1; k++)
+ {
+ ac = 4*k*ido;
+ ah = k*ido;
+
+ for (i = 0; i < ido; i++)
+ {
+ complex_t c2, c3, c4, t1, t2, t3, t4;
+
+ RE(t2) = RE(cc[ac+i]) + RE(cc[ac+i+2*ido]);
+ RE(t1) = RE(cc[ac+i]) - RE(cc[ac+i+2*ido]);
+ IM(t2) = IM(cc[ac+i]) + IM(cc[ac+i+2*ido]);
+ IM(t1) = IM(cc[ac+i]) - IM(cc[ac+i+2*ido]);
+ RE(t3) = RE(cc[ac+i+ido]) + RE(cc[ac+i+3*ido]);
+ IM(t4) = RE(cc[ac+i+ido]) - RE(cc[ac+i+3*ido]);
+ IM(t3) = IM(cc[ac+i+3*ido]) + IM(cc[ac+i+ido]);
+ RE(t4) = IM(cc[ac+i+3*ido]) - IM(cc[ac+i+ido]);
+
+ RE(c2) = RE(t1) - RE(t4);
+ RE(c4) = RE(t1) + RE(t4);
+
+ IM(c2) = IM(t1) - IM(t4);
+ IM(c4) = IM(t1) + IM(t4);
+
+ RE(ch[ah+i]) = RE(t2) + RE(t3);
+ RE(c3) = RE(t2) - RE(t3);
+
+ IM(ch[ah+i]) = IM(t2) + IM(t3);
+ IM(c3) = IM(t2) - IM(t3);
+
+#if 1
+ ComplexMult(&RE(ch[ah+i+l1*ido]), &IM(ch[ah+i+l1*ido]),
+ RE(c2), IM(c2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah+i+2*l1*ido]), &IM(ch[ah+i+2*l1*ido]),
+ RE(c3), IM(c3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&RE(ch[ah+i+3*l1*ido]), &IM(ch[ah+i+3*l1*ido]),
+ RE(c4), IM(c4), RE(wa3[i]), IM(wa3[i]));
+#else
+ ComplexMult(&IM(ch[ah+i+l1*ido]), &RE(ch[ah+i+l1*ido]),
+ IM(c2), RE(c2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah+i+2*l1*ido]), &RE(ch[ah+i+2*l1*ido]),
+ IM(c3), RE(c3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&IM(ch[ah+i+3*l1*ido]), &RE(ch[ah+i+3*l1*ido]),
+ IM(c4), RE(c4), RE(wa3[i]), IM(wa3[i]));
+#endif
+ }
+ }
+ }
+}
+
+static void passf5(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa1, const complex_t *wa2, const complex_t *wa3,
+ const complex_t *wa4, const int8_t isign)
+{
+ static real_t tr11 = FRAC_CONST(0.309016994374947);
+ static real_t ti11 = FRAC_CONST(0.951056516295154);
+ static real_t tr12 = FRAC_CONST(-0.809016994374947);
+ static real_t ti12 = FRAC_CONST(0.587785252292473);
+ uint16_t i, k, ac, ah;
+ complex_t c2, c3, c4, c5, d3, d4, d5, d2, t2, t3, t4, t5;
+
+ if (ido == 1)
+ {
+ if (isign == 1)
+ {
+ for (k = 0; k < l1; k++)
+ {
+ ac = 5*k + 1;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac+3]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+3]);
+ RE(t3) = RE(cc[ac+1]) + RE(cc[ac+2]);
+ IM(t3) = IM(cc[ac+1]) + IM(cc[ac+2]);
+ RE(t4) = RE(cc[ac+1]) - RE(cc[ac+2]);
+ IM(t4) = IM(cc[ac+1]) - IM(cc[ac+2]);
+ RE(t5) = RE(cc[ac]) - RE(cc[ac+3]);
+ IM(t5) = IM(cc[ac]) - IM(cc[ac+3]);
+
+ RE(ch[ah]) = RE(cc[ac-1]) + RE(t2) + RE(t3);
+ IM(ch[ah]) = IM(cc[ac-1]) + IM(t2) + IM(t3);
+
+ RE(c2) = RE(cc[ac-1]) + MUL_F(RE(t2),tr11) + MUL_F(RE(t3),tr12);
+ IM(c2) = IM(cc[ac-1]) + MUL_F(IM(t2),tr11) + MUL_F(IM(t3),tr12);
+ RE(c3) = RE(cc[ac-1]) + MUL_F(RE(t2),tr12) + MUL_F(RE(t3),tr11);
+ IM(c3) = IM(cc[ac-1]) + MUL_F(IM(t2),tr12) + MUL_F(IM(t3),tr11);
+
+ ComplexMult(&RE(c5), &RE(c4),
+ ti11, ti12, RE(t5), RE(t4));
+ ComplexMult(&IM(c5), &IM(c4),
+ ti11, ti12, IM(t5), IM(t4));
+
+ RE(ch[ah+l1]) = RE(c2) - IM(c5);
+ IM(ch[ah+l1]) = IM(c2) + RE(c5);
+ RE(ch[ah+2*l1]) = RE(c3) - IM(c4);
+ IM(ch[ah+2*l1]) = IM(c3) + RE(c4);
+ RE(ch[ah+3*l1]) = RE(c3) + IM(c4);
+ IM(ch[ah+3*l1]) = IM(c3) - RE(c4);
+ RE(ch[ah+4*l1]) = RE(c2) + IM(c5);
+ IM(ch[ah+4*l1]) = IM(c2) - RE(c5);
+ }
+ } else {
+ for (k = 0; k < l1; k++)
+ {
+ ac = 5*k + 1;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac+3]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+3]);
+ RE(t3) = RE(cc[ac+1]) + RE(cc[ac+2]);
+ IM(t3) = IM(cc[ac+1]) + IM(cc[ac+2]);
+ RE(t4) = RE(cc[ac+1]) - RE(cc[ac+2]);
+ IM(t4) = IM(cc[ac+1]) - IM(cc[ac+2]);
+ RE(t5) = RE(cc[ac]) - RE(cc[ac+3]);
+ IM(t5) = IM(cc[ac]) - IM(cc[ac+3]);
+
+ RE(ch[ah]) = RE(cc[ac-1]) + RE(t2) + RE(t3);
+ IM(ch[ah]) = IM(cc[ac-1]) + IM(t2) + IM(t3);
+
+ RE(c2) = RE(cc[ac-1]) + MUL_F(RE(t2),tr11) + MUL_F(RE(t3),tr12);
+ IM(c2) = IM(cc[ac-1]) + MUL_F(IM(t2),tr11) + MUL_F(IM(t3),tr12);
+ RE(c3) = RE(cc[ac-1]) + MUL_F(RE(t2),tr12) + MUL_F(RE(t3),tr11);
+ IM(c3) = IM(cc[ac-1]) + MUL_F(IM(t2),tr12) + MUL_F(IM(t3),tr11);
+
+ ComplexMult(&RE(c4), &RE(c5),
+ ti12, ti11, RE(t5), RE(t4));
+ ComplexMult(&IM(c4), &IM(c5),
+ ti12, ti11, IM(t5), IM(t4));
+
+ RE(ch[ah+l1]) = RE(c2) + IM(c5);
+ IM(ch[ah+l1]) = IM(c2) - RE(c5);
+ RE(ch[ah+2*l1]) = RE(c3) + IM(c4);
+ IM(ch[ah+2*l1]) = IM(c3) - RE(c4);
+ RE(ch[ah+3*l1]) = RE(c3) - IM(c4);
+ IM(ch[ah+3*l1]) = IM(c3) + RE(c4);
+ RE(ch[ah+4*l1]) = RE(c2) - IM(c5);
+ IM(ch[ah+4*l1]) = IM(c2) + RE(c5);
+ }
+ }
+ } else {
+ if (isign == 1)
+ {
+ for (k = 0; k < l1; k++)
+ {
+ for (i = 0; i < ido; i++)
+ {
+ ac = i + (k*5 + 1) * ido;
+ ah = i + k * ido;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac+3*ido]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+3*ido]);
+ RE(t3) = RE(cc[ac+ido]) + RE(cc[ac+2*ido]);
+ IM(t3) = IM(cc[ac+ido]) + IM(cc[ac+2*ido]);
+ RE(t4) = RE(cc[ac+ido]) - RE(cc[ac+2*ido]);
+ IM(t4) = IM(cc[ac+ido]) - IM(cc[ac+2*ido]);
+ RE(t5) = RE(cc[ac]) - RE(cc[ac+3*ido]);
+ IM(t5) = IM(cc[ac]) - IM(cc[ac+3*ido]);
+
+ RE(ch[ah]) = RE(cc[ac-ido]) + RE(t2) + RE(t3);
+ IM(ch[ah]) = IM(cc[ac-ido]) + IM(t2) + IM(t3);
+
+ RE(c2) = RE(cc[ac-ido]) + MUL_F(RE(t2),tr11) + MUL_F(RE(t3),tr12);
+ IM(c2) = IM(cc[ac-ido]) + MUL_F(IM(t2),tr11) + MUL_F(IM(t3),tr12);
+ RE(c3) = RE(cc[ac-ido]) + MUL_F(RE(t2),tr12) + MUL_F(RE(t3),tr11);
+ IM(c3) = IM(cc[ac-ido]) + MUL_F(IM(t2),tr12) + MUL_F(IM(t3),tr11);
+
+ ComplexMult(&RE(c5), &RE(c4),
+ ti11, ti12, RE(t5), RE(t4));
+ ComplexMult(&IM(c5), &IM(c4),
+ ti11, ti12, IM(t5), IM(t4));
+
+ IM(d2) = IM(c2) + RE(c5);
+ IM(d3) = IM(c3) + RE(c4);
+ RE(d4) = RE(c3) + IM(c4);
+ RE(d5) = RE(c2) + IM(c5);
+ RE(d2) = RE(c2) - IM(c5);
+ IM(d5) = IM(c2) - RE(c5);
+ RE(d3) = RE(c3) - IM(c4);
+ IM(d4) = IM(c3) - RE(c4);
+
+#if 1
+ ComplexMult(&IM(ch[ah+l1*ido]), &RE(ch[ah+l1*ido]),
+ IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah+2*l1*ido]), &RE(ch[ah+2*l1*ido]),
+ IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&IM(ch[ah+3*l1*ido]), &RE(ch[ah+3*l1*ido]),
+ IM(d4), RE(d4), RE(wa3[i]), IM(wa3[i]));
+ ComplexMult(&IM(ch[ah+4*l1*ido]), &RE(ch[ah+4*l1*ido]),
+ IM(d5), RE(d5), RE(wa4[i]), IM(wa4[i]));
+#else
+ ComplexMult(&RE(ch[ah+l1*ido]), &IM(ch[ah+l1*ido]),
+ RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah+2*l1*ido]), &IM(ch[ah+2*l1*ido]),
+ RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&RE(ch[ah+3*l1*ido]), &IM(ch[ah+3*l1*ido]),
+ RE(d4), IM(d4), RE(wa3[i]), IM(wa3[i]));
+ ComplexMult(&RE(ch[ah+4*l1*ido]), &IM(ch[ah+4*l1*ido]),
+ RE(d5), IM(d5), RE(wa4[i]), IM(wa4[i]));
+#endif
+ }
+ }
+ } else {
+ for (k = 0; k < l1; k++)
+ {
+ for (i = 0; i < ido; i++)
+ {
+ ac = i + (k*5 + 1) * ido;
+ ah = i + k * ido;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac+3*ido]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+3*ido]);
+ RE(t3) = RE(cc[ac+ido]) + RE(cc[ac+2*ido]);
+ IM(t3) = IM(cc[ac+ido]) + IM(cc[ac+2*ido]);
+ RE(t4) = RE(cc[ac+ido]) - RE(cc[ac+2*ido]);
+ IM(t4) = IM(cc[ac+ido]) - IM(cc[ac+2*ido]);
+ RE(t5) = RE(cc[ac]) - RE(cc[ac+3*ido]);
+ IM(t5) = IM(cc[ac]) - IM(cc[ac+3*ido]);
+
+ RE(ch[ah]) = RE(cc[ac-ido]) + RE(t2) + RE(t3);
+ IM(ch[ah]) = IM(cc[ac-ido]) + IM(t2) + IM(t3);
+
+ RE(c2) = RE(cc[ac-ido]) + MUL_F(RE(t2),tr11) + MUL_F(RE(t3),tr12);
+ IM(c2) = IM(cc[ac-ido]) + MUL_F(IM(t2),tr11) + MUL_F(IM(t3),tr12);
+ RE(c3) = RE(cc[ac-ido]) + MUL_F(RE(t2),tr12) + MUL_F(RE(t3),tr11);
+ IM(c3) = IM(cc[ac-ido]) + MUL_F(IM(t2),tr12) + MUL_F(IM(t3),tr11);
+
+ ComplexMult(&RE(c4), &RE(c5),
+ ti12, ti11, RE(t5), RE(t4));
+ ComplexMult(&IM(c4), &IM(c5),
+ ti12, ti11, IM(t5), IM(t4));
+
+ IM(d2) = IM(c2) - RE(c5);
+ IM(d3) = IM(c3) - RE(c4);
+ RE(d4) = RE(c3) - IM(c4);
+ RE(d5) = RE(c2) - IM(c5);
+ RE(d2) = RE(c2) + IM(c5);
+ IM(d5) = IM(c2) + RE(c5);
+ RE(d3) = RE(c3) + IM(c4);
+ IM(d4) = IM(c3) + RE(c4);
+
+#if 1
+ ComplexMult(&RE(ch[ah+l1*ido]), &IM(ch[ah+l1*ido]),
+ RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah+2*l1*ido]), &IM(ch[ah+2*l1*ido]),
+ RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&RE(ch[ah+3*l1*ido]), &IM(ch[ah+3*l1*ido]),
+ RE(d4), IM(d4), RE(wa3[i]), IM(wa3[i]));
+ ComplexMult(&RE(ch[ah+4*l1*ido]), &IM(ch[ah+4*l1*ido]),
+ RE(d5), IM(d5), RE(wa4[i]), IM(wa4[i]));
+#else
+ ComplexMult(&IM(ch[ah+l1*ido]), &RE(ch[ah+l1*ido]),
+ IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah+2*l1*ido]), &RE(ch[ah+2*l1*ido]),
+ IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&IM(ch[ah+3*l1*ido]), &RE(ch[ah+3*l1*ido]),
+ IM(d4), RE(d4), RE(wa3[i]), IM(wa3[i]));
+ ComplexMult(&IM(ch[ah+4*l1*ido]), &RE(ch[ah+4*l1*ido]),
+ IM(d5), RE(d5), RE(wa4[i]), IM(wa4[i]));
+#endif
+ }
+ }
+ }
+ }
+}
+
+
+/*----------------------------------------------------------------------
+ cfftf1, cfftf, cfftb, cffti1, cffti. Complex FFTs.
+ ----------------------------------------------------------------------*/
+
+static INLINE void cfftf1pos(uint16_t n, complex_t *c, complex_t *ch,
+ const uint16_t *ifac, const complex_t *wa,
+ const int8_t isign)
+{
+ uint16_t i;
+ uint16_t k1, l1, l2;
+ uint16_t na, nf, ip, iw, ix2, ix3, ix4, ido, idl1;
+
+ nf = ifac[1];
+ na = 0;
+ l1 = 1;
+ iw = 0;
+
+ for (k1 = 2; k1 <= nf+1; k1++)
+ {
+ ip = ifac[k1];
+ l2 = ip*l1;
+ ido = n / l2;
+ idl1 = ido*l1;
+
+ switch (ip)
+ {
+ case 4:
+ ix2 = iw + ido;
+ ix3 = ix2 + ido;
+
+ if (na == 0)
+ passf4pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]);
+ else
+ passf4pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]);
+
+ na = 1 - na;
+ break;
+ case 2:
+ if (na == 0)
+ passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]);
+ else
+ passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]);
+
+ na = 1 - na;
+ break;
+ case 3:
+ ix2 = iw + ido;
+
+ if (na == 0)
+ passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], isign);
+ else
+ passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], isign);
+
+ na = 1 - na;
+ break;
+ case 5:
+ ix2 = iw + ido;
+ ix3 = ix2 + ido;
+ ix4 = ix3 + ido;
+
+ if (na == 0)
+ passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
+ else
+ passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
+
+ na = 1 - na;
+ break;
+ }
+
+ l1 = l2;
+ iw += (ip-1) * ido;
+ }
+
+ if (na == 0)
+ return;
+
+ for (i = 0; i < n; i++)
+ {
+ RE(c[i]) = RE(ch[i]);
+ IM(c[i]) = IM(ch[i]);
+ }
+}
+
+static INLINE void cfftf1neg(uint16_t n, complex_t *c, complex_t *ch,
+ const uint16_t *ifac, const complex_t *wa,
+ const int8_t isign)
+{
+ uint16_t i;
+ uint16_t k1, l1, l2;
+ uint16_t na, nf, ip, iw, ix2, ix3, ix4, ido, idl1;
+
+ nf = ifac[1];
+ na = 0;
+ l1 = 1;
+ iw = 0;
+
+ for (k1 = 2; k1 <= nf+1; k1++)
+ {
+ ip = ifac[k1];
+ l2 = ip*l1;
+ ido = n / l2;
+ idl1 = ido*l1;
+
+ switch (ip)
+ {
+ case 4:
+ ix2 = iw + ido;
+ ix3 = ix2 + ido;
+
+ if (na == 0)
+ passf4neg((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]);
+ else
+ passf4neg((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]);
+
+ na = 1 - na;
+ break;
+ case 2:
+ if (na == 0)
+ passf2neg((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]);
+ else
+ passf2neg((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]);
+
+ na = 1 - na;
+ break;
+ case 3:
+ ix2 = iw + ido;
+
+ if (na == 0)
+ passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], isign);
+ else
+ passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], isign);
+
+ na = 1 - na;
+ break;
+ case 5:
+ ix2 = iw + ido;
+ ix3 = ix2 + ido;
+ ix4 = ix3 + ido;
+
+ if (na == 0)
+ passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
+ else
+ passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
+
+ na = 1 - na;
+ break;
+ }
+
+ l1 = l2;
+ iw += (ip-1) * ido;
+ }
+
+ if (na == 0)
+ return;
+
+ for (i = 0; i < n; i++)
+ {
+ RE(c[i]) = RE(ch[i]);
+ IM(c[i]) = IM(ch[i]);
+ }
+}
+
+void cfftf(cfft_info *cfft, complex_t *c)
+{
+ cfftf1neg(cfft->n, c, cfft->work, (const uint16_t*)cfft->ifac, (const complex_t*)cfft->tab, -1);
+}
+
+void cfftb(cfft_info *cfft, complex_t *c)
+{
+ cfftf1pos(cfft->n, c, cfft->work, (const uint16_t*)cfft->ifac, (const complex_t*)cfft->tab, +1);
+}
+
+static void cffti1(uint16_t n, complex_t *wa, uint16_t *ifac)
+{
+ static uint16_t ntryh[4] = {3, 4, 2, 5};
+#ifndef FIXED_POINT
+ real_t arg, argh, argld, fi;
+ uint16_t ido, ipm;
+ uint16_t i1, k1, l1, l2;
+ uint16_t ld, ii, ip;
+#endif
+ uint16_t ntry = 0, i, j;
+ uint16_t ib;
+ uint16_t nf, nl, nq, nr;
+
+ nl = n;
+ nf = 0;
+ j = 0;
+
+startloop:
+ j++;
+
+ if (j <= 4)
+ ntry = ntryh[j-1];
+ else
+ ntry += 2;
+
+ do
+ {
+ nq = nl / ntry;
+ nr = nl - ntry*nq;
+
+ if (nr != 0)
+ goto startloop;
+
+ nf++;
+ ifac[nf+1] = ntry;
+ nl = nq;
+
+ if (ntry == 2 && nf != 1)
+ {
+ for (i = 2; i <= nf; i++)
+ {
+ ib = nf - i + 2;
+ ifac[ib+1] = ifac[ib];
+ }
+ ifac[2] = 2;
+ }
+ } while (nl != 1);
+
+ ifac[0] = n;
+ ifac[1] = nf;
+
+#ifndef FIXED_POINT
+ argh = (real_t)2.0*(real_t)M_PI / (real_t)n;
+ i = 0;
+ l1 = 1;
+
+ for (k1 = 1; k1 <= nf; k1++)
+ {
+ ip = ifac[k1+1];
+ ld = 0;
+ l2 = l1*ip;
+ ido = n / l2;
+ ipm = ip - 1;
+
+ for (j = 0; j < ipm; j++)
+ {
+ i1 = i;
+ RE(wa[i]) = 1.0;
+ IM(wa[i]) = 0.0;
+ ld += l1;
+ fi = 0;
+ argld = ld*argh;
+
+ for (ii = 0; ii < ido; ii++)
+ {
+ i++;
+ fi++;
+ arg = fi * argld;
+ RE(wa[i]) = (real_t)cos(arg);
+#if 1
+ IM(wa[i]) = (real_t)sin(arg);
+#else
+ IM(wa[i]) = (real_t)-sin(arg);
+#endif
+ }
+
+ if (ip > 5)
+ {
+ RE(wa[i1]) = RE(wa[i]);
+ IM(wa[i1]) = IM(wa[i]);
+ }
+ }
+ l1 = l2;
+ }
+#endif
+}
+
+cfft_info *cffti(uint16_t n)
+{
+ cfft_info *cfft = (cfft_info*)faad_malloc(sizeof(cfft_info));
+
+ cfft->n = n;
+ cfft->work = (complex_t*)faad_malloc(n*sizeof(complex_t));
+
+#ifndef FIXED_POINT
+ cfft->tab = (complex_t*)faad_malloc(n*sizeof(complex_t));
+
+ cffti1(n, cfft->tab, cfft->ifac);
+#else
+ cffti1(n, NULL, cfft->ifac);
+
+ switch (n)
+ {
+ case 64: cfft->tab = (complex_t*)cfft_tab_64; break;
+ case 512: cfft->tab = (complex_t*)cfft_tab_512; break;
+#ifdef LD_DEC
+ case 256: cfft->tab = (complex_t*)cfft_tab_256; break;
+#endif
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+ case 60: cfft->tab = (complex_t*)cfft_tab_60; break;
+ case 480: cfft->tab = (complex_t*)cfft_tab_480; break;
+#ifdef LD_DEC
+ case 240: cfft->tab = (complex_t*)cfft_tab_240; break;
+#endif
+#endif
+ case 128: cfft->tab = (complex_t*)cfft_tab_128; break;
+ }
+#endif
+
+ return cfft;
+}
+
+void cfftu(cfft_info *cfft)
+{
+ if (cfft->work) faad_free(cfft->work);
+#ifndef FIXED_POINT
+ if (cfft->tab) faad_free(cfft->tab);
+#endif
+
+ if (cfft) faad_free(cfft);
+}
+
diff --git a/faad2/src/libfaad/cfft.h b/faad2/src/libfaad/cfft.h
new file mode 100644
index 0000000..7072d0d
--- /dev/null
+++ b/faad2/src/libfaad/cfft.h
@@ -0,0 +1,56 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: cfft.h,v 1.24 2007/11/01 12:33:29 menno Exp $
+**/
+
+#ifndef __CFFT_H__
+#define __CFFT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ uint16_t n;
+ uint16_t ifac[15];
+ complex_t *work;
+ complex_t *tab;
+} cfft_info;
+
+
+void cfftf(cfft_info *cfft, complex_t *c);
+void cfftb(cfft_info *cfft, complex_t *c);
+cfft_info *cffti(uint16_t n);
+void cfftu(cfft_info *cfft);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/faad2/src/libfaad/cfft_tab.h b/faad2/src/libfaad/cfft_tab.h
new file mode 100644
index 0000000..4f0197f
--- /dev/null
+++ b/faad2/src/libfaad/cfft_tab.h
@@ -0,0 +1,1823 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+**
+** 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.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: cfft_tab.h,v 1.21 2007/11/01 12:33:29 menno Exp $
+**/
+
+#ifndef __CFFT_TAB_H__
+#define __CFFT_TAB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef FIXED_POINT
+
+ALIGN static const complex_t cfft_tab_512[] =
+{
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.999924719333649), FRAC_CONST(0.012271538376808) },
+ { FRAC_CONST(0.999698817729950), FRAC_CONST(0.024541229009628) },
+ { FRAC_CONST(0.999322354793549), FRAC_CONST(0.036807224154472) },
+ { FRAC_CONST(0.998795449733734), FRAC_CONST(0.049067676067352) },
+ { FRAC_CONST(0.998118102550507), FRAC_CONST(0.061320740729570) },
+ { FRAC_CONST(0.997290432453156), FRAC_CONST(0.073564566671848) },
+ { FRAC_CONST(0.996312618255615), FRAC_CONST(0.085797317326069) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.993906974792480), FRAC_CONST(0.110222205519676) },
+ { FRAC_CONST(0.992479562759399), FRAC_CONST(0.122410677373409) },
+ { FRAC_CONST(0.990902662277222), FRAC_CONST(0.134580716490746) },
+ { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) },
+ { FRAC_CONST(0.987301409244537), FRAC_CONST(0.158858150243759) },
+ { FRAC_CONST(0.985277652740479), FRAC_CONST(0.170961901545525) },
+ { FRAC_CONST(0.983105480670929), FRAC_CONST(0.183039888739586) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.978317379951477), FRAC_CONST(0.207111388444901) },
+ { FRAC_CONST(0.975702106952667), FRAC_CONST(0.219101235270500) },
+ { FRAC_CONST(0.972939968109131), FRAC_CONST(0.231058120727539) },
+ { FRAC_CONST(0.970031261444092), FRAC_CONST(0.242980197072029) },
+ { FRAC_CONST(0.966976463794708), FRAC_CONST(0.254865676164627) },
+ { FRAC_CONST(0.963776051998138), FRAC_CONST(0.266712784767151) },
+ { FRAC_CONST(0.960430502891541), FRAC_CONST(0.278519690036774) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.953306019306183), FRAC_CONST(0.302005946636200) },
+ { FRAC_CONST(0.949528157711029), FRAC_CONST(0.313681751489639) },
+ { FRAC_CONST(0.945607304573059), FRAC_CONST(0.325310319662094) },
+ { FRAC_CONST(0.941544055938721), FRAC_CONST(0.336889863014221) },
+ { FRAC_CONST(0.937339007854462), FRAC_CONST(0.348418682813644) },
+ { FRAC_CONST(0.932992815971375), FRAC_CONST(0.359895050525665) },
+ { FRAC_CONST(0.928506076335907), FRAC_CONST(0.371317207813263) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.919113874435425), FRAC_CONST(0.393992066383362) },
+ { FRAC_CONST(0.914209723472595), FRAC_CONST(0.405241340398788) },
+ { FRAC_CONST(0.909167945384979), FRAC_CONST(0.416429579257965) },
+ { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) },
+ { FRAC_CONST(0.898674488067627), FRAC_CONST(0.438616245985031) },
+ { FRAC_CONST(0.893224298954010), FRAC_CONST(0.449611335992813) },
+ { FRAC_CONST(0.887639641761780), FRAC_CONST(0.460538715124130) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.876070082187653), FRAC_CONST(0.482183754444122) },
+ { FRAC_CONST(0.870086967945099), FRAC_CONST(0.492898225784302) },
+ { FRAC_CONST(0.863972842693329), FRAC_CONST(0.503538370132446) },
+ { FRAC_CONST(0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(0.851355195045471), FRAC_CONST(0.524589717388153) },
+ { FRAC_CONST(0.844853579998016), FRAC_CONST(0.534997642040253) },
+ { FRAC_CONST(0.838224709033966), FRAC_CONST(0.545324981212616) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.824589252471924), FRAC_CONST(0.565731823444366) },
+ { FRAC_CONST(0.817584812641144), FRAC_CONST(0.575808227062225) },
+ { FRAC_CONST(0.810457170009613), FRAC_CONST(0.585797905921936) },
+ { FRAC_CONST(0.803207516670227), FRAC_CONST(0.595699310302734) },
+ { FRAC_CONST(0.795836925506592), FRAC_CONST(0.605511009693146) },
+ { FRAC_CONST(0.788346409797668), FRAC_CONST(0.615231633186340) },
+ { FRAC_CONST(0.780737221240997), FRAC_CONST(0.624859511852264) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.765167236328125), FRAC_CONST(0.643831551074982) },
+ { FRAC_CONST(0.757208824157715), FRAC_CONST(0.653172850608826) },
+ { FRAC_CONST(0.749136388301849), FRAC_CONST(0.662415802478790) },
+ { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) },
+ { FRAC_CONST(0.732654273509979), FRAC_CONST(0.680601000785828) },
+ { FRAC_CONST(0.724247097969055), FRAC_CONST(0.689540565013886) },
+ { FRAC_CONST(0.715730786323547), FRAC_CONST(0.698376297950745) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.698376238346100), FRAC_CONST(0.715730845928192) },
+ { FRAC_CONST(0.689540505409241), FRAC_CONST(0.724247097969055) },
+ { FRAC_CONST(0.680601000785828), FRAC_CONST(0.732654273509979) },
+ { FRAC_CONST(0.671558916568756), FRAC_CONST(0.740951180458069) },
+ { FRAC_CONST(0.662415742874146), FRAC_CONST(0.749136388301849) },
+ { FRAC_CONST(0.653172791004181), FRAC_CONST(0.757208883762360) },
+ { FRAC_CONST(0.643831551074982), FRAC_CONST(0.765167295932770) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.624859452247620), FRAC_CONST(0.780737280845642) },
+ { FRAC_CONST(0.615231573581696), FRAC_CONST(0.788346409797668) },
+ { FRAC_CONST(0.605511009693146), FRAC_CONST(0.795836925506592) },
+ { FRAC_CONST(0.595699310302734), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(0.585797846317291), FRAC_CONST(0.810457170009613) },
+ { FRAC_CONST(0.575808167457581), FRAC_CONST(0.817584812641144) },
+ { FRAC_CONST(0.565731823444366), FRAC_CONST(0.824589312076569) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.545324981212616), FRAC_CONST(0.838224709033966) },
+ { FRAC_CONST(0.534997642040253), FRAC_CONST(0.844853579998016) },
+ { FRAC_CONST(0.524589657783508), FRAC_CONST(0.851355195045471) },
+ { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) },
+ { FRAC_CONST(0.503538429737091), FRAC_CONST(0.863972842693329) },
+ { FRAC_CONST(0.492898195981979), FRAC_CONST(0.870086967945099) },
+ { FRAC_CONST(0.482183724641800), FRAC_CONST(0.876070141792297) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.460538715124130), FRAC_CONST(0.887639641761780) },
+ { FRAC_CONST(0.449611306190491), FRAC_CONST(0.893224298954010) },
+ { FRAC_CONST(0.438616186380386), FRAC_CONST(0.898674488067627) },
+ { FRAC_CONST(0.427555114030838), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(0.416429549455643), FRAC_CONST(0.909168004989624) },
+ { FRAC_CONST(0.405241280794144), FRAC_CONST(0.914209783077240) },
+ { FRAC_CONST(0.393991947174072), FRAC_CONST(0.919113874435425) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.371317148208618), FRAC_CONST(0.928506076335907) },
+ { FRAC_CONST(0.359894961118698), FRAC_CONST(0.932992815971375) },
+ { FRAC_CONST(0.348418682813644), FRAC_CONST(0.937339007854462) },
+ { FRAC_CONST(0.336889833211899), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(0.325310230255127), FRAC_CONST(0.945607364177704) },
+ { FRAC_CONST(0.313681662082672), FRAC_CONST(0.949528217315674) },
+ { FRAC_CONST(0.302005946636200), FRAC_CONST(0.953306019306183) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.278519600629807), FRAC_CONST(0.960430562496185) },
+ { FRAC_CONST(0.266712754964828), FRAC_CONST(0.963776051998138) },
+ { FRAC_CONST(0.254865646362305), FRAC_CONST(0.966976463794708) },
+ { FRAC_CONST(0.242980122566223), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(0.231058135628700), FRAC_CONST(0.972939968109131) },
+ { FRAC_CONST(0.219101220369339), FRAC_CONST(0.975702106952667) },
+ { FRAC_CONST(0.207111328840256), FRAC_CONST(0.978317379951477) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.183039888739586), FRAC_CONST(0.983105480670929) },
+ { FRAC_CONST(0.170961856842041), FRAC_CONST(0.985277652740479) },
+ { FRAC_CONST(0.158858075737953), FRAC_CONST(0.987301409244537) },
+ { FRAC_CONST(0.146730497479439), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(0.134580686688423), FRAC_CONST(0.990902662277222) },
+ { FRAC_CONST(0.122410625219345), FRAC_CONST(0.992479562759399) },
+ { FRAC_CONST(0.110222116112709), FRAC_CONST(0.993906974792480) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(0.085797272622585), FRAC_CONST(0.996312618255615) },
+ { FRAC_CONST(0.073564492166042), FRAC_CONST(0.997290432453156) },
+ { FRAC_CONST(0.061320748180151), FRAC_CONST(0.998118102550507) },
+ { FRAC_CONST(0.049067649990320), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(0.036807164549828), FRAC_CONST(0.999322414398193) },
+ { FRAC_CONST(0.024541135877371), FRAC_CONST(0.999698817729950) },
+ { FRAC_CONST(0.012271529063582), FRAC_CONST(0.999924719333649) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.012271616607904), FRAC_CONST(0.999924719333649) },
+ { FRAC_CONST(-0.024541223421693), FRAC_CONST(0.999698817729950) },
+ { FRAC_CONST(-0.036807250231504), FRAC_CONST(0.999322354793549) },
+ { FRAC_CONST(-0.049067739397287), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(-0.061320833861828), FRAC_CONST(0.998118102550507) },
+ { FRAC_CONST(-0.073564574122429), FRAC_CONST(0.997290432453156) },
+ { FRAC_CONST(-0.085797362029552), FRAC_CONST(0.996312618255615) },
+ { FRAC_CONST(-0.098017223179340), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(-0.110222205519676), FRAC_CONST(0.993906974792480) },
+ { FRAC_CONST(-0.122410707175732), FRAC_CONST(0.992479503154755) },
+ { FRAC_CONST(-0.134580776095390), FRAC_CONST(0.990902602672577) },
+ { FRAC_CONST(-0.146730571985245), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(-0.158858165144920), FRAC_CONST(0.987301409244537) },
+ { FRAC_CONST(-0.170961946249008), FRAC_CONST(0.985277652740479) },
+ { FRAC_CONST(-0.183039978146553), FRAC_CONST(0.983105480670929) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.207111418247223), FRAC_CONST(0.978317379951477) },
+ { FRAC_CONST(-0.219101309776306), FRAC_CONST(0.975702106952667) },
+ { FRAC_CONST(-0.231058210134506), FRAC_CONST(0.972939908504486) },
+ { FRAC_CONST(-0.242980197072029), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(-0.254865705966949), FRAC_CONST(0.966976463794708) },
+ { FRAC_CONST(-0.266712844371796), FRAC_CONST(0.963776051998138) },
+ { FRAC_CONST(-0.278519690036774), FRAC_CONST(0.960430502891541) },
+ { FRAC_CONST(-0.290284723043442), FRAC_CONST(0.956940293312073) },
+ { FRAC_CONST(-0.302006036043167), FRAC_CONST(0.953306019306183) },
+ { FRAC_CONST(-0.313681721687317), FRAC_CONST(0.949528157711029) },
+ { FRAC_CONST(-0.325310319662094), FRAC_CONST(0.945607304573059) },
+ { FRAC_CONST(-0.336889922618866), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(-0.348418772220612), FRAC_CONST(0.937338948249817) },
+ { FRAC_CONST(-0.359895050525665), FRAC_CONST(0.932992815971375) },
+ { FRAC_CONST(-0.371317237615585), FRAC_CONST(0.928506076335907) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.393992036581039), FRAC_CONST(0.919113874435425) },
+ { FRAC_CONST(-0.405241340398788), FRAC_CONST(0.914209723472595) },
+ { FRAC_CONST(-0.416429519653320), FRAC_CONST(0.909168004989624) },
+ { FRAC_CONST(-0.427555084228516), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(-0.438616245985031), FRAC_CONST(0.898674428462982) },
+ { FRAC_CONST(-0.449611365795136), FRAC_CONST(0.893224298954010) },
+ { FRAC_CONST(-0.460538804531097), FRAC_CONST(0.887639582157135) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.482183903455734), FRAC_CONST(0.876070022583008) },
+ { FRAC_CONST(-0.492898166179657), FRAC_CONST(0.870087027549744) },
+ { FRAC_CONST(-0.503538370132446), FRAC_CONST(0.863972842693329) },
+ { FRAC_CONST(-0.514102756977081), FRAC_CONST(0.857728600502014) },
+ { FRAC_CONST(-0.524589717388153), FRAC_CONST(0.851355135440826) },
+ { FRAC_CONST(-0.534997701644897), FRAC_CONST(0.844853520393372) },
+ { FRAC_CONST(-0.545325100421906), FRAC_CONST(0.838224649429321) },
+ { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) },
+ { FRAC_CONST(-0.565731763839722), FRAC_CONST(0.824589312076569) },
+ { FRAC_CONST(-0.575808167457581), FRAC_CONST(0.817584812641144) },
+ { FRAC_CONST(-0.585797905921936), FRAC_CONST(0.810457170009613) },
+ { FRAC_CONST(-0.595699369907379), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(-0.605511128902435), FRAC_CONST(0.795836865901947) },
+ { FRAC_CONST(-0.615231692790985), FRAC_CONST(0.788346350193024) },
+ { FRAC_CONST(-0.624859631061554), FRAC_CONST(0.780737102031708) },
+ { FRAC_CONST(-0.634393274784088), FRAC_CONST(0.773010492324829) },
+ { FRAC_CONST(-0.643831551074982), FRAC_CONST(0.765167236328125) },
+ { FRAC_CONST(-0.653172850608826), FRAC_CONST(0.757208824157715) },
+ { FRAC_CONST(-0.662415802478790), FRAC_CONST(0.749136328697205) },
+ { FRAC_CONST(-0.671559035778046), FRAC_CONST(0.740951061248779) },
+ { FRAC_CONST(-0.680601119995117), FRAC_CONST(0.732654154300690) },
+ { FRAC_CONST(-0.689540684223175), FRAC_CONST(0.724246978759766) },
+ { FRAC_CONST(-0.698376238346100), FRAC_CONST(0.715730845928192) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.715730845928192), FRAC_CONST(0.698376238346100) },
+ { FRAC_CONST(-0.724247157573700), FRAC_CONST(0.689540505409241) },
+ { FRAC_CONST(-0.732654333114624), FRAC_CONST(0.680600941181183) },
+ { FRAC_CONST(-0.740951240062714), FRAC_CONST(0.671558856964111) },
+ { FRAC_CONST(-0.749136507511139), FRAC_CONST(0.662415623664856) },
+ { FRAC_CONST(-0.757208824157715), FRAC_CONST(0.653172850608826) },
+ { FRAC_CONST(-0.765167295932770), FRAC_CONST(0.643831551074982) },
+ { FRAC_CONST(-0.773010492324829), FRAC_CONST(0.634393274784088) },
+ { FRAC_CONST(-0.780737280845642), FRAC_CONST(0.624859452247620) },
+ { FRAC_CONST(-0.788346469402313), FRAC_CONST(0.615231513977051) },
+ { FRAC_CONST(-0.795836985111237), FRAC_CONST(0.605510950088501) },
+ { FRAC_CONST(-0.803207635879517), FRAC_CONST(0.595699131488800) },
+ { FRAC_CONST(-0.810457170009613), FRAC_CONST(0.585797846317291) },
+ { FRAC_CONST(-0.817584812641144), FRAC_CONST(0.575808167457581) },
+ { FRAC_CONST(-0.824589312076569), FRAC_CONST(0.565731763839722) },
+ { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) },
+ { FRAC_CONST(-0.838224768638611), FRAC_CONST(0.545324862003326) },
+ { FRAC_CONST(-0.844853639602661), FRAC_CONST(0.534997463226318) },
+ { FRAC_CONST(-0.851355314254761), FRAC_CONST(0.524589538574219) },
+ { FRAC_CONST(-0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(-0.863972842693329), FRAC_CONST(0.503538370132446) },
+ { FRAC_CONST(-0.870087027549744), FRAC_CONST(0.492898136377335) },
+ { FRAC_CONST(-0.876070141792297), FRAC_CONST(0.482183694839478) },
+ { FRAC_CONST(-0.881921350955963), FRAC_CONST(0.471396625041962) },
+ { FRAC_CONST(-0.887639701366425), FRAC_CONST(0.460538566112518) },
+ { FRAC_CONST(-0.893224298954010), FRAC_CONST(0.449611365795136) },
+ { FRAC_CONST(-0.898674488067627), FRAC_CONST(0.438616245985031) },
+ { FRAC_CONST(-0.903989315032959), FRAC_CONST(0.427555054426193) },
+ { FRAC_CONST(-0.909168004989624), FRAC_CONST(0.416429489850998) },
+ { FRAC_CONST(-0.914209783077240), FRAC_CONST(0.405241221189499) },
+ { FRAC_CONST(-0.919113874435425), FRAC_CONST(0.393991917371750) },
+ { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) },
+ { FRAC_CONST(-0.928506076335907), FRAC_CONST(0.371317237615585) },
+ { FRAC_CONST(-0.932992815971375), FRAC_CONST(0.359895050525665) },
+ { FRAC_CONST(-0.937339007854462), FRAC_CONST(0.348418653011322) },
+ { FRAC_CONST(-0.941544115543365), FRAC_CONST(0.336889803409576) },
+ { FRAC_CONST(-0.945607364177704), FRAC_CONST(0.325310200452805) },
+ { FRAC_CONST(-0.949528217315674), FRAC_CONST(0.313681602478027) },
+ { FRAC_CONST(-0.953306078910828), FRAC_CONST(0.302005797624588) },
+ { FRAC_CONST(-0.956940352916718), FRAC_CONST(0.290284723043442) },
+ { FRAC_CONST(-0.960430502891541), FRAC_CONST(0.278519690036774) },
+ { FRAC_CONST(-0.963776051998138), FRAC_CONST(0.266712725162506) },
+ { FRAC_CONST(-0.966976463794708), FRAC_CONST(0.254865586757660) },
+ { FRAC_CONST(-0.970031261444092), FRAC_CONST(0.242980077862740) },
+ { FRAC_CONST(-0.972939968109131), FRAC_CONST(0.231057971715927) },
+ { FRAC_CONST(-0.975702166557312), FRAC_CONST(0.219101071357727) },
+ { FRAC_CONST(-0.978317379951477), FRAC_CONST(0.207111403346062) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.983105480670929), FRAC_CONST(0.183039844036102) },
+ { FRAC_CONST(-0.985277652740479), FRAC_CONST(0.170961812138557) },
+ { FRAC_CONST(-0.987301409244537), FRAC_CONST(0.158858031034470) },
+ { FRAC_CONST(-0.989176511764526), FRAC_CONST(0.146730333566666) },
+ { FRAC_CONST(-0.990902662277222), FRAC_CONST(0.134580522775650) },
+ { FRAC_CONST(-0.992479503154755), FRAC_CONST(0.122410699725151) },
+ { FRAC_CONST(-0.993906974792480), FRAC_CONST(0.110222198069096) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(0.098017096519470) },
+ { FRAC_CONST(-0.996312618255615), FRAC_CONST(0.085797227919102) },
+ { FRAC_CONST(-0.997290492057800), FRAC_CONST(0.073564447462559) },
+ { FRAC_CONST(-0.998118102550507), FRAC_CONST(0.061320584267378) },
+ { FRAC_CONST(-0.998795449733734), FRAC_CONST(0.049067486077547) },
+ { FRAC_CONST(-0.999322354793549), FRAC_CONST(0.036807239055634) },
+ { FRAC_CONST(-0.999698817729950), FRAC_CONST(0.024541210383177) },
+ { FRAC_CONST(-0.999924719333649), FRAC_CONST(0.012271485291421) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.999698817729950), FRAC_CONST(0.024541229009628) },
+ { FRAC_CONST(0.998795449733734), FRAC_CONST(0.049067676067352) },
+ { FRAC_CONST(0.997290432453156), FRAC_CONST(0.073564566671848) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.992479562759399), FRAC_CONST(0.122410677373409) },
+ { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) },
+ { FRAC_CONST(0.985277652740479), FRAC_CONST(0.170961901545525) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.975702106952667), FRAC_CONST(0.219101235270500) },
+ { FRAC_CONST(0.970031261444092), FRAC_CONST(0.242980197072029) },
+ { FRAC_CONST(0.963776051998138), FRAC_CONST(0.266712784767151) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.949528157711029), FRAC_CONST(0.313681751489639) },
+ { FRAC_CONST(0.941544055938721), FRAC_CONST(0.336889863014221) },
+ { FRAC_CONST(0.932992815971375), FRAC_CONST(0.359895050525665) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.914209723472595), FRAC_CONST(0.405241340398788) },
+ { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) },
+ { FRAC_CONST(0.893224298954010), FRAC_CONST(0.449611335992813) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.870086967945099), FRAC_CONST(0.492898225784302) },
+ { FRAC_CONST(0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(0.844853579998016), FRAC_CONST(0.534997642040253) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.817584812641144), FRAC_CONST(0.575808227062225) },
+ { FRAC_CONST(0.803207516670227), FRAC_CONST(0.595699310302734) },
+ { FRAC_CONST(0.788346409797668), FRAC_CONST(0.615231633186340) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.757208824157715), FRAC_CONST(0.653172850608826) },
+ { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) },
+ { FRAC_CONST(0.724247097969055), FRAC_CONST(0.689540565013886) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.689540505409241), FRAC_CONST(0.724247097969055) },
+ { FRAC_CONST(0.671558916568756), FRAC_CONST(0.740951180458069) },
+ { FRAC_CONST(0.653172791004181), FRAC_CONST(0.757208883762360) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.615231573581696), FRAC_CONST(0.788346409797668) },
+ { FRAC_CONST(0.595699310302734), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(0.575808167457581), FRAC_CONST(0.817584812641144) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.534997642040253), FRAC_CONST(0.844853579998016) },
+ { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) },
+ { FRAC_CONST(0.492898195981979), FRAC_CONST(0.870086967945099) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.449611306190491), FRAC_CONST(0.893224298954010) },
+ { FRAC_CONST(0.427555114030838), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(0.405241280794144), FRAC_CONST(0.914209783077240) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.359894961118698), FRAC_CONST(0.932992815971375) },
+ { FRAC_CONST(0.336889833211899), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(0.313681662082672), FRAC_CONST(0.949528217315674) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.266712754964828), FRAC_CONST(0.963776051998138) },
+ { FRAC_CONST(0.242980122566223), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(0.219101220369339), FRAC_CONST(0.975702106952667) },
+ { FRAC_CONST(0.1950902342