Changeset 4114:41916d68d624 in roaraudio for libroardsp
- Timestamp:
- 08/06/10 17:18:49 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroardsp/convert.c
r4113 r4114 1209 1209 float y[3]; 1210 1210 float x_val; 1211 int32_t temp; 1211 1212 1212 1213 /* Can't create poly out of less than 3 samples in each channel. */ … … 1220 1221 memcpy(ip, in, ilen * sizeof(int16_t)); 1221 1222 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++) { 1224 1227 pos_in = (float)x / ratio; 1225 1228 … … 1229 1232 y[2] = ip[2 * channels + c]; 1230 1233 x_val = pos_in; 1234 roar_math_mkpoly_3x3(poly, y); 1231 1235 } else if ( (int)pos_in + 1 >= ilen/channels ) { 1232 1236 /* If we're at the end of the block, we will need to interpolate against a value that is not yet known. … … 1234 1238 y[0] = ip[((int)pos_in - 1) * channels + c]; 1235 1239 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; 1237 1244 x_val = pos_in - (int)pos_in + 1.0; 1238 1245 } else { … … 1241 1248 y[2] = ip[((int)pos_in + 1) * channels + c]; 1242 1249 x_val = pos_in - (int)pos_in + 1.0; 1250 roar_math_mkpoly_3x3(poly, y); 1243 1251 } 1244 1252 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); 1248 1255 /* temp could be out of bounds, so need to check this */ 1249 1256 if (temp > 0x7FFE ) { 1250 1257 out[x * channels + c] = 0x7FFE; 1251 } else if (temp < -0x7FF E) {1252 out[x * channels + c] = -0x7FF E;1258 } else if (temp < -0x7FFF) { 1259 out[x * channels + c] = -0x7FFF; 1253 1260 } else { 1254 1261 out[x * channels + c] = (int16_t)temp; … … 1256 1263 } 1257 1264 } 1265 1258 1266 roar_mm_free(ip); 1259 1267 return 0;
Note: See TracChangeset
for help on using the changeset viewer.