I used G729 codec in my VOIP App, when the app target only armv7, it works fine. The Callee can hear my voice clearly. Then I turn to arm64, the callee no longer get my voice clearly. I record the input voice raw data before and after G729 codec both on armv7 device and arm64 device on the Caller side, and then convert the G729 encoded data back. I find the converted back voice from armv7 device is much better than arm64 device.
This depends on the G729 implementation you are using, but if you are using Samuel Vinson's, I believe I found the problem.
In lpc.c
there is a comparison between a result and a subtraction between two values on lines 643 and 698 respectively:
lpc.c:643 if ((UWord32)(t0 - 0xfe000000L) < 0x01ffffffL - 0xfe000000L)
lpc.c:698 if ((UWord32)(t0 - 0xff000000L) < 0x00ffffffL - 0xff000000L)
The result of 0x00ffffffL - 0xff000000L
is 1ffffff
(33554431
) on 32 bit, but ffffffff01ffffff
(-4261412865
) on 64 bit, because the long is way larger on 64 bit on an ARM processor (I am testing with an iPhone 4, armv7, 32 bit and an iPhone 5s, arm64, 64 bit).
So basically on 64 bit the comparison will always fail the check as the second term is always negative and a UWord32
will always be positive.
My solution is to use the hardcoded results of the subtraction on 32 bit, so
using 0x3ffffffL
for the first conditional and 0x1ffffffL
for the second, fixes the voice quality issue for me:
lpc.c:643 if ((UWord32)(t0 - 0xff000000L) < 0x3ffffffL)
lpc.c:698 if ((UWord32)(t0 - 0xfe000000L) < 0x1ffffffL)
Hope this helps.