mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-11-02 12:07:02 +00:00
Some unvalid checks on astc decoder
This commit is contained in:
@@ -296,14 +296,19 @@ uint ExtractBits(uvec4 payload, int offset, int bits) {
|
|||||||
if (bits > 32) {
|
if (bits > 32) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
const int last_offset = offset + bits - 1;
|
if (offset >= 128) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const int avail_bits = min(bits, 128 - offset);
|
||||||
|
const int last_offset = offset + avail_bits - 1;
|
||||||
const int shifted_offset = offset >> 5;
|
const int shifted_offset = offset >> 5;
|
||||||
if ((last_offset >> 5) == shifted_offset) {
|
if ((last_offset >> 5) == shifted_offset) {
|
||||||
return bitfieldExtract(payload[shifted_offset], offset & 31, bits);
|
return bitfieldExtract(payload[shifted_offset], offset & 31, avail_bits);
|
||||||
}
|
}
|
||||||
const int first_bits = 32 - (offset & 31);
|
const int first_bits = 32 - (offset & 31);
|
||||||
const int result_first = int(bitfieldExtract(payload[shifted_offset], offset & 31, first_bits));
|
const int result_first = int(bitfieldExtract(payload[shifted_offset], offset & 31, first_bits));
|
||||||
const int result_second = int(bitfieldExtract(payload[shifted_offset + 1], 0, bits - first_bits));
|
const int result_second =
|
||||||
|
int(bitfieldExtract(payload[shifted_offset + 1], 0, avail_bits - first_bits));
|
||||||
return result_first | (result_second << first_bits);
|
return result_first | (result_second << first_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -950,7 +950,7 @@ void ConvertImage(std::span<const u8> input, const ImageInfo& info, std::span<u8
|
|||||||
tile_size.height, output.subspan(output_offset));
|
tile_size.height, output.subspan(output_offset));
|
||||||
|
|
||||||
output_offset += copy.image_extent.width * copy.image_extent.height *
|
output_offset += copy.image_extent.width * copy.image_extent.height *
|
||||||
copy.image_subresource.num_layers *
|
copy.image_extent.depth * copy.image_subresource.num_layers *
|
||||||
BytesPerBlock(PixelFormat::A8B8G8R8_UNORM);
|
BytesPerBlock(PixelFormat::A8B8G8R8_UNORM);
|
||||||
} else if (astc) {
|
} else if (astc) {
|
||||||
// BC1 uses 0.5 bytes per texel
|
// BC1 uses 0.5 bytes per texel
|
||||||
@@ -985,7 +985,7 @@ void ConvertImage(std::span<const u8> input, const ImageInfo& info, std::span<u8
|
|||||||
} else {
|
} else {
|
||||||
DecompressBCn(input_offset, output.subspan(output_offset), copy, info.format);
|
DecompressBCn(input_offset, output.subspan(output_offset), copy, info.format);
|
||||||
output_offset += copy.image_extent.width * copy.image_extent.height *
|
output_offset += copy.image_extent.width * copy.image_extent.height *
|
||||||
copy.image_subresource.num_layers *
|
copy.image_extent.depth * copy.image_subresource.num_layers *
|
||||||
ConvertedBytesPerBlock(info.format);
|
ConvertedBytesPerBlock(info.format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user