Skip to content

Commit ef6ca34

Browse files
localai-botmudler
andauthored
chore: ⬆️ Update leejet/stable-diffusion.cpp to 5b0267e941cade15bd80089d89838795d9f4baa6 (#9907)
Adapt the C++ wrapper to the new `generate_video()` signature: upstream now returns `bool` and writes frames/audio via out-parameters (`sd_image_t**`, `sd_audio_t**`). Also set `p->fps` on the params struct (new upstream field) and free the returned audio handle on both the success and error paths. Assisted-by: claude-code:claude-opus-4-7 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 9413c37 commit ef6ca34

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

backend/go/stablediffusion-ggml/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ JOBS?=$(shell nproc --ignore=1)
88

99
# stablediffusion.cpp (ggml)
1010
STABLEDIFFUSION_GGML_REPO?=https://github.com/leejet/stable-diffusion.cpp
11-
STABLEDIFFUSION_GGML_VERSION?=bd17f53b7386fb5f60e8587b75e73c4b2fed3426
11+
STABLEDIFFUSION_GGML_VERSION?=5b0267e941cade15bd80089d89838795d9f4baa6
1212

1313
CMAKE_ARGS+=-DGGML_MAX_NAME=128
1414

backend/go/stablediffusion-ggml/cpp/gosd.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,9 @@ int gen_video(sd_vid_gen_params_t *p, int steps, char *dst, float cfg_scale, int
11881188
p->high_noise_sample_params.scheduler = scheduler;
11891189
p->high_noise_sample_params.flow_shift = flow_shift;
11901190

1191+
// Pin output fps in params; upstream uses it for audio sync (and we also mux at this rate).
1192+
p->fps = fps;
1193+
11911194
// Load init/end reference images if provided (resized to output dims).
11921195
uint8_t* init_buf = nullptr;
11931196
uint8_t* end_buf = nullptr;
@@ -1206,11 +1209,14 @@ int gen_video(sd_vid_gen_params_t *p, int steps, char *dst, float cfg_scale, int
12061209

12071210
// Generate
12081211
int num_frames_out = 0;
1209-
sd_image_t* frames = generate_video(sd_c, p, &num_frames_out);
1212+
sd_image_t* frames = nullptr;
1213+
sd_audio_t* audio = nullptr;
1214+
bool ok = generate_video(sd_c, p, &frames, &num_frames_out, &audio);
12101215
std::free(p);
12111216

1212-
if (!frames || num_frames_out == 0) {
1217+
if (!ok || !frames || num_frames_out == 0) {
12131218
fprintf(stderr, "generate_video produced no frames\n");
1219+
if (audio) free_sd_audio(audio);
12141220
if (init_buf) free(init_buf);
12151221
if (end_buf) free(end_buf);
12161222
return 1;
@@ -1224,6 +1230,7 @@ int gen_video(sd_vid_gen_params_t *p, int steps, char *dst, float cfg_scale, int
12241230
if (frames[i].data) free(frames[i].data);
12251231
}
12261232
free(frames);
1233+
if (audio) free_sd_audio(audio);
12271234
if (init_buf) free(init_buf);
12281235
if (end_buf) free(end_buf);
12291236

0 commit comments

Comments
 (0)