]> git.sesse.net Git - ffmpeg/commitdiff
avisynth: fix audio on big endian
authorStephen Hutchinson <qyot27@gmail.com>
Sun, 3 Jan 2021 22:58:36 +0000 (17:58 -0500)
committerStephen Hutchinson <qyot27@gmail.com>
Thu, 11 Mar 2021 19:21:30 +0000 (14:21 -0500)
AviSynth+ outputs audio in the same format as the
OS, so assuming little endian formats as input
on big endian OSes results in nothing but static.

Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
libavformat/avisynth.c

index 64fb6cc98fc83e0126465dfb97ce7f2d55ea8f2b..21ae8c183a9b9b27108d508d3b9845f04dbfa13e 100644 (file)
   #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF
 #endif
 
+/* Endianness guards for audio */
+#if HAVE_BIGENDIAN
+    #define PCM(format) (AV_CODEC_ID_PCM_ ## format ## BE)
+#else
+    #define PCM(format) (AV_CODEC_ID_PCM_ ## format ## LE)
+#endif
+
 #include <avisynth/avisynth_c.h>
 
 typedef struct AviSynthLibrary {
@@ -513,16 +520,16 @@ static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
         st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
         break;
     case AVS_SAMPLE_INT16:
-        st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+        st->codecpar->codec_id = PCM(S16);
         break;
     case AVS_SAMPLE_INT24:
-        st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
+        st->codecpar->codec_id = PCM(S24);
         break;
     case AVS_SAMPLE_INT32:
-        st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
+        st->codecpar->codec_id = PCM(S32);
         break;
     case AVS_SAMPLE_FLOAT:
-        st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
+        st->codecpar->codec_id = PCM(F32);
         break;
     default:
         av_log(s, AV_LOG_ERROR,