#include "mixer.h"
#include <assert.h>
+#include <endian.h>
#include <epoxy/egl.h>
#include <movit/effect_chain.h>
#include <movit/effect_util.h>
uint32_t s2 = *src++;
uint32_t s3 = *src++;
uint32_t s = s1 | (s1 << 8) | (s2 << 16) | (s3 << 24);
- dst[i * out_channels + j] = int(s) * (1.0f / 4294967296.0f);
+ dst[i * out_channels + j] = int(s) * (1.0f / 2147483648.0f);
}
src += 3 * (in_channels - out_channels);
}
assert(in_channels >= out_channels);
for (size_t i = 0; i < num_samples; ++i) {
for (size_t j = 0; j < out_channels; ++j) {
- // Note: Assumes little-endian.
- int32_t s = *(int32_t *)src;
- dst[i * out_channels + j] = s * (1.0f / 4294967296.0f);
+ int32_t s = le32toh(*(int32_t *)src);
+ dst[i * out_channels + j] = s * (1.0f / 2147483648.0f);
src += 4;
}
src += 4 * (in_channels - out_channels);
// printf("limiter=%+5.1f compressor=%+5.1f\n", 20.0*log10(limiter_att), 20.0*log10(compressor_att));
- // Upsample 4x to find interpolated peak.
- peak_resampler.inp_data = samples_out.data();
- peak_resampler.inp_count = samples_out.size() / 2;
-
- vector<float> interpolated_samples_out;
- interpolated_samples_out.resize(samples_out.size());
- while (peak_resampler.inp_count > 0) { // About four iterations.
- peak_resampler.out_data = &interpolated_samples_out[0];
- peak_resampler.out_count = interpolated_samples_out.size() / 2;
- peak_resampler.process();
- size_t out_stereo_samples = interpolated_samples_out.size() / 2 - peak_resampler.out_count;
- peak = max<float>(peak, find_peak(interpolated_samples_out.data(), out_stereo_samples * 2));
- peak_resampler.out_data = nullptr;
- }
-
// At this point, we are most likely close to +0 LU, but all of our
// measurements have been on raw sample values, not R128 values.
// So we have a final makeup gain to get us to +0 LU; the gain
final_makeup_gain = m;
}
+ // Upsample 4x to find interpolated peak.
+ peak_resampler.inp_data = samples_out.data();
+ peak_resampler.inp_count = samples_out.size() / 2;
+
+ vector<float> interpolated_samples_out;
+ interpolated_samples_out.resize(samples_out.size());
+ while (peak_resampler.inp_count > 0) { // About four iterations.
+ peak_resampler.out_data = &interpolated_samples_out[0];
+ peak_resampler.out_count = interpolated_samples_out.size() / 2;
+ peak_resampler.process();
+ size_t out_stereo_samples = interpolated_samples_out.size() / 2 - peak_resampler.out_count;
+ peak = max<float>(peak, find_peak(interpolated_samples_out.data(), out_stereo_samples * 2));
+ peak_resampler.out_data = nullptr;
+ }
+
// Find R128 levels and L/R correlation.
vector<float> left, right;
deinterleave_samples(samples_out, &left, &right);