title: FFMPEG audio decoding: efficient conversion from short to float sample buffer
body: <p>I am using the FFMPEG <code>avcodec_decode_audio</code> to decode audio input files of various types. The resulting samples are of type SHORT.</p>
  
  <p>These samples are processed with another library which requires the samples in FLOAT input format. Finally, for playback (on Android), I need to convert the FLOAT samples back to SHORT again:</p>
  
  <pre><code>short* inputSamples = ...;
  float* tmpBuffer = new float[nrInputSamples];
  for (int i=0; i&lt;nrInputSamples; i++)
    tmpBuffer[i] = inputSamples[i]/32767.0f;
  
  //process audio here
  
  for (int i=0; i&lt;nrInputSamples; i++)
    inputSamples[i] = tmpBuffer[i]*32767.0f;
  </code></pre>
  
  <p>Is there a more efficient way to do this (for instance force ffmpeg to decode the audio to FLOAT samples)?</p>
  
  <p>Regards,</p>