use ffmpeg for sample packing

FFmpeg has a much more optimized algorithm than we do so may as well use it.
This commit is contained in:
itsmattkc
2021-09-25 13:22:13 -07:00
parent 4c9863a696
commit 845b4a7559
9 changed files with 191 additions and 29 deletions
-19
View File
@@ -237,23 +237,4 @@ void SampleBuffer::set(int channel, const float *data, int sample_offset, int sa
memcpy(&data_[channel].data()[sample_offset], data, sizeof(float) * sample_length);
}
QByteArray SampleBuffer::toPackedData() const
{
QByteArray packed_data;
if (is_allocated()) {
packed_data.resize(audio_params_.samples_to_bytes(sample_count_per_channel_));
float* output_data = reinterpret_cast<float*>(packed_data.data());
for (int j=0;j<sample_count_per_channel_;j++) {
for (int i=0;i<audio_params_.channel_count();i++) {
output_data[i*j + i] = data_[i][j];
}
}
}
return packed_data;
}
}