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_convert24.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_convert24.c')
-rw-r--r-- | audio/filter/af_convert24.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/audio/filter/af_convert24.c b/audio/filter/af_convert24.c index 18ce156467..96924de344 100644 --- a/audio/filter/af_convert24.c +++ b/audio/filter/af_convert24.c @@ -78,12 +78,12 @@ static struct mp_audio *play(struct af_instance *af, struct mp_audio *data) return NULL; struct mp_audio *out = af->data; - size_t len = data->len / data->bps; + size_t len = mp_audio_psize(data) / data->bps; if (data->bps == 4) { for (int s = 0; s < len; s++) { - uint32_t val = *((uint32_t *)data->audio + s); - uint8_t *ptr = (uint8_t *)out->audio + s * 3; + uint32_t val = *((uint32_t *)data->planes[0] + s); + uint8_t *ptr = (uint8_t *)out->planes[0] + s * 3; ptr[0] = val >> SHIFT(0); ptr[1] = val >> SHIFT(1); ptr[2] = val >> SHIFT(2); @@ -91,24 +91,23 @@ static struct mp_audio *play(struct af_instance *af, struct mp_audio *data) mp_audio_set_format(data, af_fmt_change_bits(data->format, 24)); } else { for (int s = 0; s < len; s++) { - uint8_t *ptr = (uint8_t *)data->audio + s * 3; + uint8_t *ptr = (uint8_t *)data->planes[0] + s * 3; uint32_t val = ptr[0] << SHIFT(0) | ptr[1] << SHIFT(1) | ptr[2] << SHIFT(2); - *((uint32_t *)out->audio + s) = val; + *((uint32_t *)out->planes[0] + s) = val; } mp_audio_set_format(data, af_fmt_change_bits(data->format, 32)); } - data->audio = out->audio; - data->len = len * data->bps; + data->planes[0] = out->planes[0]; return data; } static void uninit(struct af_instance* af) { if (af->data) - free(af->data->audio); + free(af->data->planes[0]); } static int af_open(struct af_instance *af) |