refactor(node): de-Qt oaknode and wrap it in a pure C ABI

- copy engine/node (188 files) to src/node/src, de-Qt in waves:
  core infra (Node/Param/Value/Variant/mathtypes), project/serializer,
  block/output, color, effect leaves, generator, gizmo/plugins
- strip QObject/signals/slots: notifications move to the facade's
  oakengine_event channel, ownership becomes explicit (unique_ptr,
  add_keyframe/add_gizmo), sender() replaced by current_gizmo
- QVariant replaced by olive::Variant, Qt math types by POD mathtypes,
  QXmlStreamReader/Writer by oakcommon's expat-based classes
- sink VideoParams/SubtitleParams/LoopMode/ColorTransform to oakcommon
  (M3.5); polygon/text rasterization behind backend hooks
- pure C ABI in include/node + src/node/c_api (oaknode_ prefix,
  OAKNODE_E_* codes, undoable variants take OakUndoCommand out-params)
- fix Project::clear() root_ reset + disconnect assert, Sequence
  TrackList leak
- 96 gtest cases green in standalone build (build-oaknode)
- docs: signal/slot handling strategy + M3 implementation status
This commit is contained in:
2026-08-05 23:55:54 +08:00
parent c50017127b
commit d77348ad9f
375 changed files with 59682 additions and 1 deletions
+109
View File
@@ -0,0 +1,109 @@
/***
Oak Video Editor - Non-Linear Video Editor
Copyright (C) 2026 Oak Team
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/>.
***/
#ifndef OAK_EDITOR_COLORTRANSFORM_H
#define OAK_EDITOR_COLORTRANSFORM_H
#include "common/error.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Opaque handle to a color transform description
* (olive::ColorTransform).
*/
typedef struct OakCommonColorTransform OakCommonColorTransform;
/**
* @brief Create a plain output-colorspace transform.
*
* @param output Output colorspace name. Must not be NULL.
* @return Transform handle, or NULL on failure.
*/
OakCommonColorTransform *oakcommon_colortransform_init_output(
const char *output);
/**
* @brief Create a display/view/look transform.
*
* All three strings must not be NULL.
*
* @return Transform handle, or NULL on failure.
*/
OakCommonColorTransform *oakcommon_colortransform_init_display(
const char *display, const char *view, const char *look);
/**
* @brief Destroy a transform. No-op on NULL.
*/
void oakcommon_colortransform_free(OakCommonColorTransform *transform);
/**
* @brief Query whether this is a display/view/look transform.
*
* @param is_display Receives the result. Must not be NULL.
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_colortransform_is_display(OakCommonColorTransform *transform,
int *is_display);
/**
* @brief Get the display name (two-stage string getter).
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_colortransform_get_display(OakCommonColorTransform *transform,
char *buf, int buf_size);
/**
* @brief Get the output colorspace name (two-stage string getter).
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_colortransform_get_output(OakCommonColorTransform *transform,
char *buf, int buf_size);
/**
* @brief Get the view name (two-stage string getter).
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_colortransform_get_view(OakCommonColorTransform *transform,
char *buf, int buf_size);
/**
* @brief Get the look name (two-stage string getter).
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_colortransform_get_look(OakCommonColorTransform *transform,
char *buf, int buf_size);
#ifdef __cplusplus
}
#endif
#endif //OAK_EDITOR_COLORTRANSFORM_H
+44
View File
@@ -0,0 +1,44 @@
/***
Oak Video Editor - Non-Linear Video Editor
Copyright (C) 2026 Oak Team
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/>.
***/
#ifndef OAK_EDITOR_LOOPMODE_H
#define OAK_EDITOR_LOOPMODE_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Playback loop mode, mirroring olive::LoopMode.
*
* The numeric values must stay in sync with src/common/src/loopmode.h.
* Pure enum: no functions are needed.
*/
enum OakCommonLoopMode {
OAKCOMMON_LOOP_MODE_OFF = 0, /**< Looping disabled. */
OAKCOMMON_LOOP_MODE_LOOP = 1, /**< Loop playback. */
OAKCOMMON_LOOP_MODE_CLAMP = 2 /**< Clamp at the end. */
};
#ifdef __cplusplus
}
#endif
#endif //OAK_EDITOR_LOOPMODE_H
+140
View File
@@ -0,0 +1,140 @@
/***
Oak Video Editor - Non-Linear Video Editor
Copyright (C) 2026 Oak Team
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/>.
***/
#ifndef OAK_EDITOR_SUBTITLEPARAMS_H
#define OAK_EDITOR_SUBTITLEPARAMS_H
#include "common/error.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Opaque handle to a subtitle parameter set (olive::SubtitleParams).
*/
typedef struct OakCommonSubtitleParams OakCommonSubtitleParams;
/**
* @brief Create an empty subtitle parameter set.
*
* @return Params handle, or NULL on allocation failure.
*/
OakCommonSubtitleParams *oakcommon_subtitleparams_init(void);
/**
* @brief Destroy a subtitle parameter set. No-op on NULL.
*/
void oakcommon_subtitleparams_free(OakCommonSubtitleParams *params);
int oakcommon_subtitleparams_get_stream_index(
OakCommonSubtitleParams *params, int *index);
int oakcommon_subtitleparams_set_stream_index(
OakCommonSubtitleParams *params, int index);
int oakcommon_subtitleparams_get_enabled(OakCommonSubtitleParams *params,
int *enabled);
int oakcommon_subtitleparams_set_enabled(OakCommonSubtitleParams *params,
int enabled);
/**
* @brief Query whether the set contains at least one subtitle.
*/
int oakcommon_subtitleparams_is_valid(OakCommonSubtitleParams *params,
int *is_valid);
/**
* @brief Number of subtitle entries.
*/
int oakcommon_subtitleparams_count(OakCommonSubtitleParams *params,
int *count);
/**
* @brief Out time of the last subtitle (0/1 when empty).
*/
int oakcommon_subtitleparams_duration(OakCommonSubtitleParams *params,
int *numerator, int *denominator);
/**
* @brief Append a subtitle entry.
*
* @param text Subtitle text. Must not be NULL.
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_subtitleparams_add_subtitle(OakCommonSubtitleParams *params,
int in_num, int in_den, int out_num,
int out_den, const char *text);
/**
* @brief Remove all subtitle entries.
*/
int oakcommon_subtitleparams_clear(OakCommonSubtitleParams *params);
/**
* @brief Get the time range of the subtitle at @p index.
*
* @return OAKCOMMON_OK, OAKCOMMON_E_NOT_FOUND if @p index is out of range,
* or another negative OAKCOMMON_E_* error code.
*/
int oakcommon_subtitleparams_get_subtitle(OakCommonSubtitleParams *params,
int index, int *in_num, int *in_den,
int *out_num, int *out_den);
/**
* @brief Get the text of the subtitle at @p index (two-stage string getter).
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), OAKCOMMON_E_NOT_FOUND if @p index is out of
* range, or another negative OAKCOMMON_E_* error code.
*/
int oakcommon_subtitleparams_get_subtitle_text(OakCommonSubtitleParams *params,
int index, char *buf,
int buf_size);
/**
* @brief Generate a default ASS header (static, no handle required).
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_subtitleparams_generate_ass_header(char *buf, int buf_size);
/**
* @brief Load subtitles from an XML fragment.
*
* @param xml NUL-terminated XML text. Must not be NULL.
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_subtitleparams_load_xml(OakCommonSubtitleParams *params,
const char *xml);
/**
* @brief Save subtitles to an XML fragment (two-stage string getter).
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_subtitleparams_save_xml(OakCommonSubtitleParams *params,
char *buf, int buf_size);
#ifdef __cplusplus
}
#endif
#endif //OAK_EDITOR_SUBTITLEPARAMS_H
+301
View File
@@ -0,0 +1,301 @@
/***
Oak Video Editor - Non-Linear Video Editor
Copyright (C) 2026 Oak Team
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/>.
***/
#ifndef OAK_EDITOR_VIDEOPARAMS_H
#define OAK_EDITOR_VIDEOPARAMS_H
#ifndef __cplusplus
#include <stdbool.h>
#endif
#include <stdint.h>
#include "common/error.h"
#include "common/ocioutils.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Opaque handle to a video parameter set (olive::VideoParams).
*/
typedef struct OakCommonVideoParams OakCommonVideoParams;
/**
* @brief Interlacing modes, mirroring olive::VideoParams::Interlacing.
*/
enum OakCommonVideoInterlacing {
OAKCOMMON_VIDEO_INTERLACE_NONE = 0,
OAKCOMMON_VIDEO_INTERLACED_TOP_FIRST = 1,
OAKCOMMON_VIDEO_INTERLACED_BOTTOM_FIRST = 2
};
/**
* @brief Video stream types, mirroring olive::VideoParams::Type.
*/
enum OakCommonVideoType {
OAKCOMMON_VIDEO_TYPE_VIDEO = 0,
OAKCOMMON_VIDEO_TYPE_STILL = 1,
OAKCOMMON_VIDEO_TYPE_IMAGE_SEQUENCE = 2
};
/**
* @brief Color range codes, mirroring olive::VideoParams::ColorRange.
*/
enum OakCommonVideoColorRange {
OAKCOMMON_COLOR_RANGE_LIMITED = 0, /**< 16-235 */
OAKCOMMON_COLOR_RANGE_FULL = 1 /**< 0-255 */
};
/**
* @brief Create a default (invalid) video parameter set.
*
* @return Params handle, or NULL on allocation failure.
*/
OakCommonVideoParams *oakcommon_videoparams_init(void);
/**
* @brief Create a video parameter set without a time base.
*
* @param pixel_format One of the OakCommonPixelFormat values.
* @return Params handle, or NULL on allocation failure.
*/
OakCommonVideoParams *oakcommon_videoparams_init_basic(
int width, int height, int pixel_format, int nb_channels,
int pixel_aspect_num, int pixel_aspect_den, int interlacing, int divider);
/**
* @brief Create a video parameter set with a time base.
*
* The frame rate is derived as the flipped time base.
*
* @param pixel_format One of the OakCommonPixelFormat values.
* @return Params handle, or NULL on allocation failure.
*/
OakCommonVideoParams *oakcommon_videoparams_init_with_time_base(
int width, int height, int time_base_num, int time_base_den,
int pixel_format, int nb_channels, int pixel_aspect_num,
int pixel_aspect_den, int interlacing, int divider);
/**
* @brief Destroy a video parameter set. No-op on NULL.
*/
void oakcommon_videoparams_free(OakCommonVideoParams *params);
int oakcommon_videoparams_get_width(OakCommonVideoParams *params, int *width);
int oakcommon_videoparams_set_width(OakCommonVideoParams *params, int width);
int oakcommon_videoparams_get_height(OakCommonVideoParams *params, int *height);
int oakcommon_videoparams_set_height(OakCommonVideoParams *params, int height);
int oakcommon_videoparams_get_depth(OakCommonVideoParams *params, int *depth);
int oakcommon_videoparams_set_depth(OakCommonVideoParams *params, int depth);
int oakcommon_videoparams_get_is_3d(OakCommonVideoParams *params, int *is_3d);
/**
* @brief Rational getters return the value as a numerator/denominator pair.
*/
int oakcommon_videoparams_get_time_base(OakCommonVideoParams *params,
int *numerator, int *denominator);
int oakcommon_videoparams_set_time_base(OakCommonVideoParams *params,
int numerator, int denominator);
int oakcommon_videoparams_get_frame_rate(OakCommonVideoParams *params,
int *numerator, int *denominator);
int oakcommon_videoparams_set_frame_rate(OakCommonVideoParams *params,
int numerator, int denominator);
int oakcommon_videoparams_frame_rate_as_time_base(OakCommonVideoParams *params,
int *numerator,
int *denominator);
int oakcommon_videoparams_get_pixel_aspect_ratio(OakCommonVideoParams *params,
int *numerator,
int *denominator);
int oakcommon_videoparams_set_pixel_aspect_ratio(OakCommonVideoParams *params,
int numerator, int denominator);
/**
* @brief Format getters/setters use the OakCommonPixelFormat codes.
*/
int oakcommon_videoparams_get_format(OakCommonVideoParams *params, int *format);
int oakcommon_videoparams_set_format(OakCommonVideoParams *params, int format);
int oakcommon_videoparams_get_channel_count(OakCommonVideoParams *params,
int *count);
int oakcommon_videoparams_set_channel_count(OakCommonVideoParams *params,
int count);
int oakcommon_videoparams_get_interlacing(OakCommonVideoParams *params,
int *interlacing);
int oakcommon_videoparams_set_interlacing(OakCommonVideoParams *params,
int interlacing);
int oakcommon_videoparams_get_divider(OakCommonVideoParams *params,
int *divider);
int oakcommon_videoparams_set_divider(OakCommonVideoParams *params,
int divider);
int oakcommon_videoparams_get_enabled(OakCommonVideoParams *params,
int *enabled);
int oakcommon_videoparams_set_enabled(OakCommonVideoParams *params,
int enabled);
int oakcommon_videoparams_get_x(OakCommonVideoParams *params, float *x);
int oakcommon_videoparams_set_x(OakCommonVideoParams *params, float x);
int oakcommon_videoparams_get_y(OakCommonVideoParams *params, float *y);
int oakcommon_videoparams_set_y(OakCommonVideoParams *params, float y);
int oakcommon_videoparams_get_stream_index(OakCommonVideoParams *params,
int *index);
int oakcommon_videoparams_set_stream_index(OakCommonVideoParams *params,
int index);
int oakcommon_videoparams_get_video_type(OakCommonVideoParams *params,
int *type);
int oakcommon_videoparams_set_video_type(OakCommonVideoParams *params,
int type);
int oakcommon_videoparams_get_start_time(OakCommonVideoParams *params,
int64_t *start_time);
int oakcommon_videoparams_set_start_time(OakCommonVideoParams *params,
int64_t start_time);
int oakcommon_videoparams_get_duration(OakCommonVideoParams *params,
int64_t *duration);
int oakcommon_videoparams_set_duration(OakCommonVideoParams *params,
int64_t duration);
int oakcommon_videoparams_get_premultiplied_alpha(OakCommonVideoParams *params,
int *premultiplied);
int oakcommon_videoparams_set_premultiplied_alpha(OakCommonVideoParams *params,
int premultiplied);
int oakcommon_videoparams_get_color_range(OakCommonVideoParams *params,
int *color_range);
int oakcommon_videoparams_set_color_range(OakCommonVideoParams *params,
int color_range);
int oakcommon_videoparams_get_color_primaries(OakCommonVideoParams *params,
int *primaries);
int oakcommon_videoparams_set_color_primaries(OakCommonVideoParams *params,
int primaries);
int oakcommon_videoparams_get_color_transfer(OakCommonVideoParams *params,
int *transfer);
int oakcommon_videoparams_set_color_transfer(OakCommonVideoParams *params,
int transfer);
/**
* @brief Get the colorspace name (two-stage string getter).
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_videoparams_get_colorspace(OakCommonVideoParams *params,
char *buf, int buf_size);
int oakcommon_videoparams_set_colorspace(OakCommonVideoParams *params,
const char *colorspace);
/**
* @brief Width multiplied by the pixel aspect ratio.
*/
int oakcommon_videoparams_get_square_pixel_width(OakCommonVideoParams *params,
int *width);
int oakcommon_videoparams_get_effective_width(OakCommonVideoParams *params,
int *width);
int oakcommon_videoparams_get_effective_height(OakCommonVideoParams *params,
int *height);
int oakcommon_videoparams_get_effective_depth(OakCommonVideoParams *params,
int *depth);
int oakcommon_videoparams_get_is_valid(OakCommonVideoParams *params,
int *is_valid);
int oakcommon_videoparams_get_bytes_per_channel(OakCommonVideoParams *params,
int *bytes);
int oakcommon_videoparams_get_bytes_per_pixel(OakCommonVideoParams *params,
int *bytes);
int oakcommon_videoparams_get_buffer_size(OakCommonVideoParams *params,
int *size);
/**
* @brief Convert a time (in seconds, as a rational) to time base units.
*
* Returns INT64_MIN (AV_NOPTS_VALUE) in @p timestamp when no time base is
* set.
*/
int oakcommon_videoparams_get_time_in_timebase_units(
OakCommonVideoParams *params, int time_num, int time_den,
int64_t *timestamp);
/**
* @brief Compare two parameter sets for equality.
*/
int oakcommon_videoparams_equals(OakCommonVideoParams *params,
OakCommonVideoParams *other, int *equal);
/**
* @brief Load parameters from an XML fragment.
*
* @param xml NUL-terminated XML text. Must not be NULL.
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_videoparams_load_xml(OakCommonVideoParams *params,
const char *xml);
/**
* @brief Save parameters to an XML fragment (two-stage string getter).
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_videoparams_save_xml(OakCommonVideoParams *params, char *buf,
int buf_size);
/* Static helpers (no handle required). */
int oakcommon_videoparams_get_bytes_per_channel_for_format(int pixel_format);
int oakcommon_videoparams_get_bytes_per_pixel_for_format(int pixel_format,
int channels);
int oakcommon_videoparams_calculate_buffer_size(int width, int height,
int pixel_format,
int channels);
int oakcommon_videoparams_format_is_float(int pixel_format);
int oakcommon_videoparams_generate_auto_divider(int64_t width, int64_t height);
int oakcommon_videoparams_get_scaled_dimension(int dimension, int divider);
int oakcommon_videoparams_get_divider_for_target_resolution(int src_width,
int src_height,
int dst_width,
int dst_height);
/**
* @brief Human-readable name for a divider ("Full", "1/2", ...).
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_videoparams_get_name_for_divider(int divider, char *buf,
int buf_size);
/**
* @brief Human-readable name for a pixel format.
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_videoparams_get_format_name(int pixel_format, char *buf,
int buf_size);
/**
* @brief Human-readable frame rate string ("23.976 FPS").
*
* @return Required buffer size in bytes including the terminating NUL
* (non-negative), or a negative OAKCOMMON_E_* error code.
*/
int oakcommon_videoparams_frame_rate_to_string(int numerator, int denominator,
char *buf, int buf_size);
#ifdef __cplusplus
}
#endif
#endif //OAK_EDITOR_VIDEOPARAMS_H