/*
* Every time releasing a gst buffer, we need to check the status of surface's lock,
- * so that we could manage locked surfaces seperatedly in the context.
+ * so that we could manage locked surfaces separately in the context.
* Otherwise, we put the surface to the available list.
*/
void
}
if ((flags & GST_MAP_WRITE) && mem->surface && mem->surface->Data.Locked) {
- GST_WARNING ("The surface in memory %p is not still avaliable", mem);
+ GST_WARNING ("The surface in memory %p is not still available", mem);
return FALSE;
}
pitch = mem_id->pitch;
#endif
- /* The first channel in memory is V for GST_VIDEO_FORMAT_VUYA */
- if (meta->format == GST_VIDEO_FORMAT_VUYA)
- *data = mem->surface->Data.V + offset;
- else if (meta->format == GST_VIDEO_FORMAT_Y410)
- *data = mem->surface->Data.U + offset; /* Data.Y410 */
- else
- *data = mem->surface->Data.Y + offset;
- *stride = pitch;
+ switch (meta->format) {
+ case GST_VIDEO_FORMAT_BGRA:
+ *data = mem->surface->Data.B + offset;
+ break;
+
+ /* The first channel in memory is V for GST_VIDEO_FORMAT_VUYA */
+ case GST_VIDEO_FORMAT_VUYA:
+ *data = mem->surface->Data.V + offset;
+ break;
+
+ case GST_VIDEO_FORMAT_Y410:
+ *data = mem->surface->Data.U + offset; /* Data.Y410 */
+ break;
+
+ default:
+ *data = mem->surface->Data.Y + offset;
+ break;
+ }
+ *stride = pitch;
info->flags = flags;
ret = (*data != NULL);
if ((info->flags & GST_MAP_WRITE) && mem->surface
&& mem->surface->Data.Locked) {
- GST_WARNING ("The surface in memory %p is not still avaliable", mem);
+ GST_WARNING ("The surface in memory %p is not still available", mem);
return NULL;
}
gst_msdk_frame_lock (msdk_video_allocator->context, mem->surface->Data.MemId,
&mem->surface->Data);
- return mem->surface->Data.Y;
+
+ switch (mem->surface->Info.FourCC) {
+ case MFX_FOURCC_RGB4:
+ return mem->surface->Data.B; /* The first channel is B */
+
+ /* The first channel in memory is V for MFX_FOURCC_AYUV (GST_VIDEO_FORMAT_VUYA) format */
+ case MFX_FOURCC_AYUV:
+ return mem->surface->Data.V;
+
+#if (MFX_VERSION >= 1027)
+ case MFX_FOURCC_Y410:
+ return mem->surface->Data.U; /* Data.Y410 */
+#endif
+
+ default:
+ return mem->surface->Data.Y;
+ }
}
static void
{
GstMsdkVideoAllocator *allocator = GST_MSDK_VIDEO_ALLOCATOR_CAST (object);
+ gst_msdk_frame_free (allocator->context, allocator->alloc_response);
+
gst_object_unref (allocator->context);
G_OBJECT_CLASS (gst_msdk_video_allocator_parent_class)->finalize (object);
}
GstVideoInfo * image_info, mfxFrameAllocResponse * alloc_resp)
{
GstMsdkVideoAllocator *allocator;
+ GstMsdkAllocResponse *cached = NULL;
g_return_val_if_fail (context != NULL, NULL);
g_return_val_if_fail (image_info != NULL, NULL);
+ cached = gst_msdk_context_get_cached_alloc_responses (context, alloc_resp);
+
+ if (!cached) {
+ GST_ERROR ("Failed to get the cached alloc response");
+ return NULL;
+ }
+
allocator = g_object_new (GST_TYPE_MSDK_VIDEO_ALLOCATOR, NULL);
if (!allocator)
return NULL;
+ g_atomic_int_inc (&cached->refcount);
allocator->context = gst_object_ref (context);
allocator->image_info = *image_info;
- allocator->alloc_response = alloc_resp;
+ allocator->mfx_response = *alloc_resp;
+ allocator->alloc_response = &allocator->mfx_response;
return GST_ALLOCATOR_CAST (allocator);
}
{
GstMsdkDmaBufAllocator *allocator = GST_MSDK_DMABUF_ALLOCATOR_CAST (object);
+ gst_msdk_frame_free (allocator->context, allocator->alloc_response);
+
gst_object_unref (allocator->context);
G_OBJECT_CLASS (gst_msdk_dmabuf_allocator_parent_class)->finalize (object);
}
GstVideoInfo * image_info, mfxFrameAllocResponse * alloc_resp)
{
GstMsdkDmaBufAllocator *allocator;
+ GstMsdkAllocResponse *cached = NULL;
g_return_val_if_fail (context != NULL, NULL);
g_return_val_if_fail (image_info != NULL, NULL);
+ cached = gst_msdk_context_get_cached_alloc_responses (context, alloc_resp);
+
+ if (!cached) {
+ GST_ERROR ("Failed to get the cached alloc response");
+ return NULL;
+ }
+
allocator = g_object_new (GST_TYPE_MSDK_DMABUF_ALLOCATOR, NULL);
if (!allocator)
return NULL;
+ g_atomic_int_inc (&cached->refcount);
allocator->context = gst_object_ref (context);
allocator->image_info = *image_info;
- allocator->alloc_response = alloc_resp;
+ allocator->mfx_response = *alloc_resp;
+ allocator->alloc_response = &allocator->mfx_response;
return GST_ALLOCATOR_CAST (allocator);
}