Commit e8f7aeb9 authored by Ripinder Singh's avatar Ripinder Singh
Browse files

Merge branch '1154-add-rtpdump-support-PI-extension' into '1154-add-rtpdump-support'

Implement audio focus PI data and apply diegetic type PI data in rendering

See merge request !2263
parents 75b97ed5 a9cc66bc
Loading
Loading
Loading
Loading
Loading
+51 −4
Original line number Diff line number Diff line
@@ -216,8 +216,8 @@ static const char *PiDataNames[IVAS_PI_MAX_ID] = {
    "SCENE_ORIENTATION", "DEVICE_ORIENTATION_COMPENSATED", "DEVICE_ORIENTATION_UNCOMPENSATED",
    "ACOUSTIC_ENVIRONMENT", "AUDIO_DESCRIPTION", "ISM_NUM", "ISM_ID", "ISM_GAIN", "ISM_ORIENTATION",
    "ISM_POSITION", "ISM_DISTANCE_ATTENUATION", "ISM_DIRECTIVITY", "DIEGETIC_TYPE", "RESERVED13",
    "RESERVED14", "RESERVED15", "PLAYBACK_DEVICE_ORIENTATION", "HEAD_ORIENTATION", "LISTENER_POSITION",
    "DYNAMIC_AUDIO_SUPPRESSION", "AUDIO_FOCUS_DIRECTION", "PI_LATENCY", "R_ISM_ID", "R_ISM_GAIN",
    "AUDIO_FOCUS_INDICATION", "RESERVED15", "PLAYBACK_DEVICE_ORIENTATION", "HEAD_ORIENTATION", "LISTENER_POSITION",
    "DYNAMIC_AUDIO_SUPPRESSION", "AUDIO_FOCUS_REQUEST", "PI_LATENCY", "R_ISM_ID", "R_ISM_GAIN",
    "R_ISM_ORIENTATION", "R_ISM_POSITION", "R_ISM_DIRECTION", "RESERVED27", "RESERVED28", "RESERVED29",
    "RESERVED30", "NO_DATA"
};
@@ -261,7 +261,6 @@ static void IVAS_RTP_LogPiData( FILE *f_piDataOut, PIDATA_TS *piData, uint32_t n
#ifdef RTP_S4_251135_CR26253_0016_REV1
            case IVAS_PI_PLAYBACK_DEVICE_ORIENTATION:
            case IVAS_PI_HEAD_ORIENTATION:
            case IVAS_PI_AUDIO_FOCUS_DIRECTION:
            case IVAS_PI_R_ISM_ORIENTATION:
#endif
            {
@@ -327,6 +326,26 @@ static void IVAS_RTP_LogPiData( FILE *f_piDataOut, PIDATA_TS *piData, uint32_t n
                fprintf( f_piDataOut, "\t\t\t]\n\t\t}" );
            }
            break;
            case IVAS_PI_AUDIO_FOCUS_INDICATION:
            {
                fprintf( f_piDataOut, "{" );
                if ( cur->data.focusIndication.availDirection )
                {
                    fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" );
                    fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}",
                             cur->data.focusIndication.direction.w, cur->data.focusIndication.direction.x, cur->data.focusIndication.direction.y, cur->data.focusIndication.direction.z );
                    if ( cur->data.focusIndication.availLevel )
                    {
                        fprintf( f_piDataOut, "," );
                    }
                }
                if ( cur->data.focusIndication.availLevel )
                {
                    fprintf( f_piDataOut, "\n\t\t\t\"level\": %d", cur->data.focusIndication.flvl );
                }
                fprintf( f_piDataOut, "\n\t\t}" );
            }
            break;
            case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION:
            {
                IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppression;
@@ -339,7 +358,26 @@ static void IVAS_RTP_LogPiData( FILE *f_piDataOut, PIDATA_TS *piData, uint32_t n
            }
            break;
            case IVAS_PI_RESERVED13:
            case IVAS_PI_RESERVED14:
            case IVAS_PI_AUDIO_FOCUS_REQUEST:
            {
                fprintf( f_piDataOut, "{" );
                if ( cur->data.focusRequest.availDirection )
                {
                    fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" );
                    fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}",
                             cur->data.focusRequest.direction.w, cur->data.focusRequest.direction.x, cur->data.focusRequest.direction.y, cur->data.focusRequest.direction.z );
                    if ( cur->data.focusRequest.availLevel )
                    {
                        fprintf( f_piDataOut, "," );
                    }
                }
                if ( cur->data.focusRequest.availLevel )
                {
                    fprintf( f_piDataOut, "\n\t\t\t\"level\": %d", cur->data.focusRequest.flvl );
                }
                fprintf( f_piDataOut, "\n\t\t}" );
            }
            break;
            case IVAS_PI_RESERVED15:
            case IVAS_PI_RESERVED27:
            case IVAS_PI_RESERVED28:
