start moving core frameworks to external libraries
This commit is contained in:
@@ -27,8 +27,6 @@ set(OLIVE_SOURCES
|
||||
render/audiowaveformcache.cpp
|
||||
render/audiowaveformcache.h
|
||||
render/cancelatom.h
|
||||
render/color.cpp
|
||||
render/color.h
|
||||
render/colorprocessor.cpp
|
||||
render/colorprocessor.h
|
||||
render/colorprocessorcache.h
|
||||
|
||||
@@ -203,7 +203,7 @@ void AudioParams::Load(QXmlStreamReader *reader)
|
||||
} else if (reader->name() == QStringLiteral("duration")) {
|
||||
set_duration(reader->readElementText().toLongLong());
|
||||
} else if (reader->name() == QStringLiteral("timebase")) {
|
||||
set_time_base(rational::fromString(reader->readElementText()));
|
||||
set_time_base(rational::fromString(reader->readElementText().toStdString()));
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
@@ -218,7 +218,7 @@ void AudioParams::Save(QXmlStreamWriter *writer) const
|
||||
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"), timebase_.toString());
|
||||
writer->writeTextElement(QStringLiteral("timebase"), QString::fromStdString(timebase_.toString()));
|
||||
}
|
||||
|
||||
QString AudioParams::SampleRateToString(const int &sample_rate)
|
||||
|
||||
@@ -25,14 +25,15 @@ extern "C" {
|
||||
#include <libavutil/channel_layout.h>
|
||||
}
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QtMath>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "common/rational.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
using namespace core;
|
||||
|
||||
class AudioParams {
|
||||
public:
|
||||
// Only append to this list (never insert) because indexes are used in serialized files
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define AUDIOPLAYBACKCACHE_H
|
||||
|
||||
#include "audio/audiovisualwaveform.h"
|
||||
#include "common/timerange.h"
|
||||
#include "codec/samplebuffer.h"
|
||||
#include "render/playbackcache.h"
|
||||
|
||||
|
||||
@@ -97,9 +97,9 @@ void AudioWaveformCache::SetPassthrough(PlaybackCache *cache)
|
||||
for (const TimeRange &r : c->GetValidatedRanges()) {
|
||||
WaveformPassthrough t = r;
|
||||
t.waveform = c->waveforms_;
|
||||
passthroughs_.append(t);
|
||||
passthroughs_.push_back(t);
|
||||
}
|
||||
passthroughs_.append(c->passthroughs_);
|
||||
passthroughs_.insert(passthroughs_.end(), c->passthroughs_.begin(), c->passthroughs_.end());
|
||||
|
||||
SetParameters(c->GetParameters());
|
||||
SetSavingEnabled(c->IsSavingEnabled());
|
||||
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
WaveformPtr waveform;
|
||||
};
|
||||
|
||||
QVector<WaveformPassthrough> passthroughs_;
|
||||
std::vector<WaveformPassthrough> passthroughs_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,300 +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 "color.h"
|
||||
|
||||
#include <OpenImageIO/imagebuf.h>
|
||||
|
||||
#include "common/clamp.h"
|
||||
#include "common/oiioutils.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
Color Color::fromHsv(const DataType &h, const DataType &s, const DataType &v)
|
||||
{
|
||||
DataType C = s * v;
|
||||
DataType X = C * (1.0 - abs(fmod(h / 60.0, 2.0) - 1.0));
|
||||
DataType m = v - C;
|
||||
DataType Rs, Gs, Bs;
|
||||
|
||||
if(h >= 0.0 && h < 60.0) {
|
||||
Rs = C;
|
||||
Gs = X;
|
||||
Bs = 0.0;
|
||||
}
|
||||
else if(h >= 60.0 && h < 120.0) {
|
||||
Rs = X;
|
||||
Gs = C;
|
||||
Bs = 0.0;
|
||||
}
|
||||
else if(h >= 120.0 && h < 180.0) {
|
||||
Rs = 0.0;
|
||||
Gs = C;
|
||||
Bs = X;
|
||||
}
|
||||
else if(h >= 180.0 && h < 240.0) {
|
||||
Rs = 0.0;
|
||||
Gs = X;
|
||||
Bs = C;
|
||||
}
|
||||
else if(h >= 240.0 && h < 300.0) {
|
||||
Rs = X;
|
||||
Gs = 0.0;
|
||||
Bs = C;
|
||||
}
|
||||
else {
|
||||
Rs = C;
|
||||
Gs = 0.0;
|
||||
Bs = X;
|
||||
}
|
||||
|
||||
return Color(Rs + m, Gs + m, Bs + m);
|
||||
}
|
||||
|
||||
Color::Color(const char *data, const VideoParams::Format &format, int ch_layout)
|
||||
{
|
||||
*this = fromData(data, format, ch_layout);
|
||||
}
|
||||
|
||||
Color::Color(const QColor &c)
|
||||
{
|
||||
set_red(c.redF());
|
||||
set_green(c.greenF());
|
||||
set_blue(c.blueF());
|
||||
set_alpha(c.alphaF());
|
||||
}
|
||||
|
||||
void Color::toHsv(DataType *hue, DataType *sat, DataType *val) const
|
||||
{
|
||||
DataType fCMax = qMax(qMax(red(), green()), blue());
|
||||
DataType fCMin = qMin(qMin(red(), green()), blue());
|
||||
DataType fDelta = fCMax - fCMin;
|
||||
|
||||
if(fDelta > 0) {
|
||||
if(fCMax == red()) {
|
||||
*hue = 60 * (fmod(((green() - blue()) / fDelta), 6));
|
||||
} else if(fCMax == green()) {
|
||||
*hue = 60 * (((blue() - red()) / fDelta) + 2);
|
||||
} else if(fCMax == blue()) {
|
||||
*hue = 60 * (((red() - green()) / fDelta) + 4);
|
||||
}
|
||||
|
||||
if(fCMax > 0) {
|
||||
*sat = fDelta / fCMax;
|
||||
} else {
|
||||
*sat = 0;
|
||||
}
|
||||
|
||||
*val = fCMax;
|
||||
} else {
|
||||
*hue = 0;
|
||||
*sat = 0;
|
||||
*val = fCMax;
|
||||
}
|
||||
|
||||
if(*hue < 0) {
|
||||
*hue = 360 + *hue;
|
||||
}
|
||||
}
|
||||
|
||||
Color::DataType Color::hsv_hue() const
|
||||
{
|
||||
DataType h, s, v;
|
||||
toHsv(&h, &s, &v);
|
||||
return h;
|
||||
}
|
||||
|
||||
Color::DataType Color::hsv_saturation() const
|
||||
{
|
||||
DataType h, s, v;
|
||||
toHsv(&h, &s, &v);
|
||||
return s;
|
||||
}
|
||||
|
||||
Color::DataType Color::value() const
|
||||
{
|
||||
DataType h, s, v;
|
||||
toHsv(&h, &s, &v);
|
||||
return v;
|
||||
}
|
||||
|
||||
void Color::toHsl(DataType *hue, DataType *sat, DataType *lightness) const
|
||||
{
|
||||
DataType fCMin = qMin(red(), qMin(green(), blue()));
|
||||
DataType fCMax = qMax(red(), qMax(green(), blue()));
|
||||
|
||||
*lightness = 0.5 * (fCMin + fCMax);
|
||||
|
||||
if (fCMin == fCMax)
|
||||
{
|
||||
*sat = 0;
|
||||
*hue = 0;
|
||||
return;
|
||||
|
||||
}
|
||||
else if (*lightness < 0.5)
|
||||
{
|
||||
*sat = (fCMax - fCMin) / (fCMax + fCMin);
|
||||
}
|
||||
else
|
||||
{
|
||||
*sat = (fCMax - fCMin) / (2.0 - fCMax - fCMin);
|
||||
}
|
||||
|
||||
if (fCMax == red())
|
||||
{
|
||||
*hue = 60 * (green() - blue()) / (fCMax - fCMin);
|
||||
}
|
||||
if (fCMax == green())
|
||||
{
|
||||
*hue = 60 * (blue() - red()) / (fCMax - fCMin) + 120;
|
||||
}
|
||||
if (fCMax == blue())
|
||||
{
|
||||
*hue = 60 * (red() - green()) / (fCMax - fCMin) + 240;
|
||||
}
|
||||
if (*hue < 0)
|
||||
{
|
||||
*hue = *hue + 360;
|
||||
}
|
||||
}
|
||||
|
||||
Color::DataType Color::hsl_hue() const
|
||||
{
|
||||
DataType h, s, l;
|
||||
toHsl(&h, &s, &l);
|
||||
return h;
|
||||
}
|
||||
|
||||
Color::DataType Color::hsl_saturation() const
|
||||
{
|
||||
DataType h, s, l;
|
||||
toHsl(&h, &s, &l);
|
||||
return s;
|
||||
}
|
||||
|
||||
Color::DataType Color::lightness() const
|
||||
{
|
||||
DataType h, s, l;
|
||||
toHsl(&h, &s, &l);
|
||||
return l;
|
||||
}
|
||||
|
||||
void Color::toData(char *data, const VideoParams::Format &format, int ch_layout) const
|
||||
{
|
||||
OIIO::convert_pixel_values(OIIO::TypeDesc::FLOAT,
|
||||
data_,
|
||||
OIIOUtils::GetOIIOBaseTypeFromFormat(format),
|
||||
data,
|
||||
ch_layout);
|
||||
}
|
||||
|
||||
Color Color::fromData(const char *data, const VideoParams::Format &format, int ch_layout)
|
||||
{
|
||||
Color c;
|
||||
|
||||
OIIO::convert_pixel_values(OIIOUtils::GetOIIOBaseTypeFromFormat(format),
|
||||
data,
|
||||
OIIO::TypeDesc::FLOAT,
|
||||
c.data_,
|
||||
ch_layout);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
QColor Color::toQColor() const
|
||||
{
|
||||
QColor c;
|
||||
|
||||
// QColor only supports values from 0.0 to 1.0 and are only used for UI representations
|
||||
c.setRedF(clamp(red(), 0.0f, 1.0f));
|
||||
c.setGreenF(clamp(green(), 0.0f, 1.0f));
|
||||
c.setBlueF(clamp(blue(), 0.0f, 1.0f));
|
||||
c.setAlphaF(clamp(alpha(), 0.0f, 1.0f));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
Color::DataType Color::GetRoughLuminance() const
|
||||
{
|
||||
return (2*red()+blue()+3*green())/6.0;
|
||||
}
|
||||
|
||||
Color &Color::operator+=(const Color &rhs)
|
||||
{
|
||||
for (int i=0;i<VideoParams::kRGBAChannelCount;i++) {
|
||||
data_[i] += rhs.data_[i];
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Color &Color::operator-=(const Color &rhs)
|
||||
{
|
||||
for (int i=0;i<VideoParams::kRGBAChannelCount;i++) {
|
||||
data_[i] -= rhs.data_[i];
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Color &Color::operator+=(const DataType &rhs)
|
||||
{
|
||||
for (int i=0;i<VideoParams::kRGBAChannelCount;i++) {
|
||||
data_[i] += rhs;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Color &Color::operator-=(const DataType &rhs)
|
||||
{
|
||||
for (int i=0;i<VideoParams::kRGBAChannelCount;i++) {
|
||||
data_[i] -= rhs;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Color &Color::operator*=(const DataType &rhs)
|
||||
{
|
||||
for (int i=0;i<VideoParams::kRGBAChannelCount;i++) {
|
||||
data_[i] *= rhs;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Color &Color::operator/=(const DataType &rhs)
|
||||
{
|
||||
for (int i=0;i<VideoParams::kRGBAChannelCount;i++) {
|
||||
data_[i] /= rhs;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const olive::Color &r)
|
||||
{
|
||||
debug.nospace() << "[R: " << r.red() << ", G: " << r.green() << ", B: " << r.blue() << ", A: " << r.alpha() << "]";
|
||||
return debug.space();
|
||||
}
|
||||
@@ -1,161 +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 COLOR_H
|
||||
#define COLOR_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
|
||||
#include "common/define.h"
|
||||
#include "render/videoparams.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
/**
|
||||
* @brief High precision 32-bit DataType based RGBA color value
|
||||
*/
|
||||
class Color
|
||||
{
|
||||
public:
|
||||
using DataType = float;
|
||||
|
||||
Color()
|
||||
{
|
||||
for (int i=0;i<VideoParams::kRGBAChannelCount;i++) {
|
||||
data_[i] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
Color(const DataType& r, const DataType& g, const DataType& b, const DataType& a = 1.0f)
|
||||
{
|
||||
data_[0] = r;
|
||||
data_[1] = g;
|
||||
data_[2] = b;
|
||||
data_[3] = a;
|
||||
}
|
||||
|
||||
Color(const char *data, const VideoParams::Format &format, int ch_layout);
|
||||
|
||||
Color(const QColor& c);
|
||||
|
||||
/**
|
||||
* @brief Creates a Color struct from hue/saturation/value
|
||||
*
|
||||
* Hue expects a value between 0.0 and 360.0. Saturation and Value expect a value between 0.0 and 1.0.
|
||||
*/
|
||||
static Color fromHsv(const DataType& h, const DataType& s, const DataType &v);
|
||||
|
||||
const DataType& red() const {return data_[0];}
|
||||
const DataType& green() const {return data_[1];}
|
||||
const DataType& blue() const {return data_[2];}
|
||||
const DataType& alpha() const {return data_[3];}
|
||||
|
||||
void toHsv(DataType* hue, DataType* sat, DataType* val) const;
|
||||
DataType hsv_hue() const;
|
||||
DataType hsv_saturation() const;
|
||||
DataType value() const;
|
||||
|
||||
void toHsl(DataType* hue, DataType* sat, DataType* lightness) const;
|
||||
DataType hsl_hue() const;
|
||||
DataType hsl_saturation() const;
|
||||
DataType lightness() const;
|
||||
|
||||
void set_red(const DataType& red) {data_[0] = red;}
|
||||
void set_green(const DataType& green) {data_[1] = green;}
|
||||
void set_blue(const DataType& blue) {data_[2] = blue;}
|
||||
void set_alpha(const DataType& alpha) {data_[3] = alpha;}
|
||||
|
||||
DataType* data() {return data_;}
|
||||
const DataType* data() const {return data_;}
|
||||
|
||||
void toData(char* data, const VideoParams::Format& format, int ch_layout) const;
|
||||
|
||||
static Color fromData(const char* data, const VideoParams::Format& format, int ch_layout);
|
||||
|
||||
QColor toQColor() const;
|
||||
|
||||
// Suuuuper rough luminance value mostly used for UI (determining whether to overlay with black
|
||||
// or white text)
|
||||
DataType GetRoughLuminance() const;
|
||||
|
||||
// Assignment math operators
|
||||
Color& operator+=(const Color& rhs);
|
||||
Color& operator-=(const Color& rhs);
|
||||
Color& operator+=(const DataType& rhs);
|
||||
Color& operator-=(const DataType& rhs);
|
||||
Color& operator*=(const DataType& rhs);
|
||||
Color& operator/=(const DataType& rhs);
|
||||
|
||||
// Binary math operators
|
||||
Color operator+(const Color& rhs) const
|
||||
{
|
||||
Color c(*this);
|
||||
c += rhs;
|
||||
return c;
|
||||
}
|
||||
|
||||
Color operator-(const Color& rhs) const
|
||||
{
|
||||
Color c(*this);
|
||||
c -= rhs;
|
||||
return c;
|
||||
}
|
||||
|
||||
Color operator+(const DataType& rhs) const
|
||||
{
|
||||
Color c(*this);
|
||||
c += rhs;
|
||||
return c;
|
||||
}
|
||||
|
||||
Color operator-(const DataType& rhs) const
|
||||
{
|
||||
Color c(*this);
|
||||
c -= rhs;
|
||||
return c;
|
||||
}
|
||||
|
||||
Color operator*(const DataType& rhs) const
|
||||
{
|
||||
Color c(*this);
|
||||
c *= rhs;
|
||||
return c;
|
||||
}
|
||||
|
||||
Color operator/(const DataType& rhs) const
|
||||
{
|
||||
Color c(*this);
|
||||
c /= rhs;
|
||||
return c;
|
||||
}
|
||||
|
||||
private:
|
||||
DataType data_[VideoParams::kRGBAChannelCount];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const olive::Color& r);
|
||||
|
||||
Q_DECLARE_METATYPE(olive::Color)
|
||||
|
||||
#endif // COLOR_H
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include "codec/frame.h"
|
||||
#include "common/ocioutils.h"
|
||||
#include "render/color.h"
|
||||
#include "render/colortransform.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -158,11 +158,11 @@ FramePtr FrameHashCache::LoadCacheFrame(const QString &fn)
|
||||
|
||||
int div = qMax(1, static_cast<const Imf::IntAttribute&>(file.header()["oliveDivider"]).value());
|
||||
|
||||
VideoParams::Format image_format;
|
||||
PixelFormat image_format;
|
||||
if (pix_type == Imf::HALF) {
|
||||
image_format = VideoParams::kFormatFloat16;
|
||||
image_format = PixelFormat::F16;
|
||||
} else {
|
||||
image_format = VideoParams::kFormatFloat32;
|
||||
image_format = PixelFormat::F32;
|
||||
}
|
||||
|
||||
int channel_count = has_alpha ? VideoParams::kRGBAChannelCount : VideoParams::kRGBChannelCount;
|
||||
@@ -202,7 +202,7 @@ FramePtr FrameHashCache::LoadCacheFrame(const QString &fn)
|
||||
|
||||
// FIXME: Hardcoded
|
||||
const int div = 1;
|
||||
const VideoParams::Format image_format = VideoParams::kFormatUnsigned8;
|
||||
const PixelFormat image_format = PixelFormat::U8;
|
||||
const int channel_count = 4;
|
||||
const rational par(1, 1);
|
||||
|
||||
@@ -343,7 +343,7 @@ bool FrameHashCache::SaveCacheFrame(const QString &filename, const FramePtr fram
|
||||
// Floating point types are stored in EXR
|
||||
Imf::PixelType pix_type;
|
||||
|
||||
if (frame->format() == VideoParams::kFormatFloat16) {
|
||||
if (frame->format() == PixelFormat::F16) {
|
||||
pix_type = Imf::HALF;
|
||||
} else {
|
||||
pix_type = Imf::FLOAT;
|
||||
@@ -392,22 +392,22 @@ bool FrameHashCache::SaveCacheFrame(const QString &filename, const FramePtr fram
|
||||
QImage::Format fmt = QImage::Format_Invalid;
|
||||
|
||||
switch (frame->format()) {
|
||||
case VideoParams::kFormatUnsigned8:
|
||||
case PixelFormat::U8:
|
||||
if (frame->channel_count() == VideoParams::kRGBAChannelCount){
|
||||
fmt = QImage::Format_RGBA8888_Premultiplied;
|
||||
} else if (frame->channel_count() == VideoParams::kRGBChannelCount){
|
||||
fmt = QImage::Format_RGB888;
|
||||
}
|
||||
break;
|
||||
case VideoParams::kFormatUnsigned16:
|
||||
case PixelFormat::U16:
|
||||
if (frame->channel_count() == VideoParams::kRGBAChannelCount){
|
||||
fmt = QImage::Format_RGBA64_Premultiplied;
|
||||
}
|
||||
break;
|
||||
case VideoParams::kFormatFloat16:
|
||||
case VideoParams::kFormatFloat32:
|
||||
case VideoParams::kFormatCount:
|
||||
case VideoParams::kFormatInvalid:
|
||||
case PixelFormat::F16:
|
||||
case PixelFormat::F32:
|
||||
case PixelFormat::FORMAT_COUNT:
|
||||
case PixelFormat::INVALID:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
#ifndef VIDEORENDERFRAMECACHE_H
|
||||
#define VIDEORENDERFRAMECACHE_H
|
||||
|
||||
#include "common/rational.h"
|
||||
#include "common/timecodefunctions.h"
|
||||
#include "common/timerange.h"
|
||||
#include "codec/frame.h"
|
||||
#include "render/playbackcache.h"
|
||||
#include "render/videoparams.h"
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include "acceleratedjob.h"
|
||||
#include "codec/samplebuffer.h"
|
||||
#include "common/timerange.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ ManagedColor::ManagedColor(const double &r, const double &g, const double &b, co
|
||||
{
|
||||
}
|
||||
|
||||
ManagedColor::ManagedColor(const char *data, const VideoParams::Format &format, int channel_layout) :
|
||||
ManagedColor::ManagedColor(const char *data, const PixelFormat &format, int channel_layout) :
|
||||
Color(data, format, channel_layout)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
#ifndef MANAGEDCOLOR_H
|
||||
#define MANAGEDCOLOR_H
|
||||
|
||||
#include "color.h"
|
||||
#include <olive/core/core.h>
|
||||
|
||||
#include "colortransform.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -31,7 +32,7 @@ class ManagedColor : public Color
|
||||
public:
|
||||
ManagedColor();
|
||||
ManagedColor(const double& r, const double& g, const double& b, const double& a = 1.0);
|
||||
ManagedColor(const char *data, const VideoParams::Format &format, int channel_layout);
|
||||
ManagedColor(const char *data, const PixelFormat &format, int channel_layout);
|
||||
ManagedColor(const Color& c);
|
||||
|
||||
const QString& color_input() const;
|
||||
|
||||
@@ -189,7 +189,7 @@ void OpenGLRenderer::ClearDestination(Texture *texture, double r, double g, doub
|
||||
}
|
||||
}
|
||||
|
||||
QVariant OpenGLRenderer::CreateNativeTexture(int width, int height, int depth, VideoParams::Format format, int channel_count, const void *data, int linesize)
|
||||
QVariant OpenGLRenderer::CreateNativeTexture(int width, int height, int depth, PixelFormat format, int channel_count, const void *data, int linesize)
|
||||
{
|
||||
GL_PREAMBLE;
|
||||
|
||||
@@ -673,10 +673,10 @@ void OpenGLRenderer::Blit(QVariant s, ShaderJob job, Texture *destination, Video
|
||||
vao_.destroy();
|
||||
}
|
||||
|
||||
GLint OpenGLRenderer::GetInternalFormat(VideoParams::Format format, int channel_layout)
|
||||
GLint OpenGLRenderer::GetInternalFormat(PixelFormat format, int channel_layout)
|
||||
{
|
||||
switch (format) {
|
||||
case VideoParams::kFormatUnsigned8:
|
||||
case PixelFormat::U8:
|
||||
switch (channel_layout) {
|
||||
case 1:
|
||||
return GL_R8;
|
||||
@@ -688,7 +688,7 @@ GLint OpenGLRenderer::GetInternalFormat(VideoParams::Format format, int channel_
|
||||
return GL_RGBA8;
|
||||
}
|
||||
break;
|
||||
case VideoParams::kFormatUnsigned16:
|
||||
case PixelFormat::U16:
|
||||
switch (channel_layout) {
|
||||
case 1:
|
||||
return GL_R16;
|
||||
@@ -700,7 +700,7 @@ GLint OpenGLRenderer::GetInternalFormat(VideoParams::Format format, int channel_
|
||||
return GL_RGBA16;
|
||||
}
|
||||
break;
|
||||
case VideoParams::kFormatFloat16:
|
||||
case PixelFormat::F16:
|
||||
switch (channel_layout) {
|
||||
case 1:
|
||||
return GL_R16F;
|
||||
@@ -712,7 +712,7 @@ GLint OpenGLRenderer::GetInternalFormat(VideoParams::Format format, int channel_
|
||||
return GL_RGBA16F;
|
||||
}
|
||||
break;
|
||||
case VideoParams::kFormatFloat32:
|
||||
case PixelFormat::F32:
|
||||
switch (channel_layout) {
|
||||
case 1:
|
||||
return GL_R32F;
|
||||
@@ -724,28 +724,28 @@ GLint OpenGLRenderer::GetInternalFormat(VideoParams::Format format, int channel_
|
||||
return GL_RGBA32F;
|
||||
}
|
||||
break;
|
||||
case VideoParams::kFormatInvalid:
|
||||
case VideoParams::kFormatCount:
|
||||
case PixelFormat::INVALID:
|
||||
case PixelFormat::FORMAT_COUNT:
|
||||
break;
|
||||
}
|
||||
|
||||
return GL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
GLenum OpenGLRenderer::GetPixelType(VideoParams::Format format)
|
||||
GLenum OpenGLRenderer::GetPixelType(PixelFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case VideoParams::kFormatUnsigned8:
|
||||
case PixelFormat::U8:
|
||||
return GL_UNSIGNED_BYTE;
|
||||
case VideoParams::kFormatUnsigned16:
|
||||
case PixelFormat::U16:
|
||||
return GL_UNSIGNED_SHORT;
|
||||
case VideoParams::kFormatFloat16:
|
||||
case PixelFormat::F16:
|
||||
return GL_HALF_FLOAT;
|
||||
case VideoParams::kFormatFloat32:
|
||||
case PixelFormat::F32:
|
||||
return GL_FLOAT;
|
||||
|
||||
case VideoParams::kFormatInvalid:
|
||||
case VideoParams::kFormatCount:
|
||||
case PixelFormat::INVALID:
|
||||
case PixelFormat::FORMAT_COUNT:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,16 +70,16 @@ protected:
|
||||
olive::VideoParams destination_params,
|
||||
bool clear_destination) override;
|
||||
|
||||
virtual QVariant CreateNativeTexture(int width, int height, int depth, olive::VideoParams::Format format, int channel_count, const void* data = nullptr, int linesize = 0) override;
|
||||
virtual QVariant CreateNativeTexture(int width, int height, int depth, PixelFormat format, int channel_count, const void* data = nullptr, int linesize = 0) override;
|
||||
|
||||
virtual void DestroyNativeTexture(QVariant texture) override;
|
||||
|
||||
virtual void DestroyInternal() override;
|
||||
|
||||
private:
|
||||
static GLint GetInternalFormat(VideoParams::Format format, int channel_layout);
|
||||
static GLint GetInternalFormat(PixelFormat format, int channel_layout);
|
||||
|
||||
static GLenum GetPixelType(VideoParams::Format format);
|
||||
static GLenum GetPixelType(PixelFormat format);
|
||||
|
||||
static GLenum GetPixelFormat(int channel_count);
|
||||
|
||||
@@ -105,7 +105,7 @@ private:
|
||||
int width;
|
||||
int height;
|
||||
int depth;
|
||||
VideoParams::Format format;
|
||||
PixelFormat format;
|
||||
int channel_count;
|
||||
|
||||
bool operator==(const TextureCacheKey &rhs) const
|
||||
|
||||
@@ -115,7 +115,7 @@ void PlaybackCache::LoadState()
|
||||
|
||||
Passthrough p = TimeRange(rational(in_num, in_den), rational(out_num, out_den));
|
||||
p.cache = id;
|
||||
passthroughs_.append(p);
|
||||
passthroughs_.push_back(p);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -136,7 +136,7 @@ void PlaybackCache::SaveState()
|
||||
|
||||
QDir cache_dir = GetThisCacheDirectory();
|
||||
QFile f(cache_dir.filePath(QStringLiteral("state")));
|
||||
if (validated_.isEmpty() && passthroughs_.isEmpty()) {
|
||||
if (validated_.isEmpty() && passthroughs_.empty()) {
|
||||
if (f.exists()) {
|
||||
f.remove();
|
||||
}
|
||||
@@ -150,7 +150,8 @@ void PlaybackCache::SaveState()
|
||||
|
||||
SaveStateEvent(s);
|
||||
|
||||
s << validated_.size();
|
||||
// Using "int" for backwards compatibility with when we used QVector, could potentially overflow
|
||||
s << int(validated_.size());
|
||||
|
||||
for (const TimeRange &r : validated_) {
|
||||
s << r.in().numerator();
|
||||
@@ -159,7 +160,8 @@ void PlaybackCache::SaveState()
|
||||
s << r.out().denominator();
|
||||
}
|
||||
|
||||
s << passthroughs_.size();
|
||||
// Using "int" for backwards compatibility with when we used QVector, could potentially overflow
|
||||
s << int(passthroughs_.size());
|
||||
|
||||
for (const Passthrough &p : passthroughs_) {
|
||||
s << p.in().numerator();
|
||||
@@ -211,7 +213,7 @@ void PlaybackCache::SetPassthrough(PlaybackCache *cache)
|
||||
passthroughs_.push_back(p);
|
||||
}
|
||||
|
||||
passthroughs_.append(cache->GetPassthroughs());
|
||||
passthroughs_.insert(passthroughs_.end(), cache->GetPassthroughs().begin(), cache->GetPassthroughs().end());
|
||||
|
||||
if (saving_enabled_) {
|
||||
SaveState();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#ifndef PLAYBACKCACHE_H
|
||||
#define PLAYBACKCACHE_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QDir>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
@@ -28,7 +29,8 @@
|
||||
#include <QUuid>
|
||||
|
||||
#include "common/jobtime.h"
|
||||
#include "common/timerange.h"
|
||||
|
||||
using namespace olive::core;
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -96,9 +98,9 @@ public:
|
||||
QUuid cache;
|
||||
};
|
||||
|
||||
const QVector<Passthrough> &GetPassthroughs() const { return passthroughs_; }
|
||||
const std::vector<Passthrough> &GetPassthroughs() const { return passthroughs_; }
|
||||
|
||||
void ClearRequestRange(const olive::TimeRange &r)
|
||||
void ClearRequestRange(const TimeRange &r)
|
||||
{
|
||||
requested_.remove(r);
|
||||
}
|
||||
@@ -113,14 +115,14 @@ public:
|
||||
public slots:
|
||||
void InvalidateAll();
|
||||
|
||||
void Request(const olive::TimeRange &r);
|
||||
void Request(const TimeRange &r);
|
||||
|
||||
signals:
|
||||
void Invalidated(const olive::TimeRange& r);
|
||||
void Invalidated(const TimeRange& r);
|
||||
|
||||
void Validated(const olive::TimeRange& r);
|
||||
void Validated(const TimeRange& r);
|
||||
|
||||
void Requested(const olive::TimeRange& r);
|
||||
void Requested(const TimeRange& r);
|
||||
|
||||
void CancelAll();
|
||||
|
||||
@@ -146,7 +148,7 @@ private:
|
||||
|
||||
QMutex mutex_;
|
||||
|
||||
QVector<Passthrough> passthroughs_;
|
||||
std::vector<Passthrough> passthroughs_;
|
||||
|
||||
qint64 last_loaded_state_;
|
||||
|
||||
|
||||
@@ -589,7 +589,7 @@ RenderTicketWatcher* PreviewAutoCacher::RenderFrame(Node *node, const rational&
|
||||
if (ThumbnailCache *wave_cache = dynamic_cast<ThumbnailCache *>(cache)) {
|
||||
rvp.video_params.set_divider(VideoParams::GetDividerForTargetResolution(rvp.video_params.width(), rvp.video_params.height(), 160, 120));
|
||||
rvp.force_color_output = display_color_processor_;
|
||||
rvp.force_format = VideoParams::kFormatUnsigned8;
|
||||
rvp.force_format = PixelFormat::U8;
|
||||
} else {
|
||||
frame_cache->SetTimebase(viewer_node_->GetVideoParams().frame_rate_as_time_base());
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, Renderer::Col
|
||||
}
|
||||
|
||||
// Allocate 3D LUT
|
||||
color_ctx.lut3d_textures[i].texture = CreateTexture(VideoParams(edge_len, edge_len, edge_len, VideoParams::kFormatFloat32, VideoParams::kRGBChannelCount), values);
|
||||
color_ctx.lut3d_textures[i].texture = CreateTexture(VideoParams(edge_len, edge_len, edge_len, PixelFormat::F32, VideoParams::kRGBChannelCount), values);
|
||||
color_ctx.lut3d_textures[i].name = sampler_name;
|
||||
color_ctx.lut3d_textures[i].interpolation = (interpolation == OCIO::INTERP_NEAREST) ? Texture::kNearest : Texture::kLinear;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, Renderer::Col
|
||||
}
|
||||
|
||||
// Allocate 1D LUT
|
||||
color_ctx.lut1d_textures[i].texture = CreateTexture(VideoParams(width, height, VideoParams::kFormatFloat32, (channel == OCIO::GpuShaderDesc::TEXTURE_RED_CHANNEL) ? 1 : VideoParams::kRGBChannelCount), values);
|
||||
color_ctx.lut1d_textures[i].texture = CreateTexture(VideoParams(width, height, PixelFormat::F32, (channel == OCIO::GpuShaderDesc::TEXTURE_RED_CHANNEL) ? 1 : VideoParams::kRGBChannelCount), values);
|
||||
color_ctx.lut1d_textures[i].name = sampler_name;
|
||||
color_ctx.lut1d_textures[i].interpolation = (interpolation == OCIO::INTERP_NEAREST) ? Texture::kNearest : Texture::kLinear;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <QVariant>
|
||||
|
||||
#include "common/define.h"
|
||||
#include "common/timerange.h"
|
||||
#include "node/node.h"
|
||||
#include "render/colorprocessor.h"
|
||||
#include "render/job/colortransformjob.h"
|
||||
@@ -106,7 +105,7 @@ protected:
|
||||
olive::VideoParams destination_params,
|
||||
bool clear_destination) = 0;
|
||||
|
||||
virtual QVariant CreateNativeTexture(int width, int height, int depth, olive::VideoParams::Format format, int channel_count, const void* data = nullptr, int linesize = 0) = 0;
|
||||
virtual QVariant CreateNativeTexture(int width, int height, int depth, PixelFormat format, int channel_count, const void* data = nullptr, int linesize = 0) = 0;
|
||||
|
||||
virtual void DestroyNativeTexture(QVariant texture) = 0;
|
||||
|
||||
@@ -139,7 +138,7 @@ private:
|
||||
int width;
|
||||
int height;
|
||||
int depth;
|
||||
VideoParams::Format format;
|
||||
PixelFormat format;
|
||||
int channel_count;
|
||||
QVariant handle;
|
||||
qint64 accessed;
|
||||
|
||||
@@ -29,7 +29,7 @@ void RenderJobTracker::insert(const TimeRange &range, JobTime job_time)
|
||||
|
||||
// Now append the job
|
||||
TimeRangeWithJob job(range, job_time);
|
||||
jobs_.append(job);
|
||||
jobs_.push_back(job);
|
||||
}
|
||||
|
||||
void RenderJobTracker::insert(const TimeRangeList &ranges, JobTime job_time)
|
||||
|
||||
@@ -21,11 +21,14 @@
|
||||
#ifndef RENDERJOBTRACKER_H
|
||||
#define RENDERJOBTRACKER_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
|
||||
#include "common/jobtime.h"
|
||||
#include "common/timerange.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
using namespace core;
|
||||
|
||||
class RenderJobTracker
|
||||
{
|
||||
public:
|
||||
@@ -59,7 +62,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
QVector<TimeRangeWithJob> jobs_;
|
||||
std::vector<TimeRangeWithJob> jobs_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ RenderTicketPtr RenderManager::RenderFrame(const RenderVideoParams ¶ms)
|
||||
ticket->setProperty("time", QVariant::fromValue(params.time));
|
||||
ticket->setProperty("size", params.force_size);
|
||||
ticket->setProperty("matrix", params.force_matrix);
|
||||
ticket->setProperty("format", params.force_format);
|
||||
ticket->setProperty("format", static_cast<PixelFormat::Format>(params.force_format));
|
||||
ticket->setProperty("usecache", params.use_cache);
|
||||
ticket->setProperty("channelcount", params.force_channel_count);
|
||||
ticket->setProperty("mode", params.mode);
|
||||
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
color_manager = colorman;
|
||||
use_cache = false;
|
||||
return_type = kFrame;
|
||||
force_format = VideoParams::kFormatInvalid;
|
||||
force_format = PixelFormat::INVALID;
|
||||
force_color_output = nullptr;
|
||||
force_size = QSize(0, 0);
|
||||
force_channel_count = 0;
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
QSize force_size;
|
||||
int force_channel_count;
|
||||
QMatrix4x4 force_matrix;
|
||||
VideoParams::Format force_format;
|
||||
PixelFormat force_format;
|
||||
ColorProcessorPtr force_color_output;
|
||||
};
|
||||
|
||||
|
||||
@@ -70,8 +70,8 @@ FramePtr RenderProcessor::GenerateFrame(TexturePtr texture, const rational& time
|
||||
frame_params.set_height(frame_size.height());
|
||||
}
|
||||
|
||||
VideoParams::Format frame_format = static_cast<VideoParams::Format>(ticket_->property("format").toInt());
|
||||
if (frame_format != VideoParams::kFormatInvalid) {
|
||||
PixelFormat frame_format = static_cast<PixelFormat::Format>(ticket_->property("format").toInt());
|
||||
if (frame_format != PixelFormat::INVALID) {
|
||||
frame_params.set_format(frame_format);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "codec/frame.h"
|
||||
#include "codec/samplebuffer.h"
|
||||
#include "common/cancelableobject.h"
|
||||
#include "common/timerange.h"
|
||||
#include "node/output/viewer/viewer.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -125,9 +125,9 @@ void SubtitleParams::Load(QXmlStreamReader *reader)
|
||||
|
||||
XMLAttributeLoop(reader, attr) {
|
||||
if (attr.name() == QStringLiteral("in")) {
|
||||
in = rational::fromString(attr.value().toString());
|
||||
in = rational::fromString(attr.value().toString().toStdString());
|
||||
} else if (attr.name() == QStringLiteral("out")) {
|
||||
out = rational::fromString(attr.value().toString());
|
||||
out = rational::fromString(attr.value().toString().toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,8 +152,8 @@ void SubtitleParams::Save(QXmlStreamWriter *writer) const
|
||||
writer->writeStartElement(QStringLiteral("subtitles"));
|
||||
for (auto it=this->cbegin(); it!=this->cend(); it++) {
|
||||
writer->writeStartElement(QStringLiteral("subtitle"));
|
||||
writer->writeAttribute(QStringLiteral("in"), it->time().in().toString());
|
||||
writer->writeAttribute(QStringLiteral("out"), it->time().out().toString());
|
||||
writer->writeAttribute(QStringLiteral("in"), QString::fromStdString(it->time().in().toString()));
|
||||
writer->writeAttribute(QStringLiteral("out"), QString::fromStdString(it->time().out().toString()));
|
||||
writer->writeCharacters(it->text());
|
||||
writer->writeEndElement(); // subtitle
|
||||
}
|
||||
|
||||
@@ -21,12 +21,13 @@
|
||||
#ifndef SUBTITLEPARAMS_H
|
||||
#define SUBTITLEPARAMS_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "common/timerange.h"
|
||||
using namespace olive::core;
|
||||
|
||||
namespace olive {
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
return QVector2D(params_.square_pixel_width(), params_.height());
|
||||
}
|
||||
|
||||
VideoParams::Format format() const
|
||||
PixelFormat format() const
|
||||
{
|
||||
return params_.format();
|
||||
}
|
||||
|
||||
+28
-43
@@ -24,6 +24,7 @@ extern "C" {
|
||||
#include <libavutil/avutil.h>
|
||||
}
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QtMath>
|
||||
|
||||
#include "core.h"
|
||||
@@ -69,7 +70,7 @@ VideoParams::VideoParams() :
|
||||
width_(0),
|
||||
height_(0),
|
||||
depth_(0),
|
||||
format_(kFormatInvalid),
|
||||
format_(PixelFormat::INVALID),
|
||||
channel_count_(0),
|
||||
interlacing_(Interlacing::kInterlaceNone),
|
||||
divider_(1)
|
||||
@@ -77,7 +78,7 @@ VideoParams::VideoParams() :
|
||||
set_defaults_for_footage();
|
||||
}
|
||||
|
||||
VideoParams::VideoParams(int width, int height, Format format, int nb_channels, const rational& pixel_aspect_ratio, Interlacing interlacing, int divider) :
|
||||
VideoParams::VideoParams(int width, int height, PixelFormat format, int nb_channels, const rational& pixel_aspect_ratio, Interlacing interlacing, int divider) :
|
||||
width_(width),
|
||||
height_(height),
|
||||
depth_(1),
|
||||
@@ -92,7 +93,7 @@ VideoParams::VideoParams(int width, int height, Format format, int nb_channels,
|
||||
set_defaults_for_footage();
|
||||
}
|
||||
|
||||
VideoParams::VideoParams(int width, int height, int depth, Format format, int nb_channels, const rational &pixel_aspect_ratio, VideoParams::Interlacing interlacing, int divider) :
|
||||
VideoParams::VideoParams(int width, int height, int depth, PixelFormat format, int nb_channels, const rational &pixel_aspect_ratio, VideoParams::Interlacing interlacing, int divider) :
|
||||
width_(width),
|
||||
height_(height),
|
||||
depth_(depth),
|
||||
@@ -107,7 +108,7 @@ VideoParams::VideoParams(int width, int height, int depth, Format format, int nb
|
||||
set_defaults_for_footage();
|
||||
}
|
||||
|
||||
VideoParams::VideoParams(int width, int height, const rational &time_base, Format format, int nb_channels, const rational& pixel_aspect_ratio, Interlacing interlacing, int divider) :
|
||||
VideoParams::VideoParams(int width, int height, const rational &time_base, PixelFormat format, int nb_channels, const rational& pixel_aspect_ratio, Interlacing interlacing, int divider) :
|
||||
width_(width),
|
||||
height_(height),
|
||||
depth_(1),
|
||||
@@ -177,25 +178,25 @@ bool VideoParams::operator!=(const VideoParams &rhs) const
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
int VideoParams::GetBytesPerChannel(VideoParams::Format format)
|
||||
int VideoParams::GetBytesPerChannel(PixelFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case kFormatInvalid:
|
||||
case kFormatCount:
|
||||
case PixelFormat::INVALID:
|
||||
case PixelFormat::FORMAT_COUNT:
|
||||
break;
|
||||
case kFormatUnsigned8:
|
||||
case PixelFormat::U8:
|
||||
return 1;
|
||||
case kFormatUnsigned16:
|
||||
case kFormatFloat16:
|
||||
case PixelFormat::U16:
|
||||
case PixelFormat::F16:
|
||||
return 2;
|
||||
case kFormatFloat32:
|
||||
case PixelFormat::F32:
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VideoParams::GetBytesPerPixel(VideoParams::Format format, int channels)
|
||||
int VideoParams::GetBytesPerPixel(PixelFormat format, int channels)
|
||||
{
|
||||
return GetBytesPerChannel(format) * channels;
|
||||
}
|
||||
@@ -209,35 +210,19 @@ QString VideoParams::GetNameForDivider(int div)
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoParams::FormatIsFloat(VideoParams::Format format)
|
||||
QString VideoParams::GetFormatName(PixelFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case kFormatFloat16:
|
||||
case kFormatFloat32:
|
||||
return true;
|
||||
case kFormatUnsigned8:
|
||||
case kFormatUnsigned16:
|
||||
case kFormatInvalid:
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QString VideoParams::GetFormatName(VideoParams::Format format)
|
||||
{
|
||||
switch (format) {
|
||||
case kFormatUnsigned8:
|
||||
case PixelFormat::U8:
|
||||
return QCoreApplication::translate("VideoParams", "8-bit");
|
||||
case kFormatUnsigned16:
|
||||
case PixelFormat::U16:
|
||||
return QCoreApplication::translate("VideoParams", "16-bit Integer");
|
||||
case kFormatFloat16:
|
||||
case PixelFormat::F16:
|
||||
return QCoreApplication::translate("VideoParams", "Half-Float (16-bit)");
|
||||
case kFormatFloat32:
|
||||
case PixelFormat::F32:
|
||||
return QCoreApplication::translate("VideoParams", "Full-Float (32-bit)");
|
||||
case kFormatInvalid:
|
||||
case kFormatCount:
|
||||
case PixelFormat::INVALID:
|
||||
case PixelFormat::FORMAT_COUNT:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -302,7 +287,7 @@ bool VideoParams::is_valid() const
|
||||
return (width() > 0
|
||||
&& height() > 0
|
||||
&& !pixel_aspect_ratio_.isNull()
|
||||
&& format_ > kFormatInvalid && format_ < kFormatCount
|
||||
&& format_ > PixelFormat::INVALID && format_ < PixelFormat::FORMAT_COUNT
|
||||
&& channel_count_ > 0);
|
||||
}
|
||||
|
||||
@@ -359,13 +344,13 @@ void VideoParams::Load(QXmlStreamReader *reader)
|
||||
} else if (reader->name() == QStringLiteral("depth")) {
|
||||
set_depth(reader->readElementText().toInt());
|
||||
} else if (reader->name() == QStringLiteral("timebase")) {
|
||||
set_time_base(rational::fromString(reader->readElementText()));
|
||||
set_time_base(rational::fromString(reader->readElementText().toStdString()));
|
||||
} else if (reader->name() == QStringLiteral("format")) {
|
||||
set_format(static_cast<VideoParams::Format>(reader->readElementText().toInt()));
|
||||
set_format(static_cast<PixelFormat::Format>(reader->readElementText().toInt()));
|
||||
} else if (reader->name() == QStringLiteral("channelcount")) {
|
||||
set_channel_count(reader->readElementText().toInt());
|
||||
} else if (reader->name() == QStringLiteral("pixelaspectratio")) {
|
||||
set_pixel_aspect_ratio(rational::fromString(reader->readElementText()));
|
||||
set_pixel_aspect_ratio(rational::fromString(reader->readElementText().toStdString()));
|
||||
} else if (reader->name() == QStringLiteral("interlacing")) {
|
||||
set_interlacing(static_cast<VideoParams::Interlacing>(reader->readElementText().toInt()));
|
||||
} else if (reader->name() == QStringLiteral("divider")) {
|
||||
@@ -381,7 +366,7 @@ void VideoParams::Load(QXmlStreamReader *reader)
|
||||
} else if (reader->name() == QStringLiteral("videotype")) {
|
||||
set_video_type(static_cast<VideoParams::Type>(reader->readElementText().toInt()));
|
||||
} else if (reader->name() == QStringLiteral("framerate")) {
|
||||
set_frame_rate(rational::fromString(reader->readElementText()));
|
||||
set_frame_rate(rational::fromString(reader->readElementText().toStdString()));
|
||||
} else if (reader->name() == QStringLiteral("starttime")) {
|
||||
set_start_time(reader->readElementText().toLongLong());
|
||||
} else if (reader->name() == QStringLiteral("duration")) {
|
||||
@@ -403,10 +388,10 @@ void VideoParams::Save(QXmlStreamWriter *writer) const
|
||||
writer->writeTextElement(QStringLiteral("width"), QString::number(width_));
|
||||
writer->writeTextElement(QStringLiteral("height"), QString::number(height_));
|
||||
writer->writeTextElement(QStringLiteral("depth"), QString::number(depth_));
|
||||
writer->writeTextElement(QStringLiteral("timebase"), time_base_.toString());
|
||||
writer->writeTextElement(QStringLiteral("timebase"), QString::fromStdString(time_base_.toString()));
|
||||
writer->writeTextElement(QStringLiteral("format"), QString::number(format_));
|
||||
writer->writeTextElement(QStringLiteral("channelcount"), QString::number(channel_count_));
|
||||
writer->writeTextElement(QStringLiteral("pixelaspectratio"), pixel_aspect_ratio_.toString());
|
||||
writer->writeTextElement(QStringLiteral("pixelaspectratio"), QString::fromStdString(pixel_aspect_ratio_.toString()));
|
||||
writer->writeTextElement(QStringLiteral("interlacing"), QString::number(interlacing_));
|
||||
writer->writeTextElement(QStringLiteral("divider"), QString::number(divider_));
|
||||
writer->writeTextElement(QStringLiteral("enabled"), QString::number(enabled_));
|
||||
@@ -414,7 +399,7 @@ void VideoParams::Save(QXmlStreamWriter *writer) const
|
||||
writer->writeTextElement(QStringLiteral("y"), QString::number(y_));
|
||||
writer->writeTextElement(QStringLiteral("streamindex"), QString::number(stream_index_));
|
||||
writer->writeTextElement(QStringLiteral("videotype"), QString::number(video_type_));
|
||||
writer->writeTextElement(QStringLiteral("framerate"), frame_rate_.toString());
|
||||
writer->writeTextElement(QStringLiteral("framerate"), QString::fromStdString(frame_rate_.toString()));
|
||||
writer->writeTextElement(QStringLiteral("starttime"), QString::number(start_time_));
|
||||
writer->writeTextElement(QStringLiteral("duration"), QString::number(duration_));
|
||||
writer->writeTextElement(QStringLiteral("premultipliedalpha"), QString::number(premultiplied_alpha_));
|
||||
|
||||
+17
-37
@@ -21,40 +21,17 @@
|
||||
#ifndef VIDEOPARAMS_H
|
||||
#define VIDEOPARAMS_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QVector2D>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "common/rational.h"
|
||||
#include "rendermodes.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
using namespace core;
|
||||
|
||||
class VideoParams {
|
||||
public:
|
||||
enum Format {
|
||||
/// Invalid or no format
|
||||
kFormatInvalid = -1,
|
||||
|
||||
/// 8-bit unsigned integer
|
||||
kFormatUnsigned8,
|
||||
|
||||
/// 16-bit unsigned integer
|
||||
kFormatUnsigned16,
|
||||
|
||||
/// 16-bit half float
|
||||
kFormatFloat16,
|
||||
|
||||
/// 32-bit full float
|
||||
kFormatFloat32,
|
||||
|
||||
/// 64-bit double float - disabled since very, very few libs support 64-bit buffers
|
||||
//kFormatFloat64,
|
||||
|
||||
/// Total format count
|
||||
kFormatCount
|
||||
};
|
||||
|
||||
enum Interlacing {
|
||||
kInterlaceNone,
|
||||
kInterlacedTopFirst,
|
||||
@@ -76,15 +53,15 @@ public:
|
||||
|
||||
|
||||
VideoParams();
|
||||
VideoParams(int width, int height, Format format, int nb_channels,
|
||||
VideoParams(int width, int height, PixelFormat format, int nb_channels,
|
||||
const rational& pixel_aspect_ratio = 1,
|
||||
Interlacing interlacing = kInterlaceNone, int divider = 1);
|
||||
VideoParams(int width, int height, int depth,
|
||||
Format format, int nb_channels,
|
||||
PixelFormat format, int nb_channels,
|
||||
const rational& pixel_aspect_ratio = 1,
|
||||
Interlacing interlacing = kInterlaceNone, int divider = 1);
|
||||
VideoParams(int width, int height, const rational& time_base,
|
||||
Format format, int nb_channels,
|
||||
PixelFormat format, int nb_channels,
|
||||
const rational& pixel_aspect_ratio = 1,
|
||||
Interlacing interlacing = kInterlaceNone, int divider = 1);
|
||||
|
||||
@@ -182,12 +159,12 @@ public:
|
||||
return effective_depth_;
|
||||
}
|
||||
|
||||
Format format() const
|
||||
PixelFormat format() const
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
||||
void set_format(Format f)
|
||||
void set_format(PixelFormat f)
|
||||
{
|
||||
format_ = f;
|
||||
}
|
||||
@@ -230,19 +207,19 @@ public:
|
||||
bool operator==(const VideoParams& rhs) const;
|
||||
bool operator!=(const VideoParams& rhs) const;
|
||||
|
||||
static int GetBytesPerChannel(Format format);
|
||||
static int GetBytesPerChannel(PixelFormat format);
|
||||
int GetBytesPerChannel() const
|
||||
{
|
||||
return GetBytesPerChannel(format_);
|
||||
}
|
||||
|
||||
static int GetBytesPerPixel(Format format, int channels);
|
||||
static int GetBytesPerPixel(PixelFormat format, int channels);
|
||||
int GetBytesPerPixel() const
|
||||
{
|
||||
return GetBytesPerPixel(format_, channel_count_);
|
||||
}
|
||||
|
||||
static int GetBufferSize(int width, int height, Format format, int channels)
|
||||
static int GetBufferSize(int width, int height, PixelFormat format, int channels)
|
||||
{
|
||||
return width * height * GetBytesPerPixel(format, channels);
|
||||
}
|
||||
@@ -253,9 +230,12 @@ public:
|
||||
|
||||
static QString GetNameForDivider(int div);
|
||||
|
||||
static bool FormatIsFloat(Format format);
|
||||
static bool FormatIsFloat(PixelFormat format)
|
||||
{
|
||||
return format.is_float();
|
||||
}
|
||||
|
||||
static QString GetFormatName(Format format);
|
||||
static QString GetFormatName(PixelFormat format);
|
||||
|
||||
static int GetDividerForTargetResolution(int src_width, int src_height, int dst_width, int dst_height);
|
||||
|
||||
@@ -395,7 +375,7 @@ private:
|
||||
int depth_;
|
||||
rational time_base_;
|
||||
|
||||
Format format_;
|
||||
PixelFormat format_;
|
||||
|
||||
int channel_count_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user