refactor(codec): de-Qt oakcodec and wrap it in a pure C ABI; switch common handles to refcounted value structs
- oakcodec: de-Qt all 20 sources (QThread decode loop -> std::thread,
QObject/signals -> callbacks), pure C ABI in include/codec with
refcounted neutral handles (OakFrame/OakDecoder/OakEncoder),
framemanager moved in from render, frame_to_buffer/buffer_to_frame
moved in from oakcommon oiioutils, codec->task via submit callback
(M8 will register), all cross-module calls go through the other
side's C API, -fvisibility=hidden + OAKCODEC_API
- oakcommon: handles become refcounted value structs
{ctx, addref, release, abi_version} (FFmpeg-style), pass-by-value
signatures, free() as release wrapper; init_from_native/get_native
for copyable value objects; OakCommonXxx renamed to OakXxx
- oakcommon: add logging (log_debug/info/warning/critical with level
filtering and sink injection) + printf-style oakcommon_log C wrapper
- oakrender: add CancelAtom C API family; complete
oakrender_color_processor_convert_frame; fix get_processor() missing
definition and OCIO env var lookup
- tests: oakcommon 174, oaknode 96, oakrender 42, oakcodec 18, all
green in their standalone builds
This commit is contained in:
@@ -22,24 +22,39 @@
|
||||
#define OAK_EDITOR_COLORTRANSFORM_H
|
||||
|
||||
#include "common/error.h"
|
||||
#include "common/handle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace olive
|
||||
{
|
||||
class ColorTransform;
|
||||
}
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Opaque handle to a color transform description
|
||||
* @brief Neutral by-value handle to a color transform description
|
||||
* (olive::ColorTransform).
|
||||
*
|
||||
* Ownership/count semantics follow the convention in common/handle.h:
|
||||
* init functions return a handle whose object has reference count 1,
|
||||
* addref(ctx)/release(ctx) adjust it atomically, and release destroys
|
||||
* the object at zero. abi_version is always OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakCommonColorTransform OakCommonColorTransform;
|
||||
typedef struct OakColorTransform {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakColorTransform;
|
||||
|
||||
/**
|
||||
* @brief Create a plain output-colorspace transform.
|
||||
*
|
||||
* @param output Output colorspace name. Must not be NULL.
|
||||
* @return Transform handle, or NULL on failure.
|
||||
* @return Handle with reference count 1; ctx is NULL on failure.
|
||||
*/
|
||||
OakCommonColorTransform *oakcommon_colortransform_init_output(
|
||||
OakColorTransform oakcommon_colortransform_init_output(
|
||||
const char *output);
|
||||
|
||||
/**
|
||||
@@ -47,15 +62,47 @@ OakCommonColorTransform *oakcommon_colortransform_init_output(
|
||||
*
|
||||
* All three strings must not be NULL.
|
||||
*
|
||||
* @return Transform handle, or NULL on failure.
|
||||
* @return Handle with reference count 1; ctx is NULL on failure.
|
||||
*/
|
||||
OakCommonColorTransform *oakcommon_colortransform_init_display(
|
||||
OakColorTransform oakcommon_colortransform_init_display(
|
||||
const char *display, const char *view, const char *look);
|
||||
|
||||
#ifdef __cplusplus
|
||||
/**
|
||||
* @brief Destroy a transform. No-op on NULL.
|
||||
* @brief Copy a native olive::ColorTransform into a new handle.
|
||||
*
|
||||
* The source object is deep-copied; the handle does not keep any
|
||||
* reference to @p src, which may be destroyed immediately afterwards.
|
||||
* Only visible to C++ consumers.
|
||||
*
|
||||
* @return Handle with reference count 1; ctx is NULL if src is NULL or
|
||||
* on allocation failure.
|
||||
*/
|
||||
void oakcommon_colortransform_free(OakCommonColorTransform *transform);
|
||||
OakColorTransform oakcommon_colortransform_init_from_native(
|
||||
const olive::ColorTransform *src);
|
||||
|
||||
/**
|
||||
* @brief Borrow the native object behind a handle.
|
||||
*
|
||||
* The returned pointer is borrowed: it stays valid while the caller
|
||||
* holds a reference to the handle (i.e. until the matching release).
|
||||
* Only visible to C++ consumers.
|
||||
*
|
||||
* @return Borrowed pointer, or NULL if transform is NULL or
|
||||
* transform->ctx is NULL.
|
||||
*/
|
||||
const olive::ColorTransform *oakcommon_colortransform_get_native(
|
||||
OakColorTransform transform);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Release one reference to a transform.
|
||||
*
|
||||
* Convenience wrapper around handle.release(handle.ctx): decrements the
|
||||
* atomic reference count and destroys the object when it reaches zero.
|
||||
* No-op when transform is NULL or transform->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_colortransform_free(OakColorTransform *transform);
|
||||
|
||||
/**
|
||||
* @brief Query whether this is a display/view/look transform.
|
||||
@@ -63,7 +110,7 @@ void oakcommon_colortransform_free(OakCommonColorTransform *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 oakcommon_colortransform_is_display(OakColorTransform transform,
|
||||
int *is_display);
|
||||
|
||||
/**
|
||||
@@ -72,7 +119,7 @@ int oakcommon_colortransform_is_display(OakCommonColorTransform *transform,
|
||||
* @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,
|
||||
int oakcommon_colortransform_get_display(OakColorTransform transform,
|
||||
char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -81,7 +128,7 @@ int oakcommon_colortransform_get_display(OakCommonColorTransform *transform,
|
||||
* @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,
|
||||
int oakcommon_colortransform_get_output(OakColorTransform transform,
|
||||
char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -90,7 +137,7 @@ int oakcommon_colortransform_get_output(OakCommonColorTransform *transform,
|
||||
* @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,
|
||||
int oakcommon_colortransform_get_view(OakColorTransform transform,
|
||||
char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -99,7 +146,7 @@ int oakcommon_colortransform_get_view(OakCommonColorTransform *transform,
|
||||
* @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,
|
||||
int oakcommon_colortransform_get_look(OakColorTransform transform,
|
||||
char *buf, int buf_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -26,56 +26,82 @@
|
||||
#endif
|
||||
|
||||
#include "common/error.h"
|
||||
#include "common/handle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Opaque handle to a command-line parser instance.
|
||||
* @brief Neutral by-value handle to a command-line parser instance.
|
||||
*
|
||||
* Ownership/count semantics follow the convention in common/handle.h:
|
||||
* init returns a handle whose object has reference count 1,
|
||||
* addref(ctx)/release(ctx) adjust it atomically, and release destroys
|
||||
* the object at zero. abi_version is always OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakCommonCommandLineParser OakCommonCommandLineParser;
|
||||
typedef struct OakCommandLineParser {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakCommandLineParser;
|
||||
|
||||
/**
|
||||
* @brief Opaque handle to a registered command-line option.
|
||||
* @brief Neutral by-value handle to a registered command-line option.
|
||||
*
|
||||
* The handle wrapper is freed with oakcommon_commandlineoption_free();
|
||||
* the underlying option is owned by the parser and stays valid until
|
||||
* the parser is freed.
|
||||
* The handle is released with oakcommon_commandlineoption_free() (or
|
||||
* handle.release(handle.ctx)); the underlying option is owned by the
|
||||
* parser and stays valid until the parser is destroyed. abi_version is
|
||||
* always OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakCommonCommandLineOption OakCommonCommandLineOption;
|
||||
typedef struct OakCommandLineOption {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakCommandLineOption;
|
||||
|
||||
/**
|
||||
* @brief Opaque handle to a registered positional argument.
|
||||
* @brief Neutral by-value handle to a registered positional argument.
|
||||
*
|
||||
* The handle wrapper is freed with
|
||||
* oakcommon_commandlinepositionalargument_free(); the underlying argument
|
||||
* is owned by the parser and stays valid until the parser is freed.
|
||||
* The handle is released with
|
||||
* oakcommon_commandlinepositionalargument_free() (or
|
||||
* handle.release(handle.ctx)); the underlying argument is owned by the
|
||||
* parser and stays valid until the parser is destroyed. abi_version is
|
||||
* always OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakCommonCommandLinePositionalArgument
|
||||
OakCommonCommandLinePositionalArgument;
|
||||
typedef struct OakCommandLinePositionalArgument {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakCommandLinePositionalArgument;
|
||||
|
||||
/**
|
||||
* @brief Create a command-line parser.
|
||||
*
|
||||
* @return Parser handle, or NULL on allocation failure.
|
||||
* @return Handle with reference count 1; ctx is NULL on allocation
|
||||
* failure.
|
||||
*/
|
||||
OakCommonCommandLineParser *oakcommon_commandlineparser_init(void);
|
||||
OakCommandLineParser oakcommon_commandlineparser_init(void);
|
||||
|
||||
/**
|
||||
* @brief Destroy a command-line parser.
|
||||
* @brief Release one reference to a command-line parser.
|
||||
*
|
||||
* Destroys all option and positional-argument handles created from it.
|
||||
* NULL is a no-op.
|
||||
* Convenience wrapper around handle.release(handle.ctx): decrements the
|
||||
* atomic reference count and destroys the parser (invalidating all
|
||||
* option and positional-argument handles created from it) when the
|
||||
* count reaches zero. No-op when parser is NULL or parser->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_commandlineparser_free(OakCommonCommandLineParser *parser);
|
||||
void oakcommon_commandlineparser_free(OakCommandLineParser *parser);
|
||||
|
||||
/**
|
||||
* @brief Set the application name/version shown by print_help.
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_commandlineparser_set_app_info(OakCommonCommandLineParser *parser,
|
||||
int oakcommon_commandlineparser_set_app_info(OakCommandLineParser parser,
|
||||
const char *name,
|
||||
const char *version);
|
||||
|
||||
@@ -88,26 +114,28 @@ int oakcommon_commandlineparser_set_app_info(OakCommonCommandLineParser *parser,
|
||||
* @param takes_arg Non-zero if the option consumes the following argument.
|
||||
* @param arg_placeholder Placeholder shown in help, may be NULL.
|
||||
* @param hidden Non-zero to omit from help output.
|
||||
* @param out_option Receives the option handle. May be NULL if unused.
|
||||
* @param out_option Receives the option handle (reference count 1).
|
||||
* May be NULL if unused.
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_commandlineparser_add_option(
|
||||
OakCommonCommandLineParser *parser, const char *const *names, int name_count,
|
||||
OakCommandLineParser parser, const char *const *names, int name_count,
|
||||
const char *description, int takes_arg, const char *arg_placeholder,
|
||||
int hidden, OakCommonCommandLineOption **out_option);
|
||||
int hidden, OakCommandLineOption *out_option);
|
||||
|
||||
/**
|
||||
* @brief Register a positional argument.
|
||||
*
|
||||
* @param out_argument Receives the argument handle. May be NULL if unused.
|
||||
* @param out_argument Receives the argument handle (reference count 1).
|
||||
* May be NULL if unused.
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_commandlineparser_add_positional_argument(
|
||||
OakCommonCommandLineParser *parser, const char *name,
|
||||
OakCommandLineParser parser, const char *name,
|
||||
const char *description, int required,
|
||||
OakCommonCommandLinePositionalArgument **out_argument);
|
||||
OakCommandLinePositionalArgument *out_argument);
|
||||
|
||||
/**
|
||||
* @brief Parse an argv-style argument list.
|
||||
@@ -116,7 +144,7 @@ int oakcommon_commandlineparser_add_positional_argument(
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_commandlineparser_process(OakCommonCommandLineParser *parser,
|
||||
int oakcommon_commandlineparser_process(OakCommandLineParser parser,
|
||||
const char *const *argv, int argc);
|
||||
|
||||
/**
|
||||
@@ -124,7 +152,7 @@ int oakcommon_commandlineparser_process(OakCommonCommandLineParser *parser,
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_commandlineparser_print_help(OakCommonCommandLineParser *parser,
|
||||
int oakcommon_commandlineparser_print_help(OakCommandLineParser parser,
|
||||
const char *filename);
|
||||
|
||||
/**
|
||||
@@ -134,15 +162,17 @@ int oakcommon_commandlineparser_print_help(OakCommonCommandLineParser *parser,
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_commandlineoption_is_set(OakCommonCommandLineOption *option,
|
||||
int oakcommon_commandlineoption_is_set(OakCommandLineOption option,
|
||||
bool *is_set);
|
||||
|
||||
/**
|
||||
* @brief Free an option handle wrapper.
|
||||
* @brief Release one reference to an option handle.
|
||||
*
|
||||
* Does not unregister the option from the parser. NULL is a no-op.
|
||||
* Convenience wrapper around handle.release(handle.ctx). Does not
|
||||
* unregister the option from the parser. No-op when option is NULL or
|
||||
* option->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_commandlineoption_free(OakCommonCommandLineOption *option);
|
||||
void oakcommon_commandlineoption_free(OakCommandLineOption *option);
|
||||
|
||||
/**
|
||||
* @brief Get an option's argument value (two-stage string getter).
|
||||
@@ -150,7 +180,7 @@ void oakcommon_commandlineoption_free(OakCommonCommandLineOption *option);
|
||||
* @return Required buffer size in bytes including the terminating NUL
|
||||
* (non-negative), or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_commandlineoption_get_setting(OakCommonCommandLineOption *option,
|
||||
int oakcommon_commandlineoption_get_setting(OakCommandLineOption option,
|
||||
char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -158,7 +188,7 @@ int oakcommon_commandlineoption_get_setting(OakCommonCommandLineOption *option,
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_commandlineoption_set_setting(OakCommonCommandLineOption *option,
|
||||
int oakcommon_commandlineoption_set_setting(OakCommandLineOption option,
|
||||
const char *value);
|
||||
|
||||
/**
|
||||
@@ -168,7 +198,7 @@ int oakcommon_commandlineoption_set_setting(OakCommonCommandLineOption *option,
|
||||
* (non-negative), or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_commandlinepositionalargument_get_setting(
|
||||
OakCommonCommandLinePositionalArgument *argument, char *buf, int buf_size);
|
||||
OakCommandLinePositionalArgument argument, char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
* @brief Set a positional argument's value.
|
||||
@@ -176,15 +206,17 @@ int oakcommon_commandlinepositionalargument_get_setting(
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_commandlinepositionalargument_set_setting(
|
||||
OakCommonCommandLinePositionalArgument *argument, const char *value);
|
||||
OakCommandLinePositionalArgument argument, const char *value);
|
||||
|
||||
/**
|
||||
* @brief Free a positional argument handle wrapper.
|
||||
* @brief Release one reference to a positional argument handle.
|
||||
*
|
||||
* Does not unregister the argument from the parser. NULL is a no-op.
|
||||
* Convenience wrapper around handle.release(handle.ctx). Does not
|
||||
* unregister the argument from the parser. No-op when argument is NULL
|
||||
* or argument->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_commandlinepositionalargument_free(
|
||||
OakCommonCommandLinePositionalArgument *argument);
|
||||
OakCommandLinePositionalArgument *argument);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+42
-26
@@ -22,12 +22,27 @@
|
||||
#define OAK_EDITOR_CURRENT_H
|
||||
|
||||
#include "common/error.h"
|
||||
#include "common/handle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct OakCommonCurrent OakCommonCurrent;
|
||||
/**
|
||||
* @brief Neutral by-value handle to the process-wide Current singleton.
|
||||
*
|
||||
* Uses the standard handle layout (see common/handle.h) but with
|
||||
* singleton semantics: ctx points to a statically allocated object that
|
||||
* lives until process exit, so addref() and release() are intentionally
|
||||
* no-ops and never destroy anything. abi_version is always
|
||||
* OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakCurrent {
|
||||
void *ctx; /**< Opaque pointer to the singleton object. */
|
||||
void (*addref)(void *ctx); /**< No-op (singleton). */
|
||||
void (*release)(void *ctx); /**< No-op (singleton). */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakCurrent;
|
||||
|
||||
/**
|
||||
* @brief Destructor callback for objects handed to Current slots.
|
||||
@@ -35,23 +50,24 @@ typedef struct OakCommonCurrent OakCommonCurrent;
|
||||
* Called when the slot is overwritten or cleared. May be NULL if the
|
||||
* caller keeps ownership of the object.
|
||||
*/
|
||||
typedef void (*OakCommonDestroyFn)(void *obj);
|
||||
typedef void (*OakDestroyFn)(void *obj);
|
||||
|
||||
/**
|
||||
* @brief Return a handle to the process-wide Current singleton.
|
||||
*
|
||||
* The returned handle is borrowed: it is valid for the lifetime of the
|
||||
* process and must not be freed with oakcommon_current_free() more
|
||||
* than out of symmetry (free is a no-op for the singleton).
|
||||
* The returned handle is borrowed: its ctx is valid for the lifetime of
|
||||
* the process. addref/release on it are no-ops; calling
|
||||
* oakcommon_current_free() is allowed for symmetry and does nothing.
|
||||
*/
|
||||
OakCommonCurrent *oakcommon_current_instance(void);
|
||||
OakCurrent oakcommon_current_instance(void);
|
||||
|
||||
/**
|
||||
* @brief Release a Current handle.
|
||||
*
|
||||
* No-op: the underlying object is a singleton. Safe to call with NULL.
|
||||
* No-op: the underlying object is a singleton whose release() never
|
||||
* destroys anything. Safe to call with NULL or a ctx == NULL handle.
|
||||
*/
|
||||
void oakcommon_current_free(OakCommonCurrent *self);
|
||||
void oakcommon_current_free(OakCurrent *self);
|
||||
|
||||
/**
|
||||
* @brief Store a pointer in a Current slot, taking over destruction.
|
||||
@@ -63,16 +79,16 @@ void oakcommon_current_free(OakCommonCurrent *self);
|
||||
* @param obj Opaque pointer to the external object (e.g. a
|
||||
* VideoParams), or NULL to clear.
|
||||
* @param destroy Optional destructor invoked when the slot is replaced.
|
||||
* @return OAKCOMMON_OK on success, OAKCOMMON_E_INVALID if self is NULL.
|
||||
* @return OAKCOMMON_OK on success, OAKCOMMON_E_INVALID if self.ctx is NULL.
|
||||
*/
|
||||
int oakcommon_current_set_video_params(OakCommonCurrent *self, void *obj,
|
||||
OakCommonDestroyFn destroy);
|
||||
int oakcommon_current_set_audio_params(OakCommonCurrent *self, void *obj,
|
||||
OakCommonDestroyFn destroy);
|
||||
int oakcommon_current_set_plugin_host(OakCommonCurrent *self, void *obj,
|
||||
OakCommonDestroyFn destroy);
|
||||
int oakcommon_current_set_plugin_cache(OakCommonCurrent *self, void *obj,
|
||||
OakCommonDestroyFn destroy);
|
||||
int oakcommon_current_set_video_params(OakCurrent self, void *obj,
|
||||
OakDestroyFn destroy);
|
||||
int oakcommon_current_set_audio_params(OakCurrent self, void *obj,
|
||||
OakDestroyFn destroy);
|
||||
int oakcommon_current_set_plugin_host(OakCurrent self, void *obj,
|
||||
OakDestroyFn destroy);
|
||||
int oakcommon_current_set_plugin_cache(OakCurrent self, void *obj,
|
||||
OakDestroyFn destroy);
|
||||
|
||||
/**
|
||||
* @brief Fetch the raw pointer currently stored in a slot.
|
||||
@@ -82,23 +98,23 @@ int oakcommon_current_set_plugin_cache(OakCommonCurrent *self, void *obj,
|
||||
*
|
||||
* @param self Handle from oakcommon_current_instance().
|
||||
* @param out Receives the stored pointer.
|
||||
* @return OAKCOMMON_OK on success, OAKCOMMON_E_INVALID if self or out
|
||||
* is NULL.
|
||||
* @return OAKCOMMON_OK on success, OAKCOMMON_E_INVALID if self.ctx or
|
||||
* out is NULL.
|
||||
*/
|
||||
int oakcommon_current_get_video_params(OakCommonCurrent *self, void **out);
|
||||
int oakcommon_current_get_audio_params(OakCommonCurrent *self, void **out);
|
||||
int oakcommon_current_get_plugin_host(OakCommonCurrent *self, void **out);
|
||||
int oakcommon_current_get_plugin_cache(OakCommonCurrent *self, void **out);
|
||||
int oakcommon_current_get_video_params(OakCurrent self, void **out);
|
||||
int oakcommon_current_get_audio_params(OakCurrent self, void **out);
|
||||
int oakcommon_current_get_plugin_host(OakCurrent self, void **out);
|
||||
int oakcommon_current_get_plugin_cache(OakCurrent self, void **out);
|
||||
|
||||
/**
|
||||
* @brief Query whether the session is interactive.
|
||||
*
|
||||
* @param self Handle from oakcommon_current_instance().
|
||||
* @param out Receives 1 for interactive, 0 otherwise.
|
||||
* @return OAKCOMMON_OK on success, OAKCOMMON_E_INVALID if self or out
|
||||
* is NULL.
|
||||
* @return OAKCOMMON_OK on success, OAKCOMMON_E_INVALID if self.ctx or
|
||||
* out is NULL.
|
||||
*/
|
||||
int oakcommon_current_is_interactive(OakCommonCurrent *self, int *out);
|
||||
int oakcommon_current_is_interactive(OakCurrent self, int *out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+41
-3
@@ -32,7 +32,7 @@ extern "C" {
|
||||
*
|
||||
* Mirrors olive::DebugLevel in src/common/src/debug.h.
|
||||
*/
|
||||
enum OakCommonDebugLevel {
|
||||
enum OakDebugLevel {
|
||||
OAKCOMMON_DEBUG_DEBUG = 0, /**< Verbose debug message. */
|
||||
OAKCOMMON_DEBUG_INFO = 1, /**< Informational message. */
|
||||
OAKCOMMON_DEBUG_WARNING = 2, /**< Warning message. */
|
||||
@@ -46,7 +46,7 @@ enum OakCommonDebugLevel {
|
||||
* De-Qt replacement for the old Qt message handler. The line is
|
||||
* flushed immediately.
|
||||
*
|
||||
* @param level One of OakCommonDebugLevel; out-of-range values print
|
||||
* @param level One of OakDebugLevel; out-of-range values print
|
||||
* as "UNKNOWN".
|
||||
* @param msg NUL-terminated message; NULL is treated as an empty
|
||||
* string.
|
||||
@@ -60,7 +60,7 @@ int oakcommon_debug_log(int level, const char *msg);
|
||||
* Two-segment string getter: if buf is NULL or buf_size is too small,
|
||||
* nothing is written.
|
||||
*
|
||||
* @param level One of OakCommonDebugLevel.
|
||||
* @param level One of OakDebugLevel.
|
||||
* @param buf Destination buffer, may be NULL to query the size.
|
||||
* @param buf_size Size of buf in bytes.
|
||||
* @return Required buffer size in bytes including the terminating NUL
|
||||
@@ -68,6 +68,44 @@ int oakcommon_debug_log(int level, const char *msg);
|
||||
*/
|
||||
int oakcommon_debug_level_name(int level, char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
* @brief printf-style filtered log, replacing qDebug()/qInfo()/
|
||||
* qWarning()/qCritical() call sites.
|
||||
*
|
||||
* The message is formatted with vsnprintf into a dynamically sized
|
||||
* buffer (arbitrary length, no truncation, no fixed stack buffer) and
|
||||
* emitted as "[LEVEL] message\n" unless @p level is below the current
|
||||
* filter level (see oakcommon_log_set_level()).
|
||||
*
|
||||
* @param level One of OakDebugLevel; out-of-range values print
|
||||
* as "UNKNOWN" and are never filtered out below FATAL.
|
||||
* @param fmt printf-style format string. Must not be NULL.
|
||||
* @return OAKCOMMON_OK on success, OAKCOMMON_E_INVALID if fmt is NULL,
|
||||
* OAKCOMMON_E_FAILED if formatting failed.
|
||||
*/
|
||||
int oakcommon_log(int level, const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* @brief Set the minimum level emitted by oakcommon_log().
|
||||
*
|
||||
* Messages with a lower level are dropped. The default is
|
||||
* OAKCOMMON_DEBUG_INFO.
|
||||
*
|
||||
* @param level One of OakDebugLevel.
|
||||
* @return OAKCOMMON_OK on success, OAKCOMMON_E_INVALID if level is
|
||||
* outside the OakDebugLevel range.
|
||||
*/
|
||||
int oakcommon_log_set_level(int level);
|
||||
|
||||
/**
|
||||
* @brief Query the current minimum level emitted by oakcommon_log().
|
||||
*
|
||||
* @param out_level Receives one of OakDebugLevel. Must not be NULL.
|
||||
* @return OAKCOMMON_OK on success, OAKCOMMON_E_INVALID if out_level is
|
||||
* NULL.
|
||||
*/
|
||||
int oakcommon_log_get_level(int *out_level);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ extern "C" {
|
||||
* src/common/src/dropworkflowbehavior.h; enumerator order and values
|
||||
* must stay identical because the config layer persists them as ints.
|
||||
*/
|
||||
enum OakCommonDropWorkflowBehavior {
|
||||
enum OakDropWorkflowBehavior {
|
||||
OAKCOMMON_DWS_ASK = 0, /**< Ask the user every time. */
|
||||
OAKCOMMON_DWS_AUTO = 1, /**< Automatically create a sequence. */
|
||||
OAKCOMMON_DWS_MANUAL = 2, /**< Never create; import manually. */
|
||||
@@ -43,7 +43,7 @@ enum OakCommonDropWorkflowBehavior {
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Check whether value is a valid OakCommonDropWorkflowBehavior.
|
||||
* @brief Check whether value is a valid OakDropWorkflowBehavior.
|
||||
*
|
||||
* @param value Integer behavior value (e.g. read from config).
|
||||
* @return 1 if valid, 0 otherwise (this is a predicate, not a status
|
||||
@@ -57,7 +57,7 @@ int oakcommon_drop_workflow_behavior_is_valid(int value);
|
||||
* Two-segment string getter: if buf is NULL or buf_size is too small,
|
||||
* nothing is written. Invalid values yield "UNKNOWN".
|
||||
*
|
||||
* @param value One of OakCommonDropWorkflowBehavior.
|
||||
* @param value One of OakDropWorkflowBehavior.
|
||||
* @param buf Destination buffer, may be NULL to query the size.
|
||||
* @param buf_size Size of buf in bytes.
|
||||
* @return Required buffer size in bytes including the terminating NUL
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* (including the terminating NUL) as a non-negative value instead.
|
||||
*/
|
||||
#define OAKCOMMON_OK 0 /**< Success. */
|
||||
#define OAKCOMMON_E_INVALID (-1) /**< NULL handle or invalid argument. */
|
||||
#define OAKCOMMON_E_INVALID (-1) /**< Empty handle (ctx == NULL) or invalid argument. */
|
||||
#define OAKCOMMON_E_STATE (-2) /**< Call not valid in the current state. */
|
||||
#define OAKCOMMON_E_FAILED (-3) /**< The underlying operation failed. */
|
||||
#define OAKCOMMON_E_NOT_FOUND (-4) /**< Index out of range / entry not found. */
|
||||
|
||||
@@ -22,30 +22,44 @@
|
||||
#define OAK_EDITOR_FILEFUNCTIONS_H
|
||||
|
||||
#include "common/error.h"
|
||||
#include "common/handle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Opaque handle for the filefunctions family
|
||||
* @brief Neutral by-value handle for the filefunctions family
|
||||
*
|
||||
* File functions are stateless; the handle only exists to keep the C API
|
||||
* shape uniform across oakcommon families.
|
||||
* shape uniform across oakcommon families. Ownership/count semantics
|
||||
* follow the convention in common/handle.h: init returns a handle whose
|
||||
* (empty) object has reference count 1, addref(ctx)/release(ctx) adjust
|
||||
* it atomically, and release destroys it at zero. abi_version is always
|
||||
* OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakCommonFileFunctions OakCommonFileFunctions;
|
||||
typedef struct OakFileFunctions {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakFileFunctions;
|
||||
|
||||
/**
|
||||
* @brief Creates a filefunctions handle
|
||||
*
|
||||
* @return A new handle, or NULL on failure.
|
||||
* @return Handle with reference count 1; ctx is NULL on failure.
|
||||
*/
|
||||
OakCommonFileFunctions *oakcommon_filefunctions_init(void);
|
||||
OakFileFunctions oakcommon_filefunctions_init(void);
|
||||
|
||||
/**
|
||||
* @brief Destroys a filefunctions handle (NULL is a no-op)
|
||||
* @brief Releases one reference to a filefunctions handle
|
||||
*
|
||||
* Convenience wrapper around handle.release(handle.ctx): decrements the
|
||||
* atomic reference count and destroys the object when it reaches zero.
|
||||
* No-op when self is NULL or self->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_filefunctions_free(OakCommonFileFunctions *self);
|
||||
void oakcommon_filefunctions_free(OakFileFunctions *self);
|
||||
|
||||
/**
|
||||
* @brief Returns a deterministic identifier string for a file
|
||||
@@ -55,20 +69,20 @@ void oakcommon_filefunctions_free(OakCommonFileFunctions *self);
|
||||
* the file does not exist.
|
||||
*/
|
||||
int oakcommon_filefunctions_get_unique_file_identifier(
|
||||
OakCommonFileFunctions *self, const char *filename, char *buf,
|
||||
OakFileFunctions self, const char *filename, char *buf,
|
||||
int buf_size);
|
||||
|
||||
int oakcommon_filefunctions_get_configuration_location(
|
||||
OakCommonFileFunctions *self, char *buf, int buf_size);
|
||||
OakFileFunctions self, char *buf, int buf_size);
|
||||
|
||||
int oakcommon_filefunctions_get_application_path(
|
||||
OakCommonFileFunctions *self, char *buf, int buf_size);
|
||||
OakFileFunctions self, char *buf, int buf_size);
|
||||
|
||||
int oakcommon_filefunctions_get_temp_file_path(
|
||||
OakCommonFileFunctions *self, char *buf, int buf_size);
|
||||
OakFileFunctions self, char *buf, int buf_size);
|
||||
|
||||
int oakcommon_filefunctions_get_auto_recovery_root(
|
||||
OakCommonFileFunctions *self, char *buf, int buf_size);
|
||||
OakFileFunctions self, char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
* @brief Checks whether `source` can be copied to `dest` without
|
||||
@@ -77,13 +91,13 @@ int oakcommon_filefunctions_get_auto_recovery_root(
|
||||
* @param out Receives 1 (safe) or 0 (would overwrite).
|
||||
*/
|
||||
int oakcommon_filefunctions_can_copy_directory_without_overwriting(
|
||||
OakCommonFileFunctions *self, const char *source, const char *dest,
|
||||
OakFileFunctions self, const char *source, const char *dest,
|
||||
int *out);
|
||||
|
||||
/**
|
||||
* @brief Recursively copies a directory
|
||||
*/
|
||||
int oakcommon_filefunctions_copy_directory(OakCommonFileFunctions *self,
|
||||
int oakcommon_filefunctions_copy_directory(OakFileFunctions self,
|
||||
const char *source,
|
||||
const char *dest, int overwrite);
|
||||
|
||||
@@ -93,7 +107,7 @@ int oakcommon_filefunctions_copy_directory(OakCommonFileFunctions *self,
|
||||
* @param out Receives 1 (valid) or 0 (invalid).
|
||||
*/
|
||||
int oakcommon_filefunctions_directory_is_valid(
|
||||
OakCommonFileFunctions *self, const char *dir,
|
||||
OakFileFunctions self, const char *dir,
|
||||
int try_to_create_if_not_exists, int *out);
|
||||
|
||||
/**
|
||||
@@ -103,7 +117,7 @@ int oakcommon_filefunctions_directory_is_valid(
|
||||
* OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_filefunctions_ensure_filename_extension(
|
||||
OakCommonFileFunctions *self, const char *filename,
|
||||
OakFileFunctions self, const char *filename,
|
||||
const char *extension, char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -114,7 +128,7 @@ int oakcommon_filefunctions_ensure_filename_extension(
|
||||
* the file cannot be read.
|
||||
*/
|
||||
int oakcommon_filefunctions_read_file_as_string(
|
||||
OakCommonFileFunctions *self, const char *filename, char *buf,
|
||||
OakFileFunctions self, const char *filename, char *buf,
|
||||
int buf_size);
|
||||
|
||||
/**
|
||||
@@ -124,7 +138,7 @@ int oakcommon_filefunctions_read_file_as_string(
|
||||
* OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_filefunctions_get_safe_temporary_filename(
|
||||
OakCommonFileFunctions *self, const char *original, char *buf,
|
||||
OakFileFunctions self, const char *original, char *buf,
|
||||
int buf_size);
|
||||
|
||||
/**
|
||||
@@ -133,7 +147,7 @@ int oakcommon_filefunctions_get_safe_temporary_filename(
|
||||
* @param out Receives 1 (renamed) or 0 (failed).
|
||||
*/
|
||||
int oakcommon_filefunctions_rename_file_allow_overwrite(
|
||||
OakCommonFileFunctions *self, const char *from, const char *to,
|
||||
OakFileFunctions self, const char *from, const char *to,
|
||||
int *out);
|
||||
|
||||
/**
|
||||
@@ -143,7 +157,7 @@ int oakcommon_filefunctions_rename_file_allow_overwrite(
|
||||
* OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_filefunctions_get_formatted_executable_for_platform(
|
||||
OakCommonFileFunctions *self, const char *unformatted, char *buf,
|
||||
OakFileFunctions self, const char *unformatted, char *buf,
|
||||
int buf_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/***
|
||||
|
||||
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_HANDLE_H
|
||||
#define OAK_EDITOR_HANDLE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Current ABI version stamped into every oakcommon handle.
|
||||
*
|
||||
* Bump whenever the handle layout or the semantics of any exported
|
||||
* function change incompatibly. Consumers should compare a handle's
|
||||
* abi_version field against the value they were compiled with before
|
||||
* dereferencing ctx.
|
||||
*/
|
||||
#define OAKCOMMON_ABI_VERSION 1
|
||||
|
||||
/**
|
||||
* @brief Neutral handle convention shared by all oakcommon wrappers.
|
||||
*
|
||||
* Every wrapper type is a by-value struct with the same four fields:
|
||||
*
|
||||
* typedef struct OakXxx {
|
||||
* void *ctx; // opaque, points to the impl
|
||||
* void (*addref)(void *ctx); // atomic +1, owner-DLL code
|
||||
* void (*release)(void *ctx); // atomic -1, destroys at 0
|
||||
* uint32_t abi_version; // OAKCOMMON_ABI_VERSION
|
||||
* } OakXxx;
|
||||
*
|
||||
* Rules:
|
||||
* - oakcommon_<name>_init*() returns a handle whose underlying object
|
||||
* has reference count 1.
|
||||
* - Copying the struct copies the pointer, not the count: call
|
||||
* handle.addref(handle.ctx) for every additional long-lived copy and
|
||||
* handle.release(handle.ctx) (or the oakcommon_<name>_free()
|
||||
* convenience wrapper) when done with each copy.
|
||||
* - release() decrements the atomic count and destroys the underlying
|
||||
* object when it reaches zero; the destructor runs in the DLL that
|
||||
* created the object, so cross-DLL handing is safe.
|
||||
* - The struct itself carries no ownership: it is never heap-allocated
|
||||
* by the API, so it needs no destruction of its own.
|
||||
* - Functions that only read a handle take it BY VALUE (OakXxx self);
|
||||
* an empty handle (ctx == NULL) is reported as OAKCOMMON_E_INVALID.
|
||||
* oakcommon_<name>_free() deliberately stays a pointer API
|
||||
* (OakXxx *h, like av_frame_unref()/av_buffer_unref()) so it can
|
||||
* null out the caller's ctx after the final release; NULL and
|
||||
* ctx == NULL are no-ops. Out parameters that produce a handle
|
||||
* (e.g. option/positional-argument registration) also stay pointers.
|
||||
*/
|
||||
|
||||
#endif //OAK_EDITOR_HANDLE_H
|
||||
@@ -31,7 +31,7 @@ extern "C" {
|
||||
* The numeric values must stay in sync with src/common/src/loopmode.h.
|
||||
* Pure enum: no functions are needed.
|
||||
*/
|
||||
enum OakCommonLoopMode {
|
||||
enum OakLoopMode {
|
||||
OAKCOMMON_LOOP_MODE_OFF = 0, /**< Looping disabled. */
|
||||
OAKCOMMON_LOOP_MODE_LOOP = 1, /**< Loop playback. */
|
||||
OAKCOMMON_LOOP_MODE_CLAMP = 2 /**< Clamp at the end. */
|
||||
|
||||
+28
-11
@@ -22,6 +22,7 @@
|
||||
#define OAK_EDITOR_OCIOUTILS_H
|
||||
|
||||
#include "common/error.h"
|
||||
#include "common/handle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -33,7 +34,7 @@ extern "C" {
|
||||
* The numeric values must stay in sync with
|
||||
* olive/core/render/pixelformat.h (Format enum).
|
||||
*/
|
||||
enum OakCommonPixelFormat {
|
||||
enum OakPixelFormat {
|
||||
OAKCOMMON_PIXEL_FORMAT_INVALID = -1, /**< Invalid/unknown format. */
|
||||
OAKCOMMON_PIXEL_FORMAT_U8 = 0, /**< 8-bit unsigned integer. */
|
||||
OAKCOMMON_PIXEL_FORMAT_U10 = 1, /**< 10-bit unsigned integer. */
|
||||
@@ -52,34 +53,50 @@ enum OakCommonPixelFormat {
|
||||
* BitDepth enum: 0 = unknown, 1 = uint8, 2 = uint10, 3 = uint12,
|
||||
* 4 = uint14, 5 = uint16, 6 = uint32, 7 = f16, 8 = f32 (OCIO v2).
|
||||
*/
|
||||
typedef struct OakCommonOCIOUtils OakCommonOCIOUtils;
|
||||
/**
|
||||
* @brief Neutral by-value handle for the OCIO utils family
|
||||
*
|
||||
* The object is stateless; the handle exists only to satisfy the C API
|
||||
* lifetime contract. Ownership/count semantics follow common/handle.h:
|
||||
* init returns a handle whose (empty) object has reference count 1 and
|
||||
* release destroys it at zero. abi_version is always
|
||||
* OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakOCIOUtils {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakOCIOUtils;
|
||||
|
||||
/**
|
||||
* @brief Creates an OCIOUtils handle
|
||||
*
|
||||
* The object is stateless; the handle exists only to satisfy the C API
|
||||
* lifetime contract. Returns NULL on failure.
|
||||
* @return Handle with reference count 1; ctx is NULL on failure.
|
||||
*/
|
||||
OakCommonOCIOUtils *oakcommon_ocioutils_init(void);
|
||||
OakOCIOUtils oakcommon_ocioutils_init(void);
|
||||
|
||||
/**
|
||||
* @brief Destroys an OCIOUtils handle; no-op on NULL
|
||||
* @brief Releases one reference to an OCIOUtils handle
|
||||
*
|
||||
* Convenience wrapper around handle.release(handle.ctx); no-op when
|
||||
* self is NULL or self->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_ocioutils_free(OakCommonOCIOUtils *self);
|
||||
void oakcommon_ocioutils_free(OakOCIOUtils *self);
|
||||
|
||||
/**
|
||||
* @brief Maps a native pixel format to an OCIO bit depth
|
||||
*
|
||||
* @param self handle from oakcommon_ocioutils_init()
|
||||
* @param pixel_format one of the OakCommonPixelFormat values
|
||||
* @param pixel_format one of the OakPixelFormat values
|
||||
* @param out_bit_depth receives the OCIO bit depth as an int (see the
|
||||
* OakCommonOCIOUtils typedef documentation); set to 0
|
||||
* OakOCIOUtils typedef documentation); set to 0
|
||||
* (BIT_DEPTH_UNKNOWN) for invalid formats
|
||||
* @return OAKCOMMON_OK, or OAKCOMMON_E_INVALID if self or
|
||||
* @return OAKCOMMON_OK, or OAKCOMMON_E_INVALID if self.ctx or
|
||||
* out_bit_depth is NULL or pixel_format is not a known code
|
||||
*/
|
||||
int oakcommon_ocioutils_get_ocio_bit_depth_from_pixel_format(
|
||||
OakCommonOCIOUtils *self, int pixel_format, int *out_bit_depth);
|
||||
OakOCIOUtils self, int pixel_format, int *out_bit_depth);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+34
-18
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "common/error.h"
|
||||
|
||||
/* Reuses the OakCommonPixelFormat enum (mirroring
|
||||
/* Reuses the OakPixelFormat enum (mirroring
|
||||
* olive::core::PixelFormat) rather than redefining it here. */
|
||||
#include "common/ocioutils.h"
|
||||
|
||||
@@ -41,48 +41,64 @@ extern "C" {
|
||||
* 13 = STRING, 14 = PTR. OIIO >= 2.5 adds 15 = USTRINGHASH and shifts
|
||||
* LASTBASE, so the exact LASTBASE value is version-dependent.
|
||||
*/
|
||||
typedef struct OakCommonOIIOUtils OakCommonOIIOUtils;
|
||||
/**
|
||||
* @brief Neutral by-value handle for the OIIO utils family
|
||||
*
|
||||
* The object is stateless; the handle exists only to satisfy the C API
|
||||
* lifetime contract. Ownership/count semantics follow common/handle.h:
|
||||
* init returns a handle whose (empty) object has reference count 1 and
|
||||
* release destroys it at zero. abi_version is always
|
||||
* OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakOIIOUtils {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakOIIOUtils;
|
||||
|
||||
/**
|
||||
* @brief Creates an OIIOUtils handle
|
||||
*
|
||||
* The object is stateless; the handle exists only to satisfy the C API
|
||||
* lifetime contract. Returns NULL on failure.
|
||||
* @return Handle with reference count 1; ctx is NULL on failure.
|
||||
*/
|
||||
OakCommonOIIOUtils *oakcommon_oiioutils_init(void);
|
||||
OakOIIOUtils oakcommon_oiioutils_init(void);
|
||||
|
||||
/**
|
||||
* @brief Destroys an OIIOUtils handle; no-op on NULL
|
||||
* @brief Releases one reference to an OIIOUtils handle
|
||||
*
|
||||
* Convenience wrapper around handle.release(handle.ctx); no-op when
|
||||
* self is NULL or self->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_oiioutils_free(OakCommonOIIOUtils *self);
|
||||
void oakcommon_oiioutils_free(OakOIIOUtils *self);
|
||||
|
||||
/**
|
||||
* @brief Maps a native pixel format to an OIIO base type
|
||||
*
|
||||
* @param self handle from oakcommon_oiioutils_init()
|
||||
* @param pixel_format one of the OakCommonPixelFormat values
|
||||
* @param pixel_format one of the OakPixelFormat values
|
||||
* @param out_base_type receives the OIIO base type as an int (see the
|
||||
* OakCommonOIIOUtils typedef documentation); set to 0
|
||||
* OakOIIOUtils typedef documentation); set to 0
|
||||
* (TypeDesc::UNKNOWN) for invalid or unmappable formats
|
||||
* @return OAKCOMMON_OK, or OAKCOMMON_E_INVALID if self or out_base_type
|
||||
* is NULL or pixel_format is not a known code
|
||||
* @return OAKCOMMON_OK, or OAKCOMMON_E_INVALID if self.ctx or
|
||||
* out_base_type is NULL or pixel_format is not a known code
|
||||
*/
|
||||
int oakcommon_oiioutils_get_oiio_base_type_from_format(
|
||||
OakCommonOIIOUtils *self, int pixel_format, int *out_base_type);
|
||||
OakOIIOUtils self, int pixel_format, int *out_base_type);
|
||||
|
||||
/**
|
||||
* @brief Maps an OIIO base type to a native pixel format
|
||||
*
|
||||
* @param self handle from oakcommon_oiioutils_init()
|
||||
* @param base_type an OIIO TypeDesc::BASETYPE value as an int
|
||||
* @param out_pixel_format receives one of the OakCommonPixelFormat
|
||||
* @param out_pixel_format receives one of the OakPixelFormat
|
||||
* values; set to OAKCOMMON_PIXEL_FORMAT_INVALID for unknown or
|
||||
* unmappable base types
|
||||
* @return OAKCOMMON_OK, or OAKCOMMON_E_INVALID if self or
|
||||
* @return OAKCOMMON_OK, or OAKCOMMON_E_INVALID if self.ctx or
|
||||
* out_pixel_format is NULL or base_type is negative
|
||||
*/
|
||||
int oakcommon_oiioutils_get_format_from_oiio_basetype(
|
||||
OakCommonOIIOUtils *self, int base_type, int *out_pixel_format);
|
||||
OakOIIOUtils self, int base_type, int *out_pixel_format);
|
||||
|
||||
/**
|
||||
* @brief Converts a PixelAspectRatio attribute value to a rational
|
||||
@@ -95,11 +111,11 @@ int oakcommon_oiioutils_get_format_from_oiio_basetype(
|
||||
* @param pixel_aspect_ratio the PixelAspectRatio attribute value
|
||||
* @param out_numerator receives the rational numerator
|
||||
* @param out_denominator receives the rational denominator
|
||||
* @return OAKCOMMON_OK, or OAKCOMMON_E_INVALID if self, out_numerator
|
||||
* or out_denominator is NULL
|
||||
* @return OAKCOMMON_OK, or OAKCOMMON_E_INVALID if self.ctx,
|
||||
* out_numerator or out_denominator is NULL
|
||||
*/
|
||||
int oakcommon_oiioutils_get_pixel_aspect_ratio(
|
||||
OakCommonOIIOUtils *self, double pixel_aspect_ratio, int *out_numerator,
|
||||
OakOIIOUtils self, double pixel_aspect_ratio, int *out_numerator,
|
||||
int *out_denominator);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -22,53 +22,89 @@
|
||||
#define OAK_EDITOR_SUBTITLEPARAMS_H
|
||||
|
||||
#include "common/error.h"
|
||||
#include "common/handle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace olive
|
||||
{
|
||||
class SubtitleParams;
|
||||
}
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Opaque handle to a subtitle parameter set (olive::SubtitleParams).
|
||||
* @brief Neutral by-value handle to a subtitle parameter set
|
||||
* (olive::SubtitleParams).
|
||||
*
|
||||
* Ownership/count semantics follow the convention in common/handle.h:
|
||||
* init functions return a handle whose object has reference count 1,
|
||||
* addref(ctx)/release(ctx) adjust it atomically, and release destroys
|
||||
* the object at zero. abi_version is always OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakCommonSubtitleParams OakCommonSubtitleParams;
|
||||
typedef struct OakSubtitleParams {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakSubtitleParams;
|
||||
|
||||
/**
|
||||
* @brief Create an empty subtitle parameter set.
|
||||
*
|
||||
* @return Params handle, or NULL on allocation failure.
|
||||
* @return Handle with reference count 1; ctx is NULL on allocation
|
||||
* failure.
|
||||
*/
|
||||
OakCommonSubtitleParams *oakcommon_subtitleparams_init(void);
|
||||
OakSubtitleParams oakcommon_subtitleparams_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
/**
|
||||
* @brief Copy a native olive::SubtitleParams into a new handle.
|
||||
*
|
||||
* The source object is deep-copied; the handle does not keep any
|
||||
* reference to @p src, which may be destroyed immediately afterwards.
|
||||
* Only visible to C++ consumers.
|
||||
*
|
||||
* @return Handle with reference count 1; ctx is NULL if src is NULL or
|
||||
* on allocation failure.
|
||||
*/
|
||||
OakSubtitleParams oakcommon_subtitleparams_init_from_native(
|
||||
const olive::SubtitleParams *src);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Destroy a subtitle parameter set. No-op on NULL.
|
||||
* @brief Release one reference to a subtitle parameter set.
|
||||
*
|
||||
* Convenience wrapper around handle.release(handle.ctx): decrements the
|
||||
* atomic reference count and destroys the object when it reaches zero.
|
||||
* No-op when params is NULL or params->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_subtitleparams_free(OakCommonSubtitleParams *params);
|
||||
void oakcommon_subtitleparams_free(OakSubtitleParams *params);
|
||||
|
||||
int oakcommon_subtitleparams_get_stream_index(
|
||||
OakCommonSubtitleParams *params, int *index);
|
||||
OakSubtitleParams params, int *index);
|
||||
int oakcommon_subtitleparams_set_stream_index(
|
||||
OakCommonSubtitleParams *params, int index);
|
||||
int oakcommon_subtitleparams_get_enabled(OakCommonSubtitleParams *params,
|
||||
OakSubtitleParams params, int index);
|
||||
int oakcommon_subtitleparams_get_enabled(OakSubtitleParams params,
|
||||
int *enabled);
|
||||
int oakcommon_subtitleparams_set_enabled(OakCommonSubtitleParams *params,
|
||||
int oakcommon_subtitleparams_set_enabled(OakSubtitleParams params,
|
||||
int enabled);
|
||||
|
||||
/**
|
||||
* @brief Query whether the set contains at least one subtitle.
|
||||
*/
|
||||
int oakcommon_subtitleparams_is_valid(OakCommonSubtitleParams *params,
|
||||
int oakcommon_subtitleparams_is_valid(OakSubtitleParams params,
|
||||
int *is_valid);
|
||||
|
||||
/**
|
||||
* @brief Number of subtitle entries.
|
||||
*/
|
||||
int oakcommon_subtitleparams_count(OakCommonSubtitleParams *params,
|
||||
int oakcommon_subtitleparams_count(OakSubtitleParams params,
|
||||
int *count);
|
||||
|
||||
/**
|
||||
* @brief Out time of the last subtitle (0/1 when empty).
|
||||
*/
|
||||
int oakcommon_subtitleparams_duration(OakCommonSubtitleParams *params,
|
||||
int oakcommon_subtitleparams_duration(OakSubtitleParams params,
|
||||
int *numerator, int *denominator);
|
||||
|
||||
/**
|
||||
@@ -77,14 +113,14 @@ int oakcommon_subtitleparams_duration(OakCommonSubtitleParams *params,
|
||||
* @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 oakcommon_subtitleparams_add_subtitle(OakSubtitleParams 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);
|
||||
int oakcommon_subtitleparams_clear(OakSubtitleParams params);
|
||||
|
||||
/**
|
||||
* @brief Get the time range of the subtitle at @p index.
|
||||
@@ -92,7 +128,7 @@ int oakcommon_subtitleparams_clear(OakCommonSubtitleParams *params);
|
||||
* @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 oakcommon_subtitleparams_get_subtitle(OakSubtitleParams params,
|
||||
int index, int *in_num, int *in_den,
|
||||
int *out_num, int *out_den);
|
||||
|
||||
@@ -103,7 +139,7 @@ int oakcommon_subtitleparams_get_subtitle(OakCommonSubtitleParams *params,
|
||||
* (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 oakcommon_subtitleparams_get_subtitle_text(OakSubtitleParams params,
|
||||
int index, char *buf,
|
||||
int buf_size);
|
||||
|
||||
@@ -121,7 +157,7 @@ int oakcommon_subtitleparams_generate_ass_header(char *buf, int buf_size);
|
||||
* @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,
|
||||
int oakcommon_subtitleparams_load_xml(OakSubtitleParams params,
|
||||
const char *xml);
|
||||
|
||||
/**
|
||||
@@ -130,7 +166,7 @@ int oakcommon_subtitleparams_load_xml(OakCommonSubtitleParams *params,
|
||||
* @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,
|
||||
int oakcommon_subtitleparams_save_xml(OakSubtitleParams params,
|
||||
char *buf, int buf_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+141
-75
@@ -28,21 +28,37 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common/error.h"
|
||||
#include "common/handle.h"
|
||||
#include "common/ocioutils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace olive
|
||||
{
|
||||
class VideoParams;
|
||||
}
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Opaque handle to a video parameter set (olive::VideoParams).
|
||||
* @brief Neutral by-value handle to a video parameter set
|
||||
* (olive::VideoParams).
|
||||
*
|
||||
* Ownership/count semantics follow the convention in common/handle.h:
|
||||
* init functions return a handle whose object has reference count 1,
|
||||
* addref(ctx)/release(ctx) adjust it atomically, and release destroys
|
||||
* the object at zero. abi_version is always OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakCommonVideoParams OakCommonVideoParams;
|
||||
typedef struct OakVideoParams {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakVideoParams;
|
||||
|
||||
/**
|
||||
* @brief Interlacing modes, mirroring olive::VideoParams::Interlacing.
|
||||
*/
|
||||
enum OakCommonVideoInterlacing {
|
||||
enum OakVideoInterlacing {
|
||||
OAKCOMMON_VIDEO_INTERLACE_NONE = 0,
|
||||
OAKCOMMON_VIDEO_INTERLACED_TOP_FIRST = 1,
|
||||
OAKCOMMON_VIDEO_INTERLACED_BOTTOM_FIRST = 2
|
||||
@@ -51,7 +67,7 @@ enum OakCommonVideoInterlacing {
|
||||
/**
|
||||
* @brief Video stream types, mirroring olive::VideoParams::Type.
|
||||
*/
|
||||
enum OakCommonVideoType {
|
||||
enum OakVideoType {
|
||||
OAKCOMMON_VIDEO_TYPE_VIDEO = 0,
|
||||
OAKCOMMON_VIDEO_TYPE_STILL = 1,
|
||||
OAKCOMMON_VIDEO_TYPE_IMAGE_SEQUENCE = 2
|
||||
@@ -60,7 +76,7 @@ enum OakCommonVideoType {
|
||||
/**
|
||||
* @brief Color range codes, mirroring olive::VideoParams::ColorRange.
|
||||
*/
|
||||
enum OakCommonVideoColorRange {
|
||||
enum OakVideoColorRange {
|
||||
OAKCOMMON_COLOR_RANGE_LIMITED = 0, /**< 16-235 */
|
||||
OAKCOMMON_COLOR_RANGE_FULL = 1 /**< 0-255 */
|
||||
};
|
||||
@@ -68,17 +84,19 @@ enum OakCommonVideoColorRange {
|
||||
/**
|
||||
* @brief Create a default (invalid) video parameter set.
|
||||
*
|
||||
* @return Params handle, or NULL on allocation failure.
|
||||
* @return Handle with reference count 1; ctx is NULL on allocation
|
||||
* failure.
|
||||
*/
|
||||
OakCommonVideoParams *oakcommon_videoparams_init(void);
|
||||
OakVideoParams 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.
|
||||
* @param pixel_format One of the OakPixelFormat values.
|
||||
* @return Handle with reference count 1; ctx is NULL on allocation
|
||||
* failure.
|
||||
*/
|
||||
OakCommonVideoParams *oakcommon_videoparams_init_basic(
|
||||
OakVideoParams 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);
|
||||
|
||||
@@ -87,103 +105,136 @@ OakCommonVideoParams *oakcommon_videoparams_init_basic(
|
||||
*
|
||||
* 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.
|
||||
* @param pixel_format One of the OakPixelFormat values.
|
||||
* @return Handle with reference count 1; ctx is NULL on allocation
|
||||
* failure.
|
||||
*/
|
||||
OakCommonVideoParams *oakcommon_videoparams_init_with_time_base(
|
||||
OakVideoParams 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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
/**
|
||||
* @brief Destroy a video parameter set. No-op on NULL.
|
||||
* @brief Copy a native olive::VideoParams into a new handle.
|
||||
*
|
||||
* The source object is deep-copied; the handle does not keep any
|
||||
* reference to @p src, which may be destroyed immediately afterwards.
|
||||
* Only visible to C++ consumers.
|
||||
*
|
||||
* @return Handle with reference count 1; ctx is NULL if src is NULL or
|
||||
* on allocation failure.
|
||||
*/
|
||||
void oakcommon_videoparams_free(OakCommonVideoParams *params);
|
||||
OakVideoParams oakcommon_videoparams_init_from_native(
|
||||
const olive::VideoParams *src);
|
||||
|
||||
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 Borrow the native object behind a handle.
|
||||
*
|
||||
* The returned pointer is borrowed: it stays valid while the caller
|
||||
* holds a reference to the handle (i.e. until the matching release).
|
||||
* Only visible to C++ consumers.
|
||||
*
|
||||
* @return Borrowed pointer, or NULL if params is NULL or params->ctx is
|
||||
* NULL.
|
||||
*/
|
||||
const olive::VideoParams *oakcommon_videoparams_get_native(
|
||||
OakVideoParams params);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Release one reference to a video parameter set.
|
||||
*
|
||||
* Convenience wrapper around handle.release(handle.ctx): decrements the
|
||||
* atomic reference count and destroys the object when it reaches zero.
|
||||
* No-op when params is NULL or params->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_videoparams_free(OakVideoParams *params);
|
||||
|
||||
int oakcommon_videoparams_get_width(OakVideoParams params, int *width);
|
||||
int oakcommon_videoparams_set_width(OakVideoParams params, int width);
|
||||
int oakcommon_videoparams_get_height(OakVideoParams params, int *height);
|
||||
int oakcommon_videoparams_set_height(OakVideoParams params, int height);
|
||||
int oakcommon_videoparams_get_depth(OakVideoParams params, int *depth);
|
||||
int oakcommon_videoparams_set_depth(OakVideoParams params, int depth);
|
||||
int oakcommon_videoparams_get_is_3d(OakVideoParams params, int *is_3d);
|
||||
|
||||
/**
|
||||
* @brief Rational getters return the value as a numerator/denominator pair.
|
||||
*/
|
||||
int oakcommon_videoparams_get_time_base(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_time_base(OakVideoParams params,
|
||||
int *numerator, int *denominator);
|
||||
int oakcommon_videoparams_set_time_base(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_time_base(OakVideoParams params,
|
||||
int numerator, int denominator);
|
||||
int oakcommon_videoparams_get_frame_rate(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_frame_rate(OakVideoParams params,
|
||||
int *numerator, int *denominator);
|
||||
int oakcommon_videoparams_set_frame_rate(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_frame_rate(OakVideoParams params,
|
||||
int numerator, int denominator);
|
||||
int oakcommon_videoparams_frame_rate_as_time_base(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_frame_rate_as_time_base(OakVideoParams params,
|
||||
int *numerator,
|
||||
int *denominator);
|
||||
int oakcommon_videoparams_get_pixel_aspect_ratio(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_pixel_aspect_ratio(OakVideoParams params,
|
||||
int *numerator,
|
||||
int *denominator);
|
||||
int oakcommon_videoparams_set_pixel_aspect_ratio(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_pixel_aspect_ratio(OakVideoParams params,
|
||||
int numerator, int denominator);
|
||||
|
||||
/**
|
||||
* @brief Format getters/setters use the OakCommonPixelFormat codes.
|
||||
* @brief Format getters/setters use the OakPixelFormat 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 oakcommon_videoparams_get_format(OakVideoParams params, int *format);
|
||||
int oakcommon_videoparams_set_format(OakVideoParams params, int format);
|
||||
int oakcommon_videoparams_get_channel_count(OakVideoParams params,
|
||||
int *count);
|
||||
int oakcommon_videoparams_set_channel_count(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_channel_count(OakVideoParams params,
|
||||
int count);
|
||||
int oakcommon_videoparams_get_interlacing(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_interlacing(OakVideoParams params,
|
||||
int *interlacing);
|
||||
int oakcommon_videoparams_set_interlacing(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_interlacing(OakVideoParams params,
|
||||
int interlacing);
|
||||
int oakcommon_videoparams_get_divider(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_divider(OakVideoParams params,
|
||||
int *divider);
|
||||
int oakcommon_videoparams_set_divider(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_divider(OakVideoParams params,
|
||||
int divider);
|
||||
int oakcommon_videoparams_get_enabled(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_enabled(OakVideoParams params,
|
||||
int *enabled);
|
||||
int oakcommon_videoparams_set_enabled(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_enabled(OakVideoParams 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 oakcommon_videoparams_get_x(OakVideoParams params, float *x);
|
||||
int oakcommon_videoparams_set_x(OakVideoParams params, float x);
|
||||
int oakcommon_videoparams_get_y(OakVideoParams params, float *y);
|
||||
int oakcommon_videoparams_set_y(OakVideoParams params, float y);
|
||||
int oakcommon_videoparams_get_stream_index(OakVideoParams params,
|
||||
int *index);
|
||||
int oakcommon_videoparams_set_stream_index(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_stream_index(OakVideoParams params,
|
||||
int index);
|
||||
int oakcommon_videoparams_get_video_type(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_video_type(OakVideoParams params,
|
||||
int *type);
|
||||
int oakcommon_videoparams_set_video_type(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_video_type(OakVideoParams params,
|
||||
int type);
|
||||
int oakcommon_videoparams_get_start_time(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_start_time(OakVideoParams params,
|
||||
int64_t *start_time);
|
||||
int oakcommon_videoparams_set_start_time(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_start_time(OakVideoParams params,
|
||||
int64_t start_time);
|
||||
int oakcommon_videoparams_get_duration(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_duration(OakVideoParams params,
|
||||
int64_t *duration);
|
||||
int oakcommon_videoparams_set_duration(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_duration(OakVideoParams params,
|
||||
int64_t duration);
|
||||
int oakcommon_videoparams_get_premultiplied_alpha(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_premultiplied_alpha(OakVideoParams params,
|
||||
int *premultiplied);
|
||||
int oakcommon_videoparams_set_premultiplied_alpha(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_premultiplied_alpha(OakVideoParams params,
|
||||
int premultiplied);
|
||||
int oakcommon_videoparams_get_color_range(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_color_range(OakVideoParams params,
|
||||
int *color_range);
|
||||
int oakcommon_videoparams_set_color_range(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_color_range(OakVideoParams params,
|
||||
int color_range);
|
||||
int oakcommon_videoparams_get_color_primaries(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_color_primaries(OakVideoParams params,
|
||||
int *primaries);
|
||||
int oakcommon_videoparams_set_color_primaries(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_color_primaries(OakVideoParams params,
|
||||
int primaries);
|
||||
int oakcommon_videoparams_get_color_transfer(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_color_transfer(OakVideoParams params,
|
||||
int *transfer);
|
||||
int oakcommon_videoparams_set_color_transfer(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_color_transfer(OakVideoParams params,
|
||||
int transfer);
|
||||
|
||||
/**
|
||||
@@ -192,29 +243,29 @@ int oakcommon_videoparams_set_color_transfer(OakCommonVideoParams *params,
|
||||
* @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,
|
||||
int oakcommon_videoparams_get_colorspace(OakVideoParams params,
|
||||
char *buf, int buf_size);
|
||||
int oakcommon_videoparams_set_colorspace(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_set_colorspace(OakVideoParams params,
|
||||
const char *colorspace);
|
||||
|
||||
/**
|
||||
* @brief Width multiplied by the pixel aspect ratio.
|
||||
*/
|
||||
int oakcommon_videoparams_get_square_pixel_width(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_square_pixel_width(OakVideoParams params,
|
||||
int *width);
|
||||
int oakcommon_videoparams_get_effective_width(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_effective_width(OakVideoParams params,
|
||||
int *width);
|
||||
int oakcommon_videoparams_get_effective_height(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_effective_height(OakVideoParams params,
|
||||
int *height);
|
||||
int oakcommon_videoparams_get_effective_depth(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_effective_depth(OakVideoParams params,
|
||||
int *depth);
|
||||
int oakcommon_videoparams_get_is_valid(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_is_valid(OakVideoParams params,
|
||||
int *is_valid);
|
||||
int oakcommon_videoparams_get_bytes_per_channel(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_bytes_per_channel(OakVideoParams params,
|
||||
int *bytes);
|
||||
int oakcommon_videoparams_get_bytes_per_pixel(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_bytes_per_pixel(OakVideoParams params,
|
||||
int *bytes);
|
||||
int oakcommon_videoparams_get_buffer_size(OakCommonVideoParams *params,
|
||||
int oakcommon_videoparams_get_buffer_size(OakVideoParams params,
|
||||
int *size);
|
||||
|
||||
/**
|
||||
@@ -224,14 +275,14 @@ int oakcommon_videoparams_get_buffer_size(OakCommonVideoParams *params,
|
||||
* set.
|
||||
*/
|
||||
int oakcommon_videoparams_get_time_in_timebase_units(
|
||||
OakCommonVideoParams *params, int time_num, int time_den,
|
||||
OakVideoParams 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);
|
||||
int oakcommon_videoparams_equals(OakVideoParams params,
|
||||
OakVideoParams other, int *equal);
|
||||
|
||||
/**
|
||||
* @brief Load parameters from an XML fragment.
|
||||
@@ -239,7 +290,7 @@ int oakcommon_videoparams_equals(OakCommonVideoParams *params,
|
||||
* @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,
|
||||
int oakcommon_videoparams_load_xml(OakVideoParams params,
|
||||
const char *xml);
|
||||
|
||||
/**
|
||||
@@ -248,7 +299,7 @@ int oakcommon_videoparams_load_xml(OakCommonVideoParams *params,
|
||||
* @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 oakcommon_videoparams_save_xml(OakVideoParams params, char *buf,
|
||||
int buf_size);
|
||||
|
||||
/* Static helpers (no handle required). */
|
||||
@@ -294,6 +345,21 @@ int oakcommon_videoparams_get_format_name(int pixel_format, char *buf,
|
||||
int oakcommon_videoparams_frame_rate_to_string(int numerator, int denominator,
|
||||
char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
* @brief Get bytes per channel.
|
||||
*
|
||||
* @return Bytes per channel.
|
||||
*/
|
||||
int oakcommon_videoparams_static_get_bytes_per_channel(OakPixelFormat format);
|
||||
|
||||
/**
|
||||
* @brief Get bytes per pixel.
|
||||
*
|
||||
* @return Bytes per pixel.
|
||||
*/
|
||||
int oakcommon_videoparams_static_get_bytes_per_pixel(OakPixelFormat format,
|
||||
int channels);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
+59
-25
@@ -22,26 +22,56 @@
|
||||
#define OAK_EDITOR_XMLUTILS_H
|
||||
|
||||
#include "common/error.h"
|
||||
#include "common/handle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct OakCommonXmlReader OakCommonXmlReader;
|
||||
typedef struct OakCommonXmlWriter OakCommonXmlWriter;
|
||||
/**
|
||||
* @brief Neutral by-value handle to a streaming XML reader.
|
||||
*
|
||||
* Ownership/count semantics follow the convention in common/handle.h:
|
||||
* init returns a handle whose object has reference count 1,
|
||||
* addref(ctx)/release(ctx) adjust it atomically, and release destroys
|
||||
* the object at zero. abi_version is always OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakXmlReader {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakXmlReader;
|
||||
|
||||
/**
|
||||
* @brief Neutral by-value handle to a streaming XML writer.
|
||||
*
|
||||
* Same ownership/count semantics as OakXmlReader.
|
||||
*/
|
||||
typedef struct OakXmlWriter {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakXmlWriter;
|
||||
|
||||
/**
|
||||
* @brief Create a streaming XML reader over a complete document.
|
||||
*
|
||||
* @param data NUL-terminated XML text. Must not be NULL.
|
||||
* @return A new reader, or NULL on failure (NULL data, out of memory).
|
||||
* @return Handle with reference count 1; ctx is NULL on failure
|
||||
* (NULL data, out of memory).
|
||||
*/
|
||||
OakCommonXmlReader *oakcommon_xml_reader_init(const char *data);
|
||||
OakXmlReader oakcommon_xml_reader_init(const char *data);
|
||||
|
||||
/**
|
||||
* @brief Destroy a reader. No-op on NULL.
|
||||
* @brief Release one reference to a reader.
|
||||
*
|
||||
* Convenience wrapper around handle.release(handle.ctx): decrements the
|
||||
* atomic reference count and destroys the object when it reaches zero.
|
||||
* No-op when reader is NULL or reader->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_xml_reader_free(OakCommonXmlReader *reader);
|
||||
void oakcommon_xml_reader_free(OakXmlReader *reader);
|
||||
|
||||
/**
|
||||
* @brief Advance until the next start element, an end element, or the end
|
||||
@@ -51,7 +81,7 @@ void oakcommon_xml_reader_free(OakCommonXmlReader *reader);
|
||||
* @param found Out: 1 if positioned on a start element, 0 otherwise.
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_read_next_start_element(OakCommonXmlReader *reader,
|
||||
int oakcommon_xml_reader_read_next_start_element(OakXmlReader reader,
|
||||
int *found);
|
||||
|
||||
/**
|
||||
@@ -60,7 +90,7 @@ int oakcommon_xml_reader_read_next_start_element(OakCommonXmlReader *reader,
|
||||
* @return Required buffer size in bytes (including NUL), or a negative
|
||||
* OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_name(OakCommonXmlReader *reader, char *buf,
|
||||
int oakcommon_xml_reader_name(OakXmlReader reader, char *buf,
|
||||
int buf_size);
|
||||
|
||||
/**
|
||||
@@ -72,7 +102,7 @@ int oakcommon_xml_reader_name(OakCommonXmlReader *reader, char *buf,
|
||||
* @return Required buffer size in bytes (including NUL), or a negative
|
||||
* OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_read_element_text(OakCommonXmlReader *reader,
|
||||
int oakcommon_xml_reader_read_element_text(OakXmlReader reader,
|
||||
char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -80,14 +110,14 @@ int oakcommon_xml_reader_read_element_text(OakCommonXmlReader *reader,
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_skip_current_element(OakCommonXmlReader *reader);
|
||||
int oakcommon_xml_reader_skip_current_element(OakXmlReader reader);
|
||||
|
||||
/**
|
||||
* @brief Number of attributes on the current start element.
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_attribute_count(OakCommonXmlReader *reader,
|
||||
int oakcommon_xml_reader_attribute_count(OakXmlReader reader,
|
||||
int *count);
|
||||
|
||||
/**
|
||||
@@ -96,7 +126,7 @@ int oakcommon_xml_reader_attribute_count(OakCommonXmlReader *reader,
|
||||
* @return Required buffer size in bytes (including NUL), OAKCOMMON_E_NOT_FOUND
|
||||
* if @p index is out of range, or another negative OAKCOMMON_E_* code.
|
||||
*/
|
||||
int oakcommon_xml_reader_attribute_name(OakCommonXmlReader *reader, int index,
|
||||
int oakcommon_xml_reader_attribute_name(OakXmlReader reader, int index,
|
||||
char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -105,7 +135,7 @@ int oakcommon_xml_reader_attribute_name(OakCommonXmlReader *reader, int index,
|
||||
* @return Required buffer size in bytes (including NUL), OAKCOMMON_E_NOT_FOUND
|
||||
* if @p index is out of range, or another negative OAKCOMMON_E_* code.
|
||||
*/
|
||||
int oakcommon_xml_reader_attribute_value(OakCommonXmlReader *reader,
|
||||
int oakcommon_xml_reader_attribute_value(OakXmlReader reader,
|
||||
int index, char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -113,32 +143,36 @@ int oakcommon_xml_reader_attribute_value(OakCommonXmlReader *reader,
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_has_error(OakCommonXmlReader *reader,
|
||||
int oakcommon_xml_reader_has_error(OakXmlReader reader,
|
||||
int *has_error);
|
||||
|
||||
/**
|
||||
* @brief Create a streaming XML writer.
|
||||
*
|
||||
* @return A new writer, or NULL on failure.
|
||||
* @return Handle with reference count 1; ctx is NULL on failure.
|
||||
*/
|
||||
OakCommonXmlWriter *oakcommon_xml_writer_init(void);
|
||||
OakXmlWriter oakcommon_xml_writer_init(void);
|
||||
|
||||
/**
|
||||
* @brief Destroy a writer. No-op on NULL.
|
||||
* @brief Release one reference to a writer.
|
||||
*
|
||||
* Convenience wrapper around handle.release(handle.ctx): decrements the
|
||||
* atomic reference count and destroys the object when it reaches zero.
|
||||
* No-op when writer is NULL or writer->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_xml_writer_free(OakCommonXmlWriter *writer);
|
||||
void oakcommon_xml_writer_free(OakXmlWriter *writer);
|
||||
|
||||
int oakcommon_xml_writer_write_start_element(OakCommonXmlWriter *writer,
|
||||
int oakcommon_xml_writer_write_start_element(OakXmlWriter writer,
|
||||
const char *name);
|
||||
int oakcommon_xml_writer_write_attribute(OakCommonXmlWriter *writer,
|
||||
int oakcommon_xml_writer_write_attribute(OakXmlWriter writer,
|
||||
const char *name, const char *value);
|
||||
int oakcommon_xml_writer_write_characters(OakCommonXmlWriter *writer,
|
||||
int oakcommon_xml_writer_write_characters(OakXmlWriter writer,
|
||||
const char *text);
|
||||
int oakcommon_xml_writer_write_text_element(OakCommonXmlWriter *writer,
|
||||
int oakcommon_xml_writer_write_text_element(OakXmlWriter writer,
|
||||
const char *name,
|
||||
const char *text);
|
||||
int oakcommon_xml_writer_write_end_element(OakCommonXmlWriter *writer);
|
||||
int oakcommon_xml_writer_write_end_document(OakCommonXmlWriter *writer);
|
||||
int oakcommon_xml_writer_write_end_element(OakXmlWriter writer);
|
||||
int oakcommon_xml_writer_write_end_document(OakXmlWriter writer);
|
||||
|
||||
/**
|
||||
* @brief The document written so far.
|
||||
@@ -146,7 +180,7 @@ int oakcommon_xml_writer_write_end_document(OakCommonXmlWriter *writer);
|
||||
* @return Required buffer size in bytes (including NUL), or a negative
|
||||
* OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_writer_output(OakCommonXmlWriter *writer, char *buf,
|
||||
int oakcommon_xml_writer_output(OakXmlWriter writer, char *buf,
|
||||
int buf_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user