Commit b09eaf4c authored by emerit's avatar emerit
Browse files

merge float-pc and main_pc

parent 962221fd
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -103,7 +103,6 @@

#define FIX_956_DECODER_COMMAND_LINE_FIX                /* VA: Output correct error message when the decoder command-line has too many mandatory arguments. */

//#define SPLIT_REND_WITH_HEAD_ROT_NEW                    /* Orange: split rendering code differ between branchs main-pc and float-pc, do not know what to do */
#define NONBE_FIX_BINARY_BINAURAL_READING               /* Orange: Add support for reading binaural binary file */
//#define USE_NEW_HRTF_BINARY_FILE_FORMAT                 /* Orange: to activate when decided to change the hrtf binary file format */
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
+31 −130
Original line number Diff line number Diff line
@@ -1479,6 +1479,9 @@ static ivas_error setRendInputActiveIsm(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    Word16 i;
#endif
    Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
    Word16 num_src;

    inputIsm = (input_ism *) input;
    rendCtx = inputIsm->base.ctx;
    outConfig = *rendCtx.pOutConfig;
@@ -1528,7 +1531,7 @@ static ivas_error setRendInputActiveIsm(
#endif

    test();
#ifdef SPLIT_REND_WITH_HEAD_ROT_NEW
#ifdef SPLIT_REND_WITH_HEAD_ROT
    test();
    test();
    IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
@@ -1536,147 +1539,62 @@ static ivas_error setRendInputActiveIsm(
    IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
#endif
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) )
#else
        IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) )
#endif
#else
#ifndef SPLIT_REND_WITH_HEAD_ROT
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) )
#else
        IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) )
#endif
#endif
        {
            return error;
        }
    }
    ELSE IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) )
    {
        IF( NE_32( ( error = initIsmMasaRendering( inputIsm, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
    }
    ELSE
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT_NEW
#ifndef SPLIT_REND_WITH_HEAD_ROT
        if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK )
#else
        IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
        {
            return error;
        }

        if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
            if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK )
        /* Open TD renderer wrappers */
        FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
        {
                return error;
            }
        }
#else
        if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK )
            IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->splitTdRendWrappers[i], inConfig, hRendCfg, NULL, *inputIsm->base.ctx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
            {
                return error;
            }

        if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
            if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK )
            {
                return error;
            /* Assert same delay as main TD renderer */
            assert( inputIsm->splitTdRendWrappers[i].binaural_latency_ns == inputIsm->tdRendWrapper.binaural_latency_ns );
        }
#endif
    }
        else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
    ELSE IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) )
    {
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
            if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK )
#else
            if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK )
#endif
        IF( NE_32( ( error = initIsmMasaRendering( inputIsm, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
    }
#endif

#else
        Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
        Word16 num_src;
        Word16 ivas_format;
        IF( EQ_32( getAudioConfigType( inConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) )
        {
            ivas_format = MC_FORMAT;
        }
    ELSE
    {
            ivas_format = ISM_FORMAT;
        }

        move16();
        IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
#ifndef SPLIT_REND_WITH_HEAD_ROT
        if ( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ) != IVAS_ERR_OK )
        {
            return error;
        }


        Word16 nchan_rend = num_src;
        move16();

        test();
        IF( EQ_16( ivas_format, MC_FORMAT ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
        {
            nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */
        }
        FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
        {
            TDREND_SRC_t *Src_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]];
            IF( Src_p != NULL )
        if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
                IF( Src_p->SrcSpatial_p != NULL )
            if ( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK )
            {
                    Src_p->SrcSpatial_p->q_Pos_p = Q31;
                    move16();
                }
                TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p;
                SrcSpatial_p->q_Pos_p = Q31;
                move16();
                return error;
            }
        }

#ifdef SPLIT_REND_WITH_HEAD_ROT
        /* Open TD renderer wrappers */
        FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
        {
            if ( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->splitTdRendWrappers[i], inConfig, hRendCfg, NULL, *inputIsm->base.ctx.pOutSampleRate, SrcInd, &num_src ) ) != IVAS_ERR_OK )
#else
        IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
        {
            return error;
        }

            /* Assert same delay as main TD renderer */
            assert( inputIsm->splitTdRendWrappers[i].binaural_latency_ns == inputIsm->tdRendWrapper.binaural_latency_ns );

            FOR( Word16 nS = 0; nS < nchan_rend; nS++ )
            {
                TDREND_SRC_t *Src_p = inputIsm->splitTdRendWrappers[i].hBinRendererTd->Sources[SrcInd[nS]];
                IF( Src_p != NULL )
                {
                    IF( Src_p->SrcSpatial_p != NULL )
                    {
                        Src_p->SrcSpatial_p->q_Pos_p = Q31;
                        move16();
                    }
                    TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->splitTdRendWrappers[i].hBinRendererTd->Sources[nS]->SrcSpatial_p;
                    SrcSpatial_p->q_Pos_p = Q31;
                    move16();
                }
            }
        }

#endif

        IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
        {
            IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) )
@@ -1684,7 +1602,6 @@ static ivas_error setRendInputActiveIsm(
                return error;
            }
        }
#ifdef SPLIT_REND_WITH_HEAD_ROT_NEW
        ELSE IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
        {
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
@@ -1697,8 +1614,6 @@ static ivas_error setRendInputActiveIsm(
            }
        }
#endif

#endif /* SPLIT_REND_WITH_HEAD_ROT_NEW */
    }

    return IVAS_ERR_OK;
@@ -6273,10 +6188,7 @@ static ivas_error renderIsmToBinauralRoom(
    IF( NE_32( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) )
#else
    /* render 7_1_4 with BRIRs */
    IF( NE_32( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR,
                                                 NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate,
                                                 getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ) ) ),
               IVAS_ERR_OK ) )
    IF( NE_32( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) )
#endif
    {
        return error;
@@ -7089,9 +7001,7 @@ static ivas_error renderMcToBinaural(
#ifdef SPLIT_REND_WITH_HEAD_ROT
        IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, p_tmpRendBuffer_fx, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) )
#else
        IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, *mcInput->base.ctx.pOutSampleRate,
                                                     getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ),
                   IVAS_ERR_OK ) )
        IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, p_tmpRendBuffer_fx, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) )
#endif
        {
            return error;
@@ -7234,9 +7144,7 @@ static ivas_error renderMcToBinauralRoom(
#ifdef SPLIT_REND_WITH_HEAD_ROT
        IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) )
#else
        IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate,
                                                     getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ),
                   IVAS_ERR_OK ) )
        IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) )
#endif
        {
            return error;
@@ -7367,9 +7275,7 @@ static ivas_error renderMcCustomLsToBinauralRoom(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) )
#else
    IF( NE_32( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL,
                                                 p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ),
               IVAS_ERR_OK ) )
    IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) )
#endif
    {
        return error;
@@ -8087,9 +7993,7 @@ static ivas_error renderSbaToBinaural(
#ifdef SPLIT_REND_WITH_HEAD_ROT
        IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, output_fx, output_fx, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) )
#else
        IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, output_fx, *sbaInput->base.ctx.pOutSampleRate,
                                                     getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ),
                   IVAS_ERR_OK ) )
        IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, output_fx, output_fx, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) )
#endif
        {
            return error;
@@ -8218,10 +8122,7 @@ static ivas_error renderSbaToBinauralRoom(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) )
#else
    IF( NE_32( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig,
                                                 NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate,
                                                 getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ),
               IVAS_ERR_OK ) )
    IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) )
#endif
    {
        return error;