Commit 6f242bfb authored by vaclav's avatar vaclav
Browse files

Merge branch '2051-basop-PortMr2059-from-float-renderer-granularity-revision' into 'main'

Port MR2059 from float to BASOP - Renderer granularity revision

Closes #2051

See merge request !2285
parents c3479a56 a6604126
Loading
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -1005,12 +1005,20 @@ Word16 IGF_MapBitRateToIndex(
    const Word16 rf_mode       /* i  :  flag to signal the RF mode */
);

#ifdef NONBE_1303_REND_GRANULARITY
Word16 ivas_jbm_dec_get_render_granularity_fx(
    const RENDERER_TYPE renderer_type,                          /* i  : renderer type                                               */
    const RENDERER_TYPE renderer_type_sec,                      /* i  : secondary renderer type                                     */
    const int32_t output_Fs                                     /* i  : sampling rate                                               */
);
#else
Word16 ivas_jbm_dec_get_render_granularity(
    const RENDERER_TYPE rendererType, /* i  : renderer type     */
    const IVAS_FORMAT ivas_format,    /* i  : ivas format */
    const MC_MODE mc_mode,            /* i  : MC mode */
    const Word32 output_Fs            /* i  : sampling rate     */
); 
#endif

// ivas_stereo_dft_com.c
void stereo_dft_config_fx(
@@ -6252,7 +6260,7 @@ void ivas_renderer_select(

#ifdef FIX_CREND_SIMPLIFY_CODE
/*! r: secondary binaural renderer type */
RENDERER_TYPE ivas_renderer_secondary_select(
RENDERER_TYPE ivas_renderer_secondary_select_fx(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);
#endif
@@ -6275,15 +6283,15 @@ int16_t is_DTXrate(
 * JBM prototypes
 *----------------------------------------------------------------------------------*/

ivas_error ivas_jbm_dec_set_discard_samples(
ivas_error ivas_jbm_dec_set_discard_samples_fx(
    Decoder_Struct *st_ivas                                     /* i/o: main IVAS decoder structre                                  */
);

TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode(
TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx(
    Decoder_Struct *st_ivas                                     /* i  : IVAS decoder handle                                         */
);

void ivas_jbm_dec_tc_buffer_close(
void ivas_jbm_dec_tc_buffer_close_fx(
    DECODER_TC_BUFFER_HANDLE *phTcBuffer                        /* i/o: TC buffer handle                                            */
);

+1 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@
#define FIX_1384_MSAN_stereo_tcx_core_enc               /* VA: issue 1384: fix use-of-uninitialized value in stereo_tcx_core_enc() */
#define NONBE_FIX_1297_SPAR_JBM_MEM_SAN                 /* Dolby: issue 1297, SPAR + JBM + BR switch memory sanitizer */
#define NONBE_1303_GRANULARITY_OSBA_REND                /* VA: issue 1303: Correctly set the granularity in OSBA, Disc mode, and BINAURAL_ROOM_REVERB output */
#define NONBE_1303_REND_GRANULARITY                     /* VA: issue 1303: Renderer granularity revision */

// object-editing feature porting
#define OBJ_EDITING_API                                 /* object editing changes related to the API */
+14 −5
Original line number Diff line number Diff line
@@ -2661,7 +2661,7 @@ ivas_error ivas_init_decoder_fx(
                return error;
            }
        }

#ifndef NONBE_1303_REND_GRANULARITY
        granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );

        n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
@@ -2671,6 +2671,7 @@ ivas_error ivas_init_decoder_fx(
        {
            return error;
        }
#endif
    }
    ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
    {
@@ -2720,7 +2721,7 @@ ivas_error ivas_init_decoder_fx(

        st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;
        move32();

#ifndef NONBE_1303_REND_GRANULARITY
        test();
        IF( ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) )
        {
@@ -2743,6 +2744,7 @@ ivas_error ivas_init_decoder_fx(
                return error;
            }
        }
#endif
    }

    IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
@@ -2781,7 +2783,7 @@ ivas_error ivas_init_decoder_fx(

            IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
            {
                IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
                IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, output_Fs ) ), IVAS_ERR_OK ) )
                {
                    return error;
                }
@@ -3029,9 +3031,16 @@ ivas_error ivas_init_decoder_fx(
    IF( st_ivas->hTcBuffer == NULL )
    {
        /* no module has yet open the TC buffer, open a default one */
#ifdef NONBE_1303_REND_GRANULARITY
        granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs );
        n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );

        IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )
        IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) )
#else
        n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );

        IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )
#endif
        {
            return error;
        }
@@ -3551,7 +3560,7 @@ void ivas_destroy_dec_fx(
        st_ivas->hDecoderConfig = NULL;
    }

    ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer );
    ivas_jbm_dec_tc_buffer_close_fx( &st_ivas->hTcBuffer );

    IF( st_ivas->hJbmMetadata != NULL )
    {
+7 −3
Original line number Diff line number Diff line
@@ -171,7 +171,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(

        /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
                render what still fits in the new granularity */
#ifdef NONBE_1303_REND_GRANULARITY
        tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
#else
    tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );
#endif

        IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
        {
@@ -199,7 +203,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
        /* JBM: when granularity goes up set samples to discard at the beginning of the frame */
        ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
        {
            IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) )
            IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
@@ -374,7 +378,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
        DECODER_TC_BUFFER_HANDLE hTcBuffer;

        hTcBuffer = st_ivas->hTcBuffer;
        tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas );
        tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas );
        tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
        tc_nchan_allocate_new = tc_nchan_tc_new;
        move16();
+15 −1
Original line number Diff line number Diff line
@@ -584,7 +584,11 @@ ivas_error ivas_param_ism_dec_open_fx(
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
)
{
#ifdef NONBE_1303_REND_GRANULARITY
    Word16 i, granularity;
#else
    Word16 i;
#endif
    PARAM_ISM_DEC_HANDLE hParamIsmDec;
    IVAS_OUTPUT_SETUP hOutSetup;
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
@@ -747,6 +751,9 @@ ivas_error ivas_param_ism_dec_open_fx(
    st_ivas->hParamIsmDec = hParamIsmDec;
    st_ivas->hSpatParamRendCom = hSpatParamRendCom;

#ifdef NONBE_1303_REND_GRANULARITY
    granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs );
#endif

    test();
    IF( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) )
@@ -793,8 +800,11 @@ ivas_error ivas_param_ism_dec_open_fx(

        IF( st_ivas->hTcBuffer == NULL )
        {
#ifdef NONBE_1303_REND_GRANULARITY
            IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, granularity ) ), IVAS_ERR_OK ) )
#else
            IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )

#endif
            {
                return error;
            }
@@ -807,8 +817,12 @@ ivas_error ivas_param_ism_dec_open_fx(
        IF( st_ivas->hTcBuffer == NULL )
        {
            Word16 nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out;
#ifdef NONBE_1303_REND_GRANULARITY
            IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) )
#else
            move16(); // NS2SA
            IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) )
#endif
            {
                return error;
            }
Loading