title: How to display decoded MediaCodec frames out of order
body: <p>I'd like to display decoded video frames from <code>MediaCodec</code> out of order, or omit frames, or show frames multiple times.</p>
  
  <p>I considered configuring <code>MediaCodec</code> to use a <code>Surface</code>, call <code>MediaCodec.dequeueOutputBuffer()</code> repeatedly, save the resulting buffer indices, and then later call <code>MediaCodec.releaseOutputBuffer(desired_index, true)</code>, but there doesn't seem to be a way to increase the number of output buffers, so I might run out of output buffers if I'm dealing with a lot of frames to be rearranged.</p>
  
  <p>One idea I'm considering is to use <code>glReadPixels()</code> to read the pixel data into a frame buffer, convert the color format appropriately, then copy it to a <code>SurfaceView</code> when I need the frame displayed. But this seems like a lot of copying (and color format conversion) overhead, especially when I don't inherently need to modify the pixel data.</p>
  
  <p>So I'm wondering if there is a better, more performant way. Perhaps there is a way to configure a different Surface/Texture/Buffer for each decoded frame, and then a way to tell the <code>SurfaceView</code> to display a specific Surface/Texture/Buffer (without having to do a memory copy). It seems like there must be a way to accomplish this with OpenGL, but I'm very new to OpenGL and could use recommendations on areas to investigate. I'll even go NDK if I have to.</p>
  
  <p>So far I've been reviewing the Android docs, and fadden's bigflake and Grafika. Thanks.</p>