Commit a5837bad authored by vasilache's avatar vasilache
Browse files

fix penalty

parent e5d231fd
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
@@ -622,6 +622,54 @@ ivas_error only_reduce_bits_direction_fx(
    ELSE
    {
#ifdef FIX_QMETADATA_PENALTY    
        #if 1
        
            Word16  m, sorted, index1, index2;

            FOR( j = 0; j < coding_subbands; j++ )
            {
                ind_order[j] = j;
                move16();
            }
            sorted = 0;
            move16();
            FOR( m = coding_subbands - 1; m && !sorted; m-- )
            {
                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++ )
                    {
                        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] ));
                    }
                    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] ) )
                    {
                        sorted = 0;
                        move16();               
                        ind_order[j] = index2;
                        move16();
                        ind_order[j + 1] = index1;
                        move16();
                    }
                }
            }

            
        
        #else
        FOR( j = 0; j < coding_subbands; j++ )
        {
            penalty[j] = 1;
@@ -643,6 +691,7 @@ ivas_error only_reduce_bits_direction_fx(
            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 );
        #endif
        for ( j = 0; j < coding_subbands; j++ )
        {
            printf( "%d ", ind_order[j] );
@@ -815,6 +864,11 @@ ivas_error only_reduce_bits_direction(
        }
        sort_desc_ind( penalty, coding_subbands, ind_order );
    }
    for ( j = 0; j < coding_subbands; j++ )
    {
        printf( "%d ", ind_order[j] );
    }
    printf( "\n" );

    *reduce_bits_out = -reduce_bits;