videos: the tower reads a keyframe's own canvas frame, never a re-decode

The reference feeds the vision tower the same resized tensor it hands the
video VAE: an anchor's identity and its pinned latent are the SAME pixels.
Our port showed the tower the source file at the `match` area instead, so
a keyframe whose native aspect differed from the canvas reached the two
channels differently (parallel PR #236, point 5).

A keyframe now decodes once, onto the exact output canvas, in a pre-loop
that owns every FIRST/LAST_FRAME part: the pixels fill enc_pixels for the
VAE pin as before, and the frame itself rides to the prompt block, where
the anchor loop hands it to the tower through the new IMultimodal
prepare_frame -- implemented by the bridge as Processor::image_from, which
smart-resizes and patchifies the caller's pixels exactly as a prepared
file's would be. A reference picture is unchanged (tower `match`, encoder
grid); the two never share a request. The encode loop's keyframe branch is
gone: its pixels were built above, one decode for both consumers.

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

No files matched your search

+12
View File
@@ -746,6 +746,18 @@ public:
return rc;
}
/* The frame arrives already decoded (a keyframe on the output canvas), so no decoder is
* needed -- only the tower the processor patchifies for. It smart-resizes internally, exactly
* as a prepared file would, but from the caller's pixels. */
int prepare_frame(const mm::Frame& f, std::shared_ptr<mm::Item>* out,
std::string* why) override {
if (!accepts(MediaKind::Image)) {
if (why) *why = "this model's vision tower serves no pictures";
return RAD_E_UNSUPPORTED;
}
return p_->image_from(f, out, why);
}
int encoder_image(const uint8_t* bytes, size_t n, int32_t ratio, int32_t max_side,
mm::Frame* out, std::string* why) override {
if (!p_ || !mm::decoder_available()) {