Justin Ruggles <[email protected]> writes:

> On 05/24/2011 08:14 AM, Anton Khirnov wrote:
>
>> From: Nicolas George <[email protected]>
>> 
>> Currently, only S16 quad, 5.1 and 7.1 are implemented.
>> Implementing support for other formats/layouts and capture should be
>> straightforward.
>> 
>> 7.1 support by Carl Eugen Hoyos.
>> 
>> Signed-off-by: Anton Khirnov <[email protected]>
>> ---
>>  libavdevice/alsa-audio-common.c |   90 
>> +++++++++++++++++++++++++++++++++++++++
>>  libavdevice/alsa-audio-enc.c    |   10 ++++-
>>  libavdevice/alsa-audio.h        |    7 +++
>>  3 files changed, 106 insertions(+), 1 deletions(-)
>> 
>> diff --git a/libavdevice/alsa-audio-common.c 
>> b/libavdevice/alsa-audio-common.c
>> index ff6c9f8..e7fee7b 100644
>> --- a/libavdevice/alsa-audio-common.c
>> +++ b/libavdevice/alsa-audio-common.c
>> @@ -43,6 +43,59 @@ static av_cold snd_pcm_format_t 
>> codec_id_to_pcm_format(int codec_id)
>>      }
>>  }
>>  
>> +static void alsa_reorder_s16_out_51(const void *in_v, void *out_v, int n)
>> +{
>> +    const int16_t *in = in_v;
>> +    int16_t *out = out_v;
>> +
>> +    while (n-- > 0) {
>> +        out[0] = in[0];
>> +        out[1] = in[1];
>> +        out[2] = in[4];
>> +        out[3] = in[5];
>> +        out[4] = in[2];
>> +        out[5] = in[3];
>> +        in  += 6;
>> +        out += 6;
>> +    }
>> +}
>> +
>> +static void alsa_reorder_s16_out_71(const void *in_v, void *out_v, int n)
>> +{
>> +    const int16_t *in = in_v;
>> +    int16_t *out = out_v;
>> +
>> +    while (n-- > 0) {
>> +        out[0] = in[0];
>> +        out[1] = in[1];
>> +        out[2] = in[4];
>> +        out[3] = in[5];
>> +        out[4] = in[2];
>> +        out[5] = in[3];
>> +        out[6] = in[6];
>> +        out[7] = in[7];
>> +        in  += 8;
>> +        out += 8;
>> +    }
>> +}
>
> I'm sure these could be more optimized, but I guess it doesn't matter
> that much with ALSA output.  First thing that comes to mind is memcpy()
> then loop doing FFSWAP() of 2/3 and 4/5 as int32_t.  These are also
> great candidates for SIMD.  But then again... maybe not that important
> in this case.

These things do not belong here at all.  Ideally it should be done by
pointer swizzling during interleaving after decoding.  Failing that, it
should be an independent step just like format conversion.

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to