Commit b2f48acd authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'renderer_compute_mixing_matrices_updates' into 'main'

Renderer bug fixes, precision improvements in compute mixing matrices

See merge request !540
parents b80a2de2 0e52b6ae
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2688,8 +2688,8 @@ static void IsmPositionProvider_getNextFrame(
        /* Clamp pitch to lie within [-90, 90] range (can't be wrapped easily) */
        objectMetadataBuffer->positions[objIdx].pitch = min( max( objectMetadataBuffer->positions[objIdx].pitch, -90 ), 90 );
#ifdef IVAS_FLOAT_FIXED
        objectMetadataBuffer->positions[objIdx].yaw_fx = (Word32) objectMetadataBuffer->positions[objIdx].yaw * ( 1 << Q22 );
        objectMetadataBuffer->positions[objIdx].pitch_fx = (Word32) objectMetadataBuffer->positions[objIdx].pitch * ( 1 << Q22 );
        objectMetadataBuffer->positions[objIdx].yaw_fx = (Word32) ( ( objectMetadataBuffer->positions[objIdx].yaw ) * ( 1 << Q22 ) );
        objectMetadataBuffer->positions[objIdx].pitch_fx = (Word32) ( ( objectMetadataBuffer->positions[objIdx].pitch ) * ( 1 << Q22 ) );
#endif
    }

+12 −0
Original line number Diff line number Diff line
@@ -1234,6 +1234,18 @@ Word16 matrix_diag_product_fx(
    Word32 *Z,             /* o  : resulting matrix after the matrix multiplication                                       */
    Word16 *Z_e );

Word16 matrix_diag_product_fx_1(
    const Word32 *X, /* i  : left hand matrix                                                                       */
    const Word16 *X_e,
    const Word16 rowsX,   /* i  : number of rows of the left hand matrix                                                 */
    const Word16 colsX,   /* i  : number of columns of the left hand matrix                                              */
    const Word16 transpX, /* i  : flag indicating the transposition of the left hand matrix prior to the multiplication  */
    const Word32 *Y,      /* i  : right hand diagonal matrix as vector containing the diagonal elements                  */
    const Word16 *Y_e,
    const Word16 entriesY, /* i  : number of entries in the diagonal                                                      */
    Word32 *Z,             /* o  : resulting matrix after the matrix multiplication                                       */
    Word16 *Z_e );

Word16 diag_matrix_product_fx(
    const Word32 *Y, /* i  : left hand diagonal matrix as vector containing the diagonal elements                   */
    Word16 Y_e,
+64 −0
Original line number Diff line number Diff line
@@ -2156,6 +2156,70 @@ Word16 matrix_diag_product_fx(

    return EXIT_SUCCESS;
}

Word16 matrix_diag_product_fx_1(
    const Word32 *X, /* i  : left hand matrix                                                                       */
    const Word16 *X_e,
    const Word16 rowsX,   /* i  : number of rows of the left hand matrix                                                 */
    const Word16 colsX,   /* i  : number of columns of the left hand matrix                                              */
    const Word16 transpX, /* i  : flag indicating the transposition of the left hand matrix prior to the multiplication  */
    const Word32 *Y,      /* i  : right hand diagonal matrix as vector containing the diagonal elements                  */
    const Word16 *Y_e,
    const Word16 entriesY, /* i  : number of entries in the diagonal                                                      */
    Word32 *Z,             /* o  : resulting matrix after the matrix multiplication                                       */
    Word16 *Z_e )
{
    Word16 i, j;
    Word32 *Zp = Z;
    Word16 *Z_ep = Z_e;
    Word16 tmp;

    /* Processing */
    IF( EQ_16( transpX, 1 ) ) /* We use X transpose */
    {
        IF( NE_16( rowsX, entriesY ) )
        {
            return EXIT_FAILURE;
        }
        FOR( j = 0; j < entriesY; ++j )
        {
            FOR( i = 0; i < colsX; ++i )
            {
                tmp = add( j, imult1616( i, rowsX ) );
                *( Zp ) = Mpy_32_32( X[tmp], Y[j] );
                move32();
                Zp++;
                *( Z_ep ) = add( X_e[tmp], Y_e[j] );
                move16();
                Z_ep++;
            }
        }
    }
    ELSE /* Regular case */
    {
        IF( NE_16( colsX, entriesY ) )
        {
            return EXIT_FAILURE;
        }

        FOR( j = 0; j < entriesY; ++j )
        {
            FOR( i = 0; i < rowsX; ++i )
            {
                *( Zp ) = Mpy_32_32( *( X ), Y[j] );
                move32();
                Zp++;
                *( Z_ep ) = add( *( X_e ), Y_e[j] );
                move16();
                Z_ep++;
                X++;
                X_e++;
            }
        }
    }

    return EXIT_SUCCESS;
}
#endif

#ifdef IVAS_FLOAT_FIXED
+175 −249

File changed.

Preview size limit exceeded, changes collapsed.

+26 −49
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ static void HouseholderReduction_fx(
    Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS],
    Word32 secDiag_fx[MAX_OUTPUT_CHANNELS],
    Word16 singularVectors_Left_e,
    Word16 *singularValues_fx_e,
    Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS],
    Word16 *secDiag_fx_e,
    const int16_t nChannelsL,
    const int16_t nChannelsC,
