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_channels.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_channels.c')
-rw-r--r-- | audio/filter/af_channels.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/audio/filter/af_channels.c b/audio/filter/af_channels.c index 27445aafe2..fd3b8262f5 100644 --- a/audio/filter/af_channels.c +++ b/audio/filter/af_channels.c @@ -169,6 +169,10 @@ static int control(struct af_instance* af, int cmd, void* arg) af->data->rate = ((struct mp_audio*)arg)->rate; mp_audio_set_format(af->data, ((struct mp_audio*)arg)->format); af->mul = (double)af->data->nch / ((struct mp_audio*)arg)->nch; + mp_audio_force_interleaved_format(af->data); + int r = af_test_output(af,(struct mp_audio*)arg); + if (r != AF_OK) + return r; return check_routes(s,((struct mp_audio*)arg)->nch,af->data->nch); case AF_CONTROL_COMMAND_LINE:{ int nch = 0; @@ -219,7 +223,7 @@ static void uninit(struct af_instance* af) { free(af->setup); if (af->data) - free(af->data->audio); + free(af->data->planes[0]); free(af->data); } @@ -235,16 +239,16 @@ static struct mp_audio* play(struct af_instance* af, struct mp_audio* data) return NULL; // Reset unused channels - memset(l->audio,0,c->len / c->nch * l->nch); + memset(l->planes[0],0,mp_audio_psize(c) / c->nch * l->nch); if(AF_OK == check_routes(s,c->nch,l->nch)) for(i=0;i<s->nr;i++) - copy(c->audio,l->audio,c->nch,s->route[i][FR], - l->nch,s->route[i][TO],c->len,c->bps); + copy(c->planes[0],l->planes[0],c->nch,s->route[i][FR], + l->nch,s->route[i][TO],mp_audio_psize(c),c->bps); // Set output data - c->audio = l->audio; - c->len = c->len / c->nch * l->nch; + c->planes[0] = l->planes[0]; + c->samples = c->samples / c->nch * l->nch; mp_audio_set_channels(c, &l->channels); return c; |