@@ -534,6 +572,15 @@ static ivas_error IVAS_RTP_ApplyPiData( IVAS_RTP *rtp, IVAS_DEC_HANDLE hIvasDec,
                }
                break;

#ifdef RTP_S4_251135_CR26253_0016_REV1
                case IVAS_PI_DIEGETIC_TYPE:
                {
                    DEBUG_PRINT( stdout, "PI_DIEGETIC_TYPE : %d, %d, %d, %d, %d\n", piData->data.digeticIndicator.isDiegetic[0], piData->data.digeticIndicator.isDiegetic[1], piData->data.digeticIndicator.isDiegetic[2], piData->data.digeticIndicator.isDiegetic[3], piData->data.digeticIndicator.isDiegetic[4] );
                    IVAS_DEC_setDiegeticInputPI( hIvasDec, piData->data.digeticIndicator.isDiegetic );
                }
                break;

#endif
                default:
                {
                    fprintf( stderr, "Unhandled PI data of type : %s\n", PiDataNames[piDataType] );
+1 −1
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@
/* ################## Start DEVELOPMENT switches ######################### */


//#define RTP_S4_251135_CR26253_0016_REV1                /* RTP Pack/Unpack API corresponding to CR 26253 */
#define RTP_S4_251135_CR26253_0016_REV1                /* RTP Pack/Unpack API corresponding to CR 26253 */
#define IVAS_RTPDUMP                                   /* RTPDUMP writing and reading for IVAS payloads */

/* ################### Start BE switches ################################# */
+25 −0
Original line number Diff line number Diff line
@@ -3827,6 +3827,31 @@ void IVAS_DEC_resetExternalOrientations(
}


#endif
#ifdef RTP_S4_251135_CR26253_0016_REV1
/*---------------------------------------------------------------------*
 * IVAS_DEC_setDiegeticInput( )
 *
 * Set isDiegeticInput flag for combined orientation handle based on PI data.
 *---------------------------------------------------------------------*/

void IVAS_DEC_setDiegeticInputPI(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
    const bool *diegeticPIValues                /* i  : diegetic values for the input stream                                    */
)
{
    if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL )
    {
        int8_t i;
        for ( i = 0; i < (1 + IVAS_MAX_NUM_OBJECTS); i++ )
        {
            hIvasDec->st_ivas->hCombinedOrientationData->isDiegeticInputPI[i] = diegeticPIValues[i];
        }
        hIvasDec->st_ivas->hCombinedOrientationData->isDiegeticInputPISet = true;
    }
}


#endif
/*---------------------------------------------------------------------*
 * IVAS_DEC_VoIP_IsEmpty( )
+7 −0
Original line number Diff line number Diff line
@@ -349,6 +349,13 @@ void IVAS_DEC_resetExternalOrientations(
    IVAS_DEC_HANDLE hIvasDec                    /* i/o: IVAS decoder handle                                                     */
);

#endif
#ifdef RTP_S4_251135_CR26253_0016_REV1
void IVAS_DEC_setDiegeticInputPI(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle                                                     */
    const bool *diegeticPIValues                /* i  : diegetic values for the input stream                                    */
);

#endif
/* Setter functions - apply changes to decoder configuration */

+62 −0
Original line number Diff line number Diff line
@@ -862,6 +862,14 @@ ivas_error ivas_combined_orientation_open(
    ( *hCombinedOrientationData )->subframe_idx = 0;
    ( *hCombinedOrientationData )->subframe_size = (int16_t) ( fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) );
    ( *hCombinedOrientationData )->cur_subframe_samples_rendered = 0;
