Archived
video: endpoint keyframe completion (I2VA / L2VA / FL2VA)
One keyframe path serves three DaSiWa modes: first_frame pins output frame 0,
last_frame pins the last frame, and the gap is diffused. A keyframe is pure
attention conditioning -- its VAE latent rides as a pinned (update=0) cond row
at its frame's time position, faithful to comfy/ldm/minimax/model.py where
keyframe latents are img_update==False rows. The sampler is untouched; the step
merely widens to carry the extra cond rows.
- server (videos.cpp/iface.h/adapters.h): first_frame/last_frame form parts ->
VideoRefMedia::FIRST_FRAME/LAST_FRAME; kf_task validation (i2va/fl2va need
first, l2va/fl2va need last); keyframes are mutually exclusive with refs;
encoder_image_canvas(cover=LAST) sizes the anchor.
- driver (video_driver.cpp): keyframe pass issues a RAD_ENC_IMAGE Vencode per
anchor (slot = ++ref_tab[1], ordered), appends ref_tab key triples
{frame(0|frames-1), video_t=1, audio_t=0}.
- arch (minimaxh3.cpp): ref_parts emits keyframe cond parts FIRST; the step
scatter admits kR2VCond/kR2VCondAudio rows.
- tests: video_gen_test keyframe-completes-widens-the-step-and-pins-the-ends
(2x Vencode at slot 1,2; widened step; seg_cu/lat_cu/ref_tab pinned); fake_pack_ref
lays keyframe rows (nk=0 byte-identical to before); videos_test keyframe API.
Device-verified (TP2, seed 9999): FL2VA completes a valid 73-frame MP4+AAC; pins
are consumed (fl2va != same-seed t2va) and force the endpoints (frame0 vs anchor
0.687 pinned vs 0.460 un-pinned; last 0.719 vs 0.521). Fidelity follow-up (not
function): anchors ride as pins only; the reference also feeds them through the
TE as vision tokens, so a prompt that contradicts the anchor lets text win --
full endpoint parity vs a golden needs TE-anchor tokens (#10/P6 bucket).
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
8ddcbbf01f
commit
60e920cd4d
11 files changed
+410
-37
No files matched your search
@@ -1041,6 +1041,44 @@ int Processor::encoder_image(const uint8_t* bytes, size_t n, int32_t ratio, int3
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
int Processor::encoder_image_canvas(const uint8_t* bytes, size_t n, int32_t w, int32_t h,
|
||||
bool cover, Frame* out, std::string* why) const {
|
||||
if (w < 1 || h < 1) {
|
||||
if (why) *why = "the keyframe canvas is empty";
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
/* The same decode guard as encoder_image(): a keyframe the client sends is held to the size a
|
||||
* reference would be. */
|
||||
Frame f;
|
||||
RAD_TRY(decode_image(bytes, n, cfg_.max_source_pixels, &f, why));
|
||||
if (!cover) {
|
||||
/* "disabled": a plain stretch to the canvas, exactly the reference's first-frame resize. */
|
||||
if (w == f.w && h == f.h) { *out = std::move(f); return RAD_OK; }
|
||||
resize_lanczos_rgb(f, w, h, out);
|
||||
return RAD_OK;
|
||||
}
|
||||
/* "center": scale up to COVER the canvas keeping aspect (both axes at least the target), then
|
||||
* cut the exact canvas from the centre -- the reference's last-frame resize. The scale is the
|
||||
* larger of the two axis ratios so neither side falls short; each is rounded up to at least the
|
||||
* target so the crop always has enough to take from. */
|
||||
const double s = std::max((double)w / (double)f.w, (double)h / (double)f.h);
|
||||
int32_t cw = (int32_t)std::llround((double)f.w * s);
|
||||
int32_t ch = (int32_t)std::llround((double)f.h * s);
|
||||
if (cw < w) cw = w;
|
||||
if (ch < h) ch = h;
|
||||
Frame big;
|
||||
resize_lanczos_rgb(f, cw, ch, &big);
|
||||
const int32_t x0 = (cw - w) / 2, y0 = (ch - h) / 2;
|
||||
out->w = w;
|
||||
out->h = h;
|
||||
out->rgb.resize((size_t)w * h * 3);
|
||||
for (int32_t y = 0; y < h; ++y)
|
||||
for (int32_t x = 0; x < w * 3; ++x)
|
||||
out->rgb[(size_t)y * w * 3 + x] =
|
||||
big.rgb[(size_t)(y0 + y) * cw * 3 + (size_t)(x0 * 3 + x)];
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
namespace {
|
||||
/* Which frames of a source video a reference clip keeps: spread uniformly over the stream, the
|
||||
* largest count no more than both the stream's length and `max_frames` that is 5 modulo 17 — the
|
||||
|
||||
Reference in new issue
Block a user