Commit 7dcdd71b authored by fotopoulou's avatar fotopoulou
Browse files

encoder changes to code discrete ISMs with SBA with MCT under...

encoder changes to code discrete ISMs with SBA with MCT under OSBA_DISC_OBJ_MCT. Encoder runs through.
parent 307acdb4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -401,6 +401,10 @@ typedef enum
    ISM_MODE_NONE,
    ISM_MODE_DISC,                              /* discrete ISM */
    ISM_MODE_PARAM                              /* parametric ISM */
#ifdef OSBA_DISC_OBJ_MCT    
, 
    ISM_SBA_MODE_DISC                           /* discrete coding of objects with OSBA*/
#endif
} ISM_MODE;


+4 −0
Original line number Diff line number Diff line
@@ -162,6 +162,10 @@
#define FIX_580_PARAMMC_ENER_BURSTS                     /* FhG: issue 580: energy bursts due to ILD holding when energy relations change too much */

#define SBA_AND_OBJECTS
#ifdef SBA_AND_OBJECTS
#define OSBA_DISC_OBJ_MCT
#endif

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */

+77 −2
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ ivas_error ivas_enc(
    else if ( ivas_format == SBA_ISM_FORMAT )
    {
        /*Default mode for OSBA*/
        st_ivas->ism_mode = ISM_MODE_NONE;
        // st_ivas->ism_mode = ISM_MODE_NONE;

        if ( st_ivas->ism_mode == ISM_MODE_NONE ) /*rendering of objects in SBA signal*/
        {
@@ -286,7 +286,7 @@ ivas_error ivas_enc(
            /* delay ISM input channels to match the SBA encoder delay */
            for ( n = 0; n < hEncoderConfig->nchan_ism; n++ )
            {
                delay_signal( data_f[n], input_frame, st_ivas->hSpar->input_data_mem[n], NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) );
                delay_signal( data_f[n], input_frame, st_ivas->hOSba->input_data_mem[n], NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) );
            }
        }

@@ -338,6 +338,81 @@ ivas_error ivas_enc(
                }
            }
        }
        else
        {

            n = hEncoderConfig->nchan_ism;
/*deal with metadata writing a bit later*/
#if 0
/* Encode ISMs metadata */
            if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, &nb_bits_metadata[1] /*, 0 */ ) ) != IVAS_ERR_OK ) /*TODOfto: not needed for now*/
            {
                return error;
            }
            if ( st_ivas->nchan_transport == 1 )
            {
                st = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0];
                hMetaData = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData;

                /* update pointer to the buffer of indices (ISM indices were alredy written) */
                hMetaData->ind_list = st_ivas->hSCE[st_ivas->nSCE - 2]->hMetaData->ind_list + st_ivas->hSCE[st_ivas->nSCE - 2]->hMetaData->nb_ind_tot;
                st->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 2]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 2]->hCoreCoder[0]->hBstr->nb_ind_tot;
            }
            else
            {
                st = st_ivas->hCPE[0]->hCoreCoder[0];
                hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData;

                /* update pointer to the buffer of indices (ISM indices were alredy written) */
                hMetaData->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->nb_ind_tot;
                st->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->nb_ind_tot;
            }
#endif
            st = st_ivas->hCPE[0]->hCoreCoder[0];
            hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData;
            /* Write SBA planar flag */
            push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS );

            /* Write SBA order */
            push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS );

            /* SBA metadata encoding and SBA metadata bitstream writing */
            if ( ( error = ivas_spar_enc( st_ivas, &data_f[n], input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK )
            {
                return error;
            }

            /* get SBA TCs */
            ivas_sba_getTCs( &data_f[n], st_ivas, input_frame );

            //  if ( st_ivas->hEncoderConfig->ivas_total_brate >= IVAS_256k )
            // {
            //   st_ivas->nchan_transport += n;
            //}

            /* encode SBA transport channels */
            if ( st_ivas->nchan_transport == 1 )
            {
                if ( ( error = ivas_sce_enc( st_ivas, hEncoderConfig->nchan_ism, data_f[n], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
            else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */
            {
                if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[n], data_f[n + 1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
            else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */
            {
                if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
        }
    }
#endif
    else if ( ivas_format == MC_FORMAT )
+40 −0
Original line number Diff line number Diff line
@@ -569,6 +569,11 @@ ivas_error ivas_init_encoder(

        st_ivas->ism_mode = ISM_MODE_NONE;

        if ( ivas_total_brate >= IVAS_256k )
        {
            st_ivas->ism_mode = ISM_SBA_MODE_DISC;
        }

        if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
        {
            return error;
@@ -622,14 +627,49 @@ ivas_error ivas_init_encoder(
                }
            }
        }
        else
        {


#if 0
            /* allocate and initialize ISM core-coder handles */
            for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
            {
                if ( ( error = create_sce_enc( st_ivas, sce_id, sep_object_brate_osba[k - 2][st_ivas->nSCE - 1] ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
#endif

            /* allocate and initialize MCT core coder */

            st_ivas->nCPE += st_ivas->hEncoderConfig->nchan_ism >> 1;

            for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
            {
                if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }

            if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
#ifndef OSBA_DISC_OBJ_MCT
        if ( st_ivas->ism_mode == ISM_MODE_NONE )
        {
#endif
            if ( ( error = ivas_osba_enc_open( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }
#ifndef OSBA_DISC_OBJ_MCT
        }
#endif
    }
#endif
    else if ( ivas_format == MC_FORMAT )
+8 −0
Original line number Diff line number Diff line
@@ -242,6 +242,14 @@ ivas_error ivas_ism_enc(
        ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr );
    }

#ifdef OSBA_DISC_OBJ_MCT
    /*only metadata encoding is needed for this case*/
    if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT )
    {
        assert( st_ivas->ism_mode != ISM_MODE_NONE );
        return error;
    }
#endif
    /*------------------------------------------------------------------*
     * CoreCoders encoding
     *-----------------------------------------------------------------*/
Loading