Commit 6abbfbf3 authored by Ripinder Singh's avatar Ripinder Singh
Browse files

SR codec framesize support in RTP ToC SR byte



To estmate the correct frame size of a SR frame in RTP payload, it is
important to know the codec's framesize employed in addition to the
bitrate. This can be propagated from SDP, this work extends to resolve
this info from the ToC byte which makes it easier to parse an rtp dump
even if the sdp negotiated codec framesize is not available.

Signed-off-by: default avatarRipinder Singh <ripinder.singh@dolby.com>
parent 1d1a53e4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3442,7 +3442,11 @@ static ivas_error decodeVoIP(
#ifdef IVAS_RTPDUMP
    IVAS_RTP ivasRtp = { 0 };
    IVAS_RTP srRtp = { 0 };
#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE
    IVAS_RTP_SR_INFO srInfo = { true, false, 0, 20, IVAS_SR_TRANSPORT_LCLD };
#else
    IVAS_RTP_SR_INFO srInfo = { true, false, 0, IVAS_SR_TRANSPORT_LCLD };
#endif
    int32_t initialTsOffsetSystemAndRTP = 0;
#else
    FILE *f_rtpstream = NULL;
@@ -4125,6 +4129,7 @@ static ivas_error decodeVoIP(
        {
            srInfo.bitrateKbps = splitRendBits->bits_written * 1000 / splitRendBits->codec_frame_size_ms;
            srInfo.codec = ( splitRendBits->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) ? IVAS_SR_TRANSPORT_LC3PLUS : IVAS_SR_TRANSPORT_LCLD;
            srInfo.codecFrameSizeMs = (uint32_t) splitRendBits->codec_frame_size_ms;
            if ( ( error = IVAS_RTP_WriteNextFrame( &srRtp, splitRendBits->bits_buf, &srInfo, (int16_t) splitRendBits->bits_written, false, false ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError %s while pushing SR audio bitstream to RTP pack\n", ivas_error_to_string( error ) );
+2 −0
Original line number Diff line number Diff line
@@ -167,6 +167,8 @@
#define ISM_PI_DATA                                    /* Add reading and packing/unpacking of ISM PI data */
#define REVERSE_ISM_PI_DATA                            /* Add reading and packing/unpacking of reverse ISM PI data */
#define DECODER_FORMAT_SWITCHING                       /* Re-initialize the decoder when the format/subformat of the incoming stream is changed */
#define RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE            /* CR for split rendering codec framesize signalling in Toc Byte*/


/* ################### Start BE switches ################################# */
/* only BE switches wrt selection floating point code */
+6 −3
Original line number Diff line number Diff line
@@ -275,6 +275,9 @@ typedef struct
    bool valid;           /* Valid Split Rendering Info for/in the ToC */
    bool diegetic;        /* SR content digetic */
    uint32_t bitrateKbps; /* SR bitrate in kbps */
#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE
    uint32_t codecFrameSizeMs; /* SR transport codec framesize in ms (5/10/20) */
#endif
    IVAS_RTP_SR_TRANSPORT codec; /* SR Transport Codec used*/
} IVAS_RTP_SR_INFO;
#endif /* RTP_S4_251135_CR26253_0016_REV1 */
+24 −0
Original line number Diff line number Diff line
@@ -852,7 +852,16 @@ static ivas_error getSRToCByte(
    uint8_t *tocByte                /* o : toc byte 2           */
)
{
#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE
    uint8_t bitIdx, codecId, digetic, codecFrameSize;

    if ( srInfo->codecFrameSizeMs != 5 && srInfo->codecFrameSizeMs != 10 && srInfo->codecFrameSizeMs != 20 )
    {
        return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported codec framesize for SR provided" );
    }
#else
    uint8_t bitIdx, codecId, digetic;
#endif
    if ( srInfo->bitrateKbps < 256000 || srInfo->bitrateKbps > 512000 )
    {
        return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported bitrate for SR" );
@@ -862,7 +871,12 @@ static ivas_error getSRToCByte(
    codecId = (uint8_t) srInfo->codec;
    digetic = srInfo->diegetic ? 1 : 0;

#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE
    codecFrameSize = ( srInfo->codecFrameSizeMs == 20 ) ? 3 : (uint8_t) ( srInfo->codecFrameSizeMs / 5 );
    *tocByte = ( digetic << 6 ) | ( codecId << 5 ) | ( bitIdx << 3 ) | ( codecFrameSize << 1 );
#else
    *tocByte = ( digetic << 6 ) | ( codecId << 5 ) | ( bitIdx << 3 );
#endif

    return IVAS_ERR_OK;
}
@@ -1474,6 +1488,9 @@ static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBy
                if ( nBytes < payload->length )
                {
                    uint8_t SR_BR;
#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE
                    static const uint8_t codecFrameSizeMap[4] = { 0, 5, 10, 20 };
#endif
                    byte = payload->buffer[nBytes++];
                    SR_BR = ( byte >> 3 ) & MASK_2BIT;
                    if ( SR_BR == 0 )
@@ -1484,7 +1501,14 @@ static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBy
                    toc->srInfo.diegetic = ( byte >> 6 ) & MASK_1BIT;
                    toc->srInfo.codec = IVAS_SR_TRANSPORT_LCLD + ( ( byte >> 5 ) & MASK_1BIT );
                    toc->srInfo.bitrateKbps = ( SR_BR + 1 ) * 128000u;
#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE
                    toc->srInfo.codecFrameSizeMs = codecFrameSizeMap[( byte >> 1 ) & MASK_2BIT];
                    /* SDP negotiated codecFrameSizeMs must match ToC codecFrameSizeMs */
                    assert( toc->srInfo.codecFrameSizeMs == srCodecFrameSizeMs );
                    toc->auNumBits = toc->srInfo.bitrateKbps * toc->srInfo.codecFrameSizeMs / 1000;
#else
                    toc->auNumBits = toc->srInfo.bitrateKbps * srCodecFrameSizeMs / 1000;
#endif
                }
                else
                {