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
@@ -417,12 +417,14 @@ int VideoDriver::submit(std::unique_ptr<VideoRequest> r, std::string* why) {
|
||||
* frames and its soundtrack's are the Vencode/Aencode latent counts rad_arch_encode_geom gives
|
||||
* (a video's are the same before and after the encode pass clip-pads its short final clip). The
|
||||
* table must exist before the step layout is decided, because when the denoiser consumes it the
|
||||
* reference rows are part of that layout. The keyframe count stays 0 (continuation is separate
|
||||
* work), so the table holds only reference rows. */
|
||||
* reference rows are part of that layout. Endpoint keyframes (a first and/or last frame pinned
|
||||
* at the output's ends) are appended after the reference rows as {frame, video_t, audio_t}
|
||||
* triples; a request carries either references or keyframes, never both. */
|
||||
if (d.encodes) {
|
||||
bool need_geom = false;
|
||||
for (const VideoRefMedia& m : r->refs)
|
||||
if (m.kind != VideoRefMedia::IMAGE) need_geom = true;
|
||||
if (m.kind != VideoRefMedia::IMAGE && m.kind != VideoRefMedia::FIRST_FRAME &&
|
||||
m.kind != VideoRefMedia::LAST_FRAME) need_geom = true;
|
||||
if (need_geom && !enc_geom_)
|
||||
return no("the request carries a reference video or audio, but this plugin exports no "
|
||||
"rad_arch_encode_geom, so their encoder geometry cannot be sized");
|
||||
@@ -507,6 +509,33 @@ int VideoDriver::submit(std::unique_ptr<VideoRequest> r, std::string* why) {
|
||||
}
|
||||
/* VIDEO_AUDIO rows are folded into their video above, so they take no row here. */
|
||||
}
|
||||
/* Endpoint keyframes: each FIRST_FRAME/LAST_FRAME the server resized to the target canvas
|
||||
* and staged in enc_pixels folds into the pack's KEYFRAME table -- not a reference row. The
|
||||
* DiT reads its latent rows PINNED at that frame's moment on the target timeline (denoised
|
||||
* never): the first pins output frame 0, the last the final frame, and the gap between is
|
||||
* diffused. The key triple is {pixel frame, video_t, audio_t}; a picture anchor is video-only
|
||||
* (video_t = one latent frame, audio_t = 0), and its pixel frame is 0 or frames-1 -- the same
|
||||
* resolved frame index the reference's MiniMaxH3ImageToVideo assigns. Its latents ride the
|
||||
* image slot its keyframe ORDER names (1, then 2): a keyframe request carries no references,
|
||||
* so those slots are free, and ref_parts -- and the scatter -- read them back by the same
|
||||
* order. Keyframe rows are appended after every reference row, which is where ref_pack_of
|
||||
* reads the table's key block. */
|
||||
for (size_t i = 0; i < r->refs.size(); ++i) {
|
||||
const VideoRefMedia& m = r->refs[i];
|
||||
const bool first = m.kind == VideoRefMedia::FIRST_FRAME;
|
||||
if (!first && m.kind != VideoRefMedia::LAST_FRAME) continue;
|
||||
if (m.enc_pixels.empty())
|
||||
return no("'" + m.name + "' was not prepared for the video encoder");
|
||||
if (bad_side(m))
|
||||
return no("'" + m.name + "' has encoder sides (" + std::to_string(m.enc_h) +
|
||||
"x" + std::to_string(m.enc_w) + ") the VAE grid of " +
|
||||
std::to_string(d.enc_ratio) + " does not divide");
|
||||
if (j->ref_tab.empty()) j->ref_tab.assign(2, 0); /* [n_refs, n_keys] */
|
||||
const int32_t slot = ++j->ref_tab[1]; /* keyframe order -> image slot 1, 2 */
|
||||
j->enc_q.push_back({RAD_ENC_IMAGE, slot, (int32_t)i});
|
||||
j->ref_tab.insert(j->ref_tab.end(),
|
||||
{first ? 0 : s.frames - 1, 1 /*one latent frame*/, 0 /*no soundtrack*/});
|
||||
}
|
||||
}
|
||||
/* The step's packed sequence. When the denoiser consumes the reference table the pack is the
|
||||
* only source of its rows, segment boundaries and positions -- the reference rows sit between
|
||||
@@ -640,8 +669,8 @@ int VideoDriver::submit(std::unique_ptr<VideoRequest> r, std::string* why) {
|
||||
* chosen. Each reference the server decoded into encoder form rides one encode pass at the slot
|
||||
* its index numbers within its kind -- a picture or video a Vencode pass, a standalone audio and
|
||||
* every video's soundtrack an Aencode pass (a soundtrack at its video's slot, since the encoder
|
||||
* and the scatter both number it by its video). The keyframe count stays 0: continuation is
|
||||
* separate work. */
|
||||
* and the scatter both number it by its video). Endpoint keyframes ride the same queue as
|
||||
* picture anchors -- a Vencode pass at the image slot their keyframe order names. */
|
||||
/* The soundtrack's length, exactly the samples the decode will hand the encoder — the
|
||||
* number a caller that chains clips against an audio floor checks. A build without
|
||||
* libavcodec never gets the muxed file to read it back from, so it is logged here. */
|
||||
|
||||
Reference in new issue
Block a user