[FFmpeg-devel] SAMPLE_FMT_FLT bounds

Vitor Sessak vitor1001
Thu Aug 6 22:32:37 CEST 2009


Michael Niedermayer wrote:
> On Wed, Aug 05, 2009 at 05:17:41PM +0100, Colin McQuillan wrote:
>> I'm looking for the correct way to clip the output of a floating-point decoder.
>>
>> audioconvert.c converts floats thus:
>> lrintf(*(const float*)pi * (1<<15))) to convert to int16_t
>> lrintf(*(const float*)pi * (1<<7)) + 0x80) to convert to uint8_t
>>
>> qcelpdec.c clips to [-1.0, 32767.0/32768.0]. This is alright when
>> converting to 16-bit but will overflow when converting to 8-bit.
>> Should I clip to [-1, 127.0/128.0]? Or [-128.499/127, 127.499/128]?
> 
> id say convert should be
> lrintf(*(const float*)pi * 32767.5 - 0.5)

This is the same as floorf(*(const float*)pi * 32767.5), no? Any idea of 
what is faster?

-Vitor



More information about the ffmpeg-devel mailing list