Skip to content

Commit

Permalink
Support for MS Windows platform
Browse files Browse the repository at this point in the history
- VS build (2017 tested)
- Media Foundation Framework support to read/write pcm data (instead of
libsndfile)
  • Loading branch information
dcherednik committed May 14, 2019
1 parent 218e216 commit ed96293
Show file tree
Hide file tree
Showing 61 changed files with 1,491 additions and 142 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

add_subdirectory(3rd/gtest-1.7.0)
if (UNIX)
add_subdirectory(3rd/gtest-1.7.0)
add_subdirectory(test)
endif()
add_subdirectory(src)
add_subdirectory(test)
32 changes: 27 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)

macro(use_11)
if (CMAKE_VERSION VERSION_LESS "3.1")
Expand All @@ -17,14 +17,34 @@ use_11()
#add_definitions( "-Wall -O2 -g -Rpass-analysis=loop-vectorize" )
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")

add_definitions( "-Wall -O2 -g" )
if (UNIX)
add_definitions( "-Wall -O2 -g" )
endif()

project(atracdenc)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
INCLUDE(FindLibSndFile)

include_directories(${LIBSNDFILE_INCLUDE_DIR})
if (WIN32)
add_compile_definitions(PLATFORM_WINDOWS)
include_directories("platform/win/getopt")
set(SOURCE_PCM_IO_LIB
platform/win/pcm_io_mf/pcm_io_mf.cpp
)
else()
INCLUDE(FindLibSndFile)
include_directories(${LIBSNDFILE_INCLUDE_DIR})
set(SOURCE_PCM_IO_LIB
pcm_io_sndfile.cpp
)
endif()

include (TestBigEndian)
TEST_BIG_ENDIAN(BIGENDIAN_ORDER)
if (${BIGENDIAN})
add_compile_definitions(BIGENDIAN_ORDER)
endif()

include_directories("oma/liboma/include")

