Commit 3de03fe9 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into...

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into 1866-replace-overflow-basop-operators-by-overflow-free-variants-in-lib_dec
parents f28636ae 0de863f5
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -2336,6 +2336,9 @@ void ivas_dirac_dec_read_BS_fx(
    Word16 *nb_bits,                                      /* o  : number of bits read                     */
    const Word16 last_bit_pos,                            /* i  : last read bitstream position            */
    const Word16 hodirac_flag,                            /* i  : flag to indicate HO-DirAC mode          */
#ifdef NONBE_FIX_1052_SBA_EXT
    const Word16 nchan_transport,                              /* i  : number of transport channels                             */
#endif    
	Word16 *dirac_to_spar_md_bands                        /* o  : DirAC->SPAR MD bands                    */
);

@@ -2496,6 +2499,13 @@ Word16 ivas_sba_get_nchan_metadata_fx(
    const Word32 ivas_total_brate /* i  : IVAS total bitrate               */
);

#ifdef NONBE_FIX_1052_SBA_EXT
/*! r: number of bits in SPAR SID frame */
Word16 ivas_sba_spar_sid_bitlen_fx(
    const Word16 nchan_transport /* i  : number of transport channels            */
);
#endif

void ivas_sba_get_spar_hoa_ch_ind_fx(
    const Word16 num_md_chs,       /* i  : number of MD channels       */
    const Word32 ivas_total_brate, /* i  : IVAS total bitrate           */
@@ -3500,6 +3510,9 @@ void ivas_qmetadata_enc_sid_encode_fx(
    BSTR_ENC_HANDLE hMetaData,        /* i/o: metadata bitstream handle               */
    IVAS_QMETADATA *q_metadata,       /* i/o: metadata handle                         */
    const Word16 masa_sid_descriptor, /* i  : description of MASA SID coding structure*/
#ifdef NONBE_FIX_1052_SBA_EXT
    const Word16 nchan_transport, /* i  : number of transport channels                             */
#endif
    const Word16 ivas_format          /* i  : ivas format                             */
);
void ivas_param_mc_enc_fx(
@@ -4974,11 +4987,6 @@ Word16 ivas_sba_get_nchan_metadata(
    const Word32 ivas_total_brate /* i  : IVAS total bitrate                      */
);

void ivas_sba_get_spar_hoa_ch_ind(
    const Word16 num_md_chs,       /* i  : number of MD channels                   */
    const Word32 ivas_total_brate, /* i  : IVAS total bitrate                      */
    Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] );

/*! r: flag indicating to code SPAR HOA MD for all bands */
void ivas_sba_get_spar_hoa_md_flag(
    const Word16 sba_order,        /* i  : Ambisonic (SBA) order                   */
@@ -5838,6 +5846,9 @@ ivas_error ivas_dirac_enc_fx(
    const Word16 input_frame,      /* i  : input frame length                      */
    const Word16 dtx_vad,          /* i  : DTX vad flag                            */
    const IVAS_FORMAT ivas_format, /* i  : ivas format                             */
#ifdef NONBE_FIX_1052_SBA_EXT
    const Word16 nchan_transport,                              /* i  : number of transport channels                             */
#endif
    const Word16 hodirac_flag,     /* i  : hodirac flag                            */
    const Word16 shift );

+24 −0
Original line number Diff line number Diff line
@@ -167,6 +167,30 @@ Word16 ivas_sba_get_nchan_fx(
}


#ifdef NONBE_FIX_1052_SBA_EXT
/*-------------------------------------------------------------------*
 * ivas_sba_spar_sid_bitlen_fx()
 *
 * Get number of bits in SPAR SID frame
 *-------------------------------------------------------------------*/

/*! r: number of bits in SPAR SID frame */
Word16 ivas_sba_spar_sid_bitlen_fx(
    const Word16 nchan_transport /* i  : number of transport channels            */
)
{
    Word16 num_bits;

    num_bits = i_mult( SPAR_DTX_BANDS, SPAR_SID_BITS_TAR_PER_BAND );
    IF( GT_16( nchan_transport, 1 ) )
    {
        num_bits = sub( num_bits, 2 );
    }

    return num_bits;
}
#endif

/*-------------------------------------------------------------------*
 * ivas_sba_get_nchan_metadata()
 *
+1 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@
#define ISSUE_1866_replace_overflow_libdec

#define FIX_1068_ASAN_IN_MC_2_BINAURAL_ROOM_IR          /* issue 1068 : Memory leak in MC to BINAURAL_ROOM decoding with bitrate switching*/
#define NONBE_FIX_1052_SBA_EXT                          /* Dlb: SBA external output support */
#define NONBE_FIX_MC_LFE_LPF                                  /* Dlb: Adding the LFE LPF filter back for MC content. */

/* #################### End BASOP porting switches ############################ */
+19 −2
Original line number Diff line number Diff line
@@ -1246,6 +1246,9 @@ void ivas_dirac_dec_read_BS_fx(
    Word16 *nb_bits,                                      /* o  : number of bits read             */
    const Word16 last_bit_pos,                            /* i  : last read bitstream position    */
    const Word16 hodirac_flag,                            /* i  : flag to indicate HO-DirAC mode  */
#ifdef NONBE_FIX_1052_SBA_EXT
    const Word16 nchan_transport, /* i  : number of transport channels                             */
#endif
    Word16 *dirac_to_spar_md_bands /* o  : DirAC->SPAR MD bands            */
)
{
@@ -1289,9 +1292,13 @@ void ivas_dirac_dec_read_BS_fx(
                    set32_fx( hQMetaData->q_direction[0].band_data[b].elevation_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
                }
            }
#ifdef NONBE_FIX_1052_SBA_EXT
            *nb_bits = add( *nb_bits, ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), nchan_transport, NULL, SBA_FORMAT ) );
            move16();
#else
            *nb_bits = add( *nb_bits, ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), 0, NULL, SBA_FORMAT ) );
            move16();

