It looks like the code you’ve posted subtracts the mean in each channel, but does not divide by the standard deviation.
Also, the code is apparently dealing with unnormalized image values in [0, 255], which explains the mean values.
The complicated looking conversion is just the transformation of YUV to RGB format.