various: moved more to core lib

This commit is contained in:
itsmattkc
2023-01-19 16:01:31 -08:00
parent dd9c52ab59
commit c1c6893713
92 changed files with 448 additions and 1558 deletions
+16 -16
View File
@@ -73,7 +73,7 @@ int InputCallback(const void *input, void *output, unsigned long frameCount, con
FFmpegEncoder *f = static_cast<FFmpegEncoder*>(userData);
AudioParams our_params = f->params().audio_params();
our_params.set_format(AudioParams::GetPackedEquivalent(f->params().audio_params().format()));
our_params.set_format(f->params().audio_params().format().to_packed_equivalent());
f->WriteAudioData(our_params, reinterpret_cast<const uint8_t**>(&input), frameCount);
@@ -119,27 +119,27 @@ void AudioManager::ClearBufferedOutput()
output_buffer_->clear();
}
PaSampleFormat AudioManager::GetPortAudioSampleFormat(AudioParams::Format fmt)
PaSampleFormat AudioManager::GetPortAudioSampleFormat(SampleFormat fmt)
{
switch (fmt) {
case AudioParams::kFormatUnsigned8Packed:
case AudioParams::kFormatUnsigned8Planar:
case SampleFormat::U8:
case SampleFormat::U8P:
return paUInt8;
case AudioParams::kFormatSigned16Packed:
case AudioParams::kFormatSigned16Planar:
case SampleFormat::S16:
case SampleFormat::S16P:
return paInt16;
case AudioParams::kFormatSigned32Packed:
case AudioParams::kFormatSigned32Planar:
case SampleFormat::S32:
case SampleFormat::S32P:
return paInt32;
case AudioParams::kFormatFloat32Packed:
case AudioParams::kFormatFloat32Planar:
case SampleFormat::F32:
case SampleFormat::F32P:
return paFloat32;
case AudioParams::kFormatSigned64Packed:
case AudioParams::kFormatSigned64Planar:
case AudioParams::kFormatFloat64Packed:
case AudioParams::kFormatFloat64Planar:
case AudioParams::kFormatInvalid:
case AudioParams::kFormatCount:
case SampleFormat::S64:
case SampleFormat::S64P:
case SampleFormat::F64:
case SampleFormat::F64P:
case SampleFormat::INVALID:
case SampleFormat::COUNT:
break;
}
+1 -2
View File
@@ -30,7 +30,6 @@
#include "audio/audioprocessor.h"
#include "common/define.h"
#include "codec/ffmpeg/ffmpegencoder.h"
#include "render/audioparams.h"
#include "render/audioplaybackcache.h"
#include "render/previewaudiodevice.h"
@@ -94,7 +93,7 @@ private:
virtual ~AudioManager() override;
static PaSampleFormat GetPortAudioSampleFormat(AudioParams::Format fmt);
static PaSampleFormat GetPortAudioSampleFormat(SampleFormat fmt);
void CloseOutputStream();
+5 -5
View File
@@ -90,13 +90,13 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to, double
double speed_log = log(tempo) / log(base);
// This is the number of how many 0.5 or 2.0 tempos we need to daisychain
int whole = qFloor(speed_log);
int whole = std::floor(speed_log);
// Set speed_log to the remainder
speed_log -= whole;
for (int i=0;i<=whole;i++) {
double filter_tempo = (i == whole) ? qPow(base, speed_log) : base;
double filter_tempo = (i == whole) ? std::pow(base, speed_log) : base;
if (qFuzzyCompare(filter_tempo, 1.0)) {
// This filter would do nothing
@@ -117,7 +117,7 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to, double
// Create conversion filter
if (from.sample_rate() != to.sample_rate() || from.channel_layout() != to.channel_layout() || from.format() != to.format()
|| (to.FormatIsPlanar() && create_tempo)) { // Tempo processor automatically converts to packed,
|| (to.format().is_planar() && create_tempo)) { // Tempo processor automatically converts to packed,
// so if the desired output is planar, it'll need
// to be converted
snprintf(filter_args, 200, "sample_fmts=%s:sample_rates=%d:channel_layouts=0x%" PRIx64,
@@ -238,7 +238,7 @@ int AudioProcessor::Convert(float **in, int nb_in_samples, AudioProcessor::Buffe
if (output) {
int nb_channels = to_.channel_count();
if (to_.FormatIsPacked()) {
if (to_.format().is_packed()) {
nb_channels = 1;
}
@@ -261,7 +261,7 @@ int AudioProcessor::Convert(float **in, int nb_in_samples, AudioProcessor::Buffe
}
int nb_bytes = out_frame_->nb_samples * to_.bytes_per_sample_per_channel();
if (to_.FormatIsPacked()) {
if (to_.format().is_packed()) {
nb_bytes *= to_.channel_count();
}
+4 -1
View File
@@ -22,16 +22,19 @@
#define AUDIOPROCESSOR_H
#include <inttypes.h>
#include <olive/core/core.h>
#include <QByteArray>
extern "C" {
#include <libavfilter/avfilter.h>
}
#include "common/define.h"
#include "render/audioparams.h"
namespace olive {
using namespace core;
class AudioProcessor
{
public:
+3 -4
View File
@@ -24,7 +24,6 @@
#include <QtGlobal>
#include "config/config.h"
#include "common/cpuoptimize.h"
namespace olive {
@@ -459,8 +458,8 @@ void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect& rect, con
break;
}
next_sample_index = qMin(arr.size(),
start_sample_index + qFloor(rate_dbl * static_cast<double>(i - rect.x() + 1) / scale) * samples.channel_count());
next_sample_index = std::min(arr.size(),
size_t(start_sample_index + std::floor(rate_dbl * static_cast<double>(i - rect.x() + 1) / scale) * samples.channel_count()));
if (summary_index != sample_index) {
summary = AudioVisualWaveform::ReSumSamples(&arr.at(sample_index),
@@ -480,7 +479,7 @@ size_t AudioVisualWaveform::time_to_samples(const rational &time, double sample_
size_t AudioVisualWaveform::time_to_samples(const double &time, double sample_rate) const
{
return qFloor(time * sample_rate) * channels_;
return std::floor(time * sample_rate) * channels_;
}
std::map<rational, AudioVisualWaveform::Sample>::const_iterator AudioVisualWaveform::GetMipmapForScale(double scale) const
+3 -2
View File
@@ -21,13 +21,14 @@
#ifndef SUMSAMPLES_H
#define SUMSAMPLES_H
#include <olive/core/core.h>
#include <QPainter>
#include <QVector>
#include "codec/samplebuffer.h"
namespace olive {
using namespace core;
/**
* @brief A buffer of data used to store a visual representation of audio
*