@@ -109,7 +109,7 @@ static void biDiagonalReductionLeft_fx(
    Word32 singularValues[MAX_OUTPUT_CHANNELS],
    Word32 secDiag[MAX_OUTPUT_CHANNELS],
    Word16 *singularVectors_e,
    Word16 *singularValues_e,
    Word16 singularValues_e[MAX_OUTPUT_CHANNELS],
    Word16 *secDiag_e,
    const Word16 nChannelsL,
    const Word16 nChannelsC,
@@ -134,7 +134,7 @@ static void singularVectorsAccumulationLeft_fx(
    Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], // Q31 output
    Word32 singularValues[MAX_OUTPUT_CHANNELS],
    Word16 singularVectors_e,
    Word16 singularValues_e,
    Word16 singularValues_e[MAX_OUTPUT_CHANNELS],
    const Word16 nChannelsL,
    const Word16 nChannelsC );

@@ -165,7 +165,7 @@ static Word16 BidagonalDiagonalisation_fx(
    Word32 singularValues_fx[MAX_OUTPUT_CHANNELS],          /* i/o: singular values vector (S)                       */
    Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) Q31                   */
    Word32 secDiag_fx[MAX_OUTPUT_CHANNELS],                 /* i/o:                                                  */
    Word16 *singularValues_fx_e,                            /* i/o: singular values vector (S)                       */
    Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS],        /* i/o: singular values vector (S)                       */
    Word16 *secDiag_fx_e,                                   /* i/o:                                                  */
    const Word16 nChannelsL,                                /* i  : number of rows in the matrix to be decomposed    */
    const Word16 nChannelsC,                                /* i  : number of columns in the matrix to be decomposed */
@@ -396,7 +396,7 @@ Word16 svd_fx(
    Word32 singularVectors_Left_fx[][MAX_OUTPUT_CHANNELS],  /* o  : left singular vectors (U) (Q31)                  */
    Word32 singularValues_fx[MAX_OUTPUT_CHANNELS],          /* o  : singular values vector (S)                       */
    Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* o  : right singular vectors (V) (Q31)                 */
    Word16 *singularValues_fx_e,
    Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS],
    const Word16 nChannelsL, /* i  : number of rows in the matrix to be decomposed    */
    const Word16 nChannelsC  /* i  : number of columns in the matrix to be decomposed */
)
@@ -412,6 +412,7 @@ Word16 svd_fx(
    move16();
    Word16 eps_x_fx_e = 0;
    move16();
    Word16 temp_fx_e;
    push_wmops( "svd_fx" );

    set32_fx( secDiag_fx, 0, MAX_OUTPUT_CHANNELS );
@@ -426,8 +427,7 @@ Word16 svd_fx(
        }
    }

    *singularValues_fx_e = 0;
    move16();
    set16_fx( singularValues_fx_e, 0, MAX_OUTPUT_CHANNELS );

    /* Householder reduction */
    HouseholderReduction_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Right_fx, secDiag_fx, InputMatrix_e, singularValues_fx_e, &secDiag_fx_e, nChannelsL, nChannelsC, &eps_x_fx, &eps_x_fx_e );
