8#include <ecl/dbobjects/ECLDspData.h>
14 const int N_CHANNELS = 16;
15 int size = src.size();
25 for (
int i = size - 1; i >= 0; i--) {
26 if (i >= 2 * N_CHANNELS)
27 dst[i] = src[i] - 2 * src[i - N_CHANNELS] + src[i - 2 * N_CHANNELS];
28 else if (i >= N_CHANNELS)
29 dst[i] = src[i] - 2 * src[i - N_CHANNELS];
44 const int value_bits = 4;
45 const long value_max = 0xF;
46 const int values_packed =
sizeof(short) * 8 / value_bits;
50 std::vector<short> packed(size / values_packed, 0);
53 for (
int i = 0; i < size; i++) {
54 short val = dst[i] - shift;
55 if (val >= 0 && val < value_max) {
57 packed[i / values_packed] |= val << (value_bits * (i % values_packed));
59 if (len >= 0 && len < i) {
62 packed[i / values_packed] |= short(value_max) << (value_bits * (i % values_packed));
69 dst.resize(len + packed.size());
70 packed_size = packed.size();
71 for (
int i = 0; i < packed_size; i++) {
72 dst[len + i] = packed[i];
75 dst.push_back(packed_size);
81 const int N_CHANNELS = 16;
86 if (packer_version == 1) {
87 dst_size = src.size();
90 if (packer_version >= 2) {
92 const int value_bits = 4;
93 const long value_max = 0xF;
94 const int values_packed =
sizeof(short) * 8 / value_bits;
96 int size = src.size();
97 int packed_size = src[--size];
99 int packed_start = size - packed_size;
100 dst_size = packed_size * values_packed;
102 dst.resize(dst_size);
104 if (packed_size > 0) {
105 int unpacked_index = 0;
107 const int shift = -6;
109 for (
int i = packed_start; i < size; i++) {
110 auto package = src[i];
111 for (
int k = 0; k < values_packed; k++) {
112 short val =
package & value_max;
113 if (val != value_max) {
114 dst[dst_index++] = val + shift;
116 dst[dst_index++] = src[unpacked_index++];
118 package >>= value_bits;
128 if (packer_version == 0) {
130 }
else if (packer_version >= 1) {
131 const std::vector<short int>& new_src = packer_version >= 2 ? dst : src;
133 for (
int i = 0; i < dst_size; i++) {
134 if (i >= 2 * N_CHANNELS)
135 dst[i] = new_src[i] + 2 * dst[i - N_CHANNELS] - dst[i - 2 * N_CHANNELS];
136 else if (i >= N_CHANNELS)
137 dst[i] = new_src[i] + 2 * dst[i - N_CHANNELS];
std::vector< short int > m_extraData
This vector contains all parameters that didn't exist in the initial version of ECL DSP file format.
void packCoefVector(const std::vector< short int > &src, std::vector< short int > &dst)
Convert vector of DSP coefficients (src) to ECLDspData internal format (dst).
static constexpr short int getPackerVersion()
GETTERS.
void unpackCoefVector(const std::vector< short int > &src, std::vector< short int > &dst) const
Convert vector of DSP coefficients (src) to ECLDspData internal format (dst).
Abstract base class for different kinds of events.