@@ -240,7 +240,7 @@ FilePicReader::Picture * FilePicReader::ExtractFLACPicture(const std::string& fi
240
240
// get last block flag. if true next loop will stop
241
241
isLast = ((*buf & 0x80 ) != 0 );
242
242
// get the current block size
243
- unsigned v = (read32be (buf) & 0xffffff ) - 4 ;
243
+ unsigned v = (read_b32be (buf) & 0xffffff ) - 4 ;
244
244
if (v > MAX_PICTURE_SIZE)
245
245
break ;
246
246
@@ -250,17 +250,17 @@ FilePicReader::Picture * FilePicReader::ExtractFLACPicture(const std::string& fi
250
250
{
251
251
DBG (DBG_PROTO, " %s: picture type (%.2x)\n " , __FUNCTION__, buf[7 ]);
252
252
// check picture type matches with requirement
253
- if (read32be (buf + 4 ) == pictureType || pictureType == -1 )
253
+ if (read_b32be (buf + 4 ) == pictureType || pictureType == -1 )
254
254
{
255
255
unsigned mime_type_len;
256
256
unsigned desc_len;
257
257
unsigned data_len;
258
258
char * picbuf = new char [v];
259
259
// read data block and check for sanity
260
260
if (fread (picbuf, 1 , v, file) != v ||
261
- (mime_type_len = read32be (picbuf)) > v - 4 ||
262
- (desc_len = read32be (picbuf + 4 + mime_type_len)) > v - 8 - mime_type_len ||
263
- (data_len = read32be (picbuf + mime_type_len + desc_len + 24 )) > v - 28 - desc_len - mime_type_len)
261
+ (mime_type_len = read_b32be (picbuf)) > v - 4 ||
262
+ (desc_len = read_b32be (picbuf + 4 + mime_type_len)) > v - 8 - mime_type_len ||
263
+ (data_len = read_b32be (picbuf + mime_type_len + desc_len + 24 )) > v - 28 - desc_len - mime_type_len)
264
264
{
265
265
delete [] picbuf;
266
266
break ;
@@ -384,20 +384,20 @@ static inline void _parse_id3v2_frame_header(char * data, unsigned int version,
384
384
case 2 :
385
385
memcpy (fh->frame_id , data, 3 );
386
386
fh->frame_id [3 ] = 0 ;
387
- fh->frame_size = (unsigned )read24be (data + 3 );
387
+ fh->frame_size = (unsigned )read_b24be (data + 3 );
388
388
fh->compression = 0 ;
389
389
fh->data_length_indicator = 0 ;
390
390
break ;
391
391
case 3 :
392
392
memcpy (fh->frame_id , data, 4 );
393
- fh->frame_size = (unsigned )read32be (data + 4 );
393
+ fh->frame_size = (unsigned )read_b32be (data + 4 );
394
394
fh->compression = data[9 ] & 0x40 ;
395
395
fh->data_length_indicator = 0 ;
396
396
break ;
397
397
case 4 :
398
398
default :
399
399
memcpy (fh->frame_id , data, 4 );
400
- fh->frame_size = (unsigned )read32be (data + 4 );
400
+ fh->frame_size = (unsigned )read_b32be (data + 4 );
401
401
fh->compression = data[9 ] & 0x4 ;
402
402
fh->data_length_indicator = data[9 ] & 0x1 ;
403
403
break ;
@@ -671,7 +671,7 @@ int FilePicReader::parse_id3v2(FILE * file, long id3v2_offset, Picture ** pic, o
671
671
if (fread (extended_header_data, 1 , 6 , file) != 6 )
672
672
return -1 ;
673
673
674
- extended_header_size = (unsigned )read32be (extended_header_data);
674
+ extended_header_size = (unsigned )read_b32be (extended_header_data);
675
675
676
676
fseek (file, extended_header_size - 6 , SEEK_CUR);
677
677
frame_data_pos += extended_header_size;
@@ -766,8 +766,8 @@ FilePicReader::Picture * FilePicReader::ExtractOGGSPicture(const std::string& fi
766
766
break ;
767
767
}
768
768
// char stream_structure_version = read8(buf + 4);
769
- unsigned char header_type_flag = (unsigned char )read8 (buf + 5 );
770
- unsigned char number_page_segments = (unsigned char )read8 (buf + 26 );
769
+ unsigned char header_type_flag = (unsigned char )read_b8 (buf + 5 );
770
+ unsigned char number_page_segments = (unsigned char )read_b8 (buf + 26 );
771
771
772
772
uint32_t segment_table = 0 ;
773
773
if (fread (lacing, 1 , number_page_segments, file) != number_page_segments)
@@ -777,7 +777,7 @@ FilePicReader::Picture * FilePicReader::ExtractOGGSPicture(const std::string& fi
777
777
}
778
778
779
779
for (int i = 0 ; i < number_page_segments; ++i)
780
- segment_table += (unsigned char )read8 (lacing + i);
780
+ segment_table += (unsigned char )read_b8 (lacing + i);
781
781
782
782
// bit 0x04: this is the last page of a logical bitstream (eos)
783
783
if ((header_type_flag & 0x04 ) == 0x04 )
@@ -828,7 +828,7 @@ FilePicReader::Picture * FilePicReader::ExtractOGGSPicture(const std::string& fi
828
828
}
829
829
830
830
// check for vorbis comment header
831
- unsigned char block = (unsigned char )read8 (packet.data );
831
+ unsigned char block = (unsigned char )read_b8 (packet.data );
832
832
if (block == 0x03 && packet.datalen > 7 &&
833
833
memcmp (packet.data + 1 , " vorbis" , 6 ) == 0 )
834
834
{
@@ -895,12 +895,12 @@ bool FilePicReader::parse_comment(packet_t * packet, Picture ** pic, PictureType
895
895
bool gotoLast = false ;
896
896
unsigned char * ve = packet->data + packet->datalen ;
897
897
unsigned char * vp = packet->data + 7 ; // pass magic string
898
- vp += read32le (vp) + 4 ; // pass vendor string
899
- int count = read32le (vp); // comment list length;
898
+ vp += read_b32le (vp) + 4 ; // pass vendor string
899
+ int count = read_b32le (vp); // comment list length;
900
900
vp += 4 ;
901
901
while (count > 0 )
902
902
{
903
- int len = read32le (vp);
903
+ int len = read_b32le (vp);
904
904
vp += 4 ;
905
905
if ((vp + len) > ve)
906
906
break ; // buffer overflow
@@ -911,15 +911,15 @@ bool FilePicReader::parse_comment(packet_t * packet, Picture ** pic, PictureType
911
911
char * picbuf = nullptr ;
912
912
size_t lenbuf = Base64::b64decode (vp + 23 , len - 23 , &picbuf);
913
913
// check picture type matches with requirement
914
- if (lenbuf > 8 && (read32be (picbuf) == pictureType || pictureType == -1 ))
914
+ if (lenbuf > 8 && (read_b32be (picbuf) == pictureType || pictureType == -1 ))
915
915
{
916
916
unsigned mime_type_len;
917
917
unsigned desc_len;
918
918
unsigned data_len;
919
919
// check for sanity
920
- if ((mime_type_len = read32be (picbuf + 4 )) > lenbuf - 8 ||
921
- (desc_len = read32be (picbuf + 8 + mime_type_len)) > lenbuf - 12 - mime_type_len ||
922
- (data_len = read32be (picbuf + mime_type_len + desc_len + 28 )) > lenbuf - 32 - desc_len - mime_type_len)
920
+ if ((mime_type_len = read_b32be (picbuf + 4 )) > lenbuf - 8 ||
921
+ (desc_len = read_b32be (picbuf + 8 + mime_type_len)) > lenbuf - 12 - mime_type_len ||
922
+ (data_len = read_b32be (picbuf + mime_type_len + desc_len + 28 )) > lenbuf - 32 - desc_len - mime_type_len)
923
923
{
924
924
delete [] picbuf;
925
925
break ;
@@ -1015,15 +1015,15 @@ int FilePicReader::nextChild(unsigned char * buf, uint64_t * remaining, FILE * f
1015
1015
if (fread (buf, 1 , M4A_HEADER_SIZE, fp) == M4A_HEADER_SIZE)
1016
1016
{
1017
1017
*remaining -= M4A_HEADER_SIZE;
1018
- *child = (unsigned )read32be (buf + 4 );
1019
- *childSize = (uint32_t )read32be (buf);
1018
+ *child = (unsigned )read_b32be (buf + 4 );
1019
+ *childSize = (uint32_t )read_b32be (buf);
1020
1020
if (*childSize == 1 )
1021
1021
{
1022
1022
// size of 1 means the real size follows the header in next 8 bytes (64bits)
1023
1023
if (*remaining < 8 || fread (buf, 1 , 8 , fp) != 8 )
1024
1024
return -1 ; // error
1025
1025
*remaining -= 8 ;
1026
- *childSize = (((uint64_t )read32be (buf) << 32 ) | (uint32_t )read32be (buf + 4 )) - M4A_HEADER_SIZE - 8 ;
1026
+ *childSize = (((uint64_t )read_b32be (buf) << 32 ) | (uint32_t )read_b32be (buf + 4 )) - M4A_HEADER_SIZE - 8 ;
1027
1027
}
1028
1028
else
1029
1029
{
@@ -1054,7 +1054,7 @@ int FilePicReader::loadDataValue(uint64_t * remaining, FILE * fp, char ** alloc,
1054
1054
*remaining -= size;
1055
1055
*allocSize = size;
1056
1056
*alloc = _alloc;
1057
- return (read32be (_alloc) & 0x00ffffff ); // return datatype
1057
+ return (read_b32be (_alloc) & 0x00ffffff ); // return datatype
1058
1058
}
1059
1059
return r;
1060
1060
}
0 commit comments