Commit df507c5a authored by emerit's avatar emerit
Browse files

on going

parent cd84e4b8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -82,6 +82,9 @@ typedef struct _IVAS_ISM_METADATA
    float yaw;
    float pitch;
#endif
#ifdef ISM_NO_DIEGETIC_PAN
    uint16_t metadata_flag;
#endif
} IVAS_ISM_METADATA;

typedef struct
+10 −0
Original line number Diff line number Diff line
@@ -310,6 +310,12 @@ typedef enum
#define ISM_MEDIUM_IMP                          2
#define ISM_HIGH_IMP                            3

#ifdef ISM_NO_DIEGETIC_PAN
#define ISM_NO_DIEGETIC_PAN_NBITS                       5
#define ISM_NO_DIEGETIC_PAN_MIN                         -1.0f
#define ISM_NO_DIEGETIC_PAN_DELTA                        0.125f /* Max Pan = ISM_NO_DIEGETIC_PAN_MIN + (2^ISM_RADIUS_NBITS-1)*0.125 = 1 */
#endif

#define ISM_AZIMUTH_NBITS                       7
#define ISM_AZIMUTH_MIN                         -180.0f
#define ISM_AZIMUTH_MAX                         180.0f
@@ -389,6 +395,10 @@ enum
#ifdef TD5
    IND_ISM_RADIUS_DIFF_FLAG = TAG_ISM_LOOP_START,
    IND_ISM_RADIUS = TAG_ISM_LOOP_START,
#endif 
#ifdef ISM_NO_DIEGETIC_PAN
    IND_ISM_NO_DIEGETIC_PAN_DIFF_FLAG = TAG_ISM_LOOP_START,
    IND_ISM_NO_DIEGETIC_PAN = TAG_ISM_LOOP_START,
#endif 
    TAG_ISM_LOOP_END = TAG_ISM_LOOP_START + 100, /* IVAS_fmToDo: to be reviewed once the final metadata are defined */
    /* --------- end of loop for objects ----------- */
+4 −0
Original line number Diff line number Diff line
@@ -340,6 +340,10 @@ void ivas_ism_reset_metadata(
    hIsmMeta->pitch = 0.0f;
    hIsmMeta->radius = 1.0f;
#endif
#ifdef ISM_NO_DIEGETIC_PAN
    hIsmMeta->ism_metadata_flag = 0;
#endif

    return;
}

+4 −0
Original line number Diff line number Diff line
@@ -796,6 +796,10 @@ ivas_error set_ism_metadata(
#else
    float elevation                                             /* i  : elevation                                   */
#endif 
#ifdef ISM_NO_DIEGETIC_PAN
,
uint16_t metadata_flag                                          /* i : 0 VAD, 1 if metadate type is source or 2 if no diegetic pan*/
#endif
);

