Commit 1a41bab2 authored by vaclav's avatar vaclav
Browse files

issue 759: remove obsolete code in the OSBA encoder + harmonize duplicated...

issue 759: remove obsolete code in the OSBA encoder + harmonize duplicated code; under FIX_759_CODE_COVERAGE_OSBA
parent 031045d7
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -158,6 +158,8 @@
#define OSBA_SPLIT_RENDERING
#endif

#define FIX_759_CODE_COVERAGE_OSBA                      /* VA: issue 759: remove obsolete code in the OSBA encoder */

/* #################### End BE switches ################################## */


+49 −4
Original line number Diff line number Diff line
@@ -60,7 +60,9 @@ ivas_error ivas_enc(
    IVAS_FORMAT ivas_format;
    ENCODER_CONFIG_HANDLE hEncoderConfig;
    BSTR_ENC_HANDLE hMetaData;
#ifndef FIX_759_CODE_COVERAGE_OSBA
    Encoder_State *st; /* used for bitstream handling */
#endif
    int16_t nb_bits_metadata[MAX_SCE + 1];
    float *data_f[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS];
    int32_t ivas_total_brate;
@@ -207,7 +209,7 @@ ivas_error ivas_enc(
            {
                return error;
            }

#ifndef FIX_759_CODE_COVERAGE_OSBA
            st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0];

            /* Write SBA planar flag */
@@ -215,6 +217,7 @@ ivas_error ivas_enc(

            /* Write SBA order */
            push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS );
#endif
        }
        else
        {
@@ -379,15 +382,20 @@ ivas_error ivas_enc(
        {
            if ( st_ivas->nchan_transport == 1 )
            {
#ifndef FIX_759_CODE_COVERAGE_OSBA
                st = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0];
#endif
                hMetaData = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData;
            }
            else
            {
#ifndef FIX_759_CODE_COVERAGE_OSBA
                st = st_ivas->hCPE[0]->hCoreCoder[0];
#endif
                hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData;
            }

#ifndef FIX_759_CODE_COVERAGE_OSBA
            if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_24k4 )
            {
                /* Write SBA planar flag */
@@ -404,13 +412,14 @@ ivas_error ivas_enc(

            /* write the number of objects in ISM_SBA format*/
            push_next_indice( hMetaData, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ );

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

#ifndef FIX_759_CODE_COVERAGE_OSBA
            /* core-coding of transport channels */
            if ( st_ivas->nSCE == 1 )
            {
@@ -433,31 +442,40 @@ ivas_error ivas_enc(
                    return error;
                }
            }
#endif
        }
        else
        {

            n = hEncoderConfig->nchan_ism;
#ifndef FIX_759_CODE_COVERAGE_OSBA
            st = st_ivas->hCPE[0]->hCoreCoder[0];
#endif
            hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData;

#ifndef FIX_759_CODE_COVERAGE_OSBA
            if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE )
            {
                /* write the number of objects in ISM_SBA format*/
                push_next_indice( hMetaData, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ );
            }

#endif
#ifdef FIX_759_CODE_COVERAGE_OSBA
            if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK )
#else
            if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL, st->ini_frame ) ) != IVAS_ERR_OK )
#endif
            {
                return error;
            }

#ifndef FIX_759_CODE_COVERAGE_OSBA
            /* 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 );

#endif
            /* 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 )
            {
@@ -467,6 +485,7 @@ ivas_error ivas_enc(
            /* get SBA TCs */
            ivas_sba_getTCs( &data_f[n], st_ivas, input_frame );

#ifndef FIX_759_CODE_COVERAGE_OSBA
            /* encode SBA transport channels */
            if ( st_ivas->nchan_transport == 1 )
            {
@@ -489,7 +508,33 @@ ivas_error ivas_enc(
                    return error;
                }
            }
#endif
        }

#ifdef FIX_759_CODE_COVERAGE_OSBA
        /* core-coding of transport channels */
        if ( st_ivas->nSCE == 1 )
        {
            if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], 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[0], data_f[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 )
    {
+39 −0
Original line number Diff line number Diff line
@@ -332,10 +332,48 @@ ivas_error ivas_spar_enc(
)
{
    ENCODER_CONFIG_HANDLE hEncoderConfig;
#ifdef FIX_759_CODE_COVERAGE_OSBA
    Encoder_State *st0; /* used for bitstream handling */
#endif
    ivas_error error;

    error = IVAS_ERR_OK;
    hEncoderConfig = st_ivas->hEncoderConfig;
#ifdef FIX_759_CODE_COVERAGE_OSBA
    st0 = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0];

    /* Write SBA signaling bits */
    if ( hEncoderConfig->ivas_format == SBA_FORMAT || ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) )
    {
        /* Write SBA planar flag */
        push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS );

        /* Write SBA order */
        push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS );
    }
    else /* ism_mode == ISM_MODE_NONE */
    {
        if ( hEncoderConfig->ivas_total_brate < IVAS_24k4 )
        {
            /* Write SBA planar flag */
            push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS );

            /* hack to indicate OSBA bitstream at VLBR */
            push_indice( st0->hBstr, IND_SMODE, 0, SBA_ORDER_BITS );
        }
        else
        {
            /* Write SBA order */
            push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS );
        }
    }

    if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT )
    {
        /* write the number of objects in ISM_SBA format*/
        push_indice( hMetaData, IND_ISM_NUM_OBJECTS, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ );
    }
#endif

    /* front VAD */
    if ( ( error = front_vad_spar( st_ivas->hSpar, data_f[0], hEncoderConfig, input_frame ) ) != IVAS_ERR_OK )
@@ -348,6 +386,7 @@ ivas_error ivas_spar_enc(
        ivas_sba_zero_vert_comp( data_f, st_ivas->sba_analysis_order, hEncoderConfig->sba_planar, input_frame );
    }

    /* SPAR encoder */
    if ( ( error = ivas_spar_enc_process( st_ivas, hEncoderConfig, hMetaData, st_ivas->hSpar->front_vad_flag, data_f ) ) != IVAS_ERR_OK )
    {
        return error;