#ifdef RTP_S4_251135_CR26253_0016_REV1

    for ( i = 0; i < (1 + IVAS_MAX_NUM_OBJECTS); i++ )
    {
        ( *hCombinedOrientationData )->isDiegeticInputPI[i] = true;
    }
    ( *hCombinedOrientationData )->isDiegeticInputPISet = false;
#endif

    return IVAS_ERR_OK;
}
@@ -1022,11 +1030,30 @@ ivas_error combine_external_and_head_orientations(
    }
    else if ( hExtOrientationData == NULL && headRotQuaternions != NULL )
    {
#ifdef RTP_S4_251135_CR26253_0016_REV1
        /* Disable head rotation if diegetic PI data indicating non-diegetic audio is received */
        if ( hCombinedOrientationData->isDiegeticInputPISet && !hCombinedOrientationData->isDiegeticInputPI[0] && !hCombinedOrientationData->isDiegeticInputPI[1] && !hCombinedOrientationData->isDiegeticInputPI[2] && !hCombinedOrientationData->isDiegeticInputPI[3] && !hCombinedOrientationData->isDiegeticInputPI[4] )
        {
            for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ )
            {
                hCombinedOrientationData->Quaternions[i] = identity;
            }
        }
        else
        {
            /* Head rotation only */
            for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ )
            {
                hCombinedOrientationData->Quaternions[i] = headRotQuaternions[i];
            }
        }
#else
        /* Head rotation only */
        for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ )
        {
            hCombinedOrientationData->Quaternions[i] = headRotQuaternions[i];
        }
#endif
    }

    if ( hExtOrientationData != NULL )
@@ -1103,6 +1130,40 @@ ivas_error combine_external_and_head_orientations(
                hCombinedOrientationData->Quaternion_frozen_head = identity;
                hCombinedOrientationData->isHeadRotationFrozen = 0;
            }
#ifdef RTP_S4_251135_CR26253_0016_REV1
            /* Disable head rotation if diegetic PI data indicating non-diegetic audio is received */
            if ( hCombinedOrientationData->isDiegeticInputPISet && !hCombinedOrientationData->isDiegeticInputPI[0] && !hCombinedOrientationData->isDiegeticInputPI[1] && !hCombinedOrientationData->isDiegeticInputPI[2] && !hCombinedOrientationData->isDiegeticInputPI[3] && !hCombinedOrientationData->isDiegeticInputPI[4] )
            {
                continue;
            }
            else
            {
                /* Use the most recent head rotation */
                if ( hExtOrientationData->enableHeadRotation[i] == 1 )
                {
                    if ( hExtOrientationData->enableExternalOrientation[i] > 0 )
                    {
                        QuaternionProduct( hCombinedOrientationData->Quaternions[i], headRotQuaternions[i], &hCombinedOrientationData->Quaternions[i] );
                    }
                    else
                    {
                        hCombinedOrientationData->Quaternions[i] = headRotQuaternions[i];
                    }
                }
                /* Use the freezed head rotation */
                else if ( hExtOrientationData->enableHeadRotation[i] == 2 )
                {
                    if ( hExtOrientationData->enableExternalOrientation[i] > 0 )
                    {
                        QuaternionProduct( hCombinedOrientationData->Quaternions[i], hCombinedOrientationData->Quaternion_frozen_head, &hCombinedOrientationData->Quaternions[i] );
                    }
                    else
                    {
                        hCombinedOrientationData->Quaternions[i] = hCombinedOrientationData->Quaternion_frozen_head;
                    }
                }
            }
#else
            /* Use the most recent head rotation */
            if ( hExtOrientationData->enableHeadRotation[i] == 1 )
            {
@@ -1127,6 +1188,7 @@ ivas_error combine_external_and_head_orientations(
                    hCombinedOrientationData->Quaternions[i] = hCombinedOrientationData->Quaternion_frozen_head;
                }
            }
#endif

            /* Reset the combined orientations to identity */
            if ( hExtOrientationData->enableHeadRotation[i] == 0 && hExtOrientationData->enableExternalOrientation[i] == 0 )
Loading