set(SOURCE_FFT_LIB fft/kissfft_impl/kiss_fft.c)
Expand All @@ -34,6 +54,7 @@ set(SOURCE_EXE
main.cpp
wav.cpp
aea.cpp
env.cpp
transient_detector.cpp
atrac1denc.cpp
bitstream/bitstream.cpp
Expand All @@ -50,7 +71,8 @@ set(SOURCE_EXE
)

add_library(fft_impl STATIC ${SOURCE_FFT_LIB})
add_library(pcm_io STATIC ${SOURCE_PCM_IO_LIB})
add_library(oma STATIC ${SOURCE_OMA_LIB})
add_executable(atracdenc ${SOURCE_EXE})
target_link_libraries(atracdenc fft_impl oma ${SNDFILE_LIBRARIES})
target_link_libraries(atracdenc fft_impl pcm_io oma ${SNDFILE_LIBRARIES})

7 changes: 3 additions & 4 deletions src/aea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand All @@ -24,9 +24,8 @@

using std::string;


TAea::TMeta TAea::ReadMeta(const string& filename) {
FILE* fp = fopen(filename.c_str(), "r");
FILE* fp = fopen(filename.c_str(), "rb");
if (!fp)
throw TAeaIOError("Can't open file to read", errno);
std::array<char, AeaMetaSize> buf;
Expand All @@ -44,7 +43,7 @@ TAea::TMeta TAea::ReadMeta(const string& filename) {
}

TAea::TMeta TAea::CreateMeta(const string& filename, const string& title, int channelNum, uint32_t numFrames) {
FILE* fp = fopen(filename.c_str(), "w");
FILE* fp = fopen(filename.c_str(), "wb");
if (!fp)
throw TAeaIOError("Can't open file to write", errno);
std::array<char, AeaMetaSize> buf;
Expand Down
2 changes: 1 addition & 1 deletion src/aea.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
2 changes: 1 addition & 1 deletion src/atrac/atrac1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
3 changes: 2 additions & 1 deletion src/atrac/atrac1.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand All @@ -22,6 +22,7 @@
#include <map>
#include <math.h>
#include "../bitstream/bitstream.h"
#include "../config.h"
namespace NAtracDEnc {
namespace NAtrac1 {

Expand Down
9 changes: 8 additions & 1 deletion src/atrac/atrac1_bitalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand All @@ -23,6 +23,7 @@
#include <math.h>
#include <cassert>
#include "../bitstream/bitstream.h"
#include "../env.h"

namespace NAtracDEnc {
namespace NAtrac1 {
Expand Down Expand Up @@ -217,6 +218,12 @@ uint32_t TAtrac1SimpleBitAlloc::Write(const std::vector<TScaledBlock>& scaledBlo
return BfuAmountTab[bfuIdx];
}

TAtrac1BitStreamWriter::TAtrac1BitStreamWriter(TAea* container)
: Container(container)
{
NEnv::SetRoundFloat();
};

void TAtrac1BitStreamWriter::WriteBitStream(const vector<uint32_t>& bitsPerEachBlock,
const std::vector<TScaledBlock>& scaledBlocks,
uint32_t bfuAmountIdx,
Expand Down
10 changes: 3 additions & 7 deletions src/atrac/atrac1_bitalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand All @@ -24,7 +24,6 @@
#include <vector>
#include <map>
#include <cstdint>
#include <cfenv>

namespace NAtracDEnc {
namespace NAtrac1 {
Expand All @@ -50,11 +49,8 @@ class TBitsBooster : public virtual TAtrac1Data {
class TAtrac1BitStreamWriter : public virtual TAtrac1Data {
TAea* Container;
public:
explicit TAtrac1BitStreamWriter(TAea* container)
: Container(container)
{
fesetround(FE_TONEAREST);
};
explicit TAtrac1BitStreamWriter(TAea* container);

void WriteBitStream(const std::vector<uint32_t>& bitsPerEachBlock, const std::vector<TScaledBlock>& scaledBlocks,
uint32_t bfuAmountIdx, const TBlockSize& blockSize);
};
Expand Down
2 changes: 1 addition & 1 deletion src/atrac/atrac1_dequantiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
2 changes: 1 addition & 1 deletion src/atrac/atrac1_dequantiser.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
2 changes: 1 addition & 1 deletion src/atrac/atrac1_qmf.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
2 changes: 1 addition & 1 deletion src/atrac/atrac3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
3 changes: 2 additions & 1 deletion src/atrac/atrac3.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#pragma once
#include "../config.h"
#include <math.h>
#include <cstdint>
#include <vector>
Expand Down
6 changes: 3 additions & 3 deletions src/atrac/atrac3_bitstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down Expand Up @@ -196,7 +196,7 @@ void TAtrac3BitStreamWriter::EncodeSpecs(const TSingleChannelElement& sce, NBitS
int mt[MaxSpecs];
const vector<TScaledBlock>& scaledBlocks = sce.ScaledBlocks;

auto allocation = CreateAllocation(sce, bitsUsed, mt);
const auto& allocation = CreateAllocation(sce, bitsUsed, mt);
const vector<uint32_t>& precisionPerEachBlocks = allocation.second;
EncodeTonalComponents(sce, precisionPerEachBlocks, bitStream);
const uint32_t numBlocks = precisionPerEachBlocks.size(); //number of blocks to save
Expand Down Expand Up @@ -471,7 +471,7 @@ void TAtrac3BitStreamWriter::WriteSoundUnit(const vector<TSingleChannelElement>&
assert(s < 8);
}
}
const uint16_t bitsUsedByGainInfoAndHeader = bitStream->GetSizeInBits();
const uint16_t bitsUsedByGainInfoAndHeader = (uint16_t)bitStream->GetSizeInBits();
usedBits[channel] = bitsUsedByGainInfoAndHeader;
assert(bitStream->GetSizeInBits() == usedBits[channel]);
}
Expand Down
6 changes: 3 additions & 3 deletions src/atrac/atrac3_bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand All @@ -25,7 +25,7 @@
#include "atrac_scale.h"
#include <vector>
#include <utility>
#include <cfenv>
#include "../env.h"

namespace NAtracDEnc {
namespace NAtrac3 {
Expand Down Expand Up @@ -89,7 +89,7 @@ class TAtrac3BitStreamWriter : public virtual TAtrac3Data {
, Params(params)
, BfuIdxConst(bfuIdxConst)
{
fesetround(FE_TONEAREST);
NEnv::SetRoundFloat();
}

void WriteSoundUnit(const std::vector<TSingleChannelElement>& singleChannelElements);
Expand Down
2 changes: 1 addition & 1 deletion src/atrac/atrac3_qmf.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
2 changes: 1 addition & 1 deletion src/atrac/atrac_psy_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
2 changes: 1 addition & 1 deletion src/atrac/atrac_psy_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
2 changes: 1 addition & 1 deletion src/atrac/atrac_scale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
2 changes: 1 addition & 1 deletion src/atrac/atrac_scale.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
2 changes: 1 addition & 1 deletion src/atrac1denc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down
3 changes: 1 addition & 2 deletions src/atrac1denc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#pragma once
#include "pcmengin.h"
#include "aea.h"
#include "oma.h"
#include "atrac_encode_settings.h"
#include "transient_detector.h"
#include "atrac/atrac1.h"
#include "atrac/atrac1_qmf.h"
Expand Down
2 changes: 1 addition & 1 deletion src/atrac3denc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* License along with AtracDEnc; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down

0 comments on commit ed96293

Please sign in to comment.