Commit c3694594 authored by sagnowski's avatar sagnowski
Browse files

Update external renderer

Changes:
- Add clipping of samples before float to int conversion
- Minor improvements to command line parsing
- Merge recent main
parent 43bd3cf6
Loading
Loading
Loading
Loading
Loading
+31 −9
Original line number Diff line number Diff line
@@ -607,7 +607,19 @@ int32_t main( int32_t argc, char **argv )
        fprintf( stdout, "\nRenderer delay:         %-5u [samples] - Timescale: %5u\n", delayNumSamples_orig, delayTimeScale );
    }

    fprintf( stdout, "\n\nRendering of %d frames finished\n", frame );
    fprintf( stdout, "\n\nRendering of %d frames finished\n\n", frame );

#ifdef DEBUGGING
    int32_t cnt_frames_limited, noClipping;
    if ( ( cnt_frames_limited = IVAS_REND_GetCntFramesLimited( hIvasRend ) ) > 0 )
    {
        fprintf( stdout, "Limiter applied in %d frames.\n\n", cnt_frames_limited );
    }
    if ( ( noClipping = IVAS_REND_GetNoCLipping( hIvasRend ) ) > 0 )
    {
        fprintf( stdout, "Clipping (saturation) detected: %d samples clipped!!!\n\n", noClipping );
    }
#endif

    /* === Close === */
    count_free( inpInt16Buffer );
@@ -1170,6 +1182,7 @@ typedef enum
    CmdLnOptionId_neverDropLfe,
    CmdLnOptionId_noDelayCmp,
    CmdLnOptionId_quietModeEnabled,
    CmdLnOptionId_inputMetadata,
} CmdLnOptionId;

static void parseOption( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct )
@@ -1260,15 +1273,22 @@ static CmdlnArgs parseCmdlnArgs( int32_t argc, char **argv )
            .match = "input_file",
            .matchShort = "i",
            .isRequired = 1,
            .description = "Path to the input file",
            .description = "Path to the input file (WAV, raw PCM or scene description file)",
        },
        {
            .id = CmdLnOptionId_inputFormat,
            .match = "input_format",
            .matchShort = "if",
            .isRequired = 1,
            // .description = "Audio format of input file (e.g. 5_1 or HOA3 or META)", /* TODO(sgi): Add additional flag for listing all available formats */
            .description = "Format of input file\nIn case of a metadata format this should be followed by a list of metadata file paths or NULL",
        },
        // { /* TODO(sgi): move metadata file paths from input_format to this separate flag */
        //     .id = CmdLnOptionId_inputMetadata,
        //     .match = "input_metadata",
        //     .matchShort = "im",
        //     .description = "Space-separated list of path to metadata files for ISM or MASA inputs",
        // },
        {
            .id = CmdLnOptionId_outputFile,
            .match = "output_file",
@@ -1287,40 +1307,42 @@ static CmdlnArgs parseCmdlnArgs( int32_t argc, char **argv )
            .id = CmdLnOptionId_sampleRate,
            .match = "sample_rate",
            .matchShort = "fs",
            .isRequired = 1,
            .description = "Input sampling rate in kHz",
            .isRequired = 1, /* TODO(sgi): Shouldn't be required */
            .description = "Input sampling rate in kHz (16, 32, 48)", /* TODO(sgi): Add sampling rate to scene description files */
        },
        {
            .id = CmdLnOptionId_trajFile,
            .match = "trajectory_file",
            .matchShort = "tf",
            .description = "Head rotation trajectory file",
            .description = "Head rotation trajectory file for simulation of head tracking (only for BINAURAL and BINAURAL_ROOM outputs)",
        },
        {
            .id = CmdLnOptionId_customHrtfFile,
            .match = "custom_hrtf",
            .matchShort = "hrtf",
            .description = "Custom HRTF file for binaural rendering",
            .description = "Custom HRTF file for binaural rendering (only for BINAURAL and BINAURAL_ROOM outputs)",
        },
        {
            .id = CmdLnOptionId_renderConfigFile,
            .match = "render_config",
            .matchShort = "rc",
            .description = "Renderer configuration file",
            .description = "Binaural renderer configuration file (only for BINAURAL and BINAURAL_ROOM outputs)",
        },
        {
            .id = CmdLnOptionId_noDiegeticPan,
            .match = "no_diegetic_pan",
            .matchShort = "ndp",
            .description = "Panning mono no dietic sound to stereo -1<= pan <= 1\nleft or l or 1->left, right or r or -1->right, center or c or 0 ->middle",
            .description = "Panning mono no diegetic sound to stereo -1<= pan <= 1\nleft or l or 1->left, right or r or -1->right, center or c or 0 ->middle\n(todo: implementation)",
        },
        {
            .id = CmdLnOptionId_orientationTracking,
            .match = "tracking_type",
            .matchShort = "otr",
            .description = "Head orientation tracking type: 'ref' or 'avg' (only for binaural rendering)",
            .description = "Head orientation tracking type: 'ref' or 'avg' (only for BINAURAL and BINAURAL_ROOM) (todo: check implementation)",
        },
        {
            /* TODO(sgi): Replace with more configurable input, e.g. ask for a list of triplets: (gain, azimuth, elevation) to place LFE signal */
            /* rename to "lfeHandling" */
            .id = CmdLnOptionId_neverDropLfe,
            .match = "neverDropLfe",
            .matchShort = "ndl",
+18 −0
Original line number Diff line number Diff line
@@ -1975,11 +1975,29 @@ ivas_error preview_indices(
        }
        else if ( st_ivas->ivas_format == SBA_FORMAT )
        {

            /* Read SBA planar flag and SBA order */
            st_ivas->sba_planar = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA] == 1 );
