Unified · Split
| @@ -69,6 +69,12 @@ optional(EXTERNAL_GSM gsm/gsm.h gsm gsm_create "") · 68 unmodified lines | |||
| 69 | optional(HAVE_ALSA alsa/asoundlib.h asound snd_pcm_open alsa) | 69 | optional(HAVE_ALSA alsa/asoundlib.h asound snd_pcm_open alsa) |
| 70 | optional(HAVE_AMRNB amrnb/sp_dec.h amrnb Decoder_Interface_init amr-nb) | 70 | optional(HAVE_AMRNB amrnb/sp_dec.h amrnb Decoder_Interface_init amr-nb) |
| 71 | optional(HAVE_AMRWB amrwb/dec.h amrwb D_IF_init amr-wb) | 71 | optional(HAVE_AMRWB amrwb/dec.h amrwb D_IF_init amr-wb) |
| 72 | if(CMAKE_COMPILER_IS_GNUCC) | ||
| 73 | optional(HAVE_OPENMP omp.h gomp omp_get_thread_num "") | ||
| 74 | if(HAVE_OPENMP) | ||
| 75 | add_definitions(-fopenmp) | ||
| 76 | endif(HAVE_OPENMP) | ||
| 77 | endif(CMAKE_COMPILER_IS_GNUCC) | ||
| 72 | optional(HAVE_ID3TAG id3tag.h id3tag id3_file_open "") | 78 | optional(HAVE_ID3TAG id3tag.h id3tag id3_file_open "") |
| 73 | optional(HAVE_LIBAO ao/ao.h ao ao_play ao) | 79 | optional(HAVE_LIBAO ao/ao.h ao ao_play ao) |
| 74 | optional(HAVE_FLAC FLAC/all.h FLAC FLAC__stream_encoder_new flac) | 80 | optional(HAVE_FLAC FLAC/all.h FLAC FLAC__stream_encoder_new flac) |
| @@ -183,7 +183,7 @@ AC_SUBST(LIBTOOLFLAGS) · 182 unmodified lines | |||
| 183 | dnl Check for GOMP | 183 | dnl Check for GOMP |
| 184 | AC_MSG_CHECKING([whether to use GOMP]) | 184 | AC_MSG_CHECKING([whether to use GOMP]) |
| 185 | AC_ARG_ENABLE(gomp, | 185 | AC_ARG_ENABLE(gomp, |
| 186 | AC_HELP_STRING([--enable-gomp], [Use GOMP.]),,enable_gomp=no) | 186 | AC_HELP_STRING([--disable-gomp], [Don't use GOMP.]),,enable_gomp=yes) |
| 187 | AC_MSG_RESULT($enable_gomp) | 187 | AC_MSG_RESULT($enable_gomp) |
| 188 | if test "$enable_gomp" = "yes"; then | 188 | if test "$enable_gomp" = "yes"; then |
| 189 | AC_CHECK_HEADERS(omp.h, | 189 | AC_CHECK_HEADERS(omp.h, |
| @@ -191,10 +191,10 @@ if test "$enable_gomp" = "yes"; then · 1 unmodified line | |||
| 191 | enable_gomp=no) | 191 | enable_gomp=no) |
| 192 | fi | 192 | fi |
| 193 | if test "$enable_gomp" = yes; then | 193 | if test "$enable_gomp" = yes; then |
| 194 | AC_DEFINE(HAVE_GOMP, 1, [Define to 1 if you have GOMP.]) | 194 | AC_DEFINE(HAVE_OPENMP, 1, [Define to 1 if you have GOMP.]) |
| 195 | CFLAGS="$CFLAGS -fopenmp" | 195 | CFLAGS="$CFLAGS -fopenmp" |
| 196 | fi | 196 | fi |
| 197 | AM_CONDITIONAL(HAVE_GOMP, test x$enable_gomp = xyes) | 197 | AM_CONDITIONAL(HAVE_OPENMP, test x$enable_gomp = xyes) |
| 198 | AC_SUBST(GOMP_LIBS) | 198 | AC_SUBST(GOMP_LIBS) |
| 199 | 199 | ||
| 200 | audio_driver_found=no | 200 | audio_driver_found=no |
| @@ -254,6 +254,7 @@ static int startwrite(sox_format_t * ft) · 253 unmodified lines | |||
| 254 | static size_t write_samples(sox_format_t * ft, const sox_sample_t *buf, size_t len) | 254 | static size_t write_samples(sox_format_t * ft, const sox_sample_t *buf, size_t len) |
| 255 | { | 255 | { |
| 256 | priv_t * p = (priv_t * ) ft->priv; | 256 | priv_t * p = (priv_t * ) ft->priv; |
| 257 | SOX_SAMPLE_LOCALS; | ||
| 257 | 258 | ||
| 258 | unsigned char datum; | 259 | unsigned char datum; |
| 259 | size_t done = 0, i; | 260 | size_t done = 0, i; |
| @@ -13,9 +13,7 @@ if(CMAKE_COMPILER_IS_GNUCC) · 12 unmodified lines | |||
| 13 | else(${ver} LESS 403) | 13 | else(${ver} LESS 403) |
| 14 | add_definitions(-Wtraditional-conversion) | 14 | add_definitions(-Wtraditional-conversion) |
| 15 | endif(${ver} LESS 403) | 15 | endif(${ver} LESS 403) |
| 16 | add_definitions(-Werror) | 16 | #add_definitions(-Werror) |
| 17 | add_definitions(-fopenmp) | ||
| 18 | set(optional_libs ${optional_libs} gomp) | ||
| 19 | endif(CMAKE_COMPILER_IS_GNUCC) | 17 | endif(CMAKE_COMPILER_IS_GNUCC) |
| 20 | 18 | ||
| 21 | if (NOT EXTERNAL_GSM) | 19 | if (NOT EXTERNAL_GSM) |
| @@ -251,6 +251,7 @@ size_t lsx_adpcm_write(sox_format_t * ft, adpcm_io_t * state, const sox_sample_t · 250 unmodified lines | |||
| 251 | short word; | 251 | short word; |
| 252 | 252 | ||
| 253 | while (count < length) { | 253 | while (count < length) { |
| 254 | SOX_SAMPLE_LOCALS; | ||
| 254 | word = SOX_SAMPLE_TO_SIGNED_16BIT(*buffer++, ft->clips); | 255 | word = SOX_SAMPLE_TO_SIGNED_16BIT(*buffer++, ft->clips); |
| 255 | 256 | ||
| 256 | byte <<= 4; | 257 | byte <<= 4; |
| @@ -536,12 +536,14 @@ static int startwrite(sox_format_t * ft) · 535 unmodified lines | |||
| 536 | 536 | ||
| 537 | static void sox_ub_write_buf(char* buf1, sox_sample_t const * buf2, size_t len, sox_bool swap UNUSED, size_t * clips) | 537 | static void sox_ub_write_buf(char* buf1, sox_sample_t const * buf2, size_t len, sox_bool swap UNUSED, size_t * clips) |
| 538 | { | 538 | { |
| 539 | SOX_SAMPLE_LOCALS; | ||
| 539 | while (len--) | 540 | while (len--) |
| 540 | *(uint8_t *)buf1++ = SOX_SAMPLE_TO_UNSIGNED_8BIT(*buf2++, *clips); | 541 | *(uint8_t *)buf1++ = SOX_SAMPLE_TO_UNSIGNED_8BIT(*buf2++, *clips); |
| 541 | } | 542 | } |
| 542 | 543 | ||
| 543 | static void sox_sb_write_buf(char *buf1, sox_sample_t const * buf2, size_t len, sox_bool swap UNUSED, size_t * clips) | 544 | static void sox_sb_write_buf(char *buf1, sox_sample_t const * buf2, size_t len, sox_bool swap UNUSED, size_t * clips) |
| 544 | { | 545 | { |
| 546 | SOX_SAMPLE_LOCALS; | ||
| 545 | while (len--) | 547 | while (len--) |
| 546 | *(int8_t *)buf1++ = SOX_SAMPLE_TO_SIGNED_8BIT(*buf2++, *clips); | 548 | *(int8_t *)buf1++ = SOX_SAMPLE_TO_SIGNED_8BIT(*buf2++, *clips); |
| 547 | } | 549 | } |
| @@ -550,6 +552,7 @@ static void sox_uw_write_buf(char *buf1, sox_sample_t const * buf2, size_t len, · 2 unmodified lines | |||
| 550 | { | 552 | { |
| 551 | while (len--) | 553 | while (len--) |
| 552 | { | 554 | { |
| 555 | SOX_SAMPLE_LOCALS; | ||
| 553 | uint16_t datum = SOX_SAMPLE_TO_UNSIGNED_16BIT(*buf2++, *clips); | 556 | uint16_t datum = SOX_SAMPLE_TO_UNSIGNED_16BIT(*buf2++, *clips); |
| 554 | if (swap) | 557 | if (swap) |
| 555 | datum = lsx_swapw(datum); | 558 | datum = lsx_swapw(datum); |
| @@ -562,6 +565,7 @@ static void sox_sw_write_buf(char *buf1, sox_sample_t const * buf2, size_t len, · 6 unmodified lines | |||
| 562 | { | 565 | { |
| 563 | while (len--) | 566 | while (len--) |
| 564 | { | 567 | { |
| 568 | SOX_SAMPLE_LOCALS; | ||
| 565 | int16_t datum = SOX_SAMPLE_TO_SIGNED_16BIT(*buf2++, *clips); | 569 | int16_t datum = SOX_SAMPLE_TO_SIGNED_16BIT(*buf2++, *clips); |
| 566 | if (swap) | 570 | if (swap) |
| 567 | datum = lsx_swapw(datum); | 571 | datum = lsx_swapw(datum); |
| @@ -117,6 +117,7 @@ static size_t write_samples(sox_format_t * ft, const sox_sample_t * buf, size_t · 116 unmodified lines | |||
| 117 | size_t done; | 117 | size_t done; |
| 118 | 118 | ||
| 119 | for (done = 0; done < len; ++done) { | 119 | for (done = 0; done < len; ++done) { |
| 120 | SOX_SAMPLE_LOCALS; | ||
| 120 | p->pcm[p->pcm_index++] = SOX_SAMPLE_TO_SIGNED_16BIT(*buf++, ft->clips); | 121 | p->pcm[p->pcm_index++] = SOX_SAMPLE_TO_SIGNED_16BIT(*buf++, ft->clips); |
| 121 | if (p->pcm_index == AMR_FRAME) { | 122 | if (p->pcm_index == AMR_FRAME) { |
| 122 | p->pcm_index = 0; | 123 | p->pcm_index = 0; |
| @@ -79,6 +79,7 @@ static void sox_sw_write_buf(char *buf1, sox_sample_t const * buf2, size_t len, · 78 unmodified lines | |||
| 79 | { | 79 | { |
| 80 | while (len--) | 80 | while (len--) |
| 81 | { | 81 | { |
| 82 | SOX_SAMPLE_LOCALS; | ||
| 82 | uint16_t datum = SOX_SAMPLE_TO_SIGNED_16BIT(*buf2++, *clips); | 83 | uint16_t datum = SOX_SAMPLE_TO_SIGNED_16BIT(*buf2++, *clips); |
| 83 | if (swap) | 84 | if (swap) |
| 84 | datum = lsx_swapw(datum); | 85 | datum = lsx_swapw(datum); |
| @@ -150,6 +150,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t * ibuf, · 149 unmodified lines | |||
| 150 | 150 | ||
| 151 | /* main processing loop */ | 151 | /* main processing loop */ |
| 152 | for (i = 0; i < len; i++) { | 152 | for (i = 0; i < len; i++) { |
| 153 | SOX_SAMPLE_LOCALS; | ||
| 153 | ++p->in_pos; | 154 | ++p->in_pos; |
| 154 | 155 | ||
| 155 | /* As long as we have not yet collected enough data just read in */ | 156 | /* As long as we have not yet collected enough data just read in */ |
| @@ -213,6 +213,7 @@ static size_t read_samples(sox_format_t *ft, sox_sample_t *buf, size_t nsamp) · 212 unmodified lines | |||
| 213 | size_t samp_left; | 213 | size_t samp_left; |
| 214 | OSStatus status; | 214 | OSStatus status; |
| 215 | float *p; | 215 | float *p; |
| 216 | SOX_SAMPLE_LOCALS; | ||
| 216 | 217 | ||
| 217 | if (!ac->device_started) | 218 | if (!ac->device_started) |
| 218 | { | 219 | { |
| @@ -263,6 +264,7 @@ static size_t write_samples(sox_format_t *ft, const sox_sample_t *buf, size_t ns · 44 unmodified lines | |||
| 263 | size_t samp_left; | 264 | size_t samp_left; |
| 264 | OSStatus status; | 265 | OSStatus status; |
| 265 | float *p; | 266 | float *p; |
| 267 | SOX_SAMPLE_LOCALS; | ||
| 266 | 268 | ||
| 267 | if (!ac->device_started) | 269 | if (!ac->device_started) |
| 268 | { | 270 | { |
| @@ -135,6 +135,7 @@ static size_t sox_datwrite(sox_format_t * ft, const sox_sample_t *buf, size_t ns · 134 unmodified lines | |||
| 135 | sprintf(s," %15.8g ",dat->timevalue); | 135 | sprintf(s," %15.8g ",dat->timevalue); |
| 136 | lsx_writes(ft, s); | 136 | lsx_writes(ft, s); |
| 137 | for (i=0; i<ft->signal.channels; i++) { | 137 | for (i=0; i<ft->signal.channels; i++) { |
| 138 | SOX_SAMPLE_LOCALS; | ||
| 138 | sampval = SOX_SAMPLE_TO_FLOAT_64BIT(*buf++, ft->clips); | 139 | sampval = SOX_SAMPLE_TO_FLOAT_64BIT(*buf++, ft->clips); |
| 139 | sprintf(s," %15.8g", sampval); | 140 | sprintf(s," %15.8g", sampval); |
| 140 | lsx_writes(ft, s); | 141 | lsx_writes(ft, s); |
| @@ -218,13 +218,15 @@ static int flow_effect(sox_effects_chain_t * chain, size_t n) · 217 unmodified lines | |||
| 218 | for (f = 0; f < (int)effp->flows; ++f) | 218 | for (f = 0; f < (int)effp->flows; ++f) |
| 219 | chain->ibufc[f][i / effp->flows] = *ibuf++; | 219 | chain->ibufc[f][i / effp->flows] = *ibuf++; |
| 220 | 220 | ||
| 221 | #ifdef HAVE_OPENMP | ||
| 221 | #pragma omp parallel for | 222 | #pragma omp parallel for |
| 223 | #endif | ||
| 222 | for (f = 0; f < (int)effp->flows; ++f) { | 224 | for (f = 0; f < (int)effp->flows; ++f) { |
| 223 | size_t idonec = idone / effp->flows; | 225 | size_t idonec = idone / effp->flows; |
| 224 | size_t odonec = obeg / effp->flows; | 226 | size_t odonec = obeg / effp->flows; |
| 225 | int eff_status_c = effp->handler.flow(&chain->effects[n][f], | 227 | int eff_status_c = effp->handler.flow(&chain->effects[n][f], |
| 226 | chain->ibufc[f], chain->obufc[f], &idonec, &odonec); | 228 | chain->ibufc[f], chain->obufc[f], &idonec, &odonec); |
| 227 | #ifndef HAVE_GOMP | 229 | #ifndef HAVE_OPENMP |
| 228 | if (f && (idonec != idone_last || odonec != odone_last)) { | 230 | if (f && (idonec != idone_last || odonec != odone_last)) { |
| 229 | lsx_fail("flowed asymmetrically!"); | 231 | lsx_fail("flowed asymmetrically!"); |
| 230 | effstatus = SOX_EOF; | 232 | effstatus = SOX_EOF; |
| @@ -397,26 +397,36 @@ int lsx_set_dft_length(int num_taps) /* Set to 4 x nearest power of 2 */ · 396 unmodified lines | |||
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | #include "fft4g.h" | 399 | #include "fft4g.h" |
| 400 | int * lsx_fft_br; | 400 | int * lsx_fft_br; |
| 401 | double * lsx_fft_sc; | 401 | double * lsx_fft_sc; |
| 402 | static int fft_len; | ||
| 403 | #ifdef HAVE_OPENMP | ||
| 404 | static omp_lock_t fft_cache_lock; | ||
| 405 | #endif | ||
| 406 | |||
| 407 | static void init_fft_cache(void) | ||
| 408 | { | ||
| 409 | omp_init_lock(&fft_cache_lock); | ||
| 410 | } | ||
| 411 | |||
| 412 | static void clear_fft_cache(void) | ||
| 413 | { | ||
| 414 | omp_destroy_lock(&fft_cache_lock); | ||
| 415 | free(lsx_fft_br); | ||
| 416 | free(lsx_fft_sc); | ||
| 417 | lsx_fft_sc = NULL; | ||
| 418 | lsx_fft_br = NULL; | ||
| 419 | fft_len = 0; | ||
| 420 | } | ||
| 402 | 421 | ||
| 403 | static void update_fft_cache(int len) | 422 | static void update_fft_cache(int len) |
| 404 | { | 423 | { |
| 405 | static int n; | 424 | omp_set_lock(&fft_cache_lock); |
| 406 | 425 | if (len > fft_len) { | |
| 407 | if (!len) { | 426 | int old_n = fft_len; |
| 408 | free(lsx_fft_br); | 427 | fft_len = len; |
| 409 | free(lsx_fft_sc); | 428 | lsx_fft_br = lsx_realloc(lsx_fft_br, dft_br_len(fft_len) * sizeof(*lsx_fft_br)); |
| 410 | lsx_fft_sc = NULL; | 429 | lsx_fft_sc = lsx_realloc(lsx_fft_sc, dft_sc_len(fft_len) * sizeof(*lsx_fft_sc)); |
| 411 | lsx_fft_br = NULL; | ||
| 412 | n = 0; | ||
| 413 | return; | ||
| 414 | } | ||
| 415 | if (len > n) { | ||
| 416 | int old_n = n; | ||
| 417 | n = len; | ||
| 418 | lsx_fft_br = lsx_realloc(lsx_fft_br, dft_br_len(n) * sizeof(*lsx_fft_br)); | ||
| 419 | lsx_fft_sc = lsx_realloc(lsx_fft_sc, dft_sc_len(n) * sizeof(*lsx_fft_sc)); | ||
| 420 | if (!old_n) | 430 | if (!old_n) |
| 421 | lsx_fft_br[0] = 0; | 431 | lsx_fft_br[0] = 0; |
| 422 | } | 432 | } |
| @@ -432,6 +442,7 @@ void lsx_safe_rdft(int len, int type, double * d) · 9 unmodified lines | |||
| 432 | assert(is_power_of_2(len)); | 442 | assert(is_power_of_2(len)); |
| 433 | update_fft_cache(len); | 443 | update_fft_cache(len); |
| 434 | lsx_rdft(len, type, d, lsx_fft_br, lsx_fft_sc); | 444 | lsx_rdft(len, type, d, lsx_fft_br, lsx_fft_sc); |
| 445 | omp_unset_lock(&fft_cache_lock); | ||
| 435 | } | 446 | } |
| 436 | 447 | ||
| 437 | void lsx_safe_cdft(int len, int type, double * d) | 448 | void lsx_safe_cdft(int len, int type, double * d) |
| @@ -439,6 +450,7 @@ void lsx_safe_cdft(int len, int type, double * d) · 1 unmodified line | |||
| 439 | assert(is_power_of_2(len)); | 450 | assert(is_power_of_2(len)); |
| 440 | update_fft_cache(len); | 451 | update_fft_cache(len); |
| 441 | lsx_cdft(len, type, d, lsx_fft_br, lsx_fft_sc); | 452 | lsx_cdft(len, type, d, lsx_fft_br, lsx_fft_sc); |
| 453 | omp_unset_lock(&fft_cache_lock); | ||
| 442 | } | 454 | } |
| 443 | 455 | ||
| 444 | void lsx_power_spectrum(int n, double const * in, double * out) | 456 | void lsx_power_spectrum(int n, double const * in, double * out) |
| @@ -536,3 +548,14 @@ void lsx_apply_kaiser(double h[], const int num_points, double beta) · 91 unmodified lines | |||
| 536 | } | 548 | } |
| 537 | } | 549 | } |
| 538 | 550 | ||
| 551 | int lsx_effects_init(void) | ||
| 552 | { | ||
| 553 | init_fft_cache(); | ||
| 554 | return SOX_SUCCESS; | ||
| 555 | } | ||
| 556 | |||
| 557 | int lsx_effects_quit(void) | ||
| 558 | { | ||
| 559 | clear_fft_cache(); | ||
| 560 | return SOX_SUCCESS; | ||
| 561 | } | ||
| @@ -38,7 +38,7 @@ int main(int argc, char * argv[]) · 37 unmodified lines | |||
| 38 | assert(argc == 3); | 38 | assert(argc == 3); |
| 39 | 39 | ||
| 40 | /* All libSoX applications must start by initialising the SoX library */ | 40 | /* All libSoX applications must start by initialising the SoX library */ |
| 41 | assert(sox_format_init() == SOX_SUCCESS); | 41 | assert(sox_init() == SOX_SUCCESS); |
| 42 | 42 | ||
| 43 | /* Open the input file (with default parameters) */ | 43 | /* Open the input file (with default parameters) */ |
| 44 | assert(in = sox_open_read(argv[1], NULL, NULL, NULL)); | 44 | assert(in = sox_open_read(argv[1], NULL, NULL, NULL)); |
| @@ -110,7 +110,7 @@ int main(int argc, char * argv[]) · 109 unmodified lines | |||
| 110 | assert(argc == 3); | 110 | assert(argc == 3); |
| 111 | 111 | ||
| 112 | /* All libSoX applications must start by initialising the SoX library */ | 112 | /* All libSoX applications must start by initialising the SoX library */ |
| 113 | assert(sox_format_init() == SOX_SUCCESS); | 113 | assert(sox_init() == SOX_SUCCESS); |
| 114 | 114 | ||
| 115 | /* Open the input file (with default parameters) */ | 115 | /* Open the input file (with default parameters) */ |
| 116 | assert(in = sox_open_read(argv[1], NULL, NULL, NULL)); | 116 | assert(in = sox_open_read(argv[1], NULL, NULL, NULL)); |
| @@ -87,6 +87,7 @@ int main(int argc, char * argv[]) · 86 unmodified lines | |||
| 87 | int l, r; | 87 | int l, r; |
| 88 | 88 | ||
| 89 | for (i = 0; i < block_size; ++i) { | 89 | for (i = 0; i < block_size; ++i) { |
| 90 | SOX_SAMPLE_LOCALS; | ||
| 90 | /* convert the sample from SoX's internal format to a `double' for | 91 | /* convert the sample from SoX's internal format to a `double' for |
| 91 | * processing in this application: */ | 92 | * processing in this application: */ |
| 92 | double sample = SOX_SAMPLE_TO_FLOAT_64BIT(buf[i], clips); | 93 | double sample = SOX_SAMPLE_TO_FLOAT_64BIT(buf[i], clips); |
| @@ -406,6 +406,7 @@ static size_t write_samples(sox_format_t * ft, const sox_sample_t *buf, size_t l · 405 unmodified lines | |||
| 406 | do { | 406 | do { |
| 407 | /* If output frame is not full, copy data into it */ | 407 | /* If output frame is not full, copy data into it */ |
| 408 | if (ffmpeg->samples_index < ffmpeg->audio_input_frame_size) { | 408 | if (ffmpeg->samples_index < ffmpeg->audio_input_frame_size) { |
| 409 | SOX_SAMPLE_LOCALS; | ||
| 409 | for (; nread < len && ffmpeg->samples_index < ffmpeg->audio_input_frame_size; nread++) | 410 | for (; nread < len && ffmpeg->samples_index < ffmpeg->audio_input_frame_size; nread++) |
| 410 | ffmpeg->samples[ffmpeg->samples_index++] = SOX_SAMPLE_TO_SIGNED_16BIT(buf[nread], ft->clips); | 411 | ffmpeg->samples[ffmpeg->samples_index++] = SOX_SAMPLE_TO_SIGNED_16BIT(buf[nread], ft->clips); |
| 411 | } | 412 | } |
| @@ -436,6 +436,7 @@ static size_t write_samples(sox_format_t * const ft, sox_sample_t const * const · 435 unmodified lines | |||
| 436 | unsigned i; | 436 | unsigned i; |
| 437 | 437 | ||
| 438 | for (i = 0; i < len; ++i) { | 438 | for (i = 0; i < len; ++i) { |
| 439 | SOX_SAMPLE_LOCALS; | ||
| 439 | long pcm = SOX_SAMPLE_TO_SIGNED_32BIT(sampleBuffer[i], ft->clips); | 440 | long pcm = SOX_SAMPLE_TO_SIGNED_32BIT(sampleBuffer[i], ft->clips); |
| 440 | p->decoded_samples[i] = pcm >> (32 - p->bits_per_sample); | 441 | p->decoded_samples[i] = pcm >> (32 - p->bits_per_sample); |
| 441 | switch (p->bits_per_sample) { | 442 | switch (p->bits_per_sample) { |
| @@ -195,6 +195,7 @@ static size_t sox_gsmwrite(sox_format_t * ft, const sox_sample_t *buf, size_t sa · 194 unmodified lines | |||
| 195 | 195 | ||
| 196 | while (done < samp) | 196 | while (done < samp) |
| 197 | { | 197 | { |
| 198 | SOX_SAMPLE_LOCALS; | ||
| 198 | while ((p->samplePtr < p->sampleTop) && (done < samp)) | 199 | while ((p->samplePtr < p->sampleTop) && (done < samp)) |
| 199 | *(p->samplePtr)++ = | 200 | *(p->samplePtr)++ = |
| 200 | SOX_SAMPLE_TO_SIGNED_16BIT(buf[done++], ft->clips); | 201 | SOX_SAMPLE_TO_SIGNED_16BIT(buf[done++], ft->clips); |
| @@ -277,6 +277,7 @@ static size_t write_samples(sox_format_t * ft, const sox_sample_t *buf, size_t l · 276 unmodified lines | |||
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | for (i = 0; i < len; i++) { | 279 | for (i = 0; i < len; i++) { |
| 280 | SOX_SAMPLE_LOCALS; | ||
| 280 | datum = *buf++; | 281 | datum = *buf++; |
| 281 | p->data[p->pos++] = SOX_SAMPLE_TO_UNSIGNED_8BIT(datum, ft->clips); | 282 | p->data[p->pos++] = SOX_SAMPLE_TO_UNSIGNED_8BIT(datum, ft->clips); |
| 282 | } | 283 | } |
| @@ -230,6 +230,7 @@ static int sox_ladspa_flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_sa · 229 unmodified lines | |||
| 230 | 230 | ||
| 231 | if (len) { | 231 | if (len) { |
| 232 | LADSPA_Data *buf = lsx_malloc(sizeof(LADSPA_Data) * len); | 232 | LADSPA_Data *buf = lsx_malloc(sizeof(LADSPA_Data) * len); |
| 233 | SOX_SAMPLE_LOCALS; | ||
| 233 | 234 | ||
| 234 | /* Insert input if effect takes it */ | 235 | /* Insert input if effect takes it */ |
| 235 | if (l_st->input_port != ULONG_MAX) { | 236 | if (l_st->input_port != ULONG_MAX) { |
| @@ -85,3 +85,14 @@ SOX_MESSAGE_FUNCTION(lsx_debug_most , 6) · 84 unmodified lines | |||
| 85 | 85 | ||
| 86 | #undef SOX_MESSAGE_FUNCTION | 86 | #undef SOX_MESSAGE_FUNCTION |
| 87 | 87 | ||
| 88 | int sox_init(void) | ||
| 89 | { | ||
| 90 | sox_format_init(); | ||
| 91 | return lsx_effects_init(); | ||
| 92 | } | ||
| 93 | |||
| 94 | int sox_quit(void) | ||
| 95 | { | ||
| 96 | sox_format_quit(); | ||
| 97 | return lsx_effects_quit(); | ||
| 98 | } | ||
| @@ -161,6 +161,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t * ibuf, · 160 unmodified lines | |||
| 161 | priv_t * p = (priv_t *)effp->priv; | 161 | priv_t * p = (priv_t *)effp->priv; |
| 162 | size_t i, odone = min(*osamp, (size_t)fifo_occupancy(&p->output_fifo)); | 162 | size_t i, odone = min(*osamp, (size_t)fifo_occupancy(&p->output_fifo)); |
| 163 | double const * s = fifo_read(&p->output_fifo, (int)odone, NULL); | 163 | double const * s = fifo_read(&p->output_fifo, (int)odone, NULL); |
| 164 | SOX_SAMPLE_LOCALS; | ||
| 164 | 165 | ||
| 165 | for (i = 0; i < odone; ++i) | 166 | for (i = 0; i < odone; ++i) |
| 166 | *obuf++ = SOX_FLOAT_64BIT_TO_SAMPLE(*s++, effp->clips); | 167 | *obuf++ = SOX_FLOAT_64BIT_TO_SAMPLE(*s++, effp->clips); |
| @@ -153,6 +153,7 @@ static size_t read_samples(sox_format_t * ft, sox_sample_t *buf, size_t len) · 152 unmodified lines | |||
| 153 | size_t nread = 0; | 153 | size_t nread = 0; |
| 154 | 154 | ||
| 155 | while (nread < len) { | 155 | while (nread < len) { |
| 156 | SOX_SAMPLE_LOCALS; | ||
| 156 | /* Read more data if buffer is empty */ | 157 | /* Read more data if buffer is empty */ |
| 157 | if (lpc->samples == LPC10_SAMPLES_PER_FRAME) { | 158 | if (lpc->samples == LPC10_SAMPLES_PER_FRAME) { |
| 158 | INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME]; | 159 | INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME]; |
| @@ -178,6 +179,7 @@ static size_t write_samples(sox_format_t * ft, const sox_sample_t *buf, size_t l · 19 unmodified lines | |||
| 178 | 179 | ||
| 179 | while (len > 0) { | 180 | while (len > 0) { |
| 180 | while (len > 0 && lpc->samples < LPC10_SAMPLES_PER_FRAME) { | 181 | while (len > 0 && lpc->samples < LPC10_SAMPLES_PER_FRAME) { |
| 182 | SOX_SAMPLE_LOCALS; | ||
| 181 | lpc->speech[lpc->samples++] = SOX_SAMPLE_TO_FLOAT_32BIT(buf[nwritten++], ft->clips); | 183 | lpc->speech[lpc->samples++] = SOX_SAMPLE_TO_FLOAT_32BIT(buf[nwritten++], ft->clips); |
| 182 | len--; | 184 | len--; |
| 183 | } | 185 | } |
| @@ -406,6 +406,7 @@ static size_t sox_mp3write(sox_format_t * ft, const sox_sample_t *buf, size_t sa · 405 unmodified lines | |||
| 406 | int i,j; | 406 | int i,j; |
| 407 | ptrdiff_t done = 0; | 407 | ptrdiff_t done = 0; |
| 408 | size_t written; | 408 | size_t written; |
| 409 | SOX_SAMPLE_LOCALS; | ||
| 409 | 410 | ||
| 410 | /* NOTE: This logic assumes that "short int" is 16-bits | 411 | /* NOTE: This logic assumes that "short int" is 16-bits |
| 411 | * on all platforms. It happens to be for all that I know | 412 | * on all platforms. It happens to be for all that I know |
| @@ -442,9 +443,7 @@ static size_t sox_mp3write(sox_format_t * ft, const sox_sample_t *buf, size_t sa · 30 unmodified lines | |||
| 442 | { | 443 | { |
| 443 | j=0; | 444 | j=0; |
| 444 | for (i=0; i<nsamples; i++) | 445 | for (i=0; i<nsamples; i++) |
| 445 | { | ||
| 446 | buffer_l[i]=SOX_SAMPLE_TO_SIGNED_16BIT(buf[j++], ft->clips); | 446 | buffer_l[i]=SOX_SAMPLE_TO_SIGNED_16BIT(buf[j++], ft->clips); |
| 447 | } | ||
| 448 | } | 447 | } |
| 449 | 448 | ||
| 450 | mp3buffer_size = 1.25 * nsamples + 7200; | 449 | mp3buffer_size = 1.25 * nsamples + 7200; |
| @@ -124,6 +124,7 @@ static int sox_noiseprof_flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox · 123 unmodified lines | |||
| 124 | 124 | ||
| 125 | /* Collect data for every channel. */ | 125 | /* Collect data for every channel. */ |
| 126 | for (i = 0; i < chans; i ++) { | 126 | for (i = 0; i < chans; i ++) { |
| 127 | SOX_SAMPLE_LOCALS; | ||
| 127 | chandata_t * chan = &(p->chandata[i]); | 128 | chandata_t * chan = &(p->chandata[i]); |
| 128 | for (j = 0; j < n; j ++) | 129 | for (j = 0; j < n; j ++) |
| 129 | chan->window[j + p->bufdata] = | 130 | chan->window[j + p->bufdata] = |
| @@ -230,6 +230,7 @@ static int process_window(sox_effect_t * effp, priv_t * data, unsigned chan_num, · 229 unmodified lines | |||
| 230 | int use = min(len, WINDOWSIZE)-min(len,(WINDOWSIZE/2)); | 230 | int use = min(len, WINDOWSIZE)-min(len,(WINDOWSIZE/2)); |
| 231 | chandata_t *chan = &(data->chandata[chan_num]); | 231 | chandata_t *chan = &(data->chandata[chan_num]); |
| 232 | int first = (chan->lastwindow == NULL); | 232 | int first = (chan->lastwindow == NULL); |
| 233 | SOX_SAMPLE_LOCALS; | ||
| 233 | 234 | ||
| 234 | if ((nextwindow = lsx_calloc(WINDOWSIZE, sizeof(float))) == NULL) | 235 | if ((nextwindow = lsx_calloc(WINDOWSIZE, sizeof(float))) == NULL) |
| 235 | return SOX_EOF; | 236 | return SOX_EOF; |
| @@ -283,6 +284,7 @@ static int sox_noisered_flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_ · 47 unmodified lines | |||
| 283 | 284 | ||
| 284 | /* Reduce noise on every channel. */ | 285 | /* Reduce noise on every channel. */ |
| 285 | for (i = 0; i < tracks; i ++) { | 286 | for (i = 0; i < tracks; i ++) { |
| 287 | SOX_SAMPLE_LOCALS; | ||
| 286 | chandata_t* chan = &(data->chandata[i]); | 288 | chandata_t* chan = &(data->chandata[i]); |
| 287 | size_t j; | 289 | size_t j; |
| 288 | 290 | ||
| @@ -63,6 +63,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t * ibuf, · 62 unmodified lines | |||
| 63 | return SOX_EOF; | 63 | return SOX_EOF; |
| 64 | } | 64 | } |
| 65 | if (p->balance) for (len = *isamp; len; --len, ++ibuf) { | 65 | if (p->balance) for (len = *isamp; len; --len, ++ibuf) { |
| 66 | SOX_SAMPLE_LOCALS; | ||
| 66 | size_t dummy = 0; | 67 | size_t dummy = 0; |
| 67 | double d = SOX_SAMPLE_TO_FLOAT_64BIT(*ibuf, dummy); | 68 | double d = SOX_SAMPLE_TO_FLOAT_64BIT(*ibuf, dummy); |
| 68 | p->rms += sqr(d); | 69 | p->rms += sqr(d); |
| @@ -50,6 +50,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t * ibuf, · 49 unmodified lines | |||
| 50 | priv_t * p = (priv_t *)effp->priv; | 50 | priv_t * p = (priv_t *)effp->priv; |
| 51 | size_t dummy = 0, len = *isamp = *osamp = min(*isamp, *osamp); | 51 | size_t dummy = 0, len = *isamp = *osamp = min(*isamp, *osamp); |
| 52 | while (len--) { | 52 | while (len--) { |
| 53 | SOX_SAMPLE_LOCALS; | ||
| 53 | double d = SOX_SAMPLE_TO_FLOAT_64BIT(*ibuf++, dummy), d0 = d; | 54 | double d = SOX_SAMPLE_TO_FLOAT_64BIT(*ibuf++, dummy), d0 = d; |
| 54 | d *= p->gain; | 55 | d *= p->gain; |
| 55 | d += p->colour; | 56 | d += p->colour; |
| @@ -114,6 +114,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_sample_t *obu · 113 unmodified lines | |||
| 114 | size_t isamples0 = d->input_frames * channels; | 114 | size_t isamples0 = d->input_frames * channels; |
| 115 | size_t isamples = isamples0 + *isamp; | 115 | size_t isamples = isamples0 + *isamp; |
| 116 | size_t osamples = isamples * (d->src_ratio + 0.01) + 8; | 116 | size_t osamples = isamples * (d->src_ratio + 0.01) + 8; |
| 117 | SOX_SAMPLE_LOCALS; | ||
| 117 | 118 | ||
| 118 | if (osamples > *osamp) { | 119 | if (osamples > *osamp) { |
| 119 | osamples = *osamp; | 120 | osamples = *osamp; |
| @@ -623,6 +623,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t * ibuf, · 622 unmodified lines | |||
| 623 | { | 623 | { |
| 624 | priv_t * p = (priv_t *)effp->priv; | 624 | priv_t * p = (priv_t *)effp->priv; |
| 625 | size_t i, odone = *osamp; | 625 | size_t i, odone = *osamp; |
| 626 | SOX_SAMPLE_LOCALS; | ||
| 626 | 627 | ||
| 627 | sample_t const * s = rate_output(&p->rate, NULL, &odone); | 628 | sample_t const * s = rate_output(&p->rate, NULL, &odone); |
| 628 | for (i = 0; i < odone; ++i) *obuf++ = TO_SOX(*s++, effp->clips); | 629 | for (i = 0; i < odone; ++i) *obuf++ = TO_SOX(*s++, effp->clips); |
| @@ -69,6 +69,7 @@ int lsx_rawstart(sox_format_t * ft, sox_bool default_rate, · 68 unmodified lines | |||
| 69 | sox_format_t * ft, sox_sample_t *buf, size_t len) \ | 69 | sox_format_t * ft, sox_sample_t *buf, size_t len) \ |
| 70 | { \ | 70 | { \ |
| 71 | size_t n, nread; \ | 71 | size_t n, nread; \ |
| 72 | SOX_SAMPLE_LOCALS; \ | ||
| 72 | ctype *data = lsx_malloc(sizeof(ctype) * len); \ | 73 | ctype *data = lsx_malloc(sizeof(ctype) * len); \ |
| 73 | nread = lsx_read_ ## type ## _buf(ft, (uctype *)data, len); \ | 74 | nread = lsx_read_ ## type ## _buf(ft, (uctype *)data, len); \ |
| 74 | for (n = 0; n < nread; n++) \ | 75 | for (n = 0; n < nread; n++) \ |
| @@ -94,6 +95,7 @@ READ_SAMPLES_FUNC(df, sizeof(double), su, double, double, SOX_FLOAT_64BIT_TO_SAM · 19 unmodified lines | |||
| 94 | static size_t sox_write_ ## sign ## type ## _samples( \ | 95 | static size_t sox_write_ ## sign ## type ## _samples( \ |
| 95 | sox_format_t * ft, sox_sample_t const * buf, size_t len) \ | 96 | sox_format_t * ft, sox_sample_t const * buf, size_t len) \ |
| 96 | { \ | 97 | { \ |
| 98 | SOX_SAMPLE_LOCALS; \ | ||
| 97 | size_t n, nwritten; \ | 99 | size_t n, nwritten; \ |
| 98 | ctype *data = lsx_malloc(sizeof(ctype) * len); \ | 100 | ctype *data = lsx_malloc(sizeof(ctype) * len); \ |
| 99 | for (n = 0; n < len; n++) \ | 101 | for (n = 0; n < len; n++) \ |
| @@ -219,6 +219,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t * ibuf, · 218 unmodified lines | |||
| 219 | { | 219 | { |
| 220 | priv_t * p = (priv_t *)effp->priv; | 220 | priv_t * p = (priv_t *)effp->priv; |
| 221 | size_t c, i, w, len = min(*isamp / p->ichannels, *osamp / p->ochannels); | 221 | size_t c, i, w, len = min(*isamp / p->ichannels, *osamp / p->ochannels); |
| 222 | SOX_SAMPLE_LOCALS; | ||
| 222 | 223 | ||
| 223 | *isamp = len * p->ichannels, *osamp = len * p->ochannels; | 224 | *isamp = len * p->ichannels, *osamp = len * p->ochannels; |
| 224 | for (c = 0; c < p->ichannels; ++c) | 225 | for (c = 0; c < p->ichannels; ++c) |
| @@ -280,6 +280,7 @@ static int aboveThreshold(sox_effect_t * effp, sox_sample_t value, double thresh · 279 unmodified lines | |||
| 280 | /* Only consider the original bits when looking for silence */ | 280 | /* Only consider the original bits when looking for silence */ |
| 281 | switch(effp->in_signal.precision) | 281 | switch(effp->in_signal.precision) |
| 282 | { | 282 | { |
| 283 | SOX_SAMPLE_LOCALS; | ||
| 283 | case 8: | 284 | case 8: |
| 284 | value = SOX_SAMPLE_TO_SIGNED_8BIT(value, dummy_clipped_count); | 285 | value = SOX_SAMPLE_TO_SIGNED_8BIT(value, dummy_clipped_count); |
| 285 | ratio = (double)abs(value) / (double)SOX_INT8_MAX; | 286 | ratio = (double)abs(value) / (double)SOX_INT8_MAX; |
| @@ -159,6 +159,7 @@ static size_t write_samples(sox_format_t * ft, const sox_sample_t *buf, size_t l · 158 unmodified lines | |||
| 159 | switch (ft->encoding.bits_per_sample) { | 159 | switch (ft->encoding.bits_per_sample) { |
| 160 | case 8: | 160 | case 8: |
| 161 | switch (ft->encoding.encoding) { | 161 | switch (ft->encoding.encoding) { |
| 162 | SOX_SAMPLE_LOCALS; | ||
| 162 | case SOX_ENCODING_UNSIGNED: | 163 | case SOX_ENCODING_UNSIGNED: |
| 163 | while (done < len && lsx_writeb(ft, SOX_SAMPLE_TO_UNSIGNED_8BIT(*buf++, ft->clips)) == SOX_SUCCESS) | 164 | while (done < len && lsx_writeb(ft, SOX_SAMPLE_TO_UNSIGNED_8BIT(*buf++, ft->clips)) == SOX_SUCCESS) |
| 164 | ++done; | 165 | ++done; |
| @@ -368,6 +368,7 @@ static size_t sox_smpwrite(sox_format_t * ft, const sox_sample_t *buf, size_t le · 367 unmodified lines | |||
| 368 | size_t done = 0; | 368 | size_t done = 0; |
| 369 | 369 | ||
| 370 | while(done < len) { | 370 | while(done < len) { |
| 371 | SOX_SAMPLE_LOCALS; | ||
| 371 | datum = (int) SOX_SAMPLE_TO_SIGNED_16BIT(*buf++, ft->clips); | 372 | datum = (int) SOX_SAMPLE_TO_SIGNED_16BIT(*buf++, ft->clips); |
| 372 | lsx_writew(ft, (uint16_t)datum); | 373 | lsx_writew(ft, (uint16_t)datum); |
| 373 | smp->NoOfSamps++; | 374 | smp->NoOfSamps++; |
| @@ -20,7 +20,7 @@ · 19 unmodified lines | |||
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include "soxconfig.h" | 23 | #include "soxomp.h" /* Make this 1st in list (for soxconfig) */ |
| 24 | #include "sox.h" | 24 | #include "sox.h" |
| 25 | #include "util.h" | 25 | #include "util.h" |
| 26 | 26 | ||
| @@ -169,6 +169,10 @@ static sox_bool user_restart_eff = sox_false; · 142 unmodified lines | |||
| 169 | static int success = 0; | 169 | static int success = 0; |
| 170 | static sox_sample_t omax[2], omin[2]; | 170 | static sox_sample_t omax[2], omin[2]; |
| 171 | 171 | ||
| 172 | /* Multi-processing */ | ||
| 173 | |||
| 174 | static sox_bool single_threaded = sox_false; | ||
| 175 | |||
| 172 | 176 | ||
| 173 | /* Cleanup atexit() function, hence always called. */ | 177 | /* Cleanup atexit() function, hence always called. */ |
| 174 | static void cleanup(void) | 178 | static void cleanup(void) |
| @@ -1516,12 +1520,18 @@ static void display_SoX_version(FILE * file) · 1341 unmodified lines | |||
| 1516 | #elif defined __SUNPRO_C | 1520 | #elif defined __SUNPRO_C |
| 1517 | fprintf(file, "sun c: %x\n", __SUNPRO_C); | 1521 | fprintf(file, "sun c: %x\n", __SUNPRO_C); |
| 1518 | #endif | 1522 | #endif |
| 1519 | fprintf(file, "arch: %lu%lu%lu%lu %lu%lu %lu%lu %c\n", | 1523 | fprintf(file, "arch: %lu%lu%lu%lu %lu%lu %lu%lu %c %s\n", |
| 1520 | (unsigned long)sizeof(char), (unsigned long)sizeof(short), | 1524 | (unsigned long)sizeof(char), (unsigned long)sizeof(short), |
| 1521 | (unsigned long)sizeof(long), (unsigned long)sizeof(off_t), | 1525 | (unsigned long)sizeof(long), (unsigned long)sizeof(off_t), |
| 1522 | (unsigned long)sizeof(float), (unsigned long)sizeof(double), | 1526 | (unsigned long)sizeof(float), (unsigned long)sizeof(double), |
| 1523 | (unsigned long)sizeof(int *), (unsigned long)sizeof(int (*)(void)), | 1527 | (unsigned long)sizeof(int *), (unsigned long)sizeof(int (*)(void)), |
| 1524 | "LB"[MACHINE_IS_BIGENDIAN]); | 1528 | "LB"[MACHINE_IS_BIGENDIAN], |
| 1529 | #ifdef HAVE_OPENMP | ||
| 1530 | "OMP" | ||
| 1531 | #else | ||
| 1532 | "" | ||
| 1533 | #endif | ||
| 1534 | ); | ||
| 1525 | } | 1535 | } |
| 1526 | } | 1536 | } |
| 1527 | 1537 | ||
| @@ -1818,6 +1828,7 @@ static struct option long_options[] = · 290 unmodified lines | |||
| 1818 | {"output" , required_argument, NULL, 0}, | 1828 | {"output" , required_argument, NULL, 0}, |
| 1819 | {"effects-file" , required_argument, NULL, 0}, | 1829 | {"effects-file" , required_argument, NULL, 0}, |
| 1820 | {"temp" , required_argument, NULL, 0}, | 1830 | {"temp" , required_argument, NULL, 0}, |
| 1831 | {"single-threaded" , no_argument, NULL, 0}, | ||
| 1821 | 1832 | ||
| 1822 | {"bits" , required_argument, NULL, 'b'}, | 1833 | {"bits" , required_argument, NULL, 'b'}, |
| 1823 | {"channels" , required_argument, NULL, 'c'}, | 1834 | {"channels" , required_argument, NULL, 'c'}, |
| @@ -2006,6 +2017,10 @@ static char parse_gopts_and_fopts(file_t * f, int argc, char **argv) · 182 unmodified lines | |||
| 2006 | sox_globals.tmp_path = strdup(optarg); | 2017 | sox_globals.tmp_path = strdup(optarg); |
| 2007 | break; | 2018 | break; |
| 2008 | 2019 | ||
| 2020 | case 17: | ||
| 2021 | single_threaded = sox_true; | ||
| 2022 | break; | ||
| 2023 | |||
| 2009 | } | 2024 | } |
| 2010 | break; | 2025 | break; |
| 2011 | 2026 | ||
| @@ -2443,7 +2458,7 @@ int main(int argc, char **argv) · 431 unmodified lines | |||
| 2443 | else if (strends(myname, "soxi")) | 2458 | else if (strends(myname, "soxi")) |
| 2444 | sox_mode = sox_soxi; | 2459 | sox_mode = sox_soxi; |
| 2445 | 2460 | ||
| 2446 | if (sox_format_init() != SOX_SUCCESS) | 2461 | if (sox_init() != SOX_SUCCESS) |
| 2447 | exit(1); | 2462 | exit(1); |
| 2448 | 2463 | ||
| 2449 | if (sox_mode == sox_soxi) | 2464 | if (sox_mode == sox_soxi) |
| @@ -2471,6 +2486,11 @@ int main(int argc, char **argv) · 21 unmodified lines | |||
| 2471 | } | 2486 | } |
| 2472 | #endif | 2487 | #endif |
| 2473 | 2488 | ||
| 2489 | #ifdef HAVE_OPENMP | ||
| 2490 | if (single_threaded) | ||
| 2491 | omp_set_num_threads(1); | ||
| 2492 | #endif | ||
| 2493 | |||
| 2474 | if (sox_globals.verbosity > 2) | 2494 | if (sox_globals.verbosity > 2) |
| 2475 | display_SoX_version(stderr); | 2495 | display_SoX_version(stderr); |
| 2476 | 2496 | ||
| @@ -97,9 +97,8 @@ typedef int32_t sox_sample_t; · 96 unmodified lines | |||
| 97 | * the upper-most bit then treating them as signed integers. | 97 | * the upper-most bit then treating them as signed integers. |
| 98 | */ | 98 | */ |
| 99 | 99 | ||
| 100 | /* Temporary variables to prevent multiple evaluation of macro arguments: */ | 100 | #define SOX_SAMPLE_LOCALS sox_sample_t sox_macro_temp_sample UNUSED; \ |
| 101 | static sox_sample_t sox_macro_temp_sample UNUSED; | 101 | double sox_macro_temp_double UNUSED |
| 102 | static double sox_macro_temp_double UNUSED; | ||
| 103 | 102 | ||
| 104 | #define SOX_SAMPLE_NEG SOX_INT_MIN(32) | 103 | #define SOX_SAMPLE_NEG SOX_INT_MIN(32) |
| 105 | #define SOX_SAMPLE_TO_UNSIGNED(bits,d,clips) \ | 104 | #define SOX_SAMPLE_TO_UNSIGNED(bits,d,clips) \ |
| @@ -395,6 +394,10 @@ struct sox_format { · 289 unmodified lines | |||
| 395 | #define SOX_FILE_BIG_END (SOX_FILE_ENDIAN | SOX_FILE_ENDBIG) | 394 | #define SOX_FILE_BIG_END (SOX_FILE_ENDIAN | SOX_FILE_ENDBIG) |
| 396 | 395 | ||
| 397 | int sox_format_init(void); | 396 | int sox_format_init(void); |
| 397 | void sox_format_quit(void); | ||
| 398 | |||
| 399 | int sox_init(void); | ||
| 400 | int sox_quit(void); | ||
| 398 | 401 | ||
| 399 | typedef const sox_format_handler_t *(*sox_format_fn_t)(void); | 402 | typedef const sox_format_handler_t *(*sox_format_fn_t)(void); |
| 400 | 403 | ||
| @@ -429,7 +432,6 @@ int sox_close(sox_format_t * ft); · 28 unmodified lines | |||
| 429 | int sox_seek(sox_format_t * ft, uint64_t offset, int whence); | 432 | int sox_seek(sox_format_t * ft, uint64_t offset, int whence); |
| 430 | 433 | ||
| 431 | sox_format_handler_t const * sox_find_format(char const * name, sox_bool no_dev); | 434 | sox_format_handler_t const * sox_find_format(char const * name, sox_bool no_dev); |
| 432 | void sox_format_quit(void); | ||
| 433 | 435 | ||
| 434 | /* | 436 | /* |
| 435 | * Structures for effects. | 437 | * Structures for effects. |
| @@ -13,7 +13,7 @@ · 12 unmodified lines | |||
| 13 | #ifndef SOX_I_H | 13 | #ifndef SOX_I_H |
| 14 | #define SOX_I_H | 14 | #define SOX_I_H |
| 15 | 15 | ||
| 16 | #include "soxconfig.h" | 16 | #include "soxomp.h" /* Make this 1st in list (for soxconfig) */ |
| 17 | #include "sox.h" | 17 | #include "sox.h" |
| 18 | #include "util.h" | 18 | #include "util.h" |
| 19 | 19 | ||
| @@ -266,4 +266,7 @@ char * lsx_usage_lines(char * * usage, char const * const * lines, size_t n); · 246 unmodified lines | |||
| 266 | 266 | ||
| 267 | int lsx_effect_set_imin(sox_effect_t * effp, size_t imin); | 267 | int lsx_effect_set_imin(sox_effect_t * effp, size_t imin); |
| 268 | 268 | ||
| 269 | int lsx_effects_init(void); | ||
| 270 | int lsx_effects_quit(void); | ||
| 271 | |||
| 269 | #endif | 272 | #endif |
| @@ -163,6 +163,7 @@ int main() · 162 unmodified lines | |||
| 163 | size_t clips = 0; | 163 | size_t clips = 0; |
| 164 | 164 | ||
| 165 | double d; | 165 | double d; |
| 166 | SOX_SAMPLE_LOCALS; | ||
| 166 | 167 | ||
| 167 | TEST_UINT(8) | 168 | TEST_UINT(8) |
| 168 | TEST_UINT(16) | 169 | TEST_UINT(16) |
| @@ -23,6 +23,7 @@ · 22 unmodified lines | |||
| 23 | #cmakedefine HAVE_MKSTEMP 1 | 23 | #cmakedefine HAVE_MKSTEMP 1 |
| 24 | #cmakedefine HAVE_OGG_SPEEX 1 | 24 | #cmakedefine HAVE_OGG_SPEEX 1 |
| 25 | #cmakedefine HAVE_OGG_VORBIS 1 | 25 | #cmakedefine HAVE_OGG_VORBIS 1 |
| 26 | #cmakedefine HAVE_OPENMP 1 | ||
| 26 | #cmakedefine HAVE_POPEN 1 | 27 | #cmakedefine HAVE_POPEN 1 |
| 27 | #cmakedefine HAVE_PNG 1 | 28 | #cmakedefine HAVE_PNG 1 |
| 28 | #cmakedefine HAVE_SAMPLERATE_H 1 | 29 | #cmakedefine HAVE_SAMPLERATE_H 1 |
| @@ -0,0 +1,38 @@ | |||
| 1 | #include "soxconfig.h" | ||
| 2 | |||
| 3 | #ifdef HAVE_OPENMP | ||
| 4 | #include <omp.h> | ||
| 5 | #else | ||
| 6 | |||
| 7 | typedef int omp_lock_t; | ||
| 8 | typedef int omp_nest_lock_t; | ||
| 9 | |||
| 10 | #define omp_set_num_threads(int) (void)0 | ||
| 11 | #define omp_get_num_threads() 1 | ||
| 12 | #define omp_get_max_threads() 1 | ||
| 13 | #define omp_get_thread_num() 0 | ||
| 14 | #define omp_get_num_procs() 1 | ||
| 15 | #define omp_in_parallel() 1 | ||
| 16 | |||
| 17 | #define omp_set_dynamic(int) (void)0 | ||
| 18 | #define omp_get_dynamic() 0 | ||
| 19 | |||
| 20 | #define omp_set_nested(int) (void)0 | ||
| 21 | #define omp_get_nested() 0 | ||
| 22 | |||
| 23 | #define omp_init_lock(omp_lock_t) (void)0 | ||
| 24 | #define omp_destroy_lock(omp_lock_t) (void)0 | ||
| 25 | #define omp_set_lock(omp_lock_t) (void)0 | ||
| 26 | #define omp_unset_lock(omp_lock_t) (void)0 | ||
| 27 | #define omp_test_lock(omp_lock_t) 0 | ||
| 28 | |||
| 29 | #define omp_init_nest_lock(omp_nest_lock_t) (void)0 | ||
| 30 | #define omp_destroy_nest_lock(omp_nest_lock_t) (void)0 | ||
| 31 | #define omp_set_nest_lock(omp_nest_lock_t) (void)0 | ||
| 32 | #define omp_unset_nest_lock(omp_nest_lock_t) (void)0 | ||
| 33 | #define omp_test_nest_lock(omp_nest_lock_t) 0 | ||
| 34 | |||
| 35 | #define omp_get_wtime() 0 | ||
| 36 | #define omp_get_wtick() 0 | ||
| 37 | |||
| 38 | #endif | ||
| @@ -193,6 +193,7 @@ static int flow(sox_effect_t * effp, · 192 unmodified lines | |||
| 193 | *isamp = *osamp = len; | 193 | *isamp = *osamp = len; |
| 194 | 194 | ||
| 195 | while (sox_true) { | 195 | while (sox_true) { |
| 196 | SOX_SAMPLE_LOCALS; | ||
| 196 | if (p->read == p->step_size) { | 197 | if (p->read == p->step_size) { |
| 197 | memmove(p->buf, p->buf + p->step_size, | 198 | memmove(p->buf, p->buf + p->step_size, |
| 198 | (p->dft_size - p->step_size) * sizeof(*p->buf)); | 199 | (p->dft_size - p->step_size) * sizeof(*p->buf)); |
| @@ -152,6 +152,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t * ibuf, · 151 unmodified lines | |||
| 152 | { | 152 | { |
| 153 | priv_t * p = (priv_t *)effp->priv; | 153 | priv_t * p = (priv_t *)effp->priv; |
| 154 | size_t c, idone = 0, odone = 0; | 154 | size_t c, idone = 0, odone = 0; |
| 155 | SOX_SAMPLE_LOCALS; | ||
| 155 | *isamp /= effp->in_signal.channels; | 156 | *isamp /= effp->in_signal.channels; |
| 156 | *osamp /= effp->in_signal.channels; | 157 | *osamp /= effp->in_signal.channels; |
| 157 | 158 | ||
| @@ -140,6 +140,7 @@ static int sox_stat_flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_samp · 139 unmodified lines | |||
| 140 | 140 | ||
| 141 | if (stat->fft) { | 141 | if (stat->fft) { |
| 142 | for (x = 0; x < len; x++) { | 142 | for (x = 0; x < len; x++) { |
| 143 | SOX_SAMPLE_LOCALS; | ||
| 143 | stat->re_in[stat->fft_offset++] = SOX_SAMPLE_TO_FLOAT_32BIT(ibuf[x], effp->clips); | 144 | stat->re_in[stat->fft_offset++] = SOX_SAMPLE_TO_FLOAT_32BIT(ibuf[x], effp->clips); |
| 144 | 145 | ||
| 145 | if (stat->fft_offset >= stat->fft_size) { | 146 | if (stat->fft_offset >= stat->fft_size) { |
| @@ -264,6 +264,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t * ibuf, · 263 unmodified lines | |||
| 264 | priv_t * p = (priv_t *)effp->priv; | 264 | priv_t * p = (priv_t *)effp->priv; |
| 265 | size_t i, odone = *osamp /= effp->in_signal.channels; | 265 | size_t i, odone = *osamp /= effp->in_signal.channels; |
| 266 | float const * s = tempo_output(p->tempo, NULL, &odone); | 266 | float const * s = tempo_output(p->tempo, NULL, &odone); |
| 267 | SOX_SAMPLE_LOCALS; | ||
| 267 | 268 | ||
| 268 | for (i = 0; i < odone * effp->in_signal.channels; ++i) | 269 | for (i = 0; i < odone * effp->in_signal.channels; ++i) |
| 269 | *obuf++ = SOX_FLOAT_32BIT_TO_SAMPLE(*s++, effp->clips); | 270 | *obuf++ = SOX_FLOAT_32BIT_TO_SAMPLE(*s++, effp->clips); |
| @@ -347,6 +347,7 @@ static size_t read_samples(sox_format_t * ft, sox_sample_t * buf, · 346 unmodified lines | |||
| 347 | /* Read the data in the file */ | 347 | /* Read the data in the file */ |
| 348 | if (v->size <= 4) { | 348 | if (v->size <= 4) { |
| 349 | if (!v->adpcm.setup.sign) { | 349 | if (!v->adpcm.setup.sign) { |
| 350 | SOX_SAMPLE_LOCALS; | ||
| 350 | if (lsx_readb(ft, &uc) == SOX_EOF) { | 351 | if (lsx_readb(ft, &uc) == SOX_EOF) { |
| 351 | lsx_warn("VOC input: short file"); | 352 | lsx_warn("VOC input: short file"); |
| 352 | v->block_remaining = 0; | 353 | v->block_remaining = 0; |
| @@ -489,6 +490,7 @@ static size_t write_samples(sox_format_t * ft, const sox_sample_t * buf, · 136 unmodified lines | |||
| 489 | } | 490 | } |
| 490 | v->samples += len; | 491 | v->samples += len; |
| 491 | while (done < len) { | 492 | while (done < len) { |
| 493 | SOX_SAMPLE_LOCALS; | ||
| 492 | if (ft->encoding.bits_per_sample == 8) { | 494 | if (ft->encoding.bits_per_sample == 8) { |
| 493 | uc = SOX_SAMPLE_TO_UNSIGNED_8BIT(*buf++, ft->clips); | 495 | uc = SOX_SAMPLE_TO_UNSIGNED_8BIT(*buf++, ft->clips); |
| 494 | lsx_writeb(ft, uc); | 496 | lsx_writeb(ft, uc); |
| @@ -331,6 +331,7 @@ static size_t wavgsmwrite(sox_format_t * ft, const sox_sample_t *buf, size_t len · 330 unmodified lines | |||
| 331 | ft->sox_errno = SOX_SUCCESS; | 331 | ft->sox_errno = SOX_SUCCESS; |
| 332 | 332 | ||
| 333 | while (done < len) { | 333 | while (done < len) { |
| 334 | SOX_SAMPLE_LOCALS; | ||
| 334 | while ((wav->gsmindex < 160*2) && (done < len)) | 335 | while ((wav->gsmindex < 160*2) && (done < len)) |
| 335 | wav->gsmsample[(wav->gsmindex)++] = | 336 | wav->gsmsample[(wav->gsmindex)++] = |
| 336 | SOX_SAMPLE_TO_SIGNED_16BIT(buf[done++], ft->clips); | 337 | SOX_SAMPLE_TO_SIGNED_16BIT(buf[done++], ft->clips); |
| @@ -71,6 +71,7 @@ static size_t read_samples(sox_format_t * ft, sox_sample_t * buf, size_t len) · 70 unmodified lines | |||
| 71 | priv_t * p = (priv_t *)ft->priv; | 71 | priv_t * p = (priv_t *)ft->priv; |
| 72 | size_t i, actual = WavpackUnpackSamples(p->codec, buf, (uint32_t) len / ft->signal.channels) * ft->signal.channels; | 72 | size_t i, actual = WavpackUnpackSamples(p->codec, buf, (uint32_t) len / ft->signal.channels) * ft->signal.channels; |
| 73 | for (i = 0; i < actual; ++i) switch (ft->encoding.bits_per_sample) { | 73 | for (i = 0; i < actual; ++i) switch (ft->encoding.bits_per_sample) { |
| 74 | SOX_SAMPLE_LOCALS; | ||
| 74 | case 8: buf[i] = SOX_SIGNED_8BIT_TO_SAMPLE(buf[i],); break; | 75 | case 8: buf[i] = SOX_SIGNED_8BIT_TO_SAMPLE(buf[i],); break; |
| 75 | case 16: buf[i] = SOX_SIGNED_16BIT_TO_SAMPLE(buf[i],); break; | 76 | case 16: buf[i] = SOX_SIGNED_16BIT_TO_SAMPLE(buf[i],); break; |
| 76 | case 24: buf[i] = SOX_SIGNED_24BIT_TO_SAMPLE(buf[i],); break; | 77 | case 24: buf[i] = SOX_SIGNED_24BIT_TO_SAMPLE(buf[i],); break; |
| @@ -119,6 +120,7 @@ static size_t write_samples(sox_format_t * ft, const sox_sample_t * buf, size_t · 42 unmodified lines | |||
| 119 | int result; | 120 | int result; |
| 120 | 121 | ||
| 121 | for (i = 0; i < len; ++i) switch (ft->encoding.bits_per_sample) { | 122 | for (i = 0; i < len; ++i) switch (ft->encoding.bits_per_sample) { |
| 123 | SOX_SAMPLE_LOCALS; | ||
| 122 | case 8: obuf[i] = SOX_SAMPLE_TO_SIGNED_8BIT(buf[i], ft->clips); break; | 124 | case 8: obuf[i] = SOX_SAMPLE_TO_SIGNED_8BIT(buf[i], ft->clips); break; |
| 123 | case 16: obuf[i] = SOX_SAMPLE_TO_SIGNED_16BIT(buf[i], ft->clips); break; | 125 | case 16: obuf[i] = SOX_SAMPLE_TO_SIGNED_16BIT(buf[i], ft->clips); break; |
| 124 | case 24: obuf[i] = SOX_SAMPLE_TO_SIGNED_24BIT(buf[i], ft->clips) << 8; | 126 | case 24: obuf[i] = SOX_SAMPLE_TO_SIGNED_24BIT(buf[i], ft->clips) << 8; |