diff options
author | ghost <c42723f8913e7023435c322995e52208d7cf860640ca75118f526cca77cb5bab@yggmail> | 2022-01-05 00:35:26 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2022-02-20 01:05:40 +0300 |
commit | a8690dd6b204eae3a5e8d8466aa2abab73cdad48 (patch) | |
tree | 1d71801a076f9d5f1fe549132c920a71b36a29d5 /src/main.cpp | |
parent | cf8f27830d19e5ec2524a9dc6b50c8a30869917f (diff) | |
download | atracdenc-a8690dd6b204eae3a5e8d8466aa2abab73cdad48.tar.gz |
Support for RealMedia output file format.
ATRAC3 is one of codecs used for RealMedia player.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp index c7d2eec..e7492a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,7 @@ #include "pcmengin.h" #include "wav.h" #include "aea.h" +#include "rm.h" #include "config.h" #include "atrac1denc.h" #include "atrac3denc.h" @@ -78,6 +79,15 @@ static string GetHelp() /*"\n --nogaincontrol disable gain control (ATRAC3)"*/ } +static string GetFileExt(const string& path) { + size_t dotPos = path.rfind('.'); + std::string ext; + if (dotPos != std::string::npos && dotPos < path.size()) { + ext = path.substr(dotPos + 1); + } + return ext; +} + static int checkedStoi(const char* data, int min, int max, int def) { int tmp = 0; @@ -197,17 +207,30 @@ static void PrepareAtrac3Encoder(const string& inFile, std::cout << "bitrate " << encoderSettings.ConteinerParams->Bitrate << std::endl; const int numChannels = encoderSettings.SourceChannels; *totalSamples = wavIO->GetTotalSamples(); - const uint64_t numFrames = numChannels * ((*totalSamples) / 512); + const uint64_t numFrames = (*totalSamples) / 1024; if (numFrames >= UINT32_MAX) { std::cerr << "Number of input samples exceeds output format limitation," "the result will be incorrect" << std::endl; } - TCompressedOutputPtr omaIO = TCompressedOutputPtr(new TOma(outFile, - "test", - numChannels, - (int32_t)numFrames, OMAC_ID_ATRAC3, - encoderSettings.ConteinerParams->FrameSz, - encoderSettings.ConteinerParams->Js)); + + const string ext = GetFileExt(outFile); + + TCompressedOutputPtr omaIO; + + if (ext == "rm") { + omaIO = CreateRmOutput(outFile, "test", numChannels, + numFrames, encoderSettings.ConteinerParams->FrameSz, + encoderSettings.ConteinerParams->Js); + } else { + + omaIO.reset(new TOma(outFile, + "test", + numChannels, + (int32_t)numFrames, OMAC_ID_ATRAC3, + encoderSettings.ConteinerParams->FrameSz, + encoderSettings.ConteinerParams->Js)); + } + pcmEngine->reset(new TPCMEngine<TFloat>(4096, numChannels, TPCMEngine<TFloat>::TReaderPtr(wavIO->GetPCMReader<TFloat>()))); |