Changeset 35:cafb8920bb19 in roaraudio
- Timestamp:
- 06/22/08 03:54:19 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroardsp/convert.c
r33 r35 97 97 98 98 int roar_conv_rate_16 (void * out, void * in, int samples, int from, int to, int channels) { 99 int16_t * ip = in, * op = out;100 int16_t avg;101 int i, j, c;102 float scale = to/from;103 int step;104 105 106 if ( scale > 1 ) {107 if ( scale - (int)scale != (float)0 )108 return -1;109 110 step = scale;111 /*112 for (i = 0; i < samples/step; i++)113 for (j = 0; j < step; j++)114 for (c = 0; c < channels; c++)115 op[i + j*channels + c] = ip[i + c];116 */117 if ( step == 2 ) {118 for (i = 0; i < samples/step; i += channels) {119 for (j = 0; j < step; j++) {120 for (c = 0; c < channels; c++) {121 op[i*step + j*channels + c] = ip[i+c];122 }123 }124 }125 return 0;126 }127 return -1;128 } else {129 scale = 1/scale;130 131 if ( scale - (int)scale != (float)0 )132 return -1;133 134 step = scale;135 136 for (i = 0; i < samples/step; i++) {137 avg = 0;138 for (j = 0; j < step; j++)139 avg += ip[i*step + j];140 141 op[i] = avg/step;142 }143 return 0;144 }145 146 99 return -1; 147 100 }
Note: See TracChangeset
for help on using the changeset viewer.