Skip to content

Commit

Permalink
Fix big endian issue in last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
myrsloik committed Apr 24, 2024
1 parent 4506ed6 commit 4d0d83f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/avisynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
#define AVS_EXPORT __attribute__((visibility("default")))
#endif

// Endian detection
#ifdef _WIN32
#define BS_LITTLE_ENDIAN
#elif defined(__BYTE_ORDER__)
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define BS_BIG_ENDIAN
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define BS_LITTLE_ENDIAN
#endif
#endif

static std::once_flag BSInitOnce;

static void BSInit() {
Expand Down Expand Up @@ -343,8 +354,11 @@ class AvisynthAudioSource : public IClip {
uint8_t *Dst = reinterpret_cast<uint8_t *>(Buf);
A->GetPackedAudio(reinterpret_cast<uint8_t *>(Tmp.get()), Start, Count);
for (int64_t i = 0; i < Count * VI.nchannels; i++) {
// FIXME, the +1 is only for little endian
#ifdef BS_LITTLE_ENDIAN
memcpy(Dst, Tmp.get() + i * 4 + 1, 3);
#else
memcpy(Dst, Tmp.get() + i * 4, 3);
#endif
Dst += 3;
}
} else {
Expand Down

0 comments on commit 4d0d83f

Please sign in to comment.