title: How to convert yuy2 video samples to rgb samples?
body: <p>I know the formula to convert yuy2 to rgb as described in here: 
  <a href="https://stackoverflow.com/questions/4491649/how-to-convert-yuy2-to-a-bitmap-in-c">Convert yuy2 to bitmap</a></p>
  
  <p>My problem is that I don't know how to apply it in a directshow filter:</p>
  
  <p>In directshow i have a buffer and a header but how do I convert these into rgb?
  The formula is:</p>
  
  <pre><code>int C = luma - 16;
  int D = cr - 128;
  int E = cb - 128;
  r = (298*C+409*E+128)/256;
  g = (298*C-100*D-208*E+128)/256;
  b = (298*C+516*D+128)/256;
  </code></pre>
  
  <p>How do i get these values and how do I write them into the output buffer?</p>
  
  <p>This is how i copy the buffer at the moment:</p>
  
  <pre><code>long lSizeSample = sample-&gt;GetSize();
  long lSizeOutSample = outsample-&gt;GetSize();
  outsample-&gt;GetPointer(&amp;newBuffer);
  sample-&gt;GetPointer(&amp;sampleBuffer);
  memcpy((void *)newBuffer, (void *)sampleBuffer, lSizeSample);
  </code></pre>
  
  <p>So i just copy the buffer. But how do i modify it?</p>