msdk: Remove unused gstmsdkbufferpool and memory

GstMsdkBufferPool, GstMsdkVideoMemory and GstMsdkSystemMemory are no
longer used in msdk plugins, instead we use va/d3d11 pool for memory
allocation. So, remove the codes of unused stuffs.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4276>
This commit is contained in:
Mengkejiergeli Ba 2022-12-01 15:15:27 +08:00 committed by GStreamer Marge Bot
parent ef1397cbe3
commit ec2ef6e2d3
16 changed files with 3 additions and 1840 deletions

View file

@ -50,7 +50,6 @@
#endif
#include "gstmsdkav1dec.h"
#include "gstmsdkvideomemory.h"
GST_DEBUG_CATEGORY_EXTERN (gst_msdkav1dec_debug);
#define GST_CAT_DEFAULT gst_msdkav1dec_debug

View file

@ -1,395 +0,0 @@
/* GStreamer Intel MSDK plugin
* Copyright (c) 2018, Intel Corporation
* Copyright (c) 2018, Igalia S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGDECE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "gstmsdkbufferpool.h"
#include "gstmsdksystemmemory.h"
#include "gstmsdkvideomemory.h"
#ifndef _WIN32
#include "gstmsdkallocator_libva.h"
#endif
GST_DEBUG_CATEGORY_STATIC (gst_debug_msdkbufferpool);
#define GST_CAT_DEFAULT gst_debug_msdkbufferpool
typedef enum _GstMsdkMemoryType
{
GST_MSDK_MEMORY_TYPE_SYSTEM,
GST_MSDK_MEMORY_TYPE_VIDEO,
GST_MSDK_MEMORY_TYPE_DMABUF,
} GstMsdkMemoryType;
struct _GstMsdkBufferPoolPrivate
{
GstMsdkContext *context;
GstAllocator *allocator;
mfxFrameAllocResponse *alloc_response;
GstMsdkMemoryType memory_type;
gboolean add_videometa;
gboolean need_alignment;
GstVideoAlignment alignment;
};
#define gst_msdk_buffer_pool_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstMsdkBufferPool, gst_msdk_buffer_pool,
GST_TYPE_VIDEO_BUFFER_POOL, G_ADD_PRIVATE (GstMsdkBufferPool)
GST_DEBUG_CATEGORY_INIT (gst_debug_msdkbufferpool, "msdkbufferpool", 0,
"MSDK Buffer Pool"));
static const gchar **
gst_msdk_buffer_pool_get_options (GstBufferPool * pool)
{
static const gchar *options[] = { GST_BUFFER_POOL_OPTION_VIDEO_META,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT,
GST_BUFFER_POOL_OPTION_MSDK_USE_VIDEO_MEMORY,
GST_BUFFER_POOL_OPTION_MSDK_USE_DMABUF,
NULL
};
return options;
}
static inline GstMsdkMemoryType
_msdk_get_memory_type (GstStructure * config)
{
gboolean video, dmabuf;
video = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_MSDK_USE_VIDEO_MEMORY);
dmabuf = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_MSDK_USE_DMABUF);
if (video && !dmabuf)
return GST_MSDK_MEMORY_TYPE_VIDEO;
if (video && dmabuf)
return GST_MSDK_MEMORY_TYPE_DMABUF;
if (!video && dmabuf)
GST_WARNING ("Can't use DMAbuf since it's system msdk bufferpool");
return GST_MSDK_MEMORY_TYPE_SYSTEM;
}
static gboolean
gst_msdk_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
{
GstMsdkBufferPool *msdk_pool = GST_MSDK_BUFFER_POOL_CAST (pool);
GstMsdkBufferPoolPrivate *priv = msdk_pool->priv;
GstCaps *caps = NULL;
GstAllocator *allocator = NULL;
GstVideoInfo video_info;
guint size, min_buffers, max_buffers;
if (!gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers,
&max_buffers))
goto error_invalid_config;
if (!caps)
goto error_no_caps;
if (!gst_video_info_from_caps (&video_info, caps))
goto error_invalid_caps;
if (!gst_buffer_pool_config_get_allocator (config, &allocator, NULL))
goto error_invalid_allocator;
if (allocator
&& (g_strcmp0 (allocator->mem_type, GST_MSDK_SYSTEM_MEMORY_NAME) != 0
&& g_strcmp0 (allocator->mem_type, GST_MSDK_VIDEO_MEMORY_NAME) != 0
&& g_strcmp0 (allocator->mem_type,
GST_MSDK_DMABUF_MEMORY_NAME) != 0)) {
GST_INFO_OBJECT (pool,
"This is not MSDK allocator. So this will be ignored");
gst_object_unref (allocator);
allocator = NULL;
}
priv->add_videometa = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
priv->need_alignment = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
if (priv->add_videometa && priv->need_alignment) {
gst_msdk_set_video_alignment (&video_info, 0, 0, &priv->alignment);
gst_video_info_align (&video_info, &priv->alignment);
gst_buffer_pool_config_set_video_alignment (config, &priv->alignment);
}
priv->memory_type = _msdk_get_memory_type (config);
if (((priv->memory_type == GST_MSDK_MEMORY_TYPE_VIDEO)
|| (priv->memory_type == GST_MSDK_MEMORY_TYPE_DMABUF))
&& (!priv->context || !priv->alloc_response)) {
GST_ERROR_OBJECT (pool,
"No MSDK context or Allocation response for using video memory");
goto error_invalid_config;
}
/* create a new allocator if needed */
if (!allocator) {
GstAllocationParams params = { 0, 31, 0, 0, };
if (priv->memory_type == GST_MSDK_MEMORY_TYPE_DMABUF)
allocator =
gst_msdk_dmabuf_allocator_new (priv->context, &video_info,
priv->alloc_response);
else if (priv->memory_type == GST_MSDK_MEMORY_TYPE_VIDEO)
allocator =
gst_msdk_video_allocator_new (priv->context, &video_info,
priv->alloc_response);
else
allocator = gst_msdk_system_allocator_new (&video_info);
if (!allocator)
goto error_no_allocator;
GST_INFO_OBJECT (pool, "created new allocator %" GST_PTR_FORMAT, allocator);
gst_buffer_pool_config_set_allocator (config, allocator, &params);
gst_object_unref (allocator);
}
if (priv->allocator)
gst_object_unref (priv->allocator);
priv->allocator = gst_object_ref (allocator);
return GST_BUFFER_POOL_CLASS
(gst_msdk_buffer_pool_parent_class)->set_config (pool, config);
error_invalid_config:
{
GST_ERROR_OBJECT (pool, "invalid config");
return FALSE;
}
error_no_caps:
{
GST_ERROR_OBJECT (pool, "no caps in config");
return FALSE;
}
error_invalid_caps:
{
GST_ERROR_OBJECT (pool, "invalid caps %" GST_PTR_FORMAT, caps);
return FALSE;
}
error_invalid_allocator:
{
GST_ERROR_OBJECT (pool, "no allocator in config");
return FALSE;
}
error_no_allocator:
{
GST_ERROR_OBJECT (pool, "no allocator defined");
return FALSE;
}
}
static GstFlowReturn
gst_msdk_buffer_pool_alloc_buffer (GstBufferPool * pool,
GstBuffer ** out_buffer_ptr, GstBufferPoolAcquireParams * params)
{
GstMsdkBufferPool *msdk_pool = GST_MSDK_BUFFER_POOL_CAST (pool);
GstMsdkBufferPoolPrivate *priv = msdk_pool->priv;
GstMemory *mem;
GstBuffer *buf;
buf = gst_buffer_new ();
if (priv->memory_type == GST_MSDK_MEMORY_TYPE_DMABUF)
mem = gst_msdk_dmabuf_memory_new (priv->allocator);
else if (priv->memory_type == GST_MSDK_MEMORY_TYPE_VIDEO)
mem = gst_msdk_video_memory_new (priv->allocator);
else
mem = gst_msdk_system_memory_new (priv->allocator);
if (!mem)
goto no_memory;
gst_buffer_append_memory (buf, mem);
if (priv->add_videometa) {
GstVideoMeta *vmeta;
GstVideoInfo *info;
if (priv->memory_type == GST_MSDK_MEMORY_TYPE_DMABUF)
info = &GST_MSDK_DMABUF_ALLOCATOR_CAST (priv->allocator)->image_info;
else if (priv->memory_type == GST_MSDK_MEMORY_TYPE_VIDEO)
info = &GST_MSDK_VIDEO_ALLOCATOR_CAST (priv->allocator)->image_info;
else
info = &GST_MSDK_SYSTEM_ALLOCATOR_CAST (priv->allocator)->image_info;
vmeta = gst_buffer_add_video_meta_full (buf, GST_VIDEO_FRAME_FLAG_NONE,
GST_VIDEO_INFO_FORMAT (info),
GST_VIDEO_INFO_WIDTH (info), GST_VIDEO_INFO_HEIGHT (info),
GST_VIDEO_INFO_N_PLANES (info), info->offset, info->stride);
if (priv->need_alignment) {
if (!gst_video_meta_set_alignment (vmeta, priv->alignment)) {
GST_ERROR_OBJECT (pool, "failed to set alignment");
return GST_FLOW_ERROR;
}
}
if (priv->memory_type == GST_MSDK_MEMORY_TYPE_VIDEO) {
vmeta->map = gst_video_meta_map_msdk_memory;
vmeta->unmap = gst_video_meta_unmap_msdk_memory;
}
}
*out_buffer_ptr = buf;
return GST_FLOW_OK;
no_memory:
{
GST_ERROR_OBJECT (pool, "failed to create new MSDK memory");
return GST_FLOW_ERROR;
}
}
static GstFlowReturn
gst_msdk_buffer_pool_acquire_buffer (GstBufferPool * pool,
GstBuffer ** out_buffer_ptr, GstBufferPoolAcquireParams * params)
{
GstMsdkBufferPool *msdk_pool = GST_MSDK_BUFFER_POOL_CAST (pool);
GstMsdkBufferPoolPrivate *priv = msdk_pool->priv;
GstBuffer *buf = NULL;
GstFlowReturn ret;
mfxFrameSurface1 *surface;
ret =
GST_BUFFER_POOL_CLASS (parent_class)->acquire_buffer (pool, &buf, params);
if (ret != GST_FLOW_OK || priv->memory_type == GST_MSDK_MEMORY_TYPE_SYSTEM) {
if (buf)
*out_buffer_ptr = buf;
return ret;
}
surface = gst_msdk_get_surface_from_buffer (buf);
/* When using video memory, mfx surface is still locked even though
* it's finished by SyncOperation. There's no way to get notified when it gets unlocked.
* So we need to confirm if it's unlocked every time a gst buffer is acquired.
* If it's still locked, we can replace it with new unlocked/unused surface.
*/
if (!surface || surface->Data.Locked > 0) {
if (!gst_msdk_video_memory_get_surface_available (gst_buffer_peek_memory
(buf, 0))) {
GST_WARNING_OBJECT (pool, "failed to get new surface available");
return GST_FLOW_ERROR;
}
}
#ifndef _WIN32
/* When using dmabuf, we should confirm that the fd of memory and
* the fd of surface match, since there is no guarantee that fd matches
* between surface and memory.
*/
if (priv->memory_type == GST_MSDK_MEMORY_TYPE_DMABUF) {
gint fd;
surface = gst_msdk_get_surface_from_buffer (buf);
gst_msdk_get_dmabuf_info_from_surface (surface, &fd, NULL);
if (gst_dmabuf_memory_get_fd (gst_buffer_peek_memory (buf, 0)) != fd) {
GstMemory *mem;
mem = gst_msdk_dmabuf_memory_new_with_surface (priv->allocator, surface);
gst_buffer_replace_memory (buf, 0, mem);
gst_buffer_unset_flags (buf, GST_BUFFER_FLAG_TAG_MEMORY);
}
}
#endif
*out_buffer_ptr = buf;
return GST_FLOW_OK;
}
static void
gst_msdk_buffer_pool_release_buffer (GstBufferPool * pool, GstBuffer * buf)
{
mfxFrameSurface1 *surface;
GstMsdkBufferPool *msdk_pool = GST_MSDK_BUFFER_POOL_CAST (pool);
GstMsdkBufferPoolPrivate *priv = msdk_pool->priv;
if (priv->memory_type == GST_MSDK_MEMORY_TYPE_SYSTEM)
goto done;
surface = gst_msdk_get_surface_from_buffer (buf);
if (!surface)
goto done;
gst_msdk_video_memory_release_surface (gst_buffer_peek_memory (buf, 0));
done:
GST_BUFFER_POOL_CLASS (parent_class)->release_buffer (pool, buf);
}
static void
gst_msdk_buffer_pool_finalize (GObject * object)
{
GstMsdkBufferPool *pool = GST_MSDK_BUFFER_POOL_CAST (object);
GstMsdkBufferPoolPrivate *priv = pool->priv;
if (priv->allocator)
gst_object_unref (priv->allocator);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gst_msdk_buffer_pool_init (GstMsdkBufferPool * pool)
{
pool->priv = gst_msdk_buffer_pool_get_instance_private (pool);
}
static void
gst_msdk_buffer_pool_class_init (GstMsdkBufferPoolClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GstBufferPoolClass *pool_class = GST_BUFFER_POOL_CLASS (klass);
object_class->finalize = gst_msdk_buffer_pool_finalize;
pool_class->get_options = gst_msdk_buffer_pool_get_options;
pool_class->set_config = gst_msdk_buffer_pool_set_config;
pool_class->alloc_buffer = gst_msdk_buffer_pool_alloc_buffer;
pool_class->acquire_buffer = gst_msdk_buffer_pool_acquire_buffer;
pool_class->release_buffer = gst_msdk_buffer_pool_release_buffer;
}
GstBufferPool *
gst_msdk_buffer_pool_new (GstMsdkContext * context,
mfxFrameAllocResponse * alloc_resp)
{
GstMsdkBufferPool *pool = g_object_new (GST_TYPE_MSDK_BUFFER_POOL, NULL);
/* Doesn't need to count reference of the context */
pool->priv->context = context;
pool->priv->alloc_response = alloc_resp;
return GST_BUFFER_POOL_CAST (pool);
}

View file

@ -1,96 +0,0 @@
/* GStreamer Intel MSDK plugin
* Copyright (c) 2018, Intel Corporation
* Copyright (c) 2018, Igalia S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGDECE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef GST_MSDK_BUFFER_POOL_H
#define GST_MSDK_BUFFER_POOL_H
#include "msdk.h"
#include "gstmsdkcontext.h"
G_BEGIN_DECLS
#define GST_TYPE_MSDK_BUFFER_POOL \
(gst_msdk_buffer_pool_get_type ())
#define GST_MSDK_BUFFER_POOL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MSDK_BUFFER_POOL, \
GstMsdkBufferPool))
#define GST_MSDK_BUFFER_POOL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MSDK_BUFFER_POOL, \
GstMsdkBufferPoolClass))
#define GST_IS_MSDK_BUFFER_POOL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MSDK_BUFFER_POOL))
#define GST_IS_MSDK_BUFFER_POOL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MSDK_BUFFER_POOL))
#define GST_MSDK_BUFFER_POOL_CAST(obj) ((GstMsdkBufferPool*)(obj))
typedef struct _GstMsdkBufferPool GstMsdkBufferPool;
typedef struct _GstMsdkBufferPoolClass GstMsdkBufferPoolClass;
typedef struct _GstMsdkBufferPoolPrivate GstMsdkBufferPoolPrivate;
/*
* GST_BUFFER_POOL_OPTION_MSDK_USE_VIDEO_MEMORY:
*
* An option that presents if the bufferpool will use
* MsdkSystemAllocator or MsdkVideoAllocator.
*/
#define GST_BUFFER_POOL_OPTION_MSDK_USE_VIDEO_MEMORY "GstBufferPoolOptionMsdkUseVideoMemory"
#define GST_BUFFER_POOL_OPTION_MSDK_USE_DMABUF "GstBufferPoolOptionMsdkUseDMABuf"
/**
* GstMsdkBufferPool:
*
* A MSDK buffer pool object.
*/
struct _GstMsdkBufferPool
{
GstVideoBufferPool parent_instance;
GstMsdkBufferPoolPrivate *priv;
};
/**
* GstMsdkBufferPoolClass:
*
* A MSDK buffer pool class.
*/
struct _GstMsdkBufferPoolClass
{
GstVideoBufferPoolClass parent_class;
};
GType gst_msdk_buffer_pool_get_type (void);
GstBufferPool * gst_msdk_buffer_pool_new (GstMsdkContext * context,
mfxFrameAllocResponse * alloc_resp);
G_END_DECLS
#endif /* GST_MSDK_BUFFER_POOL_H */

View file

@ -36,9 +36,6 @@
#include <stdlib.h>
#include "gstmsdkdec.h"
#include "gstmsdkbufferpool.h"
#include "gstmsdkvideomemory.h"
#include "gstmsdksystemmemory.h"
#include "gstmsdkcontextutil.h"
#include "gstmsdkallocator.h"

View file

@ -45,10 +45,8 @@
#include <stdlib.h>
#include "gstmsdkenc.h"
#include "gstmsdkbufferpool.h"
#include "gstmsdkvideomemory.h"
#include "gstmsdksystemmemory.h"
#include "gstmsdkcontextutil.h"
#include "gstmsdkallocator.h"
#include "mfxjpeg.h"
#ifndef _WIN32
@ -1437,13 +1435,6 @@ gst_msdkenc_create_buffer_pool (GstMsdkEnc * thiz, GstCaps * caps,
GST_VIDEO_INFO_SIZE (&info), num_buffers, 0);
gst_buffer_pool_config_set_video_alignment (config, &align);
if (thiz->use_video_memory) {
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_MSDK_USE_VIDEO_MEMORY);
if (thiz->use_dmabuf)
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_MSDK_USE_DMABUF);
}
if (!gst_buffer_pool_set_config (pool, config))
goto error_pool_config;

