Commit 9036f393 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

- add FIX_REND_ROUNDING to round like mvr2s() instead of using roundf

- add FIX_REND_MONO_DMX with updated downmix coefficients for mono output
parent 3024581c
Loading
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -2461,6 +2461,9 @@ static void convertOutputBuffer(
    int16_t *intBuffer )
{
    int16_t chnl, smpl, i;
#ifdef FIX_REND_ROUNDING
    float temp;
#endif

    i = 0;

@@ -2468,7 +2471,21 @@ static void convertOutputBuffer(
    {
        for ( chnl = 0; chnl < numChannels; ++chnl )
        {
#ifdef FIX_REND_ROUNDING
            temp = floatBuffer[chnl * numSamplesPerChannel + smpl];
            temp = (float) floor( temp + 0.5f );
            if ( temp > MAX16B_FLT )
            {
                temp = MAX16B_FLT;
            }
            else if ( temp < MIN16B_FLT )
            {
                temp = MIN16B_FLT;
            }
            intBuffer[i] = (int16_t) temp;
#else
            intBuffer[i] = (int16_t) roundf( floatBuffer[chnl * numSamplesPerChannel + smpl] );
#endif

            ++i;
        }
+2 −0
Original line number Diff line number Diff line
@@ -175,6 +175,8 @@
#define FIX_GET_DELAY_RETURN                            /* Issue 223: change return data type in function get_delay() */
#define NTT_REDUC_COMP_POC                              /* NTT Contribution 10: Complexity reduction of phase spectrum in stereo downmix*/
#define FIX_ISM_DECODER_PRINTOUT                        /* Issue 229: fix ISM decoder printout */
#define FIX_REND_ROUNDING                               /* Issue 195: Align float to int16 conversion in renderer with decoder */
#define FIX_REND_MONO_DMX                               /* Issue 195: Fix mono downmix coefficients in decoder and renderer */


/* ################## End DEVELOPMENT switches ######################### */
+15 −0
Original line number Diff line number Diff line
@@ -362,6 +362,20 @@ const uint32_t ls_LFE_last_idx_CICP19[12] = { 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11,
const float ls_conversion_cicpX_mono[12][1] =
{
#ifdef EXT_RENDERER
#ifdef FIX_REND_MONO_DMX
    {1.00000000f},
    {1.00000000f},
    {1.00000000f},
    {1.00000000f},
    {0.79999995f},
    {0.79999995f},
    {0.79999995f},
    {0.79999995f},
    {0.849999964f},
    {0.849999964f},
    {0.849999964f},
    {0.849999964f}
#else /* FIX_REND_MONO_DMX */
    {1.00000000f},
    {1.00000000f},
    {1.00000000f},
@@ -374,6 +388,7 @@ const float ls_conversion_cicpX_mono[12][1] =
    {1.00000000f},
    {1.00000000f},
    {1.00000000f},
#endif /* FIX_REND_MONO_DMX */
#else
    {1.00000000f},
    {1.00000000f},
+44 −7
Original line number Diff line number Diff line
@@ -1203,6 +1203,11 @@ static ivas_error initMcPanGainsWithMonoOut(
{
    int16_t i;
    int16_t numInChannels;
#ifdef FIX_REND_MONO_DMX
    int16_t readIdx;
    int16_t writeIdx;
    bool skipSideSpeakers;
#endif
    ivas_error error;

    if ( ( error = getRendInputNumChannels( inputMc, &numInChannels ) ) != IVAS_ERR_OK )
@@ -1210,12 +1215,44 @@ static ivas_error initMcPanGainsWithMonoOut(
        return error;
    }

#ifdef FIX_REND_MONO_DMX
    if ( inputMc->base.inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM )
    {
        for ( i = 0; i < numInChannels; ++i )
        {
            /* It's OK to also set gain 1 for LFE input channels here.
             * Correct LFE handling will be applied within updateMcPanGains() */
            inputMc->panGains[i][0] = 1.f;
        }
    }
    else
    {
        /* ls_conversion_cicpX_stereo contains gains for side speakers.
         * These should be skipped with 5.1+X inputs. */
        skipSideSpeakers = false;
        if ( inputMc->base.inConfig == IVAS_REND_AUDIO_CONFIG_5_1_2 || inputMc->base.inConfig == IVAS_REND_AUDIO_CONFIG_5_1_4 )
        {
            skipSideSpeakers = true;
        }
        for ( readIdx = 0, writeIdx = 0; writeIdx < numInChannels; ++readIdx, ++writeIdx )
        {
            if ( skipSideSpeakers && readIdx == 4 )
            {
                /* Skip gains for side speakers in lookup table */
                readIdx += 2;
            }

            inputMc->panGains[writeIdx][0] = ls_conversion_cicpX_mono[readIdx][0];
        }
    }
#else
    for ( i = 0; i < numInChannels; ++i )
    {
        /* It's OK to also set gain 1 for LFE input channels here.
         * Correct LFE handling will be applied within updateMcPanGains() */
        inputMc->panGains[i][0] = 1.f;
    }
#endif

    return IVAS_ERR_OK;
}
@@ -1323,13 +1360,13 @@ static ivas_error updateMcPanGainsForMcOut(
    /* "if" conditions below realize the following mapping:

    If in == out, use identity matrix, otherwise follow the table:
    +-----------+----------+---------------+-----------+--------------------+
    +-----------+-------------+---------------+-----------+--------------------+
    |  in\out   |   MONO      |   STEREO      | custom LS |       other        |
    +-----------+----------+---------------+-----------+--------------------+
    +-----------+-------------+---------------+-----------+--------------------+
    | MONO      | mono out    | EFAP          | EFAP      | EFAP               |
    | custom LS | mono out    | EFAP          | EFAP      | EFAP               |
    | other     | mono out | stereo lookup | EFAP      | conversion mapping |
    +-----------+----------+---------------+-----------+--------------------+
    | other     | mono lookup | stereo lookup | EFAP      | conversion mapping |
    +-----------+-------------+---------------+-----------+--------------------+
    */

    if ( configsAreEqual( inputMc->base.inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ) )
+8 −8
Original line number Diff line number Diff line
@@ -37,14 +37,14 @@ IVAS_CICPX_TO_MONO = np.array(
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            0.79999995,
            0.79999995,
            0.79999995,
            0.79999995,
            0.849999964,
            0.849999964,
            0.849999964,
            0.849999964,
        ]
    ]
).T
Loading