style: unify identifier naming per updated conventions

Automated with clang-tidy readability-identifier-naming (config added to
.clang-tidy) plus scripted passes, per the updated rules now documented
in CONTRIBUTING.md:

- types (class/struct/enum/alias/template params): PascalCase
- functions, variables, members: snake_case (incl. rational -> Rational)
- private/protected members: trailing underscore; static member
  variables likewise (instance_, available_themes_)
- constants and enum values: snake_case (kLinear -> k_linear,
  F32P -> f32p); ALL_CAPS reserved for macros
- macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG ->
  OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE,
  include guards -> OAK_*)
- file names: all lowercase (Current/Plugin/OliveHost/OliveClip/
  OlivePluginInstance -> current/plugin/olivehost/oliveclip/
  oliveplugininstance)
- getters share the member name sans underscore, setters set_foo()
- Qt and third-party (OpenFX) virtual overrides and framework callbacks
  keep their original names (exempt in .clang-tidy)

Manual follow-ups required where automation could not reach:
- string-based QMetaObject/SIGNAL/SLOT references updated to renamed
  methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...)
- macro bodies referencing renamed methods (OLIVE_CONFIG,
  NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*)
- self-shadowing locals renamed where signals/methods became same-named
  (size_changed, worker_count, selected_items, import param, filters)
- third_party OFX member/namespace usages restored (OFX::Host::*,
  _created, _clipPrefsDirty, createInstance, clearPersistentMessage)
