From 5d92761bda9625b84a223b3b0da630add1a74a8b Mon Sep 17 00:00:00 2001 From: Casey Langen Date: Sat, 4 Jun 2016 18:29:13 -0700 Subject: [PATCH] AacDecoder is now compiling under OS X --- CMakeLists.txt | 1 + src/contrib/aacdecoder/AacDecoder.cpp | 25 ++-- src/contrib/aacdecoder/CMakeLists.txt | 48 +++---- src/contrib/aacdecoder/aacdecoder.vcproj | 2 +- src/contrib/aacdecoder/aacdecoder.vcxproj | 4 +- .../aacdecoder/aacdecoder.vcxproj.filters | 4 +- ...coder_plugin.cpp => aacdecoder_plugin.cpp} | 136 +++++++++--------- src/contrib/aacdecoder/drms/config.h | 0 src/contrib/aacdecoder/{ => drms}/drms.c | 0 src/contrib/aacdecoder/{ => drms}/drms.h | 0 .../aacdecoder/{ => drms}/drmstables.h | 0 src/contrib/aacdecoder/mp4ff/config.h | 0 12 files changed, 104 insertions(+), 116 deletions(-) rename src/contrib/aacdecoder/{accdecoder_plugin.cpp => aacdecoder_plugin.cpp} (97%) create mode 100644 src/contrib/aacdecoder/drms/config.h rename src/contrib/aacdecoder/{ => drms}/drms.c (100%) rename src/contrib/aacdecoder/{ => drms}/drms.h (100%) rename src/contrib/aacdecoder/{ => drms}/drmstables.h (100%) create mode 100644 src/contrib/aacdecoder/mp4ff/config.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a9b56239..1af89dc2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ include_directories ( add_subdirectory(src/core) add_subdirectory(src/musikbox) add_subdirectory(src/contrib/taglib_plugin) +add_subdirectory(src/contrib/aacdecoder) add_subdirectory(src/contrib/oggdecoder) add_subdirectory(src/contrib/mpg123decoder) add_subdirectory(src/contrib/flacdecoder) diff --git a/src/contrib/aacdecoder/AacDecoder.cpp b/src/contrib/aacdecoder/AacDecoder.cpp index dfb82bed5..bc69e4885 100644 --- a/src/contrib/aacdecoder/AacDecoder.cpp +++ b/src/contrib/aacdecoder/AacDecoder.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "AacDecoder.h" -#include using musik::core::io::IDataStream; using musik::core::audio::IBuffer; @@ -85,16 +84,16 @@ bool AacDecoder::Open(musik::core::io::IDataStream *stream) buffer = NULL; buffer_size = 0; mp4ff_get_decoder_config(decoderFile, audioTrackId, &buffer, &buffer_size); - + if (!buffer) { return false; } if (NeAACDecInit2( - decoder, - buffer, - buffer_size, - &this->sampleRate, + decoder, + buffer, + buffer_size, + &this->sampleRate, &this->channelCount) < 0) { if (buffer) { @@ -158,11 +157,11 @@ bool AacDecoder::GetBuffer(IBuffer* target) { /* read the raw data required */ - int rc = + int rc = mp4ff_read_sample( - decoderFile, - audioTrackId, - decoderSampleId, + decoderFile, + audioTrackId, + decoderSampleId, &encodedData, &encodedDataLength); @@ -170,9 +169,9 @@ bool AacDecoder::GetBuffer(IBuffer* target) { if (rc == 0 || encodedData == NULL) { return false; - } + } - sampleBuffer = + sampleBuffer = NeAACDecDecode( decoder, &frameInfo, @@ -192,7 +191,7 @@ bool AacDecoder::GetBuffer(IBuffer* target) { target->SetSampleRate(frameInfo.samplerate); target->SetChannels(frameInfo.channels); target->SetSamples(frameInfo.samples / frameInfo.channels); - + memcpy( static_cast(target->BufferPointer()), static_cast(sampleBuffer), diff --git a/src/contrib/aacdecoder/CMakeLists.txt b/src/contrib/aacdecoder/CMakeLists.txt index c8d93f6ff..85d7ea4b0 100644 --- a/src/contrib/aacdecoder/CMakeLists.txt +++ b/src/contrib/aacdecoder/CMakeLists.txt @@ -1,33 +1,21 @@ -set ( aacdecoder_SOURCES - aacdecoder_plugin.cpp - AACSourceSupplier.cpp - stdafx.cpp - drms.c - m4aAudioSource.cpp - mp4atom.c - mp4ff.c - mp4meta.c - mp4sample.c - mp4tagupdate.c - mp4util.c - ) - -if(CMAKE_SYSTEM_NAME MATCHES "Windows") - add_definitions(-DWIN32) - if(NOT DEFINED MINGW) - - endif(NOT DEFINED MINGW) -else(CMAKE_SYSTEM_NAME MATCHES "Windows") - set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fpermissive) -endif(CMAKE_SYSTEM_NAME MATCHES "Windows") - -add_definitions( - -DXML_STATIC - -D_CRT_SECURE_NO_DEPRECATE - -D_DEBUG +set (aacdecoder_SOURCES + aacdecoder_plugin.cpp + AacDecoderFactory.cpp + AacDecoder.cpp + stdafx.cpp + drms/drms.c + mp4ff/mp4atom.c + mp4ff/mp4ff.c + mp4ff/mp4meta.c + mp4ff/mp4sample.c + mp4ff/mp4tagupdate.c + mp4ff/mp4util.c ) -add_library( aacdecoder SHARED ${aacdecoder_SOURCES} ) -target_link_libraries( aacdecoder ${musikCube_LINK_LIBS}) - +include_directories( + "${CMAKE_CURRENT_SOURCE_DIR}/drms" + "${CMAKE_CURRENT_SOURCE_DIR}/mp4ff" +) +add_library(aacdecoder SHARED ${aacdecoder_SOURCES}) +target_link_libraries(aacdecoder ${musikbox_LINK_LIBS} faad) diff --git a/src/contrib/aacdecoder/aacdecoder.vcproj b/src/contrib/aacdecoder/aacdecoder.vcproj index 1d2673876..99ec62802 100644 --- a/src/contrib/aacdecoder/aacdecoder.vcproj +++ b/src/contrib/aacdecoder/aacdecoder.vcproj @@ -606,7 +606,7 @@ > - + @@ -206,4 +206,4 @@ - \ No newline at end of file + diff --git a/src/contrib/aacdecoder/aacdecoder.vcxproj.filters b/src/contrib/aacdecoder/aacdecoder.vcxproj.filters index 2f8137bd9..b328ce7e9 100755 --- a/src/contrib/aacdecoder/aacdecoder.vcxproj.filters +++ b/src/contrib/aacdecoder/aacdecoder.vcxproj.filters @@ -219,7 +219,7 @@ - + plugin @@ -364,4 +364,4 @@ plugin - \ No newline at end of file + diff --git a/src/contrib/aacdecoder/accdecoder_plugin.cpp b/src/contrib/aacdecoder/aacdecoder_plugin.cpp similarity index 97% rename from src/contrib/aacdecoder/accdecoder_plugin.cpp rename to src/contrib/aacdecoder/aacdecoder_plugin.cpp index 974a1ac2e..8e41d7c22 100644 --- a/src/contrib/aacdecoder/accdecoder_plugin.cpp +++ b/src/contrib/aacdecoder/aacdecoder_plugin.cpp @@ -1,68 +1,68 @@ -////////////////////////////////////////////////////////////////////////////// -// -// License Agreement: -// -// The following are Copyright © 2008, Björn Olievier -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// * Neither the name of the author nor the names of other contributors may -// be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" - -#include "AacDecoderFactory.h" -#include - -#ifdef WIN32 -#define DLLEXPORT __declspec(dllexport) -#else -#define DLLEXPORT -#endif - -#ifdef WIN32 -BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { - return true; -} -#endif - -class AacDecoderPlugin : public musik::core::IPlugin { - public: - virtual void Destroy() { delete this; }; - virtual const char* Name() { return "AAC IDecoder"; }; - virtual const char* Version() { return "0.2"; }; - virtual const char* Author() { return "Björn Olievier, clangen"; }; -}; - -extern "C" DLLEXPORT musik::core::IPlugin* GetPlugin() { - return new AacDecoderPlugin(); -} - -extern "C" DLLEXPORT musik::core::audio::IDecoderFactory* GetDecoderFactory() { - return new AacDecoderFactory(); -} +////////////////////////////////////////////////////////////////////////////// +// +// License Agreement: +// +// The following are Copyright © 2008, Björn Olievier +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the author nor the names of other contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" + +#include "AacDecoderFactory.h" +#include + +#ifdef WIN32 +#define DLLEXPORT __declspec(dllexport) +#else +#define DLLEXPORT +#endif + +#ifdef WIN32 +BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + return true; +} +#endif + +class AacDecoderPlugin : public musik::core::IPlugin { + public: + virtual void Destroy() { delete this; }; + virtual const char* Name() { return "AAC IDecoder"; }; + virtual const char* Version() { return "0.2"; }; + virtual const char* Author() { return "Björn Olievier, clangen"; }; +}; + +extern "C" DLLEXPORT musik::core::IPlugin* GetPlugin() { + return new AacDecoderPlugin(); +} + +extern "C" DLLEXPORT musik::core::audio::IDecoderFactory* GetDecoderFactory() { + return new AacDecoderFactory(); +} diff --git a/src/contrib/aacdecoder/drms/config.h b/src/contrib/aacdecoder/drms/config.h new file mode 100644 index 000000000..e69de29bb diff --git a/src/contrib/aacdecoder/drms.c b/src/contrib/aacdecoder/drms/drms.c similarity index 100% rename from src/contrib/aacdecoder/drms.c rename to src/contrib/aacdecoder/drms/drms.c diff --git a/src/contrib/aacdecoder/drms.h b/src/contrib/aacdecoder/drms/drms.h similarity index 100% rename from src/contrib/aacdecoder/drms.h rename to src/contrib/aacdecoder/drms/drms.h diff --git a/src/contrib/aacdecoder/drmstables.h b/src/contrib/aacdecoder/drms/drmstables.h similarity index 100% rename from src/contrib/aacdecoder/drmstables.h rename to src/contrib/aacdecoder/drms/drmstables.h diff --git a/src/contrib/aacdecoder/mp4ff/config.h b/src/contrib/aacdecoder/mp4ff/config.h new file mode 100644 index 000000000..e69de29bb