Commit 03186a11 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

adding PCM output support to ivas SBA decoder in split rend mode

parent 206e675b
Loading
Loading
Loading
Loading
Loading
+63 −8
Original line number Diff line number Diff line
@@ -117,7 +117,9 @@ typedef struct
    float no_diegetic_pan;
    bool renderConfigEnabled;
    char *renderConfigFilename;

#ifdef SPLIT_REND_WITH_HEAD_ROT
    char *outputMdFilename;
#endif
#ifdef DEBUGGING
    IVAS_DEC_FORCED_REND_MODE forcedRendMode;
#ifdef DEBUG_FOA_AGC
@@ -267,7 +269,7 @@ int main(
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM
#ifdef SPLIT_REND_WITH_HEAD_ROT
             && arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CLDFB
             && arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CLDFB && arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM
#endif
        )
        {
@@ -358,7 +360,7 @@ int main(
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM
#ifdef SPLIT_REND_WITH_HEAD_ROT
             && arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CLDFB
             && arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CLDFB && arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM
#endif
        )
        {
@@ -377,7 +379,7 @@ int main(
     * Configure the decoder
     *------------------------------------------------------------------------------------------*/
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CLDFB )
    if ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CLDFB || arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM )
    {
        arg.enableHeadRotation = true;
    }
@@ -489,7 +491,10 @@ int main(

        /* sanity check */
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) && ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL ) && ( arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CLDFB ) )
        if ( ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) &&
             ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL ) &&
             ( arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CLDFB ) &&
             ( arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) )
        {
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output OR when Split rendering mode is enabled. Exiting. \n" );
            exit( -1 );
@@ -757,10 +762,14 @@ static IVAS_DEC_AUDIO_CONFIG cmdline2config(
        output_config = IVAS_DEC_OUTPUT_BINAURAL;
    }
#ifdef SPLIT_REND_WITH_HEAD_ROT
    else if ( strcmp( argv_to_upper, "SPLIT_BINAURAL" ) == 0 )
    else if ( strcmp( argv_to_upper, "BINAURAL_SPLIT_CLDFB" ) == 0 )
    {
        output_config = IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CLDFB;
    }
    else if ( strcmp( argv_to_upper, "BINAURAL_SPLIT_PCM" ) == 0 )
    {
        output_config = IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM;
    }
#endif
    else if ( strcmp( argv_to_upper, "BINAURAL_ROOM" ) == 0 )
    {
@@ -830,6 +839,10 @@ static bool parseCmdlIVAS_dec(
    arg->renderConfigEnabled = false;
    arg->renderConfigFilename = NULL;

#ifdef SPLIT_REND_WITH_HEAD_ROT
    arg->outputMdFilename = NULL;
#endif

    arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192;
    arg->no_diegetic_pan = 0.f;

@@ -1057,6 +1070,19 @@ static bool parseCmdlIVAS_dec(
            }
            i += 2;
        }
#ifdef SPLIT_REND_WITH_HEAD_ROT
        else if ( strcmp( argv_to_upper, "-OM" ) == 0 )
        {
            arg->outputMdFilename = argv[i + 1];
            if ( arg->outputMdFilename[0] == '\0' )
            {
                fprintf( stderr, "Error: output metadata file path not specified\n\n" );
                usage_dec();
                return false;
            }
            i += 2;
        }
#endif
        else if ( strcmp( argv_to_upper, "-NO_DIEGETIC_PAN" ) == 0 )
        {
            i++;
@@ -1197,7 +1223,7 @@ static void usage_dec( void )
    fprintf( stdout, "---------------------\n" );
#ifdef SPLIT_REND_WITH_HEAD_ROT
    fprintf( stdout, "OutputConf           : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" );
    fprintf( stdout, "                       HOA2, HOA3, BINAURAL, BINAURAL_ROOM, SPLIT_BINAURAL, EXT\n" );
    fprintf( stdout, "                       HOA2, HOA3, BINAURAL, BINAURAL_ROOM, BINAURAL_SPLIT_CLDFB, BINAURAL_SPLIT_PCM, EXT\n" );
#else
    fprintf( stdout, "OutputConf           : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" );
    fprintf( stdout, "                       HOA2, HOA3, BINAURAL, BINAURAL_ROOM, EXT\n" );
@@ -1242,6 +1268,9 @@ static void usage_dec( void )
    fprintf( stdout, "-render_config File : Renderer configuration File\n" );
    fprintf( stdout, "-no_diegetic_pan    : panning mono non-diegetic sound to stereo -1<= pan <=1,\n" );
    fprintf( stdout, "                      left or l or 1->left, right or r or -1->right, center or c or  0->middle\n" );
#ifdef SPLIT_REND_WITH_HEAD_ROT
    fprintf( stdout, "-om File            : MD output file for BINAURAL_SPLIT_PCM output format\n" );
#endif
    fprintf( stdout, "-q                  : Quiet mode, no frame counter\n" );
    fprintf( stdout, "                      default is deactivated\n" );
#ifdef DEBUGGING
@@ -1343,6 +1372,22 @@ static ivas_error initOnFirstGoodFrame(
    else
#endif
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM )
        {
            int16_t delayNumSamples_temp[3];
            int32_t delayTimeScale_temp;
            IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp );
            assert( arg.outputMdFilename != NULL );
            error = split_rend_writer_open( hSplitRendFileReadWrite, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp );
            if ( error != IVAS_ERR_OK )
            {
                fprintf( stderr, "Could not open split rend metadata file %s\n", arg.outputWavFilename );
                exit( -1 );
            }
        }
#endif

        /* Open audio writer and write all previously skipped bad frames now that frame size is known */
        if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK )
        {
@@ -1717,7 +1762,7 @@ static ivas_error decodeG192(
        if ( decodedGoodFrame )
        {
#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( hSplitRendFileReadWrite != NULL )
            if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CLDFB ) )
            {
                if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written ) != IVAS_ERR_OK )
                {
@@ -1728,6 +1773,16 @@ static ivas_error decodeG192(
            else
#endif
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT
                if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) )
                {
                    if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nUnable to write to bitstream file!\n" );
                        exit( -1 );
                    }
                }
