diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2016-07-17 17:50:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2016-07-17 20:40:57 +0300 |
commit | 91a4ae90590356b513e5f882ff81a5ca9fda961d (patch) | |
tree | 040d60afe3e63ed773ff26f4391964f7a36ee916 /src/atrac3denc.h | |
parent | 3999450de0b6098d3d41549a58c3ff23cc0a565d (diff) | |
download | atracdenc-91a4ae90590356b513e5f882ff81a5ca9fda961d.tar.gz |
Experimental implementation of gain control.
Diffstat (limited to 'src/atrac3denc.h')
-rw-r--r-- | src/atrac3denc.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/atrac3denc.h b/src/atrac3denc.h index 5984728..4b0980c 100644 --- a/src/atrac3denc.h +++ b/src/atrac3denc.h @@ -30,8 +30,13 @@ public: using TGainDemodulator = TAtrac3GainProcessor::TGainDemodulator; typedef std::array<TGainDemodulator, 4> TGainDemodulatorArray; typedef std::array<TGainModulator, 4> TGainModulatorArray; - void Mdct(TFloat specs[1024], TFloat* bands[4], TGainModulatorArray gainModulators = TGainModulatorArray()); - void Midct(TFloat specs[1024], TFloat* bands[4], TGainDemodulatorArray gainDemodulators = TGainDemodulatorArray()); + void Mdct(TFloat specs[1024], + TFloat* bands[4], + TFloat maxLevels[4], + TGainModulatorArray gainModulators = TGainModulatorArray()); + void Midct(TFloat specs[1024], + TFloat* bands[4], + TGainDemodulatorArray gainDemodulators = TGainDemodulatorArray()); protected: TAtrac3MDCT::TGainModulatorArray MakeGainModulatorArray(const TAtrac3Data::SubbandInfo& si); }; @@ -43,6 +48,11 @@ class TAtrac3Processor : public IProcessor<TFloat>, public TAtrac3MDCT, public v TCompressedIOPtr Oma; const NAtrac3::TAtrac3EncoderSettings Params; TFloat PcmBuffer[2][4][256 + 256]; //2 channel, 4 band, 256 sample + 256 for overlap buffer + + TFloat LastLevels[2][4]; //2 channel, 4 band - level of last subblock, used to create curve + TFloat LastHPLevels[2][4]; //2 channel, 4 band - level of last HP filtered subblock, used for transient detection + TFloat PrevPeak[2][4]; //2 channel, 4 band - peak level (after windowing), used to check overflow during scalling + Atrac3SplitFilterBank<TFloat> SplitFilterBank[2]; TScaler<TAtrac3Data> Scaler; std::vector<TTransientDetector> TransientDetectors; @@ -50,11 +60,11 @@ class TAtrac3Processor : public IProcessor<TFloat>, public TAtrac3MDCT, public v #ifdef ATRAC_UT_PUBLIC public: #endif - uint32_t CheckLevelOverflow(const std::vector<TFloat>& gain, const TAtrac3Data::SubbandInfo::TGainPoint& point); - std::vector<SubbandInfo::TGainPoint> FilterCurve(const std::vector<TFloat>& gain, - const std::vector<SubbandInfo::TGainPoint>& curve, + uint32_t CheckLevelOverflow(TFloat max, uint32_t levelIdx); + std::vector<SubbandInfo::TGainPoint> FilterCurve(const std::vector<SubbandInfo::TGainPoint>& curve, const int threshold); TFloat LimitRel(TFloat x); + std::vector<TFloat> CalcBaseLevel(TFloat prev, const std::vector<TFloat>& gain); TAtrac3Data::SubbandInfo CreateSubbandInfo(TFloat* in[4], uint32_t channel, TTransientDetector* transientDetector); TonalComponentMask AnalyzeTonalComponent(TFloat* specs); TTonalComponents ExtractTonalComponents(TFloat* specs, TTonalDetector fn); |