diff options
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux_raw.c | 10 | ||||
-rw-r--r-- | demux/demux_tv.c | 13 | ||||
-rw-r--r-- | demux/stheader.h | 1 |
3 files changed, 17 insertions, 7 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; diff --git a/demux/demux_tv.c b/demux/demux_tv.c index fe7584a387..a4421a86cf 100644 --- a/demux/demux_tv.c +++ b/demux/demux_tv.c @@ -11,6 +11,7 @@ #include "audio/format.h" #include "video/img_fourcc.h" +#include "osdep/endian.h" #include "stream/stream.h" #include "stream/tv.h" @@ -106,14 +107,10 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check) { case AF_FORMAT_U8: case AF_FORMAT_S8: - case AF_FORMAT_U16_LE: - case AF_FORMAT_U16_BE: - case AF_FORMAT_S16_LE: - case AF_FORMAT_S16_BE: - case AF_FORMAT_S32_LE: - case AF_FORMAT_S32_BE: + case AF_FORMAT_U16: + case AF_FORMAT_S16: + case AF_FORMAT_S32: break; - case AF_FORMAT_MPEG2: default: MP_ERR(tvh, "Audio type '%s' unsupported!\n", af_fmt_to_str(audio_format)); @@ -147,6 +144,8 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check) sh_audio->wf->nSamplesPerSec = sh_audio->samplerate; sh_audio->wf->nBlockAlign = block_align; sh_audio->wf->nAvgBytesPerSec = bytes_per_second; + // wav header usually implies little endian + sh_audio->big_endian = BYTE_ORDER == BIG_ENDIAN; MP_VERBOSE(tvh, " TV audio: %d channels, %d bits, %d Hz\n", sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample, diff --git a/demux/stheader.h b/demux/stheader.h index af1e7bb44a..806f7d9c5a 100644 --- a/demux/stheader.h +++ b/demux/stheader.h @@ -70,6 +70,7 @@ typedef struct sh_audio { int bitrate; // compressed bits/sec // win32-compatible codec parameters: MP_WAVEFORMATEX *wf; + bool big_endian; // endianess with wf and mp-pcm // note codec extradata may be either under "wf" or "codecdata" unsigned char *codecdata; int codecdata_len; |