Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed compilation errors on Linux, fixed progression message and added --help flag #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions src/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,27 @@ int CmdLine::Parse(int argc,char *argv[])
std::string key,val;
Split(uparam,key,val);
if (param.length()>1 && (param[0]=='-' && param[1]=='-')) {
if (key=="--ENCODE") mode=ENCODE;
else if (key=="--DECODE") mode=DECODE;
else if (key=="--LIST") mode=LIST;
else if (key=="--LISTFULL") mode=LISTFULL;
else if (key=="--NORMAL") opt.profile=0;
else if (key=="--HIGH") opt.profile=1;
else if (key=="--OPTIMIZE") {
opt.optimize=1;
if (val=="FAST") {
opt.optimize_mode=0;
} else if (val=="NORMAL") {
opt.optimize_mode=1;
} else if (val=="HIGH") {
opt.optimize_mode=2;
} else if (val=="VERYHIGH") {
opt.optimize_mode=3;
} else if (val=="INSANE") {
opt.optimize_mode=4;
} else std::cout << "warning: unknown optimize mode '" << val << "'\n";
}
else if (key=="--SPARSE-PCM") opt.sparse_pcm=1;
else std::cout << "warning: unknown option '" << param << "'\n";
if (key=="--HELP") {
std::cout << SACHelp;
return 1;
}
else if (key=="--ENCODE") mode=ENCODE;
else if (key=="--DECODE") mode=DECODE;
else if (key=="--LIST") mode=LIST;
else if (key=="--LISTFULL") mode=LISTFULL;
else if (key=="--NORMAL") opt.profile=0;
else if (key=="--HIGH") opt.profile=1;
else if (key=="--OPTIMIZE") {
opt.optimize=1;
if (val=="FAST") opt.optimize_mode=0;
else if (val=="NORMAL") opt.optimize_mode=1;
else if (val=="HIGH") opt.optimize_mode=2;
else if (val=="VERYHIGH") opt.optimize_mode=3;
else if (val=="INSANE") opt.optimize_mode=4;
else std::cout << "warning: unknown optimize mode '" << val << "'\n";
}
else if (key=="--SPARSE-PCM") opt.sparse_pcm=1;
else std::cout << "warning: unknown option '" << param << "'\n";
} else {
if (first) {sinputfile=param;first=false;}
else soutputfile=param;
Expand Down
3 changes: 2 additions & 1 deletion src/cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

const char SACHelp[] =
"usage: sac [--options] input output\n\n"
" --help print this message\n"
" --encode encode input.wav to output.sac (default)\n"
" --normal normal compression (default)\n"
" --high high compression, slow\n"
" --optimize=# enable frame-based optimization\n"
" --optimize=# enable frame-based optimization\n"
" #=fast|normal|high|veryhigh|insane\n"
" --sparse-pcm enable pcm modelling\n"
" --decode decode input.sac to output.wav\n"
Expand Down
1 change: 1 addition & 0 deletions src/common/bufio.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <vector>
#include <cstdint>
#include <cstddef>

class BufIO {
public:
Expand Down
1 change: 1 addition & 0 deletions src/file/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>
#include <vector>
#include <fstream>
#include <cstdint>

class AudioFile {
public:
Expand Down
1 change: 1 addition & 0 deletions src/file/sac.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "file.h"
#include "wav.h"
#include <cstdint>

struct tFrameHeader {

Expand Down
1 change: 1 addition & 0 deletions src/file/wav.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define WAV_H

#include "file.h"
#include <cstdint>

class Chunks {
public:
Expand Down
10 changes: 6 additions & 4 deletions src/libsac/libsac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "pred.h"
#include "../opt/dds.h"
#include "../common/timer.h"
#include <cstring>

FrameCoder::FrameCoder(int numchannels,int framesize,const coder_ctx &opt)
:numchannels_(numchannels),framesize_(framesize),opt(opt)
Expand Down Expand Up @@ -482,10 +483,10 @@ void FrameCoder::Optimize(SacProfile &profile,const std::vector<int>&params_to_o

CostFunction *CostFunc=nullptr;
switch (opt.optimize_cost) {
case opt.SearchCost::L1:CostFunc=new CostMeanRMS();break;
case opt.SearchCost::Golomb:CostFunc=new CostGolomb();break;
case opt.SearchCost::Entropy:CostFunc=new CostEntropyO0();break;
case opt.SearchCost::Bitplane:CostFunc=new CostBitplane();break;
case coder_ctx::SearchCost::L1:CostFunc=new CostMeanRMS();break;
case coder_ctx::SearchCost::Golomb:CostFunc=new CostGolomb();break;
case coder_ctx::SearchCost::Entropy:CostFunc=new CostEntropyO0();break;
case coder_ctx::SearchCost::Bitplane:CostFunc=new CostBitplane();break;
default:std::cerr << " error: unknown FramerCoder::CostFunction\n";return;
}

Expand Down Expand Up @@ -776,6 +777,7 @@ void Codec::PrintProgress(int samplesprocessed,int totalsamples)
{
double r=samplesprocessed*100.0/(double)totalsamples;
std::cout << " " << samplesprocessed << "/" << totalsamples << ":" << std::setw(6) << miscUtils::ConvertFixed(r,1) << "%\r";
std::cout.flush();
}

// fix-me
Expand Down