aboutsummaryrefslogtreecommitdiffstats
path: root/src/atrac/atrac_scale.h
blob: bca2e61222971a92da3db987e1ccab0cb1c60651 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * This file is part of AtracDEnc.
 *
 * AtracDEnc is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * AtracDEnc is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with AtracDEnc; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#pragma once
#include <array>
#include <vector>
#include <map>
#include <cstdint>

#include "lib/bitstream/bitstream.h"
#include "../config.h"

namespace NAtracDEnc {

float QuantMantisas(const float* in, uint32_t first, uint32_t last, float mul, bool ea, int* mantisas);

struct TScaledBlock {
    TScaledBlock(uint8_t sfi) : ScaleFactorIndex(sfi) {}
    /* const */ uint8_t ScaleFactorIndex = 0;
    std::vector<float> Values;
    float MaxEnergy;
};

template <class TBaseData>
class TScaler {
    std::map<float, uint8_t> ScaleIndex;
public:
    TScaler();
    TScaledBlock Scale(const float* in, uint16_t len);
    std::vector<TScaledBlock> ScaleFrame(const std::vector<float>& specs, const typename TBaseData::TBlockSizeMod& blockSize);
};

} //namespace NAtracDEnc