src/audio/SDL_audiotypecvt.c
changeset 10799 234f71894a52
parent 10756 073957aca821
child 10814 938218064f67
     1.1 --- a/src/audio/SDL_audiotypecvt.c	Mon Jan 09 05:59:30 2017 -0500
     1.2 +++ b/src/audio/SDL_audiotypecvt.c	Mon Jan 09 06:00:58 2017 -0500
     1.3 @@ -216,177 +216,4 @@
     1.4      }
     1.5  }
     1.6  
     1.7 -void
     1.8 -SDL_Upsample_Arbitrary(SDL_AudioCVT *cvt, const int channels)
     1.9 -{
    1.10 -    const int srcsize = cvt->len_cvt - (64 * channels);
    1.11 -    const int dstsize = (int) ((((double)(cvt->len_cvt/(channels*4))) * cvt->rate_incr)) * (channels*4);
    1.12 -    register int eps = 0;
    1.13 -    float *dst = ((float *) (cvt->buf + dstsize)) - channels;
    1.14 -    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - channels;
    1.15 -    const float *target = ((const float *) cvt->buf);
    1.16 -    const size_t cpy = sizeof (float) * channels;
    1.17 -    float sample[8];
    1.18 -    float last_sample[8];
    1.19 -    int i;
    1.20 -
    1.21 -#if DEBUG_CONVERT
    1.22 -    fprintf(stderr, "Upsample arbitrary (x%f), %d channels.\n", cvt->rate_incr, channels);
    1.23 -#endif
    1.24 -
    1.25 -    SDL_assert(channels <= 8);
    1.26 -
    1.27 -    for (i = 0; i < channels; i++) {
    1.28 -        sample[i] = (float) ((((double) src[i]) + ((double) src[i - channels])) * 0.5);
    1.29 -    }
    1.30 -    SDL_memcpy(last_sample, src, cpy);
    1.31 -
    1.32 -    while (dst > target) {
    1.33 -        SDL_memcpy(dst, sample, cpy);
    1.34 -        dst -= channels;
    1.35 -        eps += srcsize;
    1.36 -        if ((eps << 1) >= dstsize) {
    1.37 -            if (src > target) {
    1.38 -                src -= channels;
    1.39 -                for (i = 0; i < channels; i++) {
    1.40 -                    sample[i] = (float) ((((double) src[i]) + ((double) last_sample[i])) * 0.5);
    1.41 -                }
    1.42 -            } else {
    1.43 -
    1.44 -            }
    1.45 -            SDL_memcpy(last_sample, src, cpy);
    1.46 -            eps -= dstsize;
    1.47 -        }
    1.48 -    }
    1.49 -
    1.50 -    cvt->len_cvt = dstsize;
    1.51 -    if (cvt->filters[++cvt->filter_index]) {
    1.52 -        cvt->filters[cvt->filter_index](cvt, AUDIO_F32SYS);
    1.53 -    }
    1.54 -}
    1.55 -
    1.56 -void
    1.57 -SDL_Downsample_Arbitrary(SDL_AudioCVT *cvt, const int channels)
    1.58 -{
    1.59 -    const int srcsize = cvt->len_cvt - (64 * channels);
    1.60 -    const int dstsize = (int) (((double)(cvt->len_cvt/(channels*4))) * cvt->rate_incr) * (channels*4);
    1.61 -    register int eps = 0;
    1.62 -    float *dst = (float *) cvt->buf;
    1.63 -    const float *src = (float *) cvt->buf;
    1.64 -    const float *target = (const float *) (cvt->buf + dstsize);
    1.65 -    const size_t cpy = sizeof (float) * channels;
    1.66 -    float last_sample[8];
    1.67 -    float sample[8];
    1.68 -    int i;
    1.69 -
    1.70 -#if DEBUG_CONVERT
    1.71 -    fprintf(stderr, "Downsample arbitrary (x%f), %d channels.\n", cvt->rate_incr, channels);
    1.72 -#endif
    1.73 -
    1.74 -    SDL_assert(channels <= 8);
    1.75 -
    1.76 -    SDL_memcpy(sample, src, cpy);
    1.77 -    SDL_memcpy(last_sample, src, cpy);
    1.78 -
    1.79 -    while (dst < target) {
    1.80 -        src += channels;
    1.81 -        eps += dstsize;
    1.82 -        if ((eps << 1) >= srcsize) {
    1.83 -            SDL_memcpy(dst, sample, cpy);
    1.84 -            dst += channels;
    1.85 -            for (i = 0; i < channels; i++) {
    1.86 -                sample[i] = (float) ((((double) src[i]) + ((double) last_sample[i])) * 0.5);
    1.87 -            }
    1.88 -            SDL_memcpy(last_sample, src, cpy);
    1.89 -            eps -= srcsize;
    1.90 -        }
    1.91 -    }
    1.92 -
    1.93 -    cvt->len_cvt = dstsize;
    1.94 -    if (cvt->filters[++cvt->filter_index]) {
    1.95 -        cvt->filters[cvt->filter_index](cvt, AUDIO_F32SYS);
    1.96 -    }
    1.97 -}
    1.98 -
    1.99 -void
   1.100 -SDL_Upsample_Multiple(SDL_AudioCVT *cvt, const int channels)
   1.101 -{
   1.102 -    const int multiple = (int) cvt->rate_incr;
   1.103 -    const int dstsize = cvt->len_cvt * multiple;
   1.104 -    float *buf = (float *) cvt->buf;
   1.105 -    float *dst = ((float *) (cvt->buf + dstsize)) - channels;
   1.106 -    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - channels;
   1.107 -    const float *target = buf + channels;
   1.108 -    const size_t cpy = sizeof (float) * channels;
   1.109 -    float last_sample[8];
   1.110 -    int i;
   1.111 -
   1.112 -#if DEBUG_CONVERT
   1.113 -    fprintf(stderr, "Upsample (x%d), %d channels.\n", multiple, channels);
   1.114 -#endif
   1.115 -
   1.116 -    SDL_assert(channels <= 8);
   1.117 -
   1.118 -    SDL_memcpy(last_sample, src, cpy);
   1.119 -
   1.120 -    while (dst > target) {
   1.121 -        SDL_assert(src >= buf);
   1.122 -
   1.123 -        for (i = 0; i < channels; i++) {
   1.124 -            dst[i] = (float) ((((double)src[i]) + ((double)last_sample[i])) * 0.5);
   1.125 -        }
   1.126 -        dst -= channels;
   1.127 -
   1.128 -        for (i = 1; i < multiple; i++) {
   1.129 -            SDL_memcpy(dst, dst + channels, cpy);
   1.130 -            dst -= channels;
   1.131 -        }
   1.132 -
   1.133 -        src -= channels;
   1.134 -        if (src > buf) {
   1.135 -            SDL_memcpy(last_sample, src - channels, cpy);
   1.136 -        }
   1.137 -    }
   1.138 -
   1.139 -    cvt->len_cvt = dstsize;
   1.140 -    if (cvt->filters[++cvt->filter_index]) {
   1.141 -        cvt->filters[cvt->filter_index](cvt, AUDIO_F32SYS);
   1.142 -    }
   1.143 -}
   1.144 -
   1.145 -void
   1.146 -SDL_Downsample_Multiple(SDL_AudioCVT *cvt, const int channels)
   1.147 -{
   1.148 -    const int multiple = (int) (1.0 / cvt->rate_incr);
   1.149 -    const int dstsize = cvt->len_cvt / multiple;
   1.150 -    float *dst = (float *) cvt->buf;
   1.151 -    const float *src = (float *) cvt->buf;
   1.152 -    const float *target = (const float *) (cvt->buf + dstsize);
   1.153 -    const size_t cpy = sizeof (float) * channels;
   1.154 -    float last_sample[8];
   1.155 -    int i;
   1.156 -
   1.157 -#if DEBUG_CONVERT
   1.158 -    fprintf(stderr, "Downsample (x%d), %d channels.\n", multiple, channels);
   1.159 -#endif
   1.160 -
   1.161 -    SDL_assert(channels <= 8);
   1.162 -    SDL_memcpy(last_sample, src, cpy);
   1.163 -
   1.164 -    while (dst < target) {
   1.165 -        for (i = 0; i < channels; i++) {
   1.166 -            dst[i] = (float) ((((double)src[i]) + ((double)last_sample[i])) * 0.5);
   1.167 -        }
   1.168 -        dst += channels;
   1.169 -
   1.170 -        SDL_memcpy(last_sample, src, cpy);
   1.171 -        src += (channels * multiple);
   1.172 -    }
   1.173 -
   1.174 -    cvt->len_cvt = dstsize;
   1.175 -    if (cvt->filters[++cvt->filter_index]) {
   1.176 -        cvt->filters[cvt->filter_index](cvt, AUDIO_F32SYS);
   1.177 -    }
   1.178 -}
   1.179 -
   1.180  /* vi: set ts=4 sw=4 expandtab: */