title: Fast RGB => YUV conversion in OpenCL
body: <p>I know the following formula can be used to convert RGB images to YUV images. In the following formula, R, G, B, Y, U, V are all 8-bit unsigned integers, and intermediate values are 16-bit unsigned integers.  </p>
  
  <pre><code>Y = ( (  66 * R + 129 * G +  25 * B + 128) &gt;&gt; 8) +  16  
  U = ( ( -38 * R -  74 * G + 112 * B + 128) &gt;&gt; 8) + 128  
  V = ( ( 112 * R -  94 * G -  18 * B + 128) &gt;&gt; 8) + 128
  </code></pre>
  
  <p>But when the formula is used in OpenCL it's a different story.<br>
      1. 8-bit memory write access is an optional extension, which means some OpenCL implementations may not support it.<br>
      2. even the above extension is supported, it's deadly slow compared with 32-bit write access.</p>
  
  <p>In order to get better performance, every 4 pixels will be processed at the same time, so the input is 12 8-bit integers and the output is 3 32-bit unsigned integers(the first one stands for 4 Y samples, the second one stands for 4 U samples, the last one stands for 4 V samples).</p>
  
  <p>My question is how to get these 3 32-bit integers directly from the 12 8-bit integers? Is there a formula to get these 3 32-bit integers, or I just need to use the old formula to get 12 8-bit integer results(4 Y, 4 U, 4 V) and construct the 3 32-bit integers with bit-wise operation?</p>