diff options
author | Sven Gothel <[email protected]> | 2015-03-28 02:08:11 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-03-28 02:08:11 +0100 |
commit | 450aa6f7df9e67dd256b86f94e65eaf707032aad (patch) | |
tree | 04aa207d84ddc8ca246d2573aaaf756b3ce8a0b5 /LibOVR/Src/Net/OVR_BitStream.cpp | |
parent | 3c7b8a17e907f4ef2afd9f77db566a3f6179cbe4 (diff) | |
parent | 4207f9c279e832e3afcb3f5fc6cd8d84cb4cfe4c (diff) |
Merge branch 'vanilla_0.5.0.1' into jogamp_0.5.0.1
Conflicts:
LibOVR/Include/OVR_CAPI_0_5_0.h
LibOVR/Src/CAPI/CAPI_HMDState.cpp
LibOVR/Src/Displays/OVR_Win32_Dxgi_Display.h
LibOVR/Src/Kernel/OVR_System.cpp
LibOVR/Src/OVR_CAPI.cpp
LibOVR/Src/OVR_Profile.cpp
LibOVRKernel/Src/Kernel/OVR_ThreadsWinAPI.cpp
LibOVRKernel/Src/Kernel/OVR_Types.h
Diffstat (limited to 'LibOVR/Src/Net/OVR_BitStream.cpp')
-rw-r--r-- | LibOVR/Src/Net/OVR_BitStream.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/LibOVR/Src/Net/OVR_BitStream.cpp b/LibOVR/Src/Net/OVR_BitStream.cpp index b565f22..054f871 100644 --- a/LibOVR/Src/Net/OVR_BitStream.cpp +++ b/LibOVR/Src/Net/OVR_BitStream.cpp @@ -107,6 +107,18 @@ BitStream::BitStream( char* _data, const unsigned int lengthInBytes, bool _copyD data = ( unsigned char* ) _data; } +void BitStream::WrapBuffer(unsigned char* _data, const unsigned int lengthInBytes) +{ + if (copyData && numberOfBitsAllocated > (BITSTREAM_STACK_ALLOCATION_SIZE << 3)) + OVR_FREE(data); // Use realloc and free so we are more efficient than delete and new for resizing + + numberOfBitsUsed = lengthInBytes << 3; + readOffset = 0; + copyData = false; + numberOfBitsAllocated = lengthInBytes << 3; + data = (unsigned char*)_data; +} + // Use this if you pass a pointer copy to the constructor (_copyData==false) and want to overallocate to prevent reallocation void BitStream::SetNumberOfBitsAllocated( const BitSize_t lengthInBits ) { @@ -183,8 +195,9 @@ void BitStream::Write( BitStream *bitStream, BitSize_t numberOfBits ) numberOfBitsUsed+=BYTES_TO_BITS(numBytes); } - while (numberOfBits-->0 && bitStream->readOffset + 1 <= bitStream->numberOfBitsUsed) + while (numberOfBits > 0 && bitStream->readOffset + 1 <= bitStream->numberOfBitsUsed) { + --numberOfBits; numberOfBitsMod8 = numberOfBitsUsed & 7; if ( numberOfBitsMod8 == 0 ) { @@ -974,14 +987,8 @@ void BitStream::AssertCopyData( void ) } bool BitStream::IsNetworkOrderInternal(void) { -#if defined(_PS3) || defined(__PS3__) || defined(SN_TARGET_PS3) - return true; -#elif defined(SN_TARGET_PSP2) - return false; -#else - static unsigned long htonlValue = htonl(12345); - return htonlValue == 12345; -#endif + static unsigned long htonlValue = htonl(12345); + return htonlValue == 12345; } void BitStream::ReverseBytes(unsigned char *inByteArray, unsigned char *inOutByteArray, const unsigned int length) { |