diff mbox series

[FFmpeg-devel,v2] avisynth: fix audio on big endian

Message ID 20210217235535.16226-1-qyot27@gmail.com
State Accepted
Commit 16e8ea0dde6c0de9bb94d1634e0ed0ad85fd642e
Headers show
Series [FFmpeg-devel,v2] avisynth: fix audio on big endian
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Stephen Hutchinson Feb. 17, 2021, 11:55 p.m. UTC
---
 libavformat/avisynth.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index f029a0e842..4cd6d6bc90 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -42,6 +42,13 @@ 
   #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 {
@@ -496,16 +503,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,