summaryrefslogtreecommitdiffstats
path: root/demux/demux_raw.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-23 21:04:37 +0200
committerwm4 <wm4@nowhere>2014-09-23 23:09:25 +0200
commitb745c2d0050468580aec0a4e12aec854fefd1796 (patch)
tree0df9a9f56b339cabc68376840b4d283b848acdf8 /demux/demux_raw.c
parent5b5a3d0c469fa5e282b60eb9ac2b7e4414640d80 (diff)
downloadmpv-b745c2d0050468580aec0a4e12aec854fefd1796.tar.bz2
mpv-b745c2d0050468580aec0a4e12aec854fefd1796.tar.xz
audio: drop swapped-endian audio formats
Until now, the audio chain could handle both little endian and big endian formats. This actually doesn't make much sense, since the audio API and the HW will most likely prefer native formats. Or at the very least, it should be trivial for audio drivers to do the byte swapping themselves. From now on, the audio chain contains native-endian formats only. All AOs and some filters are adjusted. af_convertsignendian.c is now wrongly named, but the filter name is adjusted. In some cases, the audio infrastructure was reused on the demuxer side, but that is relatively easy to rectify. This is a quite intrusive and radical change. It's possible that it will break some things (especially if they're obscure or not Linux), so watch out for regressions. It's probably still better to do it the bulldozer way, since slow transition and researching foreign platforms would take a lot of time and effort.
Diffstat (limited to 'demux/demux_raw.c')
-rw-r--r--demux/demux_raw.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/demux/demux_raw.c b/demux/demux_raw.c
index 288a1c931c..5dae30308a 100644
--- a/demux/demux_raw.c
+++ b/demux/demux_raw.c
@@ -34,10 +34,13 @@
#include "video/img_format.h"
#include "video/img_fourcc.h"
+#include "osdep/endian.h"
+
struct demux_rawaudio_opts {
struct mp_chmap channels;
int samplerate;
int aformat;
+ int endian;
};
#define OPT_BASE_STRUCT struct demux_rawaudio_opts
@@ -46,13 +49,16 @@ const struct m_sub_options demux_rawaudio_conf = {
OPT_CHMAP("channels", channels, CONF_MIN, .min = 1),
OPT_INTRANGE("rate", samplerate, 0, 1000, 8 * 48000),
OPT_AUDIOFORMAT("format", aformat, 0),
+ OPT_CHOICE("endian", endian, 0, ({"native", 0}, {"le", 1}, {"be", 2})),
{0}
},
.size = sizeof(struct demux_rawaudio_opts),
.defaults = &(const struct demux_rawaudio_opts){
+ // Note that currently, stream_cdda expects exactly these parameters!
.channels = MP_CHMAP_INIT_STEREO,
.samplerate = 44100,
.aformat = AF_FORMAT_S16,
+ .endian = 0,
},
};
@@ -121,6 +127,10 @@ static int demux_rawaudio_open(demuxer_t *demuxer, enum demux_check check)
w->nBlockAlign = w->nChannels * samplesize;
w->wBitsPerSample = 8 * samplesize;
w->cbSize = 0;
+ int machine_endian = BYTE_ORDER == BIG_ENDIAN ? 2 : 1;
+ int endian = opts->endian ? opts->endian : machine_endian;
+ // wav usually implies little endian
+ sh_audio->big_endian = endian == 2;
struct priv *p = talloc_ptrtype(demuxer, p);
demuxer->priv = p;