Skip to content

Commit ed96293

Browse files
committed
Support for MS Windows platform
- VS build (2017 tested) - Media Foundation Framework support to read/write pcm data (instead of libsndfile)
1 parent 218e216 commit ed96293

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1491
-142
lines changed

CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
22

3-
add_subdirectory(3rd/gtest-1.7.0)
3+
if (UNIX)
4+
add_subdirectory(3rd/gtest-1.7.0)
5+
add_subdirectory(test)
6+
endif()
47
add_subdirectory(src)
5-
add_subdirectory(test)

src/CMakeLists.txt

+27-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
1+
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
22

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

20-
add_definitions( "-Wall -O2 -g" )
20+
if (UNIX)
21+
add_definitions( "-Wall -O2 -g" )
22+
endif()
2123

2224
project(atracdenc)
2325

2426
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
25-
INCLUDE(FindLibSndFile)
2627

27-
include_directories(${LIBSNDFILE_INCLUDE_DIR})
28+
if (WIN32)
29+
add_compile_definitions(PLATFORM_WINDOWS)
30+
include_directories("platform/win/getopt")
31+
set(SOURCE_PCM_IO_LIB
32+
platform/win/pcm_io_mf/pcm_io_mf.cpp
33+
)
34+
else()
35+
INCLUDE(FindLibSndFile)
36+
include_directories(${LIBSNDFILE_INCLUDE_DIR})
37+
set(SOURCE_PCM_IO_LIB
38+
pcm_io_sndfile.cpp
39+
)
40+
endif()
41+
42+
include (TestBigEndian)
43+
TEST_BIG_ENDIAN(BIGENDIAN_ORDER)
44+
if (${BIGENDIAN})
45+
add_compile_definitions(BIGENDIAN_ORDER)
46+
endif()
47+
2848
include_directories("oma/liboma/include")
2949

