This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/core/mm/imaging.h
T
gearwave00001andClaude a1a75da7e9 merge origin/main: the upstream LoRA-runtime refactor beneath the ref2va port
Merges upstream 1.10.0 (152 commits: the LoRA acquire/runtime refactor, the
form-1 LTX-2 scheduler family, guidance terms + negative prompts, decoder
selection, input_reference, new architectures) into the ref2va port branch.
Resolution rule throughout: keep BOTH feature sets; ABI numbering follows
upstream (RAD_ABI_VERSION 26, RAD_FORMAT_VER 2), with the port's video fields
unioned into RadVideoGenBatch/RadVideoGenDecl and abi_layout_table.h
regenerated from the live table.

Notable reconciliations:
  * videos.cpp: the task grammars are disjoint by capability -- keyframe tasks
    (i2va/l2va/flash-attn l2va/fl2va) are recognized only when decl.encodes,
    so upstream models keep refusing them as unknown tasks; input_reference,
    the LoRA tag/field pipeline, and the guidance/negative_prompt rendering
    coexist with refs/ref2va; the prompt put() helper hoisted to block scope
    for the media branch.
  * video_schedule(): upstream's (steps, video_tokens, refine) keeps its
    positional slots; the port's shift_video/shift_audio overrides move to the
    tail so upstream's schedule tests call unchanged.
  * r4d_selftest conv3d cases: the port's sp/st/causal/down/refl geometry and
    upstream's tpad/tpre fold into one reference (ft = causal ? 2 : tpad==2 ?
    2+tpre : 1); rms_mod rows keep the port's i8/fp8 quant modes alongside
    upstream's wadd/norm_once/norm parameters.
  * tests/oot_plugins.sh: the per-plugin cmake --install gains a --prefix
    staging dir -- plugin .so files still land in the absolute
    RAD_PLUGIN_INSTALL_HOME, but libr4d now also installs r4d_selftest to a
    relative bin/, which needs no root.

Host ctest: 112/113 (mm_test's webp gap pre-exists this merge); r4d_selftest,
engine_e2e, oot_plugins, abi_layout, all LoRA tests green.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-22 18:38:04 -05:00

32 lines
1.6 KiB
C++

/* imaging.h -- image arithmetic done the way PIL does it, so a picture reaches the model exactly
* as the reference pipeline's would.
*
* Resize: PIL's Image.resize with LANCZOS, bit for bit. Per-axis coefficients are computed in
* double (support 3x the downscale, normalised to sum one) and converted to 22-bit fixed point;
* a horizontal then a vertical pass run over 8-bit values, rounding and clipping each output.
* RGBA is premultiplied by alpha first and divided back after, as PIL does. Diffusers'
* VaeImageProcessor resizes this way.
*
* Composite: Image.paste(picture, mask=alpha) onto white, each channel
* (c * a + 255 * (255 - a)) / 255 with PIL's rounding. The reference flattens a transparent
* picture this way for an RGB text encoder. */
#pragma once
#include "mm/media.h"
namespace rad {
namespace mm {
/* `src` resized to w x h. */
void resize_lanczos_rgba(const FrameRGBA& src, int32_t w, int32_t h, FrameRGBA* out);
/* As resize_lanczos_rgba for an opaque picture: wrapped with alpha 255 and resized, so the RGB
* channels are exactly PIL's LANCZOS on the RGB image (premultiply and its inverse are the
* identity at full alpha). The video VAE's reference preprocessing resizes RGB this way. */
void resize_lanczos_rgb(const Frame& src, int32_t w, int32_t h, Frame* out);
/* The same with PIL's BILINEAR filter (a triangle of support 1, widened when shrinking). */
void resize_bilinear_rgba(const FrameRGBA& src, int32_t w, int32_t h, FrameRGBA* out);
/* `src` over an opaque white ground. */
void composite_white(const FrameRGBA& src, Frame* out);
} /* namespace mm */
} /* namespace rad */