g723.1: optimise scale_vector()
authorMans Rullgard <mans@mansr.com>
Fri, 10 Aug 2012 17:15:41 +0000 (18:15 +0100)
committerMans Rullgard <mans@mansr.com>
Mon, 13 Aug 2012 00:03:25 +0000 (01:03 +0100)
commit4aca716a531b0bc1f05c96209cf30577d6e48baa
tree7f7f6ea25c3c22ed1bfdad4fd21383d4a2da0cc4
parent1eb1f6f281eb6036d363e0317c1500be4a2708f2
g723.1: optimise scale_vector()

Firstly, nothing in this function can overflow 32 bits so the use
of a 64-bit type is completely unnecessary.  Secondly, the scale
is either a power of two or 0x7fff.  Doing separate loops for these
cases avoids using multiplications.  Finally, since only the number
of bits, not the actual value, of the maximum value is needed, the
bitwise or of all the values serves the purpose while being faster.

It is worth noting that even if overflow could happen, it was not
handled correctly anyway.

Signed-off-by: Mans Rullgard <mans@mansr.com>
libavcodec/g723_1.c