- STL protocol aliases restored (const_iterator) with .clang-tidy
  ignore rules; qHash overloads restored

Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
2026-07-19 16:10:54 +08:00
parent cb1718a103
commit bb40b4923e
1014 changed files with 44257 additions and 44220 deletions
+15 -15
View File
@@ -27,7 +27,7 @@ namespace olive
ConformManager *ConformManager::instance_ = nullptr;
ConformManager::Conform ConformManager::GetConformState(
ConformManager::Conform ConformManager::get_conform_state(
const QString &decoder_id, const QString &cache_path,
const Decoder::CodecStream &stream, const AudioParams &params, bool wait)
{
@@ -36,9 +36,9 @@ ConformManager::Conform ConformManager::GetConformState(
// Return existing conform if exists
QVector<QString> filenames =
GetConformedFilename(cache_path, stream, params);
if (AllConformsExist(filenames)) {
return { kConformExists, filenames, nullptr };
get_conformed_filename(cache_path, stream, params);
if (all_conforms_exist(filenames)) {
return { k_conform_exists, filenames, nullptr };
}
ConformTask *conforming_task = nullptr;
@@ -63,10 +63,10 @@ ConformManager::Conform ConformManager::GetConformState(
conforming_task =
new ConformTask(decoder_id, stream, params, working_filenames);
connect(conforming_task, &ConformTask::Finished, this,
&ConformManager::ConformTaskFinished);
connect(conforming_task, &ConformTask::finished, this,
&ConformManager::conform_task_finished);
conforming_task->moveToThread(TaskManager::instance()->thread());
QMetaObject::invokeMethod(TaskManager::instance(), "AddTask",
QMetaObject::invokeMethod(TaskManager::instance(), "add_task",
Qt::QueuedConnection,
Q_ARG(Task *, conforming_task));
@@ -77,15 +77,15 @@ ConformManager::Conform ConformManager::GetConformState(
if (wait) {
do {
conform_done_condition_.wait(&mutex_);
} while (!AllConformsExist(filenames));
return { kConformExists, filenames, nullptr };
} while (!all_conforms_exist(filenames));
return { k_conform_exists, filenames, nullptr };
}
return { kConformGenerating, QVector<QString>(), conforming_task };
return { k_conform_generating, QVector<QString>(), conforming_task };
}
QVector<QString>
ConformManager::GetConformedFilename(const QString &cache_path,
ConformManager::get_conformed_filename(const QString &cache_path,
const Decoder::CodecStream &stream,
const AudioParams &params)
{
@@ -94,7 +94,7 @@ ConformManager::GetConformedFilename(const QString &cache_path,
for (int i = 0; i < filenames.size(); i++) {
QString index_fn =
QStringLiteral("%1-%2.%3.%4.%5.%6.pcm")
.arg(FileFunctions::GetUniqueFileIdentifier(stream.filename()),
.arg(FileFunctions::get_unique_file_identifier(stream.filename()),
QString::number(stream.stream()),
QString::number(params.sample_rate()),
QString::number(params.format()),
@@ -107,7 +107,7 @@ ConformManager::GetConformedFilename(const QString &cache_path,
return filenames;
}
bool ConformManager::AllConformsExist(const QVector<QString> &filenames)
bool ConformManager::all_conforms_exist(const QVector<QString> &filenames)
{
foreach (const QString &fn, filenames) {
if (!QFileInfo::exists(fn)) {
@@ -118,7 +118,7 @@ bool ConformManager::AllConformsExist(const QVector<QString> &filenames)
return true;
}
void ConformManager::ConformTaskFinished(Task *task, bool succeeded)
void ConformManager::conform_task_finished(Task *task, bool succeeded)
{
QMutexLocker locker(&mutex_);
@@ -146,7 +146,7 @@ void ConformManager::ConformTaskFinished(Task *task, bool succeeded)
conform_done_condition_.wakeAll();
locker.unlock();
emit ConformReady();
emit conform_ready();
} else {
// Failed, just delete the working filename if exists
for (int i = 0; i < data.working_filename.size(); i++) {
+11 -11
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFORMMANAGER_H
#define CONFORMMANAGER_H
#ifndef OAK_CONFORMMANAGER_H
#define OAK_CONFORMMANAGER_H
#include <QMutex>
#include <QObject>
@@ -31,14 +31,14 @@ namespace olive
class ConformManager : public QObject {
Q_OBJECT
public:
static void CreateInstance()
static void create_instance()
{
if (!instance_) {
instance_ = new ConformManager();
}
}
static void DestroyInstance()
static void destroy_instance()
{
delete instance_;
instance_ = nullptr;
@@ -49,7 +49,7 @@ public:
return instance_;
}
enum ConformState { kConformExists, kConformGenerating };
enum ConformState { k_conform_exists, k_conform_generating };
struct Conform {
ConformState state;
@@ -62,13 +62,13 @@ public:
*
* Thread-safe.
*/
Conform GetConformState(const QString &decoder_id,
Conform get_conform_state(const QString &decoder_id,
const QString &cache_path,
const Decoder::CodecStream &stream,
const AudioParams &params, bool wait);
signals:
void ConformReady();
void conform_ready();
private:
ConformManager() = default;
@@ -93,16 +93,16 @@ private:
* @brief Get the destination filename of an audio stream conformed to a set of parameters
*/
static QVector<QString>
GetConformedFilename(const QString &cache_path,
get_conformed_filename(const QString &cache_path,
const Decoder::CodecStream &stream,
const AudioParams &params);
static bool AllConformsExist(const QVector<QString> &filenames);
static bool all_conforms_exist(const QVector<QString> &filenames);
private slots:
void ConformTaskFinished(Task *task, bool succeeded);
void conform_task_finished(Task *task, bool succeeded);
};
} // namespace olive
#endif // CONFORMMANAGER_H
#endif // OAK_CONFORMMANAGER_H
+62 -62
View File
@@ -33,26 +33,26 @@
namespace olive
{
const rational Decoder::kAnyTimecode = RATIONAL_MIN;
const Rational Decoder::k_any_timecode = RATIONAL_MIN;
Decoder::Decoder()
: cached_texture_(nullptr)
{
UpdateLastAccessed();
update_last_accessed();
}
void Decoder::IncrementAccessTime(qint64 t)
void Decoder::increment_access_time(qint64 t)
{
last_accessed_ += t;
}
bool Decoder::Open(const CodecStream &stream)
bool Decoder::open(const CodecStream &stream)
{
QMutexLocker locker(&mutex_);
UpdateLastAccessed();
update_last_accessed();
if (stream_.IsValid()) {
if (stream_.is_valid()) {
// Decoder is already open. Return TRUE if the stream is the stream we have, or FALSE if not.
if (stream_ == stream) {
return true;
@@ -63,13 +63,13 @@ bool Decoder::Open(const CodecStream &stream)
}
} else {
// Stream was not open, try opening it now
if (!stream.IsValid()) {
if (!stream.is_valid()) {
// Cannot open null stream
qCritical() << "Decoder attempted to open null stream";
return false;
}
if (!stream.Exists()) {
if (!stream.exists()) {
// Cannot open file that doesn't exist
qCritical() << "Decoder attempted to open file that doesn't exist";
return false;
@@ -79,36 +79,36 @@ bool Decoder::Open(const CodecStream &stream)
stream_ = stream;
// Try open internal
if (OpenInternal()) {
if (open_internal()) {
return true;
} else {
// Unset stream
qCritical() << "Failed to open" << stream_.filename() << "stream"
<< stream_.stream();
CloseInternal();
stream_.Reset();
close_internal();
stream_.reset();
return false;
}
}
}
TexturePtr Decoder::RetrieveVideo(const RetrieveVideoParams &p)
TexturePtr Decoder::retrieve_video(const RetrieveVideoParams &p)
{
QMutexLocker locker(&mutex_);
UpdateLastAccessed();
update_last_accessed();
if (!stream_.IsValid()) {
if (!stream_.is_valid()) {
qCritical() << "Can't retrieve video on a closed decoder";
return nullptr;
}
if (!SupportsVideo()) {
if (!supports_video()) {
qCritical() << "Decoder doesn't support video";
return nullptr;
}
if (p.cancelled && p.cancelled->IsCancelled()) {
if (p.cancelled && p.cancelled->is_cancelled()) {
return nullptr;
}
@@ -117,110 +117,110 @@ TexturePtr Decoder::RetrieveVideo(const RetrieveVideoParams &p)
return cached_texture_;
}
cached_texture_ = RetrieveVideoInternal(p);
cached_texture_ = retrieve_video_internal(p);
cached_time_ = p.time;
cached_divider_ = p.divider;
return cached_texture_;
}
FramePtr Decoder::RetrieveVideoFrame(const RetrieveVideoParams &p)
FramePtr Decoder::retrieve_video_frame(const RetrieveVideoParams &p)
{
QMutexLocker locker(&mutex_);
UpdateLastAccessed();
update_last_accessed();
if (!stream_.IsValid()) {
if (!stream_.is_valid()) {
qCritical() << "Can't retrieve video frame on a closed decoder";
return nullptr;
}
if (!SupportsVideo()) {
if (!supports_video()) {
qCritical() << "Decoder doesn't support video";
return nullptr;
}
if (p.cancelled && p.cancelled->IsCancelled()) {
if (p.cancelled && p.cancelled->is_cancelled()) {
return nullptr;
}
return RetrieveVideoFrameInternal(p);
return retrieve_video_frame_internal(p);
}
Decoder::RetrieveAudioStatus
Decoder::RetrieveAudio(SampleBuffer &dest, const TimeRange &range,
Decoder::retrieve_audio(SampleBuffer &dest, const TimeRange &range,
const AudioParams &params, const QString &cache_path,
LoopMode loop_mode, RenderMode::Mode mode)
{
QMutexLocker locker(&mutex_);
UpdateLastAccessed();
update_last_accessed();
if (!stream_.IsValid()) {
if (!stream_.is_valid()) {
qCritical() << "Can't retrieve audio on a closed decoder";
return kInvalid;
return k_invalid;
}
if (!SupportsAudio()) {
if (!supports_audio()) {
qCritical() << "Decoder doesn't support audio";
return kInvalid;
return k_invalid;
}
if (params.sample_rate() <= 0 || params.channel_count() <= 0) {
qWarning() << "Invalid audio parameters, skipping audio retrieve";
return kInvalid;
return k_invalid;
}
// Get conform state from ConformManager
ConformManager::Conform conform =
ConformManager::instance()->GetConformState(
id(), cache_path, stream_, params, (mode == RenderMode::kOnline));
if (conform.state == ConformManager::kConformGenerating) {
ConformManager::instance()->get_conform_state(
id(), cache_path, stream_, params, (mode == RenderMode::k_online));
if (conform.state == ConformManager::k_conform_generating) {
// If we need the task, it's available in `conform.task`
return kWaitingForConform;
return k_waiting_for_conform;
}
// See if we got the conform
if (RetrieveAudioFromConform(dest, conform.filenames, range, loop_mode,
if (retrieve_audio_from_conform(dest, conform.filenames, range, loop_mode,
params)) {
return kOK;
return k_ok;
} else {
return kUnknownError;
return k_unknown_error;
}
}
qint64 Decoder::GetLastAccessedTime()
qint64 Decoder::get_last_accessed_time()
{
return last_accessed_;
}
void Decoder::Close()
void Decoder::close()
{
QMutexLocker locker(&mutex_);
UpdateLastAccessed();
update_last_accessed();
cached_texture_ = nullptr;
if (stream_.IsValid()) {
CloseInternal();
stream_.Reset();
if (stream_.is_valid()) {
close_internal();
stream_.reset();
} else {
qWarning() << "Tried to close a decoder that wasn't open";
}
}
bool Decoder::ConformAudio(const QVector<QString> &output_filenames,
bool Decoder::conform_audio(const QVector<QString> &output_filenames,
const AudioParams &params, CancelAtom *cancelled)
{
return ConformAudioInternal(output_filenames, params, cancelled);
return conform_audio_internal(output_filenames, params, cancelled);
}
/*
* DECODER STATIC PUBLIC MEMBERS
*/
QVector<DecoderPtr> Decoder::ReceiveListOfAllDecoders()
QVector<DecoderPtr> Decoder::receive_list_of_all_decoders()
{
QVector<DecoderPtr> decoders;
@@ -232,14 +232,14 @@ QVector<DecoderPtr> Decoder::ReceiveListOfAllDecoders()
return decoders;
}
DecoderPtr Decoder::CreateFromID(const QString &id)
DecoderPtr Decoder::create_from_id(const QString &id)
{
if (id.isEmpty()) {
return nullptr;
}
// Create list to iterate through
QVector<DecoderPtr> decoder_list = ReceiveListOfAllDecoders();
QVector<DecoderPtr> decoder_list = receive_list_of_all_decoders();
foreach (DecoderPtr d, decoder_list) {
if (d->id() == id) {
@@ -250,18 +250,18 @@ DecoderPtr Decoder::CreateFromID(const QString &id)
return nullptr;
}
void Decoder::SignalProcessingProgress(int64_t ts, int64_t duration)
void Decoder::signal_processing_progress(int64_t ts, int64_t duration)
{
if (duration != FB_NOPTS_VALUE && duration != 0) {
emit IndexProgress(static_cast<double>(ts) /
emit index_progress(static_cast<double>(ts) /
static_cast<double>(duration));
}
}
QString Decoder::TransformImageSequenceFileName(const QString &filename,
QString Decoder::transform_image_sequence_file_name(const QString &filename,
const int64_t &number)
{
int digit_count = GetImageSequenceDigitCount(filename);
int digit_count = get_image_sequence_digit_count(filename);
QFileInfo file_info(filename);
@@ -276,7 +276,7 @@ QString Decoder::TransformImageSequenceFileName(const QString &filename,
file_info.fileName().replace(original_basename, new_basename));
}
int Decoder::GetImageSequenceDigitCount(const QString &filename)
int Decoder::get_image_sequence_digit_count(const QString &filename)
{
QString basename = QFileInfo(filename).completeBaseName();
@@ -294,9 +294,9 @@ int Decoder::GetImageSequenceDigitCount(const QString &filename)
return digit_count;
}
int64_t Decoder::GetImageSequenceIndex(const QString &filename)
int64_t Decoder::get_image_sequence_index(const QString &filename)
{
int digit_count = GetImageSequenceDigitCount(filename);
int digit_count = get_image_sequence_digit_count(filename);
QFileInfo file_info(filename);
@@ -308,19 +308,19 @@ int64_t Decoder::GetImageSequenceIndex(const QString &filename)
return number_only.toLongLong();
}
TexturePtr Decoder::RetrieveVideoInternal(const RetrieveVideoParams &p)
TexturePtr Decoder::retrieve_video_internal(const RetrieveVideoParams &p)
{
Q_UNUSED(p)
return nullptr;
}
FramePtr Decoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p)
FramePtr Decoder::retrieve_video_frame_internal(const RetrieveVideoParams &p)
{
Q_UNUSED(p)
return nullptr;
}
bool Decoder::ConformAudioInternal(const QVector<QString> &filenames,
bool Decoder::conform_audio_internal(const QVector<QString> &filenames,
const AudioParams &params,
CancelAtom *cancelled)
{
@@ -330,14 +330,14 @@ bool Decoder::ConformAudioInternal(const QVector<QString> &filenames,
return false;
}
bool Decoder::RetrieveAudioFromConform(
bool Decoder::retrieve_audio_from_conform(
SampleBuffer &sample_buffer, const QVector<QString> &conform_filenames,
TimeRange range, LoopMode loop_mode, const AudioParams &input_params)
{
PlanarFileDevice input;
if (input.open(conform_filenames, QFile::ReadOnly)) {
// Offset range by audio start offset
range -= GetAudioStartOffset();
range -= get_audio_start_offset();
qint64 read_index = input_params.time_to_bytes(range.in()) /
input_params.channel_count();
@@ -348,7 +348,7 @@ bool Decoder::RetrieveAudioFromConform(
input_params.bytes_per_sample_per_channel();
while (write_index < buffer_length_in_bytes) {
if (loop_mode == LoopMode::kLoopModeLoop) {
if (loop_mode == LoopMode::k_loop_mode_loop) {
while (read_index >= input.size()) {
read_index -= input.size();
}
@@ -391,7 +391,7 @@ bool Decoder::RetrieveAudioFromConform(
return false;
}
void Decoder::UpdateLastAccessed()
void Decoder::update_last_accessed()
{
last_accessed_ = QDateTime::currentMSecsSinceEpoch();
}
+45 -45
View File
@@ -19,8 +19,8 @@
***/
#ifndef DECODER_H
#define DECODER_H
#ifndef OAK_DECODER_H
#define OAK_DECODER_H
#include <QFileInfo>
#include <QMutex>
@@ -43,7 +43,7 @@ using DecoderPtr = std::shared_ptr<Decoder>;
#define DECODER_DEFAULT_DESTRUCTOR(x) \
virtual ~x() override \
{ \
CloseInternal(); \
close_internal(); \
}
/**
@@ -65,7 +65,7 @@ using DecoderPtr = std::shared_ptr<Decoder>;
class Decoder : public QObject {
Q_OBJECT
public:
enum RetrieveState { kReady, kFailedToOpen, kIndexUnavailable };
enum RetrieveState { k_ready, k_failed_to_open, k_index_unavailable };
Decoder();
@@ -74,16 +74,16 @@ public:
*/
virtual QString id() const = 0;
virtual bool SupportsVideo()
virtual bool supports_video()
{
return false;
}
virtual bool SupportsAudio()
virtual bool supports_audio()
{
return false;
}
void IncrementAccessTime(qint64 t);
void increment_access_time(qint64 t);
class CodecStream {
public:
@@ -100,17 +100,17 @@ public:
{
}
bool IsValid() const
bool is_valid() const
{
return !filename_.isEmpty() && stream_ >= 0;
}
bool Exists() const
bool exists() const
{
return QFileInfo::exists(filename_);
}
void Reset()
void reset()
{
*this = CodecStream();
}
@@ -152,18 +152,18 @@ public:
* already open and the stream == the stream provided. Returns FALSE if the stream couldn't
* be opened OR if already open and the stream is NOT the same.
*/
bool Open(const CodecStream &stream);
bool open(const CodecStream &stream);
static const rational kAnyTimecode;
static const Rational k_any_timecode;
struct RetrieveVideoParams {
Renderer *renderer = nullptr;
rational time;
Rational time;
int divider = 1;
PixelFormat maximum_format = PixelFormat::INVALID;
PixelFormat maximum_format = PixelFormat::invalid;
CancelAtom *cancelled = nullptr;
VideoParams::ColorRange force_range = VideoParams::kColorRangeDefault;
VideoParams::Interlacing src_interlacing = VideoParams::kInterlaceNone;
VideoParams::ColorRange force_range = VideoParams::k_color_range_default;
VideoParams::Interlacing src_interlacing = VideoParams::k_interlace_none;
};
/**
@@ -176,7 +176,7 @@ public:
*
* This function is thread safe and can only run while the decoder is open. \see Open()
*/
TexturePtr RetrieveVideo(const RetrieveVideoParams &p);
TexturePtr retrieve_video(const RetrieveVideoParams &p);
/**
* @brief Retrieves a decoded video frame in CPU memory.
@@ -184,13 +184,13 @@ public:
* Used by render-process isolation to decode media in the main process and pass packed pixel
* data to workers through shared memory.
*/
FramePtr RetrieveVideoFrame(const RetrieveVideoParams &p);
FramePtr retrieve_video_frame(const RetrieveVideoParams &p);
enum RetrieveAudioStatus {
kInvalid = -1,
kOK,
kWaitingForConform,
kUnknownError
k_invalid = -1,
k_ok,
k_waiting_for_conform,
k_unknown_error
};
/**
@@ -202,14 +202,14 @@ public:
* This function is thread safe and can only run while the decoder is open. \see Open()
*/
RetrieveAudioStatus
RetrieveAudio(SampleBuffer &dest, const TimeRange &range,
retrieve_audio(SampleBuffer &dest, const TimeRange &range,
const AudioParams &params, const QString &cache_path,
LoopMode loop_mode, RenderMode::Mode mode);
/**
* @brief Determine the last time this decoder instance was used in any way
*/
qint64 GetLastAccessedTime();
qint64 get_last_accessed_time();
/**
* @brief Generate a Footage object from a file
@@ -222,7 +222,7 @@ public:
*
* This function is re-entrant.
*/
virtual FootageDescription Probe(const QString &filename,
virtual FootageDescription probe(const QString &filename,
CancelAtom *cancelled) const = 0;
/**
@@ -230,12 +230,12 @@ public:
*
* This function is thread safe and can only run while the decoder is open. \see Open()
*/
void Close();
void close();
/**
* @brief Conform audio stream
*/
bool ConformAudio(const QVector<QString> &output_filenames,
bool conform_audio(const QVector<QString> &output_filenames,
const AudioParams &params,
CancelAtom *cancelled = nullptr);
@@ -246,16 +246,16 @@ public:
*
* A Decoder instance or nullptr if a Decoder with this ID does not exist
*/
static DecoderPtr CreateFromID(const QString &id);
static DecoderPtr create_from_id(const QString &id);
static QString TransformImageSequenceFileName(const QString &filename,
static QString transform_image_sequence_file_name(const QString &filename,
const int64_t &number);
static int GetImageSequenceDigitCount(const QString &filename);
static int get_image_sequence_digit_count(const QString &filename);
static int64_t GetImageSequenceIndex(const QString &filename);
static int64_t get_image_sequence_index(const QString &filename);
static QVector<DecoderPtr> ReceiveListOfAllDecoders();
static QVector<DecoderPtr> receive_list_of_all_decoders();
protected:
/**
@@ -267,10 +267,10 @@ protected:
* decoder is not open yet and that the footage stream was from that sub-classes probe function.
*
* Return TRUE if everything opened successfully and the decoder is ready to work. Otherwise,
* return FALSE. If this function returns false, Decoder will call CloseInternal to clean any
* return FALSE. If this function returns false, Decoder will call close_internal to clean any
* memory allocated during OpenInternal.
*/
virtual bool OpenInternal() = 0;
virtual bool open_internal() = 0;
/**
* @brief Internal close function
@@ -278,7 +278,7 @@ protected:
* Sub-classes must override this function. Function should be able to safely clear all allocated
* memory. It may be called even if Open() didn't complete or RetrieveVideo() was never called.
*/
virtual void CloseInternal() = 0;
virtual void close_internal() = 0;
/**
* @brief Internal frame retrieval function
@@ -286,15 +286,15 @@ protected:
* Sub-classes must override this function IF they support video. Function is already mutexed
* so sub-classes don't need to worry about thread safety.
*/
virtual TexturePtr RetrieveVideoInternal(const RetrieveVideoParams &p);
virtual TexturePtr retrieve_video_internal(const RetrieveVideoParams &p);
virtual FramePtr RetrieveVideoFrameInternal(const RetrieveVideoParams &p);
virtual FramePtr retrieve_video_frame_internal(const RetrieveVideoParams &p);
virtual bool ConformAudioInternal(const QVector<QString> &filenames,
virtual bool conform_audio_internal(const QVector<QString> &filenames,
const AudioParams &params,
CancelAtom *cancelled);
void SignalProcessingProgress(int64_t ts, int64_t duration);
void signal_processing_progress(int64_t ts, int64_t duration);
/**
* @brief Return currently open stream
@@ -306,7 +306,7 @@ protected:
return stream_;
}
virtual rational GetAudioStartOffset() const
virtual Rational get_audio_start_offset() const
{
return 0;
}
@@ -316,12 +316,12 @@ signals:
* @brief While indexing, this signal will provide progress as a percentage (0-100 inclusive) if
* available
*/
void IndexProgress(double);
void index_progress(double);
private:
void UpdateLastAccessed();
void update_last_accessed();
bool RetrieveAudioFromConform(SampleBuffer &sample_buffer,
bool retrieve_audio_from_conform(SampleBuffer &sample_buffer,
const QVector<QString> &conform_filenames,
TimeRange range, LoopMode loop_mode,
const AudioParams &params);
@@ -333,7 +333,7 @@ private:
std::atomic_int64_t last_accessed_;
TexturePtr cached_texture_;
rational cached_time_;
Rational cached_time_;
int cached_divider_;
};
@@ -343,4 +343,4 @@ uint qHash(Decoder::CodecStream stream, uint seed = 0);
Q_DECLARE_METATYPE(olive::Decoder::RetrieveState)
#endif // DECODER_H
#endif // OAK_DECODER_H
+82 -82
View File
@@ -30,9 +30,9 @@
namespace olive
{
const QRegularExpression Encoder::kImageSequenceContainsDigits =
const QRegularExpression Encoder::k_image_sequence_contains_digits =
QRegularExpression(QStringLiteral("\\[[#]+\\]"));
const QRegularExpression Encoder::kImageSequenceRemoveDigits =
const QRegularExpression Encoder::k_image_sequence_remove_digits =
QRegularExpression(QStringLiteral("[\\-\\.\\ \\_]?\\[[#]+\\]"));
Encoder::Encoder(const EncodingParams &params)
@@ -45,18 +45,18 @@ const EncodingParams &Encoder::params() const
return params_;
}
QString Encoder::GetFilenameForFrame(const rational &frame)
QString Encoder::get_filename_for_frame(const Rational &frame)
{
if (params().video_is_image_sequence()) {
// Transform!
int64_t frame_index = Timecode::time_to_timestamp(
frame, params().video_params().frame_rate_as_time_base());
int digits = GetImageSequencePlaceholderDigitCount(params().filename());
int digits = get_image_sequence_placeholder_digit_count(params().filename());
QString frame_index_str =
QStringLiteral("%1").arg(frame_index, digits, 10, QChar('0'));
QString f = params_.filename();
f.replace(kImageSequenceContainsDigits, frame_index_str);
f.replace(k_image_sequence_contains_digits, frame_index_str);
return f;
} else {
// Keep filename
@@ -64,9 +64,9 @@ QString Encoder::GetFilenameForFrame(const rational &frame)
}
}
int Encoder::GetImageSequencePlaceholderDigitCount(const QString &filename)
int Encoder::get_image_sequence_placeholder_digit_count(const QString &filename)
{
int start = filename.indexOf(kImageSequenceContainsDigits);
int start = filename.indexOf(k_image_sequence_contains_digits);
int digit_count = 0;
for (int i = start + 1; i < filename.size(); i++) {
if (filename.at(i) == '#') {
@@ -78,14 +78,14 @@ int Encoder::GetImageSequencePlaceholderDigitCount(const QString &filename)
return digit_count;
}
bool Encoder::FilenameContainsDigitPlaceholder(const QString &filename)
bool Encoder::filename_contains_digit_placeholder(const QString &filename)
{
return filename.contains(kImageSequenceContainsDigits);
return filename.contains(k_image_sequence_contains_digits);
}
QString Encoder::FilenameRemoveDigitPlaceholder(QString filename)
QString Encoder::filename_remove_digit_placeholder(QString filename)
{
return filename.remove(kImageSequenceRemoveDigits);
return filename.remove(k_image_sequence_remove_digits);
}
EncodingParams::EncodingParams()
@@ -100,24 +100,24 @@ EncodingParams::EncodingParams()
, audio_bit_rate_(0)
, subtitles_enabled_(false)
, subtitles_are_sidecar_(false)
, video_scaling_method_(kStretch)
, video_scaling_method_(k_stretch)
, has_custom_range_(false)
{
}
QDir EncodingParams::GetPresetPath()
QDir EncodingParams::get_preset_path()
{
return QDir(FileFunctions::GetConfigurationLocation())
return QDir(FileFunctions::get_configuration_location())
.filePath(QStringLiteral("exportpresets"));
}
QStringList EncodingParams::GetListOfPresets()
QStringList EncodingParams::get_list_of_presets()
{
QDir d = EncodingParams::GetPresetPath();
QDir d = EncodingParams::get_preset_path();
return d.entryList(QDir::Files);
}
void EncodingParams::EnableVideo(const VideoParams &video_params,
void EncodingParams::enable_video(const VideoParams &video_params,
const ExportCodec::Codec &vcodec)
{
video_enabled_ = true;
@@ -125,7 +125,7 @@ void EncodingParams::EnableVideo(const VideoParams &video_params,
video_codec_ = vcodec;
}
void EncodingParams::EnableAudio(const AudioParams &audio_params,
void EncodingParams::enable_audio(const AudioParams &audio_params,
const ExportCodec::Codec &acodec)
{
audio_enabled_ = true;
@@ -133,13 +133,13 @@ void EncodingParams::EnableAudio(const AudioParams &audio_params,
audio_codec_ = acodec;
}
void EncodingParams::EnableSubtitles(const ExportCodec::Codec &scodec)
void EncodingParams::enable_subtitles(const ExportCodec::Codec &scodec)
{
subtitles_enabled_ = true;
subtitles_codec_ = scodec;
}
void EncodingParams::EnableSidecarSubtitles(const ExportFormat::Format &sfmt,
void EncodingParams::enable_sidecar_subtitles(const ExportFormat::Format &sfmt,
const ExportCodec::Codec &scodec)
{
subtitles_enabled_ = true;
@@ -148,24 +148,24 @@ void EncodingParams::EnableSidecarSubtitles(const ExportFormat::Format &sfmt,
subtitles_codec_ = scodec;
}
void EncodingParams::DisableVideo()
void EncodingParams::disable_video()
{
video_enabled_ = false;
}
void EncodingParams::DisableAudio()
void EncodingParams::disable_audio()
{
audio_enabled_ = false;
}
void EncodingParams::DisableSubtitles()
void EncodingParams::disable_subtitles()
{
subtitles_enabled_ = false;
}
bool EncodingParams::Load(QXmlStreamReader *reader)
bool EncodingParams::load(QXmlStreamReader *reader)
{
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("export")) {
int version = 0;
@@ -178,7 +178,7 @@ bool EncodingParams::Load(QXmlStreamReader *reader)
switch (version) {
case 1:
return LoadV1(reader);
return load_v1(reader);
}
} else {
reader->skipCurrentElement();
@@ -188,26 +188,26 @@ bool EncodingParams::Load(QXmlStreamReader *reader)
return false;
}
bool EncodingParams::Load(QIODevice *device)
bool EncodingParams::load(QIODevice *device)
{
QXmlStreamReader reader(device);
return Load(&reader);
return load(&reader);
}
void EncodingParams::Save(QIODevice *device) const
void EncodingParams::save(QIODevice *device) const
{
QXmlStreamWriter writer(device);
Save(&writer);
save(&writer);
}
void EncodingParams::Save(QXmlStreamWriter *writer) const
void EncodingParams::save(QXmlStreamWriter *writer) const
{
writer->writeStartDocument();
writer->writeStartElement(QStringLiteral("export"));
writer->writeAttribute(QStringLiteral("version"),
QString::number(kEncoderParamsVersion));
QString::number(k_encoder_params_version));
writer->writeTextElement(QStringLiteral("filename"), filename_);
writer->writeTextElement(QStringLiteral("format"),
@@ -217,10 +217,10 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
QString::number(has_custom_range_));
writer->writeTextElement(
QStringLiteral("customrangein"),
QString::fromStdString(custom_range_.in().toString()));
QString::fromStdString(custom_range_.in().to_string()));
writer->writeTextElement(
QStringLiteral("customrangeout"),
QString::fromStdString(custom_range_.out().toString()));
QString::fromStdString(custom_range_.out().to_string()));
writer->writeStartElement(QStringLiteral("video"));
@@ -239,10 +239,10 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
writer->writeTextElement(
QStringLiteral("pixelaspect"),
QString::fromStdString(
video_params_.pixel_aspect_ratio().toString()));
video_params_.pixel_aspect_ratio().to_string()));
writer->writeTextElement(
QStringLiteral("timebase"),
QString::fromStdString(video_params_.time_base().toString()));
QString::fromStdString(video_params_.time_base().to_string()));
writer->writeTextElement(QStringLiteral("divider"),
QString::number(video_params_.divider()));
writer->writeTextElement(QStringLiteral("bitrate"),
@@ -332,77 +332,77 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
writer->writeEndDocument();
}
Encoder *Encoder::CreateFromID(Type id, const EncodingParams &params)
Encoder *Encoder::create_from_id(Type id, const EncodingParams &params)
{
switch (id) {
case kEncoderTypeNone:
case k_encoder_type_none:
break;
case kEncoderTypeFFmpeg:
case k_encoder_type_f_fmpeg:
return new FFmpegEncoder(params);
case kEncoderTypeOIIO:
case k_encoder_type_oiio:
return new OIIOEncoder(params);
}
return nullptr;
}
Encoder::Type Encoder::GetTypeFromFormat(ExportFormat::Format f)
Encoder::Type Encoder::get_type_from_format(ExportFormat::Format f)
{
switch (f) {
case ExportFormat::kFormatDNxHD:
case ExportFormat::kFormatMatroska:
case ExportFormat::kFormatQuickTime:
case ExportFormat::kFormatMPEG4Video:
case ExportFormat::kFormatMPEG4Audio:
case ExportFormat::kFormatWAV:
case ExportFormat::kFormatAIFF:
case ExportFormat::kFormatMP3:
case ExportFormat::kFormatFLAC:
case ExportFormat::kFormatOgg:
case ExportFormat::kFormatWebM:
case ExportFormat::kFormatSRT:
return kEncoderTypeFFmpeg;
case ExportFormat::kFormatOpenEXR:
case ExportFormat::kFormatPNG:
case ExportFormat::kFormatTIFF:
return kEncoderTypeOIIO;
case ExportFormat::kFormatCount:
case ExportFormat::k_format_d_nx_hd:
case ExportFormat::k_format_matroska:
case ExportFormat::k_format_quick_time:
case ExportFormat::k_format_mpe_g4_video:
case ExportFormat::k_format_mpe_g4_audio:
case ExportFormat::k_format_wav:
case ExportFormat::k_format_aiff:
case ExportFormat::k_format_m_p3:
case ExportFormat::k_format_flac:
case ExportFormat::k_format_ogg:
case ExportFormat::k_format_web_m:
case ExportFormat::k_format_srt:
return k_encoder_type_f_fmpeg;
case ExportFormat::k_format_open_exr:
case ExportFormat::k_format_png:
case ExportFormat::k_format_tiff:
return k_encoder_type_oiio;
case ExportFormat::k_format_count:
break;
}
return kEncoderTypeNone;
return k_encoder_type_none;
}
Encoder *Encoder::CreateFromFormat(ExportFormat::Format f,
Encoder *Encoder::create_from_format(ExportFormat::Format f,
const EncodingParams &params)
{
return CreateFromID(GetTypeFromFormat(f), params);
return create_from_id(get_type_from_format(f), params);
}
Encoder *Encoder::CreateFromParams(const EncodingParams &params)
Encoder *Encoder::create_from_params(const EncodingParams &params)
{
return CreateFromFormat(params.format(), params);
return create_from_format(params.format(), params);
}
QStringList Encoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const
QStringList Encoder::get_pixel_formats_for_codec(ExportCodec::Codec c) const
{
return QStringList();
}
std::vector<SampleFormat>
Encoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const
Encoder::get_sample_formats_for_codec(ExportCodec::Codec c) const
{
return std::vector<SampleFormat>();
}
QMatrix4x4
EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method,
EncodingParams::generate_matrix(EncodingParams::VideoScalingMethod method,
int source_width, int source_height,
int dest_width, int dest_height)
{
QMatrix4x4 preview_matrix;
if (method == EncodingParams::kStretch) {
if (method == EncodingParams::k_stretch) {
return preview_matrix;
}
@@ -415,7 +415,7 @@ EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method,
return preview_matrix;
}
if ((export_ar > source_ar) == (method == EncodingParams::kFit)) {
if ((export_ar > source_ar) == (method == EncodingParams::k_fit)) {
preview_matrix.scale(source_ar / export_ar, 1.0F);
} else {
preview_matrix.scale(1.0F, export_ar / source_ar);
@@ -424,11 +424,11 @@ EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method,
return preview_matrix;
}
bool EncodingParams::LoadV1(QXmlStreamReader *reader)
bool EncodingParams::load_v1(QXmlStreamReader *reader)
{
rational custom_range_in, custom_range_out;
Rational custom_range_in, custom_range_out;
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("filename")) {
filename_ = reader->readElementText();
} else if (reader->name() == QStringLiteral("format")) {
@@ -438,10 +438,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
has_custom_range_ = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("customrangein")) {
custom_range_in =
rational::fromString(reader->readElementText().toStdString());
Rational::from_string(reader->readElementText().toStdString());
} else if (reader->name() == QStringLiteral("customrangeout")) {
custom_range_out =
rational::fromString(reader->readElementText().toStdString());
Rational::from_string(reader->readElementText().toStdString());
} else if (reader->name() == QStringLiteral("video")) {
XMLAttributeLoop(reader, attr)
{
@@ -450,7 +450,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
}
}
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("codec")) {
video_codec_ = static_cast<ExportCodec::Codec>(
reader->readElementText().toInt());
@@ -462,10 +462,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
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(
video_params_.set_pixel_aspect_ratio(Rational::from_string(
reader->readElementText().toStdString()));
} else if (reader->name() == QStringLiteral("timebase")) {
video_params_.set_time_base(rational::fromString(
video_params_.set_time_base(Rational::from_string(
reader->readElementText().toStdString()));
} else if (reader->name() == QStringLiteral("divider")) {
video_params_.set_divider(
@@ -488,7 +488,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
video_is_image_sequence_ =
reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("color")) {
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("output")) {
color_transform_ = reader->readElementText();
} else {
@@ -499,10 +499,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
video_scaling_method_ = static_cast<VideoScalingMethod>(
reader->readElementText().toInt());
} else if (reader->name() == QStringLiteral("opts")) {
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("entry")) {
QString key, value;
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("key")) {
key = reader->readElementText();
} else if (reader->name() ==
@@ -534,7 +534,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
}
}
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("codec")) {
audio_codec_ = static_cast<ExportCodec::Codec>(
reader->readElementText().toInt());
@@ -566,7 +566,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader)
}
}
while (XMLReadNextStartElement(reader)) {
while (xml_read_next_start_element(reader)) {
if (reader->name() == QStringLiteral("sidecar")) {
subtitles_are_sidecar_ = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("sidecarformat")) {
+53 -53
View File
@@ -19,8 +19,8 @@
***/
#ifndef ENCODER_H
#define ENCODER_H
#ifndef OAK_ENCODER_H
#define OAK_ENCODER_H
#include <memory>
#include <QRegularExpression>
@@ -43,34 +43,34 @@ using EncoderPtr = std::shared_ptr<Encoder>;
class EncodingParams {
public:
enum VideoScalingMethod { kFit, kStretch, kCrop };
enum VideoScalingMethod { k_fit, k_stretch, k_crop };
EncodingParams();
static QDir GetPresetPath();
static QStringList GetListOfPresets();
static QDir get_preset_path();
static QStringList get_list_of_presets();
bool IsValid() const
bool is_valid() const
{
return video_enabled_ || audio_enabled_ || subtitles_enabled_;
}
void SetFilename(const QString &filename)
void set_filename(const QString &filename)
{
filename_ = filename;
}
void EnableVideo(const VideoParams &video_params,
void enable_video(const VideoParams &video_params,
const ExportCodec::Codec &vcodec);
void EnableAudio(const AudioParams &audio_params,
void enable_audio(const AudioParams &audio_params,
const ExportCodec::Codec &acodec);
void EnableSubtitles(const ExportCodec::Codec &scodec);
void EnableSidecarSubtitles(const ExportFormat::Format &sfmt,
void enable_subtitles(const ExportCodec::Codec &scodec);
void enable_sidecar_subtitles(const ExportFormat::Format &sfmt,
const ExportCodec::Codec &scodec);
void DisableVideo();
void DisableAudio();
void DisableSubtitles();
void disable_video();
void disable_audio();
void disable_subtitles();
const ExportFormat::Format &format() const
{
@@ -219,20 +219,20 @@ public:
return subtitles_codec_;
}
const rational &GetExportLength() const
const Rational &get_export_length() const
{
return export_length_;
}
void SetExportLength(const rational &export_length)
void set_export_length(const Rational &export_length)
{
export_length_ = export_length;
}
bool Load(QIODevice *device);
bool Load(QXmlStreamReader *reader);
bool load(QIODevice *device);
bool load(QXmlStreamReader *reader);
void Save(QIODevice *device) const;
void Save(QXmlStreamWriter *writer) const;
void save(QIODevice *device) const;
void save(QXmlStreamWriter *writer) const;
bool has_custom_range() const
{
@@ -258,20 +258,20 @@ public:
video_scaling_method_ = video_scaling_method;
}
static QMatrix4x4 GenerateMatrix(VideoScalingMethod method,
static QMatrix4x4 generate_matrix(VideoScalingMethod method,
int source_width, int source_height,
int dest_width, int dest_height);
private:
static const int kEncoderParamsVersion = 1;
static const int k_encoder_params_version = 1;
bool LoadV1(QXmlStreamReader *reader);
bool load_v1(QXmlStreamReader *reader);
QString filename_;
ExportFormat::Format format_ = ExportFormat::kFormatCount;
ExportFormat::Format format_ = ExportFormat::k_format_count;
bool video_enabled_;
ExportCodec::Codec video_codec_ = ExportCodec::kCodecCount;
ExportCodec::Codec video_codec_ = ExportCodec::k_codec_count;
VideoParams video_params_;
QHash<QString, QString> video_opts_;
int64_t video_bit_rate_;
@@ -284,16 +284,16 @@ private:
ColorTransform color_transform_;
bool audio_enabled_;
ExportCodec::Codec audio_codec_ = ExportCodec::kCodecCount;
ExportCodec::Codec audio_codec_ = ExportCodec::k_codec_count;
AudioParams audio_params_;
int64_t audio_bit_rate_;
bool subtitles_enabled_;
bool subtitles_are_sidecar_;
ExportFormat::Format subtitle_sidecar_fmt_ = ExportFormat::kFormatCount;
ExportCodec::Codec subtitles_codec_ = ExportCodec::kCodecCount;
ExportFormat::Format subtitle_sidecar_fmt_ = ExportFormat::k_format_count;
ExportCodec::Codec subtitles_codec_ = ExportCodec::k_codec_count;
rational export_length_;
Rational export_length_;
VideoScalingMethod video_scaling_method_;
bool has_custom_range_;
@@ -305,7 +305,7 @@ class Encoder : public QObject {
public:
Encoder(const EncodingParams &params);
enum Type { kEncoderTypeNone = -1, kEncoderTypeFFmpeg, kEncoderTypeOIIO };
enum Type { k_encoder_type_none = -1, k_encoder_type_f_fmpeg, k_encoder_type_oiio };
/**
* @brief Create a Encoder instance using a Encoder ID
@@ -314,53 +314,53 @@ public:
*
* A Encoder instance or nullptr if a Decoder with this ID does not exist
*/
static Encoder *CreateFromID(Type id, const EncodingParams &params);
static Encoder *create_from_id(Type id, const EncodingParams &params);
static Type GetTypeFromFormat(ExportFormat::Format f);
static Type get_type_from_format(ExportFormat::Format f);
static Encoder *CreateFromFormat(ExportFormat::Format f,
static Encoder *create_from_format(ExportFormat::Format f,
const EncodingParams &params);
static Encoder *CreateFromParams(const EncodingParams &params);
static Encoder *create_from_params(const EncodingParams &params);
virtual QStringList GetPixelFormatsForCodec(ExportCodec::Codec c) const;
virtual QStringList get_pixel_formats_for_codec(ExportCodec::Codec c) const;
virtual std::vector<SampleFormat>
GetSampleFormatsForCodec(ExportCodec::Codec c) const;
get_sample_formats_for_codec(ExportCodec::Codec c) const;
const EncodingParams &params() const;
virtual PixelFormat GetDesiredPixelFormat() const
virtual PixelFormat get_desired_pixel_format() const
{
return PixelFormat::INVALID;
return PixelFormat::invalid;
}
const QString &GetError() const
const QString &get_error() const
{
return error_;
}
QString GetFilenameForFrame(const rational &frame);
QString get_filename_for_frame(const Rational &frame);
static int GetImageSequencePlaceholderDigitCount(const QString &filename);
static int get_image_sequence_placeholder_digit_count(const QString &filename);
static bool FilenameContainsDigitPlaceholder(const QString &filename);
static QString FilenameRemoveDigitPlaceholder(QString filename);
static bool filename_contains_digit_placeholder(const QString &filename);
static QString filename_remove_digit_placeholder(QString filename);
static const QRegularExpression kImageSequenceContainsDigits;
static const QRegularExpression kImageSequenceRemoveDigits;
static const QRegularExpression k_image_sequence_contains_digits;
static const QRegularExpression k_image_sequence_remove_digits;
public slots:
virtual bool Open() = 0;
virtual bool open() = 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;
virtual bool write_frame(olive::FramePtr frame,
olive::core::Rational time) = 0;
virtual bool write_audio(const olive::SampleBuffer &audio) = 0;
virtual bool write_subtitle(const SubtitleBlock *sub_block) = 0;
virtual void Close() = 0;
virtual void close() = 0;
protected:
void SetError(const QString &err)
void set_error(const QString &err)
{
error_ = err;
}
@@ -373,4 +373,4 @@ private:
}
#endif // ENCODER_H
#endif // OAK_ENCODER_H
+63 -63
View File
@@ -27,109 +27,109 @@ extern "C" {
namespace olive
{
QString ExportCodec::GetCodecName(ExportCodec::Codec c)
QString ExportCodec::get_codec_name(ExportCodec::Codec c)
{
switch (c) {
case kCodecDNxHD:
case k_codec_d_nx_hd:
return tr("DNxHD");
case kCodecH264:
case k_codec_h264:
return tr("H.264");
case kCodecH264rgb:
case k_codec_h264rgb:
return tr("H.264 RGB");
case kCodecH265:
case k_codec_h265:
return tr("H.265");
case kCodecOpenEXR:
case k_codec_open_exr:
return tr("OpenEXR");
case kCodecPNG:
case k_codec_png:
return tr("PNG");
case kCodecProRes:
case k_codec_pro_res:
return tr("ProRes");
case kCodecCineform:
case k_codec_cineform:
return tr("Cineform");
case kCodecTIFF:
case k_codec_tiff:
return tr("TIFF");
case kCodecMP2:
case k_codec_m_p2:
return tr("MP2");
case kCodecMP3:
case k_codec_m_p3:
return tr("MP3");
case kCodecAAC:
case k_codec_aac:
return tr("AAC");
case kCodecPCM:
case k_codec_pcm:
return tr("PCM (Uncompressed)");
case kCodecFLAC:
case k_codec_flac:
return tr("FLAC");
case kCodecOpus:
case k_codec_opus:
return tr("Opus");
case kCodecVorbis:
case k_codec_vorbis:
return tr("Vorbis");
case kCodecVP9:
case k_codec_v_p9:
return tr("VP9");
case kCodecAV1:
case k_codec_a_v1:
return tr("AV1");
case kCodecSRT:
case k_codec_srt:
return tr("SubRip SRT");
case kCodecCount:
case k_codec_count:
break;
}
return tr("Unknown");
}
bool ExportCodec::IsCodecAStillImage(ExportCodec::Codec c)
bool ExportCodec::is_codec_a_still_image(ExportCodec::Codec c)
{
switch (c) {
case kCodecDNxHD:
case kCodecH264:
case kCodecH264rgb:
case kCodecH265:
case kCodecProRes:
case kCodecCineform:
case kCodecMP2:
case kCodecMP3:
case kCodecAAC:
case kCodecPCM:
case kCodecVorbis:
case kCodecOpus:
case kCodecFLAC:
case kCodecVP9:
case kCodecAV1:
case kCodecSRT:
case k_codec_d_nx_hd:
case k_codec_h264:
case k_codec_h264rgb:
case k_codec_h265:
case k_codec_pro_res:
case k_codec_cineform:
case k_codec_m_p2:
case k_codec_m_p3:
case k_codec_aac:
case k_codec_pcm:
case k_codec_vorbis:
case k_codec_opus:
case k_codec_flac:
case k_codec_v_p9:
case k_codec_a_v1:
case k_codec_srt:
return false;
case kCodecOpenEXR:
case kCodecPNG:
case kCodecTIFF:
case k_codec_open_exr:
case k_codec_png:
case k_codec_tiff:
return true;
case kCodecCount:
case k_codec_count:
break;
}
return false;
}
bool ExportCodec::IsCodecLossless(Codec c)
bool ExportCodec::is_codec_lossless(Codec c)
{
switch (c) {
case kCodecPCM:
case kCodecFLAC:
case k_codec_pcm:
case k_codec_flac:
return true;
case kCodecDNxHD:
case kCodecH264:
case kCodecH264rgb:
case kCodecH265:
case kCodecProRes:
case kCodecCineform:
case kCodecMP2:
case kCodecMP3:
case kCodecAAC:
case kCodecVorbis:
case kCodecOpus:
case kCodecVP9:
case kCodecAV1:
case kCodecSRT:
case kCodecOpenEXR:
case kCodecPNG:
case kCodecTIFF:
case kCodecCount:
case k_codec_d_nx_hd:
case k_codec_h264:
case k_codec_h264rgb:
case k_codec_h265:
case k_codec_pro_res:
case k_codec_cineform:
case k_codec_m_p2:
case k_codec_m_p3:
case k_codec_aac:
case k_codec_vorbis:
case k_codec_opus:
case k_codec_v_p9:
case k_codec_a_v1:
case k_codec_srt:
case k_codec_open_exr:
case k_codec_png:
case k_codec_tiff:
case k_codec_count:
break;
}
+26 -26
View File
@@ -19,8 +19,8 @@
***/
#ifndef EXPORTCODEC_H
#define EXPORTCODEC_H
#ifndef OAK_EXPORTCODEC_H
#define OAK_EXPORTCODEC_H
#include <QObject>
#include <QString>
@@ -36,36 +36,36 @@ class ExportCodec : public QObject {
public:
// Only append to this list (never insert) because indexes are used in serialized files
enum Codec {
kCodecDNxHD,
kCodecH264,
kCodecH264rgb,
kCodecH265,
kCodecOpenEXR,
kCodecPNG,
kCodecProRes,
kCodecCineform,
kCodecTIFF,
kCodecVP9,
kCodecMP2,
kCodecMP3,
kCodecAAC,
kCodecPCM,
kCodecOpus,
kCodecVorbis,
kCodecFLAC,
kCodecSRT,
kCodecAV1,
k_codec_d_nx_hd,
k_codec_h264,
k_codec_h264rgb,
k_codec_h265,
k_codec_open_exr,
k_codec_png,
k_codec_pro_res,
k_codec_cineform,
k_codec_tiff,
k_codec_v_p9,
k_codec_m_p2,
k_codec_m_p3,
k_codec_aac,
k_codec_pcm,
k_codec_opus,
k_codec_vorbis,
k_codec_flac,
k_codec_srt,
k_codec_a_v1,
kCodecCount
k_codec_count
};
static QString GetCodecName(Codec c);
static QString get_codec_name(Codec c);
static bool IsCodecAStillImage(Codec c);
static bool is_codec_a_still_image(Codec c);
static bool IsCodecLossless(Codec c);
static bool is_codec_lossless(Codec c);
};
}
#endif // EXPORTCODEC_H
#endif // OAK_EXPORTCODEC_H
+122 -122
View File
@@ -26,206 +26,206 @@
namespace olive
{
QString ExportFormat::GetName(olive::ExportFormat::Format f)
QString ExportFormat::get_name(olive::ExportFormat::Format f)
{
switch (f) {
case kFormatDNxHD:
case k_format_d_nx_hd:
return tr("DNxHD");
case kFormatMatroska:
case k_format_matroska:
return tr("Matroska Video");
case kFormatMPEG4Video:
case k_format_mpe_g4_video:
return tr("MPEG-4 Video");
case kFormatMPEG4Audio:
case k_format_mpe_g4_audio:
return tr("MPEG-4 Audio");
case kFormatOpenEXR:
case k_format_open_exr:
return tr("OpenEXR");
case kFormatPNG:
case k_format_png:
return tr("PNG");
case kFormatTIFF:
case k_format_tiff:
return tr("TIFF");
case kFormatQuickTime:
case k_format_quick_time:
return tr("QuickTime");
case kFormatWAV:
case k_format_wav:
return tr("Wave Audio");
case kFormatAIFF:
case k_format_aiff:
return tr("AIFF");
case kFormatMP3:
case k_format_m_p3:
return tr("MP3");
case kFormatFLAC:
case k_format_flac:
return tr("FLAC");
case kFormatOgg:
case k_format_ogg:
return tr("Ogg");
case kFormatWebM:
case k_format_web_m:
return tr("WebM");
case kFormatSRT:
case k_format_srt:
return tr("SubRip SRT");
case kFormatCount:
case k_format_count:
break;
}
return tr("Unknown");
}
QString ExportFormat::GetExtension(ExportFormat::Format f)
QString ExportFormat::get_extension(ExportFormat::Format f)
{
switch (f) {
case kFormatDNxHD:
case k_format_d_nx_hd:
return QStringLiteral("mxf");
case kFormatMatroska:
case k_format_matroska:
return QStringLiteral("mkv");
case kFormatMPEG4Video:
case k_format_mpe_g4_video:
return QStringLiteral("mp4");
case kFormatMPEG4Audio:
case k_format_mpe_g4_audio:
return QStringLiteral("m4a");
case kFormatOpenEXR:
case k_format_open_exr:
return QStringLiteral("exr");
case kFormatPNG:
case k_format_png:
return QStringLiteral("png");
case kFormatTIFF:
case k_format_tiff:
return QStringLiteral("tiff");
case kFormatQuickTime:
case k_format_quick_time:
return QStringLiteral("mov");
case kFormatWAV:
case k_format_wav:
return QStringLiteral("wav");
case kFormatAIFF:
case k_format_aiff:
return QStringLiteral("aiff");
case kFormatMP3:
case k_format_m_p3:
return QStringLiteral("mp3");
case kFormatFLAC:
case k_format_flac:
return QStringLiteral("flac");
case kFormatOgg:
case k_format_ogg:
return QStringLiteral("ogg");
case kFormatWebM:
case k_format_web_m:
return QStringLiteral("webm");
case kFormatSRT:
case k_format_srt:
return QStringLiteral("srt");
case kFormatCount:
case k_format_count:
break;
}
return QString();
}
QList<ExportCodec::Codec> ExportFormat::GetVideoCodecs(ExportFormat::Format f)
QList<ExportCodec::Codec> ExportFormat::get_video_codecs(ExportFormat::Format f)
{
switch (f) {
case kFormatDNxHD:
return { ExportCodec::kCodecDNxHD };
case kFormatMatroska:
return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb,
ExportCodec::kCodecH265, ExportCodec::kCodecVP9 };
case kFormatMPEG4Video:
return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb,
ExportCodec::kCodecH265 };
case kFormatOpenEXR:
return { ExportCodec::kCodecOpenEXR };
case kFormatPNG:
return { ExportCodec::kCodecPNG };
case kFormatTIFF:
return { ExportCodec::kCodecTIFF };
case kFormatQuickTime:
return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb,
ExportCodec::kCodecH265, ExportCodec::kCodecProRes,
ExportCodec::kCodecCineform };
case kFormatWebM:
return { ExportCodec::kCodecAV1, ExportCodec::kCodecVP9 };
case kFormatOgg:
case kFormatWAV:
case kFormatMPEG4Audio:
case kFormatAIFF:
case kFormatMP3:
case kFormatFLAC:
case kFormatSRT:
case kFormatCount:
case k_format_d_nx_hd:
return { ExportCodec::k_codec_d_nx_hd };
case k_format_matroska:
return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb,
ExportCodec::k_codec_h265, ExportCodec::k_codec_v_p9 };
case k_format_mpe_g4_video:
return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb,
ExportCodec::k_codec_h265 };
case k_format_open_exr:
return { ExportCodec::k_codec_open_exr };
case k_format_png:
return { ExportCodec::k_codec_png };
case k_format_tiff:
return { ExportCodec::k_codec_tiff };
case k_format_quick_time:
return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb,
ExportCodec::k_codec_h265, ExportCodec::k_codec_pro_res,
ExportCodec::k_codec_cineform };
case k_format_web_m:
return { ExportCodec::k_codec_a_v1, ExportCodec::k_codec_v_p9 };
case k_format_ogg:
case k_format_wav:
case k_format_mpe_g4_audio:
case k_format_aiff:
case k_format_m_p3:
case k_format_flac:
case k_format_srt:
case k_format_count:
break;
}
return {};
}
QList<ExportCodec::Codec> ExportFormat::GetAudioCodecs(ExportFormat::Format f)
QList<ExportCodec::Codec> ExportFormat::get_audio_codecs(ExportFormat::Format f)
{
switch (f) {
// Video/audio formats
case kFormatDNxHD:
return { ExportCodec::kCodecPCM };
case kFormatMatroska:
return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2,
ExportCodec::kCodecMP3, ExportCodec::kCodecPCM,
ExportCodec::kCodecVorbis, ExportCodec::kCodecOpus,
ExportCodec::kCodecFLAC };
case kFormatMPEG4Video:
case kFormatMPEG4Audio:
return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2,
ExportCodec::kCodecMP3 };
case kFormatQuickTime:
return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2,
ExportCodec::kCodecMP3, ExportCodec::kCodecPCM };
case kFormatWebM:
return { ExportCodec::kCodecOpus, ExportCodec::kCodecAAC,
ExportCodec::kCodecMP2, ExportCodec::kCodecMP3,
ExportCodec::kCodecPCM, ExportCodec::kCodecVorbis };
case k_format_d_nx_hd:
return { ExportCodec::k_codec_pcm };
case k_format_matroska:
return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2,
ExportCodec::k_codec_m_p3, ExportCodec::k_codec_pcm,
ExportCodec::k_codec_vorbis, ExportCodec::k_codec_opus,
ExportCodec::k_codec_flac };
case k_format_mpe_g4_video:
case k_format_mpe_g4_audio:
return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2,
ExportCodec::k_codec_m_p3 };
case k_format_quick_time:
return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2,
ExportCodec::k_codec_m_p3, ExportCodec::k_codec_pcm };
case k_format_web_m:
return { ExportCodec::k_codec_opus, ExportCodec::k_codec_aac,
ExportCodec::k_codec_m_p2, ExportCodec::k_codec_m_p3,
ExportCodec::k_codec_pcm, ExportCodec::k_codec_vorbis };
// Audio only formats
case kFormatWAV:
return { ExportCodec::kCodecPCM };
case kFormatAIFF:
return { ExportCodec::kCodecPCM };
case kFormatMP3:
return { ExportCodec::kCodecMP3 };
case kFormatFLAC:
return { ExportCodec::kCodecFLAC };
case kFormatOgg:
return { ExportCodec::kCodecOpus, ExportCodec::kCodecVorbis,
ExportCodec::kCodecPCM };
case k_format_wav:
return { ExportCodec::k_codec_pcm };
case k_format_aiff:
return { ExportCodec::k_codec_pcm };
case k_format_m_p3:
return { ExportCodec::k_codec_m_p3 };
case k_format_flac:
return { ExportCodec::k_codec_flac };
case k_format_ogg:
return { ExportCodec::k_codec_opus, ExportCodec::k_codec_vorbis,
ExportCodec::k_codec_pcm };
// Video only formats
case kFormatOpenEXR:
case kFormatPNG:
case kFormatTIFF:
case kFormatSRT:
case kFormatCount:
case k_format_open_exr:
case k_format_png:
case k_format_tiff:
case k_format_srt:
case k_format_count:
break;
}
return {};
}
QList<ExportCodec::Codec> ExportFormat::GetSubtitleCodecs(Format f)
QList<ExportCodec::Codec> ExportFormat::get_subtitle_codecs(Format f)
{
switch (f) {
case kFormatDNxHD:
case kFormatMPEG4Video:
case kFormatMPEG4Audio:
case kFormatOpenEXR:
case kFormatQuickTime:
case kFormatPNG:
case kFormatTIFF:
case kFormatWAV:
case kFormatAIFF:
case kFormatMP3:
case kFormatFLAC:
case kFormatOgg:
case kFormatWebM:
case kFormatCount:
case k_format_d_nx_hd:
case k_format_mpe_g4_video:
case k_format_mpe_g4_audio:
case k_format_open_exr:
case k_format_quick_time:
case k_format_png:
case k_format_tiff:
case k_format_wav:
case k_format_aiff:
case k_format_m_p3:
case k_format_flac:
case k_format_ogg:
case k_format_web_m:
case k_format_count:
break;
case kFormatMatroska:
case kFormatSRT:
return { ExportCodec::kCodecSRT };
case k_format_matroska:
case k_format_srt:
return { ExportCodec::k_codec_srt };
}
return {};
}
QStringList ExportFormat::GetPixelFormatsForCodec(ExportFormat::Format f,
QStringList ExportFormat::get_pixel_formats_for_codec(ExportFormat::Format f,
ExportCodec::Codec c)
{
Encoder *e = Encoder::CreateFromFormat(f, EncodingParams());
Encoder *e = Encoder::create_from_format(f, EncodingParams());
QStringList list;
if (e) {
list = e->GetPixelFormatsForCodec(c);
list = e->get_pixel_formats_for_codec(c);
delete e;
}
@@ -233,13 +233,13 @@ QStringList ExportFormat::GetPixelFormatsForCodec(ExportFormat::Format f,
}
std::vector<SampleFormat>
ExportFormat::GetSampleFormatsForCodec(Format format, ExportCodec::Codec c)
ExportFormat::get_sample_formats_for_codec(Format format, ExportCodec::Codec c)
{
std::vector<SampleFormat> f;
Encoder *e = Encoder::CreateFromFormat(format, EncodingParams());
Encoder *e = Encoder::create_from_format(format, EncodingParams());
if (e) {
f = e->GetSampleFormatsForCodec(c);
f = e->get_sample_formats_for_codec(c);
delete e;
}
+26 -26
View File
@@ -19,8 +19,8 @@
***/
#ifndef EXPORTFORMAT_H
#define EXPORTFORMAT_H
#ifndef OAK_EXPORTFORMAT_H
#define OAK_EXPORTFORMAT_H
#include <QList>
#include <QString>
@@ -36,36 +36,36 @@ class ExportFormat : public QObject {
public:
// Only append to this list (never insert) because indexes are used in serialized files
enum Format {
kFormatDNxHD,
kFormatMatroska,
kFormatMPEG4Video,
kFormatOpenEXR,
kFormatQuickTime,
kFormatPNG,
kFormatTIFF,
kFormatWAV,
kFormatAIFF,
kFormatMP3,
kFormatFLAC,
kFormatOgg,
kFormatWebM,
kFormatSRT,
kFormatMPEG4Audio,
k_format_d_nx_hd,
k_format_matroska,
k_format_mpe_g4_video,
k_format_open_exr,
k_format_quick_time,
k_format_png,
k_format_tiff,
k_format_wav,
k_format_aiff,
k_format_m_p3,
k_format_flac,
k_format_ogg,
k_format_web_m,
k_format_srt,
k_format_mpe_g4_audio,
kFormatCount
k_format_count
};
static QString GetName(Format f);
static QString GetExtension(Format f);
static QList<ExportCodec::Codec> GetVideoCodecs(ExportFormat::Format f);
static QList<ExportCodec::Codec> GetAudioCodecs(ExportFormat::Format f);
static QList<ExportCodec::Codec> GetSubtitleCodecs(ExportFormat::Format f);
static QString get_name(Format f);
static QString get_extension(Format f);
static QList<ExportCodec::Codec> get_video_codecs(ExportFormat::Format f);
static QList<ExportCodec::Codec> get_audio_codecs(ExportFormat::Format f);
static QList<ExportCodec::Codec> get_subtitle_codecs(ExportFormat::Format f);
static QStringList GetPixelFormatsForCodec(Format f, ExportCodec::Codec c);
static QStringList get_pixel_formats_for_codec(Format f, ExportCodec::Codec c);
static std::vector<SampleFormat>
GetSampleFormatsForCodec(Format f, ExportCodec::Codec c);
get_sample_formats_for_codec(Format f, ExportCodec::Codec c);
};
}
#endif // EXPORTFORMAT_H
#endif // OAK_EXPORTFORMAT_H
File diff suppressed because it is too large Load Diff
+26 -26
View File
@@ -19,8 +19,8 @@
***/
#ifndef FFMPEGDECODER_H
#define FFMPEGDECODER_H
#ifndef OAK_FFMPEGDECODER_H
#define OAK_FFMPEGDECODER_H
#include <inttypes.h>
@@ -53,30 +53,30 @@ public:
virtual QString id() const override;
virtual bool SupportsVideo() override
virtual bool supports_video() override
{
return true;
}
virtual bool SupportsAudio() override
virtual bool supports_audio() override
{
return true;
}
virtual FootageDescription Probe(const QString &filename,
virtual FootageDescription probe(const QString &filename,
CancelAtom *cancelled) const override;
protected:
virtual bool OpenInternal() override;
virtual bool open_internal() override;
virtual TexturePtr
RetrieveVideoInternal(const RetrieveVideoParams &p) override;
retrieve_video_internal(const RetrieveVideoParams &p) override;
virtual FramePtr
RetrieveVideoFrameInternal(const RetrieveVideoParams &p) override;
virtual bool ConformAudioInternal(const QVector<QString> &filenames,
retrieve_video_frame_internal(const RetrieveVideoParams &p) override;
virtual bool conform_audio_internal(const QVector<QString> &filenames,
const AudioParams &params,
CancelAtom *cancelled) override;
virtual void CloseInternal() override;
virtual void close_internal() override;
virtual rational GetAudioStartOffset() const override;
virtual Rational get_audio_start_offset() const override;
private:
/**
@@ -87,32 +87,32 @@ private:
*
* @param error_code
*/
static QString FFmpegError(int error_code);
static QString f_fmpeg_error(int error_code);
void FreeScaler();
void free_scaler();
AVFramePtr TransferHardwareFrame(AVFramePtr f);
AVFramePtr transfer_hardware_frame(AVFramePtr f);
static PixelFormat GetNativePixelFormat(int pix_fmt);
static int GetNativeChannelCount(int pix_fmt);
static PixelFormat get_native_pixel_format(int pix_fmt);
static int get_native_channel_count(int pix_fmt);
static bool IsPixelFormatGLSLCompatible(int f);
static bool is_pixel_format_glsl_compatible(int f);
AVFramePtr GetFrameFromCache(const int64_t &t) const;
AVFramePtr get_frame_from_cache(const int64_t &t) const;
void ClearFrameCache();
void clear_frame_cache();
AVFramePtr PreProcessFrame(AVFramePtr f, const RetrieveVideoParams &p);
AVFramePtr pre_process_frame(AVFramePtr f, const RetrieveVideoParams &p);
TexturePtr ProcessFrameIntoTexture(AVFramePtr f,
TexturePtr process_frame_into_texture(AVFramePtr f,
const RetrieveVideoParams &p,
const AVFramePtr original);
AVFramePtr RetrieveFrame(const rational &time, CancelAtom *cancelled);
AVFramePtr retrieve_frame(const Rational &time, CancelAtom *cancelled);
void RemoveFirstFrame();
void remove_first_frame();
static int MaximumQueueSize();
static int maximum_queue_size();
FBScaler *scaler_;
int scaler_src_width_;
@@ -137,7 +137,7 @@ private:
// Stream parameters cached on open (the stream object itself lives
// inside the bridge library)
rational stream_time_base_;
Rational stream_time_base_;
int64_t stream_start_time_;
int64_t stream_duration_;
int64_t format_start_time_;
@@ -148,4 +148,4 @@ private:
}
#endif // FFMPEGDECODER_H
#endif // OAK_FFMPEGDECODER_H
+94 -94
View File
@@ -38,12 +38,12 @@ FFmpegEncoder::FFmpegEncoder(const EncodingParams &params)
{
}
QStringList FFmpegEncoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const
QStringList FFmpegEncoder::get_pixel_formats_for_codec(ExportCodec::Codec c) const
{
QStringList pix_fmts;
int bridge_codec = ExportCodecToBridge(c);
if (bridge_codec != FB_CODEC_NONE) {
int bridge_codec = export_codec_to_bridge(c);
if (bridge_codec != fb_codec_none) {
int count =
fb_encoder_codec_get_pixel_formats(bridge_codec, nullptr, 0);
if (count > 0) {
@@ -60,19 +60,19 @@ QStringList FFmpegEncoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const
}
std::vector<SampleFormat>
FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const
FFmpegEncoder::get_sample_formats_for_codec(ExportCodec::Codec c) const
{
std::vector<SampleFormat> f;
if (c == ExportCodec::kCodecPCM) {
if (c == ExportCodec::k_codec_pcm) {
// FFmpeg lists these as separate codecs so we need custom functionality here
// We list signed 16 first because ExportDialog will always use the first element by default
// (because first element is the "default" in FFmpeg)
f = { SampleFormat::S16, SampleFormat::U8, SampleFormat::S32,
SampleFormat::S64, SampleFormat::F32, SampleFormat::F64 };
f = { SampleFormat::s16, SampleFormat::u8, SampleFormat::s32,
SampleFormat::s64, SampleFormat::f32, SampleFormat::f64 };
} else {
int bridge_codec = ExportCodecToBridge(c);
if (bridge_codec != FB_CODEC_NONE) {
int bridge_codec = export_codec_to_bridge(c);
if (bridge_codec != fb_codec_none) {
int count =
fb_encoder_codec_get_sample_formats(bridge_codec, nullptr, 0);
if (count > 0) {
@@ -81,8 +81,8 @@ FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const
count);
for (int fmt : fmts) {
SampleFormat native =
FFmpegUtils::GetNativeSampleFormat(fmt);
if (native != SampleFormat::INVALID) {
FFmpegUtils::get_native_sample_format(fmt);
if (native != SampleFormat::invalid) {
f.push_back(native);
}
}
@@ -93,7 +93,7 @@ FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const
return f;
}
bool FFmpegEncoder::Open()
bool FFmpegEncoder::open()
{
if (open_) {
return true;
@@ -117,7 +117,7 @@ bool FFmpegEncoder::Open()
// Set up video if it's enabled
if (params().video_enabled()) {
config.video_enabled = 1;
config.video_codec = ExportCodecToBridge(params().video_codec());
config.video_codec = export_codec_to_bridge(params().video_codec());
config.video_width = params().video_params().width();
config.video_height = params().video_params().height();
config.video_pixel_aspect_num =
@@ -141,17 +141,17 @@ bool FFmpegEncoder::Open()
// This is the format we will need to convert the frame to for the bridge to understand it
video_conversion_fmt_ =
FFmpegUtils::GetCompatiblePixelFormat(native_pixel_fmt);
FFmpegUtils::get_compatible_pixel_format(native_pixel_fmt);
// These are the equivalent pixel formats as bridge pixel formats
int src_alpha_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat(
video_conversion_fmt_, VideoParams::kRGBAChannelCount);
int src_noalpha_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat(
video_conversion_fmt_, VideoParams::kRGBChannelCount);
int src_alpha_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format(
video_conversion_fmt_, VideoParams::k_rgba_channel_count);
int src_noalpha_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format(
video_conversion_fmt_, VideoParams::k_rgb_channel_count);
if (src_alpha_pix_fmt == FB_PIX_FMT_NONE ||
src_noalpha_pix_fmt == FB_PIX_FMT_NONE) {
SetError(
if (src_alpha_pix_fmt == fb_pix_fmt_none ||
src_noalpha_pix_fmt == fb_pix_fmt_none) {
set_error(
tr("Failed to find suitable pixel format for this buffer"));
return false;
}
@@ -160,19 +160,19 @@ bool FFmpegEncoder::Open()
config.video_color_range =
params().video_params().color_range() ==
VideoParams::kColorRangeFull ?
FB_COLOR_RANGE_JPEG :
FB_COLOR_RANGE_MPEG;
VideoParams::k_color_range_full ?
fb_color_range_jpeg :
fb_color_range_mpeg;
switch (params().video_params().interlacing()) {
case VideoParams::kInterlacedTopFirst:
config.video_field_order = FB_FIELD_ORDER_TT;
case VideoParams::k_interlaced_top_first:
config.video_field_order = fb_field_order_tt;
break;
case VideoParams::kInterlacedBottomFirst:
config.video_field_order = FB_FIELD_ORDER_BB;
case VideoParams::k_interlaced_bottom_first:
config.video_field_order = fb_field_order_bb;
break;
default:
config.video_field_order = FB_FIELD_ORDER_PROGRESSIVE;
config.video_field_order = fb_field_order_progressive;
break;
}
@@ -207,11 +207,11 @@ bool FFmpegEncoder::Open()
// Set up audio if it's enabled
if (params().audio_enabled()) {
config.audio_enabled = 1;
config.audio_codec = ExportCodecToBridge(params().audio_codec());
config.audio_codec = export_codec_to_bridge(params().audio_codec());
config.audio_sample_rate = params().audio_params().sample_rate();
config.audio_channel_layout_mask =
params().audio_params().channel_layout();
config.audio_sample_format = FFmpegUtils::GetFFmpegSampleFormat(
config.audio_sample_format = FFmpegUtils::get_f_fmpeg_sample_format(
params().audio_params().format());
config.audio_bit_rate = params().audio_bit_rate();
}
@@ -219,8 +219,8 @@ bool FFmpegEncoder::Open()
// Set up subtitles if they're enabled
if (params().subtitles_enabled()) {
config.subtitles_enabled = 1;
config.subtitle_codec = ExportCodecToBridge(params().subtitles_codec());
subtitle_header = SubtitleParams::GenerateASSHeader().toUtf8();
config.subtitle_codec = export_codec_to_bridge(params().subtitles_codec());
subtitle_header = SubtitleParams::generate_ass_header().toUtf8();
config.subtitle_header =
reinterpret_cast<const uint8_t *>(subtitle_header.constData());
config.subtitle_header_size = subtitle_header.size();
@@ -228,12 +228,12 @@ bool FFmpegEncoder::Open()
encoder_ = fb_encoder_create(&config);
if (!encoder_) {
SetError(tr("Failed to create encoder"));
set_error(tr("Failed to create encoder"));
return false;
}
if (fb_encoder_open(encoder_) != 0) {
SetErrorFromBridge();
set_error_from_bridge();
fb_encoder_free(&encoder_);
return false;
}
@@ -242,29 +242,29 @@ bool FFmpegEncoder::Open()
return true;
}
bool FFmpegEncoder::WriteFrame(FramePtr frame, rational time)
bool FFmpegEncoder::write_frame(FramePtr frame, Rational time)
{
// We may need to convert this frame to a frame that the bridge will understand
if (frame->format() != video_conversion_fmt_) {
frame = frame->convert(video_conversion_fmt_);
}
int src_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat(frame->format(),
int src_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format(frame->format(),
frame->channel_count());
int r = fb_encoder_write_video_frame(
encoder_, frame->width(), frame->height(), src_pix_fmt,
reinterpret_cast<const uint8_t *>(frame->data()),
frame->linesize_bytes(), time.toDouble());
frame->linesize_bytes(), time.to_double());
if (r != 0) {
SetErrorFromBridge();
set_error_from_bridge();
return false;
}
return true;
}
bool FFmpegEncoder::WriteAudio(const SampleBuffer &audio)
bool FFmpegEncoder::write_audio(const SampleBuffer &audio)
{
if (!audio.is_allocated()) {
return true;
@@ -284,50 +284,50 @@ bool FFmpegEncoder::WriteAudio(const SampleBuffer &audio)
int r = fb_encoder_write_audio(
encoder_, channel_data.data(),
audio.audio_params().channel_count(),
FFmpegUtils::GetFFmpegSampleFormat(audio.audio_params().format()),
FFmpegUtils::get_f_fmpeg_sample_format(audio.audio_params().format()),
audio_params.sample_rate(), audio_params.channel_layout(),
int64_t(audio.sample_count()));
if (r != 0) {
SetErrorFromBridge();
set_error_from_bridge();
return false;
}
return true;
}
bool FFmpegEncoder::WriteAudioData(const AudioParams &audio_params,
bool FFmpegEncoder::write_audio_data(const AudioParams &audio_params,
const uint8_t **data,
int input_sample_count)
{
int r = fb_encoder_write_audio(
encoder_, data, audio_params.channel_count(),
FFmpegUtils::GetFFmpegSampleFormat(audio_params.format()),
FFmpegUtils::get_f_fmpeg_sample_format(audio_params.format()),
audio_params.sample_rate(), audio_params.channel_layout(),
input_sample_count);
if (r != 0) {
SetErrorFromBridge();
set_error_from_bridge();
return false;
}
return true;
}
bool FFmpegEncoder::WriteSubtitle(const SubtitleBlock *sub_block)
bool FFmpegEncoder::write_subtitle(const SubtitleBlock *sub_block)
{
QByteArray utf8_sub = sub_block->GetText().toUtf8();
QByteArray utf8_sub = sub_block->get_text().toUtf8();
int r = fb_encoder_write_subtitle(encoder_, utf8_sub.constData(),
sub_block->in().toDouble(),
sub_block->length().toDouble());
sub_block->in().to_double(),
sub_block->length().to_double());
if (r != 0) {
SetErrorFromBridge();
set_error_from_bridge();
return false;
}
return true;
}
void FFmpegEncoder::Close()
void FFmpegEncoder::close()
{
if (encoder_) {
// Flushes encoders, writes the trailer, and frees everything
@@ -337,57 +337,57 @@ void FFmpegEncoder::Close()
open_ = false;
}
void FFmpegEncoder::SetErrorFromBridge()
void FFmpegEncoder::set_error_from_bridge()
{
SetError(QString::fromUtf8(fb_encoder_get_error(encoder_)));
set_error(QString::fromUtf8(fb_encoder_get_error(encoder_)));
}
int FFmpegEncoder::ExportCodecToBridge(ExportCodec::Codec c)
int FFmpegEncoder::export_codec_to_bridge(ExportCodec::Codec c)
{
switch (c) {
case ExportCodec::kCodecH264:
return FB_CODEC_H264;
case ExportCodec::kCodecH264rgb:
return FB_CODEC_H264RGB;
case ExportCodec::kCodecDNxHD:
return FB_CODEC_DNXHD;
case ExportCodec::kCodecProRes:
return FB_CODEC_PRORES;
case ExportCodec::kCodecCineform:
return FB_CODEC_CINEFORM;
case ExportCodec::kCodecH265:
return FB_CODEC_H265;
case ExportCodec::kCodecVP9:
return FB_CODEC_VP9;
case ExportCodec::kCodecAV1:
return FB_CODEC_AV1;
case ExportCodec::kCodecOpenEXR:
return FB_CODEC_OPENEXR;
case ExportCodec::kCodecPNG:
return FB_CODEC_PNG;
case ExportCodec::kCodecTIFF:
return FB_CODEC_TIFF;
case ExportCodec::kCodecMP2:
return FB_CODEC_MP2;
case ExportCodec::kCodecMP3:
return FB_CODEC_MP3;
case ExportCodec::kCodecAAC:
return FB_CODEC_AAC;
case ExportCodec::kCodecPCM:
return FB_CODEC_PCM;
case ExportCodec::kCodecFLAC:
return FB_CODEC_FLAC;
case ExportCodec::kCodecOpus:
return FB_CODEC_OPUS;
case ExportCodec::kCodecVorbis:
return FB_CODEC_VORBIS;
case ExportCodec::kCodecSRT:
return FB_CODEC_SRT;
case ExportCodec::kCodecCount:
case ExportCodec::k_codec_h264:
return fb_codec_h264;
case ExportCodec::k_codec_h264rgb:
return fb_codec_h264_rgb;
case ExportCodec::k_codec_d_nx_hd:
return fb_codec_dnxhd;
case ExportCodec::k_codec_pro_res:
return fb_codec_prores;
case ExportCodec::k_codec_cineform:
return fb_codec_cineform;
case ExportCodec::k_codec_h265:
return fb_codec_h265;
case ExportCodec::k_codec_v_p9:
return fb_codec_v_p9;
case ExportCodec::k_codec_a_v1:
return fb_codec_a_v1;
case ExportCodec::k_codec_open_exr:
return fb_codec_openexr;
case ExportCodec::k_codec_png:
return fb_codec_png;
case ExportCodec::k_codec_tiff:
return fb_codec_tiff;
case ExportCodec::k_codec_m_p2:
return fb_codec_m_p2;
case ExportCodec::k_codec_m_p3:
return fb_codec_m_p3;
case ExportCodec::k_codec_aac:
return fb_codec_aac;
case ExportCodec::k_codec_pcm:
return fb_codec_pcm;
case ExportCodec::k_codec_flac:
return fb_codec_flac;
case ExportCodec::k_codec_opus:
return fb_codec_opus;
case ExportCodec::k_codec_vorbis:
return fb_codec_vorbis;
case ExportCodec::k_codec_srt:
return fb_codec_srt;
case ExportCodec::k_codec_count:
break;
}
return FB_CODEC_NONE;
return fb_codec_none;
}
}
+15 -15
View File
@@ -19,8 +19,8 @@
***/
#ifndef FFMPEGENCODER_H
#define FFMPEGENCODER_H
#ifndef OAK_FFMPEGENCODER_H
#define OAK_FFMPEGENCODER_H
#include <ffmpeg_bridge/ffmpeg_bridge.h>
@@ -42,26 +42,26 @@ public:
FFmpegEncoder(const EncodingParams &params);
virtual QStringList
GetPixelFormatsForCodec(ExportCodec::Codec c) const override;
get_pixel_formats_for_codec(ExportCodec::Codec c) const override;
virtual std::vector<SampleFormat>
GetSampleFormatsForCodec(ExportCodec::Codec c) const override;
get_sample_formats_for_codec(ExportCodec::Codec c) const override;
virtual bool Open() override;
virtual bool open() override;
virtual bool WriteFrame(olive::FramePtr frame,
olive::core::rational time) override;
virtual bool write_frame(olive::FramePtr frame,
olive::core::Rational time) override;
virtual bool WriteAudio(const olive::SampleBuffer &audio) override;
virtual bool write_audio(const olive::SampleBuffer &audio) override;
bool WriteAudioData(const AudioParams &audio_params, const uint8_t **data,
bool write_audio_data(const AudioParams &audio_params, const uint8_t **data,
int input_sample_count);
virtual bool WriteSubtitle(const SubtitleBlock *sub_block) override;
virtual bool write_subtitle(const SubtitleBlock *sub_block) override;
virtual void Close() override;
virtual void close() override;
virtual PixelFormat GetDesiredPixelFormat() const override
virtual PixelFormat get_desired_pixel_format() const override
{
return video_conversion_fmt_;
}
@@ -70,9 +70,9 @@ private:
/**
* @brief Copy the last error message from the bridge into the encoder error state
*/
void SetErrorFromBridge();
void set_error_from_bridge();
static int ExportCodecToBridge(ExportCodec::Codec c);
static int export_codec_to_bridge(ExportCodec::Codec c);
FBEncoder *encoder_;
@@ -83,4 +83,4 @@ private:
}
#endif // FFMPEGENCODER_H
#endif // OAK_FFMPEGENCODER_H
+15 -15
View File
@@ -44,7 +44,7 @@ Frame::~Frame()
destroy();
}
FramePtr Frame::Create()
FramePtr Frame::create()
{
return std::make_shared<Frame>();
}
@@ -60,10 +60,10 @@ void Frame::set_video_params(const VideoParams &params)
linesize_ = generate_linesize_bytes(width(), params_.format(),
params_.channel_count());
linesize_pixels_ = linesize_ / params_.GetBytesPerPixel();
linesize_pixels_ = linesize_ / params_.get_bytes_per_pixel();
}
FramePtr Frame::Interlace(FramePtr top, FramePtr bottom)
FramePtr Frame::interlace(FramePtr top, FramePtr bottom)
{
if (top->video_params() != bottom->video_params()) {
qCritical()
@@ -71,7 +71,7 @@ FramePtr Frame::Interlace(FramePtr top, FramePtr bottom)
return nullptr;
}
FramePtr interlaced = Frame::Create();
FramePtr interlaced = Frame::create();
interlaced->set_video_params(top->video_params());
interlaced->allocate();
@@ -91,7 +91,7 @@ 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) *
return VideoParams::get_bytes_per_pixel(format, channel_count) *
((width + 31) & ~31);
}
@@ -102,7 +102,7 @@ Color Frame::get_pixel(int x, int y) const
}
int byte_offset =
y * linesize_bytes() + x * video_params().GetBytesPerPixel();
y * linesize_bytes() + x * video_params().get_bytes_per_pixel();
return Color(reinterpret_cast<const char *>(data_ + byte_offset),
video_params().format(), video_params().channel_count());
@@ -120,9 +120,9 @@ void Frame::set_pixel(int x, int y, const Color &c)
}
int byte_offset =
y * linesize_bytes() + x * video_params().GetBytesPerPixel();
y * linesize_bytes() + x * video_params().get_bytes_per_pixel();
c.toData(reinterpret_cast<char *>(data_ + byte_offset),
c.to_data(reinterpret_cast<char *>(data_ + byte_offset),
video_params().format(), video_params().channel_count());
}
@@ -140,7 +140,7 @@ bool Frame::allocate()
}
data_size_ = linesize_ * height();
data_ = FrameManager::Allocate(data_size_);
data_ = FrameManager::allocate(data_size_);
return true;
}
@@ -148,7 +148,7 @@ bool Frame::allocate()
void Frame::destroy()
{
if (is_allocated()) {
FrameManager::Deallocate(data_size_, data_);
FrameManager::deallocate(data_size_, data_);
data_size_ = 0;
data_ = nullptr;
@@ -162,7 +162,7 @@ FramePtr Frame::convert(PixelFormat format) const
params.set_format(format);
// Create new frame
FramePtr converted = Frame::Create();
FramePtr converted = Frame::create();
converted->set_video_params(params);
converted->set_timestamp(timestamp_);
converted->allocate();
@@ -170,16 +170,16 @@ FramePtr Frame::convert(PixelFormat format) const
// Do the conversion through OIIO for convenience
OIIO::ImageBuf src(
OIIO::ImageSpec(width(), height(), channel_count(),
OIIOUtils::GetOIIOBaseTypeFromFormat(this->format())));
OIIOUtils::get_oiio_base_type_from_format(this->format())));
OIIOUtils::FrameToBuffer(this, &src);
OIIOUtils::frame_to_buffer(this, &src);
OIIO::ImageBuf dst(OIIO::ImageSpec(
converted->width(), converted->height(), channel_count(),
OIIOUtils::GetOIIOBaseTypeFromFormat(format)));
OIIOUtils::get_oiio_base_type_from_format(format)));
if (dst.copy_pixels(src)) {
OIIOUtils::BufferToFrame(&dst, converted.get());
OIIOUtils::buffer_to_frame(&dst, converted.get());
return converted;
} else {
return nullptr;
+9 -9
View File
@@ -19,8 +19,8 @@
***/
#ifndef FRAME_H
#define FRAME_H
#ifndef OAK_FRAME_H
#define OAK_FRAME_H
#include <memory>
#include <olive/core/core.h>
@@ -46,12 +46,12 @@ public:
DISABLE_COPY_MOVE(Frame)
static FramePtr Create();
static FramePtr create();
const VideoParams &video_params() const;
void set_video_params(const VideoParams &params);
static FramePtr Interlace(FramePtr top, FramePtr bottom);
static FramePtr interlace(FramePtr top, FramePtr bottom);
static int generate_linesize_bytes(int width, PixelFormat format,
int channel_count);
@@ -93,14 +93,14 @@ public:
/**
* @brief Get frame's timestamp.
*
* This timestamp is always a rational that will equate to the time in seconds.
* This timestamp is always a Rational that will equate to the time in seconds.
*/
const rational &timestamp() const
const Rational &timestamp() const
{
return timestamp_;
}
void set_timestamp(const rational &timestamp)
void set_timestamp(const Rational &timestamp)
{
timestamp_ = timestamp;
}
@@ -161,7 +161,7 @@ private:
char *data_;
int data_size_;
rational timestamp_;
Rational timestamp_;
int linesize_;
@@ -172,4 +172,4 @@ private:
Q_DECLARE_METATYPE(olive::FramePtr)
#endif // FRAME_H
#endif // OAK_FRAME_H
+32 -32
View File
@@ -32,7 +32,7 @@
namespace olive
{
QStringList OIIODecoder::supported_formats_;
QStringList OIIODecoder::supported_formats;
OIIODecoder::OIIODecoder()
: image_(nullptr)
@@ -44,7 +44,7 @@ QString OIIODecoder::id() const
return QStringLiteral("oiio");
}
FootageDescription OIIODecoder::Probe(const QString &filename,
FootageDescription OIIODecoder::probe(const QString &filename,
CancelAtom *cancelled) const
{
Q_UNUSED(cancelled)
@@ -53,7 +53,7 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
// Filter out any file extensions that aren't expected to work - sometimes OIIO will crash trying
// to open a file that it can't if it's given one
if (!FileTypeIsSupported(filename)) {
if (!file_type_is_supported(filename)) {
return desc;
}
@@ -77,7 +77,7 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
for (i = 0; in->seek_subimage(i, 0); i++) {
OIIO::ImageSpec spec = in->spec();
VideoParams video_params = GetVideoParamsFromImageSpec(spec);
VideoParams video_params = get_video_params_from_image_spec(spec);
video_params.set_stream_index(i);
@@ -104,10 +104,10 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
// likely reduces the fidelity?
video_params.set_premultiplied_alpha(true);
desc.AddVideoStream(video_params);
desc.add_video_stream(video_params);
}
desc.SetStreamCount(i);
desc.set_stream_count(i);
// If we're here, we have a successful image open
in->close();
@@ -115,26 +115,26 @@ FootageDescription OIIODecoder::Probe(const QString &filename,
return desc;
}
bool OIIODecoder::OpenInternal()
bool OIIODecoder::open_internal()
{
// If we can open the filename provided, assume everything is working
return OpenImageHandler(stream().filename(), stream().stream());
return open_image_handler(stream().filename(), stream().stream());
}
TexturePtr OIIODecoder::RetrieveVideoInternal(const RetrieveVideoParams &p)
TexturePtr OIIODecoder::retrieve_video_internal(const RetrieveVideoParams &p)
{
FramePtr frame = RetrieveVideoFrameInternal(p);
FramePtr frame = retrieve_video_frame_internal(p);
if (!frame) {
return nullptr;
}
return p.renderer->CreateTexture(frame->video_params(), frame->data(),
return p.renderer->create_texture(frame->video_params(), frame->data(),
frame->linesize_pixels());
}
FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p)
FramePtr OIIODecoder::retrieve_video_frame_internal(const RetrieveVideoParams &p)
{
VideoParams vp = GetVideoParamsFromImageSpec(image_->spec());
VideoParams vp = get_video_params_from_image_spec(image_->spec());
vp.set_divider(p.divider);
if (!buffer_.is_allocated() || last_params_.divider != p.divider) {
@@ -154,7 +154,7 @@ FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p)
buf.scanline_stride(), buf.z_stride());
// Roughly downsample image for divider (for some reason OIIO::ImageBufAlgo::resample failed here)
int px_sz = vp.GetBytesPerPixel();
int px_sz = vp.get_bytes_per_pixel();
for (int dst_y = 0; dst_y < buffer_.height(); dst_y++) {
int src_y = dst_y * buf.spec().height / buffer_.height();
@@ -171,15 +171,15 @@ FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p)
}
// Force F32 output for all still images
if (vp.format() != PixelFormat::F32) {
FramePtr f32_frame = buffer_.convert(PixelFormat::F32);
if (vp.format() != PixelFormat::f32) {
FramePtr f32_frame = buffer_.convert(PixelFormat::f32);
if (f32_frame) {
f32_frame->set_timestamp(p.time);
return f32_frame;
}
}
FramePtr frame = Frame::Create();
FramePtr frame = Frame::create();
frame->set_video_params(buffer_.video_params());
frame->set_timestamp(p.time);
if (!frame->allocate()) {
@@ -190,19 +190,19 @@ FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p)
return frame;
}
void OIIODecoder::CloseInternal()
void OIIODecoder::close_internal()
{
CloseImageHandle();
close_image_handle();
}
bool OIIODecoder::FileTypeIsSupported(const QString &fn)
bool OIIODecoder::file_type_is_supported(const QString &fn)
{
// We prioritize OIIO over FFmpeg to pick up still images more effectively, but some OIIO decoders (notably OpenJPEG)
// will segfault entirely if given unexpected data (an MPEG-4 for instance). To workaround this issue, we use OIIO's
// "extension_list" attribute and match it with the extension of the file.
// Check if we've created the supported formats list, create it if not
if (supported_formats_.isEmpty()) {
if (supported_formats.isEmpty()) {
QStringList extension_list =
QString::fromStdString(OIIO::get_string_attribute("extension_list"))
.split(';');
@@ -211,11 +211,11 @@ bool OIIODecoder::FileTypeIsSupported(const QString &fn)
foreach (const QString &ext, extension_list) {
QStringList format_and_ext = ext.split(':');
supported_formats_.append(format_and_ext.at(1).split(','));
supported_formats.append(format_and_ext.at(1).split(','));
}
}
if (!supported_formats_.contains(QFileInfo(fn).suffix(),
if (!supported_formats.contains(QFileInfo(fn).suffix(),
Qt::CaseInsensitive)) {
return false;
}
@@ -223,7 +223,7 @@ bool OIIODecoder::FileTypeIsSupported(const QString &fn)
return true;
}
bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage)
bool OIIODecoder::open_image_handler(const QString &fn, int subimage)
{
image_ = OIIO::ImageInput::open(fn.toStdString());
@@ -239,16 +239,16 @@ bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage)
const OIIO::ImageSpec &spec = image_->spec();
// We use RGBA frames because that tends to be the native format of GPUs
pix_fmt_ = OIIOUtils::GetFormatFromOIIOBasetype(
pix_fmt_ = OIIOUtils::get_format_from_oiio_basetype(
static_cast<OIIO::TypeDesc::BASETYPE>(spec.format.basetype));
if (pix_fmt_ == PixelFormat::INVALID) {
if (pix_fmt_ == PixelFormat::invalid) {
qWarning()
<< "Failed to convert OIIO::ImageDesc to native pixel format";
return false;
}
oiio_pix_fmt_ = OIIOUtils::GetOIIOBaseTypeFromFormat(pix_fmt_);
oiio_pix_fmt_ = OIIOUtils::get_oiio_base_type_from_format(pix_fmt_);
if (oiio_pix_fmt_ == OIIO::TypeDesc::UNKNOWN) {
qCritical()
@@ -259,7 +259,7 @@ bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage)
return true;
}
void OIIODecoder::CloseImageHandle()
void OIIODecoder::close_image_handle()
{
if (image_) {
image_->close();
@@ -270,18 +270,18 @@ void OIIODecoder::CloseImageHandle()
}
VideoParams
OIIODecoder::GetVideoParamsFromImageSpec(const OIIO::ImageSpec &spec)
OIIODecoder::get_video_params_from_image_spec(const OIIO::ImageSpec &spec)
{
VideoParams video_params;
video_params.set_width(spec.width);
video_params.set_height(spec.height);
video_params.set_format(OIIOUtils::GetFormatFromOIIOBasetype(
video_params.set_format(OIIOUtils::get_format_from_oiio_basetype(
static_cast<OIIO::TypeDesc::BASETYPE>(spec.format.basetype)));
video_params.set_channel_count(spec.nchannels);
video_params.set_pixel_aspect_ratio(
OIIOUtils::GetPixelAspectRatioFromOIIO(spec));
video_params.set_video_type(VideoParams::kVideoTypeStill);
OIIOUtils::get_pixel_aspect_ratio_from_oiio(spec));
video_params.set_video_type(VideoParams::k_video_type_still);
return video_params;
}
+14 -14
View File
@@ -19,8 +19,8 @@
***/
#ifndef OIIODECODER_H
#define OIIODECODER_H
#ifndef OAK_OIIODECODER_H
#define OAK_OIIODECODER_H
#include <OpenImageIO/imageio.h>
#include <OpenImageIO/imagebuf.h>
@@ -39,32 +39,32 @@ public:
virtual QString id() const override;
virtual bool SupportsVideo() override
virtual bool supports_video() override
{
return true;
}
virtual FootageDescription Probe(const QString &filename,
virtual FootageDescription probe(const QString &filename,
CancelAtom *cancelled) const override;
protected:
virtual bool OpenInternal() override;
virtual bool open_internal() override;
virtual TexturePtr
RetrieveVideoInternal(const RetrieveVideoParams &p) override;
retrieve_video_internal(const RetrieveVideoParams &p) override;
virtual FramePtr
RetrieveVideoFrameInternal(const RetrieveVideoParams &p) override;
virtual void CloseInternal() override;
retrieve_video_frame_internal(const RetrieveVideoParams &p) override;
virtual void close_internal() override;
private:
std::unique_ptr<OIIO::ImageInput> image_;
static bool FileTypeIsSupported(const QString &fn);
static bool file_type_is_supported(const QString &fn);
bool OpenImageHandler(const QString &fn, int subimage);
bool open_image_handler(const QString &fn, int subimage);
void CloseImageHandle();
void close_image_handle();
static VideoParams GetVideoParamsFromImageSpec(const OIIO::ImageSpec &spec);
static VideoParams get_video_params_from_image_spec(const OIIO::ImageSpec &spec);
PixelFormat pix_fmt_;
OIIO::TypeDesc::BASETYPE oiio_pix_fmt_;
@@ -72,9 +72,9 @@ private:
Frame buffer_;
RetrieveVideoParams last_params_;
static QStringList supported_formats_;
static QStringList supported_formats;
};
}
#endif // OIIODECODER_H
#endif // OAK_OIIODECODER_H
+7 -7
View File
@@ -31,21 +31,21 @@ OIIOEncoder::OIIOEncoder(const EncodingParams &params)
{
}
bool OIIOEncoder::Open()
bool OIIOEncoder::open()
{
return true;
}
bool OIIOEncoder::WriteFrame(FramePtr frame, rational time)
bool OIIOEncoder::write_frame(FramePtr frame, Rational time)
{
std::string filename = GetFilenameForFrame(time).toStdString();
std::string filename = get_filename_for_frame(time).toStdString();
auto output = OIIO::ImageOutput::create(filename);
if (!output) {
return false;
}
OIIO::TypeDesc type = OIIOUtils::GetOIIOBaseTypeFromFormat(frame->format());
OIIO::TypeDesc type = OIIOUtils::get_oiio_base_type_from_format(frame->format());
OIIO::ImageSpec spec(frame->width(), frame->height(),
frame->channel_count(), type);
@@ -65,18 +65,18 @@ bool OIIOEncoder::WriteFrame(FramePtr frame, rational time)
return true;
}
bool OIIOEncoder::WriteAudio(const SampleBuffer &audio)
bool OIIOEncoder::write_audio(const SampleBuffer &audio)
{
// Do nothing
return false;
}
bool OIIOEncoder::WriteSubtitle(const SubtitleBlock *sub_block)
bool OIIOEncoder::write_subtitle(const SubtitleBlock *sub_block)
{
return false;
}
void OIIOEncoder::Close()
void OIIOEncoder::close()
{
// Do nothing
}
+9 -9
View File
@@ -19,8 +19,8 @@
***/
#ifndef OIIOENCODER_H
#define OIIOENCODER_H
#ifndef OAK_OIIOENCODER_H
#define OAK_OIIOENCODER_H
#include "codec/encoder.h"
@@ -33,16 +33,16 @@ public:
OIIOEncoder(const EncodingParams &params);
public slots:
virtual bool Open() override;
virtual bool open() 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;
virtual bool write_frame(olive::FramePtr frame,
olive::core::Rational time) override;
virtual bool write_audio(const SampleBuffer &audio) override;
virtual bool write_subtitle(const SubtitleBlock *sub_block) override;
virtual void Close() override;
virtual void close() override;
};
}
#endif // OIIOENCODER_H
#endif // OAK_OIIOENCODER_H
+3 -3
View File
@@ -19,8 +19,8 @@
***/
#ifndef PLANARFILEDEVICE_H
#define PLANARFILEDEVICE_H
#ifndef OAK_PLANARFILEDEVICE_H
#define OAK_PLANARFILEDEVICE_H
#include <olive/core/core.h>
#include <QFile>
@@ -62,4 +62,4 @@ private:
}
#endif // PLANARFILEDEVICE_H
#endif // OAK_PLANARFILEDEVICE_H
+48 -48
View File
@@ -34,7 +34,7 @@ namespace olive
ProxyManager *ProxyManager::instance_ = nullptr;
bool ProxyParamsEqual(const ProxyManager::ProxyParams &a,
bool proxy_params_equal(const ProxyManager::ProxyParams &a,
const ProxyManager::ProxyParams &b)
{
return a.width == b.width && a.height == b.height &&
@@ -43,22 +43,22 @@ bool ProxyParamsEqual(const ProxyManager::ProxyParams &a,
a.include_audio == b.include_audio;
}
QString ProxyManager::GetProxyDirectory(const QString &cache_path)
QString ProxyManager::get_proxy_directory(const QString &cache_path)
{
return QDir(cache_path).filePath(QStringLiteral("proxy"));
}
QString ProxyManager::GetProxyFilename(const QString &cache_path,
QString ProxyManager::get_proxy_filename(const QString &cache_path,
const QString &source_filename,
int stream_index,
const ProxyParams &params)
{
const QString proxy_dir = GetProxyDirectory(cache_path);
const QString proxy_dir = get_proxy_directory(cache_path);
const QString extension =
params.extension.isEmpty() ? QStringLiteral("mp4") : params.extension;
const QString filename =
QStringLiteral("%1-%2.%3x%4.v%5.a%6.%7")
.arg(FileFunctions::GetUniqueFileIdentifier(source_filename),
.arg(FileFunctions::get_unique_file_identifier(source_filename),
QString::number(stream_index), QString::number(params.width),
QString::number(params.height), QString::number(params.version),
params.include_audio ? QStringLiteral("1") : QStringLiteral("0"),
@@ -67,7 +67,7 @@ QString ProxyManager::GetProxyFilename(const QString &cache_path,
return QDir(proxy_dir).filePath(filename);
}
QString ProxyManager::GetWorkingProxyFilename(const QString &proxy_filename)
QString ProxyManager::get_working_proxy_filename(const QString &proxy_filename)
{
// Append a recognizable suffix while keeping a standard container extension
// so ffmpeg can infer the output format.
@@ -75,29 +75,29 @@ QString ProxyManager::GetWorkingProxyFilename(const QString &proxy_filename)
}
ProxyManager::ProxyState
ProxyManager::GetProxyState(const QString &proxy_filename)
ProxyManager::get_proxy_state(const QString &proxy_filename)
{
if (QFileInfo::exists(proxy_filename)) {
return kProxyReady;
return k_proxy_ready;
}
if (QFileInfo::exists(GetWorkingProxyFilename(proxy_filename))) {
return kProxyGenerating;
if (QFileInfo::exists(get_working_proxy_filename(proxy_filename))) {
return k_proxy_generating;
}
return kProxyMissing;
return k_proxy_missing;
}
QString ProxyManager::ProxyStateToString(ProxyState state)
QString ProxyManager::proxy_state_to_string(ProxyState state)
{
switch (state) {
case kProxyMissing:
case k_proxy_missing:
return QStringLiteral("missing");
case kProxyGenerating:
case k_proxy_generating:
return QStringLiteral("generating");
case kProxyReady:
case k_proxy_ready:
return QStringLiteral("ready");
case kProxyFailed:
case k_proxy_failed:
return QStringLiteral("failed");
}
@@ -105,41 +105,41 @@ QString ProxyManager::ProxyStateToString(ProxyState state)
}
ProxyManager::ProxyState
ProxyManager::ProxyStateFromString(const QString &state)
ProxyManager::proxy_state_from_string(const QString &state)
{
if (state == QStringLiteral("generating")) {
return kProxyGenerating;
return k_proxy_generating;
}
if (state == QStringLiteral("ready")) {
return kProxyReady;
return k_proxy_ready;
}
if (state == QStringLiteral("failed")) {
return kProxyFailed;
return k_proxy_failed;
}
return kProxyMissing;
return k_proxy_missing;
}
bool ProxyManager::ProxyFilenameHasAudio(const QString &proxy_filename)
bool ProxyManager::proxy_filename_has_audio(const QString &proxy_filename)
{
return QFileInfo(proxy_filename).fileName().contains(
QStringLiteral(".a1."));
}
ProxyManager::ProxyParams ProxyManager::ProxyParamsFromConfig()
ProxyManager::ProxyParams ProxyManager::proxy_params_from_config()
{
ProxyParams params;
params.width = OLIVE_CONFIG("ProxyWidth").value<int>();
params.height = OLIVE_CONFIG("ProxyHeight").value<int>();
params.crf = OLIVE_CONFIG("ProxyCRF").value<int>();
params.preset = OLIVE_CONFIG("ProxyPreset").toString();
params.include_audio = OLIVE_CONFIG("ProxyIncludeAudio").toBool();
params.width = OAK_CONFIG("ProxyWidth").value<int>();
params.height = OAK_CONFIG("ProxyHeight").value<int>();
params.crf = OAK_CONFIG("ProxyCRF").value<int>();
params.preset = OAK_CONFIG("ProxyPreset").toString();
params.include_audio = OAK_CONFIG("ProxyIncludeAudio").toBool();
return params;
}
QString ProxyManager::FindFFmpegExecutable(const QString &configured_path)
QString ProxyManager::find_f_fmpeg_executable(const QString &configured_path)
{
// An explicitly configured path takes precedence if it is usable
if (!configured_path.isEmpty()) {
@@ -187,46 +187,46 @@ QString ProxyManager::FindFFmpegExecutable(const QString &configured_path)
}
ProxyManager::Proxy
ProxyManager::GetOrStartProxy(const QString &cache_path,
ProxyManager::get_or_start_proxy(const QString &cache_path,
const QString &source_filename, int stream_index,
const ProxyParams &params)
{
QMutexLocker locker(&mutex_);
const QString filename =
GetProxyFilename(cache_path, source_filename, stream_index, params);
const ProxyState file_state = GetProxyState(filename);
if (file_state == kProxyReady) {
return { kProxyReady, filename, nullptr };
get_proxy_filename(cache_path, source_filename, stream_index, params);
const ProxyState file_state = get_proxy_state(filename);
if (file_state == k_proxy_ready) {
return { k_proxy_ready, filename, nullptr };
}
for (const ProxyData &data : proxying_) {
if (data.source_filename == source_filename &&
data.stream_index == stream_index &&
ProxyParamsEqual(data.params, params)) {
return { kProxyGenerating, filename, data.task };
proxy_params_equal(data.params, params)) {
return { k_proxy_generating, filename, data.task };
}
}
if (file_state == kProxyGenerating) {
QFile::remove(GetWorkingProxyFilename(filename));
if (file_state == k_proxy_generating) {
QFile::remove(get_working_proxy_filename(filename));
}
const QString working_filename = GetWorkingProxyFilename(filename);
const QString working_filename = get_working_proxy_filename(filename);
ProxyTask *task =
new ProxyTask(source_filename, stream_index, params, working_filename);
connect(task, &Task::Finished, this, &ProxyManager::ProxyTaskFinished);
connect(task, &Task::finished, this, &ProxyManager::proxy_task_finished);
task->moveToThread(TaskManager::instance()->thread());
QMetaObject::invokeMethod(TaskManager::instance(), "AddTask",
QMetaObject::invokeMethod(TaskManager::instance(), "add_task",
Qt::QueuedConnection, Q_ARG(Task *, task));
proxying_.append({ source_filename, stream_index, params, task,
working_filename, filename });
return { kProxyGenerating, filename, task };
return { k_proxy_generating, filename, task };
}
void ProxyManager::ProxyTaskFinished(Task *task, bool succeeded)
void ProxyManager::proxy_task_finished(Task *task, bool succeeded)
{
QMutexLocker locker(&mutex_);
@@ -250,18 +250,18 @@ void ProxyManager::ProxyTaskFinished(Task *task, bool succeeded)
QFile::remove(data.finished_filename);
if (QFile::rename(data.working_filename, data.finished_filename)) {
locker.unlock();
emit ProxyReady(data.source_filename, data.stream_index,
emit proxy_ready(data.source_filename, data.stream_index,
data.finished_filename);
emit ProxyFinished(data.source_filename, data.stream_index,
data.finished_filename, kProxyReady);
emit proxy_finished(data.source_filename, data.stream_index,
data.finished_filename, k_proxy_ready);
return;
}
}
QFile::remove(data.working_filename);
locker.unlock();
emit ProxyFinished(data.source_filename, data.stream_index,
data.finished_filename, kProxyFailed);
emit proxy_finished(data.source_filename, data.stream_index,
data.finished_filename, k_proxy_failed);
}
}
+23 -23
View File
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROXYMANAGER_H
#define PROXYMANAGER_H
#ifndef OAK_PROXYMANAGER_H
#define OAK_PROXYMANAGER_H
#include <QMutex>
#include <QObject>
@@ -34,14 +34,14 @@ class ProxyTask;
class ProxyManager : public QObject {
Q_OBJECT
public:
static void CreateInstance()
static void create_instance()
{
if (!instance_) {
instance_ = new ProxyManager();
}
}
static void DestroyInstance()
static void destroy_instance()
{
delete instance_;
instance_ = nullptr;
@@ -53,10 +53,10 @@ public:
}
enum ProxyState {
kProxyMissing,
kProxyGenerating,
kProxyReady,
kProxyFailed
k_proxy_missing,
k_proxy_generating,
k_proxy_ready,
k_proxy_failed
};
struct ProxyParams {
@@ -70,36 +70,36 @@ public:
};
struct Proxy {
ProxyState state = kProxyMissing;
ProxyState state = k_proxy_missing;
QString filename;
ProxyTask *task = nullptr;
};
static QString GetProxyDirectory(const QString &cache_path);
static QString get_proxy_directory(const QString &cache_path);
static QString GetProxyFilename(const QString &cache_path,
static QString get_proxy_filename(const QString &cache_path,
const QString &source_filename,
int stream_index,
const ProxyParams &params);
static QString GetWorkingProxyFilename(const QString &proxy_filename);
static QString get_working_proxy_filename(const QString &proxy_filename);
static ProxyState GetProxyState(const QString &proxy_filename);
static ProxyState get_proxy_state(const QString &proxy_filename);
static QString ProxyStateToString(ProxyState state);
static QString proxy_state_to_string(ProxyState state);
static ProxyState ProxyStateFromString(const QString &state);
static ProxyState proxy_state_from_string(const QString &state);
/**
* @brief Returns true if a proxy filename generated by GetProxyFilename()
* indicates the proxy contains audio streams
*/
static bool ProxyFilenameHasAudio(const QString &proxy_filename);
static bool proxy_filename_has_audio(const QString &proxy_filename);
/**
* @brief Builds proxy parameters from the global application config
*/
static ProxyParams ProxyParamsFromConfig();
static ProxyParams proxy_params_from_config();
/**
* @brief Locates an ffmpeg executable for proxy generation
@@ -109,16 +109,16 @@ public:
* platform-specific install locations. Returns an empty string if no
* executable could be found.
*/
static QString FindFFmpegExecutable(const QString &configured_path);
static QString find_f_fmpeg_executable(const QString &configured_path);
Proxy GetOrStartProxy(const QString &cache_path,
Proxy get_or_start_proxy(const QString &cache_path,
const QString &source_filename, int stream_index,
const ProxyParams &params);
signals:
void ProxyReady(const QString &source_filename, int stream_index,
void proxy_ready(const QString &source_filename, int stream_index,
const QString &proxy_filename);
void ProxyFinished(const QString &source_filename, int stream_index,
void proxy_finished(const QString &source_filename, int stream_index,
const QString &proxy_filename, ProxyState state);
private:
@@ -139,9 +139,9 @@ private:
QVector<ProxyData> proxying_;
private slots:
void ProxyTaskFinished(Task *task, bool succeeded);
void proxy_task_finished(Task *task, bool succeeded);
};
}
#endif // PROXYMANAGER_H
#endif // OAK_PROXYMANAGER_H
+7 -7
View File
@@ -29,8 +29,8 @@ namespace olive
{
TimecodeMetadata::SourceTime
TimecodeMetadata::FromTimecodeString(const QString &timecode,
const core::rational &timebase)
TimecodeMetadata::from_timecode_string(const QString &timecode,
const core::Rational &timebase)
{
SourceTime result;
const QString trimmed = timecode.trimmed();
@@ -40,8 +40,8 @@ TimecodeMetadata::FromTimecodeString(const QString &timecode,
bool ok = false;
const core::Timecode::Display display =
trimmed.contains(';') ? core::Timecode::kTimecodeDropFrame :
core::Timecode::kTimecodeNonDropFrame;
trimmed.contains(';') ? core::Timecode::k_timecode_drop_frame :
core::Timecode::k_timecode_non_drop_frame;
result.time = core::Timecode::timecode_to_time(trimmed.toStdString(),
timebase, display, &ok);
result.valid = ok;
@@ -52,7 +52,7 @@ TimecodeMetadata::FromTimecodeString(const QString &timecode,
}
TimecodeMetadata::SourceTime
TimecodeMetadata::FromBwfTimeReference(const QString &time_reference,
TimecodeMetadata::from_bwf_time_reference(const QString &time_reference,
int sample_rate)
{
SourceTime result;
@@ -75,10 +75,10 @@ TimecodeMetadata::FromBwfTimeReference(const QString &time_reference,
const qulonglong rational_limit =
static_cast<qulonglong>(std::numeric_limits<int>::max());
if (numerator <= rational_limit && denominator <= rational_limit) {
result.time = core::rational(static_cast<int>(numerator),
result.time = core::Rational(static_cast<int>(numerator),
static_cast<int>(denominator));
} else {
result.time = core::rational::fromDouble(
result.time = core::Rational::from_double(
static_cast<double>(samples) / static_cast<double>(sample_rate));
}
result.source = QStringLiteral("bwf_time_reference");
+7 -7
View File
@@ -18,8 +18,8 @@
***/
#ifndef TIMECODEMETADATA_H
#define TIMECODEMETADATA_H
#ifndef OAK_TIMECODEMETADATA_H
#define OAK_TIMECODEMETADATA_H
#include <QString>
@@ -31,18 +31,18 @@ namespace olive
class TimecodeMetadata {
public:
struct SourceTime {
core::rational time;
core::Rational time;
QString source;
bool valid = false;
};
static SourceTime FromTimecodeString(const QString &timecode,
const core::rational &timebase);
static SourceTime from_timecode_string(const QString &timecode,
const core::Rational &timebase);
static SourceTime FromBwfTimeReference(const QString &time_reference,
static SourceTime from_bwf_time_reference(const QString &time_reference,
int sample_rate);
};
}
#endif // TIMECODEMETADATA_H
#endif // OAK_TIMECODEMETADATA_H