Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,13 @@ target_sources(${SD_LIB} PRIVATE $<TARGET_OBJECTS:zip>)
target_link_libraries(${SD_LIB} PUBLIC ggml)
find_package(Threads REQUIRED)
target_link_libraries(${SD_LIB} PRIVATE Threads::Threads)
if(WIN32)
target_link_libraries(${SD_LIB} PRIVATE advapi32)
endif()
target_link_libraries(${SD_LIB} PRIVATE onig sd-utf8proc)
if(SD_WEBP)
target_compile_definitions(${SD_LIB} PRIVATE SD_USE_WEBP)
target_link_libraries(${SD_LIB} PRIVATE webp webpdemux)
target_link_libraries(${SD_LIB} PRIVATE webp webpdemux libwebpmux)
endif()
if(SD_WEBM)
target_compile_definitions(${SD_LIB} PRIVATE SD_USE_WEBM)
Expand Down
19 changes: 6 additions & 13 deletions docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,12 @@ tree for the compatibility layer's private headers.
## WebP and WebM Support

WebP and WebM support are enabled by default. The library links `libwebp`,
`libwebpdemux` and `libwebm` so DGL `video::load` works through the C API as
well as CLI and server. WebP input supports static images and animation;
WebM input supports this project's independent VP8 frames and PCM16 audio.
No libvpx dependency is required. See [DGL media I/O](dgl.md) for frame-rate
and codec restrictions.

The CLI and server also use `libwebp` for WebP images. CLI WebM output reuses
`libwebp` to encode each frame as VP8 before muxing with `libwebm`. System WebP
packages must provide the decoder, demuxer and muxer libraries.