@@ -449,7 +449,7 @@ Word16 svd_fx(
        move16();
        FOR( iCh = 0; iCh < sub( lengthSingularValues, 1 ); iCh++ )
        {
            IF( LT_32( singularValues_fx[iCh], singularValues_fx[iCh + 1] ) )
            IF( BASOP_Util_Cmp_Mant32Exp( singularValues_fx[iCh], singularValues_fx_e[iCh], singularValues_fx[iCh + 1], singularValues_fx_e[iCh + 1] ) < 0 )
            {
                condition = 1;
                move16();
@@ -459,6 +459,12 @@ Word16 svd_fx(
                move32();
                singularValues_fx[iCh + 1] = temp_fx;
                move32();
                temp_fx_e = singularValues_fx_e[iCh];
                move16();
                singularValues_fx_e[iCh] = singularValues_fx_e[iCh + 1];
                move16();
                singularValues_fx_e[iCh + 1] = temp_fx_e;
                move16();

                FOR( jCh = 0; jCh < nChannelsL; ++jCh )
                {
@@ -583,7 +589,7 @@ static Word16 BidagonalDiagonalisation_fx(
    Word32 singularValues_fx[MAX_OUTPUT_CHANNELS],          /* i/o: singular values vector (S)                       */
    Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) Q31                   */
    Word32 secDiag_fx[MAX_OUTPUT_CHANNELS],                 /* i/o:                                                  */
    Word16 *singularValues_fx_e,                            /* i/o: singular values vector (S)                       */
    Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS],        /* i/o: singular values vector (S)                       */
    Word16 *secDiag_fx_e,                                   /* i/o:                                                  */
    const Word16 nChannelsL,                                /* i  : number of rows in the matrix to be decomposed    */
    const Word16 nChannelsC,                                /* i  : number of columns in the matrix to be decomposed */
@@ -606,7 +612,7 @@ static Word16 BidagonalDiagonalisation_fx(
    Word16 error = 0;
    move16();
    Word16 singularValues_new_e[MAX_OUTPUT_CHANNELS], secDiag_new_e[MAX_OUTPUT_CHANNELS];
    set16_fx( singularValues_new_e, *singularValues_fx_e, MAX_OUTPUT_CHANNELS );
    Copy( singularValues_fx_e, singularValues_new_e, MAX_OUTPUT_CHANNELS );
    set16_fx( secDiag_new_e, *secDiag_fx_e, MAX_OUTPUT_CHANNELS );

    FOR( iCh = nChannelsC - 1; iCh >= 0; iCh-- ) /* nChannelsC */
@@ -745,24 +751,9 @@ static Word16 BidagonalDiagonalisation_fx(
    }

    // rescaling block
    Word16 max_exp = -31;
    move16();
    FOR( iCh = 0; iCh < nChannelsC; iCh++ )
    {
        if ( singularValues_fx[iCh] )
        {
            max_exp = s_max( max_exp, singularValues_new_e[iCh] );
        }
    }
    *singularValues_fx_e = max_exp;
    move16();
    FOR( iCh = 0; iCh < nChannelsC; iCh++ )
    {
        singularValues_fx[iCh] = L_shr_r( singularValues_fx[iCh], sub( *singularValues_fx_e, singularValues_new_e[iCh] ) );
        move32();
    }
    Copy( singularValues_new_e, singularValues_fx_e, MAX_OUTPUT_CHANNELS );

    max_exp = -31;
    Word16 max_exp = -31;
    move16();
    FOR( iCh = 0; iCh < nChannelsC; iCh++ )
    {
@@ -1245,7 +1236,7 @@ static void HouseholderReduction_fx(
    Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS],
    Word32 secDiag_fx[MAX_OUTPUT_CHANNELS],
    Word16 singularVectors_Left_e,
    Word16 *singularValues_fx_e,
    Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS],
    Word16 *secDiag_fx_e,
    const Word16 nChannelsL,
    const Word16 nChannelsC,
@@ -1267,7 +1258,7 @@ static void HouseholderReduction_fx(
        biDiagonalReductionRight_fx( singularVectors_Left_fx, secDiag_fx, &singularVectors_Left_e, secDiag_fx_e, nChannelsL, nChannelsC, nCh, &sig_x_fx, &sig_x_fx_e, &g_fx );

        Word16 L_temp_e;
        Word32 L_temp = BASOP_Util_Add_Mant32Exp( L_abs( singularValues_fx[nCh] ), *singularValues_fx_e, L_abs( secDiag_fx[nCh] ), *secDiag_fx_e, &L_temp_e );
        Word32 L_temp = BASOP_Util_Add_Mant32Exp( L_abs( singularValues_fx[nCh] ), singularValues_fx_e[nCh], L_abs( secDiag_fx[nCh] ), *secDiag_fx_e, &L_temp_e );
        IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_temp, L_temp_e, *eps_x_fx, *eps_x_fx_e ), 1 ) )
        {
            *eps_x_fx = L_temp;
@@ -1280,7 +1271,7 @@ static void HouseholderReduction_fx(
    /* SingularVecotr Accumulation */
    singularVectorsAccumulationRight_fx( singularVectors_Left_fx, singularVectors_Right_fx, secDiag_fx, singularVectors_Left_e, *secDiag_fx_e, nChannelsC );

    singularVectorsAccumulationLeft_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Left_e, *singularValues_fx_e, nChannelsL, nChannelsC );
    singularVectorsAccumulationLeft_fx( singularVectors_Left_fx, singularValues_fx, singularVectors_Left_e, singularValues_fx_e, nChannelsL, nChannelsC );

    return;
}
@@ -1325,7 +1316,7 @@ static void biDiagonalReductionLeft_fx(
    Word32 singularValues[MAX_OUTPUT_CHANNELS],
    Word32 secDiag[MAX_OUTPUT_CHANNELS],
    Word16 *singularVectors_e,
    Word16 *singularValues_e,
    Word16 singularValues_e[MAX_OUTPUT_CHANNELS],
    Word16 *secDiag_e,
    const Word16 nChannelsL,
    const Word16 nChannelsC,
@@ -1483,23 +1474,9 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */
    // rescaling block
    singularValues[currChannel] = Mpy_32_32( ( *sig_x ), ( *g ) );
    move32();
    IF( GT_16( *sig_x_e, *singularValues_e ) )
    {
        FOR( Word16 i = 0; i < MAX_OUTPUT_CHANNELS; i++ ){
            IF( NE_16( i, currChannel ) ){
                singularValues[i] = L_shl( singularValues[i], sub( *singularValues_e, *sig_x_e ) );
        move32();
    }
}
*singularValues_e = *sig_x_e;
    singularValues_e[currChannel] = *sig_x_e;
    move16();
}
ELSE IF( LT_16( *sig_x_e, *singularValues_e ) )
{
    singularValues[currChannel] = L_shr_r( singularValues[currChannel], sub( *singularValues_e, *sig_x_e ) );
    move32();
}
}

return;
}
@@ -1818,7 +1795,7 @@ static void singularVectorsAccumulationLeft_fx(
    Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], // Q31 output
    Word32 singularValues[MAX_OUTPUT_CHANNELS],
    Word16 singularVectors_e,
    Word16 singularValues_e,
    Word16 singularValues_e[MAX_OUTPUT_CHANNELS],
    const Word16 nChannelsL,
    const Word16 nChannelsC )
{
@@ -1839,7 +1816,7 @@ static void singularVectorsAccumulationLeft_fx(
    {
        t_ii = singularValues[nCh];
        move32();
        t_ii_e = singularValues_e;
        t_ii_e = singularValues_e[nCh];
        move16();

        FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */
Loading