#endif
            FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
            {
                hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[1].azimuth_fx[0];
@@ -1351,7 +1358,12 @@ void ivas_dirac_dec_read_BS_fx(

        /* subtract mode signaling bits, since bitstream was moved after mode reading */
        iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &quo, &rem, 0 );
#ifdef NONBE_FIX_1052_SBA_EXT
        st->next_bit_pos = extract_l( L_sub( L_sub( quo, 1 ), SID_FORMAT_NBITS + SBA_PLANAR_BITS + SBA_ORDER_BITS ) );
#else
        st->next_bit_pos = extract_l( L_sub( L_sub( quo, 1 ), SID_FORMAT_NBITS ) );
#endif

        move16();
        /* 1 bit flag for signaling metadata to read */
        b = st->bit_stream[( st->next_bit_pos )--];
@@ -1374,8 +1386,13 @@ void ivas_dirac_dec_read_BS_fx(
                }
            }
        }
#ifdef NONBE_FIX_1052_SBA_EXT
        *nb_bits = add( *nb_bits, ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), nchan_transport, NULL, SBA_FORMAT ) );
        move16();
#else
        *nb_bits = add( *nb_bits, ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), 0, NULL, SBA_FORMAT ) );
        move16();
#endif
        FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
        {
            hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[1].azimuth_fx[0];
+58 −0
Original line number Diff line number Diff line
@@ -55,6 +55,10 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, Word16 *num_bits_re

static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas );

#ifdef NONBE_FIX_1052_SBA_EXT
static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const Word16 sba_order );
#endif

static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas );


@@ -257,6 +261,29 @@ static ivas_error ivas_dec_init_split_rend(
    return error;
}

#ifdef NONBE_FIX_1052_SBA_EXT
static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const Word16 sba_order )
{
    AUDIO_CONFIG output_config;
    output_config = IVAS_AUDIO_CONFIG_HOA3;
    switch ( sba_order )
    {
        case SBA_FOA_ORDER:
            output_config = IVAS_AUDIO_CONFIG_FOA;
            break;
        case SBA_HOA2_ORDER:
            output_config = IVAS_AUDIO_CONFIG_HOA2;
            break;
        case SBA_HOA3_ORDER:
            output_config = IVAS_AUDIO_CONFIG_HOA3;
            break;
        default:
            assert( 0 );
    }
    return output_config;
}
#endif

/*-------------------------------------------------------------------*
 * ivas_dec_setup()
 *
@@ -351,6 +378,14 @@ ivas_error ivas_dec_setup(
            move16();
            st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );
            move16();
#ifdef NONBE_FIX_1052_SBA_EXT
            IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
            {
                st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order );
                st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config );
            }
#endif

            num_bits_read = add( num_bits_read, SBA_ORDER_BITS );
            test();
            test();
@@ -660,6 +695,14 @@ ivas_error ivas_dec_setup(
                BREAK;
        }

#ifdef NONBE_FIX_1052_SBA_EXT
        IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) && EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
        {
            st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order );
            st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config );
        }
#endif

        test();
        IF( st_ivas->ini_frame > 0 && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
        {
@@ -998,6 +1041,21 @@ static ivas_error ivas_read_format(

        IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
        {
#ifdef NONBE_FIX_1052_SBA_EXT
            /* read Ambisonic (SBA) planar flag */
            st_ivas->sba_planar = st_ivas->bit_stream[*num_bits_read];
            move16();
            *num_bits_read = add( *num_bits_read, SBA_PLANAR_BITS );
            move16();

            /* read Ambisonic (SBA) order */
            st_ivas->sba_order = st_ivas->bit_stream[*num_bits_read + 1];
            move16();
            st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[*num_bits_read], 1 ) );
            move16();
            *num_bits_read = add( *num_bits_read, SBA_ORDER_BITS );
            move16();
#endif
            if ( st_ivas->sba_analysis_order == 0 )
            {
                st_ivas->sba_analysis_order = SBA_FOA_ORDER;
Loading