Commit 1ac94db0 authored by Stefan Doehla's avatar Stefan Doehla
Browse files

added C sources as in float but without defines to avoid conflicts this time

parent 1cfdb16e
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@
#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 */
#define FIXED_RTP_SEQUENCE_NUM                         /* Remove random sequence number initialization */
#define PI_LATENCY                                     /* Support for PI latency */

/* #################### End BASOP porting switches ############################ */

+12 −1
Original line number Diff line number Diff line
@@ -341,7 +341,18 @@ void IVAS_RTP_LogPiData(
            case IVAS_PI_ISM_POSITION:
            case IVAS_PI_ISM_DISTANCE_ATTENUATION:
            case IVAS_PI_ISM_DIRECTIVITY:
            {
                fprintf( f_piDataOut, "{}" );
            }
            break;
            case IVAS_PI_PI_LATENCY:
            {
                fprintf( f_piDataOut, "{" );
                fprintf( f_piDataOut, "\n\t\t\t\"reverseType\": \"%s\",", PiDataNames[cur->data.piLatency.type] );
                fprintf( f_piDataOut, "\n\t\t\t\"latency\": %d", cur->data.piLatency.latency );
                fprintf( f_piDataOut, "\n\t\t}" );
            }
            break;
            case IVAS_PI_R_ISM_ID:
            case IVAS_PI_R_ISM_GAIN:
            case IVAS_PI_R_ISM_DIRECTION:
@@ -600,7 +611,7 @@ void IVAS_RTP_WriteExtPiData(
            break;
            case IVAS_PI_PI_LATENCY:
            {
                fprintf( f_piDataOut, "%d", cur->data.piLatency.latency );
                fprintf( f_piDataOut, "%s,%d", PiDataNames[cur->data.piLatency.type], cur->data.piLatency.latency );
            }
            break;
            case IVAS_PI_R_ISM_ID:
+69 −2
Original line number Diff line number Diff line
@@ -630,6 +630,71 @@ static ivas_error unpackAudioFocusCommon( const uint8_t *buffer, uint32_t numDat
    return IVAS_ERR_OK;
}

static ivas_error packPiLatency( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten )
{
    uint32_t typeBits;
    uint32_t latencyBits;
    uint32_t word;
    uint32_t nBytes = 0;
    const IVAS_PIDATA_REVERSE_PI_LATENCY *p = (const IVAS_PIDATA_REVERSE_PI_LATENCY *) piData;

    *nBytesWritten = 0;
    if ( piData->size != sizeof( IVAS_PIDATA_REVERSE_PI_LATENCY ) )
    {
        return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size for PI_LATENCY data" );
    }
    if ( piData->piDataType != IVAS_PI_PI_LATENCY )
    {
        return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID for PI_LATENCY data" );
    }
    if ( maxDataBytes < 2 + 4 )
    {
        return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack PI_LATENCY data" );
    }

    buffer[nBytes++] = ( p->piDataType & MASK_5BIT );
    buffer[nBytes++] = 4;

    typeBits = (uint32_t) ( p->type & MASK_5BIT );
    latencyBits = (uint32_t) ( p->latency & 0x07FFFFFF );
    word = ( typeBits << 27 ) | latencyBits;

    buffer[nBytes++] = (uint8_t) ( word >> 24 );
    buffer[nBytes++] = (uint8_t) ( word >> 16 );
    buffer[nBytes++] = (uint8_t) ( word >> 8 );
    buffer[nBytes++] = (uint8_t) ( word );
    *nBytesWritten = nBytes;

    return IVAS_ERR_OK;
}

static ivas_error unpackPiLatency( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData )
{
    uint32_t word;
    uint32_t lat;
    IVAS_PIDATA_REVERSE_PI_LATENCY *p = (IVAS_PIDATA_REVERSE_PI_LATENCY *) piData;

    if ( numDataBytes != 4 )
    {
        return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack PI_LATENCY data" );
    }

    p->size = sizeof( IVAS_PIDATA_REVERSE_PI_LATENCY );
    p->piDataType = IVAS_PI_PI_LATENCY;

    word = ( (uint32_t) buffer[0] << 24 ) | ( (uint32_t) buffer[1] << 16 ) |
           ( (uint32_t) buffer[2] << 8 ) | (uint32_t) buffer[3];
    p->type = (IVAS_PI_TYPE) ( ( word >> 27 ) & MASK_5BIT );
    lat = word & 0x07FFFFFF;

    /* Sign-extend 27-bit value */
    if ( lat & ( 1u << 26 ) )
        p->latency = (int32_t) ( lat | ~0x07FFFFFF );
    else
        p->latency = (int32_t) lat;

    return IVAS_ERR_OK;
}

#endif /* RTP_S4_251135_CR26253_0016_REV1 */

@@ -668,14 +733,15 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = {
    packListenerPosition,   /* LISTENER_POSITION                */
    packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION        */
    packAudioFocusCommon,   /* AUDIO_FOCUS_REQUEST              */
    packPiLatency,          /* PI_LATENCY                       */
#else
    packUnsupportedData,   /* PLAYBACK_DEVICE_ORIENTATION      */
    packUnsupportedData,   /* HEAD_ORIENTATION                 */
    packUnsupportedData,   /* LISTENER_POSITION                */
    packUnsupportedData,   /* DYNAMIC_AUDIO_SUPPRESSION        */
    packUnsupportedData,   /* AUDIO_FOCUS_DIRECTION            */
#endif
    packUnsupportedData,   /* PI_LATENCY                       */
#endif
    packUnsupportedData, /* R_ISM_ID                         */
    packUnsupportedData, /* R_ISM_GAIN                       */
#ifdef RTP_S4_251135_CR26253_0016_REV1
@@ -727,14 +793,15 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = {
    unpackListenerPosition,   /* LISTENER_POSITION                */
    unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION        */
    unpackAudioFocusCommon,   /* AUDIO_FOCUS_REQUEST              */
    unpackPiLatency,          /* PI_LATENCY                       */
#else
    unpackUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION      */
    unpackUnsupportedData, /* HEAD_ORIENTATION                 */
    unpackUnsupportedData, /* LISTENER_POSITION                */
    unpackUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION        */
    unpackUnsupportedData, /* AUDIO_FOCUS_DIRECTION            */
#endif
    unpackUnsupportedData, /* PI_LATENCY                       */
#endif
    unpackUnsupportedData, /* R_ISM_ID                         */
    unpackUnsupportedData, /* R_ISM_GAIN                       */
#ifdef RTP_S4_251135_CR26253_0016_REV1