refactor(task,render): RenderTask family over a new oakrender ticket C ABI

- oakrender: new ticket family (render_frame/render_audio with finished
  callback, result frame/samples access, cancel/wait), project copier
  C API, cache get_invalidated_ranges, manager set_aggressive_gc
- oaknode: node_copy_inputs, set_value_hint_track, viewer params
  setters, video frame cache borrowed outlet, project copy_settings
- oakcodec: encoder desired pixel format, export format extension,
  encoding generate_matrix, custom range in encoding params POD
- oaktask: RenderTask orchestrates oakrender tickets (no Qt threads/
  watchers), PreCacheTask and ExportTask rewritten over the oaknode/
  oakrender/oakcodec C ABIs; frames cross from oakrender to oakcodec
  handles by pixel copy (different control blocks)
- the two-step texture/download render path collapses into single-step
  (tickets always yield frames); subtitle sidecar kept
- tests: 105 in build-oaktask (export/precache factory paths,
  construction, conform end-to-end); regressions all green
This commit is contained in:
2026-08-07 14:40:12 +08:00
parent 6ded1d2d63
commit 40a336276f
29 changed files with 2548 additions and 726 deletions
+31
View File
@@ -116,6 +116,14 @@ typedef struct oakcodec_encoding_params {
int export_length_num; /**< Export length in seconds (rational). */
int export_length_den;
/** Custom export range (seconds, rational pairs); used when
* has_custom_range != 0. */
int has_custom_range;
int64_t custom_range_in_num;
int64_t custom_range_in_den;
int64_t custom_range_out_num;
int64_t custom_range_out_den;
} oakcodec_encoding_params;
/**
@@ -185,6 +193,29 @@ OAKCODEC_API int oakcodec_encoder_flush(OakEncoder encoder);
*/
OAKCODEC_API int oakcodec_encoder_last_error(OakEncoder encoder, char *buf, int buf_size);
/**
* @brief The pixel format the encoder wants frames in
* (Encoder::get_desired_pixel_format()), as int; -1 when
* unknown/invalid encoder.
*/
OAKCODEC_API int oakcodec_encoder_get_desired_pixel_format(OakEncoder encoder);
/**
* @brief File extension for an export format
* (ExportFormat::get_extension()), two-stage string getter.
*/
OAKCODEC_API int oakcodec_export_format_get_extension(int format, char *buf,
int buf_size);
/**
* @brief Scaling matrix for a scaling method
* (EncodingParams::generate_matrix()), row-major 4x4 into
* out_matrix[16].
*/
OAKCODEC_API int oakcodec_encoding_generate_matrix(int method, int src_width,
int src_height, int dst_width,
int dst_height, double *out_matrix);
#ifdef __cplusplus
}
#endif
+45
View File
@@ -23,6 +23,7 @@
#include <stdint.h>
#include "common/videoparams.h"
#include "node/error.h"
#include "undo/undocommand.h"
@@ -110,6 +111,16 @@ typedef struct OakNodeProject OakNodeProject;
typedef struct OakNodeMarkerList OakNodeMarkerList;
typedef struct OakNodeWorkArea OakNodeWorkArea;
/**
* @brief Opaque borrowed handle to a node's video frame cache
* (olive::FrameHashCache in oakrender). oakrender reinterprets this into
* its own handle types.
*/
typedef struct OakNodeFrameCache OakNodeFrameCache;
/* oakcore handles used by the viewer setters. */
typedef struct OakAudioParams OakAudioParams;
/**
* @brief Number of live owned objects created through this API
* (nodes from oaknode_factory_create_from_id()/oaknode_node_create_copy(),
@@ -543,6 +554,40 @@ int oaknode_node_get_markers(const OakNodeNode *node,
int oaknode_node_get_work_area(const OakNodeNode *node,
OakNodeWorkArea **out);
/**
* @brief Borrowed video frame cache of a node (NULL when the node has
* none or for NULL input).
*/
int oaknode_node_get_video_frame_cache(const OakNodeNode *node,
OakNodeFrameCache **out);
/**
* @brief Copy input values/connections from one node to another
* (Node::copy_inputs()). include_connections != 0 also copies
* input connections.
*/
int oaknode_node_copy_inputs(OakNodeNode *dst, const OakNodeNode *src,
int include_connections);
/**
* @brief Set a track-routing value hint on an input
* (Node::set_value_hint_for_input() with a single texture type
* and a Track::Reference string).
*/
int oaknode_node_set_value_hint_track(OakNodeNode *node,
const char *input_id,
int track_type, int track_index);
/**
* @brief Set a viewer node's video/audio params (ViewerOutput::
* set_video_params/set_audio_params, stream index 0). `params` is an
* oakcommon handle (video) or borrowed oakcore handle (audio).
*/
int oaknode_viewer_set_video_params(OakNodeNode *viewer,
const OakVideoParams *params);
int oaknode_viewer_set_audio_params(OakNodeNode *viewer,
const OakAudioParams *params);
/**
* @brief Create a command that removes a node from its graph together
* with its exclusive dependencies and disconnects its edges
+6
View File
@@ -163,6 +163,12 @@ int oaknode_project_is_new(const OakNodeProject *project);
int oaknode_project_cache_path(const OakNodeProject *project, char *buf,
int buf_size);
/**
* @brief Copy all project settings (Project::copy_settings()).
*/
int oaknode_project_copy_settings(OakNodeProject *dst,
const OakNodeProject *src);
/**
* @brief Cache location setting enum value
* (Project::get_cache_location_setting(): 0 = default location,
+14
View File
@@ -107,6 +107,20 @@ int oakrender_cache_has_validated_ranges(const OakRenderCache *cache);
*/
int oakrender_cache_indicator_height(void);
/**
* @brief The invalidated sub-ranges of [in, out) as flat
* {in_n, in_d, out_n, out_d} quadruples
* (PlaybackCache::get_invalidated_ranges()).
*
* Two-stage: call with ranges == NULL (or max_ranges == 0) to get the
* count; then call with a buffer of max_ranges * 4 int64_t values.
*
* @return Range count (>= 0), or a negative OAKRENDER_E_* code.
*/
int oakrender_cache_get_invalidated_ranges(OakRenderCache *c,
int64_t in_num, int64_t in_den, int64_t out_num, int64_t out_den,
int64_t *ranges, int max_ranges);
/**
* @brief Load a cached frame from disk
* (FrameHashCache::load_cache_frame(cache_path, uuid, ts)).
+65
View File
@@ -0,0 +1,65 @@
/***
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_RENDER_COPIER_H
#define OAK_EDITOR_RENDER_COPIER_H
#include "node/node.h"
#include "node/project.h"
#include "render/error.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Opaque handle to a project copier (olive::ProjectCopier):
* deep-copies a project graph for background processing
* (export/precache).
*/
typedef struct OakRenderProjectCopier OakRenderProjectCopier;
/**
* @brief Create a copier. The copy is built by
* oakrender_project_copier_set_project().
*/
OakRenderProjectCopier *oakrender_project_copier_create(void);
/** @brief Free the copier AND its copied project. NULL-safe. */
void oakrender_project_copier_free(OakRenderProjectCopier *copier);
/** @brief (Re)build the copy from `project`. */
int oakrender_project_copier_set_project(OakRenderProjectCopier *copier,
OakNodeProject *project);
/** @brief The copied counterpart of an original node (borrowed), NULL
* when the node is not in the copied project. */
OakNodeNode *oakrender_project_copier_get_copy(
OakRenderProjectCopier *copier, OakNodeNode *original);
/** @brief The copied project (borrowed). */
OakNodeProject *oakrender_project_copier_get_copied_project(
OakRenderProjectCopier *copier);
#ifdef __cplusplus
}
#endif
#endif //OAK_EDITOR_RENDER_COPIER_H
+156
View File
@@ -0,0 +1,156 @@
/***
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_RENDER_TICKET_H
#define OAK_EDITOR_RENDER_TICKET_H
#include <stdint.h>
#include "common/colortransform.h"
#include "common/videoparams.h"
#include "node/colormanager.h"
#include "node/node.h"
#include "olive/core/oakcore/audioparams.h"
#include "olive/core/oakcore/samplebuffer.h"
#include "render/error.h"
#include "render/color.h"
#include "render/renderer.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Opaque handle to a render ticket (olive::RenderTicketWatcher).
*
* Created by oakrender_ticket_render_frame() /
* oakrender_ticket_render_audio(); free with oakrender_ticket_free().
*/
typedef struct OakRenderTicket OakRenderTicket;
/**
* @brief Finished callback (async command return channel, 01 §4
* exception). Fires on the ticket's finishing thread, exactly
* once (cancelled tickets fire with a NULL result).
*/
typedef void (*oakrender_ticket_finished_fn)(OakRenderTicket *ticket,
void *userdata);
/** @brief Ticket types (RenderManager::TicketType). */
enum OakRenderTicketType {
OAKRENDER_TICKET_VIDEO = 0,
OAKRENDER_TICKET_AUDIO = 1
};
/**
* @brief Parameters for a video frame ticket
* (RenderManager::RenderVideoParams).
*/
typedef struct oakrender_video_ticket_params {
OakNodeNode *output_node; /**< Connected texture output node. */
OakVideoParams video_params; /**< By value (oakcommon handle). */
OakAudioParams *audio_params; /**< Borrowed oakcore handle, may be NULL. */
int64_t time_num; /**< Frame timestamp as rational. */
int64_t time_den;
OakNodeColorManager *color_manager; /**< Borrowed, may be NULL. */
int mode; /**< olive::RenderMode::Mode as int. */
int force_width; /**< 0/0 = off. */
int force_height;
double force_matrix[16]; /**< Used when has_force_matrix != 0. */
int has_force_matrix;
int force_format; /**< PixelFormat as int, -1 = off. */
int force_channel_count; /**< 0 = off. */
OakColorProcessor *force_color_output; /**< May be NULL. */
OakColorTransform force_color_transform; /**< By value; empty ctx = default. */
OakNodeFrameCache *cache; /**< Borrowed frame cache, may be NULL. */
} oakrender_video_ticket_params;
/**
* @brief Submit a video frame render ticket.
*
* @return Ticket handle (caller frees), or NULL on failure. The finished
* callback fires exactly once; NULL `cb` is allowed (poll with
* oakrender_ticket_wait()/oakrender_ticket_is_finished()).
*/
OakRenderTicket *oakrender_ticket_render_frame(
const oakrender_video_ticket_params *params,
oakrender_ticket_finished_fn cb, void *userdata);
/**
* @brief Submit an audio render ticket (RenderManager::render_audio()).
*
* @param output_node Connected sample output node.
* @param params Audio params (borrowed oakcore handle).
*/
OakRenderTicket *oakrender_ticket_render_audio(
OakNodeNode *output_node, int64_t in_num, int64_t in_den,
int64_t out_num, int64_t out_den, const OakAudioParams *params,
int mode, oakrender_ticket_finished_fn cb, void *userdata);
int oakrender_ticket_is_finished(OakRenderTicket *ticket);
/** @brief Block until the ticket finishes. */
int oakrender_ticket_wait(OakRenderTicket *ticket);
int oakrender_ticket_cancel(OakRenderTicket *ticket);
/** @brief OAKRENDER_TICKET_* or negative error. */
int oakrender_ticket_get_type(OakRenderTicket *ticket);
/** @brief Ticket timestamp (video tickets). */
int oakrender_ticket_get_time(OakRenderTicket *ticket, int64_t *out_num,
int64_t *out_den);
/** @brief Ticket time range (audio tickets). */
int oakrender_ticket_get_range(OakRenderTicket *ticket, int64_t *in_num,
int64_t *in_den, int64_t *out_num,
int64_t *out_den);
/**
* @brief The resulting frame (video tickets). *out receives a retained
* OakCodecFrame (release with oakrender_codec_frame_free()).
* OAKRENDER_E_STATE when unfinished, OAKRENDER_E_FAILED when the
* ticket has no frame result.
*/
int oakrender_ticket_get_frame(OakRenderTicket *ticket,
OakCodecFrame **out);
/**
* @brief The resulting samples (audio tickets). *out receives a copy
* (release with oakcore_samplebuffer_free()).
*/
int oakrender_ticket_get_samples(OakRenderTicket *ticket,
OakSampleBuffer **out);
/** @brief Free the ticket handle (safe on finished tickets; cancels and
* waits on running ones). No-op on NULL. */
void oakrender_ticket_free(OakRenderTicket *ticket);
/**
* @brief Toggle aggressive garbage collection on the render manager
* (RenderManager::set_aggressive_garbage_collection()).
*/
int oakrender_manager_set_aggressive_gc(int enabled);
#ifdef __cplusplus
}
#endif
#endif //OAK_EDITOR_RENDER_TICKET_H
+12
View File
@@ -21,9 +21,12 @@
#ifndef OAK_EDITOR_TASK_PROJECT_H
#define OAK_EDITOR_TASK_PROJECT_H
#include "codec/encoder.h"
#include "node/colormanager.h"
#include "node/footage.h"
#include "node/node.h"
#include "node/project.h"
#include "node/sequence.h"
#include "task/task.h"
#include "undo/undocommand.h"
@@ -67,6 +70,15 @@ int oaktask_import_invalid_count(OakTaskTask *t);
int oaktask_import_invalid_at(OakTaskTask *t, int index, char *buf,
int buf_size);
/** @brief olive::PreCacheTask. */
OakTaskTask *oaktask_create_precache(OakNodeFootage *footage, int index,
OakNodeSequence *sequence);
/** @brief olive::ExportTask (params POD from codec/encoder.h). */
OakTaskTask *oaktask_create_export(OakNodeNode *viewer,
OakNodeColorManager *color_manager,
const oakcodec_encoding_params *params);
/**
* @brief Image-sequence confirmation callback (facade/UI concern;
* olive::ProjectImportTask::set_image_sequence_confirm_callback).