You're right, i really should've seen that when i documented the calls. I didn't actually change them except flipping the one operand there, just added the docs, but apparently didn't pay enough attention.
No matter, i gave it another try and refactored the whole function to use variable names matching the C ones very closely, no changes of meaning in the variables anymore.
The test videos you and cyberbeing posted are working fine now.