mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
Add read_64bitBE/LE for Rockstar AWC
They use it encode 3 values in 64b and save one byte in the process, whee.
This commit is contained in:
parent
5bf0ddbfac
commit
c4a6e6e194
@ -134,6 +134,18 @@ static inline int32_t read_32bitBE(off_t offset, STREAMFILE * streamfile) {
|
||||
if (read_streamfile(buf,offset,4,streamfile)!=4) return -1;
|
||||
return get_32bitBE(buf);
|
||||
}
|
||||
static inline int64_t read_64bitLE(off_t offset, STREAMFILE * streamfile) {
|
||||
uint8_t buf[8];
|
||||
|
||||
if (read_streamfile(buf,offset,8,streamfile)!=8) return -1;
|
||||
return get_64bitLE(buf);
|
||||
}
|
||||
static inline int64_t read_64bitBE(off_t offset, STREAMFILE * streamfile) {
|
||||
uint8_t buf[8];
|
||||
|
||||
if (read_streamfile(buf,offset,8,streamfile)!=8) return -1;
|
||||
return get_64bitBE(buf);
|
||||
}
|
||||
|
||||
static inline int8_t read_8bit(off_t offset, STREAMFILE * streamfile) {
|
||||
uint8_t buf[1];
|
||||
|
@ -25,6 +25,14 @@ static inline int32_t get_32bitLE(uint8_t * p) {
|
||||
return (p[0]) | (p[1]<<8) | (p[2]<<16) | (p[3]<<24);
|
||||
}
|
||||
|
||||
static inline int64_t get_64bitBE(uint8_t * p) {
|
||||
return (uint64_t)(((uint64_t)p[0]<<56) | ((uint64_t)p[1]<<48) | ((uint64_t)p[2]<<40) | ((uint64_t)p[3]<<32) | ((uint64_t)p[4]<<24) | ((uint64_t)p[5]<<16) | ((uint64_t)p[6]<<8) | ((uint64_t)p[7]));
|
||||
}
|
||||
|
||||
static inline int64_t get_64bitLE(uint8_t * p) {
|
||||
return (uint64_t)(((uint64_t)p[0]) | ((uint64_t)p[1]<<8) | ((uint64_t)p[2]<<16) | ((uint64_t)p[3]<<24) | ((uint64_t)p[4]<<32) | ((uint64_t)p[5]<<40) | ((uint64_t)p[6]<<48) | ((uint64_t)p[7]<<56));
|
||||
}
|
||||
|
||||
void put_8bit(uint8_t * buf, int8_t i);
|
||||
|
||||
void put_16bitLE(uint8_t * buf, int16_t i);
|
||||
|
Loading…
x
Reference in New Issue
Block a user