From 1a41bab204b63922c55ec9af099c41b4d281882d Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 4 Sep 2023 10:44:11 +0200 Subject: [PATCH] issue 759: remove obsolete code in the OSBA encoder + harmonize duplicated code; under FIX_759_CODE_COVERAGE_OSBA --- lib_com/options.h | 2 ++ lib_enc/ivas_enc.c | 53 ++++++++++++++++++++++++++++++++++--- lib_enc/ivas_spar_encoder.c | 39 +++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d945683e41..3ed92d5481 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -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 ################################## */ diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 8096199382..0f5721b591 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -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 ) { diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 476a1f39c3..d518113ce5 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -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; -- GitLab