#ifndef SBA_ORDER_BITSTREAM
            st_ivas->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA + 2] == 1 );
            st_ivas->sba_order += 2 * ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA + 1] == 1 );
#else
            st_ivas->hDecoderConfig->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA + 2] == 1 );
            st_ivas->hDecoderConfig->sba_order += 2 * ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA + 1] == 1 );
            st_ivas->sba_analysis_order = st_ivas->hDecoderConfig->sba_order;
#endif
#ifdef SBA_ORDER_BITSTREAM
            /*Hard coding the the sba_oder as 1 as higher not supported below 256k bitrate*/
            if ( total_brate < IVAS_256k )
            {
                st_ivas->sba_analysis_order = 1;
            }
#endif
#ifdef SBA_ORDER_BITSTREAM
            ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ), st_ivas->sba_mode );
#else
            ivas_sba_config( total_brate, st_ivas->sba_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ), st_ivas->sba_mode );
#endif
        }
    }

+8 −0
Original line number Diff line number Diff line
@@ -82,7 +82,11 @@ ivas_error ivas_dirac_config(
        nCPE = &( (Encoder_Struct *) st_ivas )->nCPE;
        element_mode = &( (Encoder_Struct *) st_ivas )->hEncoderConfig->element_mode_init;
        nchan_transport = &( (Encoder_Struct *) st_ivas )->nchan_transport;
#ifndef SBA_ORDER_BITSTREAM
        sba_order = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->sba_order;
#else
        sba_order = ( (Encoder_Struct *) st_ivas )->sba_analysis_order;
#endif
        sba_planar = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->sba_planar;
        ivas_total_brate = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->ivas_total_brate;
        Fs = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->input_Fs;
@@ -107,7 +111,11 @@ ivas_error ivas_dirac_config(
        nCPE = &( (Decoder_Struct *) st_ivas )->nCPE;
        element_mode = &( (Decoder_Struct *) st_ivas )->element_mode_init;
        nchan_transport = &( (Decoder_Struct *) st_ivas )->nchan_transport;
#ifndef SBA_ORDER_BITSTREAM
        sba_order = ( (Decoder_Struct *) st_ivas )->sba_order;
#else
        sba_order = ( (Decoder_Struct *) st_ivas )->sba_analysis_order;
#endif
        sba_planar = ( (Decoder_Struct *) st_ivas )->sba_planar;
        ivas_total_brate = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->ivas_total_brate;
        Fs = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->output_Fs;
+8 −10
Original line number Diff line number Diff line
@@ -2155,9 +2155,7 @@ void stereo_mdct_core_dec(
void splitAvailableBits(
    const int16_t total_bits,                                   /* i  : total available bits for TCX coding     */
    const int16_t split_ratio,                                  /* i  : split ratio                             */
#ifdef LBR_SBA_CORE_CODING_TUNING
    const int16_t isSBAStereoMode,                              /* i  : signal core coding for sba              */
#endif
    int16_t *bits_ch0,                                          /* o  : bits for channel 0                      */
    int16_t *bits_ch1                                           /* o  : bits for channel 1                      */
);
@@ -2175,9 +2173,7 @@ void parse_stereo_from_bitstream(
    STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct,                    /* i/o: MDCT stereo decoder structure           */
    Decoder_State **sts,                                        /* i/o: decoder state structure                 */
    const int16_t mct_on,                                       /* i  : flag mct block (1) or stereo (0)        */
#ifdef LBR_SBA_CORE_CODING_TUNING
    const int16_t isSBAStereoMode,                              /* i: flag core coding for sba         */
#endif
    Decoder_State *st0,                                         /* i/o: decoder state structure for Bstr        */
    int16_t ms_mask[NB_DIV][MAX_SFB]                            /* o  : bandwise MS mask                        */
);
@@ -2513,10 +2509,8 @@ ivas_error stereo_memory_enc(
    const int16_t max_bwidth,                                   /* i  : maximum audio bandwidth                 */
    float *tdm_last_ratio,                                      /* o  : TD stereo last ratio                    */
    const IVAS_FORMAT ivas_format                               /* i  : IVAS format                             */
#ifdef LBR_SBA_CORE_CODING_TUNING
    ,
    const int16_t nchan_transport                               /* i  : number transport chans                  */
#endif

);

@@ -3013,11 +3007,7 @@ void ivas_dirac_param_est_enc(
 *----------------------------------------------------------------------------------*/

/*! r: SBA format mode */
#ifdef LBR_SBA_CORE_CODING_TUNING
SBA_MODE ivas_sba_mode_select( 
#else
int16_t ivas_sba_mode_select( 
#endif
    const int32_t ivas_total_brate                              /* i  : IVAS total bitrate                      */
);

@@ -3876,6 +3866,10 @@ void ivas_spar_dec_upmixer(
ivas_error ivas_spar_md_enc_open(
    ivas_spar_md_enc_state_t **hMdEnc,                          /* i/o: SPAR MD encoder handle                  */
    const ENCODER_CONFIG_HANDLE hEncoderConfig                  /* i  : configuration structure                 */
#ifdef SBA_ORDER_BITSTREAM
    ,
    int16_t sba_order
#endif
);

void ivas_spar_md_enc_close(
@@ -3888,6 +3882,10 @@ ivas_error ivas_spar_md_enc_process(
    ivas_spar_md_enc_in_buf_t *pIn_buf,
    BSTR_ENC_HANDLE hMetaData,                                  /* i/o: MetaData handle                         */
    const int16_t dtx_silence_mode
#ifdef SBA_ORDER_BITSTREAM
    ,
    int16_t sba_order
#endif
);

void ivas_compute_spar_params(
+0 −4
Original line number Diff line number Diff line
@@ -46,9 +46,7 @@
void splitAvailableBits(
    const int16_t total_bits,      /* i  : total available bits for TCX coding   */
    const int16_t split_ratio,     /* i  : split ratio                           */
#ifdef LBR_SBA_CORE_CODING_TUNING
    const int16_t isSBAStereoMode, /* i  : signal core coding for sba            */
#endif
    int16_t *bits_ch0,             /* o  : bits for channel 0                    */
    int16_t *bits_ch1              /* o  : bits for channel 1                    */
)
@@ -56,13 +54,11 @@ void splitAvailableBits(
    assert( split_ratio >= 1 && split_ratio < SMDCT_BITRATE_RATIO_RANGE );

    *bits_ch0 = split_ratio * total_bits / SMDCT_BITRATE_RATIO_RANGE;
#ifdef LBR_SBA_CORE_CODING_TUNING
    /* for SBA mode bias the distribution towards the W channel */
    if ( split_ratio < 7 && isSBAStereoMode )
    {
        *bits_ch0 += (int16_t) ( 0.2 * *bits_ch0 );
    }
#endif
    *bits_ch1 = total_bits - *bits_ch0;

    return;
Loading