Commit 45d3dfa4 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

adding planar and order bits to SID frame in SBA

parent 448172d7
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1082,7 +1082,11 @@ void ivas_dirac_dec_read_BS(
        next_bit_pos_orig = st->next_bit_pos;

        /* subtract mode signaling bits, since bitstream was moved after mode reading */
#ifdef NONBE_FIX_1052_SBA_EXT
        st->next_bit_pos = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 - SID_FORMAT_NBITS - SBA_PLANAR_BITS - SBA_ORDER_BITS );
#else
        st->next_bit_pos = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 - SID_FORMAT_NBITS );
#endif
        /* 1 bit flag for signaling metadata to read */
        b = st->bit_stream[( st->next_bit_pos )--];
        ( *nb_bits )++;
+47 −18
Original line number Diff line number Diff line
@@ -59,6 +59,10 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_r

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 int16_t sba_order );
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas );

@@ -240,6 +244,28 @@ static ivas_error ivas_dec_init_split_rend(
}
#endif

#ifdef NONBE_FIX_1052_SBA_EXT
static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t 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()
@@ -330,22 +356,7 @@ ivas_error ivas_dec_setup(
#ifdef NONBE_FIX_1052_SBA_EXT
            if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
            {
                switch (st_ivas->sba_order)
                {
                case SBA_FOA_ORDER:
                    st_ivas->hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_FOA;
                    break;
                case SBA_HOA2_ORDER:
                    st_ivas->hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_HOA2;
                    break;
                case SBA_HOA3_ORDER:
                    st_ivas->hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_HOA3;
                    break;
                default:
                    fprintf(stderr, "Unsupported SBA order %d\n", st_ivas->sba_order);
                    return IVAS_ERR_WRONG_PARAMS;
                    break;
                }
                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
@@ -619,6 +630,14 @@ ivas_error ivas_dec_setup(
                break;
        }

#ifdef NONBE_FIX_1052_SBA_EXT
        if ( st_ivas->ivas_format == SBA_FORMAT && 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

        if ( st_ivas->ini_frame > 0 && st_ivas->ivas_format == SBA_FORMAT )
        {
            int16_t nchan_transport_old, nchan_transport;
@@ -895,6 +914,16 @@ static ivas_error ivas_read_format(

        if ( 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];
            *num_bits_read += SBA_PLANAR_BITS;

            /* read Ambisonic (SBA) order */
            st_ivas->sba_order = st_ivas->bit_stream[*num_bits_read + 1];
            st_ivas->sba_order += 2 * st_ivas->bit_stream[*num_bits_read];
            *num_bits_read += SBA_ORDER_BITS;
#endif
            if ( st_ivas->sba_analysis_order == 0 )
            {
                st_ivas->sba_analysis_order = SBA_FOA_ORDER;
+4 −0
Original line number Diff line number Diff line
@@ -1221,7 +1221,11 @@ int16_t ivas_qmetadata_dec_sid_decode(

    if ( ivas_format == SBA_FORMAT )
    {
#ifdef NONBE_FIX_1052_SBA_EXT
        metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/
#else
        metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - 2 - SID_FORMAT_NBITS; /* -1 for inactive mode header bit*/
#endif
    }
    else
    {
+8 −0
Original line number Diff line number Diff line
@@ -368,7 +368,11 @@ ivas_error ivas_spar_dec(

    if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 )
    {
#ifdef NONBE_FIX_1052_SBA_EXT
        last_bit_pos -= SID_FORMAT_NBITS - SBA_PLANAR_BITS - SBA_ORDER_BITS;
#else
        last_bit_pos -= SID_FORMAT_NBITS;
#endif
    }
    nb_bits_read_orig = *nb_bits_read;
    last_bit_pos -= nb_bits_read_orig;
@@ -403,7 +407,11 @@ ivas_error ivas_spar_dec(
    if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 )
    {
        int16_t zero_pad_bits;
#ifdef NONBE_FIX_1052_SBA_EXT
        *nb_bits_read += SID_FORMAT_NBITS + SBA_PLANAR_BITS + SBA_ORDER_BITS;
#else
        *nb_bits_read += SID_FORMAT_NBITS;
#endif
        zero_pad_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - *nb_bits_read;
        assert( zero_pad_bits <= 1 );
        *nb_bits_read += zero_pad_bits;
+10 −0
Original line number Diff line number Diff line
@@ -600,6 +600,16 @@ ivas_error ivas_cpe_enc(
    if ( sts[0]->core_brate == SID_2k40 )
    {
        ivas_write_format_sid( ivas_format, hCPE->element_mode, sts[0]->hBstr );
#ifdef NONBE_FIX_1052_SBA_EXT
        if ( ivas_format == SBA_FORMAT )
        {
            /* Write SBA planar flag */
            push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_planar, SBA_PLANAR_BITS );

            /* Write SBA order */
            push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS );
        }
#endif
    }

    /*----------------------------------------------------------------*
Loading