sequence: made divider a sequence parameter rather than a viewer parameter
Doing this makes the preview resolution an explicit project setting rather than a temporary UI setting. This will allow more consistency when caching.
This commit is contained in:
+15
-66
@@ -26,125 +26,74 @@ extern "C" {
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
AudioParams::AudioParams() :
|
||||
sample_rate_(0),
|
||||
channel_layout_(0)
|
||||
{
|
||||
}
|
||||
|
||||
AudioParams::AudioParams(const int &sample_rate, const uint64_t &channel_layout) :
|
||||
sample_rate_(sample_rate),
|
||||
channel_layout_(channel_layout)
|
||||
{
|
||||
}
|
||||
|
||||
const int &AudioParams::sample_rate() const
|
||||
{
|
||||
return sample_rate_;
|
||||
}
|
||||
|
||||
const uint64_t &AudioParams::channel_layout() const
|
||||
{
|
||||
return channel_layout_;
|
||||
}
|
||||
|
||||
rational AudioParams::time_base() const
|
||||
{
|
||||
return rational(1, sample_rate());
|
||||
}
|
||||
|
||||
AudioRenderingParams::AudioRenderingParams() :
|
||||
format_(SampleFormat::SAMPLE_FMT_INVALID)
|
||||
{
|
||||
}
|
||||
|
||||
AudioRenderingParams::AudioRenderingParams(const int &sample_rate, const uint64_t &channel_layout, const SampleFormat::Format &format) :
|
||||
AudioParams(sample_rate, channel_layout),
|
||||
format_(format)
|
||||
{
|
||||
}
|
||||
|
||||
AudioRenderingParams::AudioRenderingParams(const AudioParams ¶ms, const SampleFormat::Format &format) :
|
||||
AudioParams(params),
|
||||
format_(format)
|
||||
{
|
||||
}
|
||||
|
||||
int AudioRenderingParams::time_to_bytes(const double &time) const
|
||||
int AudioParams::time_to_bytes(const double &time) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return time_to_samples(time) * channel_count() * bytes_per_sample_per_channel();
|
||||
}
|
||||
|
||||
const SampleFormat::Format &AudioRenderingParams::format() const
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
||||
bool AudioRenderingParams::operator==(const AudioRenderingParams &other) const
|
||||
bool AudioParams::operator==(const AudioParams &other) const
|
||||
{
|
||||
return (format() == other.format()
|
||||
&& sample_rate() == other.sample_rate()
|
||||
&& channel_layout() == other.channel_layout());
|
||||
}
|
||||
|
||||
bool AudioRenderingParams::operator!=(const AudioRenderingParams &other) const
|
||||
bool AudioParams::operator!=(const AudioParams &other) const
|
||||
{
|
||||
return (format() != other.format()
|
||||
|| sample_rate() != other.sample_rate()
|
||||
|| channel_layout() != other.channel_layout());
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
int AudioRenderingParams::time_to_bytes(const rational &time) const
|
||||
int AudioParams::time_to_bytes(const rational &time) const
|
||||
{
|
||||
return time_to_bytes(time.toDouble());
|
||||
}
|
||||
|
||||
int AudioRenderingParams::time_to_samples(const double &time) const
|
||||
int AudioParams::time_to_samples(const double &time) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return qFloor(time * sample_rate());
|
||||
}
|
||||
|
||||
int AudioRenderingParams::time_to_samples(const rational &time) const
|
||||
int AudioParams::time_to_samples(const rational &time) const
|
||||
{
|
||||
return time_to_samples(time.toDouble());
|
||||
}
|
||||
|
||||
int AudioRenderingParams::samples_to_bytes(const int &samples) const
|
||||
int AudioParams::samples_to_bytes(const int &samples) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return samples * channel_count() * bytes_per_sample_per_channel();
|
||||
}
|
||||
|
||||
rational AudioRenderingParams::samples_to_time(const int &samples) const
|
||||
rational AudioParams::samples_to_time(const int &samples) const
|
||||
{
|
||||
return rational(samples, sample_rate());
|
||||
}
|
||||
|
||||
int AudioRenderingParams::bytes_to_samples(const int &bytes) const
|
||||
int AudioParams::bytes_to_samples(const int &bytes) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return bytes / (channel_count() * bytes_per_sample_per_channel());
|
||||
}
|
||||
|
||||
rational AudioRenderingParams::bytes_to_time(const int &bytes) const
|
||||
rational AudioParams::bytes_to_time(const int &bytes) const
|
||||
{
|
||||
Q_ASSERT(is_valid());
|
||||
|
||||
return samples_to_time(bytes_to_samples(bytes));
|
||||
}
|
||||
|
||||
int AudioRenderingParams::channel_count() const
|
||||
int AudioParams::channel_count() const
|
||||
{
|
||||
return av_get_channel_layout_nb_channels(channel_layout());
|
||||
}
|
||||
|
||||
int AudioRenderingParams::bytes_per_sample_per_channel() const
|
||||
int AudioParams::bytes_per_sample_per_channel() const
|
||||
{
|
||||
switch (format_) {
|
||||
case SampleFormat::SAMPLE_FMT_U8:
|
||||
@@ -165,12 +114,12 @@ int AudioRenderingParams::bytes_per_sample_per_channel() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AudioRenderingParams::bits_per_sample() const
|
||||
int AudioParams::bits_per_sample() const
|
||||
{
|
||||
return bytes_per_sample_per_channel() * 8;
|
||||
}
|
||||
|
||||
bool AudioRenderingParams::is_valid() const
|
||||
bool AudioParams::is_valid() const
|
||||
{
|
||||
bool valid = (sample_rate() > 0
|
||||
&& channel_layout() > 0
|
||||
|
||||
Reference in New Issue
Block a user