View file

@ -50,7 +50,6 @@
#endif
#include "gstmsdkh265dec.h"
#include "gstmsdkvideomemory.h"
GST_DEBUG_CATEGORY_EXTERN (gst_msdkh265dec_debug);
#define GST_CAT_DEFAULT gst_msdkh265dec_debug

View file

@ -53,7 +53,6 @@
#include <mfxjpeg.h>
#include "gstmsdkmjpegdec.h"
#include "gstmsdkvideomemory.h"
#include <gst/pbutils/pbutils.h>

View file

@ -1,380 +0,0 @@
/* GStreamer Intel MSDK plugin
* Copyright (c) 2018, Intel Corporation
* Copyright (c) 2018, Igalia S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGDECE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _WIN32
#include <unistd.h>
#endif
#include <stdlib.h>
#include "gstmsdksystemmemory.h"
#include <string.h>
#ifdef _WIN32
#define posix_memalign(d, a, s) ((*((void**)d) = _aligned_malloc(s, a)) ? 0 : -1)
#endif
#ifndef _WIN32
#define _aligned_free free
#endif
static gboolean
ensure_data (GstMsdkSystemMemory * mem)
{
gsize size;
void *data;
GstVideoInfo *info;
GstAllocator *allocator;
GstMsdkSystemAllocator *msdk_allocator;
allocator = GST_MEMORY_CAST (mem)->allocator;
msdk_allocator = GST_MSDK_SYSTEM_ALLOCATOR_CAST (allocator);
info = &msdk_allocator->image_info;
size = GST_VIDEO_INFO_SIZE (info);
if (mem->cache)
return TRUE;
if (posix_memalign (&data, 32, size) != 0) {
GST_ERROR ("Memory allocation failed");
return FALSE;
}
mem->cache = data;
mem->cached_data[0] = mem->cache;
mem->cached_data[1] = mem->cache + GST_VIDEO_INFO_PLANE_OFFSET (info, 1);
mem->cached_data[2] = mem->cache + GST_VIDEO_INFO_PLANE_OFFSET (info, 2);
mem->destination_pitches[0] = GST_VIDEO_INFO_PLANE_STRIDE (info, 0);
mem->destination_pitches[1] = GST_VIDEO_INFO_PLANE_STRIDE (info, 1);
mem->destination_pitches[2] = GST_VIDEO_INFO_PLANE_STRIDE (info, 2);
switch (GST_VIDEO_INFO_FORMAT (info)) {
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_P010_10LE:
case GST_VIDEO_FORMAT_P012_LE:
mem->surface->Data.Y = mem->cached_data[0];
mem->surface->Data.UV = mem->cached_data[1];
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
case GST_VIDEO_FORMAT_YV12:
mem->surface->Data.Y = mem->cached_data[0];
mem->surface->Data.U = mem->cached_data[2];
mem->surface->Data.V = mem->cached_data[1];
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
case GST_VIDEO_FORMAT_I420:
mem->surface->Data.Y = mem->cached_data[0];
mem->surface->Data.U = mem->cached_data[1];
mem->surface->Data.V = mem->cached_data[2];
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
case GST_VIDEO_FORMAT_YUY2:
mem->surface->Data.Y = mem->cached_data[0];
mem->surface->Data.U = mem->surface->Data.Y + 1;
mem->surface->Data.V = mem->surface->Data.Y + 3;
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
case GST_VIDEO_FORMAT_UYVY:
mem->surface->Data.Y = mem->cached_data[0];
mem->surface->Data.U = mem->surface->Data.Y;
mem->surface->Data.V = mem->surface->Data.U + 2;
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
case GST_VIDEO_FORMAT_BGRA:
case GST_VIDEO_FORMAT_BGRx:
mem->surface->Data.B = mem->cached_data[0];
mem->surface->Data.G = mem->surface->Data.B + 1;
mem->surface->Data.R = mem->surface->Data.B + 2;
mem->surface->Data.A = mem->surface->Data.B + 3;
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
#if (MFX_VERSION >= 1028)
case GST_VIDEO_FORMAT_RGB16:
mem->surface->Data.R = mem->cached_data[0];
mem->surface->Data.G = mem->surface->Data.R;
mem->surface->Data.B = mem->surface->Data.R;
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
#endif
case GST_VIDEO_FORMAT_VUYA:
mem->surface->Data.V = mem->cached_data[0];
mem->surface->Data.U = mem->surface->Data.V + 1;
mem->surface->Data.Y = mem->surface->Data.V + 2;
mem->surface->Data.A = mem->surface->Data.V + 3;
mem->surface->Data.PitchHigh =
(mfxU16) (mem->destination_pitches[0] / (1 << 16));
mem->surface->Data.PitchLow =
(mfxU16) (mem->destination_pitches[0] % (1 << 16));
break;
case GST_VIDEO_FORMAT_BGR10A2_LE:
mem->surface->Data.R = mem->cached_data[0];
mem->surface->Data.G = mem->surface->Data.R;
mem->surface->Data.B = mem->surface->Data.R;
mem->surface->Data.A = mem->surface->Data.R;
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
case GST_VIDEO_FORMAT_Y210:
case GST_VIDEO_FORMAT_Y212_LE:
mem->surface->Data.Y = mem->cached_data[0];
mem->surface->Data.U = mem->surface->Data.Y + 2;
mem->surface->Data.V = mem->surface->Data.Y + 6;
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
case GST_VIDEO_FORMAT_Y410:
mem->surface->Data.U = mem->cached_data[0]; /* Data.Y410 */
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
case GST_VIDEO_FORMAT_Y412_LE:
mem->surface->Data.U = mem->cached_data[0];
mem->surface->Data.Y = mem->surface->Data.U + 2;
mem->surface->Data.V = mem->surface->Data.U + 4;
mem->surface->Data.A = mem->surface->Data.U + 6;
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
#if (MFX_VERSION >= 2004)
case GST_VIDEO_FORMAT_RGBP:
mem->surface->Data.Pitch = mem->destination_pitches[0];
mem->surface->Data.R = mem->cached_data[0];
mem->surface->Data.G = mem->cached_data[1];
mem->surface->Data.B = mem->cached_data[2];
break;
case GST_VIDEO_FORMAT_BGRP:
mem->surface->Data.Pitch = mem->destination_pitches[0];
mem->surface->Data.B = mem->cached_data[0];
mem->surface->Data.G = mem->cached_data[1];
mem->surface->Data.R = mem->cached_data[2];
break;
#endif
default:
g_assert_not_reached ();
break;
}
return TRUE;
}
static mfxFrameSurface1 *
gst_msdk_system_allocator_create_surface (GstAllocator * allocator)
{
mfxFrameInfo frame_info = { {0,}, 0, };
mfxFrameSurface1 *surface;
GstMsdkSystemAllocator *msdk_system_allocator =
GST_MSDK_SYSTEM_ALLOCATOR_CAST (allocator);
surface = (mfxFrameSurface1 *) g_slice_new0 (mfxFrameSurface1);
if (!surface) {
GST_ERROR ("failed to allocate surface");
return NULL;
}
gst_msdk_set_mfx_frame_info_from_video_info (&frame_info,
&msdk_system_allocator->image_info);
surface->Info = frame_info;
return surface;
}
GstMemory *
gst_msdk_system_memory_new (GstAllocator * base_allocator)
{
GstMsdkSystemAllocator *allocator;
GstVideoInfo *vip;
GstMsdkSystemMemory *mem;
g_return_val_if_fail (base_allocator, NULL);
g_return_val_if_fail (GST_IS_MSDK_SYSTEM_ALLOCATOR (base_allocator), NULL);
allocator = GST_MSDK_SYSTEM_ALLOCATOR_CAST (base_allocator);
mem = g_slice_new0 (GstMsdkSystemMemory);
if (!mem)
return NULL;
mem->surface = gst_msdk_system_allocator_create_surface (base_allocator);
if (!mem->surface) {
g_slice_free (GstMsdkSystemMemory, mem);
return NULL;
}
vip = &allocator->image_info;
gst_memory_init (&mem->parent_instance, 0,
base_allocator, NULL, GST_VIDEO_INFO_SIZE (vip), 0, 0,
GST_VIDEO_INFO_SIZE (vip));
if (!ensure_data (mem)) {
g_slice_free (mfxFrameSurface1, mem->surface);
g_slice_free (GstMsdkSystemMemory, mem);
return NULL;
}
return GST_MEMORY_CAST (mem);
}
static gpointer
gst_msdk_system_memory_map_full (GstMemory * base_mem, GstMapInfo * info,
gsize maxsize)
{
GstMsdkSystemMemory *const mem = GST_MSDK_SYSTEM_MEMORY_CAST (base_mem);
g_return_val_if_fail (mem, NULL);
if (!mem->surface) {
GST_WARNING ("The surface is not allocated");
return NULL;
}
if ((info->flags & GST_MAP_WRITE) && mem->surface
&& mem->surface->Data.Locked) {
GST_WARNING ("The surface in memory %p is not still available", mem);
return NULL;
}
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
#if (MFX_VERSION >= 1031)
case MFX_FOURCC_Y416:
return mem->surface->Data.U; /* The first channel is U */
#endif
#if (MFX_VERSION >= 2004)
case MFX_FOURCC_RGBP:
return mem->surface->Data.R;
case MFX_FOURCC_BGRP:
return mem->surface->Data.B;
#endif
default:
return mem->surface->Data.Y;
}
}
static void
gst_msdk_system_memory_unmap (GstMemory * base_mem)
{
}
static GstMemory *
gst_msdk_system_memory_copy (GstMemory * base_mem, gssize offset, gssize size)
{
GstMsdkSystemMemory *copy;
GstVideoInfo *info;
GstMsdkSystemAllocator *msdk_allocator;
gsize mem_size;
/* FIXME: can we consider offset and size here ? */
copy =
(GstMsdkSystemMemory *) gst_msdk_system_memory_new (base_mem->allocator);
msdk_allocator = GST_MSDK_SYSTEM_ALLOCATOR_CAST (base_mem->allocator);
info = &msdk_allocator->image_info;
mem_size = GST_VIDEO_INFO_SIZE (info);
memcpy (copy->cache, GST_MSDK_SYSTEM_MEMORY_CAST (base_mem)->cache, mem_size);
return GST_MEMORY_CAST (copy);
}
/* GstMsdkSystemAllocator */
G_DEFINE_TYPE (GstMsdkSystemAllocator, gst_msdk_system_allocator,
GST_TYPE_ALLOCATOR);
static void
gst_msdk_system_allocator_free (GstAllocator * allocator, GstMemory * base_mem)
{
GstMsdkSystemMemory *const mem = GST_MSDK_SYSTEM_MEMORY_CAST (base_mem);
_aligned_free (mem->cache);
g_slice_free (mfxFrameSurface1, mem->surface);
g_slice_free (GstMsdkSystemMemory, mem);
}
static GstMemory *
gst_msdk_system_allocator_alloc (GstAllocator * allocator, gsize size,
GstAllocationParams * params)
{
return gst_msdk_system_memory_new (allocator);
}
static void
gst_msdk_system_allocator_class_init (GstMsdkSystemAllocatorClass * klass)
{
GstAllocatorClass *const allocator_class = GST_ALLOCATOR_CLASS (klass);
allocator_class->alloc = gst_msdk_system_allocator_alloc;
allocator_class->free = gst_msdk_system_allocator_free;
}
static void
gst_msdk_system_allocator_init (GstMsdkSystemAllocator * allocator)
{
GstAllocator *const base_allocator = GST_ALLOCATOR_CAST (allocator);
base_allocator->mem_type = GST_MSDK_SYSTEM_MEMORY_NAME;
base_allocator->mem_map_full = gst_msdk_system_memory_map_full;
base_allocator->mem_unmap = gst_msdk_system_memory_unmap;
base_allocator->mem_copy = gst_msdk_system_memory_copy;
GST_OBJECT_FLAG_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
}
GstAllocator *
gst_msdk_system_allocator_new (GstVideoInfo * image_info)
{
GstMsdkSystemAllocator *allocator;
g_return_val_if_fail (image_info != NULL, NULL);
allocator = g_object_new (GST_TYPE_MSDK_SYSTEM_ALLOCATOR, NULL);
if (!allocator)
return NULL;
allocator->image_info = *image_info;
return GST_ALLOCATOR_CAST (allocator);
}

