From 583bd0e47c0d3c579c9e5b716e112cc4ab5c6960 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 11 Sep 2022 21:07:47 -0700 Subject: Ensure coeff_scale is set for ambdec files --- core/ambdec.cpp | 15 ++++++++++----- core/ambdec.h | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/ambdec.cpp b/core/ambdec.cpp index e40b3868..31eaf391 100644 --- a/core/ambdec.cpp +++ b/core/ambdec.cpp @@ -220,8 +220,6 @@ al::optional AmbDecConf::load(const char *fname) noexcept if(!ChanMask) return al::make_optional("Invalid chan_mask: "+std::to_string(ChanMask)); - if(ChanMask > Ambi3OrderMask && CoeffScale == AmbDecScale::FuMa) - return al::make_optional("FuMa not compatible with over third-order"); } else if(command == "/dec/freq_bands") { @@ -252,15 +250,15 @@ al::optional AmbDecConf::load(const char *fname) noexcept } else if(command == "/dec/coeff_scale") { + if(CoeffScale != AmbDecScale::Unset) + return al::make_optional("Duplicate coeff_scale"); + std::string scale = read_word(istr); if(scale == "n3d") CoeffScale = AmbDecScale::N3D; else if(scale == "sn3d") CoeffScale = AmbDecScale::SN3D; else if(scale == "fuma") CoeffScale = AmbDecScale::FuMa; else return al::make_optional("Unexpected coeff_scale: "+scale); - - if(ChanMask > Ambi3OrderMask && CoeffScale == AmbDecScale::FuMa) - return al::make_optional("FuMa not compatible with over third-order"); } else if(command == "/opt/xover_freq") { @@ -362,8 +360,15 @@ al::optional AmbDecConf::load(const char *fname) noexcept if(!is_at_end(buffer, endpos)) return al::make_optional("Extra junk on end: " + buffer.substr(endpos)); + if(ChanMask == 0) + return al::make_optional("No channel mask defined"); if(!speakers_loaded || !matrix_loaded || (FreqBands == 2 && !lfmatrix_loaded)) return al::make_optional("No decoder defined"); + if(CoeffScale == AmbDecScale::Unset) + return al::make_optional("No coefficient scaling defined"); + + if(ChanMask > Ambi3OrderMask && CoeffScale == AmbDecScale::FuMa) + return al::make_optional("FuMa not compatible with over third-order"); return al::nullopt; } diff --git a/core/ambdec.h b/core/ambdec.h index e1bcde26..7f739781 100644 --- a/core/ambdec.h +++ b/core/ambdec.h @@ -11,6 +11,7 @@ /* Helpers to read .ambdec configuration files. */ enum class AmbDecScale { + Unset, N3D, SN3D, FuMa, @@ -21,7 +22,7 @@ struct AmbDecConf { unsigned int ChanMask{0u}; unsigned int FreqBands{0u}; /* Must be 1 or 2 */ - AmbDecScale CoeffScale{}; + AmbDecScale CoeffScale{AmbDecScale::Unset}; float XOverFreq{0.0f}; float XOverRatio{0.0f}; -- cgit v1.2.3