Forrest
2019-Jun-14 18:00 UTC
[opus] resample of libopusenc-0.2.1 outputs all zeros if define FIXED_POINT
Actually opus-tools-0.2 has the same issue. Sincerely Forrest Zhang -------------- next part -------------- Add "#define FIXED_POINT 1" into the top of resample.c, outputs of resample are all zeros. Actually the data transform is required before/after calling speex_resampler_process_native(). diff -Naupr libopusenc-0.2.1-vanilla/src/resample.c libopusenc-0.2.1/src/resample.c --- libopusenc-0.2.1-vanilla/src/resample.c 2018-09-15 10:35:06 +0800 +++ libopusenc-0.2.1/src/resample.c 2019-06-15 01:32:37 +0800 @@ -82,7 +82,7 @@ static void speex_free(void *ptr) {free( #include <limits.h> #ifndef M_PI -#define M_PI 3.14159265358979323846 +#define M_PI 3.14159265358979323846f #endif #define IMAX(a,b) ((a) > (b) ? (a) : (b)) @@ -1000,7 +1000,8 @@ EXPORT int speex_resampler_process_int(S if (in) { for(j=0;j<ichunk;++j) #ifdef FIXED_POINT - x[j+st->filt_len-1]=WORD2INT(in[j*istride_save]); + /* [-1.0, 1.0] ==> [-32768, 32767] */ + x[j+st->filt_len-1]=WORD2INT(32768 * in[j*istride_save]); #else x[j+st->filt_len-1]=in[j*istride_save]; #endif @@ -1017,7 +1018,8 @@ EXPORT int speex_resampler_process_int(S for (j=0;j<ochunk+omagic;++j) #ifdef FIXED_POINT - out[j*ostride_save] = ystack[j]; + /* [-32768, 32767] ==> [-1.0, 1.0] */ + out[j*ostride_save] = ystack[j] / 32768.f; #else out[j*ostride_save] = WORD2INT(ystack[j]); #endif