title: Custom array sort ( YUYV -> YUV422P)
body: <p>I'm trying to sort and array from YUYV format to YUV422p format. The array currently looks like:</p>
  
  <p>[y1][cb1][y2][cr1][y3][cb2][y4][cr2][y5][cb3][y6][cr3][y7][cb4][y8][cr4] ...[yn][cbn+1/2][yn+1][crn+1/2]</p>
  
  <p>and i need to sort it to look like:</p>
  
  <p>[y1][y2][y3][y4][y5][y6][y7][y8][yn][yn+1]..[cb1][cb2][cb3][cb4][cbn+1/2]..[cr1][cr2][cr3][cr4][crn+1/2]</p>
  
  <p>all the y's need to be together, all the cb's together, all the cr's together. </p>
  
  <p>I'm trying to make this section as efficient as possible and take the least amount of time. </p>
  
  <p>Here is what I've done so far:</p>
  
  <pre><code>    inline const void YUYV_to_YUV422P_1280x960( char* yuyv, char* yuv422p)
      {
           const unsigned int height = 960;
           const unsigned int width  = 1280;
           int loopCount1 = height*width/2;
           int loopCount2 = height*width;
           char* yComponent   = yuv422p;
           char* cbComponent  = yuv422p + loopCount2;
           char* crComponent  = yuv422p + loopCount1 + loopCount2; 
  
           int i;
           for( i = (loopCount1 - 1); i != 0; --i )
           {
             cbComponent[ i ] = yuyv[ i*4 + 1 ];
             crComponent[ i ] = yuyv[ i*4 + 3 ];
           }
  
           for( i = (loopCount2 -1); i != 0; --i )
           {
             yComponent[ i ] = yuyv[ i*2 ];
           }
      }
  </code></pre>
  
  <p>Any thoughts on how to make this more efficient and faster please let me know.</p>