Browse Source

avisynth: fix audio on big endian

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>
tags/n4.4
Stephen Hutchinson 5 years ago
parent
commit
16e8ea0dde
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      libavformat/avisynth.c

+ 11
- 4
libavformat/avisynth.c View File

@@ -42,6 +42,13 @@
#define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF
#endif #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> #include <avisynth/avisynth_c.h>


typedef struct AviSynthLibrary { 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; st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
break; break;
case AVS_SAMPLE_INT16: case AVS_SAMPLE_INT16:
st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
st->codecpar->codec_id = PCM(S16);
break; break;
case AVS_SAMPLE_INT24: case AVS_SAMPLE_INT24:
st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
st->codecpar->codec_id = PCM(S24);
break; break;
case AVS_SAMPLE_INT32: case AVS_SAMPLE_INT32:
st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
st->codecpar->codec_id = PCM(S32);
break; break;
case AVS_SAMPLE_FLOAT: case AVS_SAMPLE_FLOAT:
st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
st->codecpar->codec_id = PCM(F32);
break; break;
default: default:
av_log(s, AV_LOG_ERROR, av_log(s, AV_LOG_ERROR,


Loading…
Cancel
Save