/** * gst_vaapi_surface_query_status: * @surface: a #GstVaapiSurface * @pstatus: return location for the #GstVaapiSurfaceStatus * * Finds out any pending operations on the @surface. The * #GstVaapiSurfaceStatus flags are returned into @pstatus. * * Return value: %TRUE on success */ gboolean gst_vaapi_surface_query_status( GstVaapiSurface *surface, GstVaapiSurfaceStatus *pstatus ) { VASurfaceStatus surface_status; VAStatus status; g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), FALSE); GST_VAAPI_OBJECT_LOCK_DISPLAY(surface); status = vaQuerySurfaceStatus( GST_VAAPI_OBJECT_VADISPLAY(surface), GST_VAAPI_OBJECT_ID(surface), &surface_status ); GST_VAAPI_OBJECT_UNLOCK_DISPLAY(surface); if (!vaapi_check_status(status, "vaQuerySurfaceStatus()")) return FALSE; if (pstatus) *pstatus = to_GstVaapiSurfaceStatus(surface_status); return TRUE; }
static void coded_buffer_unmap (GstVaapiCodedBuffer * buf) { if (!buf->segment_list) return; GST_VAAPI_OBJECT_LOCK_DISPLAY (buf); vaapi_unmap_buffer (GST_VAAPI_OBJECT_VADISPLAY (buf), GST_VAAPI_OBJECT_ID (buf), (void **) &buf->segment_list); GST_VAAPI_OBJECT_UNLOCK_DISPLAY (buf); }
static gboolean coded_buffer_map (GstVaapiCodedBuffer * buf) { if (buf->segment_list) return TRUE; GST_VAAPI_OBJECT_LOCK_DISPLAY (buf); buf->segment_list = vaapi_map_buffer (GST_VAAPI_OBJECT_VADISPLAY (buf), GST_VAAPI_OBJECT_ID (buf)); GST_VAAPI_OBJECT_UNLOCK_DISPLAY (buf); return buf->segment_list != NULL; }
/** * gst_vaapi_texture_put_surface: * @texture: a #GstVaapiTexture * @surface: a #GstVaapiSurface * @flags: postprocessing flags. See #GstVaapiTextureRenderFlags * * Renders the @surface into the àtexture. The @flags specify how * de-interlacing (if needed), color space conversion, scaling and * other postprocessing transformations are performed. * * Return value: %TRUE on success */ static gboolean gst_vaapi_texture_glx_put_surface_unlocked (GstVaapiTexture * base_texture, GstVaapiSurface * surface, const GstVaapiRectangle * crop_rect, guint flags) { GstVaapiTextureGLX *const texture = GST_VAAPI_TEXTURE_GLX (base_texture); VAStatus status; GLContextState old_cs; gboolean success = FALSE; const GLfloat *txc, *tyc; static const GLfloat g_texcoords[2][2] = { {0.0f, 1.0f}, {1.0f, 0.0f}, }; status = vaPutSurface (GST_VAAPI_OBJECT_VADISPLAY (texture), GST_VAAPI_OBJECT_ID (surface), texture->pixo->pixmap, crop_rect->x, crop_rect->y, crop_rect->width, crop_rect->height, 0, 0, base_texture->width, base_texture->height, NULL, 0, from_GstVaapiSurfaceRenderFlags (flags)); if (!vaapi_check_status (status, "vaPutSurface() [TFP]")) return FALSE; if (texture->gl_context && !gl_set_current_context (texture->gl_context, &old_cs)) return FALSE; if (!gl_bind_framebuffer_object (texture->fbo)) { GST_ERROR ("failed to bind FBO"); goto out_reset_context; } if (!gst_vaapi_surface_sync (surface)) { GST_ERROR ("failed to render surface to pixmap"); goto out_unbind_fbo; } if (!gl_bind_pixmap_object (texture->pixo)) { GST_ERROR ("could not bind GLX pixmap"); goto out_unbind_fbo; } flags = GST_VAAPI_TEXTURE_FLAGS (texture); txc = g_texcoords[! !(flags & GST_VAAPI_TEXTURE_ORIENTATION_FLAG_X_INVERTED)]; tyc = g_texcoords[! !(flags & GST_VAAPI_TEXTURE_ORIENTATION_FLAG_Y_INVERTED)]; glColor4f (1.0f, 1.0f, 1.0f, 1.0f); glBegin (GL_QUADS); { glTexCoord2f (txc[0], tyc[0]); glVertex2i (0, 0); glTexCoord2f (txc[0], tyc[1]); glVertex2i (0, base_texture->height); glTexCoord2f (txc[1], tyc[1]); glVertex2i (base_texture->width, base_texture->height); glTexCoord2f (txc[1], tyc[0]); glVertex2i (base_texture->width, 0); } glEnd (); if (!gl_unbind_pixmap_object (texture->pixo)) { GST_ERROR ("failed to release GLX pixmap"); goto out_unbind_fbo; } success = TRUE; out_unbind_fbo: if (!gl_unbind_framebuffer_object (texture->fbo)) success = FALSE; out_reset_context: if (texture->gl_context && !gl_set_current_context (&old_cs, NULL)) success = FALSE; return success; }