DGL `video::encode` supports silent WebM and AVI with PCM16 audio. Requesting
WebM audio reports an unsupported-encoder error; use `format="avi"` to include
an audio track.
`libwebpdemux`, the WebP muxer and `libwebm`. These codecs are shared by
DGL, the CLI and the server. The built-in WebM reader handles independent VP8
frames, including older files with PCM16 audio. The built-in writer produces
silent VP8 WebM. WebM with audio uses FFmpeg with Opus. AVI supports PCM16 audio.
See [DGL media input and output](dgl.md#media-input-and-output) for format and
codec details.

If you do not want WebP/WebM support, you can disable them at configure time:

Expand Down
7 changes: 4 additions & 3 deletions docs/development/c_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ See the [C API guide](../guides/c_api.md) for keys, value types and ownership ru
| `src/api/templates/` | Complete DGL execution flows and a few shared helpers. |
| `src/api/program_result.cpp` | Adaptation of DGL tensors and dictionaries to C results. |
| `src/api/generation_metadata.cpp` | Image parameter and WebUI infotext extraction through the metadata C API. |
| `src/api/image_metadata.cpp` | Container metadata reading and text/JSON reports through `sd_read_metadata()`. |
| `src/api/media_metadata.cpp`, `metadata.h` | Shared metadata encoding and C access to PNG/JPEG/XMP/AVI chunks. |
| `src/api/image_metadata.cpp` | Container metadata reading and text/JSON reports through `media::read_metadata`. |
| `src/api/media_metadata.cpp`, `metadata.h` | Shared PNG/JPEG/XMP/AVI metadata encoding. |
| `src/core/option_types.h/.cpp` | Internal mode enums, name lookup and parsing. |

Options are validated and converted at the API boundary. The translator renders
Expand Down Expand Up @@ -64,7 +64,8 @@ embedding are separate from inference and never rebuild the execution program.
`src/api/generation_metadata.cpp` parses the source once to produce image
parameters and WebUI infotext together. Examples obtain this JSON through
`sd_get_generation_metadata()` without compiling or calling the DGL parser.
Container reading and metadata chunk generation also use the public C API.
The CLI reads containers through the DGL media built-in. The library's encoders
write container metadata.
Examples have no private `src` include path and retain generated DGL source
without legacy JSON conversion or LoRA path rewriting.
The translator uses an explicit `llm_path` as the text encoder's main `path`, falling back to
Expand Down
16 changes: 11 additions & 5 deletions docs/dgl-builtins.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Optional parameters are marked with `?`. Default values follow `=`. See [DGL syn
| `animatediff::load` (resource) | `path: string`, `family?: string = "auto"`, `wtype?: string = "auto"`, `conv_scale?: number = 0`, `linear_scale?: number = 0`, `attn_scale?: number = 0`, `backend?: string = ""`, `params_backend?: string = ""`, `split_mode?: string = ""`, `model_args?: string = ""`, `tensor_type_rules?: string = ""`, `flash_attn_mode?: string = "auto"`, `conv_direct_mode?: string = "auto"`, `sage_attn?: bool = false`, `linear_type?: string = "auto"` | `animatediff` |
| `apg` | `positive: predictor`, `negative: predictor`, `scale: number`, `image_only?: predictor`, `image_scale?: number = 1`, `schedule?: list<number>`, `eta?: number = 1`, `momentum?: number = 0`, `norm_threshold?: number = 0`, `norm_threshold_smoothing?: number = 0` | `predictor` |
| `apply_lora` | `model: model`, `lora: lora`, `weight?: number = 1.0`, `mode?: string` | same type as `model` |
| `audio::decode` | `data: bytes` | `dict`<br>`sample_rate: int`<br>`samples: tensor` |
| `audio::encode` | `audio: dict`, `format?: string = "wav"`, `pcm?: string = "f32"` | `dict`<br>`data: bytes`<br>`mime_type: string` |
| `audio::load` | `path: string` | `dict`<br>`sample_rate: int`<br>`samples: tensor` |
| `audio::save` | `path: string`, `audio: dict`, `format?: string = "f32"` | `void` |
| `audio_latent_shape` | `vae: audio_vae`, `frames: int`, `fps: int` | `tensor` |
Expand All @@ -29,10 +31,11 @@ Optional parameters are marked with `?`. Default values follow `=`. See [DGL syn
| `encode_prompt` | `encoder: text_encoder`, `text: string`, `width?: int = 512`, `height?: int = 512`, `clip_skip?: int = -1`, `system?: string`, `media?: list<any>`, `image_bindings?: dict`, `raw?: bool = false` | `dict`<br>`concat: tensor`<br>`crossattn: tensor`<br>`extra_crossattn: list<tensor>`<br>`image_embed_indices: list<tensor>`<br>`image_embeds: list<tensor>`<br>`input_ids: tensor`<br>`position_ids: tensor`<br>`ref_audios: list<tensor>`<br>`ref_images: list<tensor>`<br>`reference_blocks: list<dict>`<br>`reference_blocks.audio: int`<br>`reference_blocks.frame_index: int`<br>`reference_blocks.kind: string`<br>`reference_blocks.video: int`<br>`t5_ids: tensor`<br>`t5_weights: tensor`<br>`token_types: tensor`<br>`vector: tensor`<br>`vinput_mask: tensor` |
| `encode_vision` | `encoder: vision_encoder`, `image: tensor`, `pooled?: bool = false`, `clip_skip?: int = -2`, `zero?: bool = false`, `zero_input?: bool = false` | `tensor` |
| `image::canny` | `image: tensor`, `high_threshold?: number = 0.08`, `low_threshold?: number = 0.04`, `weak?: number = 0.5`, `strong?: number = 1`, `invert?: bool = false` | `tensor` |
| `image::encode` | `image: tensor`, `format?: string = "png"` | `dict`<br>`data: bytes`<br>`mime_type: string` |
| `image::load` | `path: string` | `tensor` |
| `image::decode` | `data: bytes`, `channels?: int = 0`, `strict_channels?: bool = false` | `tensor` |
| `image::encode` | `image: tensor`, `format?: string = "png"`, `quality?: int = 90`, `metadata?: string` | `dict`<br>`data: bytes`<br>`mime_type: string` |
| `image::load` | `path: string`, `channels?: int = 0`, `strict_channels?: bool = false` | `tensor` |
| `image::load_dir` | `path: string`, `max_images?: int = 0` | `list<tensor>` |
| `image::save` | `path: string`, `image: tensor` | `void` |
| `image::save` | `path: string`, `image: tensor`, `quality?: int = 90`, `metadata?: string` | `void` |
| `image::to_f32` | `image: tensor`, `channels?: int = 0` | `tensor` |
| `image::to_u8` | `pixels: tensor` | `tensor` |
| `ip_adapter::apply` | `condition: dict`, `adapter: ip_adapter`, `tokens: tensor`, `strength?: number = 1`, `start_sigma?: number`, `end_sigma?: number` | same type as `condition`<br>`ip_adapters: ip_adapter_bindings` |
Expand Down Expand Up @@ -65,7 +68,9 @@ Optional parameters are marked with `?`. Default values follow `=`. See [DGL syn
| `math::product` | `items: i64 tensor or list<int>` | `int` |
| `math::round` | `value: number` | `int` |
| `math::sub` | `a: number`, `b: number` | `number` |
| `media::read_metadata` | `path: string`, `format?: string = "text"`, `raw?: bool = false`, `brief?: bool = false`, `structural?: bool = false` | `string` |
| `media::save` | `path: string`, `media: dict` | `void` |
| `media::supported_formats` | | `dict`<br>`audio: list<string>`<br>`image: list<string>`<br>`video: list<string>` |
| `photomaker::apply` | `condition: dict`, `photomaker: photomaker`, `tokens: tensor`, `mask: tensor` | same type as `condition`<br>`crossattn: tensor` |
| `photomaker::encode_images` | `photomaker: photomaker`, `images: list<tensor>`, `id_embedding?: tensor` | `tensor` |
| `photomaker::encode_prompt` | `encoder: text_encoder`, `text: string`, `tokens: tensor`, `width?: int = 1024`, `height?: int = 1024`, `clip_skip?: int = -1` | `dict`<br>`condition: dict`<br>`condition.concat: tensor`<br>`condition.crossattn: tensor`<br>`condition.extra_crossattn: list<tensor>`<br>`condition.image_embed_indices: list<tensor>`<br>`condition.image_embeds: list<tensor>`<br>`condition.input_ids: tensor`<br>`condition.position_ids: tensor`<br>`condition.ref_audios: list<tensor>`<br>`condition.ref_images: list<tensor>`<br>`condition.reference_blocks: list<dict>`<br>`condition.reference_blocks.audio: int`<br>`condition.reference_blocks.frame_index: int`<br>`condition.reference_blocks.kind: string`<br>`condition.reference_blocks.video: int`<br>`condition.t5_ids: tensor`<br>`condition.t5_weights: tensor`<br>`condition.token_types: tensor`<br>`condition.vector: tensor`<br>`condition.vinput_mask: tensor`<br>`mask: tensor`<br>`plain: dict`<br>`plain.concat: tensor`<br>`plain.crossattn: tensor`<br>`plain.extra_crossattn: list<tensor>`<br>`plain.image_embed_indices: list<tensor>`<br>`plain.image_embeds: list<tensor>`<br>`plain.input_ids: tensor`<br>`plain.position_ids: tensor`<br>`plain.ref_audios: list<tensor>`<br>`plain.ref_images: list<tensor>`<br>`plain.reference_blocks: list<dict>`<br>`plain.reference_blocks.audio: int`<br>`plain.reference_blocks.frame_index: int`<br>`plain.reference_blocks.kind: string`<br>`plain.reference_blocks.video: int`<br>`plain.t5_ids: tensor`<br>`plain.t5_weights: tensor`<br>`plain.token_types: tensor`<br>`plain.vector: tensor`<br>`plain.vinput_mask: tensor` |
Expand Down Expand Up @@ -136,10 +141,11 @@ Optional parameters are marked with `?`. Default values follow `=`. See [DGL syn
| `vae_encode` | `vae: vae`, `pixels: tensor`, `rng: rng`, `tiling?: dict`, `circular_x?: bool = false`, `circular_y?: bool = false`, `posterior?: string = "sample"` | `tensor` |
| `vae_to_dit_latents` | `vae: vae`, `latent: tensor` | `tensor` |
| `vae_to_unet_latents` (alias of `vae_to_dit_latents`) | `vae: vae`, `latent: tensor` | `tensor` |
| `video::encode` | `video: dict`, `audio?: dict`, `format?: string = "webm"` | `dict`<br>`data: bytes`<br>`mime_type: string` |
| `video::decode` | `data: bytes`, `max_frames?: int = 0`, `fps_num?: int = 0`, `fps_den?: int = 1`, `audio?: bool = true` | `dict`<br>`audio: dict`<br>`audio.sample_rate: int`<br>`audio.samples: tensor`<br>`video: dict`<br>`video.fps_den: int`<br>`video.fps_num: int`<br>`video.frames: tensor` |
| `video::encode` | `video: dict`, `audio?: dict`, `format?: string = "webm"`, `trim_audio?: bool = false`, `codec?: string = "auto"`, `quality?: int = 90`, `audio_format?: string = "pcm16"`, `metadata?: string` | `dict`<br>`data: bytes`<br>`mime_type: string` |
| `video::join_windows` | `windows: list<tensor>`, `overlap?: int = 0` | `tensor` |
| `video::load` | `path: string`, `max_frames?: int = 0`, `fps_num?: int = 0`, `fps_den?: int = 1`, `audio?: bool = true` | `dict`<br>`audio: dict`<br>`audio.sample_rate: int`<br>`audio.samples: tensor`<br>`video: dict`<br>`video.fps_den: int`<br>`video.fps_num: int`<br>`video.frames: tensor` |
| `video::save` | `path: string`, `video: dict`, `audio?: dict`, `trim_audio?: bool = false`, `codec?: string = "auto"`, `quality?: int = 90`, `audio_format?: string = "f32"` | `void` |
| `video::save` | `path: string`, `video: dict`, `audio?: dict`, `trim_audio?: bool = false`, `codec?: string = "auto"`, `quality?: int = 90`, `audio_format?: string = "f32"`, `metadata?: string` | `void` |
| `video::split_windows` | `frames: tensor`, `size: int`, `overlap?: int = 0` | `list<tensor>` |
| `wan::s2v_audio_window` | `embedding: tensor`, `latent_frames: int` | `tensor` |
| `zero_out` | `condition: dict`, `fields?: list<string>` | same type as `condition` |
Expand Down
Loading
Loading