View file

@ -1,119 +0,0 @@
/* GStreamer Intel MSDK plugin
* Copyright (c) 2018, Intel Corporation
* Copyright (c) 2018, Igalia S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGDECE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef GST_MSDK_SYSTEM_MEMORY_H
#define GST_MSDK_SYSTEM_MEMORY_H
#include "msdk.h"
G_BEGIN_DECLS
typedef struct _GstMsdkSystemMemory GstMsdkSystemMemory;
typedef struct _GstMsdkSystemAllocator GstMsdkSystemAllocator;
typedef struct _GstMsdkSystemAllocatorClass GstMsdkSystemAllocatorClass;
/* ---------------------------------------------------------------------*/
/* GstMsdkSystemMemory */
/* ---------------------------------------------------------------------*/
#define GST_MSDK_SYSTEM_MEMORY_CAST(mem) \
((GstMsdkSystemMemory *) (mem))
#define GST_IS_MSDK_SYSTEM_MEMORY(mem) \
((mem) && (mem)->allocator && GST_IS_MSDK_SYSTEM_ALLOCATOR((mem)->allocator))
#define GST_MSDK_SYSTEM_MEMORY_NAME "GstMsdkSystemMemory"
/**
* GstMsdkSystemMemory:
*
* A MSDK memory object holder, including mfxFrameSurface,
* video info of the surface.
*/
struct _GstMsdkSystemMemory
{
GstMemory parent_instance;
mfxFrameSurface1 *surface;
guint8 *cache;
mfxU8 *cached_data[4];
guint destination_pitches[4];
};
GstMemory *
gst_msdk_system_memory_new (GstAllocator * base_allocator);
/* ---------------------------------------------------------------------*/
/* GstMsdkSystemAllocator */
/* ---------------------------------------------------------------------*/
#define GST_MSDK_SYSTEM_ALLOCATOR_CAST(allocator) \
((GstMsdkSystemAllocator *) (allocator))
#define GST_TYPE_MSDK_SYSTEM_ALLOCATOR \
(gst_msdk_system_allocator_get_type ())
#define GST_MSDK_SYSTEM_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MSDK_SYSTEM_ALLOCATOR, \
GstMsdkSystemAllocator))
#define GST_IS_MSDK_SYSTEM_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MSDK_SYSTEM_ALLOCATOR))
/**
* GstMsdkSystemAllocator:
*
* A MSDK memory allocator object.
*/
struct _GstMsdkSystemAllocator
{
GstAllocator parent_instance;
GstVideoInfo image_info;
};
/**
* GstMsdkSystemAllocatorClass:
*
* A MSDK memory allocator class.
*/
struct _GstMsdkSystemAllocatorClass
{
GstAllocatorClass parent_class;
};
GType gst_msdk_system_allocator_get_type (void);
GstAllocator * gst_msdk_system_allocator_new (GstVideoInfo *image_info);
G_END_DECLS
#endif /* GST_MSDK_SYSTEM_MEMORY_H */

