Commit 041dac64 authored by bayers's avatar bayers
Browse files

fix some problems with the unified channel mem handling

parent aa2404ba
Loading
Loading
Loading
Loading
+23 −10
Original line number Diff line number Diff line
@@ -844,6 +844,12 @@ void ivas_jbm_dec_get_md_map(

int16_t ivas_jbm_dec_get_num_tc_channels( 
    Decoder_Struct *st_ivas                                     /* i  : IVAS decoder handle                                         */
#ifdef UNIFY_CHANNEL_MEM_HEAP
    ,
    int16_t *nchan_transport_jbm,                               /* o  : number of TSM channels                                      */
    int16_t *nchan_transport_internal,                          /* o  : number of internal channels (i.e. plus e.g. addtl. decorr   */
    int16_t *nchan_transport_full                               /* o  : number of channels to allocate fully                        */
#endif
);

void ivas_jbm_dec_copy_tc_no_tsm( 
@@ -866,10 +872,14 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode(

/*! r: render granularity */
int16_t ivas_jbm_dec_get_render_granularity(
#ifdef UNIFY_CHANNEL_MEM_HEAP
    Decoder_Struct *st_ivas /* i  : main decoder structure */
#else
    const RENDERER_TYPE rendererType, /* i  : renderer type     */
    const IVAS_FORMAT ivas_format,    /* i  : ivas format */
    const MC_MODE mc_mode,            /* i  : MC mode */
    const int32_t output_Fs           /* i  : sampling rate     */
#endif
);

ivas_error ivas_jbm_dec_tc_buffer_open(
@@ -882,12 +892,15 @@ ivas_error ivas_jbm_dec_tc_buffer_open(
);

ivas_error ivas_jbm_dec_tc_buffer_reconfigure(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                      */
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                                      */
#ifndef UNIFY_CHANNEL_MEM_HEAP
    ,
    const TC_BUFFER_MODE tc_buffer_mode,    /* i  : new buffer mode                         */
    const int16_t nchan_transport_jbm,      /* i  : new number of real transport channels   */
    const int16_t nchan_transport_internal, /* i  : new number of totally buffered channels */
    const int16_t nchan_full,               /* i  : new number of channels to fully store   */
    const int16_t n_samples_granularity     /* i  : new granularity of the renderer/buffer  */
#endif
);

void ivas_jbm_dec_tc_buffer_close(
+2 −1
Original line number Diff line number Diff line
@@ -197,10 +197,11 @@
#define NONBE_FIX_752_OSBA_MISCONFIG_MCT                      /* FhG: issue 752: misconfiguration of MCT causes crashes for coding with sampling rate under 48kHz at 256kbps*/
#define NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION              /* Dlb : issue 727 : headrotation in MC paramupmix mode*/
#define NONBE_FIX_779_ISM_FREE_REVERB_HANDLE                  /* VA: issue 779: fix Crash in ISM rate switching with BINAURAL_ROOM_REVERB */

#define NONBE_UNIFIED_DECODING_PATHS                          /* FhG: unify decoding paths   */
#ifdef NONBE_UNIFIED_DECODING_PATHS
#define REMOVE_5MS_FLAG
#define FIX_XXX_JBM_PARAMUPMIX_RS
#define UNIFY_CHANNEL_MEM_HEAP
#endif
#define NONBE_FIX_722_MEMORY_LEAK_IN_PARAMUPMIX               /* Dlb : issue 722: memory leak fix in MC param upmix mode with BR switching*/
#define NONBE_FIX_780_ISM_STARTS_WITH_SID                     /* VA: issue 780: fix Crash in ISM decoding when bitstream starts with an SID and output_config is not EXT */
+4 −3
Original line number Diff line number Diff line
@@ -957,6 +957,7 @@ ivas_error ivas_dirac_dec_config(
        }
    }

#if 0
    /* Allocate transport channel buffers for SBA format when in JBM */
    if ( dec_config_flag == DIRAC_OPEN )
    {
@@ -989,7 +990,7 @@ ivas_error ivas_dirac_dec_config(
            }
        }
    }

#endif
    return error;
}

+25 −2
Original line number Diff line number Diff line
@@ -1098,7 +1098,9 @@ ivas_error ivas_init_decoder(
    int16_t i, n, k;
    int16_t sce_id, cpe_id;
    int16_t numCldfbAnalyses, numCldfbSyntheses;
#ifndef UNIFY_CHANNEL_MEM_HEAP
    int16_t granularity, n_channels_transport_jbm;
#endif
    int32_t output_Fs, ivas_total_brate;
    int32_t binauralization_delay_ns;
    AUDIO_CONFIG output_config;
@@ -1967,6 +1969,7 @@ ivas_error ivas_init_decoder(
            }
        }

#ifndef UNIFY_CHANNEL_MEM_HEAP
#ifndef REMOVE_5MS_FLAG
        if ( st_ivas->hDecoderConfig->Opt_5ms )
#endif
@@ -1979,6 +1982,7 @@ ivas_error ivas_init_decoder(
                return error;
            }
        }
#endif
    }
    else if ( st_ivas->renderer_type == RENDERER_MC )
    {
@@ -2017,6 +2021,7 @@ ivas_error ivas_init_decoder(

        st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;

#ifndef UNIFY_CHANNEL_MEM_HEAP
#ifndef REMOVE_5MS_FLAG
        if ( st_ivas->hDecoderConfig->Opt_5ms )
#endif
@@ -2044,6 +2049,7 @@ ivas_error ivas_init_decoder(
                }
            }
        }
