title: Convert RGB8888 to YUV420 with ColorMatrix.setRGB2YUV()
body: <p>I'm trying to find a faster way of converting RGB to YUV using the Android SDK as the standard pixel for pixel methods are pretty slow in Java. ColorMatrices seem to be pretty efficient and I see there's a setRGB2YUV() method but I can't find any examples and the documentation simply says "Set the matrix to convert RGB to YUV" which is completely useless as usual.</p>
  
  <p>Here's part of my initialization code, which is a little compicated slightly with arrays due to multithreading:</p>
  
  <pre><code>cacheBitmaps = new Bitmap[NumberOfThreads];
  cacheCanvas = new Canvas[NumberOfThreads];
  mRGB2YUV = new ColorMatrix();   
  cmfRGB2YUV = new ColorMatrixColorFilter(mRGB2YUV);
  pRGB2YUV = new Paint();
  pRGB2YUV.setColorFilter(cmfRGB2YUV);
  for (int m=0; m&lt; NumberOfThreads; m++) {
     cacheBitmaps[m] = Bitmap.createBitmap(widthX,heightY, Config.ARGB_8888);
     cacheCanvas[m] = new Canvas(cacheBitmaps[m]);
  }
  </code></pre>
  
  <p>Later I use this to paint an RGB to a canvas with the specified paint:</p>
  
  <pre><code>cacheCanvas[n].drawBitmap(fb.frames[n].getAndroidBitmap(),0,0, pRGB2YUV);
  </code></pre>
  
  <p>I've also experimented using a standard matrix that shouldn't apply any changes to the RGB values like this:</p>
  
  <pre><code>float[] matrix = { 
  0, 1, 0, 0, 0, //red
  0, 0, 1, 0, 0, //green
  0, 0, 0, 1, 0, //blue
  0, 0, 0, 0, 1 //alpha
  };
  mRGB2YUV.set(matrix);
  </code></pre>
  
  <p>Whatever I do I either get black, green or distorted frames in my output video (using JavaCV with FFMPEG and specifying AV_PIX_FMT_NV21 as a color format after copying the final bitmap to an IplImage).</p>
  
  <p>Anyone know how to use this and if it's even possible or does what it says it does?</p>