Commit 14b905b6 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Merge branch 'ericsson/contribution-38-control-metadata-directivity' into...

Merge branch 'ericsson/contribution-38-control-metadata-directivity' into 'philips/contribution-38-control-metadata-reverb'

Added directivity in binary format under CONTROL_METADATA_DIRECTIVITY and scripts/reverb/*.py

See merge request !833
parents 098ffda1 2eecc2be
Loading
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -583,6 +583,13 @@ int main(
            fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", ACOUSTIC_ENVIRONMENT_ID );
            goto cleanup;
        }
#ifdef CONTROL_METADATA_DIRECTIVITY
        if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, ACOUSTIC_ENVIRONMENT_ID, renderConfig.directivity ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Invalid directivity configuration parameters\n\n" );
            goto cleanup;
        }
#endif
#endif
        renderConfig.room_acoustics.override = true;

+1 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@
#define CONTROL_METADATA_REVERB                         /* Philips: reverb configuration change to binary format */
#ifdef CONTROL_METADATA_REVERB
#define CONTROL_METADATA_EARLY_REFLECTIONS              /* Philips/Qualcomm: early reflections extension to reverb configuration */
#define CONTROL_METADATA_DIRECTIVITY                    /* Ericsson: Directivity renderer configuration */ 
#endif
#define FIX_563_PARAMMC_LIMITER                         /* FhG: issue 563: fix ILD limiter when coming from silence w/o transient set             */
#define FIX_560_VAD_FLAG                                /* Eri: Issue 560 - VAD flag issue for unified stereo */
+118 −0
Original line number Diff line number Diff line
@@ -120,6 +120,9 @@ struct RenderConfigReader
    FrequencyGrid *pFG;  /* Frequency grids */
    uint32_t nAE;        /* Number of acoustic environments */
    AcousticEnv *pAE;    /* Acoustic environments */
#ifdef CONTROL_METADATA_DIRECTIVITY
    float directivity[3]; /* Source directivity */
#endif
#endif
};

@@ -916,6 +919,59 @@ static ivas_error get_absorption(
    return IVAS_ERR_OK;
}

#ifdef CONTROL_METADATA_DIRECTIVITY
/*-----------------------------------------------------------------------------------------*
 * Function get_angle()
 * Gets an angle value in degrees [0,360]
 *-----------------------------------------------------------------------------------------*/

static ivas_error get_angle(
    RenderConfigReader *this, /* i/o  : Render config reader handle */
    float *pResult            /* o    : Angle value              */
)
{
    ivas_error error;
    uint32_t value;

    if ( ( error = read_bits( this, &value, 5 ) ) != IVAS_ERR_OK )
    {
        return error;
    }

    *pResult = usdequant( (int16_t) value, 0.0f, 20.0f );

    return IVAS_ERR_OK;
}

/*-----------------------------------------------------------------------------------------*
 * Function get_outer_attenuation ()
 * Gets an outer attenuation value [3.1623e-05,1.0],  or in dB: [-90,0]
 *-----------------------------------------------------------------------------------------*/

static ivas_error get_outer_attenuation(
    RenderConfigReader *this, /* i/o  : Render config reader handle */
    float *pResult            /* o    : Attenuation value           */
)
{
    ivas_error error;
    uint32_t value;
    float logval, att;

    if ( ( error = read_bits( this, &value, 5 ) ) != IVAS_ERR_OK )
    {
        return error;
    }

    logval = usdequant( (int16_t) value, -90.0f, 3.0f );
    att = powf( 10, logval / 20.0f );

    *pResult = att;

    return IVAS_ERR_OK;
}

#endif

