Commit aa672148 authored by thomas dettbarn's avatar thomas dettbarn
Browse files

in case of clipping, convert_ambi_format() took a shortcut which caused...

in case of clipping, convert_ambi_format() took a shortcut which caused uninitialized output samples.
parent 3930f5a8
Loading
Loading
Loading
Loading
Loading
+22 −18
Original line number Original line Diff line number Diff line
@@ -140,7 +140,8 @@ AMBI_CONVERT_ERROR convert_ambi_format(


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


    AMBI_CHANNEL_ORDER ch_ord_in = AMBI_CHANNEL_ORDER_ACN;
    AMBI_CHANNEL_ORDER ch_ord_in = AMBI_CHANNEL_ORDER_ACN;
    AMBI_CHANNEL_ORDER ch_ord_out = AMBI_CHANNEL_ORDER_ACN;
    AMBI_CHANNEL_ORDER ch_ord_out = AMBI_CHANNEL_ORDER_ACN;
@@ -253,56 +254,59 @@ AMBI_CONVERT_ERROR convert_ambi_format(
    {
    {
        IF( ch_ord_in != ch_ord_out )
        IF( ch_ord_in != ch_ord_out )
        {
        {
            IF( ( err = renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK )
            err_normalize = renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out );
            IF( ( err_normalize != AMBI_CONVERT_OK ) && ( err_normalize != AMBI_CONVERT_CLIPPING_DETECTED ) )
            {
            {
                return err;
                return err_normalize;
            }
            }
            IF( ( err = reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK )
            IF( ( err_reorder = reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK )
            {
            {
                return err;
                return err_reorder;
            }
            }
        }
        }
        ELSE
        ELSE
        {
        {
            IF( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK )
            err_normalize = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out );
            IF( ( err_normalize != AMBI_CONVERT_OK ) && ( err_normalize != AMBI_CONVERT_CLIPPING_DETECTED ) )
            {
            {
                return err;
                return err_normalize;
            }
            }
        }
        }
    }
    }
    ELSE IF( in_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out )
    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 = reorder_channels( in, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK )
        {
        {
            return err;
            return err_reorder;
        }
        }
    }
    }
    ELSE IF( out_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out )
    ELSE IF( out_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out )
    {
    {
        IF( ch_ord_in != ch_ord_out )
        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 = reorder_channels( in, p_tmp, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK )
            {
            {
                return err;
                return err_reorder;
            }
            }
            IF( ( err = renormalize_channels( p_tmp, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK )
            err_normalize = renormalize_channels( p_tmp, out, order, ch_norm_in, ch_norm_out );
            IF( ( err_normalize != AMBI_CONVERT_OK ) && ( err_normalize != AMBI_CONVERT_CLIPPING_DETECTED ) )
            {
            {
                return err;
                return err_normalize;
            }
            }
        }
        }
        ELSE
        ELSE
        {
        {
            IF( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK )
            IF( ( err_normalize = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK )
            {
            {
                return err;
                return err_normalize;
            }
            }
        }
        }
    }
    }
    ELSE IF( out_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out )
    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 = reorder_channels( in, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK )
        {
        {
            return err;
            return err_reorder;
        }
        }
    }
    }
    ELSE IF( out_format == AMBI_FMT_ACN_SN3D && in_format == AMBI_FMT_ACN_SN3D )
    ELSE IF( out_format == AMBI_FMT_ACN_SN3D && in_format == AMBI_FMT_ACN_SN3D )
@@ -326,7 +330,7 @@ AMBI_CONVERT_ERROR convert_ambi_format(
        assert( 0 && "This should never happen!" );
        assert( 0 && "This should never happen!" );
    }
    }


    return AMBI_CONVERT_OK;
    return err_normalize;
}
}


/*-------------------------------------------------------------------------*
/*-------------------------------------------------------------------------*