- more work to adopt command line aqua-wb for analysis
This commit is contained in:
parent
1b6d548448
commit
434fa71937
|
|
@ -158,6 +158,101 @@ float PvqaUtility::process(const std::string& filepath, std::string& outputRepor
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------- AquaUtility -----------------
|
||||||
|
AquaUtility::AquaUtility()
|
||||||
|
{}
|
||||||
|
|
||||||
|
AquaUtility::~AquaUtility()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void AquaUtility::setPath(const std::string& path)
|
||||||
|
{
|
||||||
|
mAquaPath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string AquaUtility::getPath() const
|
||||||
|
{
|
||||||
|
return mAquaPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AquaUtility::setLicensePath(const std::string& path)
|
||||||
|
{
|
||||||
|
mLicensePath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string AquaUtility::getLicensePath() const
|
||||||
|
{
|
||||||
|
return mLicensePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AquaUtility::setConfigLine(const std::string& line)
|
||||||
|
{
|
||||||
|
mConfigLine = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string AquaUtility::getConfigLine() const
|
||||||
|
{
|
||||||
|
return mConfigLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
float AquaUtility::compare(const std::string& src_path, const std::string& dst_path, std::string& output_report)
|
||||||
|
{
|
||||||
|
float result = 0.0f;
|
||||||
|
|
||||||
|
// Generate temporary filename to receive .csv file
|
||||||
|
char spectrum_filename[L_tmpnam], report_filename[L_tmpnam];
|
||||||
|
tmpnam(spectrum_filename);
|
||||||
|
tmpnam(report_filename);
|
||||||
|
|
||||||
|
std::string config_line = mConfigLine;
|
||||||
|
StringHelper::replace(config_line, ":src_file", "\"" + src_path + "\"");
|
||||||
|
StringHelper::replace(config_line, ":tst_file", "\"" + dst_path + "\"");
|
||||||
|
StringHelper::replace(config_line, ":spectrum_file", spectrum_filename);
|
||||||
|
StringHelper::replace(config_line, ":report_file", report_filename);
|
||||||
|
StringHelper::replace(config_line, ":license_file", "\"" + mLicensePath + "\"");
|
||||||
|
|
||||||
|
// Build command line
|
||||||
|
char cmdbuffer[2048];
|
||||||
|
sprintf(cmdbuffer, "\"%s\" %s", mAquaPath.c_str(), config_line.c_str());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::string output = execCommand(cmdbuffer);
|
||||||
|
|
||||||
|
std::string line;
|
||||||
|
std::istringstream is(output);
|
||||||
|
std::string estimation;
|
||||||
|
while (std::getline(is, line))
|
||||||
|
{
|
||||||
|
std::string::size_type mosPosition = line.find("MOS value ");
|
||||||
|
if ( mosPosition != std::string::npos)
|
||||||
|
{
|
||||||
|
estimation = line.substr(mosPosition + 6);
|
||||||
|
estimation = StringHelper::trim(estimation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!estimation.size())
|
||||||
|
throw std::runtime_error("Bad response from pvqa: " + output);
|
||||||
|
|
||||||
|
result = std::stof(estimation);
|
||||||
|
|
||||||
|
// Read intervals report file
|
||||||
|
std::ifstream t(report_filename);
|
||||||
|
std::string str((std::istreambuf_iterator<char>(t)),
|
||||||
|
std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
|
output_report = str;
|
||||||
|
::remove(report_filename);
|
||||||
|
::remove(report_filename);
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << e.what() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------- SevanaMosUtility --------------
|
// -------------- SevanaMosUtility --------------
|
||||||
void SevanaMosUtility::run(const std::string& pcmPath, const std::string& intervalPath,
|
void SevanaMosUtility::run(const std::string& pcmPath, const std::string& intervalPath,
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,15 @@
|
||||||
|
|
||||||
namespace MT
|
namespace MT
|
||||||
{
|
{
|
||||||
enum class ReportType
|
enum class ReportType
|
||||||
{
|
{
|
||||||
PlainText,
|
PlainText,
|
||||||
Html
|
Html
|
||||||
};
|
};
|
||||||
|
|
||||||
class PvqaUtility
|
class PvqaUtility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PvqaUtility();
|
PvqaUtility();
|
||||||
~PvqaUtility();
|
~PvqaUtility();
|
||||||
|
|
||||||
|
|
@ -45,34 +45,54 @@ namespace MT
|
||||||
void setConfigPath(const std::string& path);
|
void setConfigPath(const std::string& path);
|
||||||
std::string getConfigPath() const;
|
std::string getConfigPath() const;
|
||||||
|
|
||||||
float process(const std::string& filepath, std::string& outputReport);
|
float process(const std::string& path, std::string& report);
|
||||||
|
private:
|
||||||
private:
|
|
||||||
std::string mPvqaPath, mLicensePath, mConfigPath;
|
std::string mPvqaPath, mLicensePath, mConfigPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(USE_PVQA_LIBRARY)
|
class AquaUtility
|
||||||
class SevanaMosUtility
|
{
|
||||||
{
|
public:
|
||||||
public:
|
AquaUtility();
|
||||||
|
~AquaUtility();
|
||||||
|
|
||||||
|
void setPath(const std::string& path);
|
||||||
|
std::string getPath() const;
|
||||||
|
|
||||||
|
void setLicensePath(const std::string& path);
|
||||||
|
std::string getLicensePath() const;
|
||||||
|
|
||||||
|
void setConfigLine(const std::string& line);
|
||||||
|
std::string getConfigLine() const;
|
||||||
|
|
||||||
|
float compare(const std::string& src, const std::string& dst, std::string& outputReport);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string mAquaPath, mLicensePath, mConfigLine;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(USE_PVQA_LIBRARY)
|
||||||
|
class SevanaMosUtility
|
||||||
|
{
|
||||||
|
public:
|
||||||
// Returns MOS estimation as text representation of float value or "failed" word.
|
// Returns MOS estimation as text representation of float value or "failed" word.
|
||||||
static void run(const std::string& pcmPath, const std::string& intervalPath,
|
static void run(const std::string& pcmPath, const std::string& intervalPath,
|
||||||
std::string& estimation, std::string& intervals);
|
std::string& estimation, std::string& intervals);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern float getSevanaMos(const std::string& audioPath, const std::string& intervalReportPath,
|
extern float getSevanaMos(const std::string& audioPath, const std::string& intervalReportPath,
|
||||||
std::string& intervalReport);
|
std::string& intervalReport);
|
||||||
|
|
||||||
class SevanaPVQA
|
class SevanaPVQA
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class Model
|
enum class Model
|
||||||
{
|
{
|
||||||
Stream,
|
Stream,
|
||||||
Interval
|
Interval
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void* mLibraryConfiguration;
|
static void* mLibraryConfiguration;
|
||||||
static int mLibraryErrorCode;
|
static int mLibraryErrorCode;
|
||||||
static std::atomic_int mInstanceCounter;
|
static std::atomic_int mInstanceCounter;
|
||||||
|
|
@ -89,14 +109,14 @@ namespace MT
|
||||||
std::string mDumpWavPath;
|
std::string mDumpWavPath;
|
||||||
bool mOpenFailed = false;
|
bool mOpenFailed = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::string getVersion();
|
static std::string getVersion();
|
||||||
|
|
||||||
// Required to call before any call to SevanaPVQA instance methods
|
// Required to call before any call to SevanaPVQA instance methods
|
||||||
|
|
||||||
#if defined(TARGET_ANDROID)
|
#if defined(TARGET_ANDROID)
|
||||||
static void setupAndroidEnvironment(void* environment, void* appcontext);
|
static void setupAndroidEnvironment(void* environment, void* appcontext);
|
||||||
#endif
|
#endif
|
||||||
static bool initializeLibrary(const std::string& pathToLicenseFile, const std::string& pathToConfigFile);
|
static bool initializeLibrary(const std::string& pathToLicenseFile, const std::string& pathToConfigFile);
|
||||||
static bool isInitialized();
|
static bool isInitialized();
|
||||||
|
|
||||||
|
|
@ -149,20 +169,20 @@ namespace MT
|
||||||
int getSize() const;
|
int getSize() const;
|
||||||
|
|
||||||
static std::string mosToColor(float mos);
|
static std::string mosToColor(float mos);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<SevanaPVQA> PSevanaPVQA;
|
typedef std::shared_ptr<SevanaPVQA> PSevanaPVQA;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_AQUA_LIBRARY)
|
#if defined(USE_AQUA_LIBRARY)
|
||||||
class SevanaAqua
|
class SevanaAqua
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
void* mContext = nullptr;
|
void* mContext = nullptr;
|
||||||
std::mutex mMutex;
|
std::mutex mMutex;
|
||||||
std::string mTempPath;
|
std::string mTempPath;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Returns 0 (zero) on successful initialization, otherwise it is error code
|
// Returns 0 (zero) on successful initialization, otherwise it is error code
|
||||||
static int initializeLibrary(const std::string& pathToLicenseFile);
|
static int initializeLibrary(const std::string& pathToLicenseFile);
|
||||||
static void releaseLibrary();
|
static void releaseLibrary();
|
||||||
|
|
@ -252,9 +272,9 @@ namespace MT
|
||||||
};
|
};
|
||||||
|
|
||||||
CompareResult compare(AudioBuffer& reference, AudioBuffer& test);
|
CompareResult compare(AudioBuffer& reference, AudioBuffer& test);
|
||||||
};
|
};
|
||||||
typedef std::shared_ptr<SevanaAqua> PSevanaAqua;
|
typedef std::shared_ptr<SevanaAqua> PSevanaAqua;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue