Changeset 4114:41916d68d624 in roaraudio for libroardsp


Ignore:
Timestamp:
08/06/10 17:18:49 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

optimize the code a bit more

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroardsp/convert.c

    r4113 r4114  
    12091209 float y[3]; 
    12101210 float x_val; 
     1211 int32_t temp; 
    12111212 
    12121213 /* Can't create poly out of less than 3 samples in each channel. */ 
     
    12201221 memcpy(ip, in, ilen * sizeof(int16_t)); 
    12211222 
    1222  for ( x = 0; x < olen/channels; x++ ) { 
    1223   for ( c = 0; c < channels; c++ ) { 
     1223 olen /= channels; 
     1224 
     1225 for (x = 0; x < olen; x++) { 
     1226  for (c = 0; c < channels; c++) { 
    12241227   pos_in = (float)x / ratio; 
    12251228 
     
    12291232    y[2] = ip[2 * channels + c]; 
    12301233    x_val = pos_in; 
     1234    roar_math_mkpoly_3x3(poly, y); 
    12311235   } else if ( (int)pos_in + 1 >= ilen/channels ) { 
    12321236    /* If we're at the end of the block, we will need to interpolate against a value that is not yet known. 
     
    12341238    y[0] = ip[((int)pos_in - 1) * channels + c]; 
    12351239    y[1] = ip[((int)pos_in    ) * channels + c]; 
    1236     y[2] = y[1] * 2.0 - y[0]; 
     1240 
     1241    // we create a 2x2 poly here and set the 3rd coefficient to zero to build a 3x3 poly 
     1242    roar_math_mkpoly_2x2(poly, y); 
     1243    poly[2] = 0; 
    12371244    x_val = pos_in - (int)pos_in + 1.0; 
    12381245   } else { 
     
    12411248    y[2] = ip[((int)pos_in + 1) * channels + c]; 
    12421249    x_val = pos_in - (int)pos_in + 1.0; 
     1250    roar_math_mkpoly_3x3(poly, y); 
    12431251   } 
    12441252 
    1245    roar_math_mkpoly_3x3(poly, y); 
    1246  
    1247    int32_t temp = (int32_t)(poly[2]*x_val*x_val + poly[1]*x_val + poly[0] + 0.5); 
     1253 
     1254   temp = (float)(poly[2]*x_val*x_val + poly[1]*x_val + poly[0] + 0.5); 
    12481255   /* temp could be out of bounds, so need to check this */ 
    12491256   if (temp > 0x7FFE ) { 
    12501257    out[x * channels + c] =  0x7FFE; 
    1251    } else if (temp < -0x7FFE) { 
    1252     out[x * channels + c] = -0x7FFE; 
     1258   } else if (temp < -0x7FFF) { 
     1259    out[x * channels + c] = -0x7FFF; 
    12531260   } else { 
    12541261    out[x * channels + c] = (int16_t)temp; 
     
    12561263  } 
    12571264 } 
     1265 
    12581266 roar_mm_free(ip); 
    12591267 return 0; 
Note: See TracChangeset for help on using the changeset viewer.