Commit ea5e4a39 authored by advasila's avatar advasila
Browse files

fix FCB ACELP in OMASA

parent a15f04f0
Loading
Loading
Loading
Loading
Loading
+45 −18
Original line number Diff line number Diff line
@@ -394,6 +394,9 @@ static ivas_error acelp_FCB_allocator(
    int16_t nBits_tmp;
    int16_t *p_fixed_cdk_index;
    ivas_error error;
#ifdef FIX_ACELP_TABLE
    int16_t max_n;
#endif

    error = IVAS_ERR_OK;

@@ -424,12 +427,31 @@ static ivas_error acelp_FCB_allocator(
    }

    /* distribute the bit-budget equally between subframes */
#ifdef FIX_ACELP_TABLE
    if ( L_subfr > L_SUBFR ) /* access fast_FCB_bits_2sfr */
    {
        max_n = 6;
    }
    else
    {
        max_n = ACELP_FIXED_CDK_NB;
    }
    for ( cdbk = 0; cdbk < max_n; cdbk++ )
    {
        if ( fcb_table( cdbk, L_subfr ) * nb_subfr > *nBits )
        {
            break;
        }
    }
    cdbk--;
#else
    cdbk = 0;
    while ( fcb_table( cdbk, L_subfr ) * nb_subfr <= *nBits )
    {
        cdbk++;
    }
    cdbk--;
#endif

#ifdef DEBUGGING
    if ( cdbk < 0 && coder_type != TRANSITION )
@@ -453,7 +475,10 @@ static ivas_error acelp_FCB_allocator(
        nBits_tmp = 0;
    }
    *nBits -= nBits_tmp * nb_subfr;

#ifdef FIX_ACELP_TABLE
    if ( cdbk < ACELP_FIXED_CDK_NB - 1 )
    {
#endif
        /* try to increase the FCB bit-budget of the first subframe(s) */
        step = fcb_table( cdbk + 1, L_subfr ) - nBits_tmp;
        while ( *nBits >= step )
@@ -477,7 +502,9 @@ static ivas_error acelp_FCB_allocator(
                *nBits -= step;
            }
        }

#ifdef FIX_ACELP_TABLE
    }
#endif
    /* TRANSITION coding: allocate highest FCBQ bit-budget to the subframe with the glottal-shape codebook */
    if ( tc_subfr >= L_SUBFR )
    {
+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@

#define MASA_AND_OBJECTS                                /* Nokia: Combination of MASA and objects */
#define FIX_WB_OMASA                                    /* Nokia: fixes OMASA for WB input */

#define FIX_ACELP_TABLE                                 /* Nokia: fixes over-indexing in FCB ACELP in OMASA when the separated object is inactive  */

/* ################## End BE DEVELOPMENT switches ######################### */