Commit 68675d4d authored by vaclav's avatar vaclav
Browse files

formal improvements

parent 08379324
Loading
Loading
Loading
Loading
+33 −9
Original line number Diff line number Diff line
@@ -619,6 +619,8 @@ static void setupWithSingleFormatInput(
        }
    }
#endif

    return;
}


@@ -628,6 +630,7 @@ static float dBToLin(
    return powf( 10.0f, gain_dB / 20.0f );
}


#ifdef SPLIT_REND_WITH_HEAD_ROT
static int16_t rend_openCldfb(
    HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS],
@@ -661,12 +664,17 @@ static int16_t rend_openCldfb(
    {
        cldfbSyn[n] = NULL;
    }

    return 0;
}

static void rend_closeCldfb( HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS], HANDLE_CLDFB_FILTER_BANK cldfbSyn[MAX_INPUT_CHANNELS] )

static void rend_closeCldfb(
    HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS],
    HANDLE_CLDFB_FILTER_BANK cldfbSyn[MAX_INPUT_CHANNELS] )
{
    int16_t n;

    for ( n = 0; n < MAX_INPUT_CHANNELS; n++ )
    {
        if ( cldfbAna[n] != NULL )
@@ -684,9 +692,13 @@ static void rend_closeCldfb( HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNEL
    return;
}

static int16_t get_cldfb_in_flag( IVAS_REND_AudioConfig audioConfig, IVAS_RENDER_CONFIG_DATA *renderConfig )

static int16_t get_cldfb_in_flag(
    IVAS_REND_AudioConfig audioConfig,
    IVAS_RENDER_CONFIG_DATA *renderConfig )
{
    int16_t cldfb_in;

    cldfb_in = 0;
    if ( renderConfig->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV )
    {
@@ -702,12 +714,14 @@ static int16_t get_cldfb_in_flag( IVAS_REND_AudioConfig audioConfig, IVAS_RENDER
    return cldfb_in;
}

static int16_t is_split_post_rend_mode( CmdlnArgs *args )

static int16_t is_split_post_rend_mode(
    CmdlnArgs *args )
{
    int16_t flag;

    flag = 0;
    if ( ( args->inConfig.numBinBuses > 0 ) &&
         ( ( args->inConfig.binBuses[0].audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || ( args->inConfig.binBuses[0].audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
    if ( args->inConfig.numBinBuses > 0 && ( ( args->inConfig.binBuses[0].audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || ( args->inConfig.binBuses[0].audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
    {
        flag = 1;
    }
@@ -715,12 +729,13 @@ static int16_t is_split_post_rend_mode( CmdlnArgs *args )
    return flag;
}

static int16_t is_split_pre_rend_mode( CmdlnArgs *args )
static int16_t is_split_pre_rend_mode(
    CmdlnArgs *args )
{
    int16_t flag;

    flag = 0;
    if ( ( args->outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
         ( args->outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    if ( args->outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args->outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        flag = 1;
    }
@@ -729,6 +744,7 @@ static int16_t is_split_pre_rend_mode( CmdlnArgs *args )
}
#endif


/*------------------------------------------------------------------------------------------*
 * main()
 *
@@ -1089,6 +1105,7 @@ int main(
#endif
            exit( -1 );
        }

#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( !is_split_post_rend_mode( &args ) )
        {
@@ -1357,9 +1374,11 @@ int main(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    }
#endif

    inBufferSize = frameSize_smpls * totalNumInChannels;
    outBufferSize = frameSize_smpls * numOutChannels;
    inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) );

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( cldfb_in == 0 )
    {
@@ -1464,6 +1483,7 @@ int main(
                }
            }
        }

        if ( audioReader != NULL )
        {
#endif
@@ -1538,6 +1558,7 @@ int main(
                    exit( -1 );
                }
            }

            if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer, Pos
#ifdef SPLIT_REND_WITH_HEAD_ROT
                                                      ,
@@ -1573,6 +1594,7 @@ int main(
            IVAS_REND_SetSplitRendBFI( hIvasRend, bfi );
        }
#endif

        /* Read from external orientation file if specified */
        if ( externalOrientationFileReader != NULL )
        {
@@ -1810,11 +1832,11 @@ int main(
            }
#ifdef SPLIT_REND_WITH_HEAD_ROT
        }

        bitsBuffer.config.bitsRead = 0;
        bitsBuffer.config.bitsWritten = 0;
#endif


        /* Write MASA metadata for MASA outputs */
        if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_MASA2 )
        {
@@ -2416,6 +2438,7 @@ static bool checkRequiredArgs(
        fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort );
        missingRequiredArg = true;
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    const bool singleInputSpecified = args.inConfig.numAudioObjects != 0 ||
                                      args.inConfig.numAmbisonicsBuses != 0 ||
@@ -2428,6 +2451,7 @@ static bool checkRequiredArgs(
                                      args.inConfig.numMultiChannelBuses != 0 ||
                                      args.inConfig.numMasaBuses != 0;
#endif

    if ( !args.sceneDescriptionInput && !singleInputSpecified )
    {
        /* Neither scene description input nor single-type input was specified on command line */
+1 −1
Original line number Diff line number Diff line
@@ -629,7 +629,7 @@ enum
#define CLDFB_NO_COL_MAX_SWITCH_BFI         10                     /* CLDFB resampling - max number of CLDFB col. for switching, BFI */
#define CLDFB_OVRLP_MIN_SLOTS               3                      /* CLDFB resampling - minimize processing to minimum required for transition frame ACELP->TCX/HQ */
#define INV_CLDFB_BANDWIDTH                 ( 1.f / 800.f )
#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef SPLIT_REND_WITH_HEAD_ROT // VE!!!!!
#define CLDFB_PLC_XF                        2                      /* Length of cross-fade into first good frame after frame loss in CLDFB cols. */
#endif

+48 −42
Original line number Diff line number Diff line
@@ -1568,7 +1568,42 @@ typedef enum

#define BINAURAL_NTAPS_MAX                      96

#define HRTF_SH_ORDER                           3
#ifdef UPDATE_FASTCONV_SBA_FILTER
#define HRTF_SH_CHANNELS                        HOA3_CHANNELS
#else
#define HRTF_SH_CHANNELS                        16
#endif
#define HRTF_LS_CHANNELS                        15
#define HRTF_NUM_BINS                           60
#define REVERB_PREDELAY_MAX                     20                          /* Max input delay for reverb module */
#define GAIN_LFE                                1.88364911f                 /* Gain applied to LFE during renderering */
#define LOW_BIT_RATE_BINAURAL_EQ_BINS           17                          /* Number of bins in an EQ applied at low bit rates in binauralization */
#define LOW_BIT_RATE_BINAURAL_EQ_OFFSET         14                          /* Offset of bins where the low-bit-rate EQ starts*/

#define BINAURAL_COHERENCE_DIFFERENCE_BINS      9                           /* Number of bins for direction-dependent diffuse-field binaural coherence */

typedef enum 
{
    BINAURAL_INPUT_AUDIO_CONFIG_INVALID,
    BINAURAL_INPUT_AUDIO_CONFIG_COMBINED,       /* 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA3,           /*  HOA3 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA2,           /* HOA2 */
    BINAURAL_INPUT_AUDIO_CONFIG_FOA,            /* FOA */
    BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED       /* Not used */

} BINAURAL_INPUT_AUDIO_CONFIG;

#define HEADROT_ORDER                           3
#define HEADROT_SHMAT_DIM                       ( ( HEADROT_ORDER + 1 ) * ( HEADROT_ORDER + 1 ) )
#define HEADROT_SHMAT_DIM2                      ( HEADROT_SHMAT_DIM * HEADROT_SHMAT_DIM )


#ifdef SPLIT_REND_WITH_HEAD_ROT
/*----------------------------------------------------------------------------------*
 * Split Binaural Rendering Constants
 *----------------------------------------------------------------------------------*/

#define SPLIT_REND_DECOR_ALPHA                  0.25f

#define SPLIT_REND_MAX_YAW_ONLY_POSES           2
@@ -1586,20 +1621,20 @@ typedef enum
#define COMPLEX_MD_BAND_THRESH_LOW              5

#ifndef SPLIT_REND_PRED_QUANT_63_PNTS
#define IVAS_SPLIT_REND_NUM_QUANT_STRATS (3)
#define IVAS_SPLIT_REND_NUM_QUANT_STRATS        3
#else
#define IVAS_SPLIT_REND_NUM_QUANT_STRATS (4)
#define IVAS_SPLIT_REND_NUM_QUANT_STRATS        4
#endif
#ifdef SPLIT_REND_PRED_QUANT_63_PNTS
#define IVAS_SPLIT_REND_PRED_63QUANT_PNTS ( 63 )
#define IVAS_SPLIT_REND_PRED_31QUANT_PNTS ( 31 )
#define IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS ( 31 )
#define IVAS_SPLIT_REND_PRED_63QUANT_PNTS       63
#define IVAS_SPLIT_REND_PRED_31QUANT_PNTS       31
#define IVAS_SPLIT_REND_ROLL_PRED_QUANT_PNTS    31
#else
#define IVAS_SPLIT_REND_PRED_QUANT_PNTS ( 31 )
#define IVAS_SPLIT_REND_PRED_QUANT_PNTS         31
#endif
#define IVAS_SPLIT_REND_D_QUANT_PNTS    ( 15 )
#define IVAS_SPLIT_REND_PRED_MIN_VAL    ( -1.4f )
#define IVAS_SPLIT_REND_PRED_MAX_VAL    ( 1.4f )
#define IVAS_SPLIT_REND_D_QUANT_PNTS            15
#define IVAS_SPLIT_REND_PRED_MIN_VAL            -1.4f
#define IVAS_SPLIT_REND_PRED_MAX_VAL            1.4f

#define IVAS_SPLIT_REND_PITCH_G_MIN_VAL         0.5f
#define IVAS_SPLIT_REND_PITCH_G_MAX_VAL         1.5f
@@ -1629,37 +1664,8 @@ typedef enum
#define IVAS_SPLIT_REND_DOF_BITS                2
#define IVAS_SPLIT_REND_HQ_MODE_BITS            1
#define IVAS_SPLIT_REND_ROT_AXIS_BITS           3
#endif /* SPLIT_REND_WITH_HEAD_ROT */

#define HRTF_SH_ORDER                           3
#ifdef UPDATE_FASTCONV_SBA_FILTER
#define HRTF_SH_CHANNELS                        HOA3_CHANNELS
#else
#define HRTF_SH_CHANNELS                        16
#endif
#define HRTF_LS_CHANNELS                        15
#define HRTF_NUM_BINS                           60
#define REVERB_PREDELAY_MAX                     20                          /* Max input delay for reverb module */
#define GAIN_LFE                                1.88364911f                 /* Gain applied to LFE during renderering */
#define LOW_BIT_RATE_BINAURAL_EQ_BINS           17                          /* Number of bins in an EQ applied at low bit rates in binauralization */
#define LOW_BIT_RATE_BINAURAL_EQ_OFFSET         14                          /* Offset of bins where the low-bit-rate EQ starts*/

#define BINAURAL_COHERENCE_DIFFERENCE_BINS      9                           /* Number of bins for direction-dependent diffuse-field binaural coherence */

typedef enum 
{
    BINAURAL_INPUT_AUDIO_CONFIG_INVALID,
    BINAURAL_INPUT_AUDIO_CONFIG_COMBINED,       /* 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA3,           /*  HOA3 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA2,           /* HOA2 */
    BINAURAL_INPUT_AUDIO_CONFIG_FOA,            /* FOA */
    BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED       /* Not used */

} BINAURAL_INPUT_AUDIO_CONFIG;

#define HEADROT_ORDER                           3
#define HEADROT_SHMAT_DIM                       ( ( HEADROT_ORDER + 1 ) * ( HEADROT_ORDER + 1 ) )
#define HEADROT_SHMAT_DIM2                      ( HEADROT_SHMAT_DIM * HEADROT_SHMAT_DIM )

/*----------------------------------------------------------------------------------*
 * TD Binaural Object renderer
+12 −41
Original line number Diff line number Diff line
@@ -1472,30 +1472,6 @@ static void ivas_binRenderer_convModuleClose(
}


#ifdef SPLIT_REND_WITH_HEAD_ROT
/*-------------------------------------------------------------------------
 * ivas_rend_openCldfbRend()
 *
 * Close CLDFB based fastconv binaural renderer memories
 *------------------------------------------------------------------------*/

void ivas_rend_closeCldfbRend( CLDFB_REND_WRAPPER *pCldfbRend )
{
    if ( pCldfbRend->hCldfbRend->hInputSetup != NULL )
    {
        free( pCldfbRend->hCldfbRend->hInputSetup );
        pCldfbRend->hCldfbRend->hInputSetup = NULL;
    }

    ivas_binRenderer_close( &pCldfbRend->hCldfbRend );

    ivas_HRTF_fastconv_binary_close( &pCldfbRend->hHrtfFastConv );

    return;
}
#endif


/*-------------------------------------------------------------------------
 * ivas_binRenderer_close()
 *
@@ -1715,7 +1691,7 @@ void ivas_binaural_cldfb(
                    cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] );
                    idx_in++;
                }
#ifdef SPLIT_REND_WITH_HEAD_ROT

                if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL )
                {
                    for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ )
@@ -1725,7 +1701,6 @@ void ivas_binaural_cldfb(
                    }
                    st_ivas->hSplitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config;
                }
#endif
            }
#endif
        }
@@ -1744,8 +1719,7 @@ void ivas_binaural_cldfb(
                          Cldfb_RealBuffer, Cldfb_ImagBuffer );

#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
             ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
        if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            int16_t pos_idx;
            for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ )
@@ -1756,6 +1730,7 @@ void ivas_binaural_cldfb(
                    v_multc( Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], GAIN_LFE, Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx], maxBand );
                }
            }

            for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ )
            {
                for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ )
@@ -1768,11 +1743,13 @@ void ivas_binaural_cldfb(
                                   Cldfb_RealBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx],
                                   Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx],
                                   maxBand );

                            v_add( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx],
                                   Cldfb_ImagBuffer[st_ivas->hIntSetup.nchan_out_woLFE][slot_idx],
                                   Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx],
                                   maxBand );
                        }

                        mvr2r( Cldfb_RealBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand );
                        mvr2r( Cldfb_ImagBuffer_Binaural[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[( pos_idx * BINAURAL_CHANNELS ) + ch][( subframeIdx * JBM_CLDFB_SLOTS_IN_SUBFRAME ) + slot_idx], maxBand );
                    }
@@ -1880,13 +1857,11 @@ void ivas_binaural_cldfb_sf(
                }
                else
                {
                    cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[ch][maxBand * index_slot] ),
                                      Cldfb_RealBuffer[idx_in][slot_idx],
                                      Cldfb_ImagBuffer[idx_in][slot_idx],
                                      maxBand, st_ivas->cldfbAnaDec[idx_in] );
                    cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] );
                    idx_in++;
                }
            }

#ifdef SPLIT_REND_WITH_HEAD_ROT
            /*LFE handling for split rendering cases*/
            if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
@@ -1895,10 +1870,7 @@ void ivas_binaural_cldfb_sf(
                for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ )
                {
                    ch = st_ivas->hIntSetup.index_lfe[idx_lfe];
                    cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ),
                                      Cldfb_RealBuffer[idx_in][slot_idx],
                                      Cldfb_ImagBuffer[idx_in][slot_idx],
                                      maxBand, st_ivas->cldfbAnaDec[idx_in] );
                    cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] );
                    idx_in++;
                }

@@ -1925,8 +1897,7 @@ void ivas_binaural_cldfb_sf(
                          st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer );

#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
             ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
        if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            int16_t pos_idx;
            for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ )
@@ -2033,7 +2004,7 @@ void ivas_binRenderer(
            set_zero( Cldfb_ImagBuffer_Binaural[chIdx][k], CLDFB_NO_CHANNELS_MAX );
        }
    }
#endif /* SPLIT_REND_WITH_HEAD_ROT */
#endif

    /* Head rotation in HOA3 or CICPx */
    if (
@@ -2132,7 +2103,7 @@ void ivas_binRenderer(
            }
        }
    }
#endif /* SPLIT_REND_WITH_HEAD_ROT */
#endif

    /* Obtain the binaural dmx and compute the reverb */
    if ( hBinRenderer->hReverb != NULL )
@@ -2266,4 +2237,4 @@ void ivas_rend_CldfbMultiBinRendProcess(

    return;
}
#endif /* SPLIT_REND_WITH_HEAD_ROT */
#endif
+1 −7
Original line number Diff line number Diff line
@@ -2457,13 +2457,7 @@ void ivas_dirac_dec_render_sf(
#ifdef SPLIT_REND_WITH_HEAD_ROT
                          &st_ivas->hSplitBinRend.splitrend.multiBinPoseData,
#endif
                          st_ivas->hCombinedOrientationData,
                          subframe_idx,
                          hSpatParamRendCom->subframe_nbslots[subframe_idx],
                          Cldfb_RealBuffer_Binaural,
                          Cldfb_ImagBuffer_Binaural,
                          Cldfb_RealBuffer,
                          Cldfb_ImagBuffer );
                          st_ivas->hCombinedOrientationData, subframe_idx, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer );

#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
Loading