diff options
author | wm4 <wm4@nowhere> | 2013-11-10 23:11:40 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-12 23:16:31 +0100 |
commit | d2e7467eb203d3a34bc1111564c7058b5e9c6b12 (patch) | |
tree | 9285523821c8710a0609f47e3ee923a20d038826 /audio/filter/af_volume.c | |
parent | b2d4b5ee43206f8c4491b3af1c24fedd35dbdc31 (diff) | |
download | mpv-d2e7467eb203d3a34bc1111564c7058b5e9c6b12.tar.bz2 mpv-d2e7467eb203d3a34bc1111564c7058b5e9c6b12.tar.xz |
audio/filter: prepare filter chain for non-interleaved audio
Based on earlier work by Stefano Pigozzi.
There are 2 changes:
1. Instead of mp_audio.audio, mp_audio.planes[0] must be used.
2. mp_audio.len used to contain the size of the audio in bytes. Now
mp_audio.samples must be used. (Where 1 sample is the smallest unit
of audio that covers all channels.)
Also, some filters need changes to reject non-interleaved formats
properly.
Nothing uses the non-interleaved features yet, but this is needed so
that things don't just break when doing so.
Diffstat (limited to 'audio/filter/af_volume.c')
-rw-r--r-- | audio/filter/af_volume.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/audio/filter/af_volume.c b/audio/filter/af_volume.c index 9639ffb5c4..bef7873166 100644 --- a/audio/filter/af_volume.c +++ b/audio/filter/af_volume.c @@ -43,6 +43,7 @@ static int control(struct af_instance *af, int cmd, void *arg) switch (cmd) { case AF_CONTROL_REINIT: mp_audio_copy_config(af->data, (struct mp_audio *)arg); + mp_audio_force_interleaved_format(af->data); if (s->fast && (((struct mp_audio *)arg)->format != AF_FORMAT_FLOAT_NE)) mp_audio_set_format(af->data, AF_FORMAT_S16_NE); @@ -66,8 +67,8 @@ static struct mp_audio *play(struct af_instance *af, struct mp_audio *data) struct priv *s = af->priv; if (af->data->format == AF_FORMAT_S16_NE) { - int16_t *a = c->audio; - int len = c->len / 2; + int16_t *a = c->planes[0]; + int len = c->samples * c->nch; int vol = 256.0 * s->level; if (vol != 256) { for (int i = 0; i < len; i++) { @@ -76,8 +77,8 @@ static struct mp_audio *play(struct af_instance *af, struct mp_audio *data) } } } else if (af->data->format == AF_FORMAT_FLOAT_NE) { - float *a = c->audio; - int len = c->len / 4; + float *a = c->planes[0]; + int len = c->samples * c->nch; float vol = s->level; if (vol != 1.0) { for (int i = 0; i < len; i++) { |