Skip to content

Commit 68977b0

Browse files
committed
asfvideo: replace memcpy and byteSwap
We can just treat the data as big endian with bit shifting and ORing. Signed-off-by: Rosen Penev <[email protected]>
1 parent ee3e9ad commit 68977b0

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/asfvideo.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,10 @@ bool AsfVideo::GUIDTag::operator==(const AsfVideo::GUIDTag& other) const {
4444
}
4545

4646
AsfVideo::GUIDTag::GUIDTag(const uint8_t* bytes) {
47-
std::memcpy(&data1_, bytes, DWORD);
48-
std::memcpy(&data2_, bytes + DWORD, WORD);
49-
std::memcpy(&data3_, bytes + DWORD + WORD, WORD);
47+
data1_ = Exiv2::getULong(bytes, ByteOrder::littleEndian);
48+
data2_ = Exiv2::getUShort(bytes + DWORD, ByteOrder::littleEndian);
49+
data3_ = Exiv2::getUShort(bytes + DWORD + WORD, ByteOrder::littleEndian);
5050
std::copy(bytes + QWORD, bytes + (2 * QWORD), data4_.begin());
51-
if (isBigEndianPlatform()) {
52-
data1_ = byteSwap(data1_, true);
53-
data2_ = byteSwap(data2_, true);
54-
data3_ = byteSwap(data3_, true);
55-
}
5651
}
5752

5853
std::string AsfVideo::GUIDTag::to_string() const {

0 commit comments

Comments
 (0)