[FFmpeg-devel] SAMPLE_FMT_FLT bounds
Thu Aug 6 22:45:02 CEST 2009
On Thu, Aug 06, 2009 at 10:32:37PM +0200, Vitor Sessak wrote:
> 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
>>> 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?
yes but this is easy to benchmark and the benchmark is more relevant
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
More information about the ffmpeg-devel