Need help implementing DCT Type 4 algorithm
I found the solution. There was a mistake in the paper.

On the first 2 lines of Algorithm 2:

w0 ← x0
vN/2 ← xN−1


x0 and xN-1 should be scaled by 2, giving:

w0 ← x0 * 2
vN/2 ← xN−1 * 2


The following paste has working code (and an open source license, so feel free to copy it)

https://pastebin.com/TvgU4b6d