Commit 1eb04b48 authored by emerit's avatar emerit
Browse files

version ok

parent 1934333f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ typedef struct _IVAS_ISM_METADATA
#endif
#ifdef ISM_NO_DIEGETIC_PAN
    uint16_t metadata_flag;
    float no_diegetic_pan;
#endif
} IVAS_ISM_METADATA;

+3 −0
Original line number Diff line number Diff line
@@ -141,7 +141,9 @@ ivas_error ivas_ism_config(

        for ( ch = 0; ch < n_ISms; ch++ )
        {
#ifndef ISM_NO_DIEGETIC_PAN
            if ( hIsmMeta[ch]->ism_metadata_flag == 0 )
#endif
            {
                nb_bits_metadata[0] += ISM_METADATA_VAD_FLAG_BITS;
            }
@@ -341,6 +343,7 @@ void ivas_ism_reset_metadata(
    hIsmMeta->radius = 1.0f;
#endif
#ifdef ISM_NO_DIEGETIC_PAN
    hIsmMeta->no_diegetic_pan = FLT_MAX;
    hIsmMeta->ism_metadata_flag = 0;
#endif

+2 −1
Original line number Diff line number Diff line
@@ -798,6 +798,7 @@ ivas_error set_ism_metadata(
#endif 
#ifdef ISM_NO_DIEGETIC_PAN
,
    float no_diegetic_pan,                                      /* i  : no diegetic pan           */
    uint16_t metadata_flag                                      /* i : 0 VAD, 1 if metadate type is source or 2 if no diegetic pan*/
#endif
);
+284 −147
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
 *-----------------------------------------------------------------------*/
static void decode_angle_indices( DEC_CORE_HANDLE st0, ISM_METADATA_ANGLE_HANDLE angle, int16_t *flag_abs_azimuth );
int16_t decode_radius( DEC_CORE_HANDLE st0, int16_t *last_radius_idx, int16_t *flag_abs_radius );
int16_t decode_no_diegetic_pan( DEC_CORE_HANDLE st0, int16_t *last_ndp_idx, int16_t *flag_abs_ndp );
#endif

/*-------------------------------------------------------------------------*
@@ -68,6 +69,10 @@ ivas_error ivas_ism_metadata_dec(
    const PARAM_ISM_CONFIG_HANDLE hParamIsm /* i  : Param ISM Config Handle         */
)
{
#ifdef ISM_NO_DIEGETIC_PAN
    int16_t idx_ndp;
    int16_t flag_abs_ndp;
#endif
#ifdef TD5
    int16_t ch, nb_bits_start = 0, last_bit_pos;
    int16_t idx_radius;
@@ -179,14 +184,35 @@ ivas_error ivas_ism_metadata_dec(
        }
#endif
        /* Read ISm present flags (one per object) */
#ifdef ISM_NO_DIEGETIC_PAN
        for ( ch = 0; ch < *nchan_transport; ch++ )
        {
            ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS );
        }
#endif
        for ( ch = 0; ch < *nchan_transport; ch++ )
        {
#ifndef ISM_NO_DIEGETIC_PAN
            ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS );
#endif
            localVAD[ch] = get_next_indice( st0, ISM_METADATA_VAD_FLAG_BITS );

            if ( ism_imp[ch] > ISM_NO_META )
            {
#ifdef ISM_NO_DIEGETIC_PAN
                /* read VAD flag */

                if ( localVAD[ch] )
                {
                    hIsmMeta[ch]->ism_metadata_flag = 2;
                }
                else
                {
                    hIsmMeta[ch]->ism_metadata_flag = 1;
                }
                localVAD[ch] = 1;
            }
#endif
            else
            {
                hIsmMeta[ch]->ism_metadata_flag = 0;
@@ -197,10 +223,13 @@ ivas_error ivas_ism_metadata_dec(

        for ( ; ch < num_obj; ch++ )
        {
#ifndef ISM_NO_DIEGETIC_PAN
            hIsmMeta[ch]->ism_metadata_flag = 1;
#endif
            ism_metadata_flag_global |= hIsmMeta[ch]->ism_metadata_flag;
        }

#ifndef ISM_NO_DIEGETIC_PAN
        /* read VAD flag */
        for ( ch = 0; ch < *nchan_transport; ch++ )
        {
@@ -213,6 +242,7 @@ ivas_error ivas_ism_metadata_dec(
                localVAD[ch] = 1;
            }
        }
#endif

        if ( ism_metadata_flag_global )
        {
@@ -241,8 +271,14 @@ ivas_error ivas_ism_metadata_dec(
                flag_abs_orientation = 0;
                flag_abs_radius = 0;
#endif
#ifdef ISM_NO_DIEGETIC_PAN
                flag_abs_ndp = 0;
                if ( hIsmMeta[ch]->ism_metadata_flag == 1 )
                {
#else
                    if ( hIsmMeta[ch]->ism_metadata_flag )
                    {
#endif
#ifdef TD5
                    decode_angle_indices( st0, &( hIsmMetaData->angle[0] ), &flag_abs_azimuth );
                    idx_azimuth = hIsmMetaData->angle[0].last_azimuth_idx;
@@ -426,14 +462,40 @@ ivas_error ivas_ism_metadata_dec(
                        hIsmMetaData->last_azimuth_idx = idx_azimuth;
                        hIsmMetaData->last_elevation_idx = idx_elevation;
#endif

                    /* save number of metadata bits read */
                    if ( ism_mode == ISM_MODE_DISC )
                    {
                        nb_bits_metadata[ch] = st0->next_bit_pos - nb_bits_start;
                    }
                }

#ifdef ISM_NO_DIEGETIC_PAN
                if ( hIsmMeta[ch]->ism_metadata_flag == 2 )
                {
                    /* Azimuth/Elevation dequantization */
                    if ( ism_mode == ISM_MODE_PARAM )
                    {
                    }
                    else /* ISM_MODE_DISC */
                    {
                        if ( ism_extended_metadata_flag )
                        {
                            idx_ndp = decode_no_diegetic_pan( st0, &hIsmMetaData->last_no_diegetic_pan_idx, &flag_abs_ndp );
                            hIsmMetaData->no_diegetic_pan = usdequant( idx_ndp, ISM_NO_DIEGETIC_PAN_MIN, ISM_NO_DIEGETIC_PAN_DELTA );
                        }
                        else
                        {
                            hIsmMetaData->no_diegetic_pan = FLT_MAX;
                        }
                    }
                    /* save number of metadata bits read */
                    if ( ism_mode == ISM_MODE_DISC )
                    {
                        nb_bits_metadata[ch] = st0->next_bit_pos - nb_bits_start;
                    }
                }
#endif

                if ( ism_mode == ISM_MODE_PARAM )
                {
@@ -481,6 +543,7 @@ ivas_error ivas_ism_metadata_dec(
                    }
                }
            }
        }
        else
        {
            set_s( nb_bits_metadata, 0, *nchan_transport );
@@ -628,6 +691,9 @@ ivas_error ivas_ism_metadata_dec_create(
            st_ivas->hIsmMetaData[ch]->last_azimuth_idx = 0;
            st_ivas->hIsmMetaData[ch]->last_elevation_idx = 1 << ( ISM_ELEVATION_NBITS - 1 );
#endif
#ifdef ISM_NO_DIEGETIC_PAN
        st_ivas->hIsmMetaData[ch]->last_no_diegetic_pan_idx = 8; /* Init to pan center */
#endif

        ivas_ism_reset_metadata( st_ivas->hIsmMetaData[ch] );
    }
@@ -847,3 +913,74 @@ int16_t decode_radius(
    return idx_radius;
}
#endif

#ifdef ISM_NO_DIEGETIC_PAN
int16_t decode_no_diegetic_pan(
    DEC_CORE_HANDLE st0,   /* i/o: bitstream handle           */
    int16_t *last_ndp_idx, /* i/o: last radius index          */
    int16_t *flag_abs_ndp  /* o  : no diegetic pan encoding mode       */
)
{
    /*----------------------------------------------------------------*
     * Radius decoding and dequantization
     *----------------------------------------------------------------*/
    int16_t idx_ndp, nbits_diff_ndp, diff, sgn;


    /* Decode radius index */
    if ( get_next_indice( st0, 1 ) == 1 ) /* elevation_abs_flag */
    {
        *flag_abs_ndp = 1;
        idx_ndp = get_next_indice( st0, ISM_NO_DIEGETIC_PAN_NBITS );
    }
    else
    {
        diff = 0;
        sgn = 1;

        if ( get_next_indice( st0, 1 ) == 0 )
        {
            nbits_diff_ndp = 1;
        }
        else
        {
            nbits_diff_ndp = 1;

            if ( get_next_indice( st0, 1 ) == 1 ) /* negative sign */
            {
                sgn = -1;
            }

            nbits_diff_ndp++;

            /* read until the stop bit */
            while ( ( nbits_diff_ndp < ISM_NO_DIEGETIC_PAN_NBITS ) && ( get_next_indice( st0, 1 ) == 1 ) )
            {
                diff++;
                nbits_diff_ndp++;
            }

            if ( nbits_diff_ndp < ISM_NO_DIEGETIC_PAN_NBITS )
            {
                /* count stop bit */
                nbits_diff_ndp++;
            }
        }
        idx_ndp = *last_ndp_idx + sgn * diff;
    }

    /* sanity check in case of FER or BER */
    if ( idx_ndp < 0 || idx_ndp > ( 1 << ISM_NO_DIEGETIC_PAN_NBITS ) - 1 )
    {
        idx_ndp = *last_ndp_idx;
    }

    /*----------------------------------------------------------------*
     * Final updates
     *----------------------------------------------------------------*/

    /* updates */
    *last_ndp_idx = idx_ndp;
    return idx_ndp;
}
#endif
+42 −11
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ ivas_error set_ism_metadata(
#endif
#ifdef ISM_NO_DIEGETIC_PAN
    ,
    float no_diegetic_pan, /* i  : no diegetic pan           */
    uint16_t metadata_flag /* i : 0 if VAD 1 if metadate type is source or 2 if no diegetic pan*/
#endif
)
@@ -128,6 +129,7 @@ ivas_error set_ism_metadata(
#endif
#ifdef ISM_NO_DIEGETIC_PAN
    hIsmMeta->ism_metadata_flag = metadata_flag;
    hIsmMeta->no_diegetic_pan = no_diegetic_pan;
#endif
    return IVAS_ERR_OK;
}
@@ -387,15 +389,23 @@ ivas_error ivas_ism_metadata_enc(
        /* write VAD flag */
        for ( ch = 0; ch < nchan_transport; ch++ )
        {
#ifdef ISM_NO_DIEGETIC_PAN
            if ( ( hIsmMeta[ch]->ism_metadata_flag == 0 ) || ( hIsmMeta[ch]->ism_metadata_flag == 2 ) )
#else
            if ( hIsmMeta[ch]->ism_metadata_flag == 0 )
#endif
            {
                /* this flag distinguishes between coding of inactive frame and active frame w/o. metadata */
                push_indice( hBstr, IND_ISM_VAD_FLAG, localVAD[ch], ISM_METADATA_VAD_FLAG_BITS );
            }
#ifdef ISM_NO_DIEGETIC_PAN
            else if ( hIsmMeta[ch]->ism_metadata_flag == 1 )
            {
                /* this flag distinguishes between coding of inactive frame and active frame w/o. metadata */
                push_indice( hBstr, IND_ISM_VAD_FLAG, 0, ISM_METADATA_VAD_FLAG_BITS );
            }
            else
            {
                /* this flag distinguishes between coding of inactive frame and active frame w/o. metadata */
                push_indice( hBstr, IND_ISM_VAD_FLAG, 1, ISM_METADATA_VAD_FLAG_BITS );
            }
#endif
        }
    }

@@ -429,10 +439,14 @@ ivas_error ivas_ism_metadata_enc(
                    idx_no_diegetic_pan_abs = usquant( hIsmMetaData->no_diegetic_pan, &valQ, ISM_NO_DIEGETIC_PAN_MIN, ISM_NO_DIEGETIC_PAN_DELTA, 1 << ISM_NO_DIEGETIC_PAN_NBITS );
                    encode_no_diegetic_pan( hBstr, &hIsmMetaData->last_no_diegetic_pan_idx, &hIsmMetaData->no_diegetic_pan_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_no_diegetic_pan_abs, &flag_abs_no_diegetic_pan[ch] );
                }
                /* save number of metadata bits written */
                if ( ism_mode == ISM_MODE_DISC )
                {
                    nb_bits_metadata[ch] = hBstr->nb_bits_tot - nb_bits_start;
                }
            }
            else
#endif
                if ( hIsmMeta[ch]->ism_metadata_flag )
            if ( hIsmMeta[ch]->ism_metadata_flag == 1 )
            {

#ifdef TD5
@@ -942,6 +956,10 @@ ivas_error ivas_ism_metadata_enc_create(
        st_ivas->hIsmMetaData[ch]->elevation_diff_cnt = ISM_FEC_MAX - 1;
#endif
        st_ivas->hIsmMetaData[ch]->last_ism_metadata_flag = 0;
#ifdef ISM_NO_DIEGETIC_PAN
        st_ivas->hIsmMetaData[ch]->last_no_diegetic_pan_idx = 0;
        st_ivas->hIsmMetaData[ch]->no_diegetic_pan_diff_cnt = ISM_FEC_MAX;
#endif

        ivas_ism_reset_metadata( st_ivas->hIsmMetaData[ch] );
    }
@@ -977,6 +995,9 @@ static void encode_radius(
    *flag_abs_radius = 0; /* differential coding by default */

    if ( *radius_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */
#ifdef ISM_NO_DIEGETIC_PAN
         || last_ism_metadata_flag == 2 /* If last frame had no metadata coded, do not use differential coding */
#endif
         || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */
    )
    {
@@ -1083,6 +1104,9 @@ static void encode_angle_indices(

    *flag_abs_azimuth = 0;                      /* differential coding by default */
    if ( angle->azimuth_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */
#ifdef ISM_NO_DIEGETIC_PAN
         || last_ism_metadata_flag == 2 /* If last frame had no metadata coded, do not use differential coding */
#endif
         || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */
    )
    {
@@ -1179,6 +1203,9 @@ static void encode_angle_indices(

    *flag_abs_elevation = 0;                      /* differential coding by default */
    if ( angle->elevation_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */
#ifdef ISM_NO_DIEGETIC_PAN
         || last_ism_metadata_flag == 2 /* If last frame had no metadata coded, do not use differential coding */
#endif
         || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */
    )
    {
@@ -1211,7 +1238,11 @@ static void encode_angle_indices(
            diff = -1 * min( -diff, ISM_MAX_ELEVATION_DIFF_IDX );
        }

#ifdef ISM_NO_DIEGETIC_PAN
        if ( last_ism_metadata_flag == 0 || last_ism_metadata_flag == 2 || abs( diff_orig - diff ) > ISM_MAX_ELEVATION_DIFF_IDX )
#else
        if ( last_ism_metadata_flag == 0 || abs( diff_orig - diff ) > ISM_MAX_ELEVATION_DIFF_IDX )
#endif
        {
            angle->elevation_diff_cnt = ISM_FEC_MAX - 1;
        }
@@ -1321,7 +1352,7 @@ static void encode_no_diegetic_pan(
    *flag_abs_ndp = 0; /* differential coding by default */

    if ( *ndp_diff_cnt == ISM_FEC_MAX                                  /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */
         || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */
         || last_ism_metadata_flag == 0 || last_ism_metadata_flag == 1 /* If last frame had no metadata coded, do not use differential coding */
    )
    {
        *flag_abs_ndp = 1;
Loading