Commit c5f57006 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

fix the penalty calculation update

parent e6e72aa8
Loading
Loading
Loading
Loading
Loading
+35 −16
Original line number Diff line number Diff line
@@ -618,32 +618,51 @@ ivas_error only_reduce_bits_direction_fx(
    ELSE
    {
#ifdef FIX_QMETADATA_PENALTY    

        Word16 m, sorted, index1, index2;

        FOR( j = 0; j < coding_subbands; j++ )
        {
            penalty[j] = 1;
            move32();
            FOR( k = 0; k < coding_subbands; k++ )
            ind_order[j] = j;
            move16();
        }
        sorted = 0;
        move16();
        FOR( m = coding_subbands - 1; m && !sorted; m-- )
        {
                IF( NE_16(k, j) )
            sorted = 1;
            move16();
            FOR( j = 0; j < m; j++ )
            {
                index1 = ind_order[j];
                index2 = ind_order[j + 1];
                tmp = 0;
                move16();
                FOR( k = 0; k < no_subframes; k++ )
                {
                    penalty[j] = L_shr( W_extract_l( W_mult_32_16( penalty[j], bits_sph_idx_orig[k][0] ) ), 1 );
                    tmp = add( tmp, sub( bits_sph_idx_orig[index1][k], q_direction->band_data[index1].bits_sph_idx[k] ) );
                }
                penalty[0] = L_shr( W_extract_l( W_mult_32_16( tmp, bits_sph_idx_orig[index2][0] ) ), 1 );
                tmp = 0;
                move16();
                FOR( k = 0; k < no_subframes; k++ )
                {
                    tmp = add( tmp, sub( bits_sph_idx_orig[index2][k], q_direction->band_data[index2].bits_sph_idx[k] ) );
            }
                 
            tmp = sub( bits_sph_idx_orig[j][0], q_direction->band_data[j].bits_sph_idx[0] ); 
            FOR( k = 1; k < no_subframes; k++ )
                penalty[1] = L_shr( W_extract_l( W_mult_32_16( tmp, bits_sph_idx_orig[index1][0] ) ), 1 );
                IF( LT_32( penalty[0], penalty[1] ) )
            {
                tmp = add( tmp, sub( bits_sph_idx_orig[j][k], q_direction->band_data[j].bits_sph_idx[k] ) ) ;
                    sorted = 0;
                    move16();
                    ind_order[j] = index2;
                    move16();
                    ind_order[j + 1] = index1;
                    move16();
            }
        
            penalty[j] =  L_shr(W_extract_l( W_mult_32_16( penalty[j], tmp )), 1);
        }
        sort_desc_ind_32_fx( penalty, coding_subbands, ind_order );
        for ( j = 0; j < coding_subbands; j++ )
        {
            printf( "%d ", ind_order[j] );
        }
        printf( "\n" );
        
    
#else
        FOR( j = 0; j < coding_subbands; j++ )
        {