summaryrefslogtreecommitdiffstats
path: root/audio/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-10 23:11:40 +0100
committerwm4 <wm4@nowhere>2013-11-12 23:16:31 +0100
commitd2e7467eb203d3a34bc1111564c7058b5e9c6b12 (patch)
tree9285523821c8710a0609f47e3ee923a20d038826 /audio/decode
parentb2d4b5ee43206f8c4491b3af1c24fedd35dbdc31 (diff)
downloadmpv-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/decode')
-rw-r--r--audio/decode/dec_audio.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index e381a12a3c..ef7993c83a 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -270,20 +270,20 @@ static int filter_n_bytes(sh_audio_t *sh, struct bstr *outbuf, int len)
// Filter
struct mp_audio filter_input = {
- .audio = sh->a_buffer,
- .len = len,
+ .planes = {sh->a_buffer},
.rate = sh->samplerate,
};
mp_audio_set_format(&filter_input, sh->sample_format);
mp_audio_set_channels(&filter_input, &sh->channels);
+ filter_input.samples = len / filter_input.sstride;
struct mp_audio *filter_output = af_play(sh->afilter, &filter_input);
if (!filter_output)
return -1;
- set_min_out_buffer_size(outbuf, outbuf->len + filter_output->len);
- memcpy(outbuf->start + outbuf->len, filter_output->audio,
- filter_output->len);
- outbuf->len += filter_output->len;
+ int outlen = filter_output->samples * filter_output->sstride;
+ set_min_out_buffer_size(outbuf, outbuf->len + outlen);
+ memcpy(outbuf->start + outbuf->len, filter_output->planes[0], outlen);
+ outbuf->len += outlen;
// remove processed data from decoder buffer:
sh->a_buffer_len -= len;