server: a keyframe request may centre-crop its first anchor instead of stretching it

The reference stretches the first frame to the output canvas, which squashes a portrait
photo pinned into a landscape video (ComfyUI behaves identically). Optional per-request
first_frame_mode: "stretch" (default, the reference's own resize) or "center" -- the
already-implemented cover-crop, previously used only for the last anchor: aspect kept,
the canvas centre-cropped. The latent grid stays the exact target canvas either way, so
pinned rows are unaffected; anything else is refused naming the field.
This commit is contained in:
gearwave00001 committed 2026-10-24 14:28:54 -05:00
1 parent a14ea5abad
commit 6bcb481450
3 files changed
+111 -7

No files matched your search

+4 -1
View File
@@ -411,9 +411,11 @@ struct FakeMultimodal : IMultimodal {
int32_t enc_frames = 5, enc_side = 16;
int64_t enc_n = 850;
int n_ienc = 0, n_venc = 0, n_aenc = 0, n_cenc = 0;
/* The canvas an anchor was resized to, and whether the last frame's cover-crop was asked for. */
/* The canvas an anchor was resized to, and the cover-crop asks -- cenc_cover is the LAST
* call's flag, cenc_covers records every call in order (first frame, then last). */
int32_t cenc_w = 0, cenc_h = 0;
bool cenc_cover = false;
std::vector<bool> cenc_covers;
int encoder_image(const uint8_t*, size_t, int32_t, int32_t, mm::Frame* out,
std::string*) override {
++n_ienc;
@@ -425,6 +427,7 @@ struct FakeMultimodal : IMultimodal {
mm::Frame* out, std::string*) override {
++n_cenc;
cenc_w = w; cenc_h = h; cenc_cover = cover;
cenc_covers.push_back(cover);
out->w = w; out->h = h;
out->rgb.assign((size_t)w * h * 3, 100);
return RAD_OK;