change: change code style to Linux style except indent.

This commit is contained in:
Mike Solar
2025-08-03 03:09:40 +08:00
parent 65ab76edc8
commit 74f73ab3be
789 changed files with 77113 additions and 68888 deletions
+143 -126
View File
@@ -36,12 +36,17 @@ extern "C" {
#include "render/cancelatom.h"
#include "render/rendermodes.h"
namespace olive {
namespace olive
{
class Decoder;
using DecoderPtr = std::shared_ptr<Decoder>;
#define DECODER_DEFAULT_DESTRUCTOR(x) virtual ~x() override {CloseInternal();}
#define DECODER_DEFAULT_DESTRUCTOR(x) \
virtual ~x() override \
{ \
CloseInternal(); \
}
/**
* @brief A decoder's is the main class for bringing external media into Olive
@@ -59,89 +64,88 @@ using DecoderPtr = std::shared_ptr<Decoder>;
* A decoder does NOT perform any pixel/sample format conversion. Frames should pass through the PixelService
* to be utilized in the rest of the rendering pipeline.
*/
class Decoder : public QObject
{
Q_OBJECT
class Decoder : public QObject {
Q_OBJECT
public:
enum RetrieveState {
kReady,
kFailedToOpen,
kIndexUnavailable
};
enum RetrieveState { kReady, kFailedToOpen, kIndexUnavailable };
Decoder();
Decoder();
/**
/**
* @brief Unique decoder ID
*/
virtual QString id() const = 0;
virtual QString id() const = 0;
virtual bool SupportsVideo(){return false;}
virtual bool SupportsAudio(){return false;}
virtual bool SupportsVideo()
{
return false;
}
virtual bool SupportsAudio()
{
return false;
}
void IncrementAccessTime(qint64 t);
void IncrementAccessTime(qint64 t);
class CodecStream
{
public:
CodecStream() :
stream_(-1),
block_(nullptr)
{
}
class CodecStream {
public:
CodecStream()
: stream_(-1)
, block_(nullptr)
{
}
CodecStream(const QString& filename, int stream, Block *block) :
filename_(filename),
stream_(stream),
block_(block)
{
}
CodecStream(const QString &filename, int stream, Block *block)
: filename_(filename)
, stream_(stream)
, block_(block)
{
}
bool IsValid() const
{
return !filename_.isEmpty() && stream_ >= 0;
}
bool IsValid() const
{
return !filename_.isEmpty() && stream_ >= 0;
}
bool Exists() const
{
return QFileInfo::exists(filename_);
}
bool Exists() const
{
return QFileInfo::exists(filename_);
}
void Reset()
{
*this = CodecStream();
}
void Reset()
{
*this = CodecStream();
}
bool operator==(const CodecStream& rhs) const
{
return filename_ == rhs.filename_ && stream_ == rhs.stream_;
}
bool operator==(const CodecStream &rhs) const
{
return filename_ == rhs.filename_ && stream_ == rhs.stream_;
}
const QString& filename() const
{
return filename_;
}
const QString &filename() const
{
return filename_;
}
int stream() const
{
return stream_;
}
int stream() const
{
return stream_;
}
Block *block() const
{
return block_;
}
Block *block() const
{
return block_;
}
private:
QString filename_;
private:
QString filename_;
int stream_;
int stream_;
Block *block_;
Block *block_;
};
};
/**
/**
* @brief Open stream for decoding
*
* This function is thread safe.
@@ -150,22 +154,21 @@ 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 kAnyTimecode;
struct RetrieveVideoParams
{
Renderer *renderer = nullptr;
rational time;
int divider = 1;
PixelFormat maximum_format = PixelFormat::INVALID;
CancelAtom *cancelled = nullptr;
VideoParams::ColorRange force_range = VideoParams::kColorRangeDefault;
VideoParams::Interlacing src_interlacing = VideoParams::kInterlaceNone;
};
struct RetrieveVideoParams {
Renderer *renderer = nullptr;
rational time;
int divider = 1;
PixelFormat maximum_format = PixelFormat::INVALID;
CancelAtom *cancelled = nullptr;
VideoParams::ColorRange force_range = VideoParams::kColorRangeDefault;
VideoParams::Interlacing src_interlacing = VideoParams::kInterlaceNone;
};
/**
/**
* @brief Retrieves a video frame from footage
*
* This function will always return a valid frame unless a fatal error occurs (in such case,
@@ -175,16 +178,16 @@ public:
*
* This function is thread safe and can only run while the decoder is open. \see Open()
*/
TexturePtr RetrieveVideo(const RetrieveVideoParams& p);
TexturePtr RetrieveVideo(const RetrieveVideoParams &p);
enum RetrieveAudioStatus {
kInvalid = -1,
kOK,
kWaitingForConform,
kUnknownError
};
enum RetrieveAudioStatus {
kInvalid = -1,
kOK,
kWaitingForConform,
kUnknownError
};
/**
/**
* @brief Retrieve audio data from footage
*
* This function will always return a sample buffer unless a fatal error occurs (in such case,
@@ -192,14 +195,17 @@ public:
*
* This function is thread safe and can only run while the decoder is open. \see Open()
*/
RetrieveAudioStatus RetrieveAudio(SampleBuffer &dest, const TimeRange& range, const AudioParams& params, const QString &cache_path, LoopMode loop_mode, RenderMode::Mode mode);
RetrieveAudioStatus
RetrieveAudio(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 GetLastAccessedTime();
/**
/**
* @brief Generate a Footage object from a file
*
* If this decoder is able to parse this file, it will return a valid FootagePtr. Otherwise, it
@@ -210,39 +216,43 @@ public:
*
* This function is re-entrant.
*/
virtual FootageDescription Probe(const QString& filename, CancelAtom *cancelled) const = 0;
virtual FootageDescription Probe(const QString &filename,
CancelAtom *cancelled) const = 0;
/**
/**
* @brief Closes media/deallocates memory
*
* 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, const AudioParams &params, CancelAtom *cancelled = nullptr);
bool ConformAudio(const QVector<QString> &output_filenames,
const AudioParams &params,
CancelAtom *cancelled = nullptr);
/**
/**
* @brief Create a Decoder instance using a Decoder ID
*
* @return
*
* A Decoder instance or nullptr if a Decoder with this ID does not exist
*/
static DecoderPtr CreateFromID(const QString& id);
static DecoderPtr CreateFromID(const QString &id);
static QString TransformImageSequenceFileName(const QString& filename, const int64_t& number);
static QString TransformImageSequenceFileName(const QString &filename,
const int64_t &number);
static int GetImageSequenceDigitCount(const QString& filename);
static int GetImageSequenceDigitCount(const QString &filename);
static int64_t GetImageSequenceIndex(const QString& filename);
static int64_t GetImageSequenceIndex(const QString &filename);
static QVector<DecoderPtr> ReceiveListOfAllDecoders();
static QVector<DecoderPtr> ReceiveListOfAllDecoders();
protected:
/**
/**
* @brief Internal open function
*
* Sub-classes must override this function. Function will already be mutexed, so there is no need
@@ -254,62 +264,69 @@ protected:
* return FALSE. If this function returns false, Decoder will call CloseInternal to clean any
* memory allocated during OpenInternal.
*/
virtual bool OpenInternal() = 0;
virtual bool OpenInternal() = 0;
/**
/**
* @brief Internal close function
*
* 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 CloseInternal() = 0;
/**
/**
* @brief Internal frame retrieval function
*
* 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 RetrieveVideoInternal(const RetrieveVideoParams &p);
virtual bool ConformAudioInternal(const QVector<QString>& filenames, const AudioParams &params, CancelAtom *cancelled);
virtual bool ConformAudioInternal(const QVector<QString> &filenames,
const AudioParams &params,
CancelAtom *cancelled);
void SignalProcessingProgress(int64_t ts, int64_t duration);
void SignalProcessingProgress(int64_t ts, int64_t duration);
/**
/**
* @brief Return currently open stream
*
* This function is NOT thread safe and should therefore only be called by thread safe functions.
*/
const CodecStream& stream() const
{
return stream_;
}
const CodecStream &stream() const
{
return stream_;
}
virtual rational GetAudioStartOffset() const { return 0; }
virtual rational GetAudioStartOffset() const
{
return 0;
}
signals:
/**
/**
* @brief While indexing, this signal will provide progress as a percentage (0-100 inclusive) if
* available
*/
void IndexProgress(double);
void IndexProgress(double);
private:
void UpdateLastAccessed();
void UpdateLastAccessed();
bool RetrieveAudioFromConform(SampleBuffer &sample_buffer, const QVector<QString> &conform_filenames, TimeRange range, LoopMode loop_mode, const AudioParams &params);
bool RetrieveAudioFromConform(SampleBuffer &sample_buffer,
const QVector<QString> &conform_filenames,
TimeRange range, LoopMode loop_mode,
const AudioParams &params);
CodecStream stream_;
CodecStream stream_;
QMutex mutex_;
QMutex mutex_;
std::atomic_int64_t last_accessed_;
TexturePtr cached_texture_;
rational cached_time_;
int cached_divider_;
std::atomic_int64_t last_accessed_;
TexturePtr cached_texture_;
rational cached_time_;
int cached_divider_;
};
uint qHash(Decoder::CodecStream stream, uint seed = 0);