#endif
                if ( delayNumSamples < nOutSamples )
                {
                    if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK )
+3 −2
Original line number Diff line number Diff line
@@ -685,7 +685,7 @@ ivas_error ivas_rend_openCldfbRend(
    hBinRenderer->hInputSetup->is_loudspeaker_setup = 0;
    getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE );

    if ( out_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB )
    if ( ( out_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB ) || ( out_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
        hBinRenderer->numPoses = pMultiBinPoseData->num_poses + 1;
@@ -751,7 +751,8 @@ ivas_error ivas_binRenderer_open(
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB )
    if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB ) ||
         ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
        hBinRenderer->numPoses = st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses + 1;
+7 −3
Original line number Diff line number Diff line
@@ -102,7 +102,8 @@ ivas_error ivas_dec(
    output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC );

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB )
    if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB ) ||
         ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
        assert( st_ivas->ivas_format == SBA_FORMAT && ( output_Fs == 48000 ) && "split binaural mode is currently supported with SBA format and 48k sampling rate only" );
        ivas_set_split_rend_setup( &st_ivas->splitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hHeadTrackData, hSplitRendBits );
@@ -627,19 +628,22 @@ ivas_error ivas_dec(

#ifdef SPLIT_REND_WITH_HEAD_ROT
    /*split rendering process calls*/
    if ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB )
    if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB ) ||
         ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
        IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend;
        int16_t max_band;
        int16_t pcm_out;
        hSplitBinRend = &st_ivas->splitBinRend;
        max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 );
        pcm_out = ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0;
        ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend,
                                            st_ivas->hHeadTrackData->Quaternions,
                                            st_ivas->hRenderConfig->split_rend_config.splitRendBitRate,
                                            hSplitBinRend->hSplitRendBits,
                                            hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural,
                                            hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural,
                                            max_band, output, 1, 0 );
                                            max_band, output, 1, pcm_out );

        free( st_ivas->splitBinRend.hMultiBinCldfbData );
    }
+2 −1
Original line number Diff line number Diff line
@@ -2570,7 +2570,8 @@ void ivas_dirac_dec(
                              Cldfb_RealBuffer,
                              Cldfb_ImagBuffer );
#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB )
            if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB ) ||
                 ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
            {
                int16_t pos_idx;
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
+7 −5
Original line number Diff line number Diff line
@@ -630,7 +630,7 @@ ivas_error ivas_init_decoder_front(

    if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM
#ifdef SPLIT_REND_WITH_HEAD_ROT
         || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB
         || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM
#endif
    )
    {
@@ -1217,7 +1217,8 @@ ivas_error ivas_init_decoder(
    if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB )
        if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB ) ||
             ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
        {
            ivas_renderSplitGetMultiBinPoseData(
                &st_ivas->hRenderConfig->split_rend_config,
@@ -1230,11 +1231,12 @@ ivas_error ivas_init_decoder(
            return error;
        }
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB )
        if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB ) ||
             ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
        {
            ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend,
                                      &st_ivas->hRenderConfig->split_rend_config,
                                      hDecoderConfig->output_Fs, 1, 0 );
                                      hDecoderConfig->output_Fs, 1, ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 );
        }
#endif
    }
@@ -2067,7 +2069,7 @@ static ivas_error doSanityChecks_IVAS(
        if ( !( output_config == AUDIO_CONFIG_BINAURAL ||
                output_config == AUDIO_CONFIG_BINAURAL_ROOM
#ifdef SPLIT_REND_WITH_HEAD_ROT
                || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB
                || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CLDFB || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM
#endif
                ) )
        {
Loading