3050
set(SOURCE_FFT_LIB fft/kissfft_impl/kiss_fft.c)
@@ -34,6 +54,7 @@ set(SOURCE_EXE
3454
main.cpp
3555
wav.cpp
3656
aea.cpp
57+
env.cpp
3758
transient_detector.cpp
3859
atrac1denc.cpp
3960
bitstream/bitstream.cpp
@@ -50,7 +71,8 @@ set(SOURCE_EXE
5071
)
5172

5273
add_library(fft_impl STATIC ${SOURCE_FFT_LIB})
74+
add_library(pcm_io STATIC ${SOURCE_PCM_IO_LIB})
5375
add_library(oma STATIC ${SOURCE_OMA_LIB})
5476
add_executable(atracdenc ${SOURCE_EXE})
55-
target_link_libraries(atracdenc fft_impl oma ${SNDFILE_LIBRARIES})
77+
target_link_libraries(atracdenc fft_impl pcm_io oma ${SNDFILE_LIBRARIES})
5678

src/aea.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

@@ -24,9 +24,8 @@
2424

2525
using std::string;
2626

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

4645
TAea::TMeta TAea::CreateMeta(const string& filename, const string& title, int channelNum, uint32_t numFrames) {
47-
FILE* fp = fopen(filename.c_str(), "w");
46+
FILE* fp = fopen(filename.c_str(), "wb");
4847
if (!fp)
4948
throw TAeaIOError("Can't open file to write", errno);
5049
std::array<char, AeaMetaSize> buf;

src/aea.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac/atrac1.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac/atrac1.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

@@ -22,6 +22,7 @@
2222
#include <map>
2323
#include <math.h>
2424
#include "../bitstream/bitstream.h"
25+
#include "../config.h"
2526
namespace NAtracDEnc {
2627
namespace NAtrac1 {
2728

src/atrac/atrac1_bitalloc.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

@@ -23,6 +23,7 @@
2323
#include <math.h>
2424
#include <cassert>
2525
#include "../bitstream/bitstream.h"
26+
#include "../env.h"
2627

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

221+
TAtrac1BitStreamWriter::TAtrac1BitStreamWriter(TAea* container)
222+
: Container(container)
223+
{
224+
NEnv::SetRoundFloat();
225+
};
226+
220227
void TAtrac1BitStreamWriter::WriteBitStream(const vector<uint32_t>& bitsPerEachBlock,
221228
const std::vector<TScaledBlock>& scaledBlocks,
222229
uint32_t bfuAmountIdx,

src/atrac/atrac1_bitalloc.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

@@ -24,7 +24,6 @@
2424
#include <vector>
2525
#include <map>
2626
#include <cstdint>
27-
#include <cfenv>
2827

2928
namespace NAtracDEnc {
3029
namespace NAtrac1 {
@@ -50,11 +49,8 @@ class TBitsBooster : public virtual TAtrac1Data {
5049
class TAtrac1BitStreamWriter : public virtual TAtrac1Data {
5150
TAea* Container;
5251
public:
53-
explicit TAtrac1BitStreamWriter(TAea* container)
54-
: Container(container)
55-
{
56-
fesetround(FE_TONEAREST);
57-
};
52+
explicit TAtrac1BitStreamWriter(TAea* container);
53+
5854
void WriteBitStream(const std::vector<uint32_t>& bitsPerEachBlock, const std::vector<TScaledBlock>& scaledBlocks,
5955
uint32_t bfuAmountIdx, const TBlockSize& blockSize);
6056
};

src/atrac/atrac1_dequantiser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac/atrac1_dequantiser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac/atrac1_qmf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac/atrac3.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac/atrac3.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

1919
#pragma once
20+
#include "../config.h"
2021
#include <math.h>
2122
#include <cstdint>
2223
#include <vector>

src/atrac/atrac3_bitstream.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

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

199-
auto allocation = CreateAllocation(sce, bitsUsed, mt);
199+
const auto& allocation = CreateAllocation(sce, bitsUsed, mt);
200200
const vector<uint32_t>& precisionPerEachBlocks = allocation.second;
201201
EncodeTonalComponents(sce, precisionPerEachBlocks, bitStream);
202202
const uint32_t numBlocks = precisionPerEachBlocks.size(); //number of blocks to save
@@ -471,7 +471,7 @@ void TAtrac3BitStreamWriter::WriteSoundUnit(const vector<TSingleChannelElement>&
471471
assert(s < 8);
472472
}
473473
}
474-
const uint16_t bitsUsedByGainInfoAndHeader = bitStream->GetSizeInBits();
474+
const uint16_t bitsUsedByGainInfoAndHeader = (uint16_t)bitStream->GetSizeInBits();
475475
usedBits[channel] = bitsUsedByGainInfoAndHeader;
476476
assert(bitStream->GetSizeInBits() == usedBits[channel]);
477477
}

src/atrac/atrac3_bitstream.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

@@ -25,7 +25,7 @@
2525
#include "atrac_scale.h"
2626
#include <vector>
2727
#include <utility>
28-
#include <cfenv>
28+
#include "../env.h"
2929

3030
namespace NAtracDEnc {
3131
namespace NAtrac3 {
@@ -89,7 +89,7 @@ class TAtrac3BitStreamWriter : public virtual TAtrac3Data {
8989
, Params(params)
9090
, BfuIdxConst(bfuIdxConst)
9191
{
92-
fesetround(FE_TONEAREST);
92+
NEnv::SetRoundFloat();
9393
}
9494

9595
void WriteSoundUnit(const std::vector<TSingleChannelElement>& singleChannelElements);

src/atrac/atrac3_qmf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac/atrac_psy_common.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac/atrac_psy_common.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac/atrac_scale.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac/atrac_scale.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac1denc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

src/atrac1denc.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

1919
#pragma once
2020
#include "pcmengin.h"
2121
#include "aea.h"
2222
#include "oma.h"
23-
#include "atrac_encode_settings.h"
2423
#include "transient_detector.h"
2524
#include "atrac/atrac1.h"
2625
#include "atrac/atrac1_qmf.h"

src/atrac3denc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Lesser General Public License for more details.
1313
*
1414
* You should have received a copy of the GNU Lesser General Public
15-
* License along with FFmpeg; if not, write to the Free Software
15+
* License along with AtracDEnc; if not, write to the Free Software
1616
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

0 commit comments

Comments
 (0)