View file

@ -1,597 +0,0 @@
/* GStreamer Intel MSDK plugin
* Copyright (c) 2018, Intel Corporation
* Copyright (c) 2018, Igalia S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGDECE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _WIN32
#include <unistd.h>
#include <va/va.h>
#endif
#include <stdlib.h>
#include "gstmsdkvideomemory.h"
#include "gstmsdkallocator.h"
#define GST_MSDK_BUFFER_SURFACE gst_msdk_buffer_surface_quark_get ()
static GQuark
gst_msdk_buffer_surface_quark_get (void)
{
static gsize g_quark;
if (g_once_init_enter (&g_quark)) {
gsize quark = (gsize) g_quark_from_static_string ("GstMsdkBufferSurface");
g_once_init_leave (&g_quark, quark);
}
return g_quark;
}
static mfxFrameSurface1 *
gst_msdk_video_allocator_get_surface (GstAllocator * allocator)
{
mfxFrameInfo frame_info = { {0,}, 0, };
mfxFrameSurface1 *surface;
GstMsdkContext *context = NULL;
mfxFrameAllocResponse *resp = NULL;
GstVideoInfo *vinfo = NULL;
if (GST_IS_MSDK_VIDEO_ALLOCATOR (allocator)) {
context = GST_MSDK_VIDEO_ALLOCATOR_CAST (allocator)->context;
resp = GST_MSDK_VIDEO_ALLOCATOR_CAST (allocator)->alloc_response;
vinfo = &GST_MSDK_VIDEO_ALLOCATOR_CAST (allocator)->image_info;
} else if (GST_IS_MSDK_DMABUF_ALLOCATOR (allocator)) {
context = GST_MSDK_DMABUF_ALLOCATOR_CAST (allocator)->context;
resp = GST_MSDK_DMABUF_ALLOCATOR_CAST (allocator)->alloc_response;
vinfo = &GST_MSDK_DMABUF_ALLOCATOR_CAST (allocator)->image_info;
} else {
return NULL;
}
surface = gst_msdk_context_get_surface_available (context, resp);
if (!surface) {
GST_ERROR ("failed to get surface available");
return NULL;
}
gst_msdk_set_mfx_frame_info_from_video_info (&frame_info, vinfo);
surface->Info = frame_info;
return surface;
}
gboolean
gst_msdk_video_memory_get_surface_available (GstMemory * mem)
{
GstAllocator *allocator;
mfxFrameSurface1 *surface;
g_return_val_if_fail (mem, FALSE);
allocator = mem->allocator;
surface = gst_msdk_video_allocator_get_surface (allocator);
if (GST_IS_MSDK_VIDEO_ALLOCATOR (allocator)) {
GST_MSDK_VIDEO_MEMORY_CAST (mem)->surface = surface;
} else if (GST_IS_MSDK_DMABUF_ALLOCATOR (allocator)) {
gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (mem),
GST_MSDK_BUFFER_SURFACE, surface, NULL);
}
return surface ? TRUE : FALSE;
}
/*
* Every time releasing a gst buffer, we need to check the status of surface's lock,
* so that we could manage locked surfaces separately in the context.
* Otherwise, we put the surface to the available list.
*/
void
gst_msdk_video_memory_release_surface (GstMemory * mem)
{
mfxFrameSurface1 *surface = NULL;
GstMsdkContext *context = NULL;
mfxFrameAllocResponse *alloc_response = NULL;
g_return_if_fail (mem);
if (GST_IS_MSDK_VIDEO_ALLOCATOR (mem->allocator)) {
surface = GST_MSDK_VIDEO_MEMORY_CAST (mem)->surface;
context = GST_MSDK_VIDEO_ALLOCATOR_CAST (mem->allocator)->context;
alloc_response =
GST_MSDK_VIDEO_ALLOCATOR_CAST (mem->allocator)->alloc_response;
} else if (GST_IS_MSDK_DMABUF_ALLOCATOR (mem->allocator)) {
surface =
gst_mini_object_get_qdata (GST_MINI_OBJECT (mem),
GST_MSDK_BUFFER_SURFACE);
context = GST_MSDK_DMABUF_ALLOCATOR_CAST (mem->allocator)->context;
alloc_response =
GST_MSDK_DMABUF_ALLOCATOR_CAST (mem->allocator)->alloc_response;
} else {
return;
}
if (surface->Data.Locked > 0)
gst_msdk_context_put_surface_locked (context, alloc_response, surface);
else
gst_msdk_context_put_surface_available (context, alloc_response, surface);
if (GST_IS_MSDK_VIDEO_ALLOCATOR (mem->allocator))
GST_MSDK_VIDEO_MEMORY_CAST (mem)->surface = NULL;
else if (GST_IS_MSDK_DMABUF_ALLOCATOR (mem->allocator))
gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (mem),
GST_MSDK_BUFFER_SURFACE, NULL, NULL);
return;
}
GstMemory *
gst_msdk_video_memory_new (GstAllocator * base_allocator)
{
GstMsdkVideoAllocator *allocator;
GstVideoInfo *vip;
GstMsdkVideoMemory *mem;
g_return_val_if_fail (base_allocator, NULL);
g_return_val_if_fail (GST_IS_MSDK_VIDEO_ALLOCATOR (base_allocator), NULL);
allocator = GST_MSDK_VIDEO_ALLOCATOR_CAST (base_allocator);
mem = g_slice_new0 (GstMsdkVideoMemory);
if (!mem)
return NULL;
mem->surface = gst_msdk_video_allocator_get_surface (base_allocator);
if (!mem->surface) {
g_slice_free (GstMsdkVideoMemory, mem);
return NULL;
}
vip = &allocator->image_info;
gst_memory_init (&mem->parent_instance, 0,
base_allocator, NULL, GST_VIDEO_INFO_SIZE (vip), 0, 0,
GST_VIDEO_INFO_SIZE (vip));
return GST_MEMORY_CAST (mem);
}
gboolean
gst_video_meta_map_msdk_memory (GstVideoMeta * meta, guint plane,
GstMapInfo * info, gpointer * data, gint * stride, GstMapFlags flags)
{
gboolean ret = FALSE;
GstAllocator *allocator;
GstMsdkVideoAllocator *msdk_video_allocator;
GstMsdkVideoMemory *mem =
GST_MSDK_VIDEO_MEMORY_CAST (gst_buffer_peek_memory (meta->buffer, 0));
GstMsdkMemoryID *mem_id;
guint offset = 0;
gint pitch = 0;
guint plane_id = plane;
g_return_val_if_fail (mem, FALSE);
allocator = GST_MEMORY_CAST (mem)->allocator;
msdk_video_allocator = GST_MSDK_VIDEO_ALLOCATOR_CAST (allocator);
if (!GST_IS_MSDK_VIDEO_ALLOCATOR (allocator)) {
GST_WARNING ("The allocator is not MSDK video allocator");
return FALSE;
}
if (!mem->surface) {
GST_WARNING ("The surface is not allocated");
return FALSE;
}
if ((flags & GST_MAP_WRITE) && mem->surface && mem->surface->Data.Locked) {
GST_WARNING ("The surface in memory %p is not still available", mem);
return FALSE;
}
if (!mem->mapped) {
gst_msdk_frame_lock (msdk_video_allocator->context,
mem->surface->Data.MemId, &mem->surface->Data);
}
mem->mapped++;
mem_id = mem->surface->Data.MemId;
/* msdk doesn't support I420 format and we used YV12 internally
* So we need to swap U/V planes for mapping */
if (meta->format == GST_VIDEO_FORMAT_I420)
plane_id = plane ? (plane == 1 ? 2 : 1) : plane;
#ifndef _WIN32
offset = mem_id->image.offsets[plane_id];
pitch = mem_id->image.pitches[plane_id];
#else
/* TODO: This is just to avoid compile errors on Windows.
* Implement handling Windows-specific video-memory.
*/
offset = mem_id->offset;
pitch = mem_id->pitch;
#endif
switch (meta->format) {
case GST_VIDEO_FORMAT_BGRA:
case GST_VIDEO_FORMAT_BGRx:
*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:
case GST_VIDEO_FORMAT_Y412_LE:
*data = mem->surface->Data.U + offset;
break;
default:
*data = mem->surface->Data.Y + offset;
break;
}
*stride = pitch;
info->flags = flags;
ret = (*data != NULL);
return ret;
}
gboolean
gst_video_meta_unmap_msdk_memory (GstVideoMeta * meta, guint plane,
GstMapInfo * info)
{
GstAllocator *allocator;
GstMsdkVideoAllocator *msdk_video_allocator;
GstMsdkVideoMemory *mem =
GST_MSDK_VIDEO_MEMORY_CAST (gst_buffer_peek_memory (meta->buffer, 0));
g_return_val_if_fail (mem, FALSE);
allocator = GST_MEMORY_CAST (mem)->allocator;
msdk_video_allocator = GST_MSDK_VIDEO_ALLOCATOR_CAST (allocator);
if (mem->mapped == 1)
gst_msdk_frame_unlock (msdk_video_allocator->context,
mem->surface->Data.MemId, &mem->surface->Data);
mem->mapped--;
return TRUE;
}
static gpointer
gst_msdk_video_memory_map_full (GstMemory * base_mem, GstMapInfo * info,
gsize maxsize)
{
GstMsdkVideoMemory *const mem = GST_MSDK_VIDEO_MEMORY_CAST (base_mem);
GstAllocator *allocator = base_mem->allocator;
GstMsdkVideoAllocator *msdk_video_allocator =
GST_MSDK_VIDEO_ALLOCATOR_CAST (allocator);
g_return_val_if_fail (mem, NULL);
if (!mem->surface) {
GST_WARNING ("The surface is not allocated");
return NULL;
}
if ((info->flags & GST_MAP_WRITE) && mem->surface
&& mem->surface->Data.Locked) {
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);
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
#if (MFX_VERSION >= 1031)
case MFX_FOURCC_Y416:
return mem->surface->Data.U;
#endif
#if (MFX_VERSION >= 2004)
case MFX_FOURCC_RGBP:
return mem->surface->Data.R;
case MFX_FOURCC_BGRP:
return mem->surface->Data.B;
#endif
default:
return mem->surface->Data.Y;
}
}
static void
gst_msdk_video_memory_unmap (GstMemory * base_mem)
{
GstMsdkVideoMemory *const mem = GST_MSDK_VIDEO_MEMORY_CAST (base_mem);
GstAllocator *allocator = base_mem->allocator;
GstMsdkVideoAllocator *msdk_video_allocator =
GST_MSDK_VIDEO_ALLOCATOR_CAST (allocator);
gst_msdk_frame_unlock (msdk_video_allocator->context,
mem->surface->Data.MemId, &mem->surface->Data);
}
static GstMemory *
gst_msdk_video_memory_copy (GstMemory * base_mem, gssize offset, gssize size)
{
GstMemory *copy;
GstVideoInfo *info;
GstMsdkVideoAllocator *msdk_video_allocator;
gsize mem_size;
GstMapInfo src_map, dst_map;
/* FIXME: can we consider offset and size here ? */
copy = gst_msdk_video_memory_new (base_mem->allocator);
if (!copy) {
GST_ERROR_OBJECT (base_mem->allocator, "Failed to create new video memory");
return NULL;
}
msdk_video_allocator = GST_MSDK_VIDEO_ALLOCATOR_CAST (base_mem->allocator);
info = &msdk_video_allocator->image_info;
mem_size = GST_VIDEO_INFO_SIZE (info);
gst_memory_map (base_mem, &src_map, GST_MAP_READ);
gst_memory_map (copy, &dst_map, GST_MAP_WRITE);
memcpy (dst_map.data, src_map.data, mem_size);
gst_memory_unmap (copy, &dst_map);
gst_memory_unmap (base_mem, &src_map);
return copy;
}
/* GstMsdkVideoAllocator */
G_DEFINE_TYPE (GstMsdkVideoAllocator, gst_msdk_video_allocator,
GST_TYPE_ALLOCATOR);
static GstMemory *
gst_msdk_video_allocator_alloc (GstAllocator * allocator, gsize size,
GstAllocationParams * params)
{
return gst_msdk_video_memory_new (allocator);
}
static void
gst_msdk_video_allocator_finalize (GObject * object)
{
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);
}
static void
gst_msdk_video_allocator_free (GstAllocator * allocator, GstMemory * base_mem)
{
GstMsdkVideoMemory *const mem = GST_MSDK_VIDEO_MEMORY_CAST (base_mem);
g_slice_free (GstMsdkVideoMemory, mem);
}
static void
gst_msdk_video_allocator_class_init (GstMsdkVideoAllocatorClass * klass)
{
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
GstAllocatorClass *const allocator_class = GST_ALLOCATOR_CLASS (klass);
object_class->finalize = gst_msdk_video_allocator_finalize;
allocator_class->alloc = gst_msdk_video_allocator_alloc;
allocator_class->free = gst_msdk_video_allocator_free;
}
static void
gst_msdk_video_allocator_init (GstMsdkVideoAllocator * allocator)
{
GstAllocator *const base_allocator = GST_ALLOCATOR_CAST (allocator);
base_allocator->mem_type = GST_MSDK_VIDEO_MEMORY_NAME;
base_allocator->mem_map_full = gst_msdk_video_memory_map_full;
base_allocator->mem_unmap = gst_msdk_video_memory_unmap;
base_allocator->mem_copy = gst_msdk_video_memory_copy;
GST_OBJECT_FLAG_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
}
GstAllocator *
gst_msdk_video_allocator_new (GstMsdkContext * context,
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->mfx_response = *alloc_resp;
allocator->alloc_response = &allocator->mfx_response;
return GST_ALLOCATOR_CAST (allocator);
}
/* GstMsdkDmaBufMemory */
GstMemory *
gst_msdk_dmabuf_memory_new (GstAllocator * base_allocator)
{
#ifndef _WIN32
mfxFrameSurface1 *surface;
g_return_val_if_fail (base_allocator, NULL);
g_return_val_if_fail (GST_IS_MSDK_DMABUF_ALLOCATOR (base_allocator), NULL);
surface = gst_msdk_video_allocator_get_surface (base_allocator);
if (!surface)
return NULL;
return gst_msdk_dmabuf_memory_new_with_surface (base_allocator, surface);
#else
return NULL;
#endif
}
GstMemory *
gst_msdk_dmabuf_memory_new_with_surface (GstAllocator * allocator,
mfxFrameSurface1 * surface)
{
#ifndef _WIN32
GstMemory *mem;
GstMsdkMemoryID *mem_id;
gint fd;
gsize size;
g_return_val_if_fail (allocator, NULL);
g_return_val_if_fail (GST_IS_MSDK_DMABUF_ALLOCATOR (allocator), NULL);
mem_id = surface->Data.MemId;
g_assert (mem_id->desc.num_objects == 1);
fd = mem_id->desc.objects[0].fd;
size = mem_id->desc.objects[0].size;
if (fd < 0) {
GST_ERROR ("Failed to get dmabuf handle");
return NULL;
}
mem = gst_fd_allocator_alloc (allocator, fd, size,
GST_FD_MEMORY_FLAG_DONT_CLOSE);
if (!mem) {
GST_ERROR ("failed ! dmabuf fd: %d", fd);
return NULL;
}
gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (mem),
GST_MSDK_BUFFER_SURFACE, surface, NULL);
return mem;
#else
return NULL;
#endif
}
/* GstMsdkDmaBufAllocator */
G_DEFINE_TYPE (GstMsdkDmaBufAllocator, gst_msdk_dmabuf_allocator,
GST_TYPE_DMABUF_ALLOCATOR);
static void
gst_msdk_dmabuf_allocator_finalize (GObject * object)
{
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);
}
static void
gst_msdk_dmabuf_allocator_class_init (GstMsdkDmaBufAllocatorClass * klass)
{
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gst_msdk_dmabuf_allocator_finalize;
}
static void
gst_msdk_dmabuf_allocator_init (GstMsdkDmaBufAllocator * allocator)
{
GstAllocator *const base_allocator = GST_ALLOCATOR_CAST (allocator);
base_allocator->mem_type = GST_MSDK_DMABUF_MEMORY_NAME;
}
GstAllocator *
gst_msdk_dmabuf_allocator_new (GstMsdkContext * context,
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->mfx_response = *alloc_resp;
allocator->alloc_response = &allocator->mfx_response;
return GST_ALLOCATOR_CAST (allocator);
}

