mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-23 02:07:45 +00:00

- Refactored datReader and several other files for code cleanliness - Enhanced runtime performance by optimizing select functions, utilizing std::string_view in place of std::string where appropriate - Removed deprecated filesystem implementation - Introduced Link Time Optimization (LTO) support for Linux builds - Enabled parallel builds for GCC/Clang compilers - Expanded and improved comments for various functions - Replaced version check failure with warning, allowing for continued use with a cautionary message Tested on MSVC/Windows and Clang/Ubuntu
36 lines
742 B
C++
36 lines
742 B
C++
#include "conv.h"
|
|
#include <cstring>
|
|
|
|
namespace xiv::utils::conv
|
|
{
|
|
|
|
float half2float( const uint16_t i_value )
|
|
{
|
|
uint32_t t1;
|
|
uint32_t t2;
|
|
uint32_t t3;
|
|
|
|
t1 = i_value & 0x7fff; // Non-sign bits
|
|
t2 = i_value & 0x8000; // Sign bit
|
|
t3 = i_value & 0x7c00; // Exponent
|
|
t1 <<= 13; // Align mantissa on MSB
|
|
t2 <<= 16; // Shift sign bit into position
|
|
|
|
t1 += 0x38000000; // Adjust bias
|
|
|
|
t1 = ( t3 == 0 ? 0 : t1 );// Denormals-as-zero
|
|
|
|
t1 |= t2; // Re-insert sign bit
|
|
|
|
float result;
|
|
memcpy( &result, &t1, sizeof( float ) );
|
|
return result;
|
|
}
|
|
|
|
float ubyte2float( const uint8_t i_value )
|
|
{
|
|
return i_value / 255.0f;
|
|
}
|
|
|
|
}
|
|
|