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

+13
View File
@@ -568,6 +568,19 @@ public:
virtual int prepare(MediaKind k, const std::vector<uint8_t>& bytes, const MediaOpts& opts,
std::shared_ptr<mm::Item>* out, std::string* why) = 0;
/* Process an ALREADY-DECODED frame for the language model's vision tower. The caller built the
* pixels itself -- a keyframe resized to the exact output canvas -- and the tower must see
* exactly those, not a fresh decode of the source file at its own size: the reference shows the
* tower the same resized tensor it hands the video VAE, so an anchor's identity and its pinned
* latent are the same pixels. A server whose tower can read host-built frames implements this;
* the rest leave it unsupported. */
virtual int prepare_frame(const mm::Frame& f, std::shared_ptr<mm::Item>* out,
std::string* why) {
(void)f; (void)out;
if (why) *why = "this server cannot show a pre-decoded frame to the vision tower";
return RAD_E_UNSUPPORTED;
}
/* A picture in a video VAE's encoder-ready form: decoded under the same guard as prepare() and
* resized so both sides are multiples of `ratio` and neither exceeds `max_side`. The video
* generator's server uses it to fill a reference's encoder pixels; a server with no video VAE