View file

@ -1,197 +0,0 @@
/* GStreamer Intel MSDK plugin
* Copyright (c) 2018, Intel Corporation
* Copyright (c) 2018, Igalia S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGDECE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef GST_MSDK_VIDEO_MEMORY_H
#define GST_MSDK_VIDEO_MEMORY_H
#include "msdk.h"
#include "gstmsdkcontext.h"
#include "gstmsdkallocator.h"
#include <gst/allocators/allocators.h>
G_BEGIN_DECLS
typedef struct _GstMsdkVideoMemory GstMsdkVideoMemory;
typedef struct _GstMsdkVideoAllocator GstMsdkVideoAllocator;
typedef struct _GstMsdkVideoAllocatorClass GstMsdkVideoAllocatorClass;
typedef struct _GstMsdkDmaBufAllocator GstMsdkDmaBufAllocator;
typedef struct _GstMsdkDmaBufAllocatorClass GstMsdkDmaBufAllocatorClass;
/* ---------------------------------------------------------------------*/
/* GstMsdkVideoMemory */
/* ---------------------------------------------------------------------*/
#define GST_MSDK_VIDEO_MEMORY_CAST(mem) \
((GstMsdkVideoMemory *) (mem))
#define GST_IS_MSDK_VIDEO_MEMORY(mem) \
((mem) && (mem)->allocator && GST_IS_MSDK_VIDEO_ALLOCATOR((mem)->allocator))
#define GST_MSDK_VIDEO_MEMORY_NAME "GstMsdkVideoMemory"
/*
* GstMsdkVideoMemory:
*
* A MSDK memory object holder, including mfxFrameSurface,
* video info of the surface.
*/
struct _GstMsdkVideoMemory
{
GstMemory parent_instance;
mfxFrameSurface1 *surface;
guint mapped;
};
GstMemory *
gst_msdk_video_memory_new (GstAllocator * allocator);
gboolean
gst_msdk_video_memory_get_surface_available (GstMemory * mem);
void
gst_msdk_video_memory_release_surface (GstMemory * mem);
gboolean
gst_video_meta_map_msdk_memory (GstVideoMeta * meta, guint plane,
GstMapInfo * info, gpointer * data, gint * stride, GstMapFlags flags);
gboolean
gst_video_meta_unmap_msdk_memory (GstVideoMeta * meta, guint plane,
GstMapInfo * info);
/* ---------------------------------------------------------------------*/
/* GstMsdkVideoAllocator */
/* ---------------------------------------------------------------------*/
#define GST_MSDK_VIDEO_ALLOCATOR_CAST(allocator) \
((GstMsdkVideoAllocator *) (allocator))
#define GST_TYPE_MSDK_VIDEO_ALLOCATOR \
(gst_msdk_video_allocator_get_type ())
#define GST_MSDK_VIDEO_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MSDK_VIDEO_ALLOCATOR, \
GstMsdkVideoAllocator))
#define GST_IS_MSDK_VIDEO_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MSDK_VIDEO_ALLOCATOR))
/*
* GstMsdkVideoAllocator:
*
* A MSDK video memory allocator object.
*/
struct _GstMsdkVideoAllocator
{
GstAllocator parent_instance;
GstMsdkContext *context;
GstVideoInfo image_info;
mfxFrameAllocResponse mfx_response;
mfxFrameAllocResponse *alloc_response;
};
/*
* GstMsdkVideoAllocatorClass:
*
* A MSDK video memory allocator class.
*/
struct _GstMsdkVideoAllocatorClass
{
GstAllocatorClass parent_class;
};
GType gst_msdk_video_allocator_get_type (void);
GstAllocator * gst_msdk_video_allocator_new (GstMsdkContext * context,
GstVideoInfo *image_info, mfxFrameAllocResponse * alloc_resp);
/* ---------------------------------------------------------------------*/
/* GstMsdkDmaBufMemory */
/* ---------------------------------------------------------------------*/
#define GST_MSDK_DMABUF_MEMORY_NAME "GstMsdkDmaBufMemory"
GstMemory *
gst_msdk_dmabuf_memory_new (GstAllocator * allocator);
GstMemory *
gst_msdk_dmabuf_memory_new_with_surface (GstAllocator * base_allocator, mfxFrameSurface1 * surface);
/* ---------------------------------------------------------------------*/
/* GstMsdkDmaBufAllocator */
/* ---------------------------------------------------------------------*/
#define GST_MSDK_DMABUF_ALLOCATOR_CAST(allocator) \
((GstMsdkDmaBufAllocator *) (allocator))
#define GST_TYPE_MSDK_DMABUF_ALLOCATOR \
(gst_msdk_dmabuf_allocator_get_type ())
#define GST_MSDK_DMABUF_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MSDK_DMABUF_ALLOCATOR, \
GstMsdkDmaBufAllocator))
#define GST_IS_MSDK_DMABUF_ALLOCATOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MSDK_DMABUF_ALLOCATOR))
/*
* GstMsdkDmaBufAllocator:
*
* A MSDK DMABuf memory allocator object.
*/
struct _GstMsdkDmaBufAllocator
{
GstDmaBufAllocator parent_instance;
GstMsdkContext *context;
GstVideoInfo image_info;
mfxFrameAllocResponse mfx_response;
mfxFrameAllocResponse *alloc_response;
};
/*
* GstMsdkDmaBufAllocatorClass:
*
* A MSDK DMABuf memory allocator class.
*/
struct _GstMsdkDmaBufAllocatorClass
{
GstDmaBufAllocatorClass parent_class;
};
GType gst_msdk_dmabuf_allocator_get_type (void);
GstAllocator * gst_msdk_dmabuf_allocator_new (GstMsdkContext * context,
GstVideoInfo *image_info, mfxFrameAllocResponse * alloc_resp);
G_END_DECLS
#endif /* GST_MSDK_VIDEO_MEMORY_H */

