replace copy_n + reinterpret_cast with memcpy

These usages are not problematic, but they would be if alignment does
not match. Also less verbose.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 1 year ago
parent a199d6cac5
commit bc84f63223

@ -47,9 +47,9 @@ bool AsfVideo::GUIDTag::operator==(const AsfVideo::GUIDTag& other) const {
}
AsfVideo::GUIDTag::GUIDTag(const uint8_t* bytes) {
std::copy_n(bytes, DWORD, reinterpret_cast<uint8_t*>(&data1_));
std::copy_n(bytes + DWORD, WORD, reinterpret_cast<uint8_t*>(&data2_));
std::copy_n(bytes + DWORD + WORD, WORD, reinterpret_cast<uint8_t*>(&data3_));
std::memcpy(&data1_, bytes, DWORD);
std::memcpy(&data2_, bytes + DWORD, WORD);
std::memcpy(&data3_, bytes + DWORD + WORD, WORD);
std::copy(bytes + QWORD, bytes + 2 * QWORD, data4_.begin());
if (isBigEndianPlatform()) {
data1_ = byteSwap(data1_, true);

@ -601,7 +601,7 @@ void Jp2Image::encodeJp2Header(const DataBuf& boxBuf, DataBuf& outBuf) {
while (count < length && !bWroteColor) {
Internal::enforce(boxHSize <= length - count, ErrorCode::kerCorruptedMetadata);
Internal::Jp2BoxHeader subBox;
std::copy_n(boxBuf.c_data(count), boxHSize, reinterpret_cast<byte*>(&subBox));
std::memcpy(&subBox, boxBuf.c_data(count), boxHSize);
Internal::Jp2BoxHeader newBox = subBox;
if (count < length) {

Loading…
Cancel
Save