Skip to content

clamp angular weight span before narrowing to int#649

Open
sahvx655-wq wants to merge 1 commit into
ARM-software:mainfrom
sahvx655-wq:weight-span-int-clamp
Open

clamp angular weight span before narrowing to int#649
sahvx655-wq wants to merge 1 commit into
ARM-software:mainfrom
sahvx655-wq:weight-span-int-clamp

Conversation

@sahvx655-wq

Copy link
Copy Markdown
Contributor

compute_lowest_and_highest_weight() in the angular weight search narrows the per-step span with float_to_int(maxidx - minidx + 1). The span is derived from the block's ideal decimated weights, which in turn come from the input texels, so an HDR source carrying +/-inf or NaN (both legal in fp16/fp32 and routinely present in EXR content) makes the span non-finite and the conversion runs outside the representable int range. UBSan reports "inf is outside the range of representable values of type int" at the vecmathlib float_to_int, reached directly from astcenc_compress_image on a normal HDR compress; the value is silently garbage on the platforms where it does not trap.

The span is already clamped into [2, max_quant_steps + 3] on the next two lines, so I clamp the float into that same range before the conversion rather than altering the shared float_to_int primitive. That keeps the change at the one spot that can observe non-finite input and stays bit-identical for every finite in-range value, leaving the existing integer min/max untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant