summaryrefslogtreecommitdiffstats
path: root/demux/demux_rawaudio.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-06 22:43:12 +0200
committerwm4 <wm4@nowhere>2013-05-12 21:24:55 +0200
commit4b5cee4617d0decbf93d06df4f45097fd7e00105 (patch)
treeb6d293e86d83ab5c3efd99153aa7a7a134d2937f /demux/demux_rawaudio.c
parent586b75ad0840e154835ae67c7720b71bd36f8cc9 (diff)
downloadmpv-4b5cee4617d0decbf93d06df4f45097fd7e00105.tar.bz2
mpv-4b5cee4617d0decbf93d06df4f45097fd7e00105.tar.xz
core: use channel map on demuxer level too
This helps passing the channel layout correctly from decoder to audio filter chain. (Because that part "reuses" the demuxer level codec parameters, which is very disgusting.) Note that ffmpeg stuff already passed the channel layout via mp_copy_lav_codec_headers(). So other than easier dealing with the demuxer/decoder parameters mess, there's no real advantage to doing this. Make the --channels option accept a channel map. Since simple numbers map to standard layouts with the given number of channels, this is downwards compatible. Likewise for demux_rawaudio.
Diffstat (limited to 'demux/demux_rawaudio.c')
-rw-r--r--demux/demux_rawaudio.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/demux/demux_rawaudio.c b/demux/demux_rawaudio.c
index c6aad60806..3cd2500e03 100644
--- a/demux/demux_rawaudio.c
+++ b/demux/demux_rawaudio.c
@@ -31,12 +31,12 @@
#include "audio/format.h"
-static int channels = 2;
+static struct mp_chmap channels = MP_CHMAP_INIT_STEREO;
static int samplerate = 44100;
static int format = AF_FORMAT_S16_NE;
const m_option_t demux_rawaudio_opts[] = {
- { "channels", &channels, CONF_TYPE_INT,CONF_RANGE,1,8, NULL },
+ { "channels", &channels, &m_option_type_chmap, CONF_MIN, 1 },
{ "rate", &samplerate, CONF_TYPE_INT,CONF_RANGE,1000,8*48000, NULL },
{ "format", &format, CONF_TYPE_AFMT, 0, 0, 0, NULL },
{NULL, NULL, 0, 0, 0, 0, NULL}
@@ -55,11 +55,12 @@ static demuxer_t* demux_rawaudio_open(demuxer_t* demuxer) {
sh_audio->format = format;
sh_audio->wf = w = malloc(sizeof(*w));
w->wFormatTag = 0;
- w->nChannels = sh_audio->channels = channels;
+ sh_audio->channels = channels;
+ w->nChannels = sh_audio->channels.num;
w->nSamplesPerSec = sh_audio->samplerate = samplerate;
int samplesize = (af_fmt2bits(format) + 7) / 8;
- w->nAvgBytesPerSec = samplerate * samplesize * channels;
- w->nBlockAlign = channels * samplesize;
+ w->nAvgBytesPerSec = samplerate * samplesize * w->nChannels;
+ w->nBlockAlign = w->nChannels * samplesize;
w->wBitsPerSample = 8 * samplesize;
w->cbSize = 0;
@@ -105,7 +106,7 @@ static void demux_rawaudio_seek(demuxer_t *demuxer,float rel_seek_secs,float aud
else
pos = base + (rel_seek_secs*sh_audio->i_bps);
- pos -= (pos % (sh_audio->channels * sh_audio->samplesize) );
+ pos -= (pos % (sh_audio->channels.num * sh_audio->samplesize) );
stream_seek(s,pos);
// printf("demux_rawaudio: streamtell=%d\n",(int)stream_tell(demuxer->stream));
}