Changeset 383:56f41c54f169 in roaraudio


Ignore:
Timestamp:
08/06/08 04:03:43 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added working 16 bit mono resampling code

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/libroardsp/convert.h

    r0 r383  
    2626int roar_conv       (void * out, void * in, int samples, struct roar_audio_info * from, struct roar_audio_info * to); 
    2727 
     28 
     29int roar_conv_poly4_16 (int16_t * out, int16_t * in, size_t olen, size_t ilen); 
     30 
    2831#endif 
    2932 
  • include/libroardsp/poly.h

    r30 r383  
    1313int roar_math_mkpoly_5x5 (float * poly, float * data); 
    1414 
     15float roar_math_cvpoly_4x4 (float * poly, float t); 
    1516 
    1617#endif 
  • libroardsp/convert.c

    r59 r383  
    222222} 
    223223 
     224 
     225 
     226int roar_conv_poly4_16 (int16_t * out, int16_t * in, size_t olen, size_t ilen) { 
     227 float poly[4]; 
     228 float data[4]; 
     229 float t    = 0; 
     230 float step = (float)ilen/olen; 
     231 int16_t * ci = in; 
     232 int io, ii = 0; 
     233 int i; 
     234 
     235 // we can not make a poly4 with less than 4 points ;) 
     236 if ( ilen < 4 ) 
     237  return -1; 
     238 
     239 for (i = 0; i < 4; i++) 
     240  data[i] = ci[i]; 
     241 roar_math_mkpoly_4x4(poly, data); 
     242/* 
     243 printf("new poly: data[4] = {%f, %f, %f, %f}, poly[4] = {%f, %f, %f, %f}\n", 
     244         data[0], data[1], data[2], data[3], 
     245         poly[0], poly[1], poly[2], poly[3] 
     246       ); 
     247*/ 
     248 
     249 //0 1 2 3 
     250 
     251 for (io = 0; io < olen; io++) { 
     252//  printf("t=%f\n", t); 
     253  out[io] = roar_math_cvpoly_4x4(poly, t); 
     254  t += step; 
     255  if ( t > 2 ) { // we need a new ploynome 
     256 //  printf("t > 2, need new data\n"); 
     257   if ( (ii + 4) < ilen ) { // else: end of block. 
     258    t -= 1; 
     259//    printf("new data: ii=%i\n", ii); 
     260    ii++; 
     261    ci++; 
     262    for (i = 0; i < 4; i++) 
     263     data[i] = ci[i]; 
     264    roar_math_mkpoly_4x4(poly, data); 
     265/*  
     266   printf("new poly: data[4] = {%f, %f, %f, %f}, poly[4] = {%f, %f, %f, %f}\n", 
     267           data[0], data[1], data[2], data[3], 
     268           poly[0], poly[1], poly[2], poly[3] 
     269          ); 
     270*/ 
     271   } 
     272  } 
     273 } 
     274 
     275 return 0; 
     276} 
     277 
    224278//ll 
  • libroardsp/poly.c

    r49 r383  
    7272} 
    7373 
     74 
     75float roar_math_cvpoly_4x4 (float * poly, float t) { 
     76 float ret = poly[0]; 
     77 float ct  = t; 
     78 
     79 ret += poly[1] * ct; 
     80 ct  *= t; 
     81 ret += poly[2] * ct; 
     82 ct  *= t; 
     83 ret += poly[3] * ct; 
     84 
     85// printf("ret=%f\n", ret); 
     86 
     87 return ret; 
     88} 
     89 
    7490//ll 
Note: See TracChangeset for help on using the changeset viewer.