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.
249 lines
5.2 KiB
C++
249 lines
5.2 KiB
C++
/***
|
|
|
|
Olive - Non-Linear Video Editor
|
|
Copyright (C) 2022 Olive Team
|
|
Modifications Copyright (C) 2025 mikesolar
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
***/
|
|
|
|
#include "internal.h"
|
|
|
|
#include <string.h>
|
|
|
|
FBFrame *fb_frame_alloc(void)
|
|
{
|
|
AVFrame *avf = av_frame_alloc();
|
|
if (!avf) {
|
|
return nullptr;
|
|
}
|
|
|
|
FBFrame *f = new FBFrame;
|
|
f->frame = avf;
|
|
return f;
|
|
}
|
|
|
|
void fb_frame_free(FBFrame **frame)
|
|
{
|
|
if (frame && *frame) {
|
|
av_frame_free(&(*frame)->frame);
|
|
delete *frame;
|
|
*frame = nullptr;
|
|
}
|
|
}
|
|
|
|
void fb_frame_unref(FBFrame *frame)
|
|
{
|
|
if (frame && frame->frame) {
|
|
av_frame_unref(frame->frame);
|
|
}
|
|
}
|
|
|
|
int fb_frame_get_buffer(FBFrame *frame, int align)
|
|
{
|
|
if (!frame || !frame->frame) {
|
|
return AVERROR(EINVAL);
|
|
}
|
|
return av_frame_get_buffer(frame->frame, align);
|
|
}
|
|
|
|
int fb_frame_make_writable(FBFrame *frame)
|
|
{
|
|
if (!frame || !frame->frame) {
|
|
return AVERROR(EINVAL);
|
|
}
|
|
return av_frame_make_writable(frame->frame);
|
|
}
|
|
|
|
int fb_frame_copy_props(FBFrame *dst, const FBFrame *src)
|
|
{
|
|
if (!dst || !src) {
|
|
return AVERROR(EINVAL);
|
|
}
|
|
return av_frame_copy_props(dst->frame, src->frame);
|
|
}
|
|
|
|
int fb_frame_hw_transfer_data(FBFrame *dst, const FBFrame *src)
|
|
{
|
|
if (!dst || !src) {
|
|
return AVERROR(EINVAL);
|
|
}
|
|
return av_hwframe_transfer_data(dst->frame, src->frame, 0);
|
|
}
|
|
|
|
int fb_frame_is_hw(const FBFrame *frame)
|
|
{
|
|
return frame && frame->frame && frame->frame->hw_frames_ctx != nullptr;
|
|
}
|
|
|
|
int fb_frame_get_width(const FBFrame *frame)
|
|
{
|
|
return frame ? frame->frame->width : 0;
|
|
}
|
|
|
|
void fb_frame_set_width(FBFrame *frame, int width)
|
|
{
|
|
if (frame) {
|
|
frame->frame->width = width;
|
|
}
|
|
}
|
|
|
|
int fb_frame_get_height(const FBFrame *frame)
|
|
{
|
|
return frame ? frame->frame->height : 0;
|
|
}
|
|
|
|
void fb_frame_set_height(FBFrame *frame, int height)
|
|
{
|
|
if (frame) {
|
|
frame->frame->height = height;
|
|
}
|
|
}
|
|
|
|
int fb_frame_get_format(const FBFrame *frame)
|
|
{
|
|
return frame ? fb::pix_fmt_from_av(AVPixelFormat(frame->frame->format)) :
|
|
fb_pix_fmt_none;
|
|
}
|
|
|
|
void fb_frame_set_format(FBFrame *frame, int format)
|
|
{
|
|
if (frame) {
|
|
frame->frame->format = fb::pix_fmt_to_av(format);
|
|
}
|
|
}
|
|
|
|
int64_t fb_frame_get_pts(const FBFrame *frame)
|
|
{
|
|
return frame ? frame->frame->pts : FB_NOPTS_VALUE;
|
|
}
|
|
|
|
void fb_frame_set_pts(FBFrame *frame, int64_t pts)
|
|
{
|
|
if (frame) {
|
|
frame->frame->pts = pts;
|
|
}
|
|
}
|
|
|
|
int64_t fb_frame_get_best_effort_timestamp(const FBFrame *frame)
|
|
{
|
|
return frame ? frame->frame->best_effort_timestamp : FB_NOPTS_VALUE;
|
|
}
|
|
|
|
int fb_frame_get_nb_samples(const FBFrame *frame)
|
|
{
|
|
return frame ? frame->frame->nb_samples : 0;
|
|
}
|
|
|
|
void fb_frame_set_nb_samples(FBFrame *frame, int nb_samples)
|
|
{
|
|
if (frame) {
|
|
frame->frame->nb_samples = nb_samples;
|
|
}
|
|
}
|
|
|
|
int fb_frame_get_sample_rate(const FBFrame *frame)
|
|
{
|
|
return frame ? frame->frame->sample_rate : 0;
|
|
}
|
|
|
|
void fb_frame_set_sample_rate(FBFrame *frame, int sample_rate)
|
|
{
|
|
if (frame) {
|
|
frame->frame->sample_rate = sample_rate;
|
|
}
|
|
}
|
|
|
|
int fb_frame_get_color_range(const FBFrame *frame)
|
|
{
|
|
return frame ? int(frame->frame->color_range) : fb_color_range_unspec;
|
|
}
|
|
|
|
void fb_frame_set_color_range(FBFrame *frame, int color_range)
|
|
{
|
|
if (frame) {
|
|
frame->frame->color_range = static_cast<AVColorRange>(color_range);
|
|
}
|
|
}
|
|
|
|
int fb_frame_get_colorspace(const FBFrame *frame)
|
|
{
|
|
return frame ? int(frame->frame->colorspace) : fb_col_spc_unspec;
|
|
}
|
|
|
|
void fb_frame_set_colorspace(FBFrame *frame, int colorspace)
|
|
{
|
|
if (frame) {
|
|
frame->frame->colorspace = static_cast<AVColorSpace>(colorspace);
|
|
}
|
|
}
|
|
|
|
uint64_t fb_frame_get_channel_layout_mask(const FBFrame *frame)
|
|
{
|
|
if (!frame) {
|
|
return 0;
|
|
}
|
|
if (frame->frame->ch_layout.order == AV_CHANNEL_ORDER_NATIVE) {
|
|
return frame->frame->ch_layout.u.mask;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void fb_frame_set_channel_layout_mask(FBFrame *frame, uint64_t mask)
|
|
{
|
|
if (frame) {
|
|
av_channel_layout_uninit(&frame->frame->ch_layout);
|
|
av_channel_layout_from_mask(&frame->frame->ch_layout, mask);
|
|
}
|
|
}
|
|
|
|
uint8_t *fb_frame_get_data(FBFrame *frame, int plane)
|
|
{
|
|
if (!frame || plane < 0 || plane >= AV_NUM_DATA_POINTERS) {
|
|
return nullptr;
|
|
}
|
|
return frame->frame->data[plane];
|
|
}
|
|
|
|
const uint8_t *fb_frame_get_data_const(const FBFrame *frame, int plane)
|
|
{
|
|
if (!frame || plane < 0 || plane >= AV_NUM_DATA_POINTERS) {
|
|
return nullptr;
|
|
}
|
|
return frame->frame->data[plane];
|
|
}
|
|
|
|
void fb_frame_set_data(FBFrame *frame, int plane, uint8_t *data)
|
|
{
|
|
if (frame && plane >= 0 && plane < AV_NUM_DATA_POINTERS) {
|
|
frame->frame->data[plane] = data;
|
|
}
|
|
}
|
|
|
|
int fb_frame_get_linesize(const FBFrame *frame, int plane)
|
|
{
|
|
if (!frame || plane < 0 || plane >= AV_NUM_DATA_POINTERS) {
|
|
return 0;
|
|
}
|
|
return frame->frame->linesize[plane];
|
|
}
|
|
|
|
void fb_frame_set_linesize(FBFrame *frame, int plane, int linesize)
|
|
{
|
|
if (frame && plane >= 0 && plane < AV_NUM_DATA_POINTERS) {
|
|
frame->frame->linesize[plane] = linesize;
|
|
}
|
|
}
|