Commit 8950f44a authored by thomas dettbarn's avatar thomas dettbarn
Browse files

the ambi convert function reports a AMBI_CONVERT_CLIPPING_DETECTED error in...

the ambi convert function reports a AMBI_CONVERT_CLIPPING_DETECTED error in case the output does no longer fit into 16 bit.
parent dee64c13
Loading
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@

#include <assert.h>
#include <stdio.h>
#include "wmc_auto.h"
#include "ambi_convert.h"

#define ONE_1_Q29      536870912l /* 1.0f */
@@ -344,6 +345,11 @@ AMBI_CONVERT_ERROR renormalize_channels(
    int16_t n_chan = i_mult2( add( order, 1 ), add( order, 1 ) );
    int16_t i_chan, i;
    const Word32 *conversion_table = 0;
    Word32 minval = 0;
    Word32 maxval = 0;
    move32();
    move32();
    move32();


    /* conversion factors are applied on the channels assuming that they are still/already in ACN order */
@@ -400,17 +406,23 @@ AMBI_CONVERT_ERROR renormalize_channels(
    FOR( i_chan = 0; i_chan < n_chan; i_chan++ )
    {
        Word32 conversion_factor = conversion_table[i_chan];
        Word32 outval;
        move32();
        FOR( i = 0; i < L_FRAME48k; i++ )
        {
            Word64 tmp;
            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] = extract_l( W_extract_l( tmp ) );
            outval = W_extract_l( W_shr( tmp, Q29 ) );
            minval = L_min( minval, outval );
            maxval = L_min( maxval, outval );
            out[i_chan][i] = extract_l( outval );
        }
    }

    IF( ( minval < MIN16B ) || ( maxval > MAX16B ) )
    {
        return AMBI_CONVERT_CLIPPING_DETECTED;
    }
    return AMBI_CONVERT_OK;
}

+2 −1
Original line number Diff line number Diff line
@@ -73,7 +73,8 @@ typedef enum
typedef enum
{
    AMBI_CONVERT_OK = 0,
    AMBI_CONVERT_UNSUPPORTED_CONVERSION
    AMBI_CONVERT_UNSUPPORTED_CONVERSION,
    AMBI_CONVERT_CLIPPING_DETECTED
} AMBI_CONVERT_ERROR;

AMBI_CONVERT_ERROR convert_ambi_format(

scripts/compile_ambi_converter.sh

deleted100644 → 0
+0 −4
Original line number Diff line number Diff line
#!/bin/sh

rm -r ambi_converter
cc ambi_converter.c -o ambi_converter -I../lib_util/ -I../lib_com/ -I../lib_debug/ -I../lib_enc/ -I../lib_dec/ -I../lib_rend/ -I../lib_isar -I../lib_lc3plus -L../ -livasutil -lm