<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="IT" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi all,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Eglsurface is then rendered on framebuffers, since I’m running on an embedded platform without window manger.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Pseudocode of my appsink looks like the following:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">GstBuffer* buffer = gst_sample_get_buffer(sample);</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">GstMapInfo memoryInfo;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">gst_buffer_map(buffer, &memoryInfo, GST_MAP_READ);</span><span lang="EN-US">
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">/*opengGL stuff*/<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">glTexImage2D(</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:#6F008A">GL_TEXTURE_2D</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">,
0, </span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:#6F008A">GL_LUMINANCE</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">, width, height, 0,
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:#6F008A">GL_LUMINANCE</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">,
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:#6F008A">GL_UNSIGNED_BYTE</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">, memoryInfo.data);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">gst_buffer_unmap(buffer, &memoryInfo);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">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?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Anyway I’m looking for the correct way to create the eglImage from the VASurface, something that could look like this:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> VADRMPRIMESurfaceDescriptor va_surface_descriptor;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> vaExportSurfaceHandle(va_display, va_surface, VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2, VA_EXPORT_SURFACE_READ_ONLY, &va_surface_descriptor);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> EGLAttrib egl_img_attributes[] = {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> EGL_LINUX_DRM_FOURCC_EXT, va_surface_descriptor.layers[0].drm_format,<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> EGL_WIDTH, va_surface_descriptor.width,<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> EGL_HEIGHT, va_surface_descriptor.height,<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> EGL_DMA_BUF_PLANE0_FD_EXT, va_surface_descriptor.objects[va_surface_descriptor.layers[0].object_index[0]].fd,<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> EGL_DMA_BUF_PLANE0_OFFSET_EXT, va_surface_descriptor.layers[0].offset[0],<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> EGL_DMA_BUF_PLANE0_PITCH_EXT, va_surface_descriptor.layers[0].pitch[0],<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> EGL_NONE<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> };<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> hEglImage = eglCreateImage(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, egl_img_attributes);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, hEglImage);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">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.<br>
<br>
Is it possible to access them from the Buffer Metadata? Probably doing something like this in the appsink callback:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">GstBuffer* buffer = gst_sample_get_buffer(sample);<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">GstVaapiVideoMeta*
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:blue">const</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"> meta = gst_buffer_get_vaapi_video_meta(buffer);</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Is it the correct approach?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Davide<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</body>
</html>