1 /* linearPrediction.h - header file for class providing linear prediction capability 2 * written by C. R. Helmrich, last modified in 2020 - see License.htm for legal notices 3 * 4 * The copyright in this software is being made available under the exhale Copyright License 5 * and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third- 6 * party rights, including patent rights. No such rights are granted under this License. 7 * 8 * Copyright (c) 2018-2021 Christian R. Helmrich, project ecodis. All rights reserved. 9 */ 10 11 #ifndef _LINEAR_PREDICTION_H_ 12 #define _LINEAR_PREDICTION_H_ 13 14 #include "exhaleLibPch.h" 15 16 // constants, experimental macros 17 #define LP_EPS 1 18 #define LP_SHIFT 15 19 #define LP_DEPTH (1 + LP_SHIFT - MAX_PREDICTION_ORDER) 20 #define LP_OFFSET (1 << (LP_SHIFT - 1)) 21 22 // linear predictive filter class 23 class LinearPredictor 24 { 25 private: 26 27 // temporary buffer 28 int64_t m_tempBuf[2 * MAX_PREDICTION_ORDER]; 29 30 public: 31 32 // constructor 33 LinearPredictor (); 34 // destructor ~LinearPredictor()35 ~LinearPredictor () { } 36 // public functions 37 uint32_t calcParCorCoeffs (const int32_t* const anaSignal, const uint16_t nAnaSamples, const uint16_t nCoeffs, 38 short* const parCorCoeffs); // returns 256 - 256 / prediction gain per filter order, or 0 39 uint8_t calcOptTnsCoeffs (short* const parCorCoeffs, int8_t* const quantCoeffs, bool* const lowCoeffRes, 40 const uint16_t maxOrder, const uint8_t predGain, const uint8_t tonality = 0, 41 const uint16_t parCorCoeffBitDepth = 10); // returns optimized filter order for TNS 42 unsigned lpToParCorCoeffs (short* const lpCoeffs, const uint16_t nCoeffs, short* const parCorCoeffs, 43 const uint16_t parCorCoeffBitDepth = 10); 44 unsigned parCorToLpCoeffs (const short* const parCorCoeffs, const uint16_t nCoeffs, short* const lpCoeffs, 45 const uint16_t parCorCoeffBitDepth = 10); 46 unsigned quantTnsToLpCoeffs(const int8_t* const quantCoeffs, const uint16_t nCoeffs, const bool lowCoeffRes, 47 short* const parCorCoeffs, short* const lpCoeffs); 48 bool similarParCorCoeffs (const short* const parCorCoeffs1, const short* const parCorCoeffs2, const uint16_t nCoeffs, 49 const uint16_t parCorCoeffBitDepth = 10); 50 }; // LinearPredictor 51 52 #endif // _LINEAR_PREDICTION_H_ 53