Zero copy omxh264dec to EGLImage

Zevv Glass gst at zevv.nl
Wed Oct 3 08:59:29 UTC 2018


Working on RasperryPI / RDK + gstreamer 1.10.4

I'm looking for a way to zero copy GL textures from the omx h264 decoder from a
separate thread into my own GL context. The pipeline looks like this:

  appsrc ! h264parse ! omxh264dec ! glupload \
  ! appsink caps=\"video/x-raw(memory:GLMemory), format=(string)RGBA

Everything connects and links ok, and when going to PLAY state my appsrc
properly receives GL textures from the pipeline: I see a pool of 3 texture
names being delivered in the new-sample callback - so far so good.

Now I want to take the texture and transfer it to a KHR EGLImage so I can pick
this up in another thread/GL context and use the texture there with
glEGLImageTargetTexture2DOES().

(I am under some tight constraints regarding to EGL contexts and texure IDs. I
can not simple use the texture names received from gstreamer. Basically I need
to 'fake' a TexSubImage2D() call in another thread, injecting texture data
without the application knowing)

Here is my problem:

For some reason mEglCreateImageKHR() fails with:

   "eglCreateImageKHR:  failed to create image for buffer 0x2 target 12465 error 0x3002"

with 0x3002 meaning "EGL_BAD_ACCESS". The Khronos documentation for
mEglCreateImageKHR() gives some reasons for the EGL_BAD_ACCESS, but these
reasons do not seem to apply to my case, as far as I understand. I have looked
into the broadcom GL driver source for the implementation of
mEglCreateImageKHR() on the rPi at

  https://www.graphics-muse.org/archives/pibox/1.0.0/archives/rpi1/gles/gles/
  interface/khronos/ext/egl_khr_image_client.c

but only some basic checking happens here, and the call is transferred
somewhere else using some RPC mechanism, so I'm not able to figure out what is
happening under the hood.

As a test I generated a new texture with some pixel data in the new-sample
calback and pass this to eglCreateImageKHR() instead of the texid received in
the frame:

   glGenTextures(...)
   glBindTexture(...)
   glTexImage2D(...)
   mEglCreateImageKHR(...)

which works as expected: I can transfer the EGLImage to my other context
and use it here.

My question: is there anything 'special' about the texture delivered to the
new-sample callback that makes it different from the texture I glGenTextures()
myself that would make the mEglCreateImageKHR() call fail?

Thank you!

Zevv


More information about the gstreamer-devel mailing list