#endif
    }

    if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
@@ -2192,6 +2198,7 @@ ivas_error ivas_init_decoder(
        return error;
    }

#ifndef UNIFY_CHANNEL_MEM_HEAP
    /*-----------------------------------------------------------------*
     * Allocate and initialize JBM struct + buffer
     *-----------------------------------------------------------------*/
@@ -2200,8 +2207,6 @@ ivas_error ivas_init_decoder(
        st_ivas->hDecoderConfig->Opt_5ms &&
#endif
        st_ivas->hTcBuffer == NULL )

    if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL )
    {
        /* no module has yet open the TC buffer, open a default one */
        n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas );
@@ -2220,6 +2225,7 @@ ivas_error ivas_init_decoder(
            return error;
        }
    }
#endif

    if ( st_ivas->hJbmMetadata == NULL )
    {
@@ -2260,6 +2266,23 @@ ivas_error ivas_init_decoder(
        st_ivas->p_output_f[n] = NULL;
    }

#ifdef UNIFY_CHANNEL_MEM_HEAP
    {
        int16_t nchan_transport_jbm;
        int16_t nchan_transport_internal;
        int16_t nchan_transport_full;
        int16_t renderer_granularity;
        TC_BUFFER_MODE tc_buffer_mode;
        ivas_jbm_dec_get_num_tc_channels( st_ivas, &nchan_transport_jbm, &nchan_transport_internal, &nchan_transport_full );
        tc_buffer_mode = ivas_jbm_dec_get_tc_buffer_mode( st_ivas );
        renderer_granularity = ivas_jbm_dec_get_render_granularity( st_ivas );
        if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, tc_buffer_mode, nchan_transport_jbm, nchan_transport_internal, nchan_transport_full, renderer_granularity ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
#endif

    return error;
}

+20 −3
Original line number Diff line number Diff line
@@ -63,9 +63,11 @@ static ivas_error ivas_ism_bitrate_switching_dec(
    int32_t element_brate_tmp[MAX_NUM_OBJECTS];
    int16_t nSCE_old, nCPE_old;
    int16_t numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode;
#ifndef UNIFY_CHANNEL_MEM_HEAP
    TC_BUFFER_MODE tc_buffer_mode_new;
    int16_t tc_nchan_tc_new;
    int16_t tc_nchan_allocate_new;
#endif
    int16_t tc_granularity_new;
    int16_t ch, nchan_out_buff, nchan_out_buff_old;
    AUDIO_CONFIG intern_config_old;
@@ -81,7 +83,11 @@ static ivas_error ivas_ism_bitrate_switching_dec(
    st_ivas->ism_mode = last_ism_mode;
    ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
    st_ivas->ism_mode = ism_mode;
#ifdef UNIFY_CHANNEL_MEM_HEAP
    nchan_out_buff_old = ivas_count_nchan_buffers_dec( st_ivas );
#else
    nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas );
#endif

    if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK )
    {
@@ -144,7 +150,11 @@ static ivas_error ivas_ism_bitrate_switching_dec(

        /* 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 UNIFY_CHANNEL_MEM_HEAP
        tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas );
#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 ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
        {
@@ -388,6 +398,12 @@ static ivas_error ivas_ism_bitrate_switching_dec(
    if ( st_ivas->hDecoderConfig->Opt_5ms )
#endif
    {
#ifdef UNIFY_CHANNEL_MEM_HEAP
        if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#else
        int16_t tc_nchan_full_new;
        DECODER_TC_BUFFER_HANDLE hTcBuffer;

@@ -417,6 +433,7 @@ static ivas_error ivas_ism_bitrate_switching_dec(
                return error;
            }
        }
#endif

        /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */
        if ( st_ivas->hSpatParamRendCom != NULL )
Loading