From d2e7467eb203d3a34bc1111564c7058b5e9c6b12 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 Nov 2013 23:11:40 +0100 Subject: 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. --- audio/filter/af_extrastereo.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'audio/filter/af_extrastereo.c') diff --git a/audio/filter/af_extrastereo.c b/audio/filter/af_extrastereo.c index 4cf27f2724..5b3792763b 100644 --- a/audio/filter/af_extrastereo.c +++ b/audio/filter/af_extrastereo.c @@ -49,6 +49,7 @@ static int control(struct af_instance* af, int cmd, void* arg) if(!arg) return AF_ERROR; mp_audio_copy_config(af->data, (struct mp_audio*)arg); + mp_audio_force_interleaved_format(af->data); mp_audio_set_num_channels(af->data, 2); if (af->data->format == AF_FORMAT_FLOAT_NE) { @@ -83,8 +84,8 @@ static struct mp_audio* play_s16(struct af_instance* af, struct mp_audio* data) { af_extrastereo_t *s = af->setup; register int i = 0; - int16_t *a = (int16_t*)data->audio; // Audio data - int len = data->len/2; // Number of samples + int16_t *a = (int16_t*)data->planes[0]; // Audio data + int len = data->samples*data->nch; // Number of samples int avg, l, r; for (i = 0; i < len; i+=2) @@ -105,8 +106,8 @@ static struct mp_audio* play_float(struct af_instance* af, struct mp_audio* data { af_extrastereo_t *s = af->setup; register int i = 0; - float *a = (float*)data->audio; // Audio data - int len = data->len/4; // Number of samples + float *a = (float*)data->planes[0]; // Audio data + int len = data->samples * data->nch; // Number of samples float avg, l, r; for (i = 0; i < len; i+=2) -- cgit v1.2.3