- Timestamp:
- Dec 6, 2013, 5:12:11 AM (11 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 1fe3ac2
- Parents:
- 0044b43
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_avcodec.c
r0044b43 r3d5cddf 38 38 #define AUBIO_AVCODEC_MIN_BUFFER_SIZE FF_MIN_BUFFER_SIZE 39 39 40 #define SHORT_TO_FLOAT(x) (smpl_t)(x * 3.0517578125e-05)41 42 40 struct _aubio_source_avcodec_t { 43 41 uint_t hop_size; … … 55 53 AVFrame *avFrame; 56 54 AVAudioResampleContext *avr; 57 int16_t *output;55 float *output; 58 56 uint_t read_samples; 59 57 uint_t read_index; … … 173 171 av_opt_set_int(avr, "out_sample_rate", s->samplerate, 0); 174 172 av_opt_set_int(avr, "in_sample_fmt", avCodecCtx->sample_fmt, 0); 175 av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_ S16,0);173 av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); 176 174 if ( ( err = avresample_open(avr) ) < 0) { 177 175 uint8_t errorstr_len = 128; … … 192 190 193 191 /* allocate output for avr */ 194 s->output = ( int16_t *)av_malloc(AUBIO_AVCODEC_MIN_BUFFER_SIZE * sizeof(int16_t));192 s->output = (float *)av_malloc(AUBIO_AVCODEC_MIN_BUFFER_SIZE * sizeof(float)); 195 193 196 194 s->read_samples = 0; … … 222 220 av_init_packet (&avPacket); 223 221 AVAudioResampleContext *avr = s->avr; 224 int16_t *output = s->output;222 float *output = s->output; 225 223 226 224 do … … 304 302 end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote); 305 303 for (i = 0; i < end; i++) { 306 read_data->data[i + total_wrote] = SHORT_TO_FLOAT(s->output[i + s->read_index]);304 read_data->data[i + total_wrote] = s->output[i + s->read_index]; 307 305 } 308 306 total_wrote += end;
Note: See TracChangeset
for help on using the changeset viewer.