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
+6 -6
View File
@@ -1,10 +1,10 @@
target_sources(libolive-editor PRIVATE
OliveHost.h
OliveHost.cpp
OlivePluginInstance.h
OlivePluginInstance.cpp
OliveClip.cpp
OliveClip.h
olivehost.h
olivehost.cpp
oliveplugininstance.h
oliveplugininstance.cpp
oliveclip.cpp
oliveclip.h
paraminstance.cpp
paraminstance.h
image.cpp
+24 -24
View File
@@ -28,26 +28,26 @@ namespace olive
namespace plugin
{
static const char *PixelDepthToOfx(core::PixelFormat format)
static const char *pixel_depth_to_ofx(core::PixelFormat format)
{
switch (format) {
case core::PixelFormat::U8:
case core::PixelFormat::u8:
return kOfxBitDepthByte;
case core::PixelFormat::U16:
case core::PixelFormat::u16:
return kOfxBitDepthShort;
case core::PixelFormat::F16:
case core::PixelFormat::f16:
return kOfxBitDepthHalf;
case core::PixelFormat::F32:
case core::PixelFormat::f32:
return kOfxBitDepthFloat;
case core::PixelFormat::INVALID:
case core::PixelFormat::COUNT:
case core::PixelFormat::invalid:
case core::PixelFormat::count:
break;
}
return kOfxBitDepthNone;
}
static const char *ComponentsToOfx(int channel_count)
static const char *components_to_ofx(int channel_count)
{
switch (channel_count) {
case 1:
@@ -67,7 +67,7 @@ Image::Image(OFX::Host::ImageEffect::ClipInstance &clip_instance)
: OFX::Host::ImageEffect::Image(clip_instance)
, width_(0)
, height_(0)
, format_(core::PixelFormat::INVALID)
, format_(core::PixelFormat::invalid)
, premultiplied_alpha_(false)
, channel_count_(0)
, row_bytes_(0)
@@ -82,30 +82,30 @@ Image::Image(OFX::Host::ImageEffect::ClipInstance &clip_instance,
: OFX::Host::ImageEffect::Image(clip_instance)
, width_(0)
, height_(0)
, format_(core::PixelFormat::INVALID)
, format_(core::PixelFormat::invalid)
, premultiplied_alpha_(false)
, channel_count_(0)
, row_bytes_(0)
, bounds_{ 0, 0, 0, 0 }
, rod_{ 0, 0, 0, 0 }
{
AllocateFromParams(params, bounds, rod, clear);
allocate_from_params(params, bounds, rod, clear);
}
Image::~Image()
{
}
void Image::AllocateFromParams(const VideoParams &params,
void Image::allocate_from_params(const VideoParams &params,
const OfxRectI &bounds, const OfxRectI &rod,
bool clear)
{
Allocate(bounds.x2 - bounds.x1, bounds.y2 - bounds.y1, params.format(),
allocate(bounds.x2 - bounds.x1, bounds.y2 - bounds.y1, params.format(),
params.channel_count(), params.premultiplied_alpha(), bounds, rod,
clear);
}
void Image::EnsureAllocatedFromParams(const VideoParams &params,
void Image::ensure_allocated_from_params(const VideoParams &params,
const OfxRectI &bounds,
const OfxRectI &rod, bool clear)
{
@@ -120,13 +120,13 @@ void Image::EnsureAllocatedFromParams(const VideoParams &params,
(rod_.x2 == rod.x2) && (rod_.y2 == rod.y2);
if (!same) {
AllocateFromParams(params, bounds, rod, clear);
allocate_from_params(params, bounds, rod, clear);
} else if (clear && !image_.empty()) {
std::fill(image_.begin(), image_.end(), 0);
}
}
void Image::Allocate(int width, int height, core::PixelFormat format,
void Image::allocate(int width, int height, core::PixelFormat format,
int channel_count, bool premultiplied_alpha,
const OfxRectI &bounds, const OfxRectI &rod, bool clear)
{
@@ -161,8 +161,8 @@ void Image::Allocate(int width, int height, core::PixelFormat format,
setIntProperty(kOfxImagePropRegionOfDefinition, rod.x2, 2);
setIntProperty(kOfxImagePropRegionOfDefinition, rod.y2, 3);
setStringProperty(kOfxImageEffectPropComponents,
ComponentsToOfx(channel_count_));
setStringProperty(kOfxImageEffectPropPixelDepth, PixelDepthToOfx(format_));
components_to_ofx(channel_count_));
setStringProperty(kOfxImageEffectPropPixelDepth, pixel_depth_to_ofx(format_));
setStringProperty(kOfxImageEffectPropPreMultiplication,
premultiplied_alpha_ ? kOfxImagePreMultiplied :
kOfxImageUnPreMultiplied);
@@ -170,21 +170,21 @@ void Image::Allocate(int width, int height, core::PixelFormat format,
core::PixelFormat Image::pixel_format()
{
if (format_ != core::PixelFormat::INVALID) {
if (format_ != core::PixelFormat::invalid) {
return format_;
}
std::string type = getStringProperty(kOfxImageEffectPropPixelDepth);
if (type == kOfxBitDepthByte) {
format_ = core::PixelFormat::U8;
format_ = core::PixelFormat::u8;
} else if (type == kOfxBitDepthShort) {
format_ = core::PixelFormat::U16;
format_ = core::PixelFormat::u16;
} else if (type == kOfxBitDepthHalf) {
format_ = core::PixelFormat::F16;
format_ = core::PixelFormat::f16;
} else if (type == kOfxBitDepthFloat) {
format_ = core::PixelFormat::F32;
format_ = core::PixelFormat::f32;
} else {
format_ = core::PixelFormat::INVALID;
format_ = core::PixelFormat::invalid;
}
return format_;
}
+6 -6
View File
@@ -17,8 +17,8 @@
*
*/
#ifndef OLIVE_EDITOR_PLUGIN_IMAGE_H
#define OLIVE_EDITOR_PLUGIN_IMAGE_H
#ifndef OAK_OLIVE_EDITOR_PLUGIN_IMAGE_H
#define OAK_OLIVE_EDITOR_PLUGIN_IMAGE_H
#include "ofxCore.h"
#include "ofxImageEffect.h"
@@ -50,12 +50,12 @@ public:
bool premultiplied_alpha();
int channel_count();
void AllocateFromParams(const VideoParams &params, const OfxRectI &bounds,
void allocate_from_params(const VideoParams &params, const OfxRectI &bounds,
const OfxRectI &rod, bool clear = true);
void EnsureAllocatedFromParams(const VideoParams &params,
void ensure_allocated_from_params(const VideoParams &params,
const OfxRectI &bounds, const OfxRectI &rod,
bool clear = false);
void Allocate(int width, int height, core::PixelFormat format,
void allocate(int width, int height, core::PixelFormat format,
int channel_count, bool premultiplied_alpha,
const OfxRectI &bounds, const OfxRectI &rod,
bool clear = true);
@@ -78,4 +78,4 @@ protected:
}
}
#endif //OLIVE_EDITOR_PLUGIN_IMAGE_H
#endif //OAK_OLIVE_EDITOR_PLUGIN_IMAGE_H
@@ -21,9 +21,9 @@
// Created by mikesolar on 25-10-1.
//
#include "OliveClip.h"
#include "oliveclip.h"
#include "common/Current.h"
#include "common/current.h"
#include "common/ffmpegutils.h"
#include "ofxCore.h"
#include "ofxhClip.h"
@@ -43,26 +43,26 @@ namespace
// The bridge header only defines the little-endian pixel formats. FFmpeg
// numbers each big-endian variant immediately before its little-endian
// counterpart (BE == LE - 1), so derive the BE constants used below.
constexpr int FB_PIX_FMT_GRAYF32BE = FB_PIX_FMT_GRAYF32LE - 1;
constexpr int FB_PIX_FMT_RGBF32BE = FB_PIX_FMT_RGBF32LE - 1;
constexpr int FB_PIX_FMT_RGBAF32BE = FB_PIX_FMT_RGBAF32LE - 1;
constexpr int fb_pix_fmt_gray_f32_be = fb_pix_fmt_gray_f32_le - 1;
constexpr int fb_pix_fmt_rgb_f32_be = fb_pix_fmt_rgb_f32_le - 1;
constexpr int fb_pix_fmt_rgba_f32_be = fb_pix_fmt_rgba_f32_le - 1;
const std::string kBitDepthNoneStr(kOfxBitDepthNone);
const std::string kBitDepthByteStr(kOfxBitDepthByte);
const std::string kBitDepthShortStr(kOfxBitDepthShort);
const std::string kBitDepthHalfStr(kOfxBitDepthHalf);
const std::string kBitDepthFloatStr(kOfxBitDepthFloat);
const std::string kImageComponentNoneStr(kOfxImageComponentNone);
const std::string kImageComponentAlphaStr(kOfxImageComponentAlpha);
const std::string kImageComponentRGBStr(kOfxImageComponentRGB);
const std::string kImageComponentRGBAStr(kOfxImageComponentRGBA);
const std::string kImagePremultStr(kOfxImagePreMultiplied);
const std::string kImageUnPremultStr(kOfxImageUnPreMultiplied);
const std::string kImageFieldNoneStr(kOfxImageFieldNone);
const std::string kImageFieldUpperStr(kOfxImageFieldUpper);
const std::string kImageFieldLowerStr(kOfxImageFieldLower);
const std::string k_bit_depth_none_str(kOfxBitDepthNone);
const std::string k_bit_depth_byte_str(kOfxBitDepthByte);
const std::string k_bit_depth_short_str(kOfxBitDepthShort);
const std::string k_bit_depth_half_str(kOfxBitDepthHalf);
const std::string k_bit_depth_float_str(kOfxBitDepthFloat);
const std::string k_image_component_none_str(kOfxImageComponentNone);
const std::string k_image_component_alpha_str(kOfxImageComponentAlpha);
const std::string k_image_component_rgb_str(kOfxImageComponentRGB);
const std::string k_image_component_rgba_str(kOfxImageComponentRGBA);
const std::string k_image_premult_str(kOfxImagePreMultiplied);
const std::string k_image_un_premult_str(kOfxImageUnPreMultiplied);
const std::string k_image_field_none_str(kOfxImageFieldNone);
const std::string k_image_field_upper_str(kOfxImageFieldUpper);
const std::string k_image_field_lower_str(kOfxImageFieldLower);
static int BytesToPixels(int byte_linesize, const olive::VideoParams &params)
static int bytes_to_pixels(int byte_linesize, const olive::VideoParams &params)
{
const int bytes_per_pixel =
params.channel_count() * params.format().byte_count();
@@ -72,48 +72,48 @@ static int BytesToPixels(int byte_linesize, const olive::VideoParams &params)
return byte_linesize / bytes_per_pixel;
}
static int PackedFloatChannels(int fmt)
static int packed_float_channels(int fmt)
{
switch (fmt) {
case FB_PIX_FMT_GRAYF32LE:
case FB_PIX_FMT_GRAYF32BE:
case fb_pix_fmt_gray_f32_le:
case fb_pix_fmt_gray_f32_be:
return 1;
case FB_PIX_FMT_RGBF32LE:
case FB_PIX_FMT_RGBF32BE:
case fb_pix_fmt_rgb_f32_le:
case fb_pix_fmt_rgb_f32_be:
return 3;
case FB_PIX_FMT_RGBAF32LE:
case FB_PIX_FMT_RGBAF32BE:
case fb_pix_fmt_rgba_f32_le:
case fb_pix_fmt_rgba_f32_be:
return 4;
default:
return 0;
}
}
static bool PackedDstInfo(int fmt, int *channels,
static bool packed_dst_info(int fmt, int *channels,
int *bytes_per_component)
{
switch (fmt) {
case FB_PIX_FMT_GRAY8:
case fb_pix_fmt_gra_y8:
*channels = 1;
*bytes_per_component = 1;
return true;
case FB_PIX_FMT_RGB24:
case fb_pix_fmt_rg_b24:
*channels = 3;
*bytes_per_component = 1;
return true;
case FB_PIX_FMT_RGBA:
case fb_pix_fmt_rgba:
*channels = 4;
*bytes_per_component = 1;
return true;
case FB_PIX_FMT_GRAY16LE:
case fb_pix_fmt_gra_y16_le:
*channels = 1;
*bytes_per_component = 2;
return true;
case FB_PIX_FMT_RGB48LE:
case fb_pix_fmt_rg_b48_le:
*channels = 3;
*bytes_per_component = 2;
return true;
case FB_PIX_FMT_RGBA64LE:
case fb_pix_fmt_rgb_a64_le:
*channels = 4;
*bytes_per_component = 2;
return true;
@@ -123,40 +123,40 @@ static bool PackedDstInfo(int fmt, int *channels,
}
static olive::AVFramePtr
ReadbackTextureToFrame(olive::TexturePtr texture,
readback_texture_to_frame(olive::TexturePtr texture,
const olive::VideoParams &params)
{
if (!texture || texture->IsDummy() || !texture->renderer()) {
if (!texture || texture->is_dummy() || !texture->renderer()) {
return nullptr;
}
int pix_fmt = olive::FFmpegUtils::GetFFmpegPixelFormat(
int pix_fmt = olive::FFmpegUtils::get_f_fmpeg_pixel_format(
params.format(), params.channel_count());
if (pix_fmt == FB_PIX_FMT_NONE) {
if (pix_fmt == fb_pix_fmt_none) {
return nullptr;
}
if (!fb_pix_fmt_is_planar(pix_fmt)) {
olive::AVFramePtr frame = olive::CreateAVFramePtr();
olive::AVFramePtr frame = olive::create_av_frame_ptr();
frame->set_format(pix_fmt);
frame->set_width(params.width());
frame->set_height(params.height());
if (frame->get_buffer(0) < 0) {
return nullptr;
}
const int linesize_pixels = BytesToPixels(frame->linesize(0), params);
texture->renderer()->DownloadFromTexture(
const int linesize_pixels = bytes_to_pixels(frame->linesize(0), params);
texture->renderer()->download_from_texture(
texture->id(), params, frame->data(0), linesize_pixels);
return frame;
}
olive::VideoParams rgba_params(params.width(), params.height(),
olive::core::PixelFormat::U8, 4,
olive::core::PixelFormat::u8, 4,
params.pixel_aspect_ratio(),
params.interlacing(), params.divider());
olive::AVFramePtr rgba_frame = olive::CreateAVFramePtr();
rgba_frame->set_format(FB_PIX_FMT_RGBA);
olive::AVFramePtr rgba_frame = olive::create_av_frame_ptr();
rgba_frame->set_format(fb_pix_fmt_rgba);
rgba_frame->set_width(params.width());
rgba_frame->set_height(params.height());
if (rgba_frame->get_buffer(0) < 0) {
@@ -164,11 +164,11 @@ ReadbackTextureToFrame(olive::TexturePtr texture,
}
const int linesize_pixels =
BytesToPixels(rgba_frame->linesize(0), rgba_params);
texture->renderer()->DownloadFromTexture(
bytes_to_pixels(rgba_frame->linesize(0), rgba_params);
texture->renderer()->download_from_texture(
texture->id(), rgba_params, rgba_frame->data(0), linesize_pixels);
olive::AVFramePtr dst = olive::CreateAVFramePtr();
olive::AVFramePtr dst = olive::create_av_frame_ptr();
dst->set_format(pix_fmt);
dst->set_width(params.width());
dst->set_height(params.height());
@@ -199,25 +199,25 @@ ReadbackTextureToFrame(olive::TexturePtr texture,
return dst;
}
static olive::AVFramePtr ConvertPackedFloatFrame(olive::AVFramePtr src,
static olive::AVFramePtr convert_packed_float_frame(olive::AVFramePtr src,
int dst_fmt)
{
if (!src || !src->data(0)) {
return nullptr;
}
const int src_channels =
PackedFloatChannels(src->format());
packed_float_channels(src->format());
if (src_channels == 0) {
return nullptr;
}
int dst_channels = 0;
int bytes_per_component = 0;
if (!PackedDstInfo(dst_fmt, &dst_channels, &bytes_per_component)) {
if (!packed_dst_info(dst_fmt, &dst_channels, &bytes_per_component)) {
return nullptr;
}
olive::AVFramePtr dst = olive::CreateAVFramePtr();
olive::AVFramePtr dst = olive::create_av_frame_ptr();
dst->set_format(dst_fmt);
dst->set_width(src->width());
dst->set_height(src->height());
@@ -293,25 +293,25 @@ const std::string &olive::plugin::OliveClipInstance::getUnmappedBitDepth() const
// Return the plugin's preferred pixel depth from base class
// This is set during getClipPreferences action via setPixelDepth()
const std::string &depth = getPixelDepth();
if (!depth.empty() && depth != kBitDepthNoneStr) {
if (!depth.empty() && depth != k_bit_depth_none_str) {
return depth;
}
// Fallback to params_ if base class value is not set
switch (params_.format()) {
case PixelFormat::INVALID:
return kBitDepthNoneStr;
case PixelFormat::U8:
return kBitDepthByteStr;
case PixelFormat::U10:
return kBitDepthNoneStr;
case PixelFormat::U16:
return kBitDepthShortStr;
case PixelFormat::F16:
return kBitDepthHalfStr;
case PixelFormat::F32:
return kBitDepthFloatStr;
case PixelFormat::invalid:
return k_bit_depth_none_str;
case PixelFormat::u8:
return k_bit_depth_byte_str;
case PixelFormat::u10:
return k_bit_depth_none_str;
case PixelFormat::u16:
return k_bit_depth_short_str;
case PixelFormat::f16:
return k_bit_depth_half_str;
case PixelFormat::f32:
return k_bit_depth_float_str;
default:
return kBitDepthNoneStr;
return k_bit_depth_none_str;
}
}
const std::string &
@@ -320,32 +320,32 @@ olive::plugin::OliveClipInstance::getUnmappedComponents() const
// Return the plugin's preferred components from base class
// This is set during getClipPreferences action via setComponents()
const std::string &comp = getComponents();
if (!comp.empty() && comp != kImageComponentNoneStr) {
if (!comp.empty() && comp != k_image_component_none_str) {
return comp;
}
// Fallback to params_ if base class value is not set
switch (params_.channel_count()) {
case 1:
return kImageComponentAlphaStr;
return k_image_component_alpha_str;
case 3:
return kImageComponentRGBStr;
return k_image_component_rgb_str;
case 4:
return kImageComponentRGBAStr;
return k_image_component_rgba_str;
default:
return kImageComponentNoneStr;
return k_image_component_none_str;
}
}
const std::string &olive::plugin::OliveClipInstance::getPremult() const
{
if (params_.premultiplied_alpha()) {
return kImagePremultStr;
return k_image_premult_str;
} else {
return kImageUnPremultStr;
return k_image_un_premult_str;
}
}
double olive::plugin::OliveClipInstance::getAspectRatio() const
{
double par = params_.pixel_aspect_ratio().toDouble();
double par = params_.pixel_aspect_ratio().to_double();
if (par == 0.0) {
return 1.0; // default PAR when not explicitly set
}
@@ -353,26 +353,26 @@ double olive::plugin::OliveClipInstance::getAspectRatio() const
}
double olive::plugin::OliveClipInstance::getFrameRate() const
{
return params_.frame_rate().toDouble();
return params_.frame_rate().to_double();
}
void olive::plugin::OliveClipInstance::getFrameRange(double &startFrame,
double &endFrame) const
void olive::plugin::OliveClipInstance::getFrameRange(double &start_frame,
double &end_frame) const
{
startFrame = params_.frame_rate().toDouble() * params_.start_time();
endFrame =
startFrame + params_.frame_rate().toDouble() * params_.duration();
start_frame = params_.frame_rate().to_double() * params_.start_time();
end_frame =
start_frame + params_.frame_rate().to_double() * params_.duration();
}
const std::string &olive::plugin::OliveClipInstance::getFieldOrder() const
{
switch (params_.interlacing()) {
case VideoParams::kInterlaceNone:
return kImageFieldNoneStr;
case VideoParams::kInterlacedTopFirst:
return kImageFieldUpperStr;
case VideoParams::kInterlacedBottomFirst:
return kImageFieldLowerStr;
case VideoParams::k_interlace_none:
return k_image_field_none_str;
case VideoParams::k_interlaced_top_first:
return k_image_field_upper_str;
case VideoParams::k_interlaced_bottom_first:
return k_image_field_lower_str;
}
return kImageFieldNoneStr;
return k_image_field_none_str;
}
bool olive::plugin::OliveClipInstance::getConnected() const
{
@@ -400,9 +400,9 @@ double olive::plugin::OliveClipInstance::getUnmappedFrameRate() const
return getFrameRate();
}
void olive::plugin::OliveClipInstance::getUnmappedFrameRange(
double &startFrame, double &endFrame) const
double &start_frame, double &end_frame) const
{
getFrameRange(startFrame, endFrame);
getFrameRange(start_frame, end_frame);
}
bool olive::plugin::OliveClipInstance::getContinuousSamples() const
{
@@ -410,14 +410,14 @@ bool olive::plugin::OliveClipInstance::getContinuousSamples() const
}
OFX::Host::ImageEffect::Image *
olive::plugin::OliveClipInstance::getImage(OfxTime time,
const OfxRectD *optionalBounds)
const OfxRectD *optional_bounds)
{
OfxRectD rod_d = getRegionOfDefinition(time);
OfxRectI rod = { static_cast<int>(std::floor(rod_d.x1)),
static_cast<int>(std::floor(rod_d.y1)),
static_cast<int>(std::ceil(rod_d.x2)),
static_cast<int>(std::ceil(rod_d.y2)) };
(void)optionalBounds;
(void)optional_bounds;
// Always return full-frame images to keep input data consistent.
OfxRectI bounds = rod;
@@ -435,14 +435,14 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time,
// when it releases the image
images_[time]->addReference();
images_[time]->EnsureAllocatedFromParams(params_, bounds, rod, true);
images_[time]->ensure_allocated_from_params(params_, bounds, rod, true);
// return it
return images_[time];
} else {
if (images_.contains(time)) {
Image *image = images_.value(time);
image->EnsureAllocatedFromParams(params_, bounds, rod, false);
image->ensure_allocated_from_params(params_, bounds, rod, false);
image->addReference();
return image;
}
@@ -451,7 +451,7 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time,
// Use plugin-preferred params to ensure the image format matches
// what the plugin expects (may differ from input texture format)
VideoParams preferred_params = getPluginPreferredParams();
if (preferred_params.format() == core::PixelFormat::INVALID) {
if (preferred_params.format() == core::PixelFormat::invalid) {
preferred_params = params_;
}
// Keep dimensions and other settings from params_
@@ -462,7 +462,7 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time,
// Guard against zero-size or invalid-format images that would
// cause EXC_BAD_ACCESS when the plugin accesses pixel data.
if (preferred_params.width() <= 0 || preferred_params.height() <= 0 ||
preferred_params.format() == core::PixelFormat::INVALID ||
preferred_params.format() == core::PixelFormat::invalid ||
preferred_params.channel_count() <= 0) {
return nullptr;
}
@@ -471,7 +471,7 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time,
// fetches at the same time reuse it and getConnected() reflects it.
// The extra reference keeps the cached image alive when the plugin
// releases its own.
pruneImagesCache();
prune_images_cache();
Image *image = new Image(*this, preferred_params, bounds, rod, true);
images_.insert(time, image);
image->addReference();
@@ -496,7 +496,7 @@ olive::plugin::OliveClipInstance::getOutputImage(OfxTime time)
// Use plugin-preferred params instead of params_ to ensure the image
// is created with the format the plugin expects
VideoParams preferred_params = getPluginPreferredParams();
if (preferred_params.format() == core::PixelFormat::INVALID) {
if (preferred_params.format() == core::PixelFormat::invalid) {
preferred_params = params_;
}
// Keep the dimensions and other settings from params_
@@ -518,13 +518,13 @@ olive::plugin::OliveClipInstance::getPluginPreferredParams() const
const std::string &depth = getPixelDepth();
if (!depth.empty()) {
if (depth == kOfxBitDepthByte) {
result.set_format(core::PixelFormat::U8);
result.set_format(core::PixelFormat::u8);
} else if (depth == kOfxBitDepthShort) {
result.set_format(core::PixelFormat::U16);
result.set_format(core::PixelFormat::u16);
} else if (depth == kOfxBitDepthHalf) {
result.set_format(core::PixelFormat::F16);
result.set_format(core::PixelFormat::f16);
} else if (depth == kOfxBitDepthFloat) {
result.set_format(core::PixelFormat::F32);
result.set_format(core::PixelFormat::f32);
}
}
@@ -548,38 +548,38 @@ olive::plugin::OliveClipInstance::getRegionOfDefinition(OfxTime time) const
if (regionOfDefinitions_.contains(time)) {
return regionOfDefinitions_.value(time);
}
OfxRectD regionOfDefinition;
regionOfDefinition.x1 = regionOfDefinition.y1 = 0;
double par = params_.pixel_aspect_ratio().toDouble();
regionOfDefinition.x2 = params_.width() * par;
regionOfDefinition.y2 = params_.height();
if (regionOfDefinition.x2 <= 0 || regionOfDefinition.y2 <= 0) {
OfxRectD region_of_definition;
region_of_definition.x1 = region_of_definition.y1 = 0;
double par = params_.pixel_aspect_ratio().to_double();
region_of_definition.x2 = params_.width() * par;
region_of_definition.y2 = params_.height();
if (region_of_definition.x2 <= 0 || region_of_definition.y2 <= 0) {
// The params provide no usable region; fall back to the default set
// via setDefaultRegionOfDefinition().
return defaultRegionOfDefinitions_;
}
return regionOfDefinition;
return region_of_definition;
}
void olive::plugin::OliveClipInstance::setRegionOfDefinition(
OfxRectD regionOfDefinition, OfxTime time)
OfxRectD region_of_definition, OfxTime time)
{
regionOfDefinitions_[time] = regionOfDefinition;
regionOfDefinitions_[time] = region_of_definition;
}
void olive::plugin::OliveClipInstance::setDefaultRegionOfDefinition(
OfxRectD regionOfDefinition)
OfxRectD region_of_definition)
{
defaultRegionOfDefinitions_ = regionOfDefinition;
defaultRegionOfDefinitions_ = region_of_definition;
}
void olive::plugin::OliveClipInstance::pruneImagesCache()
void olive::plugin::OliveClipInstance::prune_images_cache()
{
// Do not prune output clip images; they may have external references
// added by getImage()/addReference() and are typically single-frame.
if (name_ == kOfxImageEffectOutputClipName) {
return;
}
while (images_.size() > kMaxInputImageCache) {
while (images_.size() > k_max_input_image_cache) {
auto it = images_.begin();
Image *img = it.value();
images_.erase(it);
@@ -608,8 +608,8 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture,
// The frame rate of an OFX clip should reflect the project's frame rate,
// not the individual input texture's frame rate. If different inputs
// have different frame rates, setupClipPreferencesArgs throws an exception.
rational saved_frame_rate = params_.frame_rate();
rational saved_time_base = params_.time_base();
Rational saved_frame_rate = params_.frame_rate();
Rational saved_time_base = params_.time_base();
this->params_ = incoming;
@@ -634,16 +634,16 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture,
AVFramePtr frame = texture->frame();
if (!frame || !frame->data(0)) {
frame = ReadbackTextureToFrame(texture, params_);
frame = readback_texture_to_frame(texture, params_);
}
int expected_fmt = FFmpegUtils::GetFFmpegPixelFormat(
int expected_fmt = FFmpegUtils::get_f_fmpeg_pixel_format(
params_.format(), params_.channel_count());
if (expected_fmt == FB_PIX_FMT_NONE) {
if (expected_fmt == fb_pix_fmt_none) {
return;
}
OfxRectI bounds = { 0, 0, params_.width(), params_.height() };
OfxRectD rod_d = getRegionOfDefinition(time);
OfxRectI regionOfDefinition = { static_cast<int>(std::floor(rod_d.x1)),
OfxRectI region_of_definition = { static_cast<int>(std::floor(rod_d.x1)),
static_cast<int>(std::floor(rod_d.y1)),
static_cast<int>(std::ceil(rod_d.x2)),
static_cast<int>(std::ceil(rod_d.y2)) };
@@ -651,12 +651,12 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture,
Image *image;
if (images_.contains(time)) {
image = images_.value(time);
image->EnsureAllocatedFromParams(params_, bounds, regionOfDefinition,
image->ensure_allocated_from_params(params_, bounds, region_of_definition,
false);
} else {
pruneImagesCache();
image = new Image(*this, params_, bounds, regionOfDefinition, false);
image->EnsureAllocatedFromParams(params_, bounds, regionOfDefinition,
prune_images_cache();
image = new Image(*this, params_, bounds, region_of_definition, false);
image->ensure_allocated_from_params(params_, bounds, region_of_definition,
false);
images_.insert(time, image);
}
@@ -676,7 +676,7 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture,
// undefined behaviour when val is NaN, leading to out-of-bounds indexing
// and SIGSEGV on Apple Silicon (where (int)NaN often evaluates to 0 or
// INT_MIN, causing huge offsets into bgrid._data).
if (params_.format() == core::PixelFormat::F32) {
if (params_.format() == core::PixelFormat::f32) {
const float *fptr = reinterpret_cast<const float *>(frame->data(0));
int row_floats = frame->linesize(0) / static_cast<int>(sizeof(float));
bool has_nan = false;
@@ -706,15 +706,15 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture,
AVFramePtr src_frame = frame;
if (frame->format() != expected_fmt || frame->width() != params_.width() ||
frame->height() != params_.height()) {
if (PackedFloatChannels(frame->format()) >
if (packed_float_channels(frame->format()) >
0) {
AVFramePtr converted = ConvertPackedFloatFrame(frame, expected_fmt);
AVFramePtr converted = convert_packed_float_frame(frame, expected_fmt);
if (converted) {
src_frame = converted;
goto copy_pixels;
}
}
AVFramePtr converted = CreateAVFramePtr();
AVFramePtr converted = create_av_frame_ptr();
converted->set_format(expected_fmt);
converted->set_width(params_.width());
converted->set_height(params_.height());
@@ -758,7 +758,7 @@ copy_pixels:
int copy_height = std::min(image->height(), src_frame->height());
const uint8_t *src = src_frame->data(0);
if (params_.format() == core::PixelFormat::F32) {
if (params_.format() == core::PixelFormat::f32) {
const float *src_f = reinterpret_cast<const float *>(src);
float *dst_f = reinterpret_cast<float *>(dst);
int src_stride = src_row_bytes / static_cast<int>(sizeof(float));
@@ -806,7 +806,7 @@ void olive::plugin::OliveClipInstance::setOutputTexture(TexturePtr texture,
#ifdef OFX_SUPPORTS_OPENGLRENDER
OFX::Host::ImageEffect::Texture *
olive::plugin::OliveClipInstance::loadTexture(OfxTime time, const char *format,
const OfxRectD *optionalBounds)
const OfxRectD *optional_bounds)
{
(void)format;
@@ -818,7 +818,7 @@ olive::plugin::OliveClipInstance::loadTexture(OfxTime time, const char *format,
gl_texture = input ? input : nullptr;
}
if (!gl_texture || gl_texture->IsDummy() || !gl_texture->id().isValid()) {
if (!gl_texture || gl_texture->is_dummy() || !gl_texture->id().isValid()) {
return nullptr;
}
@@ -828,11 +828,11 @@ olive::plugin::OliveClipInstance::loadTexture(OfxTime time, const char *format,
static_cast<int>(std::ceil(rod_d.x2)),
static_cast<int>(std::ceil(rod_d.y2)) };
OfxRectI bounds = rod;
if (optionalBounds) {
bounds.x1 = static_cast<int>(std::floor(optionalBounds->x1));
bounds.y1 = static_cast<int>(std::floor(optionalBounds->y1));
bounds.x2 = static_cast<int>(std::ceil(optionalBounds->x2));
bounds.y2 = static_cast<int>(std::ceil(optionalBounds->y2));
if (optional_bounds) {
bounds.x1 = static_cast<int>(std::floor(optional_bounds->x1));
bounds.y1 = static_cast<int>(std::floor(optional_bounds->y1));
bounds.x2 = static_cast<int>(std::ceil(optional_bounds->x2));
bounds.y2 = static_cast<int>(std::ceil(optional_bounds->y2));
}
bounds.x1 = std::max(bounds.x1, rod.x1);
bounds.y1 = std::max(bounds.y1, rod.y1);
@@ -21,8 +21,8 @@
// Created by mikesolar on 25-10-1.
//
#ifndef OLIVECLIP_H
#define OLIVECLIP_H
#ifndef OAK_OLIVECLIP_H
#define OAK_OLIVECLIP_H
#include "image.h"
#include "ofxCore.h"
#include "ofxhClip.h"
@@ -37,10 +37,10 @@ namespace plugin
{
class OliveClipInstance : public OFX::Host::ImageEffect::ClipInstance {
public:
OliveClipInstance(OFX::Host::ImageEffect::Instance *effectInstance,
OliveClipInstance(OFX::Host::ImageEffect::Instance *effect_instance,
OFX::Host::ImageEffect::ClipDescriptor &desc,
VideoParams &params)
: ClipInstance(effectInstance, desc)
: ClipInstance(effect_instance, desc)
, params_(params)
, defaultRegionOfDefinitions_{ 0, 0, 0, 0 }
, name_(desc.getName())
@@ -53,24 +53,24 @@ public:
const std::string &getPremult() const override;
double getAspectRatio() const override;
double getFrameRate() const override;
void getFrameRange(double &startFrame, double &endFrame) const override;
void getFrameRange(double &start_frame, double &end_frame) const override;
const std::string &getFieldOrder() const override;
bool getConnected() const override;
double getUnmappedFrameRate() const override;
void getUnmappedFrameRange(double &startFrame,
double &endFrame) const override;
void getUnmappedFrameRange(double &start_frame,
double &end_frame) const override;
bool getContinuousSamples() const override;
OFX::Host::ImageEffect::Image *
getImage(OfxTime time, const OfxRectD *optionalBounds) override;
getImage(OfxTime time, const OfxRectD *optional_bounds) override;
OfxRectD getRegionOfDefinition(OfxTime time) const override;
void setRegionOfDefinition(OfxRectD regionOfDefinition, OfxTime time);
void setDefaultRegionOfDefinition(OfxRectD regionOfDefinition);
void setRegionOfDefinition(OfxRectD region_of_definition, OfxTime time);
void setDefaultRegionOfDefinition(OfxRectD region_of_definition);
void setParams(const VideoParams &params);
#ifdef OFX_SUPPORTS_OPENGLRENDER
OFX::Host::ImageEffect::Texture *
loadTexture(OfxTime time, const char *format,
const OfxRectD *optionalBounds) override;
const OfxRectD *optional_bounds) override;
#endif
void setInputTexture(TexturePtr texture, OfxTime time,
@@ -82,9 +82,9 @@ public:
// Prune old entries from the images_ cache to prevent unbounded growth.
// Output clip images are not pruned (they are typically single-frame).
void pruneImagesCache();
void prune_images_cache();
static constexpr int kMaxInputImageCache = 8;
static constexpr int k_max_input_image_cache = 8;
private:
VideoParams params_;
@@ -103,4 +103,4 @@ private:
}
}
#endif //OLIVECLIP_H
#endif //OAK_OLIVECLIP_H
@@ -28,10 +28,10 @@
#include <QApplication>
#include <QCoreApplication>
#include <QDir>
#include "OliveHost.h"
#include "olivehost.h"
#include "OlivePluginInstance.h"
#include "common/Current.h"
#include "oliveplugininstance.h"
#include "common/current.h"
#include "ofxMessage.h"
#include "version.h"
#include <QMessageBox>
@@ -48,7 +48,7 @@ class PluginNode;
namespace
{
void AddPluginPath(OFX::Host::PluginCache *cache, const QString &path,
void add_plugin_path(OFX::Host::PluginCache *cache, const QString &path,
bool recurse = true)
{
if (!cache || path.isEmpty()) {
@@ -61,7 +61,7 @@ void AddPluginPath(OFX::Host::PluginCache *cache, const QString &path,
cache->addFileToPath(dir.canonicalPath().toStdString(), recurse);
}
void AddPluginPathsFromEnv(OFX::Host::PluginCache *cache, const char *env_var)
void add_plugin_paths_from_env(OFX::Host::PluginCache *cache, const char *env_var)
{
QString raw = qEnvironmentVariable(env_var);
if (raw.isEmpty()) {
@@ -70,47 +70,47 @@ void AddPluginPathsFromEnv(OFX::Host::PluginCache *cache, const char *env_var)
const QChar separator = QDir::listSeparator();
const QStringList paths = raw.split(separator, Qt::SkipEmptyParts);
for (const QString &path : paths) {
AddPluginPath(cache, path);
add_plugin_path(cache, path);
}
}
}
void olive::plugin::loadPlugins(QString path)
void olive::plugin::load_plugins(QString path)
{
std::shared_ptr<OliveHost> host = Current::getInstance().pluginHost();
std::shared_ptr<ImageEffect::PluginCache> imageEffectPluginCache =
Current::getInstance().pluginCache();
std::shared_ptr<OliveHost> host = Current::getInstance().plugin_host();
std::shared_ptr<ImageEffect::PluginCache> image_effect_plugin_cache =
Current::getInstance().plugin_cache();
if (!host || !imageEffectPluginCache) {
if (!host || !image_effect_plugin_cache) {
host = std::make_shared<OliveHost>();
Current::getInstance().setPluginHost(host);
imageEffectPluginCache =
image_effect_plugin_cache =
std::make_shared<ImageEffect::PluginCache>(*host);
Current::getInstance().setPluginCache(imageEffectPluginCache);
Current::getInstance().setPluginCache(image_effect_plugin_cache);
imageEffectPluginCache->registerInCache(
image_effect_plugin_cache->registerInCache(
*OFX::Host::PluginCache::getPluginCache());
}
OFX::Host::PluginCache *cache = OFX::Host::PluginCache::getPluginCache();
cache->setPluginHostPath("Olive");
const QString home_path = QDir::homePath();
AddPluginPath(cache, QDir(home_path).filePath(".OFX/Plugins"));
AddPluginPath(cache, QDir(home_path).filePath(".local/share/OFX/Plugins"));
AddPluginPath(cache,
add_plugin_path(cache, QDir(home_path).filePath(".OFX/Plugins"));
add_plugin_path(cache, QDir(home_path).filePath(".local/share/OFX/Plugins"));
add_plugin_path(cache,
QDir(home_path).filePath(".local/share/olive/ofx/Plugins"));
const QString app_dir = QCoreApplication::applicationDirPath();
AddPluginPath(cache, QDir(app_dir).filePath("../OFX/Plugins"));
AddPluginPath(cache, QDir(app_dir).filePath("../share/olive/ofx/Plugins"));
AddPluginPath(cache, QDir(app_dir).filePath("../lib/olive/ofx/Plugins"));
add_plugin_path(cache, QDir(app_dir).filePath("../OFX/Plugins"));
add_plugin_path(cache, QDir(app_dir).filePath("../share/olive/ofx/Plugins"));
add_plugin_path(cache, QDir(app_dir).filePath("../lib/olive/ofx/Plugins"));
AddPluginPathsFromEnv(cache, "OLIVE_OFX_PLUGIN_PATH");
AddPluginPathsFromEnv(cache, "OLIVE_PLUGIN_PATH");
add_plugin_paths_from_env(cache, "OLIVE_OFX_PLUGIN_PATH");
add_plugin_paths_from_env(cache, "OLIVE_PLUGIN_PATH");
if (!path.isEmpty()) {
AddPluginPath(cache, path, true);
add_plugin_path(cache, path, true);
}
cache->scanPluginFiles();
}
@@ -120,11 +120,11 @@ OliveHost::OliveHost()
_properties.setStringProperty(kOfxPropName, "Oak Video Editor");
_properties.setStringProperty(kOfxPropLabel, "Oak Video Editor");
_properties.setStringProperty(kOfxPropVersionLabel,
olive::kAppVersion.toStdString());
olive::k_app_version.toStdString());
// Numeric version for plugins that query kOfxPropVersion directly.
const QStringList version_parts =
olive::kAppVersion.section(QLatin1Char('-'), 0, 0)
olive::k_app_version.section(QLatin1Char('-'), 0, 0)
.split(QLatin1Char('.'));
_properties.setIntProperty(kOfxPropVersion,
version_parts.value(0).toInt(), 0);
@@ -138,7 +138,7 @@ OliveHost::~OliveHost()
{
}
void OliveHost::destroyInstance(OFX::Host::ImageEffect::Instance *instance)
void OliveHost::destroy_instance(OFX::Host::ImageEffect::Instance *instance)
{
if (!instance) {
return;
@@ -159,33 +159,33 @@ OliveHost::makeDescriptor(ImageEffect::ImageEffectPlugin *plugin)
return desc;
}
std::shared_ptr<OFX::Host::ImageEffect::Descriptor>
OliveHost::makeDescriptor(const ImageEffect::Descriptor &rootContext,
OliveHost::makeDescriptor(const ImageEffect::Descriptor &root_context,
ImageEffect::ImageEffectPlugin *plugin)
{
std::shared_ptr<OFX::Host::ImageEffect::Descriptor> desc =
std::make_shared<ImageEffect::Descriptor>(rootContext, plugin);
std::make_shared<ImageEffect::Descriptor>(root_context, plugin);
descriptors_.append(std::shared_ptr<ImageEffect::Descriptor>(desc));
return desc;
}
std::shared_ptr<OFX::Host::ImageEffect::Descriptor>
OliveHost::makeDescriptor(const std::string &bundlePath,
OliveHost::makeDescriptor(const std::string &bundle_path,
ImageEffect::ImageEffectPlugin *plugin)
{
std::shared_ptr<OFX::Host::ImageEffect::Descriptor> desc =
std::make_shared<ImageEffect::Descriptor>(bundlePath, plugin);
std::make_shared<ImageEffect::Descriptor>(bundle_path, plugin);
descriptors_.append(std::shared_ptr<ImageEffect::Descriptor>(desc));
return desc;
}
ImageEffect::Instance *
OliveHost::newInstance(void *clientData, ImageEffect::ImageEffectPlugin *plugin,
OliveHost::newInstance(void *client_data, ImageEffect::ImageEffectPlugin *plugin,
ImageEffect::Descriptor &desc,
const std::string &context)
{
auto *instance = new OlivePluginInstance(
plugin, desc, context, Current::getInstance().interactive());
if (clientData) {
auto *node = static_cast<PluginNode *>(clientData);
if (client_data) {
auto *node = static_cast<PluginNode *>(client_data);
instance->setNode(
std::shared_ptr<PluginNode>(node, [](PluginNode *) {}));
}
@@ -252,21 +252,21 @@ OfxStatus olive::plugin::OliveHost::setPersistentMessage(const char *type,
QGuiApplication::platformName() == QLatin1String("offscreen");
if (strcmp(type, kOfxMessageError) == 0) {
persistent_messages_.append({ HostMessageType::Error, message });
persistent_messages_.append({ HostMessageType::error, message });
if (headless) {
qWarning().noquote() << "OFX error:" << message;
} else {
QMessageBox::critical(nullptr, "", message);
}
} else if (strcmp(type, kOfxMessageWarning) == 0) {
persistent_messages_.append({ HostMessageType::Warning, message });
persistent_messages_.append({ HostMessageType::warning, message });
if (headless) {
qWarning().noquote() << "OFX warning:" << message;
} else {
QMessageBox::warning(nullptr, "", message);
}
} else if (strcmp(type, kOfxMessageMessage) == 0) {
persistent_messages_.append({ HostMessageType::Message, message });
persistent_messages_.append({ HostMessageType::message, message });
if (headless) {
qWarning().noquote() << "OFX message:" << message;
} else {
@@ -15,9 +15,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OLIVE_HOST_H
#define OLIVE_HOST_H
#include "node/plugins/Plugin.h"
#ifndef OAK_OLIVE_HOST_H
#define OAK_OLIVE_HOST_H
#include "node/plugins/plugin.h"
#include "ofxhHost.h"
#include "ofxhImageEffectAPI.h"
#include "ofxCore.h"
@@ -35,18 +35,18 @@ namespace olive
{
namespace plugin
{
enum class HostMessageType { Error, Warning, Message };
enum class HostMessageType { error, warning, message };
struct HostPersistentMessage {
HostMessageType type;
QString message;
};
void loadPlugins(QString path);
void load_plugins(QString path);
class OliveHost : public OFX::Host::ImageEffect::Host {
public:
OliveHost();
~OliveHost() override;
void destroyInstance(OFX::Host::ImageEffect::Instance *instance);
void destroy_instance(OFX::Host::ImageEffect::Instance *instance);
bool pluginSupported(OFX::Host::ImageEffect::ImageEffectPlugin *plugin,
std::string &reason) const override
@@ -63,7 +63,7 @@ public:
};
OFX::Host::ImageEffect::Instance *
newInstance(void *clientData,
newInstance(void *client_data,
OFX::Host::ImageEffect::ImageEffectPlugin *plugin,
OFX::Host::ImageEffect::Descriptor &desc,
const std::string &context) override;
@@ -72,11 +72,11 @@ public:
makeDescriptor(OFX::Host::ImageEffect::ImageEffectPlugin *plugin) override;
std::shared_ptr<OFX::Host::ImageEffect::Descriptor>
makeDescriptor(const OFX::Host::ImageEffect::Descriptor &rootContext,
makeDescriptor(const OFX::Host::ImageEffect::Descriptor &root_context,
OFX::Host::ImageEffect::ImageEffectPlugin *plugin) override;
std::shared_ptr<OFX::Host::ImageEffect::Descriptor>
makeDescriptor(const std::string &bundlePath,
makeDescriptor(const std::string &bundle_path,
OFX::Host::ImageEffect::ImageEffectPlugin *plugin) override;
/// vmessage
virtual OfxStatus vmessage(const char *type, const char *id,
@@ -15,13 +15,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "OlivePluginInstance.h"
#include "oliveplugininstance.h"
#include "OliveClip.h"
#include "oliveclip.h"
#include "ofxGPURender.h"
#include "ofxCore.h"
#include "ofxMessage.h"
#include "common/Current.h"
#include "common/current.h"
#include "core.h"
#include "dialog/progress/progress.h"
#include "node/output/viewer/viewer.h"
@@ -45,11 +45,11 @@ namespace plugin
{
namespace
{
const std::string kImageFieldNoneStr(kOfxImageFieldNone);
const std::string kImageFieldUpperStr(kOfxImageFieldUpper);
const std::string kImageFieldLowerStr(kOfxImageFieldLower);
const std::string k_image_field_none_str(kOfxImageFieldNone);
const std::string k_image_field_upper_str(kOfxImageFieldUpper);
const std::string k_image_field_lower_str(kOfxImageFieldLower);
QString FormatOfxMessage(const char *format, va_list args)
QString format_ofx_message(const char *format, va_list args)
{
char buffer[1024];
va_list args_copy;
@@ -71,17 +71,17 @@ QString FormatOfxMessage(const char *format, va_list args)
return QString::fromUtf8(dynamic_buffer.constData());
}
const std::string &FieldOrderForParams(const VideoParams &params)
const std::string &field_order_for_params(const VideoParams &params)
{
switch (params.interlacing()) {
case VideoParams::kInterlaceNone:
return kImageFieldNoneStr;
case VideoParams::kInterlacedTopFirst:
return kImageFieldUpperStr;
case VideoParams::kInterlacedBottomFirst:
return kImageFieldLowerStr;
case VideoParams::k_interlace_none:
return k_image_field_none_str;
case VideoParams::k_interlaced_top_first:
return k_image_field_upper_str;
case VideoParams::k_interlaced_bottom_first:
return k_image_field_lower_str;
}
return kImageFieldNoneStr;
return k_image_field_none_str;
}
class DeferredRedoCommand : public UndoCommand {
@@ -96,9 +96,9 @@ public:
delete inner_;
}
Project *GetRelevantProject() const override
Project *get_relevant_project() const override
{
return inner_ ? inner_->GetRelevantProject() : nullptr;
return inner_ ? inner_->get_relevant_project() : nullptr;
}
protected:
@@ -125,24 +125,24 @@ private:
bool skip_first_redo_ = true;
};
ViewerOutput *GetActiveViewerOutput()
ViewerOutput *get_active_viewer_output()
{
PanelManager *manager = PanelManager::instance();
if (!manager) {
return nullptr;
}
if (auto *time_panel = manager->MostRecentlyFocused<TimeBasedPanel>()) {
if (time_panel->GetConnectedViewer()) {
return time_panel->GetConnectedViewer();
if (auto *time_panel = manager->most_recently_focused<TimeBasedPanel>()) {
if (time_panel->get_connected_viewer()) {
return time_panel->get_connected_viewer();
}
}
QList<TimelinePanel *> timelines =
manager->GetPanelsOfType<TimelinePanel>();
manager->get_panels_of_type<TimelinePanel>();
for (TimelinePanel *panel : timelines) {
if (panel && panel->GetConnectedViewer()) {
return panel->GetConnectedViewer();
if (panel && panel->get_connected_viewer()) {
return panel->get_connected_viewer();
}
}
@@ -152,7 +152,7 @@ ViewerOutput *GetActiveViewerOutput()
const std::string &OlivePluginInstance::getDefaultOutputFielding() const
{
return FieldOrderForParams(params_);
return field_order_for_params(params_);
}
void OlivePluginInstance::setNode(std::shared_ptr<PluginNode> node)
@@ -163,7 +163,7 @@ void OlivePluginInstance::setNode(std::shared_ptr<PluginNode> node)
continue;
}
if (auto *bound = dynamic_cast<NodeBoundParam *>(entry.second)) {
bound->SetNode(node_);
bound->set_node(node_);
}
}
}
@@ -171,7 +171,7 @@ void OlivePluginInstance::setNode(std::shared_ptr<PluginNode> node)
OfxStatus OlivePluginInstance::vmessage(const char *type, const char *id,
const char *format, va_list args)
{
const QString message = FormatOfxMessage(format, args);
const QString message = format_ofx_message(format, args);
if (message.isEmpty()) {
return kOfxStatFailed;
}
@@ -191,7 +191,7 @@ OfxStatus OlivePluginInstance::vmessage(const char *type, const char *id,
}
};
if (IsGuiThread()) {
if (is_gui_thread()) {
show_message();
} else if (auto *app = QCoreApplication::instance()) {
if (is_question) {
@@ -211,7 +211,7 @@ OfxStatus OlivePluginInstance::setPersistentMessage(const char *type,
const char *format,
va_list args)
{
const QString message = FormatOfxMessage(format, args);
const QString message = format_ofx_message(format, args);
if (message.isEmpty()) {
return kOfxStatFailed;
}
@@ -219,17 +219,17 @@ OfxStatus OlivePluginInstance::setPersistentMessage(const char *type,
ErrorType error_type;
// If This is a error message
if (strncmp(type, kOfxMessageError, strlen(kOfxMessageError)) == 0) {
error_type = ErrorType::Error;
error_type = ErrorType::error;
}
// A warning
else if (strncmp(type, kOfxMessageWarning, strlen(kOfxMessageWarning)) ==
0) {
error_type = ErrorType::Warning;
error_type = ErrorType::warning;
}
// A simple information
else if (strncmp(type, kOfxMessageMessage, strlen(kOfxMessageMessage)) ==
0) {
error_type = ErrorType::Message;
error_type = ErrorType::message;
} else {
return kOfxStatFailed;
}
@@ -237,22 +237,22 @@ OfxStatus OlivePluginInstance::setPersistentMessage(const char *type,
auto update_ui = [this, error_type, message]() {
persistentErrors_.append({ error_type, message });
switch (error_type) {
case ErrorType::Error:
case ErrorType::error:
QMessageBox::critical(nullptr, "", message);
break;
case ErrorType::Warning:
case ErrorType::warning:
QMessageBox::warning(nullptr, "", message);
break;
case ErrorType::Message:
case ErrorType::message:
QMessageBox::information(nullptr, "", message);
break;
}
if (node_) {
emit node_->MessageCountChanged();
emit node_->message_count_changed();
}
};
if (IsGuiThread()) {
if (is_gui_thread()) {
update_ui();
} else if (auto *app = QCoreApplication::instance()) {
QMetaObject::invokeMethod(app, update_ui, Qt::QueuedConnection);
@@ -265,38 +265,38 @@ OfxStatus OlivePluginInstance::clearPersistentMessage()
persistentErrors_.clear();
// TODO: tell the shell to remove message.
if (node_) {
emit node_->MessageCountChanged();
emit node_->message_count_changed();
}
};
if (IsGuiThread()) {
if (is_gui_thread()) {
clear_ui();
} else if (auto *app = QCoreApplication::instance()) {
QMetaObject::invokeMethod(app, clear_ui, Qt::QueuedConnection);
}
return kOfxStatOK;
}
void OlivePluginInstance::getProjectSize(double &xSize, double &ySize) const
void OlivePluginInstance::getProjectSize(double &x_size, double &y_size) const
{
double par = params_.pixel_aspect_ratio().toDouble();
xSize = params_.width() * par;
ySize = params_.height();
double par = params_.pixel_aspect_ratio().to_double();
x_size = params_.width() * par;
y_size = params_.height();
}
void OlivePluginInstance::getProjectOffset(double &xOffset,
double &yOffset) const
void OlivePluginInstance::getProjectOffset(double &x_offset,
double &y_offset) const
{
double par = params_.pixel_aspect_ratio().toDouble();
xOffset = params_.x() * par;
yOffset = params_.y();
double par = params_.pixel_aspect_ratio().to_double();
x_offset = params_.x() * par;
y_offset = params_.y();
}
void OlivePluginInstance::getProjectExtent(double &xSize, double &ySize) const
void OlivePluginInstance::getProjectExtent(double &x_size, double &y_size) const
{
double par = params_.pixel_aspect_ratio().toDouble();
xSize = params_.width() * par;
ySize = params_.height();
double par = params_.pixel_aspect_ratio().to_double();
x_size = params_.width() * par;
y_size = params_.height();
}
double OlivePluginInstance::getProjectPixelAspectRatio() const
{
double par = params_.pixel_aspect_ratio().toDouble();
double par = params_.pixel_aspect_ratio().to_double();
if (par == 0.0) {
return 1.0; // default PAR when not explicitly set
}
@@ -304,7 +304,7 @@ double OlivePluginInstance::getProjectPixelAspectRatio() const
}
double OlivePluginInstance::getFrameRate() const
{
return params_.frame_rate().toDouble();
return params_.frame_rate().to_double();
}
double OlivePluginInstance::getEffectDuration() const
@@ -410,7 +410,7 @@ OfxStatus OlivePluginInstance::editEnd()
return kOfxStatOK;
}
void OlivePluginInstance::SubmitUndoCommand(UndoCommand *command,
void OlivePluginInstance::submit_undo_command(UndoCommand *command,
const QString &label)
{
if (!command) {
@@ -431,7 +431,7 @@ void OlivePluginInstance::SubmitUndoCommand(UndoCommand *command,
return;
}
if (!IsGuiThread()) {
if (!is_gui_thread()) {
command->redo_now();
delete command;
return;
@@ -463,7 +463,7 @@ void OlivePluginInstance::progressStart(const std::string &message,
progress_dialog_ = new ::olive::ProgressDialog(
dialog_message, QStringLiteral("OpenFX"), nullptr);
progress_dialog_->setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(progress_dialog_, &::olive::ProgressDialog::Cancelled,
QObject::connect(progress_dialog_, &::olive::ProgressDialog::cancelled,
progress_dialog_,
[this]() { progress_cancelled_ = true; });
progress_dialog_->show();
@@ -488,7 +488,7 @@ bool OlivePluginInstance::progressUpdate(double t)
if (progress_dialog_) {
double clamped = qBound(0.0, t, 1.0);
progress_dialog_->SetProgress(clamped);
progress_dialog_->set_progress(clamped);
}
return !progress_cancelled_;
@@ -514,8 +514,8 @@ OfxStatus OlivePluginInstance::contextDetachedAction()
double OlivePluginInstance::timeLineGetTime()
{
if (ViewerOutput *viewer = GetActiveViewerOutput()) {
return viewer->GetPlayhead().toDouble();
if (ViewerOutput *viewer = get_active_viewer_output()) {
return viewer->get_playhead().to_double();
}
return 0.0;
@@ -523,16 +523,16 @@ double OlivePluginInstance::timeLineGetTime()
void OlivePluginInstance::timeLineGotoTime(double t)
{
if (ViewerOutput *viewer = GetActiveViewerOutput()) {
viewer->SetPlayhead(olive::core::rational::fromDouble(t));
if (ViewerOutput *viewer = get_active_viewer_output()) {
viewer->set_playhead(olive::core::Rational::from_double(t));
}
}
void OlivePluginInstance::timeLineGetBounds(double &t1, double &t2)
{
if (ViewerOutput *viewer = GetActiveViewerOutput()) {
if (ViewerOutput *viewer = get_active_viewer_output()) {
t1 = 0.0;
t2 = viewer->GetLength().toDouble();
t2 = viewer->get_length().to_double();
return;
}
@@ -541,12 +541,12 @@ void OlivePluginInstance::timeLineGetBounds(double &t1, double &t2)
}
void OlivePluginInstance::setCustomInArgs(const std::string &action,
OFX::Host::Property::Set &inArgs)
OFX::Host::Property::Set &in_args)
{
if (action == kOfxImageEffectActionRender ||
action == kOfxImageEffectActionBeginSequenceRender ||
action == kOfxImageEffectActionEndSequenceRender) {
inArgs.setIntProperty(kOfxImageEffectPropOpenGLEnabled,
in_args.setIntProperty(kOfxImageEffectPropOpenGLEnabled,
open_gl_enabled_ ? 1 : 0);
}
}
@@ -556,7 +556,7 @@ OFX::Host::ImageEffect::ClipInstance *OlivePluginInstance::newClipInstance(
OFX::Host::ImageEffect::ClipDescriptor *descriptor, int index)
{
// Create a new clip instance
OliveClipInstance *clipInstance =
OliveClipInstance *clip_instance =
new OliveClipInstance(plugin, *descriptor, params_);
// Initialize base class clip properties from VideoParams so that
@@ -567,16 +567,16 @@ OFX::Host::ImageEffect::ClipInstance *OlivePluginInstance::newClipInstance(
std::string comp = kOfxImageComponentRGBA; // host default
switch (params_.format()) {
case core::PixelFormat::U8:
case core::PixelFormat::u8:
depth = kOfxBitDepthByte;
break;
case core::PixelFormat::U16:
case core::PixelFormat::u16:
depth = kOfxBitDepthShort;
break;
case core::PixelFormat::F16:
case core::PixelFormat::f16:
depth = kOfxBitDepthHalf;
break;
case core::PixelFormat::F32:
case core::PixelFormat::f32:
depth = kOfxBitDepthFloat;
break;
default:
@@ -597,10 +597,10 @@ OFX::Host::ImageEffect::ClipInstance *OlivePluginInstance::newClipInstance(
break; // keep RGBA default
}
clipInstance->setPixelDepth(depth);
clipInstance->setComponents(comp);
clip_instance->setPixelDepth(depth);
clip_instance->setComponents(comp);
return clipInstance;
return clip_instance;
}
OlivePluginInstance::~OlivePluginInstance()
@@ -15,13 +15,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OLIVE_INSTANCE_H
#define OLIVE_INSTANCE_H
#ifndef OAK_OLIVE_INSTANCE_H
#define OAK_OLIVE_INSTANCE_H
#include "ofxCore.h"
#include "ofxImageEffect.h"
#include <QString>
#include "ofxhImageEffect.h"
#include "node/plugins/Plugin.h"
#include "node/plugins/plugin.h"
#include "render/videoparams.h"
#include "undo/undocommand.h"
@@ -36,7 +36,7 @@
namespace olive
{
inline bool IsGuiThread()
inline bool is_gui_thread()
{
if (auto *app = QCoreApplication::instance()) {
return QThread::currentThread() == app->thread();
@@ -47,7 +47,7 @@ class ProgressDialog;
namespace plugin
{
class PluginNode;
enum class ErrorType { Error, Warning, Message };
enum class ErrorType { error, warning, message };
struct PersistentErrors {
ErrorType type;
QString message;
@@ -108,18 +108,18 @@ public:
const char *format, va_list args) override;
OfxStatus clearPersistentMessage() override;
int persistentMessageCount() const
int persistent_message_count() const
{
return persistentErrors_.size();
}
const QList<PersistentErrors> &persistentMessages() const
const QList<PersistentErrors> &persistent_messages() const
{
return persistentErrors_;
}
void getProjectSize(double &xSize, double &ySize) const override;
void getProjectOffset(double &xOffset, double &yOffset) const override;
void getProjectExtent(double &xSize, double &ySize) const override;
void getProjectSize(double &x_size, double &y_size) const override;
void getProjectOffset(double &x_offset, double &y_offset) const override;
void getProjectExtent(double &x_size, double &y_size) const override;
// The pixel aspect ratio of the current project
double getProjectPixelAspectRatio() const override;
@@ -148,9 +148,9 @@ public:
/// Client host code needs to implement this
OFX::Host::Param::Instance *
newParam(const std::string &name,
OFX::Host::Param::Descriptor &Descriptor) override;
OFX::Host::Param::Descriptor &descriptor) override;
void SubmitUndoCommand(UndoCommand *command, const QString &label);
void submit_undo_command(UndoCommand *command, const QString &label);
/// Triggered when the plug-in calls OfxParameterSuiteV1::paramEditBegin
///
@@ -203,7 +203,7 @@ public:
virtual void timeLineGetBounds(double &t1, double &t2);
void setCustomInArgs(const std::string &action,
OFX::Host::Property::Set &inArgs) override;
OFX::Host::Property::Set &in_args) override;
private:
QList<PersistentErrors> persistentErrors_;
+4 -4
View File
@@ -19,13 +19,13 @@
#include "paraminstance.h"
#include "OlivePluginInstance.h"
#include "oliveplugininstance.h"
namespace olive
{
namespace plugin
{
void SubmitUndoCommand(const std::shared_ptr<PluginNode> &node,
void submit_undo_command(const std::shared_ptr<PluginNode> &node,
UndoCommand *command, const QString &label)
{
if (!command) {
@@ -36,12 +36,12 @@ void SubmitUndoCommand(const std::shared_ptr<PluginNode> &node,
auto *instance = node->getPluginInstance();
auto *olive_instance = dynamic_cast<OlivePluginInstance *>(instance);
if (olive_instance) {
olive_instance->SubmitUndoCommand(command, label);
olive_instance->submit_undo_command(command, label);
return;
}
}
if (!IsGuiThread()) {
if (!is_gui_thread()) {
command->redo_now();
delete command;
return;
File diff suppressed because it is too large Load Diff