radeonsi/video: Fix assert in radeon_bs_code_ns

It is valid for w to be 1, in that case nothing should be encoded
in the bitstream.
value must be lower than max, add that as an assert instead.

Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35648>
This commit is contained in:
David Rosca
2025-06-24 14:09:43 +02:00
committed by Marge Bot
parent ad56f0122c
commit a801df753c
@@ -156,6 +156,8 @@ void radeon_bs_code_ns(struct radeon_bitstream *bs, uint32_t value, uint32_t max
uint32_t m;
uint32_t max_num = max;
assert(value < max);
while ( max_num ) {
max_num >>= 1;
w++;
@@ -163,8 +165,6 @@ void radeon_bs_code_ns(struct radeon_bitstream *bs, uint32_t value, uint32_t max
m = (1 << w) - max;
assert(w > 1);
if (value < m) {
radeon_bs_code_fixed_bits(bs, value, (w - 1));
} else {