Commit 602f3192 authored by thomas dettbarn's avatar thomas dettbarn
Browse files

clang patch applied.

parent 1ff4ddda
Loading
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -52,34 +52,34 @@ int main( int argc, char *argv[] )

    uint32_t samplingRate;
    uint32_t samplesInFile;
    uint32_t numSamples = L_FRAME48k;
    uint32_t numSamples = AMBI_MAX_FRAME_LENGTH;
    uint32_t numSamplesRead32 = 0;
    uint32_t numSamplesClipped = 0;

    int16_t bps;
    int16_t samples[L_FRAME48k * AMBI_MAX_CHANNELS];
    int16_t samples[AMBI_MAX_FRAME_LENGTH * AMBI_MAX_CHANNELS];
    int16_t order = 0;
    int16_t numChannels;
    const char *name_conventions[6] = { "ACN-SN3D", "ACN-N3D", "FuMa-MaxN", "FuMa-FuMa", "SID-SN3D", "SID-N3D" };

    AMBI_FMT in_format, out_format;

    float samples_f_in[L_FRAME48k * AMBI_MAX_CHANNELS];
    float samples_f_out[L_FRAME48k * AMBI_MAX_CHANNELS];
    float samples_f_in[AMBI_MAX_FRAME_LENGTH * AMBI_MAX_CHANNELS];
    float samples_f_out[AMBI_MAX_FRAME_LENGTH * AMBI_MAX_CHANNELS];
    float *in[AMBI_MAX_CHANNELS], *out[AMBI_MAX_CHANNELS];

    for ( int16_t j = 0; j < AMBI_MAX_CHANNELS; j++ )
    {
        in[j] = &samples_f_in[j * L_FRAME48k];
        out[j] = &samples_f_out[j * L_FRAME48k];
        in[j] = &samples_f_in[j * AMBI_MAX_FRAME_LENGTH];
        out[j] = &samples_f_out[j * AMBI_MAX_FRAME_LENGTH];
    }

    printf( "Ambisonics converter program\n" );
    if ( argc != 5 )
    {
        printf( "Ambisonics converter program\n" );
        printf( "----------------------------------------------------------------------------------\n" );
        printf( "Usage:\n" );
        printf( "./ambi_conveter input_file output_file input_convention output_convention\n" );
        printf( "./ambi_converter input_file output_file input_convention output_convention\n" );
        printf( "\n" );
        printf( "input_convention and output convention must be an integer number in [0,5]\n" );
        printf( "the following conventions are supported:\n" );
@@ -122,7 +122,7 @@ int main( int argc, char *argv[] )
    order = (int16_t) sqrtf( numChannels ) - 1;
    assert( order > 0 && order <= 3 );

    numSamples = L_FRAME48k * numChannels;
    numSamples = ( samplingRate * 20 * numChannels ) / 1000; /* 20ms worth of samples */
    while ( ReadWavShort( wavFile_in, samples, numSamples, &numSamplesRead32 ) == __TWI_SUCCESS )
    {
        int32_t err = 0;
@@ -140,7 +140,7 @@ int main( int argc, char *argv[] )
            }
        }

        if ( ( err = convert_ambi_format( in, out, order, in_format, out_format ) ) != 0 )
        if ( ( err = convert_ambi_format( in, out, order, in_format, out_format, ( const uint16_t )( numSamples / numChannels ) ) ) != 0 )
        {
            printf( "Error converting the input signal!\n" );
            return err;
+36 −28
Original line number Diff line number Diff line
@@ -126,13 +126,14 @@ static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0,
AMBI_CONVERT_ERROR convert_ambi_format(
    float *in[],               /* i: input ambisonics channels  */
    float *out[],              /* o: output ambisonics channels */
    int16_t order,      /* i: ambisonics order           */
    AMBI_FMT in_format, /* i: input ambisonics format    */
    AMBI_FMT out_format /* i: output ambisonics format   */
    const int16_t order,       /* i: ambisonics order           */
    const AMBI_FMT in_format,  /* i: input ambisonics format    */
    const AMBI_FMT out_format, /* i: output ambisonics format   */
    const int16_t frame_length /* i: input/output frame length  */
)
{

    float tmp[AMBI_MAX_CHANNELS * L_FRAME48k];
    float tmp[AMBI_MAX_CHANNELS * AMBI_MAX_FRAME_LENGTH];
    float *p_tmp[AMBI_MAX_CHANNELS];
    AMBI_CONVERT_ERROR err = AMBI_CONVERT_OK;

@@ -144,6 +145,11 @@ AMBI_CONVERT_ERROR convert_ambi_format(

    assert( order <= 3 );

    if ( frame_length > AMBI_MAX_FRAME_LENGTH )
    {
        return AMBI_CONVERT_UNSUPPORTED_FRAME_LENGTH;
    }

    if ( in_format != AMBI_FMT_ACN_SN3D && out_format != AMBI_FMT_ACN_SN3D )
    {
        assert( 0 && "Conversion only supported to and from ACN-SN3D" );
@@ -151,7 +157,7 @@ AMBI_CONVERT_ERROR convert_ambi_format(

    for ( int16_t j = 0; j < AMBI_MAX_CHANNELS; j++ )
    {
        p_tmp[j] = &tmp[j * L_FRAME48k];
        p_tmp[j] = &tmp[j * frame_length];
    }

    switch ( in_format )
@@ -218,18 +224,18 @@ AMBI_CONVERT_ERROR convert_ambi_format(
    {
        if ( ch_ord_in != ch_ord_out )
        {
            if ( ( err = renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK )
            if ( ( err = renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out, frame_length ) ) != AMBI_CONVERT_OK )
            {
                return err;
            }
            if ( ( err = reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK )
            if ( ( err = reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out, frame_length ) ) != AMBI_CONVERT_OK )
            {
                return err;
            }
        }
        else
        {
            if ( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK )
            if ( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out, frame_length ) ) != AMBI_CONVERT_OK )
            {
                return err;
            }
@@ -237,7 +243,7 @@ AMBI_CONVERT_ERROR convert_ambi_format(
    }
    else if ( in_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out )
    {
        if ( ( err = reorder_channels( in, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK )
        if ( ( err = reorder_channels( in, out, order, ch_ord_in, ch_ord_out, frame_length ) ) != AMBI_CONVERT_OK )
        {
            return err;
        }
@@ -246,18 +252,18 @@ AMBI_CONVERT_ERROR convert_ambi_format(
    {
        if ( ch_ord_in != ch_ord_out )
        {
            if ( ( err = reorder_channels( in, p_tmp, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK )
            if ( ( err = reorder_channels( in, p_tmp, order, ch_ord_in, ch_ord_out, frame_length ) ) != AMBI_CONVERT_OK )
            {
                return err;
            }
            if ( ( err = renormalize_channels( p_tmp, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK )
            if ( ( err = renormalize_channels( p_tmp, out, order, ch_norm_in, ch_norm_out, frame_length ) ) != AMBI_CONVERT_OK )
            {
                return err;
            }
        }
        else
        {
            if ( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK )
            if ( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out, frame_length ) ) != AMBI_CONVERT_OK )
            {
                return err;
            }
@@ -265,7 +271,7 @@ AMBI_CONVERT_ERROR convert_ambi_format(
    }
    else if ( out_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out )
    {
        if ( ( err = reorder_channels( in, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK )
        if ( ( err = reorder_channels( in, out, order, ch_ord_in, ch_ord_out, frame_length ) ) != AMBI_CONVERT_OK )
        {
            return err;
        }
@@ -278,7 +284,7 @@ AMBI_CONVERT_ERROR convert_ambi_format(
        for ( i_chan = 0; i_chan < n_chan; i_chan++ )
        {
            int16_t i = 0;
            for ( i = 0; i < L_FRAME48k; i++ )
            for ( i = 0; i < frame_length; i++ )
            {
                out[i_chan][i] = in[i_chan][i];
            }
@@ -301,9 +307,10 @@ AMBI_CONVERT_ERROR convert_ambi_format(
AMBI_CONVERT_ERROR renormalize_channels(
    float *in[],                        /* i: input ambisonics channels  */
    float *out[],                       /* o: output ambisonics channels */
    int16_t order,               /* i: ambisonics order           */
    AMBI_CHANNEL_NORM in_format, /* i: input ambisonics format    */
    AMBI_CHANNEL_NORM out_format /* i: output ambisonics format   */
    const int16_t order,                /* i: ambisonics order           */
    const AMBI_CHANNEL_NORM in_format,  /* i: input ambisonics format    */
    const AMBI_CHANNEL_NORM out_format, /* i: output ambisonics format   */
    const int16_t frame_length          /* i: input/output frame length  */
)
{
    int16_t n_chan = ( order + 1 ) * ( order + 1 );
@@ -358,7 +365,7 @@ AMBI_CONVERT_ERROR renormalize_channels(
    for ( i_chan = 0; i_chan < n_chan; i_chan++ )
    {
        float conversion_factor = conversion_table[i_chan];
        for ( i = 0; i < L_FRAME48k; i++ )
        for ( i = 0; i < frame_length; i++ )
        {
            out[i_chan][i] = in[i_chan][i] * conversion_factor;
        }
@@ -376,9 +383,10 @@ AMBI_CONVERT_ERROR renormalize_channels(
AMBI_CONVERT_ERROR reorder_channels(
    float *in[],                         /* i: input ambisonics channels  */
    float *out[],                        /* o: output ambisonics channels */
    int16_t order,                /* i: ambisonics order           */
    AMBI_CHANNEL_ORDER in_format, /* i: input ambisonics format    */
    AMBI_CHANNEL_ORDER out_format /* i: output ambisonics format   */
    const int16_t order,                 /* i: ambisonics order           */
    const AMBI_CHANNEL_ORDER in_format,  /* i: input ambisonics format    */
    const AMBI_CHANNEL_ORDER out_format, /* i: output ambisonics format   */
    const int16_t frame_length           /* i: input/output frame length  */
)
{
    int16_t n_chan = ( order + 1 ) * ( order + 1 );
@@ -421,7 +429,7 @@ AMBI_CONVERT_ERROR reorder_channels(
        return AMBI_CONVERT_UNSUPPORTED_CONVERSION;
    }

    for ( i = 0; i < L_FRAME48k; i++ )
    for ( i = 0; i < frame_length; i++ )
    {
        for ( i_chan = 0; i_chan < n_chan; i_chan++ )
        {
+22 −18
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@

#include <stdint.h>

#define L_FRAME48k        960
#define AMBI_MAX_FRAME_LENGTH 960 /* 20ms at 48 kHz Sampling rate */
#define AMBI_MAX_CHANNELS     16

typedef enum
@@ -66,30 +66,34 @@ typedef enum
typedef enum
{
    AMBI_CONVERT_OK = 0,
    AMBI_CONVERT_UNSUPPORTED_CONVERSION
    AMBI_CONVERT_UNSUPPORTED_CONVERSION,
    AMBI_CONVERT_UNSUPPORTED_FRAME_LENGTH
} AMBI_CONVERT_ERROR;

AMBI_CONVERT_ERROR convert_ambi_format(
    float *in[],               /* i: input ambisonics channels  */
    float *out[],              /* o: output ambisonics channels */
    int16_t order,      /* i: ambisonics order           */
    AMBI_FMT in_format, /* i: input ambisonics format    */
    AMBI_FMT out_format /* i: output ambisonics format   */
    const int16_t order,       /* i: ambisonics order           */
    const AMBI_FMT in_format,  /* i: input ambisonics format    */
    const AMBI_FMT out_format, /* i: output ambisonics format   */
    const int16_t frame_length /* i: input/output frame length  */
);

AMBI_CONVERT_ERROR renormalize_channels(
    float *in[],                        /* i: input ambisonics channels  */
    float *out[],                       /* o: output ambisonics channels */
    int16_t order,               /* i: ambisonics order           */
    AMBI_CHANNEL_NORM in_format, /* i: input ambisonics format    */
    AMBI_CHANNEL_NORM out_format /* i: output ambisonics format   */
    const int16_t order,                /* i: ambisonics order           */
    const AMBI_CHANNEL_NORM in_format,  /* i: input ambisonics format    */
    const AMBI_CHANNEL_NORM out_format, /* i: output ambisonics format   */
    const int16_t frame_length          /* i: input/output frame length  */
);

AMBI_CONVERT_ERROR reorder_channels(
    float *in[],                         /* i: input ambisonics channels  */
    float *out[],                        /* o: output ambisonics channels */
    int16_t order,                /* i: ambisonics order           */
    AMBI_CHANNEL_ORDER in_format, /* i: input ambisonics format    */
    AMBI_CHANNEL_ORDER out_format /* i: output ambisonics format   */
    const int16_t order,                 /* i: ambisonics order           */
    const AMBI_CHANNEL_ORDER in_format,  /* i: input ambisonics format    */
    const AMBI_CHANNEL_ORDER out_format, /* i: output ambisonics format   */
    const int16_t frame_length           /* i: input/output frame length  */
);
#endif