#else
/*-----------------------------------------------------------------------------------------*
 * Function read_bool()
@@ -1618,6 +1674,34 @@ static ivas_error RenderConfigReader_readReverb(
                }
            }
        }
#endif
#ifdef CONTROL_METADATA_DIRECTIVITY
        /* Has source directivity */
        if ( ( error = read_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK )
        {
            return error;
        }
        if ( value == true )
        {
            if ( ( error = get_angle( pRenderConfigReader, &pRenderConfigReader->directivity[0] ) ) != IVAS_ERR_OK )
            {
                return error;
            }
            if ( ( error = get_angle( pRenderConfigReader, &pRenderConfigReader->directivity[1] ) ) != IVAS_ERR_OK )
            {
                return error;
            }
            if ( ( error = get_outer_attenuation( pRenderConfigReader, &pRenderConfigReader->directivity[2] ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
        else
        {
            pRenderConfigReader->directivity[0] = 360.0f;
            pRenderConfigReader->directivity[1] = 360.0f;
            pRenderConfigReader->directivity[2] = 1.0f;
        }
#endif
    }

@@ -1937,6 +2021,40 @@ ivas_error RenderConfigReader_getAcousticEnvironment(
    }
    return IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING;
}

#ifdef CONTROL_METADATA_DIRECTIVITY
/*------------------------------------------------------------------------------------------*
 * RenderConfigReader_getDirectivity()
 *
 * Gets Acoustic environment with a given ID
 *------------------------------------------------------------------------------------------*/

ivas_error RenderConfigReader_getDirectivity(
    RenderConfigReader *pRenderConfigReader, /* i  : RenderConfigReader handle              */
    uint16_t id,                             /* i  : Acoustic environment ID                */
    float *directivity                       /* o  : directivity                            */
)
{
    uint16_t n;

    if ( pRenderConfigReader == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    for ( n = 0; n < pRenderConfigReader->nAE; n++ )
    {
        if ( id == pRenderConfigReader->pAE[n].id )
        {
            mvr2r( pRenderConfigReader->directivity, directivity, 3 );
            return IVAS_ERR_OK;
        }
    }
    return IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING;
}
#endif


#endif

/*------------------------------------------------------------------------------------------*
+7 −0
Original line number Diff line number Diff line
@@ -62,6 +62,13 @@ ivas_error RenderConfigReader_getAcousticEnvironment(
ivas_error RenderConfigReader_checkValues(
    IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o  : Renderer configuration handle           */
);
#ifdef CONTROL_METADATA_DIRECTIVITY
ivas_error RenderConfigReader_getDirectivity(
    RenderConfigReader *pRenderConfigReader, /* i  : RenderConfigReader handle              */
    uint16_t id,                             /* i  : Acoustic environment ID                */
    float *directivity                       /* o  : directivity                            */
);
#endif
#endif

/* Reads a configuration                                                                    */
+34 −0
Original line number Diff line number Diff line
[frequencyGrid:0]
method = individualFrequencies
frequencies = [
        20.0, 25.0, 31.5, 40.0,
        50.0, 63.0, 80.0, 100.0,
        125.0, 160.0, 200.0, 250.0,
        315.0, 400.0, 500.0, 630.0,
        800.0, 1000.0, 1250.0, 1600.0,
        2000.0, 2500.0, 3150.0, 4000.0,
        5000.0, 6300.0, 8000.0, 10000.0,
        12500.0, 16000.0, 20000.0]

[acousticEnvironment:0]
id = 0
frequencyGridIndex = 0
predelay = 0.1
rt60 = [
        1.3622, 1.4486, 1.3168, 1.5787,
        1.4766, 1.3954, 1.2889, 1.3462,
        1.0759, 1.0401, 1.0970, 1.0850,
        1.0910, 1.0404, 1.0499, 1.0699,
        1.1028, 1.1714, 1.1027, 1.0666,
        1.0550, 1.0553, 1.0521, 1.0569,
        1.0421, 0.97822, 0.80487, 0.75944,
        0.71945, 0.61682, 0.60031]

dsr = [
        1.9952632e-08, 1.9952632e-08, 1.2589251e-08, 1.5848926e-08, 1.2589251e-08, 1.9952632e-08, 2.511887e-08, 3.9810708e-08, 1e-07, 1.9952633e-07,
        3.981071e-07, 6.3095763e-07, 7.943284e-07, 6.3095763e-07, 5.01187e-07, 5.01187e-07, 6.3095763e-07, 6.3095763e-07, 7.943284e-07, 6.3095763e-07,
        5.01187e-07, 6.3095763e-07, 6.3095763e-07, 6.3095763e-07, 5.01187e-07, 2.511887e-07, 1.2589251e-07, 1e-07, 6.309576e-08, 3.1622776e-08,
        2.511887e-08]

[directivity:0]
directivity = [0.0, 360.0, 0.2512]
Loading