Commit 3c5bad06 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Continue fixing 0 DOF (WIP)

parent 6ce810a9
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -132,6 +132,9 @@ typedef struct ivas_split_rend_bits_t
    int32_t buf_len; /*size of bits_buf in bytes. This field should be set by allocator of bits_buf*/
    int32_t bits_written;
    int32_t bits_read;
#ifdef API_5MS
    int16_t codec_frame_size_ms; /* TODO complete implementation */
#endif
    IVAS_SPLIT_REND_CODEC codec;
    IVAS_SPLIT_REND_POSE_CORRECTION_MODE pose_correction;
} ivas_split_rend_bits_t, IVAS_SPLIT_REND_BITS, *IVAS_SPLIT_REND_BITS_HANDLE;
@@ -202,6 +205,9 @@ typedef struct _IVAS_SPLIT_REND_CONFIG
                              3 - (3dof correction. By default YAW, PITCH and ROLL correction)
                              */
    int16_t codec_delay_ms;   /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/
#ifdef API_5MS
    int16_t codec_frame_size_ms; /*Codec frame size in milliseconds, only relevant with LC3plus */
#endif
    IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode;
    IVAS_SPLIT_REND_CODEC codec;
    IVAS_SPLIT_REND_RENDERER_SELECTION rendererSelection;
+1 −0
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@
#define FIX_XXX_JBM_USAN                                /* FhG: fix usan in acessing transport channel buffers */
#define FIX_XXX_PARAMISM_JBM_ENER_CORRECTION            /* FhG: fix energy correction in ParamISM rendering */
#define NONBE_FIX_589_JBM_TC_OFFSETS
#define FIX_JBM_MC2SBA                                  /* FhG: fix check for transport vs. internal channel count in JBM prior to ivas_mc2sba() */
#define API_5MS                                         /* FhG: 5ms rendering capability */
#ifdef API_5MS 
#define API_5MS_BASELINE                                /* FhG: baseline with 20ms rendering and split rendering through 20ms branch */
+35 −4
Original line number Diff line number Diff line
@@ -370,7 +370,14 @@ ivas_error ivas_jbm_dec_tc(

            if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == AUDIO_CONFIG_FOA || st_ivas->intern_config == AUDIO_CONFIG_HOA2 || st_ivas->intern_config == AUDIO_CONFIG_HOA3 ) )
            {
                if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) <= ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) )
                if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe )
#ifdef FIX_JBM_MC2SBA
                     >=
#else
                     <=
#endif
                     ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) )

                {
                    ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE );
                }
@@ -936,10 +943,21 @@ ivas_error ivas_jbm_dec_render(
    {
        if ( st_ivas->mc_mode == MC_MODE_MCT )
        {
#ifdef FIX_JBM_MC2SBA
            int16_t crendInPlaceRotation = FALSE;
#endif
            *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
            if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == AUDIO_CONFIG_FOA || st_ivas->intern_config == AUDIO_CONFIG_HOA2 || st_ivas->intern_config == AUDIO_CONFIG_HOA3 ) )
            {
#ifdef FIX_JBM_MC2SBA
                if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) )
                {
                    crendInPlaceRotation = TRUE;
#endif
                    ivas_mc2sba( st_ivas->hTransSetup, p_tc, p_output, *nSamplesRendered, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE );
#ifdef FIX_JBM_MC2SBA
                }
#endif
            }

            /* Rendering */
@@ -947,7 +965,14 @@ ivas_error ivas_jbm_dec_render(
            {
                if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig,
                                                               st_ivas->hCombinedOrientationData,
                                                               &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK )
                                                               &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer,
#ifdef FIX_JBM_MC2SBA
                                                               crendInPlaceRotation ? p_output : p_tc,
#else
                                                               p_tc,
#endif
                                                               p_output,
                                                               *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
@@ -1580,7 +1605,13 @@ int16_t ivas_jbm_dec_get_num_tc_channels(
            /* do all static dmx already in the TC decoder if less channels than transported... */
            if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == AUDIO_CONFIG_FOA || st_ivas->intern_config == AUDIO_CONFIG_HOA2 || st_ivas->intern_config == AUDIO_CONFIG_HOA3 ) )
            {
                if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) > ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) )
                if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe )
#ifdef FIX_JBM_MC2SBA
                     >=
#else
                     >
#endif
                     ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) )
                {
                    num_tc = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
                }
