videos+minimaxh3: the keyframe ordinal counts pictures present; chunks back to the trained floor

Two findings from #236's author, both confirmed against the reference:

The <Picture k> ordinal for endpoint keyframes was fixed by ROLE (first = 1,
last = 2), so an l2va request presented its sole frame as <Picture 2>. The
reference numbers its presentation by PRESENCE (a last-frame-only request is
its picture ONE) -- as this server's own ref2va photo numbering already does.
The parse keeps the role's provisional ordinal; the count check settles it
once every part has arrived (parts may come in either order). fl2va is
unchanged: with both ends, roles and positions agree.

kMinChunks carried a stale 'EXPERIMENT: short-chunk test' enum (4) from a
cheap-clip verification battery, letting every request go under the model's
trained 5.17 s floor (7 chunks). Restored; the file's own '5 to 15 seconds:
7 to 20 chunks' comment describes the real bound.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gearwave00001andClaude committed 2026-10-25 06:51:06 -05:00
1 parent f3c6443d95
commit baa10db1aa
3 files changed
+53 -6

No files matched your search

+1 -1
View File
@@ -122,7 +122,7 @@ enum { kMaxSteps = 64, kDefSteps = 50 };
/* Time: 24 frames a second; a video of n chunks is 17 n + 5 frames over 5 n + 2 latent frames,
* and a decode pass reads 7 latent frames from 5 c. 5 to 15 seconds: 7 to 20 chunks. */
enum { kFps = 24, kFpc = 17, kFtail = 5, kLpc = 5, kLtail = 2, kDecLat = 7 };
enum { kMinChunks = 4, kMaxChunks = 20, kDefChunks = 7 }; /* EXPERIMENT: short-chunk test */
enum { kMinChunks = 7, kMaxChunks = 20, kDefChunks = 7 };
/* Space: 16 pixels a latent, 2 x 2 latents a patch; sides multiples of 32 from 256, at most the
* 1344 x 768 canvas's area, 4:1 at most. */
enum { kScale = 16, kPatch = 2, kMult = 32, kMinSide = 256, kMaxAspect = 4 };
+12 -5
View File
@@ -335,10 +335,10 @@ HttpResponse Server::handle_video_create(const HttpRequest& req) {
gen::VideoRefMedia m;
m.kind = p.name == "first_frame" ? gen::VideoRefMedia::FIRST_FRAME
: gen::VideoRefMedia::LAST_FRAME;
/* The keyframe's <Picture k> ordinal, so its vision-anchor block is labelled the way
* the source workflow names it (first = <Picture 1>, last = <Picture 2>). A keyframe
* request carries no reference media (checked below), so these numbers cannot collide
* with a reference's own <Picture k>. */
/* The keyframe's <Picture k> ordinal, provisionally by role; the presence rule in
* the count check below settles it once every part has parsed (parts may arrive in
* either order). A keyframe request carries no reference media (checked there), so
* these numbers cannot collide with a reference's own <Picture k>. */
m.index = m.kind == gen::VideoRefMedia::FIRST_FRAME ? 1 : 2;
m.name = p.name;
m.filename = p.filename;
@@ -502,6 +502,12 @@ HttpResponse Server::handle_video_create(const HttpRequest& req) {
if (m.kind == gen::VideoRefMedia::FIRST_FRAME) ++n_first; else ++n_last;
if (n_first > 1) return bad("first_frame", "at most one first_frame part");
if (n_last > 1) return bad("last_frame", "at most one last_frame part");
/* The <Picture k> ordinal counts the images the request PRESENTS, not the keyframe's role:
* the reference numbers its presentation by presence (a last-frame-only request is its
* picture ONE), exactly as ref2va numbers reference photos 1..n. With both ends the roles
* and the positions agree, so fl2va keeps first = 1, last = 2. */
for (gen::VideoRefMedia& m : keys)
if (m.kind == gen::VideoRefMedia::LAST_FRAME) m.index = n_first ? 2 : 1;
if (!keys.empty()) {
if (!info.encodes)
return bad("first_frame", "this model has no video encoder, so it cannot pin a "
@@ -762,7 +768,8 @@ HttpResponse Server::handle_video_create(const HttpRequest& req) {
* always AFTER every reference: the driver lays the reference rows down first, then folds each
* FIRST_FRAME/LAST_FRAME into the pack's keyframe table. Sort first before last (a client may send
* the file parts in either order) so they keyframe-order 0 and 1, take image slots 1 and 2, and
* present as <Picture 1> then <Picture 2>. */
* present as <Picture 1> then <Picture 2> -- or <Picture 1> alone when only one end is given
* (the presence ordinal was settled by the count check). */
std::stable_sort(keys.begin(), keys.end(), [](const gen::VideoRefMedia& a,
const gen::VideoRefMedia& b) {
return a.kind < b.kind; /* FIRST_FRAME (4) before LAST_FRAME (5) */
+40
View File
@@ -682,6 +682,46 @@ TEST(fl2va_keyframes_feed_the_tower_and_pin_the_output_ends) {
CHECK(g.tokens == want);
}
/* A last frame ALONE is presented as <Picture 1>: the ordinal counts the images the request
* carries, not the keyframe's role -- the reference numbers its presentation by presence, and so
* does ref2va's own photo numbering. fl2va (both ends) keeps first = 1, last = 2. */
TEST(l2va_presents_its_sole_frame_as_picture_1) {
FakeMultimodal mm;
mm.expand = { 900, 901 };
mm.enc_frames = 5; mm.enc_side = 16; mm.enc_n = 850;
FakeVideoGen gen;
std::unique_ptr<Fixture> f(new Fixture(Fixture::Tweak{ [&](ServerOptions& o, Deps& d) {
d.videos = &gen;
d.mm = &mm;
o.video_model = true;
gen.inf.encodes = 1;
gen.inf.enc_ratio = 16;
gen.inf.max_enc_side = 512;
} }));
HttpRequest q;
q.method = "POST";
q.path = "/v1/videos";
q.form = { FormPart{ "prompt", "", "", "fox" },
FormPart{ "size", "", "", "256x256" },
FormPart{ "task", "", "", "l2va" },
FormPart{ "last_frame", "l.png", "image/png", "PL" } };
HttpResponse r = f->srv->router().dispatch(q);
REQUIRE_EQ(r.status, 200);
REQUIRE_EQ(gen.last().refs.size(), (size_t)1);
CHECK_EQ((int)gen.last().refs[0].kind, (int)gen::VideoRefMedia::LAST_FRAME);
CHECK_EQ(gen.last().refs[0].index, 1); /* the sole picture: <Picture 1>, not the role's 2 */
CHECK(mm.cenc_cover); /* it still takes the last frame's centre crop */
REQUIRE(gen.last().media != nullptr);
REQUIRE_EQ(gen.last().media->items.size(), (size_t)1);
std::vector<int32_t> want;
auto chars = [&](const std::string& s) { for (unsigned char c : s) want.push_back((int32_t)c); };
chars("<v>");
chars("<Picture 1>: ");
want.insert(want.end(), mm.expand.begin(), mm.expand.end());
chars("fox");
CHECK(gen.last().tokens == want);
}
/* first_frame_mode=center: the FIRST anchor is cover-cropped to the canvas instead of stretched --
* the no-distortion answer for a portrait photo pinned into a landscape output. The flag reaches
* encoder_image_canvas on the first call; the last frame keeps its centre crop either way. */