Commit 1273b6f8 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_382_MASA_META_FRAMING_ASYNC

parent a98eacdc
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -1192,13 +1192,11 @@ typedef enum
    MASA_STEREO_DOWNMIX
} MASA_TRANSPORT_SIGNAL_TYPE;

#ifdef FIX_382_MASA_META_FRAMING_ASYNC
typedef enum
{
    MASA_FRAME_1SF,
    MASA_FRAME_4SF
} MASA_FRAME_MODE;
#endif

/*----------------------------------------------------------------------------------*
 * Multichannel format
+0 −1
Original line number Diff line number Diff line
@@ -141,7 +141,6 @@
#define DISABLE_ADAP_RES_COD_TMP                        /* temporary fix for IVAS-403, disables adaptive residual coding */
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */

#define FIX_382_MASA_META_FRAMING_ASYNC                 /* Nokia: Issue 382: detect potential MASA metadata framing offset */
#define FIX_386_CORECODER_RECONFIG                      /* VA: Issue 386: Resolve ToDo comments in CoreCoder reconfig. */

#define SBA2MONO                                        /* FhG: Issue 365: Adapt processing of SBA mono output to be in line with stereo output (less delay, lower complexity) */
+0 −5
Original line number Diff line number Diff line
@@ -227,16 +227,11 @@ ivas_error ivas_enc(
            }
            else
            {
#ifdef FIX_382_MASA_META_FRAMING_ASYNC
                ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */
#endif
                if ( ( error = ivas_masa_enc_config( st_ivas ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
#ifndef FIX_382_MASA_META_FRAMING_ASYNC
                ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */
#endif
                if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format,
                                                 ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1 ) ) != IVAS_ERR_OK )
                {
+0 −63
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ static int16_t encode_lfe_to_total_energy_ratio( MASA_ENCODER_HANDLE hMasa, BSTR

static void reduce_metadata_further( MASA_ENCODER_HANDLE hMasa, IVAS_QMETADATA_HANDLE hqmetadata, const IVAS_FORMAT ivas_format );

#ifdef FIX_382_MASA_META_FRAMING_ASYNC
static void average_masa_metadata( MASA_METADATA_FRAME *masaMetadata, float energy[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] );

static void copy_masa_metadata_subframe( const MASA_METADATA_HANDLE hMetaFrom, const uint8_t sfFrom, MASA_METADATA_HANDLE hMetaTo, const uint8_t sfTo );
@@ -71,7 +70,6 @@ static void copy_masa_metadata( const MASA_METADATA_HANDLE hMetaFrom, MASA_METAD
static uint8_t are_masa_subframes_similar( const MASA_METADATA_HANDLE frame1, const uint8_t sf1_idx, const MASA_METADATA_HANDLE frame2, const uint8_t sf2_idx );

static void detect_framing_async( MASA_ENCODER_HANDLE hMasa );
#endif

#ifdef FIX_398_MASA_DIRECTION_ALIGNMENT
static void masa_metadata_direction_alignment( MASA_ENCODER_HANDLE hMasa );
@@ -143,11 +141,9 @@ ivas_error ivas_masa_enc_open(
    hMasa->data.prevq_lfeToTotalEnergyRatio = 0.0f;
    hMasa->data.prevq_lfeIndex = 0;

#ifdef FIX_382_MASA_META_FRAMING_ASYNC
    hMasa->data.sync_state.prev_sim_stop = 0;
    hMasa->data.sync_state.prev_offset = 0;
    hMasa->data.sync_state.frame_mode = MASA_FRAME_4SF;
#endif

#ifdef FIX_398_MASA_DIRECTION_ALIGNMENT
    set_zero( hMasa->data.dir_align_state.previous_azi_dir1, MASA_FREQUENCY_BANDS );
@@ -492,7 +488,6 @@ ivas_error ivas_masa_enc_config(
        masa_metadata_direction_alignment( hMasa );
#endif

#ifdef FIX_382_MASA_META_FRAMING_ASYNC
        detect_framing_async( hMasa ); /* detect the offset, set 1sf/4sf mode based on this. potentially also shift the metadata using a history buffer */

        if ( hMasa->data.sync_state.frame_mode == MASA_FRAME_1SF && hMasa->data.sync_state.prev_offset != 0 )
@@ -500,7 +495,6 @@ ivas_error ivas_masa_enc_config(
            /* average over sub-frames */
            average_masa_metadata( &( hMasa->masaMetadata ), hMasa->data.energy );
        }
#endif

        /* Inspect metadata for parameter changes that affect coding. */
        detect_metadata_composition( hMasa, &joinedSubframes, &coherencePresent, &isActualTwoDir );
@@ -1085,18 +1079,12 @@ static void detect_metadata_composition(
)
{
    MASA_METADATA_FRAME *hMeta;
#ifdef FIX_382_MASA_META_FRAMING_ASYNC
    int8_t sf, band, dir, numDir;
#else
    int16_t sf, band, dir, numDir;
#endif
    int16_t nSubFrames;
    uint8_t dirValid[2] = { FALSE };
    uint8_t cohPresent = FALSE;
    uint8_t sfDiffer = FALSE;
#ifdef FIX_382_MASA_META_FRAMING_ASYNC
    uint8_t sfSimilar;
#endif

    hMeta = &( hMasa->masaMetadata );
    numDir = hMeta->descriptive_meta.numberOfDirections + 1;
@@ -1161,7 +1149,6 @@ static void detect_metadata_composition(
    }

    /* Check if data over subframes is identical. Check is done by comparing to first subframe. */
#ifdef FIX_382_MASA_META_FRAMING_ASYNC
    sfSimilar = TRUE;
    sf = 1;
    while ( ( sfSimilar == TRUE ) && ( sf < MAX_PARAM_SPATIAL_SUBFRAMES ) )
@@ -1170,54 +1157,6 @@ static void detect_metadata_composition(
        sf++;
    }
    sfDiffer = sfSimilar == TRUE ? FALSE : TRUE;
#else
    dir = 0;
    while ( sfDiffer == FALSE && dir < numDir )
    {
        sf = 1;
        while ( sfDiffer == FALSE && sf < MAX_PARAM_SPATIAL_SUBFRAMES )
        {
            band = 0;
            while ( sfDiffer == FALSE && band < MASA_FREQUENCY_BANDS )
            {
                float aziDif;
                aziDif = fabsf( hMeta->directional_meta[dir].azimuth[sf][band] - hMeta->directional_meta[dir].azimuth[0][band] );
                aziDif = aziDif > 180.0f ? aziDif - 360.0f : aziDif;
                if ( aziDif > MASA_ANGLE_TOLERANCE )
                {
                    sfDiffer = TRUE;
                    break;
                }

                if ( fabsf( hMeta->directional_meta[dir].elevation[sf][band] - hMeta->directional_meta[dir].elevation[0][band] ) > MASA_ANGLE_TOLERANCE )
                {
                    sfDiffer = TRUE;
                    break;
                }

                if ( fabsf( hMeta->directional_meta[dir].energy_ratio[sf][band] - hMeta->directional_meta[dir].energy_ratio[0][band] ) > MASA_RATIO_TOLERANCE )
                {
                    sfDiffer = TRUE;
                    break;
                }

                if ( fabsf( hMeta->directional_meta[dir].spread_coherence[sf][band] - hMeta->directional_meta[dir].spread_coherence[0][band] ) > MASA_COHERENCE_TOLERANCE )
                {
                    sfDiffer = TRUE;
                    break;
                }

                if ( dir == 0 && fabsf( hMeta->common_meta.surround_coherence[sf][band] - hMeta->common_meta.surround_coherence[0][band] ) > MASA_COHERENCE_TOLERANCE )
                {
                    sfDiffer = TRUE;
                }
                band++;
            }
            sf++;
        }
        dir++;
    }
#endif

    /* Further checks can be done with just one subframe if they are identical */
    nSubFrames = sfDiffer == TRUE ? MAX_PARAM_SPATIAL_SUBFRAMES : 1;
@@ -1763,7 +1702,6 @@ void ivas_masa_enc_reconfigure(
}


#ifdef FIX_382_MASA_META_FRAMING_ASYNC
/*-------------------------------------------------------------------*
 * average_masa_metadata()
 *
@@ -2161,7 +2099,6 @@ static void detect_framing_async(

    return;
}
#endif


#ifdef FIX_398_MASA_DIRECTION_ALIGNMENT
+0 −4
Original line number Diff line number Diff line
@@ -732,7 +732,6 @@ typedef struct ivas_masa_dir_align_struct
} MASA_DIR_ALIGN_STATE, *MASA_DIR_ALIGN_HANDLE;
#endif

#ifdef FIX_382_MASA_META_FRAMING_ASYNC
/* structure storing MASA framing sync detection and compensation data */
typedef struct ivas_masa_sync_struct
{
@@ -742,7 +741,6 @@ typedef struct ivas_masa_sync_struct
    MASA_FRAME_MODE frame_mode;

} MASA_SYNC_STATE, *MASA_SYNC_HANDLE;
#endif

typedef struct ivas_masa_encoder_data_struct
{
@@ -760,9 +758,7 @@ typedef struct ivas_masa_encoder_data_struct
    float onset_detector_1;
    float onset_detector_2;

#ifdef FIX_382_MASA_META_FRAMING_ASYNC
    MASA_SYNC_STATE sync_state;
#endif

#ifdef FIX_398_MASA_DIRECTION_ALIGNMENT
    MASA_DIR_ALIGN_STATE dir_align_state;