+18 −8
Original line number Diff line number Diff line
@@ -1128,6 +1128,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    int32_t output_Fs;
    float output[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k];
    int16_t output_int[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; /* TODO(sgi): Need conversion */
    int16_t numSamplesPerChannelCacheSize;
    int16_t numSamplesPerChannelToDecode;
    int16_t numSamplesPerChannelToSplitEncode;
    int16_t i, j;
@@ -1153,11 +1154,12 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
         hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 )
    {
        numSamplesPerChannelToSplitEncode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES );
        numSamplesPerChannelCacheSize = numSamplesPerChannelToDecode - numSamplesPerChannelToSplitEncode;

        if ( hSplitBinRend->tdDataOut == NULL )
        {
            /* Allocate enough space to save all decoded samples that will not be split encoded directly after decoding  */
            hSplitBinRend->tdDataOut = malloc( ( numSamplesPerChannelToDecode - numSamplesPerChannelToSplitEncode ) * BINAURAL_CHANNELS * numPoses * sizeof( float ) );
            hSplitBinRend->tdDataOut = malloc( numSamplesPerChannelCacheSize * BINAURAL_CHANNELS * numPoses * sizeof( float ) );
            if ( hSplitBinRend->tdDataOut == NULL )
            {
                return IVAS_ERR_FAILED_ALLOC;
@@ -1167,6 +1169,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
    else
    {
        numSamplesPerChannelToSplitEncode = (int16_t) ( output_Fs / FRAMES_PER_SEC );
        numSamplesPerChannelCacheSize = 0;
    }

    if ( output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
@@ -1189,7 +1192,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        }
        assert( numSamplesPerChannelToDecode == *nOutSamples );
#ifdef DEBUGGING
        dbgwrite( output_int, sizeof( int16_t ), 960 * 2, 1, "res/output_int.raw" );
        dbgwrite( output_int, sizeof( int16_t ), numSamplesPerChannelToDecode * 2, 1, "res/output_int.pcm" );
#endif

        /* copy to cache if cache is in use */
@@ -1203,7 +1206,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(

            while ( readPtr != readEnd )
            {
                *writePtr++ = *readPtr++; /* TODO: test */
                *writePtr++ = *readPtr++;
            }
            hSplitBinRend->numTdSamplesPerChannelCached = *nOutSamples - numSamplesPerChannelToSplitEncode;
        }
@@ -1215,19 +1218,19 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(

        int16_t *writePtr;
        float *readPtr, *readEnd;
        readPtr = hSplitBinRend->tdDataOut + ( numSamplesPerChannelToDecode - hSplitBinRend->numTdSamplesPerChannelCached ) * BINAURAL_CHANNELS * numPoses;
        readPtr = hSplitBinRend->tdDataOut + ( numSamplesPerChannelCacheSize - hSplitBinRend->numTdSamplesPerChannelCached ) * BINAURAL_CHANNELS * numPoses;
        readEnd = readPtr + numSamplesPerChannelToSplitEncode * BINAURAL_CHANNELS * numPoses;
        writePtr = output_int;

        while ( readPtr != readEnd )
        {
            *writePtr++ = *readPtr++; /* TODO: test */
            *writePtr++ = *readPtr++;
        }
        hSplitBinRend->numTdSamplesPerChannelCached -= numSamplesPerChannelToSplitEncode;
    }

    /* [tmp] convert int back to float and change buffer layout */
    for ( i = 0; i < *nOutSamples; ++i )
    for ( i = 0; i < numSamplesPerChannelToSplitEncode; ++i )
    {
#ifdef DEBUGGING
        for ( j = 0; j < BINAURAL_CHANNELS * numPoses; ++j )
@@ -1241,7 +1244,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
        }
    }
#ifdef DEBUGGING
    dbgwrite( output[0], sizeof( float ), 960, 1, "res/output.raw" );
    dbgwrite( output[0], sizeof( float ), 240, 1, "res/output.pcm" );
#endif
    max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 );
    pcm_out = ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
@@ -1251,6 +1254,9 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
                                                st_ivas->hHeadTrackData->Quaternion,
                                                st_ivas->hRenderConfig->split_rend_config.splitRendBitRate,
                                                st_ivas->hRenderConfig->split_rend_config.codec,
#ifdef API_5MS
                                                st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms,
#endif
                                                hSplitBinRend->hSplitRendBits,
                                                hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural,
                                                hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural,
@@ -2063,6 +2069,9 @@ static ivas_error copyRendererConfigStruct( RENDER_CONFIG_HANDLE hRCin, IVAS_REN
    hRCout->split_rend_config.dof = 3;
    hRCout->split_rend_config.hq_mode = 0;
    hRCout->split_rend_config.codec_delay_ms = 0;
#ifdef API_5MS
    hRCout->split_rend_config.codec_frame_size_ms = 5;
#endif
    hRCout->split_rend_config.codec = IVAS_SPLIT_REND_CODEC_DEFAULT;
    hRCout->split_rend_config.poseCorrectionMode = IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB;
    hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection;
@@ -2140,7 +2149,8 @@ ivas_error IVAS_DEC_GetDefaultRenderConfig(
    IVAS_RENDER_CONFIG_HANDLE hRCout /* o  : Render config handle                                                    */
)
{
    RENDER_CONFIG_HANDLE hRCin;
    RENDER_CONFIG_DATA RCin;
    RENDER_CONFIG_HANDLE hRCin = &RCin;
    ivas_error error;

    if ( ( error = ivas_render_config_init_from_rom( &hRCin ) ) != IVAS_ERR_OK )
+4 −0
Original line number Diff line number Diff line
@@ -1624,7 +1624,11 @@ ivas_error ivas_rend_crendProcessSubframe(
{
    int16_t subframe_idx, subframe_len;
    int16_t nchan_out, nchan_in, ch, first_sf, last_sf, slot_size, slots_to_render;
#ifdef FIX_JBM_MC2SBA
    float *tc_local[MAX_OUTPUT_CHANNELS];
#else
    float *tc_local[MAX_TRANSPORT_CHANNELS];
#endif
    float pcm_tmp[BINAURAL_CHANNELS][L_FRAME48k];
    float *p_pcm_tmp[BINAURAL_CHANNELS];
    AUDIO_CONFIG in_config;
Loading