various: moved more to core lib
This commit is contained in:
@@ -20,8 +20,6 @@ add_subdirectory(opengl)
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
render/audioparams.cpp
|
||||
render/audioparams.h
|
||||
render/audioplaybackcache.cpp
|
||||
render/audioplaybackcache.h
|
||||
render/audiowaveformcache.cpp
|
||||
|
||||
@@ -1,358 +0,0 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "audioparams.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
}
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "common/xmlutils.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
const QVector<int> AudioParams::kSupportedSampleRates = {
|
||||
8000, // 8000 Hz
|
||||
11025, // 11025 Hz
|
||||
16000, // 16000 Hz
|
||||
22050, // 22050 Hz
|
||||
24000, // 24000 Hz
|
||||
32000, // 32000 Hz
|
||||
44100, // 44100 Hz
|
||||
48000, // 48000 Hz
|
||||
88200, // 88200 Hz
|
||||
96000 // 96000 Hz
|
||||
};
|
||||
|
||||
const QVector<uint64_t> AudioParams::kSupportedChannelLayouts = {
|
||||
AV_CH_LAYOUT_MONO,
|
||||
AV_CH_LAYOUT_STEREO,
|
||||
AV_CH_LAYOUT_2_1,
|
||||
AV_CH_LAYOUT_5POINT1,
|
||||
AV_CH_LAYOUT_7POINT1
|
||||
};
|
||||
|
||||
const AudioParams::Format AudioParams::kInternalFormat = AudioParams::kFormatFloat32Planar;
|
||||
|
||||
bool AudioParams::operator==(const AudioParams &other) const
|
||||
{
|
||||
return (format() == other.format()
|
||||
&& sample_rate() == other.sample_rate()
|
||||
&& time_base() == other.time_base()
|
||||
&& channel_layout() == other.channel_layout());
|
||||
}
|
||||
|
||||
bool AudioParams::operator!=(const AudioParams &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
qint64 AudioParams::time_to_bytes(const double &time) const
|
||||
{
|
||||
return time_to_bytes_per_channel(time) * channel_count();
|
||||
}
|
||||
|
||||
qint64 AudioParams::time_to_bytes(const rational &time) const
|
||||
{
|
||||
return time_to_bytes(time.toDouble());
|
||||
}
|
||||
|
||||
qint64 AudioParams::time_to_bytes_per_channel(const double &time) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return qint64(time_to_samples(time)) * bytes_per_sample_per_channel();
|
||||
}
|
||||
|
||||
qint64 AudioParams::time_to_bytes_per_channel(const rational &time) const
|
||||
{
|
||||
return time_to_bytes_per_channel(time.toDouble());
|
||||
}
|
||||
|
||||
qint64 AudioParams::time_to_samples(const double &time) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
// NOTE: Not sure if we should round or ceil, but I've gotten better results with ceil.
|
||||
// Specifically, we seem to occasionally get straggler ranges that never cache with round.
|
||||
return qCeil(double(sample_rate()) * time);
|
||||
}
|
||||
|
||||
qint64 AudioParams::time_to_samples(const rational &time) const
|
||||
{
|
||||
return time_to_samples(time.toDouble());
|
||||
}
|
||||
|
||||
qint64 AudioParams::samples_to_bytes(const qint64 &samples) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return samples_to_bytes_per_channel(samples) * channel_count();
|
||||
}
|
||||
|
||||
qint64 AudioParams::samples_to_bytes_per_channel(const qint64 &samples) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return samples * bytes_per_sample_per_channel();
|
||||
}
|
||||
|
||||
rational AudioParams::samples_to_time(const qint64 &samples) const
|
||||
{
|
||||
return sample_rate_as_time_base() * samples;
|
||||
}
|
||||
|
||||
qint64 AudioParams::bytes_to_samples(const qint64 &bytes) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return bytes / (channel_count() * bytes_per_sample_per_channel());
|
||||
}
|
||||
|
||||
rational AudioParams::bytes_to_time(const qint64 &bytes) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return samples_to_time(bytes_to_samples(bytes));
|
||||
}
|
||||
|
||||
rational AudioParams::bytes_per_channel_to_time(const qint64 &bytes) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return samples_to_time(bytes_to_samples(bytes * channel_count()));
|
||||
}
|
||||
|
||||
int AudioParams::channel_count() const
|
||||
{
|
||||
return channel_count_;
|
||||
}
|
||||
|
||||
int AudioParams::bytes_per_sample_per_channel() const
|
||||
{
|
||||
switch (format_) {
|
||||
case kFormatUnsigned8Packed:
|
||||
case kFormatUnsigned8Planar:
|
||||
return 1;
|
||||
case kFormatSigned16Packed:
|
||||
case kFormatSigned16Planar:
|
||||
return 2;
|
||||
case kFormatSigned32Packed:
|
||||
case kFormatSigned32Planar:
|
||||
case kFormatFloat32Packed:
|
||||
case kFormatFloat32Planar:
|
||||
return 4;
|
||||
case kFormatSigned64Packed:
|
||||
case kFormatSigned64Planar:
|
||||
case kFormatFloat64Packed:
|
||||
case kFormatFloat64Planar:
|
||||
return 8;
|
||||
case kFormatInvalid:
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AudioParams::bits_per_sample() const
|
||||
{
|
||||
return bytes_per_sample_per_channel() * 8;
|
||||
}
|
||||
|
||||
bool AudioParams::is_valid() const
|
||||
{
|
||||
return (!time_base().isNull()
|
||||
&& channel_layout() > 0
|
||||
&& format_ > kFormatInvalid
|
||||
&& format_ < kFormatCount);
|
||||
}
|
||||
|
||||
void AudioParams::Load(QXmlStreamReader *reader)
|
||||
{
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
if (reader->name() == QStringLiteral("samplerate")) {
|
||||
set_sample_rate(reader->readElementText().toInt());
|
||||
} else if (reader->name() == QStringLiteral("channellayout")) {
|
||||
set_channel_layout(reader->readElementText().toULongLong());
|
||||
} else if (reader->name() == QStringLiteral("format")) {
|
||||
set_format(static_cast<AudioParams::Format>(reader->readElementText().toInt()));
|
||||
} else if (reader->name() == QStringLiteral("enabled")) {
|
||||
set_enabled(reader->readElementText().toInt());
|
||||
} else if (reader->name() == QStringLiteral("streamindex")) {
|
||||
set_stream_index(reader->readElementText().toInt());
|
||||
} else if (reader->name() == QStringLiteral("duration")) {
|
||||
set_duration(reader->readElementText().toLongLong());
|
||||
} else if (reader->name() == QStringLiteral("timebase")) {
|
||||
set_time_base(rational::fromString(reader->readElementText().toStdString()));
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioParams::Save(QXmlStreamWriter *writer) const
|
||||
{
|
||||
writer->writeTextElement(QStringLiteral("samplerate"), QString::number(sample_rate_));
|
||||
writer->writeTextElement(QStringLiteral("channellayout"), QString::number(channel_layout_));
|
||||
writer->writeTextElement(QStringLiteral("format"), QString::number(format_));
|
||||
writer->writeTextElement(QStringLiteral("enabled"), QString::number(enabled_));
|
||||
writer->writeTextElement(QStringLiteral("streamindex"), QString::number(stream_index_));
|
||||
writer->writeTextElement(QStringLiteral("duration"), QString::number(duration_));
|
||||
writer->writeTextElement(QStringLiteral("timebase"), QString::fromStdString(timebase_.toString()));
|
||||
}
|
||||
|
||||
QString AudioParams::SampleRateToString(const int &sample_rate)
|
||||
{
|
||||
return QCoreApplication::translate("AudioParams", "%1 Hz").arg(sample_rate);
|
||||
}
|
||||
|
||||
QString AudioParams::ChannelLayoutToString(const uint64_t &layout)
|
||||
{
|
||||
switch (layout) {
|
||||
case AV_CH_LAYOUT_MONO:
|
||||
return QCoreApplication::translate("AudioParams", "Mono");
|
||||
case AV_CH_LAYOUT_STEREO:
|
||||
return QCoreApplication::translate("AudioParams", "Stereo");
|
||||
case AV_CH_LAYOUT_2_1:
|
||||
return QCoreApplication::translate("AudioParams", "2.1");
|
||||
case AV_CH_LAYOUT_5POINT1:
|
||||
return QCoreApplication::translate("AudioParams", "5.1");
|
||||
case AV_CH_LAYOUT_7POINT1:
|
||||
return QCoreApplication::translate("AudioParams", "7.1");
|
||||
default:
|
||||
return QCoreApplication::translate("AudioParams", "Unknown (0x%1)").arg(layout, 1, 16);
|
||||
}
|
||||
}
|
||||
|
||||
QString AudioParams::FormatToString(const Format &f)
|
||||
{
|
||||
switch (f) {
|
||||
case kFormatUnsigned8Packed:
|
||||
return QCoreApplication::translate("AudioParams", "Unsigned 8-bit (Packed)");
|
||||
case kFormatSigned16Packed:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 16-bit (Packed)");
|
||||
case kFormatSigned32Packed:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 32-bit (Packed)");
|
||||
case kFormatSigned64Packed:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 64-bit (Packed)");
|
||||
case kFormatFloat32Packed:
|
||||
return QCoreApplication::translate("AudioParams", "Float 32-bit (Packed)");
|
||||
case kFormatFloat64Packed:
|
||||
return QCoreApplication::translate("AudioParams", "Float 64-bit (Packed)");
|
||||
case kFormatUnsigned8Planar:
|
||||
return QCoreApplication::translate("AudioParams", "Unsigned 8-bit (Planar)");
|
||||
case kFormatSigned16Planar:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 16-bit (Planar)");
|
||||
case kFormatSigned32Planar:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 32-bit (Planar)");
|
||||
case kFormatSigned64Planar:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 64-bit (Planar)");
|
||||
case kFormatFloat32Planar:
|
||||
return QCoreApplication::translate("AudioParams", "Float 32-bit (Planar)");
|
||||
case kFormatFloat64Planar:
|
||||
return QCoreApplication::translate("AudioParams", "Float 64-bit (Planar)");
|
||||
|
||||
case kFormatInvalid:
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
|
||||
return QCoreApplication::translate("AudioParams", "Unknown (0x%1)").arg(f, 1, 16);
|
||||
}
|
||||
|
||||
AudioParams::Format AudioParams::GetPackedEquivalent(Format fmt)
|
||||
{
|
||||
switch (fmt) {
|
||||
|
||||
// For packed input, just return input
|
||||
case kFormatUnsigned8Packed:
|
||||
case kFormatSigned16Packed:
|
||||
case kFormatSigned32Packed:
|
||||
case kFormatSigned64Packed:
|
||||
case kFormatFloat32Packed:
|
||||
case kFormatFloat64Packed:
|
||||
return fmt;
|
||||
|
||||
// Convert to packed
|
||||
case kFormatUnsigned8Planar:
|
||||
return kFormatUnsigned8Packed;
|
||||
case kFormatSigned16Planar:
|
||||
return kFormatSigned16Packed;
|
||||
case kFormatSigned32Planar:
|
||||
return kFormatSigned32Packed;
|
||||
case kFormatSigned64Planar:
|
||||
return kFormatSigned64Packed;
|
||||
case kFormatFloat32Planar:
|
||||
return kFormatFloat32Packed;
|
||||
case kFormatFloat64Planar:
|
||||
return kFormatFloat64Packed;
|
||||
|
||||
case kFormatInvalid:
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
|
||||
return kFormatInvalid;
|
||||
}
|
||||
|
||||
AudioParams::Format AudioParams::GetPlanarEquivalent(Format fmt)
|
||||
{
|
||||
switch (fmt) {
|
||||
|
||||
// Convert to planar
|
||||
case kFormatUnsigned8Packed:
|
||||
return kFormatUnsigned8Planar;
|
||||
case kFormatSigned16Packed:
|
||||
return kFormatSigned16Planar;
|
||||
case kFormatSigned32Packed:
|
||||
return kFormatSigned32Planar;
|
||||
case kFormatSigned64Packed:
|
||||
return kFormatSigned64Planar;
|
||||
case kFormatFloat32Packed:
|
||||
return kFormatFloat32Planar;
|
||||
case kFormatFloat64Packed:
|
||||
return kFormatFloat64Planar;
|
||||
|
||||
// For planar input, just return input
|
||||
case kFormatUnsigned8Planar:
|
||||
case kFormatSigned16Planar:
|
||||
case kFormatSigned32Planar:
|
||||
case kFormatSigned64Planar:
|
||||
case kFormatFloat32Planar:
|
||||
case kFormatFloat64Planar:
|
||||
return fmt;
|
||||
|
||||
case kFormatInvalid:
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
|
||||
return kFormatInvalid;
|
||||
}
|
||||
|
||||
void AudioParams::calculate_channel_count()
|
||||
{
|
||||
channel_count_ = av_get_channel_layout_nb_channels(channel_layout());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,282 +0,0 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef AUDIOPARAMS_H
|
||||
#define AUDIOPARAMS_H
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/channel_layout.h>
|
||||
}
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QtMath>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
namespace olive {
|
||||
|
||||
using namespace core;
|
||||
|
||||
class AudioParams {
|
||||
public:
|
||||
// Only append to this list (never insert) because indexes are used in serialized files
|
||||
enum Format {
|
||||
/// Invalid
|
||||
kFormatInvalid = -1,
|
||||
|
||||
/// 8-bit unsigned integer
|
||||
kFormatUnsigned8Planar,
|
||||
|
||||
/// 16-bit signed integer
|
||||
kFormatSigned16Planar,
|
||||
|
||||
/// 32-bit signed integer
|
||||
kFormatSigned32Planar,
|
||||
|
||||
/// 64-bit signed integer
|
||||
kFormatSigned64Planar,
|
||||
|
||||
/// 32-bit float
|
||||
kFormatFloat32Planar,
|
||||
|
||||
/// 64-bit float
|
||||
kFormatFloat64Planar,
|
||||
|
||||
/// 8-bit unsigned integer
|
||||
kFormatUnsigned8Packed,
|
||||
|
||||
/// 16-bit signed integer
|
||||
kFormatSigned16Packed,
|
||||
|
||||
/// 32-bit signed integer
|
||||
kFormatSigned32Packed,
|
||||
|
||||
/// 64-bit signed integer
|
||||
kFormatSigned64Packed,
|
||||
|
||||
/// 32-bit float
|
||||
kFormatFloat32Packed,
|
||||
|
||||
/// 64-bit float
|
||||
kFormatFloat64Packed,
|
||||
|
||||
/// Total format count
|
||||
kFormatCount,
|
||||
|
||||
kPlanarStart = kFormatUnsigned8Planar,
|
||||
kPackedStart = kFormatUnsigned8Packed,
|
||||
kPlanarEnd = kPackedStart,
|
||||
kPackedEnd = kFormatCount
|
||||
};
|
||||
|
||||
static const Format kInternalFormat;
|
||||
|
||||
AudioParams() :
|
||||
sample_rate_(0),
|
||||
channel_layout_(0),
|
||||
format_(kFormatInvalid)
|
||||
{
|
||||
set_default_footage_parameters();
|
||||
|
||||
// Cache channel count
|
||||
calculate_channel_count();
|
||||
}
|
||||
|
||||
AudioParams(const int& sample_rate, const uint64_t& channel_layout, const Format& format) :
|
||||
sample_rate_(sample_rate),
|
||||
channel_layout_(channel_layout),
|
||||
format_(format)
|
||||
{
|
||||
set_default_footage_parameters();
|
||||
timebase_ = sample_rate_as_time_base();
|
||||
|
||||
// Cache channel count
|
||||
calculate_channel_count();
|
||||
}
|
||||
|
||||
int sample_rate() const
|
||||
{
|
||||
return sample_rate_;
|
||||
}
|
||||
|
||||
void set_sample_rate(int sample_rate)
|
||||
{
|
||||
sample_rate_ = sample_rate;
|
||||
}
|
||||
|
||||
uint64_t channel_layout() const
|
||||
{
|
||||
return channel_layout_;
|
||||
}
|
||||
|
||||
void set_channel_layout(uint64_t channel_layout)
|
||||
{
|
||||
channel_layout_ = channel_layout;
|
||||
calculate_channel_count();
|
||||
}
|
||||
|
||||
rational time_base() const
|
||||
{
|
||||
return timebase_;
|
||||
}
|
||||
|
||||
void set_time_base(const rational& timebase)
|
||||
{
|
||||
timebase_ = timebase;
|
||||
}
|
||||
|
||||
rational sample_rate_as_time_base() const
|
||||
{
|
||||
return rational(1, sample_rate());
|
||||
}
|
||||
|
||||
Format format() const
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
||||
void set_format(Format format)
|
||||
{
|
||||
format_ = format;
|
||||
}
|
||||
|
||||
bool enabled() const
|
||||
{
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
void set_enabled(bool e)
|
||||
{
|
||||
enabled_ = e;
|
||||
}
|
||||
|
||||
int stream_index() const
|
||||
{
|
||||
return stream_index_;
|
||||
}
|
||||
|
||||
void set_stream_index(int s)
|
||||
{
|
||||
stream_index_ = s;
|
||||
}
|
||||
|
||||
int64_t duration() const
|
||||
{
|
||||
return duration_;
|
||||
}
|
||||
|
||||
void set_duration(int64_t duration)
|
||||
{
|
||||
duration_ = duration;
|
||||
}
|
||||
|
||||
static bool FormatIsPacked(Format f)
|
||||
{
|
||||
return f >= kPackedStart && f < kPackedEnd;
|
||||
}
|
||||
|
||||
bool FormatIsPacked() const
|
||||
{
|
||||
return FormatIsPacked(format_);
|
||||
}
|
||||
|
||||
static bool FormatIsPlanar(Format f)
|
||||
{
|
||||
return f >= kPlanarStart && f < kPlanarEnd;
|
||||
}
|
||||
|
||||
bool FormatIsPlanar() const
|
||||
{
|
||||
return FormatIsPlanar(format_);
|
||||
}
|
||||
|
||||
qint64 time_to_bytes(const double& time) const;
|
||||
qint64 time_to_bytes(const rational& time) const;
|
||||
qint64 time_to_bytes_per_channel(const double& time) const;
|
||||
qint64 time_to_bytes_per_channel(const rational& time) const;
|
||||
qint64 time_to_samples(const double& time) const;
|
||||
qint64 time_to_samples(const rational& time) const;
|
||||
qint64 samples_to_bytes(const qint64& samples) const;
|
||||
qint64 samples_to_bytes_per_channel(const qint64& samples) const;
|
||||
rational samples_to_time(const qint64& samples) const;
|
||||
qint64 bytes_to_samples(const qint64 &bytes) const;
|
||||
rational bytes_to_time(const qint64 &bytes) const;
|
||||
rational bytes_per_channel_to_time(const qint64 &bytes) const;
|
||||
int channel_count() const;
|
||||
int bytes_per_sample_per_channel() const;
|
||||
int bits_per_sample() const;
|
||||
bool is_valid() const;
|
||||
|
||||
void Load(QXmlStreamReader* reader);
|
||||
|
||||
void Save(QXmlStreamWriter* writer) const;
|
||||
|
||||
bool operator==(const AudioParams& other) const;
|
||||
bool operator!=(const AudioParams& other) const;
|
||||
|
||||
static const QVector<uint64_t> kSupportedChannelLayouts;
|
||||
static const QVector<int> kSupportedSampleRates;
|
||||
|
||||
/**
|
||||
* @brief Convert integer sample rate to a user-friendly string
|
||||
*/
|
||||
static QString SampleRateToString(const int &sample_rate);
|
||||
|
||||
/**
|
||||
* @brief Convert channel layout to a user-friendly string
|
||||
*/
|
||||
static QString ChannelLayoutToString(const uint64_t &layout);
|
||||
|
||||
static QString FormatToString(const Format &f);
|
||||
|
||||
static AudioParams::Format GetPackedEquivalent(AudioParams::Format fmt);
|
||||
static AudioParams::Format GetPlanarEquivalent(AudioParams::Format fmt);
|
||||
|
||||
private:
|
||||
void set_default_footage_parameters()
|
||||
{
|
||||
enabled_ = true;
|
||||
stream_index_ = 0;
|
||||
duration_ = 0;
|
||||
}
|
||||
|
||||
void calculate_channel_count();
|
||||
|
||||
int sample_rate_;
|
||||
|
||||
uint64_t channel_layout_;
|
||||
|
||||
int channel_count_;
|
||||
|
||||
Format format_;
|
||||
|
||||
// Footage-specific
|
||||
int enabled_; // Switching this to int fixes GCC 11 stringop-overflow issue, I guess a byte-alignment issue?
|
||||
int stream_index_;
|
||||
int64_t duration_;
|
||||
rational timebase_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(olive::AudioParams)
|
||||
|
||||
#endif // AUDIOPARAMS_H
|
||||
@@ -68,28 +68,28 @@ void AudioPlaybackCache::WriteSilence(const TimeRange &range)
|
||||
|
||||
bool AudioPlaybackCache::WritePartOfSampleBuffer(const SampleBuffer &samples, const rational &write_start, const rational &buffer_start, const rational &length)
|
||||
{
|
||||
qint64 length_in_bytes = params_.time_to_bytes_per_channel(length);
|
||||
int64_t length_in_bytes = params_.time_to_bytes_per_channel(length);
|
||||
|
||||
qint64 start_cache_offset = params_.time_to_bytes_per_channel(write_start);
|
||||
qint64 end_cache_offset = start_cache_offset + length_in_bytes;
|
||||
int64_t start_cache_offset = params_.time_to_bytes_per_channel(write_start);
|
||||
int64_t end_cache_offset = start_cache_offset + length_in_bytes;
|
||||
|
||||
qint64 start_buffer_offset = params_.time_to_bytes_per_channel(buffer_start);
|
||||
qint64 end_buffer_offset = std::min(start_buffer_offset + length_in_bytes, params_.samples_to_bytes_per_channel(samples.sample_count()));
|
||||
int64_t start_buffer_offset = params_.time_to_bytes_per_channel(buffer_start);
|
||||
int64_t end_buffer_offset = std::min(start_buffer_offset + length_in_bytes, params_.samples_to_bytes_per_channel(samples.sample_count()));
|
||||
|
||||
qint64 current_cache_offset = start_cache_offset;
|
||||
qint64 current_buffer_offset = start_buffer_offset;
|
||||
int64_t current_cache_offset = start_cache_offset;
|
||||
int64_t current_buffer_offset = start_buffer_offset;
|
||||
|
||||
bool success = true;
|
||||
|
||||
while (current_cache_offset != end_cache_offset) {
|
||||
qint64 segment = current_cache_offset / kDefaultSegmentSizePerChannel;
|
||||
qint64 segment_start = segment * kDefaultSegmentSizePerChannel;
|
||||
qint64 segment_end = segment_start + kDefaultSegmentSizePerChannel;
|
||||
int64_t segment = current_cache_offset / kDefaultSegmentSizePerChannel;
|
||||
int64_t segment_start = segment * kDefaultSegmentSizePerChannel;
|
||||
int64_t segment_end = segment_start + kDefaultSegmentSizePerChannel;
|
||||
|
||||
qint64 offset_in_segment = current_cache_offset - segment_start;
|
||||
qint64 write_len = segment_end - offset_in_segment;
|
||||
qint64 max_buffer_len = end_buffer_offset - current_buffer_offset;
|
||||
qint64 zero_len = 0;
|
||||
int64_t offset_in_segment = current_cache_offset - segment_start;
|
||||
int64_t write_len = segment_end - offset_in_segment;
|
||||
int64_t max_buffer_len = end_buffer_offset - current_buffer_offset;
|
||||
int64_t zero_len = 0;
|
||||
|
||||
if (write_len > max_buffer_len) {
|
||||
zero_len = write_len - max_buffer_len;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define AUDIOPLAYBACKCACHE_H
|
||||
|
||||
#include "audio/audiovisualwaveform.h"
|
||||
#include "codec/samplebuffer.h"
|
||||
#include "render/playbackcache.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -406,7 +406,7 @@ bool FrameHashCache::SaveCacheFrame(const QString &filename, const FramePtr fram
|
||||
break;
|
||||
case PixelFormat::F16:
|
||||
case PixelFormat::F32:
|
||||
case PixelFormat::FORMAT_COUNT:
|
||||
case PixelFormat::COUNT:
|
||||
case PixelFormat::INVALID:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define SAMPLEJOB_H
|
||||
|
||||
#include "acceleratedjob.h"
|
||||
#include "codec/samplebuffer.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
|
||||
@@ -725,7 +725,7 @@ GLint OpenGLRenderer::GetInternalFormat(PixelFormat format, int channel_layout)
|
||||
}
|
||||
break;
|
||||
case PixelFormat::INVALID:
|
||||
case PixelFormat::FORMAT_COUNT:
|
||||
case PixelFormat::COUNT:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ GLenum OpenGLRenderer::GetPixelType(PixelFormat format)
|
||||
return GL_FLOAT;
|
||||
|
||||
case PixelFormat::INVALID:
|
||||
case PixelFormat::FORMAT_COUNT:
|
||||
case PixelFormat::COUNT:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "node/node.h"
|
||||
#include "node/output/viewer/viewer.h"
|
||||
#include "node/project/project.h"
|
||||
#include "render/audioparams.h"
|
||||
#include "render/projectcopier.h"
|
||||
#include "render/renderjobtracker.h"
|
||||
#include "render/rendermanager.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <QWaitCondition>
|
||||
|
||||
#include "codec/frame.h"
|
||||
#include "codec/samplebuffer.h"
|
||||
#include "common/cancelableobject.h"
|
||||
#include "node/output/viewer/viewer.h"
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ int VideoParams::GetBytesPerChannel(PixelFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case PixelFormat::INVALID:
|
||||
case PixelFormat::FORMAT_COUNT:
|
||||
case PixelFormat::COUNT:
|
||||
break;
|
||||
case PixelFormat::U8:
|
||||
return 1;
|
||||
@@ -222,7 +222,7 @@ QString VideoParams::GetFormatName(PixelFormat format)
|
||||
case PixelFormat::F32:
|
||||
return QCoreApplication::translate("VideoParams", "Full-Float (32-bit)");
|
||||
case PixelFormat::INVALID:
|
||||
case PixelFormat::FORMAT_COUNT:
|
||||
case PixelFormat::COUNT:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ bool VideoParams::is_valid() const
|
||||
return (width() > 0
|
||||
&& height() > 0
|
||||
&& !pixel_aspect_ratio_.isNull()
|
||||
&& format_ > PixelFormat::INVALID && format_ < PixelFormat::FORMAT_COUNT
|
||||
&& format_ > PixelFormat::INVALID && format_ < PixelFormat::COUNT
|
||||
&& channel_count_ > 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user