Vaapidecoder + appsink into eglImage

Davide Molteni via gstreamer-devel <[email protected]>
Newsgroups gmane.comp.video.gstreamer.devel
Message-ID <TYUPR04MB6964D1A7510729422783290AD138A@TYUPR04MB6964.apcprd04.prod.outlook.com>
Hi all,
I'm using a gstreamer VAAPI decoder pipeline with an appsink and I'm binding the samples on an egl texture where data is the pointer to GstMapInfo->data from gst_buffer_map.
Eglsurface is then rendered on framebuffers, since I'm running on an embedded platform without window manger.

Pseudocode of my appsink looks like the following:

GstBuffer* buffer = gst_sample_get_buffer(sample);
GstMapInfo memoryInfo;
gst_buffer_map(buffer, &memoryInfo, GST_MAP_READ);

/*opengGL stuff*/
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, memoryInfo.data);

gst_buffer_unmap(buffer, &memoryInfo);


The current code seems to work correctly in both cases when I set the caps of the decoder to video/x-raw and when I set it to video/x-raw(memory:VASurface), which is kind of strange, I would expect a crash in case of VASurface, am I missing something here?

Anyway I'm looking for the correct way to create the eglImage from the VASurface, something that could look like this:

       VADRMPRIMESurfaceDescriptor va_surface_descriptor;
       vaExportSurfaceHandle(va_display, va_surface, VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2, VA_EXPORT_SURFACE_READ_ONLY, &va_surface_descriptor);

       EGLAttrib egl_img_attributes[] = {
              EGL_LINUX_DRM_FOURCC_EXT, va_surface_descriptor.layers[0].drm_format,
              EGL_WIDTH, va_surface_descriptor.width,
              EGL_HEIGHT, va_surface_descriptor.height,
              EGL_DMA_BUF_PLANE0_FD_EXT, va_surface_descriptor.objects[va_surface_descriptor.layers[0].object_index[0]].fd,
              EGL_DMA_BUF_PLANE0_OFFSET_EXT, va_surface_descriptor.layers[0].offset[0],
              EGL_DMA_BUF_PLANE0_PITCH_EXT, va_surface_descriptor.layers[0].pitch[0],
              EGL_NONE
       };
       hEglImage = eglCreateImage(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, egl_img_attributes);
              glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, hEglImage);

But I need to get an handle to va_display (VADisplay) and va_image (which is the VASurfaceID) from the sample pulled from the appsink.

Is it possible to access them from the Buffer Metadata? Probably doing something like this in the appsink callback:

GstBuffer* buffer = gst_sample_get_buffer(sample);
GstVaapiVideoMeta* const meta = gst_buffer_get_vaapi_video_meta(buffer);
Is it the correct approach?

Thanks,
Davide
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.