title: How to access EGL Image directly from Android Surface for use in MediaCodec video decoder?
body: <p>I'm currently writing an android app where I need to cache video-frames so that I can easily go back and forth with little to no delay.</p>
  
  <p>Right now I'm letting android decode the video frame by providing a Surface to the Configure call of the <code>MediaCodec</code> object and calling <code>releaseOutputBuffer</code> with the render flag set to <code>true</code>.</p>
  
  <p>The only way I found to access the decoded surface data (besides decoding the returned bytebuffer whose format appears to be device-dependent) is to call <code>updateTeximage</code> on the <code>SurfaceTexture</code> linked to the Surface, attaching this to the <code>GL_TEXTURE_EXTERNAL_OES</code> target and rendering it to a <code>GL_TEXTURE2D</code> target texture I created myself in order to cache it.</p>
  
  <p>I would like to optimize this caching process and be able to decode the frames on a different thread. Using my current method, this means that I would have to create another EGL context for the video decoder, share the context etc...</p>
  
  <p>My question is: <strong>Is it possible to access the EGL-image or native buffer data associated with the Surface without calling</strong> <code>updateTexImage</code>? </p>
  
  <p>That way I could cache the egl image (which does not require EGL context according to <code>EGL_ANDROID_image_native_buffer</code>). This would also cache in YUV format which would be much more storage-efficient than the raw RGB textures I'm caching now.</p>