Home/docs/reference/C ABI overview
C ABI overview
C ABI Overview
Global conventions and type definitions for the C ABI. The function lists are split by entry family: ErikaHandle (23), ErikaPresenterHandle (82), and general and standalone entry points (20). crates/erika_capi/include/erika.h is the sole authority.
Entry points and conventions入口と規約#
There are two independent entry families. Integrate one or the other, not both:
- ErikaHandle — pull model. The host renders and polls state.
- ErikaPresenterHandle — push model. The engine manages decoding, timing, audio, and rendering; the host provides a surface and calls
render_tick. Available on macOS / iOS / tvOS / Windows / Android / OpenHarmony / Linux; on other targetscreatereturns NULL.
Global conventions:
- Functions that return a status use
ErikaStatus:Ok(0) andNoEvent(5) are non-error results. Other functions return pointers, values, or nothing; consult the header for their failure conventions. Many status-returning operations catch panics asErikaStatus_Panic, but not every entry point catches panics, and panic-abort builds can terminate the process. - Some failures set a thread-local error message, but not every failure guarantees one; the slot may be empty or retain an earlier message. On the thread where the call failed, before making another call, read any available message with
erika_last_error_message()and free a non-null result witherika_string_free(). For example,erika_add_external_subtitlereturns NullPointer directly whenout_track_idis NULL, without updating the slot. - A
char*returned by liberika belongs to the caller. Free independent strings witherika_string_free(); release strings insideErikaTrackInfo/ErikaDanmakuTrackInfowith the matching*_info_free(). const char*parameters are borrowed only for the duration of the call and must be NUL-terminated UTF-8.- List queries use the counted-array idiom
(buf, capacity, &len).lenis set to the total count, and at mostcapacityentries are written. When capacity is 0 and buf is NULL, the call only queries the count. - The width and height passed to attach and resize are in physical pixels. scale is the DPI ratio for logical content such as UI and danmaku; it does not scale the surface extent.
- A handle has no internal synchronization and must not be called concurrently from multiple threads.
ErikaStatusステータス#
| Value | Name | Description |
|---|---|---|
| 0 | Ok | Success. |
| 1 | NullPointer | A parameter is a null pointer. |
| 2 | InvalidUtf8 | A string parameter is not valid UTF-8. |
| 3 | PlayerError | Player error. |
| 4 | Panic | Internal panic, caught. |
| 5 | NoEvent | The event queue is empty (not an error). |
ErikaState状態#
| Value | Name | Description |
|---|---|---|
| 0 | Idle | The initial state after creation. |
| 1 | Opening | Opening. |
| 2 | Ready | Ready, not playing. |
| 3 | Playing | Playing. |
| 4 | Paused | Paused. |
| 5 | Stopped | Stopped. |
| 6 | Closed | Closed. |
| 7 | Error | Error state. |
ErikaEventKindイベント#
The enum has 14 values: 13 event kinds and None. Value 13 is reserved for host use and is not emitted by the engine.
Events are retrieved with poll_event. The queue is unbounded: a host that never polls only accumulates events and stops observing state; no events are dropped. Only one group of fields in ErikaEvent is valid, as determined by kind. VideoDecoderChanged and AudioOutputChanged have no payload fields, but they write a structured message to the thread-local error slot, which you can read with erika_last_error_message.
| Value | Name | Description | Payload |
|---|---|---|---|
| 0 | None | No event. | — |
| 1 | StateChanged | Playback state changed. | state |
| 2 | DurationChanged | Duration determined or changed. | duration_micros |
| 3 | PositionChanged | Playback position advanced. Sent about every 100 ms during playback, and separately on seek, play, and EOF. | position_micros |
| 4 | TracksChanged | Track list changed. | tracks; re-query the tracks afterward |
| 5 | BufferingChanged | Buffering state toggled. | buffering |
| 6 | VideoParamsChanged | Video parameters changed. | video |
| 7 | SurfaceAttached | Surface attached. | — |
| 8 | SurfaceDetached | Surface detached. | — |
| 9 | Error | Error. | status; last_error_message on the same thread returns details |
| 10 | TrackSelectionChanged | Selected track changed. | — |
| 11 | VideoDecoderChanged | Video decoding backend switched. | — |
| 12 | AudioOutputChanged | Audio output state changed. | — |
| 14 | Ended | Natural playback completion, after Stopped; an explicit stop does not emit it. | — |
Type inventory型#
All 50 type definitions are in erika.h. The tables below list the fields of the main structs; for complete field and enumeration definitions, the header of the same version is authoritative.
Handles
ErikaHandle— Pull-model handle.ErikaPresenterHandle— Push-model handle.ErikaFrameExportSession— Standalone frame export session handle.ErikaColdOpenCancellation— One-shot ticket for cancelling an open (0.3.8, experimental).
Structs
| Type | Purpose |
|---|---|
| ErikaHttpHeader | HTTP request header used when opening (name / value). |
| ErikaPresenterConfig | Output mode, EDR headroom, upscaling, and video alpha mode. |
| ErikaSubtitleStyle | Subtitle style override, including override_mask. |
| ErikaSurfaceOutputCapabilities | Surface output capabilities (extended-linear, direct composition, headroom). |
| ErikaUpscalerStatus | Upscaling status and frame counts. |
| ErikaOutputStatus | Output encoding, headroom, and fallback state. |
| ErikaPresenterResourceStatus | Renderer memory snapshot. |
| ErikaSubtitleMemoryFontStatus | In-memory font registration status. |
| ErikaSubtitleMemoryFontFace / Info | In-memory font face and metadata. |
| ErikaDanmakuConfig | Danmaku layout and display parameters. |
| ErikaDanmakuTrackInfo | Danmaku track information. |
| ErikaVideoParams | Video size, color primaries, and transfer. |
| ErikaTrackCounts / Selection / Info | Track counts, current selection, track info. |
| ErikaEvent | Event payload. |
| ErikaPresenterStats | Rendering statistics; fields are listed in the table below. |
New types in 0.3.0
ErikaFrameExportFormat defines RGBA (0) and PNG (1). ErikaFrameExportOptions, ErikaFrameExportResult, ErikaFrameExportSessionOptions, and ErikaFrameExportRequest describe a single export, its result, opening a session, and per-frame requests, respectively. ErikaFrameExportSession is an opaque session handle. ErikaLogLevel runs from Trace (0) to Error (4). For the full declarations and ownership rules, see Frame export and logging.
Struct fields
The tables below list the fields, types, and semantics of the commonly used structs. Field names match erika.h.
ErikaSubtitleStyle
Fallback subtitle appearance defaults to opaque white text (0xFFFFFFFF) with a translucent black outline (0x0000007F). Out-of-range numeric metrics are clamped rather than rejected; an out-of-range border_style or alignment is replaced with its default (1 and 2, respectively). How the fields take effect depends on the subtitle type. On container ASS tracks, these fields have no effect when override_mask is 0, except for font-family fallback; setting a bit makes the corresponding field override the style declared by the ASS dialogue. For plain-text subtitles (SRT/WebVTT), liberika bakes the whole style into the ASS header it generates, regardless of override_mask. All dimensions are in ASS script units and are multiplied by the set_subtitle_scale factor.
| Field | Type | Description |
|---|---|---|
| font_family | const char* | NULL or an empty string keeps the platform default. |
| font_file_path | const char* | Font file path. |
| primary_color_rgba | uint32_t | Text color, 0xRRGGBBAA. |
| outline_color_rgba | uint32_t | Outline color, 0xRRGGBBAA. |
| font_size | double | 8..400, default 48. |
| outline_width | double | 0..32, default 2. |
| bold / italic / underline / strike_out | bool | Glyph attributes. |
| spacing | double | -100..100. |
| scale_x_percent / scale_y_percent | double | 1..1000, 100 = no scaling. |
| border_style | int32_t | 1 = outline + shadow, 3 = opaque box. |
| shadow_depth | double | 0..32. |
| blur | double | 0..100. |
| alignment | int32_t | 1..9, numeric keypad layout; 2 = bottom center. |
| margin_left / margin_right / margin_vertical | int32_t | Margins, clamped to 0..10000. |
| override_mask | uint32_t | Override bitmask; see the bit table below. |
When an override bit is set, dimensions stay resolution-independent: a font_size of 48 yields the same pixel size regardless of the PlayResY the script declares. Margins are the exception: on container ASS tracks they scale with the script’s PlayResY, while on plain-text subtitles they are in pixels (liberika generates that script to match the frame size). With a zero mask, all fields stay fallback-only: they have no effect on container tracks, and erika_presenter_set_subtitle_style only influences font selection.
ErikaDanmakuConfig
Scroll duration formula: milliseconds to cross the screen = scroll_duration_seconds × clamp(logical width / 1280, 0.9, 1.3) × 1000 / scroll_speed_factor; speed = (viewport width + text width) / duration. max_quantity is a density filter on the number of items on screen at once within the scroll window, and applies only to scrolling danmaku. For max_lines_per_mode, “per mode” means one limit each for scroll-left, scroll-right, top, and bottom. set_danmaku_config replaces the fields visible from C; block_words and the custom font fields are inherited from the current configuration.
| Field | Type | Default | Description |
|---|---|---|---|
| enabled | bool | true | Danmaku master switch. |
| font_size | float | 30 | NipaPlay/Flutter logical font size; converted to glyph pixels using the surface scale. |
| opacity | float | 1.0 | Opacity. |
| display_area | float | 1.0 | Fraction of the viewport height used by the danmaku area, clamped to 0.1..1.0. |
| scroll_duration_seconds | float | 10.0 | Baseline time for scrolling danmaku to cross the screen, clamped to 1..60 seconds. |
| scroll_speed_factor | float | 1.0 | Scroll speed factor, clamped to 0.2..4.0; larger is faster. |
| track_gap_ratio | float | 0.15 | Track line spacing = danmaku height × this ratio, clamped to 0..2. |
| outline_width | float | 1.0 | Outline width. |
| shadow_offset_x / shadow_offset_y | float | 1.0 / 1.0 | Shadow offset. |
| merge_duplicates | bool | false | Merge duplicate danmaku. |
| allow_stacking | bool | false | Allow stacking within the same track. |
| allow_scroll_overwrite | bool | false | Allow scrolling danmaku to overwrite one another. |
| max_quantity | uint32_t | 0 | Upper limit on scrolling danmaku density; 0 = unlimited. |
| max_lines_per_mode | uint32_t | 0 | Maximum number of lines per danmaku mode; 0 = unlimited. |
| block_top / block_bottom / block_scroll | bool | false | Block top / bottom / scrolling danmaku. |
| shadow_style | int32_t | 3 | 0 None / 1 Soft / 2 Medium / 3 Strong; unknown values fall back to 3. |
ErikaPresenterConfig
| Field | Type | Description |
|---|---|---|
| output_mode | int32_t | ErikaPresenterOutputMode. |
| edr_headroom | float | EDR headroom; 0 = automatic. |
| luma_upscaler | int32_t | ErikaLumaUpscalerMode. |
| video_alpha_mode | int32_t | ErikaVideoAlphaMode: 0 = Opaque, 1 = PackedAlphaRight. |
ErikaSurfaceOutputCapabilities
Display and surface probe results that the host provides at attach.
| Field | Type | Description |
|---|---|---|
| extended_linear | bool | The surface supports extended-linear. |
| direct_composition | bool | Direct composition is supported. |
| desired_headroom | float | Desired headroom; 0 = system automatic. |
| fallback_reason | int32_t | ErikaOutputFallbackReason. |
ErikaUpscalerStatus
| Field | Type | Description |
|---|---|---|
| requested_mode | int32_t | Requested mode, ErikaLumaUpscalerMode. |
| active_backend | int32_t | Active backend, ErikaUpscalerBackendStatus. |
| fallback_count | uint64_t | Fallback count. |
| upscaled_frames | uint64_t | Number of upscaled frames. |
| last_encode_micros | uint64_t | Duration of the last encode, in microseconds. |
| last_gpu_micros | uint64_t | Duration of the last GPU pass, in microseconds. |
ErikaOutputStatus
| Field | Type | Description |
|---|---|---|
| requested_mode | int32_t | ErikaPresenterOutputMode. |
| active_encoding | int32_t | ErikaActiveOutputEncoding. |
| surface_format | int32_t | ErikaOutputSurfaceFormat. |
| native_data_space | int32_t | Native data-space handle. |
| requested_headroom | float | Requested headroom. |
| active_headroom | float | Headroom currently in effect. |
| active_headroom_known | bool | Whether the headroom is known. |
| extended_linear_active | bool | Whether extended-linear is active. |
| fallback_reason | int32_t | ErikaOutputFallbackReason. |
| fallback_count | uint64_t | Fallback count. |
| data_space_failures | uint64_t | Number of data-space failures. |
| headroom_updates | uint64_t | Number of headroom updates. |
| extended_linear_frames | uint64_t | Number of extended-linear frames. |
ErikaPresenterResourceStatus
Renderer memory snapshot. device_current_allocated_bytes is the Metal device-level process counter and may include allocations made by other Presenters.
| Field | Type | Description |
|---|---|---|
| device_current_allocated_bytes | uint64_t | Bytes currently allocated on the device. |
| device_recommended_working_set_bytes | uint64_t | Device-recommended working set, in bytes. |
| drawable_estimated_bytes | uint64_t | Estimated drawable bytes. |
| video_frame_bytes | uint64_t | Video frame bytes. |
| overlay_atlas_bytes | uint64_t | Subtitle atlas bytes. |
| danmaku_atlas_bytes | uint64_t | Danmaku atlas bytes. |
| danmaku_vertex_buffer_bytes | uint64_t | Danmaku vertex buffer bytes. |
| upscaler_bytes | uint64_t | Upscaler bytes. |
| renderer_tracked_bytes | uint64_t | Total bytes tracked by the renderer. |
| presenter_cpu_danmaku_atlas_bytes | uint64_t | CPU-side danmaku atlas bytes in the Presenter. |
| drawable_count | uint32_t | Drawable count. |
| output_mode_switches | uint64_t | Number of output mode switches. |
ErikaSubtitleMemoryFont*
| Type | Field | Type | Description |
|---|---|---|---|
| Status | registered_count | uintptr_t | Number of registered fonts. |
| registered_bytes | uintptr_t | Total registered bytes. | |
| selected_count | uintptr_t | Number of selected fonts. | |
| generation | uint64_t | Registration generation; a change means the registry was updated. | |
| selected_ids | uint64_t* | Array of selected font ids. | |
| Face | index | uint32_t | Index within the font collection. |
| families_json | char* | Family list, as JSON. | |
| post_script_name | char* | PostScript name. | |
| weight | uint16_t | Font weight. | |
| italic | bool | Whether the face is italic. | |
| monospaced | bool | Whether the face is monospaced. | |
| Info | id | uint64_t | Font id. |
| byte_len | uintptr_t | Font data size, in bytes. | |
| faces | Face* | Array of faces. | |
| face_count | uintptr_t | Number of faces. |
ErikaDanmakuTrackInfo
The caller owns the strings after the call returns. Release them with erika_danmaku_track_info_free.
| Field | Type | Description |
|---|---|---|
| id | uint64_t | Track id. |
| enabled | bool | Whether the track is enabled. |
| offset_micros | int64_t | Track time offset, in microseconds. |
| item_count | uintptr_t | Number of danmaku items. |
| name | char* | Track name. |
| source | char* | Source description. |
ErikaVideoParams
Video size and color metadata, reported through the VideoParamsChanged event. primaries and transfer are the project’s own enumeration values, converted from FFmpeg enumerations; they are not FFmpeg’s raw constants.
| Field | Type | Description |
|---|---|---|
| width / height | uint32_t | Video pixel size. |
| primaries | uint32_t | 0 Unknown / 1 Bt709 / 2 DisplayP3 / 3 Bt2020. |
| transfer | uint32_t | 0 Unknown / 1 Srgb / 2 Bt1886 / 3 Pq / 4 Hlg. |
Mapping: the BT.709 transfer function maps to Bt1886, and anything unrecognized maps to 0. The values come from the color information in the video track’s AVCodecParameters.
ErikaTrackCounts / ErikaTrackSelection
| Type | Field | Type | Description |
|---|---|---|---|
| Counts | video / audio / subtitle | uint32_t | Number of tracks of each kind. |
| Selection | video / audio / subtitle | int64_t | Id of the selected track of each kind; -1 = none. |
ErikaTrackInfo
The caller owns the six string fields; release them with erika_track_info_free. bit_rate (bit/s) is populated for all track kinds; the frame rate fields apply only to video tracks (frame_rate_numerator / frame_rate_denominator, 0 = unknown).
| Field | Type | Description |
|---|---|---|
| id | int64_t | Track id. |
| kind | ErikaTrackKind | Video / Audio / Subtitle. |
| source | ErikaTrackSource | Embedded / external. |
| selected | bool | Whether the track is selected. |
| can_remove | bool | Whether the track can be removed (true for external tracks). |
| title | char* | Title. |
| language | char* | Language code. |
| codec | char* | Codec name. |
| width / height | uint32_t | Video track pixel size. |
| sample_rate / channels | uint32_t | Audio track sample rate / channel count. |
| pixel_format | char* | Video pixel format. |
| sample_format | char* | Audio sample format. |
| profile | char* | Codec profile. |
| level | int32_t | Codec level. |
| bit_rate | uint64_t | Bit rate, bit/s. |
| frame_rate_numerator / frame_rate_denominator | uint32_t | Frame rate as a fraction; 0/0 = unknown. |
ErikaEvent
The valid fields form a union selected by kind; see the event table.
| Field | Type | Description |
|---|---|---|
| kind | ErikaEventKind | Event kind; determines which other fields are valid. |
| status | ErikaStatus | Error code carried by an Error event. |
| state | ErikaState | New state carried by StateChanged. |
| duration_micros | int64_t | Duration carried by DurationChanged. |
| position_micros | uint64_t | Position carried by PositionChanged. |
| buffering | bool | Buffering state carried by BufferingChanged. |
| video | ErikaVideoParams | Parameters carried by VideoParamsChanged. |
| tracks | ErikaTrackCounts | Counts carried by TracksChanged. |
ErikaPresenterStats
Render pipeline counters: decode, render, audio, and overlay counts; software versus hardware decoding and zero-copy breakdowns; and HDR and audio recovery breakdowns. audio_recovery_state values: 0 stable / 1 disconnected / 2 recovering / 3 failed.
| Field | Type | Description |
|---|---|---|
| decoded_video_frames | uint64_t | Decoded video frames. |
| rendered_video_frames | uint64_t | Rendered video frames. |
| rendered_test_frames | uint64_t | Rendered test frames. |
| pushed_audio_frames | uint64_t | Pushed audio frames. |
| overlay_frames | uint64_t | Subtitle overlay frames. |
| danmaku_frames / danmaku_items | uint64_t | Danmaku rendered frames / item count. |
| import_failures / render_failures / audio_failures | uint64_t | Import / render / audio failure counts. |
| software_video_frames / hardware_video_frames | uint64_t | Software-decoded / hardware-decoded frames. |
| zero_copy_video_frames | uint64_t | Zero-copy frames. |
| cpu_video_frame_fallbacks | uint64_t | Number of frames that fell back to the CPU. |
| last_render_micros / last_render_current_micros | uint64_t | Duration of the last full tick / renderer call, in microseconds. |
| audio_clock_read_frames / audio_clock_queued_frames / audio_clock_underflow_frames | uint64_t | Audio clock frames read / queued / underrun. |
| audio_recovery_state | int32_t | 0 stable / 1 disconnected / 2 recovering / 3 failed. |
| audio_last_error_code | int32_t | Last audio error code. |
| audio_recovery_attempts / audio_recovery_count / audio_recovery_failures | uint64_t | Audio recovery attempts / successes / failures. |
| direct_zero_copy_video_frames / shared_handle_video_frames | uint64_t | Direct zero-copy / shared-handle frames. |
| hdr_source_frames / hdr10_output_frames / sdr_tonemap_frames | uint64_t | HDR source / HDR10 output / SDR tone-mapped frames. |
| hdr10_metadata_updates / hdr10_metadata_failures / hdr10_output_failures | uint64_t | HDR10 metadata updates / metadata failures / output failures. |
| hdr10_output_active | bool | Whether HDR10 output is active. |
| video_frame_backpressure_drops | uint64_t | Frames dropped due to backpressure. |
Platform differences: on the wgpu backend, last_gpu_micros and direct_zero_copy_video_frames are always 0 (only Metal reports GPU time, and the direct-import count increments only on D3D11). shared_handle_video_frames increments only on wgpu (Android / OpenHarmony), and hdr10_output_frames increments only on D3D11. decoded_video_frames counts decoded frames sent to the renderer for upload; rendered_video_frames counts frames successfully drawn to the surface. The difference is the number of frames that were never presented.
Subtitle style override mask
override_mask is a bitwise OR of ERIKA_SUBTITLE_OVERRIDE_* values, which mirror libass’s ASS_OVERRIDE_BIT_* values. Setting a bit makes the corresponding fields override the style that an ASS dialogue event requests, instead of acting as a fallback; 0 keeps all fields as fallbacks. Unknown bits are discarded.
| Macro | Bit | Fields covered |
|---|---|---|
| ERIKA_SUBTITLE_OVERRIDE_FONT_SIZE_FIELDS | 1u<<2 | font_size, spacing, scale_x_percent, scale_y_percent |
| ERIKA_SUBTITLE_OVERRIDE_FONT_NAME | 1u<<3 | font_family |
| ERIKA_SUBTITLE_OVERRIDE_COLORS | 1u<<4 | primary_color_rgba, outline_color_rgba |
| ERIKA_SUBTITLE_OVERRIDE_ATTRIBUTES | 1u<<5 | bold, italic, underline, strike_out |
| ERIKA_SUBTITLE_OVERRIDE_BORDER | 1u<<6 | border_style, outline_width, shadow_depth |
| ERIKA_SUBTITLE_OVERRIDE_ALIGNMENT | 1u<<7 | alignment |
| ERIKA_SUBTITLE_OVERRIDE_MARGINS | 1u<<8 | margin_left, margin_right, margin_vertical |
| ERIKA_SUBTITLE_OVERRIDE_BLUR | 1u<<11 | blur |
| ERIKA_SUBTITLE_OVERRIDE_ALL | All bits | All of the above |
Enumerations
| Type | Purpose |
|---|---|
| ErikaStatus / ErikaState / ErikaEventKind | See the sections above. |
| ErikaTrackKind | Video / Audio / Subtitle. |
| ErikaTrackSource | Embedded / external. |
| ErikaWgpuSurfaceKind | wgpu surface kind, 9 members. |
| ErikaFlutterTextureKind | Flutter texture kind, 6 members. |
| ErikaPresenterOutputMode | SDR / Apple EDR / extended-linear / Auto. |
| ErikaActiveOutputEncoding | SDR sRGB / Apple EDR / Android scRGB / HDR10 PQ / Linux scRGB. |
| ErikaOutputFallbackReason | HDR fallback reason, 9 members. |
| ErikaOutputSurfaceFormat | 8-bit UNORM / 10-bit UNORM / 16-bit float. |
| ErikaLumaUpscalerMode | Off / ArtCNN / Anime4K / FSR 1.0 / platform video super resolution / MetalFX / custom model. |
| ErikaUpscalerBackendStatus | Upscaler backend status, 11 values. |
ErikaTrackKind / ErikaTrackSource
| Value | TrackKind | Value | TrackSource |
|---|---|---|---|
| 0 | Video | 0 | Embedded (in the container) |
| 1 | Audio | 1 | External (sideloaded) |
| 2 | Subtitle |
ErikaWgpuSurfaceKind
| Value | Name | Platform |
|---|---|---|
| 0 | Unknown | Unknown. |
| 1 | MacOsNsView | macOS NSView. |
| 2 | MacOsCaMetalLayer | macOS CAMetalLayer. |
| 3 | IosUiView | iOS UIView. |
| 4 | WindowsHwnd | Windows HWND. |
| 5 | XlibWindow | X11 (Xlib) window. |
| 6 | WaylandSurface | Wayland surface. |
| 7 | AndroidNativeWindow | Android ANativeWindow. |
| 8 | OhosNativeWindow | OpenHarmony native window. |
ErikaFlutterTextureKind
| Value | Name | Platform |
|---|---|---|
| 0 | Unknown | Unknown. |
| 1 | MacOsTextureRegistrar | macOS Flutter texture registrar. |
| 2 | IosTextureRegistrar | iOS Flutter texture registrar. |
| 3 | AndroidSurfaceTexture | Android SurfaceTexture. |
| 4 | WindowsTextureRegistrar | Windows Flutter texture registrar. |
| 5 | LinuxTextureRegistrar | Linux Flutter texture registrar. |
ErikaPresenterOutputMode / ErikaActiveOutputEncoding
| Value | PresenterOutputMode | Value | ActiveOutputEncoding |
|---|---|---|---|
| 0 | Sdr | 0 | SdrSrgb |
| 1 | AppleEdr | 1 | AppleEdr |
| 2 | ExtendedLinear | 2 | AndroidExtendedLinearScRgb |
| 3 | Auto | 3 | Hdr10Pq |
| — | — | 4 | LinuxExtendedLinearScRgb |
ErikaOutputFallbackReason
| Value | Name | Description |
|---|---|---|
| 0 | None | No fallback. |
| 1 | DisplayHdrUnsupported | The display does not support HDR. |
| 2 | HybridCompositionRequired | Hybrid composition is required. |
| 3 | WgpuBackendNotVulkan | The wgpu backend is not Vulkan. |
| 4 | Rgba16FloatSurfaceFormatUnavailable | RGBA16F surface format is not available. |
| 5 | NativeWindowDataSpaceApiUnavailable | The native window data-space API is unavailable. |
| 6 | ScrgbDataSpaceVerificationFailed | scRGB data-space verification failed. |
| 7 | SurfaceConfigureFailed | Surface configuration failed. |
| 8 | LegacyAppleEdrUnsupported | Legacy Apple EDR is not supported. |
ErikaOutputSurfaceFormat / ErikaLumaUpscalerMode / ErikaUpscalerBackendStatus
| Value | OutputSurfaceFormat | Value | LumaUpscalerMode | Value | UpscalerBackendStatus |
|---|---|---|---|---|---|
| 0 | EightBitUnorm | 0 | Off | 0 | Off |
| 1 | TenBitUnorm | 1 | ArtCnnC4F16 | 1 | Inactive (the selected mode cannot run on this backend; native sampling is retained) |
| 2 | SixteenBitFloat | 2 | ArtCnnC4F32 | 2 | Building |
| 3 | ArtCnnC4F16Ds | 3 | Scalar | ||
| 4 | ArtCnnC4F16Dn | 4 | SimdgroupMatrix | ||
| 5 | ArtCnnC4F32Ds | 5 | CooperativeMatrix | ||
| 6 | ArtCnnC4F32Dn | 6 | LinalgMatrix | ||
| 7 | ArtCnnR8F64 | 7 | VideoProcessor | ||
| 16 | Anime4kS | 8 | VideoToolbox | ||
| 17 | Anime4kM | 9 | MetalFx | ||
| 18 | Anime4kL | 10 | TensorOps | ||
| 19 | Anime4kVl | ||||
| 20 | Anime4kUl | ||||
| 21 | Anime4kDenoiseS | ||||
| 22 | Anime4kDenoiseM | ||||
| 23 | Anime4kDenoiseL | ||||
| 24 | Anime4kDenoiseVl | ||||
| 25 | Anime4kDenoiseUl | ||||
| 32 | Fsr1 | ||||
| 48 | PlatformVideo | ||||
| 49 | MetalFxSpatial | ||||
| 64 | Custom |
Open options and GIF export types#
The following definitions come from erika.h in 0.3.1. They give the complete fields for the HTTP read-ahead window and GIF export:
ErikaOpenOptions
typedef struct ErikaOpenOptions {
const ErikaHttpHeader *headers;
uintptr_t header_count;
uint64_t http_read_ahead_bytes;
uint64_t http_back_buffer_bytes;
uint64_t start_position_micros;
uint64_t reserved[1];
} ErikaOpenOptions;
start_position_micros is the starting time in microseconds; 0 opens at the beginning. It occupies the first former reserved slot, so zero-initialized older structs still open at the beginning.
ErikaVideoAlphaMode
typedef enum ErikaVideoAlphaMode {
ErikaVideoAlphaMode_Opaque = 0,
ErikaVideoAlphaMode_PackedAlphaRight = 1,
} ErikaVideoAlphaMode;
ErikaGifExportQuality
typedef enum ErikaGifExportQuality {
ErikaGifExportQuality_Normal = 0,
ErikaGifExportQuality_High = 1,
} ErikaGifExportQuality;
ErikaGifExportOptions
typedef struct ErikaGifExportOptions {
const char *input_uri;
const char *output_path;
uint64_t start_millis;
uint64_t end_millis;
uint32_t frames_per_second;
uint32_t output_width;
uint32_t output_height;
int32_t quality;
int32_t loop_count;
bool overwrite;
const ErikaHttpHeader *headers;
uintptr_t header_count;
uint64_t http_read_ahead_bytes;
uint64_t reserved[3];
} ErikaGifExportOptions;
ErikaGifExportResult
typedef struct ErikaGifExportResult {
uint32_t width;
uint32_t height;
uint64_t frame_count;
uint64_t file_size;
} ErikaGifExportResult;
http_read_ahead_bytes sets how many bytes to read ahead (default 2 MiB). http_back_buffer_bytes sets how much already-played data to keep (default 16 MiB). Omit either one or pass 0 to use its default. You can also set the read-ahead default with ERIKA_HTTP_READAHEAD_BYTES.
A backward seek that lands inside the back buffer reuses the data already downloaded. High-bitrate video needs a larger budget: keeping about 10 seconds of an 80 Mbit/s stream takes roughly 100 MB. The cache is limited by bytes, not by a fixed number of seconds of playback.
Native texture types · 0.3.1#
typedef struct ErikaTextureFrame ErikaTextureFrame;
typedef enum ErikaExternalTextureKind {
ErikaExternalTextureKind_Metal = 1,
ErikaExternalTextureKind_VulkanOpaqueFd = 2,
} ErikaExternalTextureKind;
typedef enum ErikaExternalTextureFormat {
ErikaExternalTextureFormat_Rgba8Unorm = 1,
} ErikaExternalTextureFormat;
typedef struct ErikaExternalTextureInfo {
ErikaExternalTextureKind kind;
ErikaExternalTextureFormat format;
uint32_t width;
uint32_t height;
uint64_t native_handle;
uint64_t device_id;
uint64_t allocation_size;
uint32_t memory_type_index;
uint32_t vulkan_format;
uint32_t vulkan_usage;
uint32_t vulkan_tiling;
uint8_t device_uuid[16];
uint8_t driver_uuid[16];
} ErikaExternalTextureInfo;A texture frame can outlive its presenter. Release only after consumer GPU work and imported aliases retire. get_info returns borrowed handles: a Metal consumer may independently retain the texture through all GPU use; duplicate the Vulkan OPAQUE_FD before import (0 is valid), match device and driver UUIDs, and import the dedicated allocation with identical properties. Acquire queue ownership from EXTERNAL with old layout GENERAL before reading. Read-only pixels are sRGB-encoded RGBA in UNORM storage. liberika texture guide.
Cancellable open · 0.3.8 (experimental)#
ErikaColdOpenCancellation is a one-shot cancellation ticket that holds no presenter pointer. It lets another thread abort a synchronous open that is still connecting or waiting to retry. Use it with erika_presenter_open_with_options_cancellable.
ErikaStatus erika_open_validate(const char *uri, const ErikaOpenOptions *options)
Returns ErikaStatus::Ok when the URI is not empty and the ErikaOpenOptions are valid. It borrows no presenter and consumes no ticket, so a host can validate new arguments before replacing an open that is still in flight. Strings must be valid NUL-terminated C strings.
ErikaColdOpenCancellation *erika_cold_open_cancellation_create(void)
Creates a cancellation ticket. Use a new one for each open.
void erika_cold_open_cancellation_cancel(const ErikaColdOpenCancellation *ticket)
Requests cancellation from any thread. NULL is a no-op.
void erika_cold_open_cancellation_release(ErikaColdOpenCancellation *ticket)
Releases the ticket. Call it after every canceller and the synchronous open it served have finished. NULL is a no-op.
Embedded fallback font#
const uint8_t *erika_embedded_fallback_font(uintptr_t *out_length)
Returns borrowed embedded font bytes and their length, or NULL when the font is not compiled in. The bytes live for the process lifetime and must not be freed. out_length is uintptr_t, matching the platform pointer width. Native hosts can pass the data to a Web nofont runtime.