Loading lib_com/hp50_fx.c 100644 → 100755 +36 −2 Original line number Diff line number Diff line Loading @@ -340,6 +340,7 @@ void hp20( Word16 signal[], /* i/o: signal to filter any * /* Can be moved to options.h */ #define HP20_FIX32_RECODING //#define DEBUG_hp20 #ifdef HP20_FIX32_RECODING void hp20_fx_32( Loading Loading @@ -371,16 +372,23 @@ void hp20_fx_32( #endif diff = s_max( diff_pos, diff_neg ); diff = s_min( diff_pos, diff_neg ); IF( NE_16( diff, 0 ) ) { #ifdef DEBUG_hp20 printf( "diff1: %d diff_pos=%d diff_neg=%d mem_fx[2]=0x%08X mem_fx[3]=0x%08X prescale=%d prescaleOld=%d\n", diff, diff_pos, diff_neg, mem_fx[2], mem_fx[3], prescale, prescaleOld ); #endif prescale = s_min( prescale, diff ); } prescale = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) ); diff = sub( prescale, prescaleOld ); #ifdef DEBUG_hp20 printf( "diff2: %d prescale=%d prescaleOld=%d\n", diff, prescale, prescaleOld ); #endif #ifdef ISSUE_1836_replace_overflow_libcom mem_fx[0] = L_shr_sat( mem_fx[0], diff ); move32(); Loading Loading @@ -453,6 +461,11 @@ void hp20_fx_32( Word64 W_sum, W_y0, W_y1, W_y2; Word32 x0, x1, x2; #ifdef DEBUG_hp20 printf( "a1=0x%08X a2=0x%08X -- b1=0x%08X b2=0x%08X\n", a1_fx, a2_fx, b1_fx, b2_fx ); printf( "diff3: Prescale: %d (prescale_current_frame=%d)\n", getScaleFactor32( signal_fx, lg), prescale_current_frame ); #endif W_sum = W_mult_32_32( b2_fx, mem_fx[2] ); /* b2*x2 */ W_sum = W_mac_32_32( W_sum, b1_fx, mem_fx[3] ); /* b1*x1 */ x2 = L_shr( signal_fx[0], prescale ); Loading @@ -463,6 +476,9 @@ void hp20_fx_32( signal_fx_i = W_extract_h( W_shl( W_y2, prescale ) ); signal_fx[0] = signal_fx_i; move32(); #ifdef DEBUG_hp20 printf( "signal[%3d] = 0x%08X (0x%016llX << %d = 0x%016llX)\n", 0, signal_fx[0], W_y2, prescale, W_shl( W_y2, prescale ) ); #endif W_sum = W_mult_32_32( b2_fx, mem_fx[3] ); /* b2*x2 */ W_sum = W_mac_32_32( W_sum, b1_fx, x2 ); /* b1*x1 */ Loading @@ -474,6 +490,9 @@ void hp20_fx_32( signal_fx_i = W_extract_h( W_shl( W_y1, prescale ) ); signal_fx[1] = signal_fx_i; move32(); #ifdef DEBUG_hp20 printf( "signal[%3d] = 0x%08X (0x%016llX << %d = 0x%016llX)\n", 1, signal_fx[1], W_y1, prescale, W_shl( W_y1, prescale ) ); #endif diff = sub( prescale_current_frame, prescale ); W_y1 = W_shr( W_y1, diff ); Loading @@ -494,6 +513,9 @@ void hp20_fx_32( signal_fx_i = W_extract_h( W_shl( W_y0, prescale_current_frame ) ); signal_fx[i] = signal_fx_i; move32(); #ifdef DEBUG_hp20 printf( "signal[%3d] = 0x%08X (0x%016llX << %d = 0x%016llX)\n", i, signal_fx[i], W_y0, prescale_current_frame, W_shl( W_y0, prescale_current_frame ) ); #endif x2 = x1; x1 = x0; Loading Loading @@ -526,7 +548,7 @@ void hp20_fx_32( const Word32 Fs ) { Word16 i; Word32 a1_fx, a2_fx, b1_fx, b2_fx; Word32 a1_fx, a2_fx, b1_fx, b2_fx, signal_fx_i; Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin; Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5; Loading Loading @@ -579,6 +601,11 @@ void hp20_fx_32( move32(); move32(); #ifdef DEBUG_hp20 printf( "a1=0x%08X a2=0x%08X -- b1=0x%08X b2=0x%08X\n", a1_fx, a2_fx, b1_fx, b2_fx ); printf( "Prescale: %d\n", getScaleFactor32( signal_fx, lg ) ); #endif Qprev_y1 = extract_l( mem_fx[4] ); Qprev_y2 = extract_l( mem_fx[5] ); y1_fx64 = W_deposit32_l( mem_fx[0] ); Loading Loading @@ -660,6 +687,9 @@ void hp20_fx_32( } signal_fx[i] = signal_fx_i; move32(); #ifdef DEBUG_hp20 printf( "signal[%3d] = 0x%08X (0x%016llX >> %d = 0x%016llX)\n", i, signal_fx[i], y0_fx64, Qmin, W_shr( y0_fx64, Qmin ) ); #endif y2_fx64 = y1_fx64; y1_fx64 = y0_fx64; Loading Loading @@ -694,6 +724,10 @@ void hp20_fx_32( mem_fx[4] = Qprev_y1; mem_fx[5] = Qprev_y2; #ifdef DEBUG_hp20 printf("Headroom: %d\n", getScaleFactor32( signal_fx, lg )); #endif move32(); move32(); move32(); Loading Loading
lib_com/hp50_fx.c 100644 → 100755 +36 −2 Original line number Diff line number Diff line Loading @@ -340,6 +340,7 @@ void hp20( Word16 signal[], /* i/o: signal to filter any * /* Can be moved to options.h */ #define HP20_FIX32_RECODING //#define DEBUG_hp20 #ifdef HP20_FIX32_RECODING void hp20_fx_32( Loading Loading @@ -371,16 +372,23 @@ void hp20_fx_32( #endif diff = s_max( diff_pos, diff_neg ); diff = s_min( diff_pos, diff_neg ); IF( NE_16( diff, 0 ) ) { #ifdef DEBUG_hp20 printf( "diff1: %d diff_pos=%d diff_neg=%d mem_fx[2]=0x%08X mem_fx[3]=0x%08X prescale=%d prescaleOld=%d\n", diff, diff_pos, diff_neg, mem_fx[2], mem_fx[3], prescale, prescaleOld ); #endif prescale = s_min( prescale, diff ); } prescale = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) ); diff = sub( prescale, prescaleOld ); #ifdef DEBUG_hp20 printf( "diff2: %d prescale=%d prescaleOld=%d\n", diff, prescale, prescaleOld ); #endif #ifdef ISSUE_1836_replace_overflow_libcom mem_fx[0] = L_shr_sat( mem_fx[0], diff ); move32(); Loading Loading @@ -453,6 +461,11 @@ void hp20_fx_32( Word64 W_sum, W_y0, W_y1, W_y2; Word32 x0, x1, x2; #ifdef DEBUG_hp20 printf( "a1=0x%08X a2=0x%08X -- b1=0x%08X b2=0x%08X\n", a1_fx, a2_fx, b1_fx, b2_fx ); printf( "diff3: Prescale: %d (prescale_current_frame=%d)\n", getScaleFactor32( signal_fx, lg), prescale_current_frame ); #endif W_sum = W_mult_32_32( b2_fx, mem_fx[2] ); /* b2*x2 */ W_sum = W_mac_32_32( W_sum, b1_fx, mem_fx[3] ); /* b1*x1 */ x2 = L_shr( signal_fx[0], prescale ); Loading @@ -463,6 +476,9 @@ void hp20_fx_32( signal_fx_i = W_extract_h( W_shl( W_y2, prescale ) ); signal_fx[0] = signal_fx_i; move32(); #ifdef DEBUG_hp20 printf( "signal[%3d] = 0x%08X (0x%016llX << %d = 0x%016llX)\n", 0, signal_fx[0], W_y2, prescale, W_shl( W_y2, prescale ) ); #endif W_sum = W_mult_32_32( b2_fx, mem_fx[3] ); /* b2*x2 */ W_sum = W_mac_32_32( W_sum, b1_fx, x2 ); /* b1*x1 */ Loading @@ -474,6 +490,9 @@ void hp20_fx_32( signal_fx_i = W_extract_h( W_shl( W_y1, prescale ) ); signal_fx[1] = signal_fx_i; move32(); #ifdef DEBUG_hp20 printf( "signal[%3d] = 0x%08X (0x%016llX << %d = 0x%016llX)\n", 1, signal_fx[1], W_y1, prescale, W_shl( W_y1, prescale ) ); #endif diff = sub( prescale_current_frame, prescale ); W_y1 = W_shr( W_y1, diff ); Loading @@ -494,6 +513,9 @@ void hp20_fx_32( signal_fx_i = W_extract_h( W_shl( W_y0, prescale_current_frame ) ); signal_fx[i] = signal_fx_i; move32(); #ifdef DEBUG_hp20 printf( "signal[%3d] = 0x%08X (0x%016llX << %d = 0x%016llX)\n", i, signal_fx[i], W_y0, prescale_current_frame, W_shl( W_y0, prescale_current_frame ) ); #endif x2 = x1; x1 = x0; Loading Loading @@ -526,7 +548,7 @@ void hp20_fx_32( const Word32 Fs ) { Word16 i; Word32 a1_fx, a2_fx, b1_fx, b2_fx; Word32 a1_fx, a2_fx, b1_fx, b2_fx, signal_fx_i; Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin; Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5; Loading Loading @@ -579,6 +601,11 @@ void hp20_fx_32( move32(); move32(); #ifdef DEBUG_hp20 printf( "a1=0x%08X a2=0x%08X -- b1=0x%08X b2=0x%08X\n", a1_fx, a2_fx, b1_fx, b2_fx ); printf( "Prescale: %d\n", getScaleFactor32( signal_fx, lg ) ); #endif Qprev_y1 = extract_l( mem_fx[4] ); Qprev_y2 = extract_l( mem_fx[5] ); y1_fx64 = W_deposit32_l( mem_fx[0] ); Loading Loading @@ -660,6 +687,9 @@ void hp20_fx_32( } signal_fx[i] = signal_fx_i; move32(); #ifdef DEBUG_hp20 printf( "signal[%3d] = 0x%08X (0x%016llX >> %d = 0x%016llX)\n", i, signal_fx[i], y0_fx64, Qmin, W_shr( y0_fx64, Qmin ) ); #endif y2_fx64 = y1_fx64; y1_fx64 = y0_fx64; Loading Loading @@ -694,6 +724,10 @@ void hp20_fx_32( mem_fx[4] = Qprev_y1; mem_fx[5] = Qprev_y2; #ifdef DEBUG_hp20 printf("Headroom: %d\n", getScaleFactor32( signal_fx, lg )); #endif move32(); move32(); move32(); Loading