Skip to content
Commits on Source (21)
......@@ -1717,7 +1717,12 @@ static ivas_error initOnFirstGoodFrame(
for ( int16_t j = 0; j < numInitialBadFrames; ++j )
{
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
float delayMs = (float) ( pFullDelayNumSamples[0] ) / (float) ( *delayTimeScale );
if ( ( error = MasaFileWriter_writeFrame( *ppMasaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK )
#else
if ( ( error = MasaFileWriter_writeFrame( *ppMasaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#endif
{
fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( *ppMasaWriter ) );
return error;
......@@ -2101,13 +2106,28 @@ static ivas_error decodeG192(
if ( bsFormat == IVAS_DEC_BS_MASA || bsFormat == IVAS_DEC_BS_MASA_ISM )
{
IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
int16_t fullDelayNumSamples[3];
float delayMs;
/* delayNumSamples is zeroed, and delayNumSamples_orig is updated only on first good frame, so need to re-fetch delay info */
if ( ( error = IVAS_DEC_GetDelay( hIvasDec, fullDelayNumSamples, &delayTimeScale ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
}
#endif
if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
goto cleanup;
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
delayMs = (float) ( fullDelayNumSamples[0] ) / (float) ( delayTimeScale );
if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK )
#else
if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#endif
{
fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) );
goto cleanup;
......@@ -2233,13 +2253,27 @@ static ivas_error decodeG192(
if ( bsFormat == IVAS_DEC_BS_MASA || bsFormat == IVAS_DEC_BS_MASA_ISM )
{
IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
int16_t fullDelayNumSamples[3];
float delayMs;
if ( ( error = IVAS_DEC_GetDelay( hIvasDec, fullDelayNumSamples, &delayTimeScale ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
}
#endif
if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
goto cleanup;
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
delayMs = (float) ( fullDelayNumSamples[0] ) / (float) ( delayTimeScale );
if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK )
#else
if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#endif
{
fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) );
goto cleanup;
......@@ -2785,13 +2819,28 @@ static ivas_error decodeVoIP(
if ( bsFormat == IVAS_DEC_BS_MASA || bsFormat == IVAS_DEC_BS_MASA_ISM )
{
IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
int16_t fullDelayNumSamples[3];
float delayMs;
/* delayNumSamples_orig is fetched only for the first good frame, but here the delay can change between frames, so need to re-fetch */
if ( ( error = IVAS_DEC_GetDelay( hIvasDec, fullDelayNumSamples, &delayTimeScale ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
}
#endif
if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 1 ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
goto cleanup;
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
delayMs = (float) ( fullDelayNumSamples[0] ) / (float) ( delayTimeScale );
if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK )
#else
if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#endif
{
fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) );
goto cleanup;
......
......@@ -1987,8 +1987,11 @@ int main(
}
}
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMetaOutput, NULL ) ) != IVAS_ERR_OK ) /* NULL -> use default metadata delay settings */
#else
if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMetaOutput ) ) != IVAS_ERR_OK )
#endif
{
fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) );
}
......
......@@ -147,7 +147,13 @@ typedef enum
RENDERER_NON_DIEGETIC_DOWNMIX,
RENDERER_OSBA_STEREO,
RENDERER_OSBA_AMBI,
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
RENDERER_OSBA_LS,
RENDERER_OMASA_OBJECT_EXT,
RENDERER_OMASA_MIX_EXT
#else
RENDERER_OSBA_LS
#endif
} RENDERER_TYPE;
#define MAX_FREQUENCY_BANDS 64
......
......@@ -156,6 +156,33 @@ void ivas_omasa_rearrange_channels_fx(
const Word16 output_frame /* i : output frame length per channel */
);
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
ivas_error ivas_omasa_combine_separate_ism_with_masa_open_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
void ivas_omasa_combine_separate_ism_with_masa_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
Word32 *output[], /* o : output synthesis signal */
Word16 *output_q, /* i/o: output Q value */
const int16_t nchan_ism, /* i : number of ISMs */
const int16_t output_frame /* i : output frame length per channel */
);
ivas_error ivas_omasa_render_objects_from_mix_open_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
void ivas_omasa_render_objects_from_mix_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
Word32 *output[], /* o : output synthesis signal */
const int16_t nchan_ism, /* i : number of ISMs */
const int16_t output_frame, /* i : output frame length per channel */
Word16 *output_q /* i/o: output Q value */
);
#endif
ivas_error ivas_omasa_ism_metadata_dec_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const Word32 ism_total_brate, /* i : ISM total bitrate */
......
......@@ -157,18 +157,17 @@
#ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM
#endif
#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */
#define NONBE_FIX_984_OMASA_EXT_OUTPUT /* Nokia: issue #984: complete the OMASA EXT output implementation */
#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */
#define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */
#define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */
#define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */
#define FIX_1831_REVERB_REGRESSION /* Philips: fixes reverb regression issues */
#define FIX_1835_REVERB_ACTIVATION /* FhG: Modified reverberation activation logic and corrected factEQ calculation */
#define NON_BE_FIX_EVS_USAN_ERR_IN_WAVEADJUST /* FhG: address issue 1037 */
#define FIX_1038_OFFSET_TO_NULL_PTR_IN_EVS_TCX_BFI /* FhG: move setting of pointers for parameter decoding so they are skipped in lost frames when they are not needed */
/* #################### End BASOP porting switches ############################ */
#endif
......@@ -718,12 +718,20 @@ void decoder_LPD_fx(
FOR( k = 0; k < 2; k++ )
{
#ifndef FIX_1038_OFFSET_TO_NULL_PTR_IN_EVS_TCX_BFI
/* Set pointer to parameters */
prm = param + ( k * DEC_NPRM_DIV );
/* Stability Factor */
#endif
IF( bfi == 0 )
{
#ifdef FIX_1038_OFFSET_TO_NULL_PTR_IN_EVS_TCX_BFI
/* Set pointer to parameters */
prm = param + ( k * DEC_NPRM_DIV );
/* Stability Factor */
#endif
st->stab_fac_fx = lsf_stab_fx( &lsf[( ( k + 1 ) ) * M], &lsf[k * M], 0, L_FRAME );
move16();
}
......
......@@ -4411,7 +4411,15 @@ void decoder_tcx_invQ_fx(
tnsSize = 0;
move16();
#ifndef FIX_1038_OFFSET_TO_NULL_PTR_IN_EVS_TCX_BFI
prm_target = NULL; /* just to suppress MSVC warnigs */
#else
/* just to suppress MSVC warnigs */
prm_target = NULL;
prm_ltp = NULL;
prm_tns = NULL;
prm_sqQ = NULL;
#endif
/*-----------------------------------------------------------------*
* Initializations
......@@ -4435,8 +4443,10 @@ void decoder_tcx_invQ_fx(
move16();
}
#ifndef FIX_1038_OFFSET_TO_NULL_PTR_IN_EVS_TCX_BFI
prm_ltp = &prm[1 + NOISE_FILL_RANGES];
prm_tns = prm_ltp + LTPSIZE;
#endif
gainCompensate = ONE_IN_Q14;
move16();
......@@ -4452,6 +4462,10 @@ void decoder_tcx_invQ_fx(
IF( !bfi )
{
#ifdef FIX_1038_OFFSET_TO_NULL_PTR_IN_EVS_TCX_BFI
prm_ltp = &prm[1 + NOISE_FILL_RANGES];
prm_tns = prm_ltp + LTPSIZE;
#endif
index = prm[0];
move16();
......@@ -4473,9 +4487,11 @@ void decoder_tcx_invQ_fx(
move16();
}
#ifndef FIX_1038_OFFSET_TO_NULL_PTR_IN_EVS_TCX_BFI
prm_hm = prm_tns + tnsSize;
prm_sqQ = prm_hm + NPRM_CTX_HM;
*prm_sqQ1 = prm_sqQ;
#endif
/*-----------------------------------------------------------*
* Spectrum data *
......@@ -4483,6 +4499,11 @@ void decoder_tcx_invQ_fx(
IF( !bfi )
{
#ifdef FIX_1038_OFFSET_TO_NULL_PTR_IN_EVS_TCX_BFI
prm_hm = prm_tns + tnsSize;
prm_sqQ = prm_hm + NPRM_CTX_HM;
*prm_sqQ1 = prm_sqQ;
#endif
/*-----------------------------------------------------------*
* Context HM *
*-----------------------------------------------------------*/
......
......@@ -386,6 +386,26 @@ ivas_error ivas_dec_setup(
st_ivas->nchan_transport = 1;
move16();
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
/* this should be non-zero if original input format was MASA_ISM_FORMAT */
st_ivas->nchan_ism = add( st_ivas->bit_stream[L_sub( res_dec, 3 )], shl( st_ivas->bit_stream[L_sub( res_dec, 2 )], 1 ) );
IF( GT_16( st_ivas->nchan_ism, 0 ) )
{
/* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */
test();
IF( EQ_16( st_ivas->nchan_transport, 2 ) && EQ_16( st_ivas->nchan_ism, 3 ) )
{
st_ivas->nchan_ism = 4;
move16();
}
/* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 */
st_ivas->nchan_transport = 2;
element_mode_flag = 1;
move16();
move16();
}
#endif
IF( st_ivas->ini_frame > 0 )
{
......@@ -1232,6 +1252,9 @@ ivas_error ivas_init_decoder_fx(
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
#endif
IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 );
......@@ -1239,7 +1262,11 @@ ivas_error ivas_init_decoder_fx(
hDecoderConfig->nchan_out = add( hDecoderConfig->nchan_out, st_ivas->nchan_ism );
move16();
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
#else
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
#endif
{
hDecoderConfig->nchan_out = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
move16();
......@@ -2391,7 +2418,39 @@ ivas_error ivas_init_decoder_fx(
return error;
}
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) )
{
/* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
error = ivas_omasa_render_objects_from_mix_open_fx( st_ivas );
move32();
IF( NE_32( error, IVAS_ERR_OK ) )
{
return error;
}
error = ivas_spat_hSpatParamRendCom_config_fx( &st_ivas->hSpatParamRendCom, DIRAC_OPEN, 0,
st_ivas->ivas_format, st_ivas->mc_mode, output_Fs, 0, 0 );
move32();
IF( NE_32( error, IVAS_ERR_OK ) )
{
return error;
}
}
IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) )
{
/* Allocate 'hIsmRendererData' handle */
error = ivas_omasa_combine_separate_ism_with_masa_open_fx( st_ivas );
move32();
IF( NE_32( error, IVAS_ERR_OK ) )
{
return error;
}
}
#endif
test();
test();
test();
......@@ -3360,6 +3419,19 @@ void ivas_init_dec_get_num_cldfb_instances(
move16();
}
BREAK;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
case RENDERER_OMASA_OBJECT_EXT:
*numCldfbAnalyses = st_ivas->nchan_transport;
*numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out;
move16();
move16();
break;
case RENDERER_OMASA_MIX_EXT:
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
*numCldfbSyntheses = 0;
move16();
break;
#endif
default:
assert( 0 && "Renderer not handled for CLDFB reservation." );
}
......@@ -3621,6 +3693,19 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx(
move16();
}
BREAK;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
case RENDERER_OMASA_OBJECT_EXT:
*numCldfbAnalyses = st_ivas->nchan_transport;
*numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out;
move16();
move16();
break;
case RENDERER_OMASA_MIX_EXT:
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
*numCldfbSyntheses = 0;
move16();
break;
#endif
default:
assert( 0 && "Renderer not handled for CLDFB reservation." );
}
......@@ -3777,6 +3862,7 @@ static ivas_error doSanityChecks_IVAS(
}
}
#ifndef NONBE_FIX_984_OMASA_EXT_OUTPUT
IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
test();
......@@ -3786,7 +3872,7 @@ static ivas_error doSanityChecks_IVAS(
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" );
}
}
#endif
return IVAS_ERR_OK;
}
......@@ -668,6 +668,20 @@ ivas_error ivas_jbm_dec_tc_fx(
{
Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) );
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
/* external output */
IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) &&
EQ_32( st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) )
{
FOR( n = 0; n < st_ivas->nchan_ism; n++ )
{
set_zero_fx( p_output_fx[add( st_ivas->nchan_transport, n )], output_frame );
}
ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, output_frame );
}
#endif
}
ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
{
......@@ -792,6 +806,22 @@ ivas_error ivas_jbm_dec_tc_fx(
}
ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame );
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
{
/* Convert separate object to MASA, combine with the original MASA, and output combined MASA + empty objects. */
ivas_omasa_combine_separate_ism_with_masa_fx( st_ivas, p_output_fx, &output_q, st_ivas->nchan_ism, output_frame );
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
{
/* Extract objects from MASA, output MASA + all objects (i.e., extracted and separated objects) */
ivas_omasa_render_objects_from_mix_fx( st_ivas, p_output_fx, st_ivas->nchan_ism, output_frame, &output_q );
}
#else
/* sanity check in case of bitrate switching */
IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
......@@ -799,9 +829,7 @@ ivas_error ivas_jbm_dec_tc_fx(
}
ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame );
output_q = 11;
move16();
#endif
ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas );
}
......@@ -1706,6 +1734,16 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
}
ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) )
{
ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots );
}
ELSE
{
#endif
test();
IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
......@@ -1729,6 +1767,9 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
{
ivas_ism_dec_digest_tc_fx( st_ivas );
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
}
#endif
if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC )
{
......@@ -2110,6 +2151,9 @@ ivas_error ivas_jbm_dec_render_fx(
move16();
test();
test();
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
#endif
IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
{
test();
......@@ -2129,6 +2173,14 @@ ivas_error ivas_jbm_dec_render_fx(
{
ivas_omasa_dirac_rend_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ||
EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) )
{
ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx );
ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, *nSamplesRendered );
}
#endif
}
ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
{
......@@ -3927,6 +3979,10 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode(
case RENDERER_PARAM_ISM:
case RENDERER_BINAURAL_MIXER_CONV:
case RENDERER_BINAURAL_MIXER_CONV_ROOM:
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
case RENDERER_OMASA_OBJECT_EXT:
case RENDERER_OMASA_MIX_EXT:
#endif
case RENDERER_OSBA_AMBI:
case RENDERER_OSBA_LS:
buffer_mode = TC_BUFFER_MODE_RENDERER;
......
......@@ -320,7 +320,33 @@ ivas_error ivas_masa_decode_fx(
}
}
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
/* read 2 bits:
'00' - MASA format at the encoder
'01' - MASA_ISM_FORMAT at the encoder, with 1 object
'10' - MASA_ISM_FORMAT at the encoder, with 2 objects
'11' - MASA_ISM_FORMAT at the encoder, with 3 or 4 objects
reading if 3 or 4 object is performed later
*/
byteBuffer = st->bit_stream[st->next_bit_pos];
move16();
st->next_bit_pos = sub( st->next_bit_pos, 1 );
byteBuffer = add( byteBuffer, shl( st->bit_stream[st->next_bit_pos], 1 ) );
st->next_bit_pos = sub( st->next_bit_pos, 1 );
test();
IF( EQ_16( byteBuffer, 0 ) && EQ_32( ivas_format, MASA_FORMAT ) )
{
hMasa->config.input_ivas_format = MASA_FORMAT;
move32();
}
ELSE
{
hMasa->config.input_ivas_format = MASA_ISM_FORMAT;
move32();
}
#else
/* read the MASA_ISM_FORMAT bit */
byteBuffer = st->bit_stream[( st->next_bit_pos )--];
move16();
......@@ -337,6 +363,7 @@ ivas_error ivas_masa_decode_fx(
/* reserved bit */
byteBuffer = st->bit_stream[( st->next_bit_pos )--];
move16();
#endif
*nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS );
/* read number of directions */
......@@ -418,7 +445,8 @@ ivas_error ivas_masa_decode_fx(
{
IF( st_ivas->hDirAC != NULL )
{
*nb_bits_read = add( *nb_bits_read, ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos,
*nb_bits_read = add( *nb_bits_read,
ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos,
st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ) );
move16();
FOR( obj = 0; obj <= st_ivas->nchan_ism; obj++ )
......@@ -439,6 +467,14 @@ ivas_error ivas_masa_decode_fx(
}
}
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) )
{
*nb_bits_read = add( *nb_bits_read, ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData,
st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos,
st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ) );
}
#endif
ELSE
{
*nb_bits_read = add( *nb_bits_read, ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos,
......@@ -587,7 +623,19 @@ ivas_error ivas_masa_decode_fx(
ivas_qmetadata_to_dirac_fx( hQMetaData, st_ivas->hDirAC, hMasa, st_ivas->hSpatParamRendCom, ivas_total_brate, ivas_format, 0, 0 );
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) )
{
Word16 index = add( st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, MAX_PARAM_SPATIAL_SUBFRAMES );
IF( GE_16( index, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ) )
{
index = sub( index, st_ivas->hSpatParamRendCom->dirac_md_buffer_length );
}
st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx = index;
move16();
}
#endif
IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
IF( hQMetaData->q_direction == NULL )
......@@ -743,7 +791,18 @@ ivas_error ivas_masa_dec_open_fx(
ism_total_brate = 0;
move32();
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
/* ISM metadata */
test();
test();
if ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) &&
st_ivas->hIsmMetaData[0] != NULL &&
EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
/* these are not needed -> clean. EXT metafile writer in OMASA needs only the number of ISMs and writes default null-data */
ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
}
#endif
test();
test();
test();
......@@ -826,7 +885,10 @@ ivas_error ivas_masa_dec_open_fx(
nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
nchan_to_allocate = nchan_transport;
move16();
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
test();
#endif
test();
test();
IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
......@@ -836,6 +898,15 @@ ivas_error ivas_masa_dec_open_fx(
nchan_to_allocate = 1;
move16();
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) &&
( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) ||
EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) )
{
nchan_transport = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
nchan_to_allocate = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
}
#endif
ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
{
/* addtl channel for CNG */
......@@ -1830,8 +1901,18 @@ ivas_error ivas_masa_dec_reconfigure_fx(
IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
{
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
IF( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
move16();
st_ivas->nchan_ism = 0; /* Initialization if it has not been already read from the end of the bitstream at the same time
with reading of the format: nchan_ism is needed in MASA format because for the EXT output in
MASA-only (pre-rendering mode of OMASA) the number of ISMs to output correct number of empty objects is needed */
}
#else
st_ivas->nchan_ism = 0;
move16();
#endif
st_ivas->ism_mode = ISM_MODE_NONE;
move16();
}
......@@ -1854,6 +1935,10 @@ ivas_error ivas_masa_dec_reconfigure_fx(
test();
test();
test();
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
test();
#endif
IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
{
IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
......@@ -1894,7 +1979,15 @@ ivas_error ivas_masa_dec_reconfigure_fx(
/* addtl channel for CNG */
tc_nchan_to_allocate = add( tc_nchan_to_allocate, 1 );
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) &&
( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) ||
EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) )
{
tc_nchan_transport = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
tc_nchan_to_allocate = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
}
#endif
test();
test();
IF( NE_16( tc_nchan_transport, st_ivas->hTcBuffer->nchan_transport_jbm ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( buffer_mode_new, st_ivas->hTcBuffer->tc_buffer_mode ) )
......@@ -3332,6 +3425,14 @@ static Word16 ivas_decode_masaism_metadata_fx(
hMasaIsmData->energy_ratio_ism_fx[dir][meta_write_index][b] = energy_ratio_ism_fx[i][band][dir];
move32();
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
IF( hMasaIsmData->hExtData != NULL )
{
hMasaIsmData->hExtData->masa_render_masa_to_total[meta_write_index][b] =
hMasaIsmData->masa_to_total_energy_ratio_fx[i][band];
move32();
}
#endif
}
}
}
......
This diff is collapsed.
......@@ -479,8 +479,26 @@ void ivas_renderer_select(
}
ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
{
*renderer_type = RENDERER_OMASA_OBJECT_EXT;
move32();
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
{
*renderer_type = RENDERER_OMASA_MIX_EXT;
move32();
}
ELSE
{
*renderer_type = RENDERER_DISABLE;
move32();
}
#else
*renderer_type = RENDERER_DISABLE;
move16();
#endif
}
}
ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
......
......@@ -771,7 +771,12 @@ void ivas_sba_dec_digest_tc_fx(
Word16 ch_idx, nchan_transport;
/* set the md map */
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
IF( st_ivas->hDirAC != NULL || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) )
#else
IF( st_ivas->hDirAC )
#endif
{
ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots );
}
......
......@@ -926,6 +926,25 @@ typedef struct ivas_masa_decoder_struct
} MASA_DECODER, *MASA_DECODER_HANDLE;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
/* Data structure for MASA_ISM EXT rendering */
typedef struct ivas_masa_ism_ext_data_structure
{
Word16 prev_idx_separated_ism; // Q0 (Integer)
Word32 prev_panning_gains[MAX_NUM_OBJECTS][2]; // Q31
Word16 ism_render_proto_energy_exp[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX]; // Q0 (Integer exponent)
Word32 ism_render_proto_energy_frac[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX]; // Q31
Word16 ism_render_target_energy_exp[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX]; // Q0 (Integer exponent)
Word32 ism_render_target_energy_frac[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX]; // Q31
Word16 masa_render_proto_energy_exp[CLDFB_NO_CHANNELS_MAX]; // Q0 (Integer exponent)
Word32 masa_render_proto_energy_frac[CLDFB_NO_CHANNELS_MAX]; // Q31
Word16 masa_render_target_energy_exp[CLDFB_NO_CHANNELS_MAX]; // Q0 (Integer exponent)
Word32 masa_render_target_energy_frac[CLDFB_NO_CHANNELS_MAX]; // Q31
Word32 masa_render_masa_to_total[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; // Q30
} MASA_ISM_EXT_DATA, *MASA_ISM_EXT_DATA_HANDLE;
#endif
/* Data structure for MASA_ISM rendering */
typedef struct ivas_masa_ism_data_structure
{
......@@ -955,7 +974,9 @@ typedef struct ivas_masa_ism_data_structure
Word32 **delayBuffer_fx; /* Q11 */
Word16 delayBuffer_size;
Word16 delayBuffer_nchan;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
MASA_ISM_EXT_DATA_HANDLE hExtData;
#endif
} MASA_ISM_DATA, *MASA_ISM_DATA_HANDLE;
......
......@@ -1987,14 +1987,37 @@ ivas_error IVAS_DEC_GetNumObjects(
UWord16 *numObjects /* o : number of objects for which the decoder has been configured */
)
{
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
Word16 is_masa_ism;
is_masa_ism = 0;
move16();
#endif
test();
IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
{
return IVAS_ERR_UNEXPECTED_NULL_POINTER;
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
IF( hIvasDec->st_ivas->hMasa != NULL )
{
IF( EQ_32( hIvasDec->st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) )
{
is_masa_ism = 1;
move16();
}
}
test();
test();
test();
IF( EQ_32( hIvasDec->st_ivas->ivas_format, ISM_FORMAT ) ||
EQ_32( hIvasDec->st_ivas->ivas_format, SBA_ISM_FORMAT ) ||
EQ_32( hIvasDec->st_ivas->ivas_format, MASA_ISM_FORMAT ) ||
EQ_16( is_masa_ism, 1 ) )
#else
test();
test();
IF( EQ_16( (Word16) hIvasDec->st_ivas->ivas_format, ISM_FORMAT ) || EQ_16( (Word16) hIvasDec->st_ivas->ivas_format, SBA_ISM_FORMAT ) || EQ_16( (Word16) hIvasDec->st_ivas->ivas_format, MASA_ISM_FORMAT ) )
#endif
{
*numObjects = hIvasDec->st_ivas->nchan_ism;
}
......@@ -2029,7 +2052,14 @@ ivas_error IVAS_DEC_GetFormat(
*format = IVAS_DEC_BS_UNKOWN;
}
move32();
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
if ( EQ_32( *format, IVAS_DEC_BS_MASA ) && EQ_32( hIvasDec->st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) )
{
*format = IVAS_DEC_BS_MASA_ISM;
move32();
}
#endif
return IVAS_ERR_OK;
}
......@@ -2140,7 +2170,11 @@ ivas_error IVAS_DEC_GetObjectMetadata(
{
Decoder_Struct *st_ivas;
ISM_METADATA_HANDLE hIsmMeta;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
Word16 is_masa_ism;
is_masa_ism = 0;
move16();
#endif
test();
IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
{
......@@ -2148,9 +2182,27 @@ ivas_error IVAS_DEC_GetObjectMetadata(
}
st_ivas = hIvasDec->st_ivas;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
IF( hIvasDec->st_ivas->hMasa != NULL )
{
IF( EQ_32( hIvasDec->st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) )
{
is_masa_ism = 1;
move16();
}
}
test();
test();
test();
if ( NE_32( st_ivas->ivas_format, ISM_FORMAT ) &&
NE_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) &&
NE_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) &&
EQ_16( is_masa_ism, 0 ) )
#else
test();
test();
IF( NE_16( st_ivas->ivas_format, ISM_FORMAT ) && NE_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
#endif
{
return IVAS_ERR_WRONG_MODE;
}
......@@ -2161,8 +2213,16 @@ ivas_error IVAS_DEC_GetObjectMetadata(
}
hIsmMeta = st_ivas->hIsmMetaData[objectIdx];
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
test();
test();
IF( hIsmMeta == NULL ||
EQ_16( zero_flag, 1 ) ||
( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) )
#else
IF( hIsmMeta == NULL || zero_flag )
#endif
{
metadata->azimuth_fx = 0; // Q22
metadata->elevation_fx = 0; // Q22
......@@ -2834,9 +2894,13 @@ ivas_error IVAS_DEC_GetDelay(
out_fs_fx = FS_48K_IN_NS_Q31;
}
move32();
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
nSamples[1] = NS2SA_FX2( hDecoderConfig->output_Fs, get_delay_fx( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0], hDecoderConfig->output_config ) );
move16();
#else
nSamples[1] = NS2SA_FX2( hDecoderConfig->output_Fs, get_delay_fx( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], hDecoderConfig->output_config ) );
move16();
#endif
nSamples[2] = extract_l( W_round64_L( W_mult0_32_32( L_shl( st_ivas->binaural_latency_ns, 1 ), out_fs_fx ) ) );
move16();
nSamples[0] = add( nSamples[1], nSamples[2] );
......
......@@ -930,7 +930,20 @@ void concealment_decode_fix(
/* sign randomization */
FOR( i = 0; i < N; i++ )
{
#ifdef NON_BE_FIX_EVS_USAN_ERR_IN_WAVEADJUST
Word16 rnd;
rnd = own_random_fix( seed );
IF( GE_16( rnd, 0 ) )
{
sign = 1;
}
ELSE IF( LT_16( rnd, 0 ) )
{
sign = -1;
}
#else
sign = add( shl( shr( own_random_fix( seed ), 15 ), 1 ), 1 );
#endif
if ( EQ_16( sign, -1 ) )
{
invkoef[i] = L_negate( invkoef[i] );
......
......@@ -533,8 +533,28 @@ ivas_error ivas_masa_encode_fx(
}
ELSE
{
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) )
{
/* use the MASA number of transport channels bit to signal if there are 3 or 4 objects */
IF( EQ_16( nchan_ism, 4 ) )
{
push_next_indice( hMetaData, 1, MASA_TRANSP_BITS );
}
ELSE
{
push_next_indice( hMetaData, 0, MASA_TRANSP_BITS );
}
}
ELSE
{
#endif
/* write the number of MASA transport channels */
push_next_indice( hMetaData, sub( nchan_transport, 1 ), MASA_TRANSP_BITS );
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
}
#endif
hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_TRANSP_BITS );
move16();
}
......@@ -542,12 +562,25 @@ ivas_error ivas_masa_encode_fx(
test();
IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) )
{
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
IF( LE_16( nchan_ism, 3 ) )
{
push_next_indice( hMetaData, nchan_ism, MASA_HEADER_BITS );
}
ELSE
{
push_next_indice( hMetaData, sub( nchan_ism, 1 ), MASA_HEADER_BITS );
}
hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_HEADER_BITS );
move16();
#else
/* signal MASA_ISM_FORMAT to decoder */
push_next_indice( hMetaData, 1, 1 );
/* write reserved bit */
push_next_indice( hMetaData, 0, MASA_HEADER_BITS - 1 );
hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_HEADER_BITS );
move16();
#endif
}
ELSE
{
......
......@@ -220,6 +220,7 @@ void diffuse_meta_merge_1x1_fx(
{
Word32 new_dir_ratio_fx, new_diff_ratio_fx;
Word16 new_dir_ratio_e;
outMeta->directionIndex[0][sf][band] = inMetaISM->directionIndex[0][sf][band];
move16();
outMeta->directToTotalRatio[0][sf][band] = inMetaISM->directToTotalRatio[0][sf][band];
......@@ -252,7 +253,8 @@ void diffuse_meta_merge_1x1_fx(
move16();
}
outMeta->directToTotalRatio[0][sf][band] = (UWord8) extract_l( L_shr( Mpy_32_16_1( new_dir_ratio_fx, UINT8_MAX ) /* (31 - new_dir_ratio_e) - 15*/, sub( 31 - 15, new_dir_ratio_e ) ) );
outMeta->directToTotalRatio[0][sf][band] = (UWord8) extract_l( L_shr( Mpy_32_16_1( new_dir_ratio_fx, UINT8_MAX ) /* (31 - new_dir_ratio_e) - 15*/, sub( 31 - 15, new_dir_ratio_e ) ) ); /* Q0 */
move16();
IF( GT_16( sub( 31, new_dir_ratio_e ), Q30 ) )
{
......
......@@ -41,11 +41,20 @@
typedef struct masaMetaDelayStorage
{
MASA_DECRIPTIVE_META descriptiveMeta;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
uint16_t directionIndex[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR + 1][MASA_FREQUENCY_BANDS];
uint8_t directToTotalRatio[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR + 1][MASA_FREQUENCY_BANDS];
uint8_t spreadCoherence[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR + 1][MASA_FREQUENCY_BANDS];
uint8_t surroundCoherence[DELAY_MASA_PARAM_DEC_SFR + 1][MASA_FREQUENCY_BANDS];
uint8_t diffuseToTotalRatio[DELAY_MASA_PARAM_DEC_SFR + 1][MASA_FREQUENCY_BANDS];
uint8_t prevDelay;
#else
uint16_t directionIndex[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR][MASA_FREQUENCY_BANDS];
uint8_t directToTotalRatio[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR][MASA_FREQUENCY_BANDS];
uint8_t spreadCoherence[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR][MASA_FREQUENCY_BANDS];
uint8_t surroundCoherence[DELAY_MASA_PARAM_DEC_SFR][MASA_FREQUENCY_BANDS];
uint8_t diffuseToTotalRatio[DELAY_MASA_PARAM_DEC_SFR][MASA_FREQUENCY_BANDS];
#endif
} MASA_META_DELAY_STORAGE;
......@@ -88,14 +97,93 @@ static void getExtMasaMetadataFileName(
static void delayMasaMetadata(
MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: New input metadata which is inplace replaced with delayed metadata frame */
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
MASA_META_DELAY_STORAGE *delayStorage, /* i/o: Storage for 15 ms of metadata and related descriptive metadata */
uint8_t delayNsf
#else
MASA_META_DELAY_STORAGE *delayStorage /* i/o: Storage for 10 ms of metadata and related descriptive metadata */
#endif
)
{
int16_t dir, sf, band;
uint8_t currentNumberOfDirections;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
int16_t storeReadOffset;
#endif
/* Move meta to delay and output. Always use two directions as the metadata is prepared to contain zero energy second direction
* if there is 1dir meta. */
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
/* stable state expected results delay change expected results
delayNsf = 2 delayNsf = 3 delayNsf = 3 (from 2) delayNsf = 2 (from 3)
ext[0] = delayStorage[0] (prev ext[2]) ext[0] = delayStorage[0] (prev ext[1]) ext[0] = delayStorage[0] (prev ext[2]) ext[0] = delayStorage[1] (prev ext[2])
ext[1] = delayStorage[1] (prev ext[3]) ext[1] = delayStorage[1] (prev ext[2]) ext[1] = delayStorage[1] (prev ext[3]) ext[1] = delayStorage[2] (prev ext[3])
ext[2] = ext[0] ext[2] = delayStorage[2] (prev ext[3]) ext[2] = delayStorage[1] (prev ext[3]) ext[2] = ext[0]
ext[3] = ext[1] ext[3] = ext[0] ext[3] = ext[0] ext[3] = ext[0]
delayStorage[0] = ext[2] delayStorage[0] = ext[1] delayStorage[0] = ext[1] delayStorage[0] = ext[2]
delayStorage[1] = ext[3] delayStorage[1] = ext[2] delayStorage[1] = ext[2] delayStorage[1] = ext[3]
delayStorage[2] = ext[3] delayStorage[2] = ext[3]
*/
storeReadOffset = delayStorage->prevDelay > delayNsf ? delayStorage->prevDelay - delayNsf : 0; /* delay decreases: read later from storage -> discard one sf */
for ( sf = 0; sf < delayNsf; sf++ )
{
for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
{
uint16_t temp_u16;
uint8_t temp_u8;
int16_t toStoreIdx, reOrgIdx, storeReadIdx;
toStoreIdx = sf + MAX_PARAM_SPATIAL_SUBFRAMES - delayNsf;
reOrgIdx = sf + delayNsf;
/* when switching to longer delay, repeat the last valid sf to fill the gap */
storeReadIdx = ( ( sf + storeReadOffset ) < delayStorage->prevDelay ) ? sf + storeReadOffset : delayStorage->prevDelay - 1;
for ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
{
temp_u16 = delayStorage->directionIndex[dir][storeReadIdx][band];
delayStorage->directionIndex[dir][sf][band] = extOutMeta->directionIndex[dir][toStoreIdx][band];
if ( reOrgIdx < MAX_PARAM_SPATIAL_SUBFRAMES )
{
extOutMeta->directionIndex[dir][reOrgIdx][band] = extOutMeta->directionIndex[dir][sf][band];
}
extOutMeta->directionIndex[dir][sf][band] = temp_u16;
temp_u8 = delayStorage->directToTotalRatio[dir][storeReadIdx][band];
delayStorage->directToTotalRatio[dir][sf][band] = extOutMeta->directToTotalRatio[dir][toStoreIdx][band];
if ( reOrgIdx < MAX_PARAM_SPATIAL_SUBFRAMES )
{
extOutMeta->directToTotalRatio[dir][reOrgIdx][band] = extOutMeta->directToTotalRatio[dir][sf][band];
}
extOutMeta->directToTotalRatio[dir][sf][band] = temp_u8;
temp_u8 = delayStorage->spreadCoherence[dir][storeReadIdx][band];
delayStorage->spreadCoherence[dir][sf][band] = extOutMeta->spreadCoherence[dir][toStoreIdx][band];
if ( reOrgIdx < MAX_PARAM_SPATIAL_SUBFRAMES )
{
extOutMeta->spreadCoherence[dir][reOrgIdx][band] = extOutMeta->spreadCoherence[dir][sf][band];
}
extOutMeta->spreadCoherence[dir][sf][band] = temp_u8;
}
temp_u8 = delayStorage->surroundCoherence[storeReadIdx][band];
delayStorage->surroundCoherence[sf][band] = extOutMeta->surroundCoherence[toStoreIdx][band];
if ( reOrgIdx < MAX_PARAM_SPATIAL_SUBFRAMES )
{
extOutMeta->surroundCoherence[reOrgIdx][band] = extOutMeta->surroundCoherence[sf][band];
}
extOutMeta->surroundCoherence[sf][band] = temp_u8;
temp_u8 = delayStorage->diffuseToTotalRatio[storeReadIdx][band];
delayStorage->diffuseToTotalRatio[sf][band] = extOutMeta->diffuseToTotalRatio[toStoreIdx][band];
if ( reOrgIdx < MAX_PARAM_SPATIAL_SUBFRAMES )
{
extOutMeta->diffuseToTotalRatio[reOrgIdx][band] = extOutMeta->diffuseToTotalRatio[sf][band];
}
extOutMeta->diffuseToTotalRatio[sf][band] = temp_u8;
}
}
#else
for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES - DELAY_MASA_PARAM_DEC_SFR; sf++ )
{
for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
......@@ -131,6 +219,7 @@ static void delayMasaMetadata(
extOutMeta->diffuseToTotalRatio[sf][band] = temp_u8;
}
}
#endif
/* Finalize descriptive meta by using new frame except for number of directions which is the larger of the two */
currentNumberOfDirections = extOutMeta->descriptiveMeta.numberOfDirections;
......@@ -140,6 +229,9 @@ static void delayMasaMetadata(
}
delayStorage->descriptiveMeta.numberOfDirections = currentNumberOfDirections;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
delayStorage->prevDelay = delayNsf;
#endif
return;
}
......@@ -182,6 +274,9 @@ ivas_error MasaFileWriter_open(
if ( !delayCompensationEnabled )
{
self->delayStorage = calloc( sizeof( MASA_META_DELAY_STORAGE ), 1 );
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
self->delayStorage->prevDelay = DELAY_MASA_PARAM_DEC_SFR;
#endif
}
*masaWriter = self;
......@@ -198,7 +293,12 @@ ivas_error MasaFileWriter_open(
ivas_error MasaFileWriter_writeFrame(
MasaFileWriter *self, /* i/o: MasaFileWriter handle */
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta, /* i/o: MASA ext out meta handle to be written */
const float *decDelay /* i : decoding audio delay */
#else
MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta /* i/o: MASA ext out meta handle to be written */
#endif
)
{
if ( self == NULL )
......@@ -209,7 +309,17 @@ ivas_error MasaFileWriter_writeFrame(
uint16_t descMetaTemp = 0;
int16_t i, sf, dir, numDirections;
uint8_t writeTempOther[MASA_FREQUENCY_BANDS];
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
/* If delay storage has been reserved, then we are in the normal mode for the decoder
* (i.e., no delay compensation for PCM) which means that metadata should be delayed
* by two or three subframes (10 or 15 ms). Descriptive metadata is a combined result. */
if ( self->delayStorage )
{
uint8_t delayFrames = (uint8_t) ( (int32_t) ( ( *decDelay ) * 48000 ) / L_SPATIAL_SUBFR_48k );
delayMasaMetadata( hMasaExtOutMeta, self->delayStorage, delayFrames );
}
#else
/* If delay storage has been reserved, then we are in the normal mode for the decoder
* (i.e., no delay compensation for PCM) which means that metadata should be delayed
* by two subframes (10 ms). Descriptive metadata is a combined result. */
......@@ -217,7 +327,7 @@ ivas_error MasaFileWriter_writeFrame(
{
delayMasaMetadata( hMasaExtOutMeta, self->delayStorage );
}
#endif
numDirections = hMasaExtOutMeta->descriptiveMeta.numberOfDirections + 1;
if ( fwrite( &( hMasaExtOutMeta->descriptiveMeta.formatDescriptor ), sizeof( uint8_t ), 8, self->file ) != 8 )
......
......@@ -48,7 +48,12 @@ ivas_error MasaFileWriter_open(
ivas_error MasaFileWriter_writeFrame(
MasaFileWriter *self, /* i/o: MasaFileWriter handle */
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta, /* i/o: MASA ext out meta handle to be written */
const float *decDelay /* i : decoding audio delay */
#else
IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta /* i/o: MASA ext out meta handle to be written */
#endif
);
void MasaFileWriter_close(
......