title: How to mirror swscale PIX_FMT_YUYV422
body: <p>I'm trying to mirror libswscale PIX_FMT_YUYV422-type image horizontally. Using simple loop for each line with 16-bits per pixel results in having colors wrong, for example blue objects are orange. Here is my code:</p>
  
  <pre><code>   typedef unsigned short YUVPixel; // 16 bits per pixel
      for (int y = 0; y &lt; outHeight; y++)
      {
          YUVPixel *p1 = (YUVPixel*)pBits + y * outWidth;
          YUVPixel *p2 = p1 + outWidth - 1;
          for (int x = 0; x &lt; outWidth/2; x++) // outWidth is image width in pixels
          {
              // packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
              unsigned short tmp;
              tmp = *p1;
              *p1 = *p2;
              *p2 = tmp;
          }
      }
  </code></pre>
  
  <p>Then I tried redefining YUVPixel as 32-bit type and modifying my loop accordingly. This results in correct colors, but looks like neighboring pixels are swapped. Any ideas, I'm totally lost with this?</p>