View file

@ -52,7 +52,6 @@
#endif
#include "gstmsdkvp9dec.h"
#include "gstmsdkvideomemory.h"
GST_DEBUG_CATEGORY_EXTERN (gst_msdkvp9dec_debug);
#define GST_CAT_DEFAULT gst_msdkvp9dec_debug

View file

@ -54,11 +54,9 @@
#include <stdlib.h>
#include "gstmsdkvpp.h"
#include "gstmsdkbufferpool.h"
#include "gstmsdkvideomemory.h"
#include "gstmsdksystemmemory.h"
#include "gstmsdkcontextutil.h"
#include "gstmsdkvpputil.h"
#include "gstmsdkallocator.h"
#define EXT_FORMATS ""
@ -565,13 +563,6 @@ gst_msdkvpp_create_buffer_pool (GstMsdkVPP * thiz, GstPadDirection direction,
goto error_no_pool;
config = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool));
if (thiz->use_video_memory) {
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_MSDK_USE_VIDEO_MEMORY);
if (use_dmabuf)
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_MSDK_USE_DMABUF);
}
gst_buffer_pool_config_set_params (config, caps,
GST_VIDEO_INFO_SIZE (&info), min_num_buffers, 0);

View file

@ -1,7 +1,6 @@
msdk_sources = [
'gstmsdk.c',
'gstmsdkallocator.c',
'gstmsdkbufferpool.c',
'gstmsdkcontext.c',
'gstmsdkcontextutil.c',
'gstmsdkdec.c',
@ -15,9 +14,7 @@ msdk_sources = [
'gstmsdkmjpegenc.c',
'gstmsdkmpeg2dec.c',
'gstmsdkmpeg2enc.c',
'gstmsdksystemmemory.c',
'gstmsdkvc1dec.c',
'gstmsdkvideomemory.c',
'gstmsdkvp8dec.c',
'gstmsdkvpp.c',
'gstmsdkvpputil.c',

View file

@ -30,8 +30,7 @@
*/
#include "msdk.h"
#include "gstmsdkvideomemory.h"
#include "gstmsdksystemmemory.h"
#include "gstmsdkcontext.h"
GST_DEBUG_CATEGORY_EXTERN (gst_msdk_debug);
#define GST_CAT_DEFAULT gst_msdk_debug
@ -549,26 +548,6 @@ gst_msdk_is_va_mem (GstMemory * mem)
return g_str_equal (allocator->mem_type, "VAMemory");
}
mfxFrameSurface1 *
gst_msdk_get_surface_from_buffer (GstBuffer * buf)
{
GstAllocator *allocator;
GstMemory *mem = gst_buffer_peek_memory (buf, 0);
allocator = GST_MEMORY_CAST (mem)->allocator;
if (GST_IS_MSDK_VIDEO_ALLOCATOR (allocator))
return GST_MSDK_VIDEO_MEMORY_CAST (mem)->surface;
else if (GST_IS_MSDK_SYSTEM_ALLOCATOR (allocator))
return GST_MSDK_SYSTEM_MEMORY_CAST (mem)->surface;
else if (GST_IS_MSDK_DMABUF_ALLOCATOR (allocator)) {
return gst_mini_object_get_qdata (GST_MINI_OBJECT (mem),
g_quark_from_static_string ("GstMsdkBufferSurface"));
}
return NULL;
}
GstVideoFormat
gst_msdk_get_video_format_from_mfx_fourcc (mfxU32 fourcc)
{

View file

@ -103,7 +103,6 @@ void GstMFXUnload (mfxLoader loader);
#endif
typedef struct _MsdkSession MsdkSession;
typedef struct _GstMsdkSurface GstMsdkSurface;
struct _MsdkSession
{
@ -135,9 +134,6 @@ void gst_msdk_set_mfx_frame_info_from_video_info (mfxFrameInfo * mfx_info,
gboolean
gst_msdk_is_va_mem (GstMemory * mem);
mfxFrameSurface1 *
gst_msdk_get_surface_from_buffer (GstBuffer * buf);
GstVideoFormat
gst_msdk_get_video_format_from_mfx_fourcc (mfxU32 fourcc);