ivas_error ivas_ism_metadata_enc_create(
+141 −1
Original line number Diff line number Diff line
@@ -60,6 +60,9 @@
#ifdef TD5
#define ISM_MAX_RADIUS_DIFF_IDX ( ISM_RADIUS_NBITS - 1 /*zero*/ - 1 /*sign*/ )
#endif
#ifdef ISM_NO_DIEGETIC_PAN
#define ISM_MAX_NO_DIEGETIC_PAN_DIFF_IDX ( ISM_NO_DIEGETIC_PAN_NBITS - 1 /*zero*/ - 1 /*sign*/ )
#endif

#define ISM_FEC_MAX 10

@@ -74,6 +77,16 @@ static void encode_radius( BSTR_ENC_HANDLE hBstr, int16_t *last_radius_idx, int1

#endif

#ifdef ISM_NO_DIEGETIC_PAN
static void encode_no_diegetic_pan(
    BSTR_ENC_HANDLE hBstr,
    int16_t *last_ndp_idx,
    int16_t *ndp_diff_cnt,
    const int16_t last_ism_metadata_flag,
    const int16_t idx_ndp_abs,
    int16_t *flag_abs_ndp );
#endif

/*-------------------------------------------------------------------------*
 * ivas_set_ism_metadata()
 *
@@ -92,6 +105,10 @@ ivas_error set_ism_metadata(
#else
    float elevation                         /* i  : elevation                                   */
#endif
#ifdef ISM_NO_DIEGETIC_PAN
    ,
    uint16_t metadata_flag /* i : 0 if VAD 1 if metadate type is source or 2 if no diegetic pan*/
#endif
)
{
    if ( hIsmMeta == NULL )
@@ -108,6 +125,9 @@ ivas_error set_ism_metadata(
    hIsmMeta->radius = radius_meta;
    hIsmMeta->yaw = yaw;
    hIsmMeta->pitch = pitch;
#endif
#ifdef ISM_NO_DIEGETIC_PAN
    hIsmMeta->ism_metadata_flag = metadata_flag;
#endif
    return IVAS_ERR_OK;
}
@@ -362,7 +382,11 @@ 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 );
@@ -392,6 +416,16 @@ ivas_error ivas_ism_metadata_enc(
                nb_bits_start = hBstr->nb_bits_tot;
            }

#ifdef ISM_NO_DIEGETIC_PAN
            if ( hIsmMeta[ch]->ism_metadata_flag == 2 )
            {
                if ( ism_mode == ISM_MODE_DISC )
                {
                    idx_radius_abs = usquant( hIsmMetaData->radius, &valQ, ISM_NO_DIEGETIC_PAN_MIN, ISM_RADIUS_DELTA, 1 << ISM_RADIUS_NBITS );
                }
            }
            else
#endif
                if ( hIsmMeta[ch]->ism_metadata_flag )
            {

@@ -1256,3 +1290,109 @@ static void encode_angle_indices(
    return;
}
#endif


#ifdef ISM_NO_DIEGETIC_PAN
static void encode_no_diegetic_pan(
    BSTR_ENC_HANDLE hBstr,                /* i/o: bitstream handle           */
    int16_t *last_ndp_idx,                /* i/o: last no diegetic pan index          */
    int16_t *ndp_diff_cnt,                /* i/o: no diegetic pan diff coding counter */
    const int16_t last_ism_metadata_flag, /* last frame ism_metadata_flag    */
    const int16_t idx_ndp_abs,            /* i  : no diegetic pan index              */
    int16_t *flag_abs_ndp                 /* o  : no diegetic pan encoding mode       */
)
{
    int16_t idx_ndp, nbits_diff_ndp, diff;


    /*----------------------------------------------------------------*
     * ndp index encoding
     *----------------------------------------------------------------*/
    idx_ndp = idx_ndp_abs;

    nbits_diff_ndp = 0;

    *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 */
    )
    {
        *flag_abs_ndp = 1;
    }

    diff = idx_ndp_abs - *last_ndp_idx;

    /* try differential coding */
    if ( *flag_abs_ndp == 0 )
    {
        if ( diff == 0 )
        {
            idx_ndp = 0;
            nbits_diff_ndp = 1;
        }
        else if ( ABSVAL( diff ) <= ISM_MAX_NO_DIEGETIC_PAN_DIFF_IDX )
        {
            idx_ndp = 1 << 1;
            nbits_diff_ndp = 1;

            if ( diff < 0 )
            {
                idx_ndp += 1; /* negative sign */
                diff *= -1;
            }
            else
            {
                idx_ndp += 0; /* positive sign */
            }

            idx_ndp = idx_ndp << diff;
            nbits_diff_ndp++;

            /* unary coding of "diff */
            idx_ndp += ( ( 1 << diff ) - 1 );
            nbits_diff_ndp += diff;

            if ( nbits_diff_ndp < ISM_NO_DIEGETIC_PAN_NBITS )
            {
                /* add stop bit */
                idx_ndp = idx_ndp << 1;
                nbits_diff_ndp++;
            }
        }
        else
        {
            *flag_abs_ndp = 1;
        }
    }

    /* update counter */
    if ( *flag_abs_ndp == 0 )
    {
        ( *ndp_diff_cnt )++;
        *ndp_diff_cnt = min( *ndp_diff_cnt, ISM_FEC_MAX );
    }
    else
    {
        *ndp_diff_cnt = 0;
    }

    /* Write ndp */
    push_indice( hBstr, IND_ISM_NO_DIEGETIC_PAN_DIFF_FLAG, *flag_abs_ndp, 1 );

    if ( *flag_abs_ndp )
    {
        push_indice( hBstr, IND_ISM_NO_DIEGETIC_PAN, idx_ndp, ISM_NO_DIEGETIC_PAN_NBITS );
    }
    else
    {
        push_indice( hBstr, IND_ISM_NO_DIEGETIC_PAN, idx_ndp, nbits_diff_ndp );
    }

    /*----------------------------------------------------------------*
     * Updates
     *----------------------------------------------------------------*/
    *last_ndp_idx = idx_ndp_abs;
    return;
}
#endif
Loading