Skip to content

Commit

Permalink
start moving core frameworks to external libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Jan 19, 2023
1 parent e798223 commit dd9c52a
Show file tree
Hide file tree
Showing 158 changed files with 478 additions and 2,484 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ find_package(OpenEXR REQUIRED)
list(APPEND OLIVE_LIBRARIES ${OPENEXR_LIBRARIES})
list(APPEND OLIVE_INCLUDE_DIRS ${OPENEXR_INCLUDES})

# Link Olive
find_package(Olive REQUIRED
COMPONENTS
Core
)
list(APPEND OLIVE_LIBRARIES ${LIBOLIVE_LIBRARIES})
list(APPEND OLIVE_INCLUDE_DIRS ${LIBOLIVE_INCLUDE_DIRS})

# Link Qt
set(QT_LIBRARIES
Core
Expand Down
2 changes: 2 additions & 0 deletions app/audio/audioprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ extern "C" {
#include <libavfilter/buffersink.h>
}

#include <QDebug>

#include "common/ffmpegutils.h"

namespace olive {
Expand Down
1 change: 1 addition & 0 deletions app/audio/audioprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C" {
#include <libavfilter/avfilter.h>
}

#include "common/define.h"
#include "render/audioparams.h"

namespace olive {
Expand Down
4 changes: 2 additions & 2 deletions app/codec/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

#include <QCoreApplication>
#include <QDebug>
#include <QHash>

#include "codec/ffmpeg/ffmpegdecoder.h"
#include "codec/planarfiledevice.h"
#include "codec/oiio/oiiodecoder.h"
#include "common/ffmpegutils.h"
#include "common/filefunctions.h"
#include "common/timecodefunctions.h"
#include "conformmanager.h"
#include "node/project/project.h"
#include "task/taskmanager.h"
Expand Down Expand Up @@ -338,7 +338,7 @@ void Decoder::UpdateLastAccessed()

uint qHash(Decoder::CodecStream stream, uint seed)
{
return qHash(stream.filename(), seed) ^ qHash(stream.stream(), seed) ^ qHash(stream.block(), seed);
return qHash(stream.filename(), seed) ^ ::qHash(stream.stream(), seed) ^ qHash(stream.block(), seed);
}

}
4 changes: 2 additions & 2 deletions app/codec/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ extern "C" {
#include <stdint.h>

#include "codec/samplebuffer.h"
#include "common/rational.h"
#include "node/block/block.h"
#include "node/project/footage/footagedescription.h"
#include "render/cancelatom.h"
#include "render/rendermodes.h"

namespace olive {

Expand Down Expand Up @@ -160,7 +160,7 @@ class Decoder : public QObject
Renderer *renderer = nullptr;
rational time;
int divider = 1;
VideoParams::Format maximum_format = VideoParams::kFormatInvalid;
PixelFormat maximum_format = PixelFormat::INVALID;
CancelAtom *cancelled = nullptr;
VideoParams::ColorRange force_range = VideoParams::kColorRangeDefault;
VideoParams::Interlacing src_interlacing = VideoParams::kInterlaceNone;
Expand Down
19 changes: 9 additions & 10 deletions app/codec/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <QFile>

#include "common/timecodefunctions.h"
#include "common/xmlutils.h"
#include "ffmpeg/ffmpegencoder.h"
#include "oiio/oiioencoder.h"
Expand Down Expand Up @@ -202,8 +201,8 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
writer->writeTextElement(QStringLiteral("format"), QString::number(format_));

writer->writeTextElement(QStringLiteral("range"), QString::number(has_custom_range_));
writer->writeTextElement(QStringLiteral("customrangein"), custom_range_.in().toString());
writer->writeTextElement(QStringLiteral("customrangeout"), custom_range_.out().toString());
writer->writeTextElement(QStringLiteral("customrangein"), QString::fromStdString(custom_range_.in().toString()));
writer->writeTextElement(QStringLiteral("customrangeout"), QString::fromStdString(custom_range_.out().toString()));

writer->writeStartElement(QStringLiteral("video"));

Expand All @@ -214,8 +213,8 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
writer->writeTextElement(QStringLiteral("width"), QString::number(video_params_.width()));
writer->writeTextElement(QStringLiteral("height"), QString::number(video_params_.height()));
writer->writeTextElement(QStringLiteral("format"), QString::number(video_params_.format()));
writer->writeTextElement(QStringLiteral("pixelaspect"), video_params_.pixel_aspect_ratio().toString());
writer->writeTextElement(QStringLiteral("timebase"), video_params_.time_base().toString());
writer->writeTextElement(QStringLiteral("pixelaspect"), QString::fromStdString(video_params_.pixel_aspect_ratio().toString()));
writer->writeTextElement(QStringLiteral("timebase"), QString::fromStdString(video_params_.time_base().toString()));
writer->writeTextElement(QStringLiteral("divider"), QString::number(video_params_.divider()));
writer->writeTextElement(QStringLiteral("bitrate"), QString::number(video_bit_rate_));
writer->writeTextElement(QStringLiteral("minbitrate"), QString::number(video_min_bit_rate_));
Expand Down Expand Up @@ -381,9 +380,9 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
} else if (reader->name() == QStringLiteral("range")) {
has_custom_range_ = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("customrangein")) {
custom_range_in = rational::fromString(reader->readElementText());
custom_range_in = rational::fromString(reader->readElementText().toStdString());
} else if (reader->name() == QStringLiteral("customrangeout")) {
custom_range_out = rational::fromString(reader->readElementText());
custom_range_out = rational::fromString(reader->readElementText().toStdString());
} else if (reader->name() == QStringLiteral("video")) {
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("enabled")) {
Expand All @@ -399,11 +398,11 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
} else if (reader->name() == QStringLiteral("height")) {
video_params_.set_height(reader->readElementText().toInt());
} else if (reader->name() == QStringLiteral("format")) {
video_params_.set_format(static_cast<VideoParams::Format>(reader->readElementText().toInt()));
video_params_.set_format(static_cast<PixelFormat::Format>(reader->readElementText().toInt()));
} else if (reader->name() == QStringLiteral("pixelaspect")) {
video_params_.set_pixel_aspect_ratio(rational::fromString(reader->readElementText()));
video_params_.set_pixel_aspect_ratio(rational::fromString(reader->readElementText().toStdString()));
} else if (reader->name() == QStringLiteral("timebase")) {
video_params_.set_time_base(rational::fromString(reader->readElementText()));
video_params_.set_time_base(rational::fromString(reader->readElementText().toStdString()));
} else if (reader->name() == QStringLiteral("divider")) {
video_params_.set_divider(reader->readElementText().toInt());
} else if (reader->name() == QStringLiteral("bitrate")) {
Expand Down
7 changes: 3 additions & 4 deletions app/codec/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "codec/exportformat.h"
#include "codec/frame.h"
#include "codec/samplebuffer.h"
#include "common/timerange.h"
#include "node/block/subtitle/subtitle.h"
#include "render/audioparams.h"
#include "render/colortransform.h"
Expand Down Expand Up @@ -209,9 +208,9 @@ class Encoder : public QObject

const EncodingParams& params() const;

virtual VideoParams::Format GetDesiredPixelFormat() const
virtual PixelFormat GetDesiredPixelFormat() const
{
return VideoParams::kFormatInvalid;
return PixelFormat::INVALID;
}

const QString& GetError() const
Expand All @@ -232,7 +231,7 @@ class Encoder : public QObject
public slots:
virtual bool Open() = 0;

virtual bool WriteFrame(olive::FramePtr frame, olive::rational time) = 0;
virtual bool WriteFrame(olive::FramePtr frame, olive::core::rational time) = 0;
virtual bool WriteAudio(const olive::SampleBuffer &audio) = 0;
virtual bool WriteSubtitle(const SubtitleBlock *sub_block) = 0;

Expand Down
11 changes: 5 additions & 6 deletions app/codec/ffmpeg/ffmpegdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ extern "C" {
#include "codec/planarfiledevice.h"
#include "common/ffmpegutils.h"
#include "common/filefunctions.h"
#include "common/timecodefunctions.h"
#include "render/renderer.h"
#include "render/subtitleparams.h"

Expand Down Expand Up @@ -78,7 +77,7 @@ TexturePtr FFmpegDecoder::ProcessFrameIntoTexture(AVFramePtr f, const RetrieveVi
{
// Determine native format
AVPixelFormat ideal_fmt = FFmpegUtils::GetCompatiblePixelFormat(static_cast<AVPixelFormat>(f->format));
VideoParams::Format native_fmt = GetNativePixelFormat(ideal_fmt);
PixelFormat native_fmt = GetNativePixelFormat(ideal_fmt);
int native_channels = GetNativeChannelCount(ideal_fmt);

// Set up video params
Expand Down Expand Up @@ -642,17 +641,17 @@ bool FFmpegDecoder::ConformAudioInternal(const QVector<QString> &filenames, cons
return success;
}

VideoParams::Format FFmpegDecoder::GetNativePixelFormat(AVPixelFormat pix_fmt)
PixelFormat FFmpegDecoder::GetNativePixelFormat(AVPixelFormat pix_fmt)
{
switch (pix_fmt) {
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_RGBA:
return VideoParams::kFormatUnsigned8;
return PixelFormat::U8;
case AV_PIX_FMT_RGB48:
case AV_PIX_FMT_RGBA64:
return VideoParams::kFormatUnsigned16;
return PixelFormat::U16;
default:
return VideoParams::kFormatInvalid;
return PixelFormat::INVALID;
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/codec/ffmpeg/ffmpegdecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class FFmpegDecoder : public Decoder

void FreeScaler();

static VideoParams::Format GetNativePixelFormat(AVPixelFormat pix_fmt);
static PixelFormat GetNativePixelFormat(AVPixelFormat pix_fmt);
static int GetNativeChannelCount(AVPixelFormat pix_fmt);

static uint64_t ValidateChannelLayout(AVStream *stream);
Expand Down
3 changes: 1 addition & 2 deletions app/codec/ffmpeg/ffmpegencoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ extern "C" {
#include <QFile>

#include "common/ffmpegutils.h"
#include "common/timecodefunctions.h"

namespace olive {

Expand Down Expand Up @@ -130,7 +129,7 @@ bool FFmpegEncoder::Open()
}

// This is the format we will expect frames received in Write() to be in
VideoParams::Format native_pixel_fmt = params().video_params().format();
PixelFormat native_pixel_fmt = params().video_params().format();

// This is the format we will need to convert the frame to for swscale to understand it
video_conversion_fmt_ = FFmpegUtils::GetCompatiblePixelFormat(native_pixel_fmt);
Expand Down
6 changes: 3 additions & 3 deletions app/codec/ffmpeg/ffmpegencoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FFmpegEncoder : public Encoder

virtual bool Open() override;

virtual bool WriteFrame(olive::FramePtr frame, olive::rational time) override;
virtual bool WriteFrame(olive::FramePtr frame, olive::core::rational time) override;

virtual bool WriteAudio(const olive::SampleBuffer &audio) override;

Expand All @@ -55,7 +55,7 @@ class FFmpegEncoder : public Encoder

virtual void Close() override;

virtual VideoParams::Format GetDesiredPixelFormat() const override
virtual PixelFormat GetDesiredPixelFormat() const override
{
return video_conversion_fmt_;
}
Expand Down Expand Up @@ -91,7 +91,7 @@ class FFmpegEncoder : public Encoder
AVFilterGraph *video_scale_ctx_;
AVFilterContext *video_buffersrc_ctx_;
AVFilterContext *video_buffersink_ctx_;
VideoParams::Format video_conversion_fmt_;
PixelFormat video_conversion_fmt_;

AVStream* audio_stream_;
AVCodecContext* audio_codec_ctx_;
Expand Down
4 changes: 2 additions & 2 deletions app/codec/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ FramePtr Frame::Interlace(FramePtr top, FramePtr bottom)
return interlaced;
}

int Frame::generate_linesize_bytes(int width, VideoParams::Format format, int channel_count)
int Frame::generate_linesize_bytes(int width, PixelFormat format, int channel_count)
{
// Align to 32 bytes (not sure if this is necessary?)
return VideoParams::GetBytesPerPixel(format, channel_count) * ((width + 31) & ~31);
Expand Down Expand Up @@ -146,7 +146,7 @@ void Frame::destroy()
}
}

FramePtr Frame::convert(VideoParams::Format format) const
FramePtr Frame::convert(PixelFormat format) const
{
// Create new params with destination format
VideoParams params = params_;
Expand Down
9 changes: 4 additions & 5 deletions app/codec/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
#define FRAME_H

#include <memory>
#include <olive/core/core.h>
#include <QVector>

#include "common/define.h"
#include "common/rational.h"
#include "render/color.h"
#include "render/videoparams.h"

namespace olive {
Expand All @@ -53,7 +52,7 @@ class Frame

static FramePtr Interlace(FramePtr top, FramePtr bottom);

static int generate_linesize_bytes(int width, VideoParams::Format format, int channel_count);
static int generate_linesize_bytes(int width, PixelFormat format, int channel_count);

int linesize_pixels() const
{
Expand All @@ -75,7 +74,7 @@ class Frame
return params_.effective_height();
}

VideoParams::Format format() const
PixelFormat format() const
{
return params_.format();
}
Expand Down Expand Up @@ -152,7 +151,7 @@ class Frame
return data_size_;
}

FramePtr convert(VideoParams::Format format) const;
FramePtr convert(PixelFormat format) const;

private:
VideoParams params_;
Expand Down
2 changes: 1 addition & 1 deletion app/codec/oiio/oiiodecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage)
// We use RGBA frames because that tends to be the native format of GPUs
pix_fmt_ = OIIOUtils::GetFormatFromOIIOBasetype(static_cast<OIIO::TypeDesc::BASETYPE>(spec.format.basetype));

if (pix_fmt_ == VideoParams::kFormatInvalid) {
if (pix_fmt_ == PixelFormat::INVALID) {
qWarning() << "Failed to convert OIIO::ImageDesc to native pixel format";
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion app/codec/oiio/oiiodecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class OIIODecoder : public Decoder

static VideoParams GetVideoParamsFromImageSpec(const OIIO::ImageSpec &spec);

VideoParams::Format pix_fmt_;
PixelFormat pix_fmt_;
OIIO::TypeDesc::BASETYPE oiio_pix_fmt_;

Frame buffer_;
Expand Down
2 changes: 1 addition & 1 deletion app/codec/oiio/oiioencoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class OIIOEncoder : public Encoder
public slots:
virtual bool Open() override;

virtual bool WriteFrame(olive::FramePtr frame, olive::rational time) override;
virtual bool WriteFrame(olive::FramePtr frame, olive::core::rational time) override;
virtual bool WriteAudio(const SampleBuffer &audio) override;
virtual bool WriteSubtitle(const SubtitleBlock *sub_block) override;

Expand Down
2 changes: 2 additions & 0 deletions app/codec/samplebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "samplebuffer.h"

#include <QDebug>

#include "common/cpuoptimize.h"

namespace olive {
Expand Down
6 changes: 0 additions & 6 deletions app/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,7 @@ set(OLIVE_SOURCES
common/range.h
common/ratiodialog.cpp
common/ratiodialog.h
common/rational.cpp
common/rational.h
common/threadsafemap.h
common/timecodefunctions.cpp
common/timecodefunctions.h
common/timerange.cpp
common/timerange.h
common/tohex.h
common/util.h
common/xmlutils.cpp
Expand Down
Loading

0 comments on commit dd9c52a

Please sign in to comment.