diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2018-04-03 11:47:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-03 11:47:31 +0300 |
commit | 8ec37180923dd976bc60b379d2940988b94da2fc (patch) | |
tree | 2edf7bbff2d185c886b7df1156bd26e2f349c4cf | |
parent | b85ed3f574be226fe5fa4ccc56bd07af33095945 (diff) | |
parent | f34037f57825a62a1efad991dc9d257a84dedfe0 (diff) | |
download | atracdenc-8ec37180923dd976bc60b379d2940988b94da2fc.tar.gz |
Merge pull request #4 from vuori/feature/encode-arg-parsing
Feature/encode arg parsing
-rw-r--r-- | src/atrac3denc.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 17 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/atrac3denc.cpp b/src/atrac3denc.cpp index f0894d5..202e10e 100644 --- a/src/atrac3denc.cpp +++ b/src/atrac3denc.cpp @@ -142,7 +142,7 @@ TAtrac3Data::TTonalComponents TAtrac3Processor::ExtractTonalComponents(TFloat* s const uint16_t specNumStart = SpecsStartLong[blockNum]; const uint16_t specNumEnd = specNumStart + SpecsPerBlock[blockNum]; float level = fn(specs + specNumStart, SpecsPerBlock[blockNum]); - if (!isnan(level)) { + if (!std::isnan(level)) { for (uint16_t n = specNumStart; n < specNumEnd; ++n) { //TODO: TFloat absValue = std::abs(specs[n]); diff --git a/src/main.cpp b/src/main.cpp index 4a8daef..51a2cac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,8 +42,8 @@ typedef std::unique_ptr<IProcessor<TFloat>> TAtracProcessorPtr; static void printUsage(const char* myName) { - cout << "\tusage: " << myName << " <-e|-d> <-i input> <-o output>\n" << endl; - cout << "-e encode mode (PCM -> ATRAC), -i wav file, -o aea file" << endl; + cout << "\tusage: " << myName << " <-e <atrac1|atrac3>|-d> <-i input> <-o output>\n" << endl; + cout << "-e atrac1|atrac3 encode mode (PCM -> ATRAC), -i wav file, -o aea/oma file" << endl; cout << "-d decode mode (ATRAC -> PCM), -i aea file, -o wav file" << endl; cout << "-h get help" << endl; @@ -60,8 +60,8 @@ static void printProgress(int percent) static string GetHelp() { - return "\n--encode -e \t - encode mode" - "\n--decode -d \t - decode mode" + return "\n--encode [atrac1|atrac3] -e <atrac1|atrac3> \t - encode mode (default codec is ATRAC1)" + "\n--decode -d \t - decode mode (only ATRAC1 supported)" "\n -i input file" "\n -o output file" "\n --bitrate (only if supported by codec)" @@ -233,9 +233,16 @@ int main(int argc, char* const* argv) switch (ch) { case O_ENCODE: mode |= E_ENCODE; + // if arg is given, it must specify the codec; otherwise use atrac1 if (optarg) { if (strcmp(optarg, "atrac3") == 0) { mode |= E_ATRAC3; + } else if (strcmp(optarg, "atrac1") == 0) { + // this is the default + } else { + // bad value + printUsage(myName); + return 1; } } break; @@ -283,7 +290,7 @@ int main(int argc, char* const* argv) case O_NOGAINCONTROL: noGainControl = true; break; - default: + default: printUsage(myName); return 1; } |