* Included by texcompress_bptc and gallium to define BPTC decoding routines.
*/
+#ifndef TEXCOMPRESS_BPTC_TMP_H
+#define TEXCOMPRESS_BPTC_TMP_H
+
#include "util/format_srgb.h"
#include "util/half_float.h"
#include "macros.h"
sign_extend(int32_t value,
int n_bits)
{
- if ((value & (1 << (n_bits - 1)))) {
- value |= (~(int32_t) 0) << n_bits;
- }
+ assert(n_bits > 0 && n_bits < 32);
- return value;
+ const unsigned n = 32 - n_bits;
+ return (int32_t)((uint32_t)value << n) >> n;
}
static int
dst += dst_row_diff;
}
}
+
+#endif