void gst_vaapi_decoder_finalize (GstVaapiDecoder * decoder) { const GstVaapiDecoderClass *const klass = GST_VAAPI_DECODER_GET_CLASS (decoder); if (klass->destroy) klass->destroy (decoder); gst_video_codec_state_unref (decoder->codec_state); decoder->codec_state = NULL; parser_state_finalize (&decoder->parser_state); if (decoder->buffers) { g_async_queue_unref (decoder->buffers); decoder->buffers = NULL; } if (decoder->frames) { g_async_queue_unref (decoder->frames); decoder->frames = NULL; } gst_vaapi_object_replace (&decoder->context, NULL); decoder->va_context = VA_INVALID_ID; gst_vaapi_display_replace (&decoder->display, NULL); decoder->va_display = NULL; }
/* Base encoder cleanup (internal) */ void gst_vaapi_encoder_finalize (GstVaapiEncoder * encoder) { GstVaapiEncoderClass *const klass = GST_VAAPI_ENCODER_GET_CLASS (encoder); klass->finalize (encoder); gst_vaapi_object_replace (&encoder->context, NULL); gst_vaapi_display_replace (&encoder->display, NULL); encoder->va_display = NULL; if (encoder->properties) { g_ptr_array_unref (encoder->properties); encoder->properties = NULL; } gst_vaapi_video_pool_replace (&encoder->codedbuf_pool, NULL); if (encoder->codedbuf_queue) { g_async_queue_unref (encoder->codedbuf_queue); encoder->codedbuf_queue = NULL; } g_cond_clear (&encoder->surface_free); g_cond_clear (&encoder->codedbuf_free); g_mutex_clear (&encoder->mutex); }
static void gst_vaapi_subpicture_destroy (GstVaapiSubpicture * subpicture) { GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (subpicture); VASubpictureID subpicture_id; VAStatus status; subpicture_id = GST_VAAPI_OBJECT_ID (subpicture); GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (subpicture_id)); if (subpicture_id != VA_INVALID_ID) { if (display) { GST_VAAPI_DISPLAY_LOCK (display); status = vaDestroySubpicture (GST_VAAPI_DISPLAY_VADISPLAY (display), subpicture_id); GST_VAAPI_DISPLAY_UNLOCK (display); if (!vaapi_check_status (status, "vaDestroySubpicture()")) g_warning ("failed to destroy subpicture %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (subpicture_id)); } GST_VAAPI_OBJECT_ID (subpicture) = VA_INVALID_ID; } gst_vaapi_object_replace (&subpicture->image, NULL); }
static gboolean ensure_image (GstVaapiVideoMemory * mem) { if (!mem->image && mem->use_direct_rendering) { mem->image = gst_vaapi_surface_derive_image (mem->surface); if (!mem->image) { GST_WARNING ("failed to derive image, fallbacking to copy"); mem->use_direct_rendering = FALSE; } else if (gst_vaapi_surface_get_format (mem->surface) != GST_VIDEO_INFO_FORMAT (mem->image_info)) { gst_vaapi_object_replace (&mem->image, NULL); mem->use_direct_rendering = FALSE; } } if (!mem->image) { GstVaapiVideoAllocator *const allocator = GST_VAAPI_VIDEO_ALLOCATOR_CAST (GST_MEMORY_CAST (mem)->allocator); mem->image = gst_vaapi_video_pool_get_object (allocator->image_pool); if (!mem->image) return FALSE; } gst_vaapi_video_meta_set_image (mem->meta, mem->image); return TRUE; }
GstAllocator * gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display, const GstVideoInfo * vip, guint flags) { GstAllocator *allocator = NULL; GstVaapiSurface *surface = NULL; GstVaapiImage *image = NULL; GstVideoInfo alloc_info; g_return_val_if_fail (display != NULL, NULL); g_return_val_if_fail (vip != NULL, NULL); do { surface = gst_vaapi_surface_new_full (display, vip, flags); if (!surface) break; image = gst_vaapi_surface_derive_image (surface); if (!image || !gst_vaapi_image_map (image)) break; gst_video_info_set_format (&alloc_info, GST_VIDEO_INFO_FORMAT (vip), GST_VIDEO_INFO_WIDTH (vip), GST_VIDEO_INFO_HEIGHT (vip)); gst_video_info_update_from_image (&alloc_info, image); gst_vaapi_image_unmap (image); allocator = gst_dmabuf_allocator_new (); if (!allocator) break; gst_allocator_set_vaapi_video_info (allocator, &alloc_info, flags); } while (0); gst_vaapi_object_replace (&image, NULL); gst_vaapi_object_replace (&surface, NULL); return allocator; }
void gst_vaapi_video_memory_reset_image (GstVaapiVideoMemory * mem) { GstVaapiVideoAllocator *const allocator = GST_VAAPI_VIDEO_ALLOCATOR_CAST (GST_MEMORY_CAST (mem)->allocator); if (mem->use_direct_rendering) gst_vaapi_object_replace (&mem->image, NULL); else if (mem->image) { gst_vaapi_video_pool_put_object (allocator->image_pool, mem->image); mem->image = NULL; } /* Don't synchronize to surface, this shall have happened during unmaps */ GST_VAAPI_VIDEO_MEMORY_FLAG_UNSET (mem, GST_VAAPI_VIDEO_MEMORY_FLAG_IMAGE_IS_CURRENT); }
/** * gst_vaapi_encoder_replace: * @old_encoder_ptr: a pointer to a #GstVaapiEncoder * @new_encoder: a #GstVaapiEncoder * * Atomically replaces the encoder encoder held in @old_encoder_ptr * with @new_encoder. This means that @old_encoder_ptr shall reference * a valid encoder. However, @new_encoder can be NULL. */ void gst_vaapi_encoder_replace (GstVaapiEncoder ** old_encoder_ptr, GstVaapiEncoder * new_encoder) { gst_vaapi_object_replace (old_encoder_ptr, new_encoder); }
/** * gst_vaapi_decoder_replace: * @old_decoder_ptr: a pointer to a #GstVaapiDecoder * @new_decoder: a #GstVaapiDecoder * * Atomically replaces the decoder decoder held in @old_decoder_ptr * with @new_decoder. This means that @old_decoder_ptr shall reference * a valid decoder. However, @new_decoder can be NULL. */ void gst_vaapi_decoder_replace (GstVaapiDecoder ** old_decoder_ptr, GstVaapiDecoder * new_decoder) { gst_vaapi_object_replace (old_decoder_ptr, new_decoder); }