Fix compilation with OpenCL on MacOS X

Also fix crash in the case of OpenCL error during encoding.
Fix building with compilers without inline asm support

Also fix crash in high bit depth builds compiled with unaligned stack.
OpenCL cosmetics
Merge branch 'plain' into 7mod