Commit d51a3d79 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch 'main' of forge.3gpp.org:ivas-codec-pc/ivas-codec into...

Merge branch 'main' of forge.3gpp.org:ivas-codec-pc/ivas-codec into 193-rendering-fix-align-ism-conversion-between-internal-and-external-renderer
parents a1b633b8 14cc1b86
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -2432,6 +2432,9 @@ static void convertOutputBuffer(
    int16_t *intBuffer )
{
    int16_t chnl, smpl, i;
#ifdef FIX_REND_ROUNDING
    float temp;
#endif

    i = 0;

@@ -2439,7 +2442,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;
        }
+3 −0
Original line number Diff line number Diff line
@@ -150,6 +150,9 @@
#define FIX_ITD                                         /* Contribution 16: TD renderer ITD improvement and code cleanup */
#define BRATE_SWITCHING_RENDERING                       /* Bitrate switching changes related to the renderers */
#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 */
#define FIX_REND_ROT_MC_BIN                             /* Issue 195: Fix wrong EFAP handle passed to renderer, resulting in no rotation for BINAURAL_ROOM output */
#define FIX_ITD_CNG                                     /* Eri Contribution 11: Fix for CNG ITD */
#define FIX_VBR_COMPLEXITY                              /* Issue 234: fix extremely high complexity numbers for IVAS EVS mode */
#define FIX_ISM_INACTIVE_BITS                           /* Issue 230: fix bitbudget distribution in inactive frames in ISM format */
+15 −0
Original line number Diff line number Diff line
@@ -361,10 +361,20 @@ const uint32_t ls_LFE_last_idx_CICP19[12] = { 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11,
 /* Downmix matrices */
const float ls_conversion_cicpX_mono[12][1] =
{
#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
    {1.00000000f},
    {1.00000000f},
    {1.00000000f},
@@ -373,6 +383,11 @@ const float ls_conversion_cicpX_mono[12][1] =
    {1.00000000f},
    {1.00000000f},
    {1.00000000f},
    {1.00000000f},
    {1.00000000f},
    {1.00000000f},
    {1.00000000f},
#endif
};

const float ls_conversion_cicpX_stereo[12][2] =
+58 −7
Original line number Diff line number Diff line
@@ -1198,6 +1198,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 )
@@ -1205,12 +1210,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;
}
@@ -1318,13 +1355,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 ) )
@@ -1514,6 +1551,12 @@ static ivas_error initMcBinauralRendering(
    {
        ivas_rend_closeCrend( &inputMc->crendWrapper );
    }
#ifdef FIX_REND_ROT_MC_BIN
    if ( inputMc->efapInWrapper.hEfap != NULL )
    {
        efap_free_data( &inputMc->efapInWrapper.hEfap );
    }
#endif

    outSampleRate = *inputMc->base.ctx.pOutSampleRate;

@@ -1557,6 +1600,14 @@ static ivas_error initMcBinauralRendering(
        }
    }

#ifdef FIX_REND_ROT_MC_BIN
    /* Initialise the EFAP handle for rotation on input layout */
    if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM && inputMc->base.ctx.pHeadRotData->headRotEnabled )
    {
        initEfap( &inputMc->efapInWrapper, inConfig, NULL );
    }
#endif

    return error;
}

+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