Commit 93a87de3 authored by thomas dettbarn's avatar thomas dettbarn
Browse files

reduced the bitwidth fron 32 to 16 bit for the ambisonic converter.

parent 395ce043
Loading
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -34,9 +34,8 @@
#include <stdio.h>
#include "ambi_convert.h"

#define THISQ Q29

#define ONE_1_Q29 536870912l /* 1.0f */
#define ONE_OVER_2_Q29 268435456 /* 1.0f/2.0f */

#define SQRT_2_Q29 759250112l  /* sqrtf(2.0f) */
#define SQRT_3_Q29 929887680l  /* sqrtf(3.0f) */
@@ -129,16 +128,16 @@ static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0,
--------------------------------------------------------------------------*/

AMBI_CONVERT_ERROR convert_ambi_format(
    Word32 *in[],       /* i: input ambisonics channels  */
    Word32 *out[],      /* o: output ambisonics channels */
    Word16 *in[],       /* i: input ambisonics channels  */
    Word16 *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   */
)
{

    Word32 tmp[AMBI_MAX_CHANNELS * L_FRAME48k];
    Word32 *p_tmp[AMBI_MAX_CHANNELS];
    Word16 tmp[AMBI_MAX_CHANNELS * L_FRAME48k];
    Word16 *p_tmp[AMBI_MAX_CHANNELS];
    AMBI_CONVERT_ERROR err = AMBI_CONVERT_OK;

    AMBI_CHANNEL_ORDER ch_ord_in = AMBI_CHANNEL_ORDER_ACN;
@@ -304,8 +303,8 @@ AMBI_CONVERT_ERROR convert_ambi_format(
--------------------------------------------------------------------------*/

AMBI_CONVERT_ERROR renormalize_channels(
    Word32 *in[],                /* i: input ambisonics channels  */
    Word32 *out[],               /* o: output ambisonics channels */
    Word16 *in[],                /* i: input ambisonics channels  */
    Word16 *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   */
@@ -315,6 +314,7 @@ AMBI_CONVERT_ERROR renormalize_channels(
    int16_t i_chan, i;
    const Word32 *conversion_table = 0;


    /* conversion factors are applied on the channels assuming that they are still/already in ACN order */
    if ( in_format == AMBI_NORM_SN3D )
    {
@@ -366,9 +366,10 @@ AMBI_CONVERT_ERROR renormalize_channels(
        for ( i = 0; i < L_FRAME48k; i++ )
        {
            Word64 tmp;
            tmp = W_mult0_32_32( in[i_chan][i], conversion_factor );
            tmp = W_mult0_32_32( (Word32)in[i_chan][i], conversion_factor );
            /* tmp = W_add( tmp, ONE_OVER_2_Q29); */ /* rounding up */
            tmp = W_shr( tmp, Q29 );
            out[i_chan][i] = W_extract_l( tmp );
            out[i_chan][i] = extract_l( W_extract_l( tmp ) );
        }
    }

@@ -382,8 +383,8 @@ AMBI_CONVERT_ERROR renormalize_channels(
--------------------------------------------------------------------------*/

AMBI_CONVERT_ERROR reorder_channels(
    Word32 *in[],                 /* i: input ambisonics channels  */
    Word32 *out[],                /* o: output ambisonics channels */
    Word16 *in[],                 /* i: input ambisonics channels  */
    Word16 *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   */
@@ -391,7 +392,7 @@ AMBI_CONVERT_ERROR reorder_channels(
{
    int16_t n_chan = i_mult2( add( order, 1 ), add( order, 1 ) );
    int16_t i_chan, i;
    Word32 tmp[AMBI_MAX_CHANNELS];
    Word16 tmp[AMBI_MAX_CHANNELS];
    const int16_t *idx_table = 0;

    if ( in_format == AMBI_CHANNEL_ORDER_ACN )
+6 −6
Original line number Diff line number Diff line
@@ -77,24 +77,24 @@ typedef enum
} AMBI_CONVERT_ERROR;

AMBI_CONVERT_ERROR convert_ambi_format(
    Word32 *in[],       /* i: input ambisonics channels  */
    Word32 *out[],      /* o: output ambisonics channels */
    Word16 *in[],       /* i: input ambisonics channels  */
    Word16 *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   */
);

AMBI_CONVERT_ERROR renormalize_channels(
    Word32 *in[],                /* i: input ambisonics channels  */
    Word32 *out[],               /* o: output ambisonics channels */
    Word16 *in[],                /* i: input ambisonics channels  */
    Word16 *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   */
);

AMBI_CONVERT_ERROR reorder_channels(
    Word32 *in[],                 /* i: input ambisonics channels  */
    Word32 *out[],                /* o: output ambisonics channels */
    Word16 *in[],                 /* i: input ambisonics channels  */
    Word16 *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   */