
10 Oct
2015
10 Oct
'15
9:12 p.m.
On Sat, 10 Oct 2015, Ricard Wanderlof wrote:
That code was intended to round correctly, but it's obviously wrong because the result is not an integer multiple of the frame size.
If that is the case we need to do something like
maxsize = (((freqn + 0xffff) & 0xffff0000) * frame_size) >> 16
Or, much simpler, I realized later:
maxsize = ((freqn + 0xffff) >> 16) * frame_size
i.e. we make the conversion from Q16.16 to integer before multiplying with the frame size to automatically get the rounding as intended.
/Ricard
--
Ricard Wolf Wanderlöf ricardw(at)axis.com
Axis Communications AB, Lund, Sweden www.axis.com
Phone +46 46 272 2016 Fax +46 46 13 61 30