mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
msdk: Move all _gst_caps_has_feature to gstmsdkcaps.c
_gst_caps_has_feature is used by all msdk elements, so move it to gstmsdkcaps.c Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4177>
This commit is contained in:
parent
5ac9cf2b60
commit
dafb801a18
8 changed files with 107 additions and 60 deletions
49
subprojects/gst-plugins-bad/sys/msdk/gstmsdkcaps.c
Normal file
49
subprojects/gst-plugins-bad/sys/msdk/gstmsdkcaps.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* GStreamer Intel MSDK plugin
|
||||
* Copyright (c) 2023, Intel Corporation.
|
||||
* 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 NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gstmsdkcaps.h"
|
||||
|
||||
gboolean
|
||||
gst_msdkcaps_has_feature (const GstCaps * caps, const gchar * feature)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
||||
GstCapsFeatures *const features = gst_caps_get_features (caps, i);
|
||||
/* Skip ANY features, we need an exact match for correct evaluation */
|
||||
if (gst_caps_features_is_any (features))
|
||||
continue;
|
||||
if (gst_caps_features_contains (features, feature))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
46
subprojects/gst-plugins-bad/sys/msdk/gstmsdkcaps.h
Normal file
46
subprojects/gst-plugins-bad/sys/msdk/gstmsdkcaps.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* GStreamer Intel MSDK plugin
|
||||
* Copyright (c) 2023, Intel Corporation.
|
||||
* 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 NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __GST_MSDKCAPS_H__
|
||||
#define __GST_MSDKCAPS_H__
|
||||
|
||||
#include "msdk.h"
|
||||
#include <mfxjpeg.h>
|
||||
#include <mfxvp8.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean
|
||||
gst_msdkcaps_has_feature (const GstCaps * caps, const gchar * feature);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_MSDKCAPS_H__ */
|
|
@ -514,24 +514,6 @@ failed:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
_gst_caps_has_feature (const GstCaps * caps, const gchar * feature)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
||||
GstCapsFeatures *const features = gst_caps_get_features (caps, i);
|
||||
/* Skip ANY features, we need an exact match for correct evaluation */
|
||||
if (gst_caps_features_is_any (features))
|
||||
continue;
|
||||
if (gst_caps_features_contains (features, feature))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pad_accept_memory (GstMsdkDec * thiz, const gchar * mem_type, GstCaps * filter)
|
||||
{
|
||||
|
@ -553,7 +535,7 @@ pad_accept_memory (GstMsdkDec * thiz, const gchar * mem_type, GstCaps * filter)
|
|||
if (gst_caps_is_any (out_caps) || gst_caps_is_empty (out_caps))
|
||||
goto done;
|
||||
|
||||
if (_gst_caps_has_feature (out_caps, mem_type))
|
||||
if (gst_msdkcaps_has_feature (out_caps, mem_type))
|
||||
ret = TRUE;
|
||||
done:
|
||||
if (caps)
|
||||
|
@ -1819,7 +1801,7 @@ gst_msdkdec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
|
|||
/* this will get updated with msdk requirement */
|
||||
thiz->min_prealloc_buffers = min_buffers;
|
||||
|
||||
if (_gst_caps_has_feature (pool_caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
||||
if (gst_msdkcaps_has_feature (pool_caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
||||
thiz->use_dmabuf = TRUE;
|
||||
}
|
||||
/* Decoder always use its own pool. So we create a pool if msdk APIs
|
||||
|
@ -1915,7 +1897,7 @@ gst_msdkdec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
|
|||
min_buffers = thiz->min_prealloc_buffers;
|
||||
|
||||
if (!has_videometa && !thiz->ds_has_known_allocator
|
||||
&& _gst_caps_has_feature (pool_caps,
|
||||
&& gst_msdkcaps_has_feature (pool_caps,
|
||||
GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY)) {
|
||||
/* We need to create other pool with system memory for copy use under conditions:
|
||||
* (1) downstream has no videometa; (2) downstream allocator is unknown;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "gstmsdkcontext.h"
|
||||
#include "msdk-enums.h"
|
||||
#include "gstmsdkdecproputil.h"
|
||||
#include "gstmsdkcaps.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
@ -1456,24 +1456,6 @@ error_pool_config:
|
|||
}
|
||||
}
|
||||
|
||||
/* Fixme: Common routine used by all msdk elements, should be
|
||||
* moved to a common util file */
|
||||
static gboolean
|
||||
_gst_caps_has_feature (const GstCaps * caps, const gchar * feature)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
||||
GstCapsFeatures *const features = gst_caps_get_features (caps, i);
|
||||
/* Skip ANY features, we need an exact match for correct evaluation */
|
||||
if (gst_caps_features_is_any (features))
|
||||
continue;
|
||||
if (gst_caps_features_contains (features, feature))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sinkpad_can_dmabuf (GstMsdkEnc * thiz)
|
||||
{
|
||||
|
@ -1491,7 +1473,7 @@ sinkpad_can_dmabuf (GstMsdkEnc * thiz)
|
|||
|| allowed_caps == caps)
|
||||
goto done;
|
||||
|
||||
if (_gst_caps_has_feature (allowed_caps, GST_CAPS_FEATURE_MEMORY_DMABUF))
|
||||
if (gst_msdkcaps_has_feature (allowed_caps, GST_CAPS_FEATURE_MEMORY_DMABUF))
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
|
@ -2053,7 +2035,7 @@ gst_msdkenc_propose_allocation (GstVideoEncoder * encoder, GstQuery * query)
|
|||
|
||||
/* if upstream allocation query supports dmabuf-capsfeatures,
|
||||
* we do allocate dmabuf backed memory */
|
||||
if (_gst_caps_has_feature (caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
||||
if (gst_msdkcaps_has_feature (caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
||||
GST_INFO_OBJECT (thiz, "MSDK VPP srcpad uses DMABuf memory");
|
||||
thiz->use_dmabuf = TRUE;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "msdk.h"
|
||||
#include "msdk-enums.h"
|
||||
#include "gstmsdkcontext.h"
|
||||
#include "gstmsdkcaps.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "gstmsdkvpp.h"
|
||||
#include "gstmsdkcaps.h"
|
||||
#include "gstmsdkcontextutil.h"
|
||||
#include "gstmsdkvpputil.h"
|
||||
#include "gstmsdkallocator.h"
|
||||
|
@ -598,22 +599,6 @@ error_pool_config:
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_gst_caps_has_feature (const GstCaps * caps, const gchar * feature)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
||||
GstCapsFeatures *const features = gst_caps_get_features (caps, i);
|
||||
/* Skip ANY features, we need an exact match for correct evaluation */
|
||||
if (gst_caps_features_is_any (features))
|
||||
continue;
|
||||
if (gst_caps_features_contains (features, feature))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GstBufferPool *
|
||||
create_src_pool (GstMsdkVPP * thiz, GstQuery * query, GstCaps * caps)
|
||||
{
|
||||
|
@ -688,7 +673,7 @@ gst_msdkvpp_decide_allocation (GstBaseTransform * trans, GstQuery * query)
|
|||
}
|
||||
/* We allocate the memory of type that downstream allocation requests */
|
||||
#ifndef _WIN32
|
||||
if (_gst_caps_has_feature (caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
||||
if (gst_msdkcaps_has_feature (caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
||||
GST_INFO_OBJECT (thiz, "MSDK VPP srcpad uses DMABuf memory");
|
||||
thiz->use_srcpad_dmabuf = TRUE;
|
||||
}
|
||||
|
@ -740,7 +725,7 @@ gst_msdkvpp_propose_allocation (GstBaseTransform * trans,
|
|||
|
||||
/* if upstream allocation query supports dmabuf-capsfeatures,
|
||||
* we do allocate dmabuf backed memory */
|
||||
if (_gst_caps_has_feature (caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
||||
if (gst_msdkcaps_has_feature (caps, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
|
||||
GST_INFO_OBJECT (thiz, "MSDK VPP srcpad uses DMABuf memory");
|
||||
thiz->use_sinkpad_dmabuf = TRUE;
|
||||
}
|
||||
|
@ -1412,7 +1397,7 @@ pad_accept_memory (GstMsdkVPP * thiz, const gchar * mem_type,
|
|||
|| out_caps == caps)
|
||||
goto done;
|
||||
|
||||
if (_gst_caps_has_feature (out_caps, mem_type))
|
||||
if (gst_msdkcaps_has_feature (out_caps, mem_type))
|
||||
ret = TRUE;
|
||||
done:
|
||||
if (caps)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
msdk_sources = [
|
||||
'gstmsdk.c',
|
||||
'gstmsdkallocator.c',
|
||||
'gstmsdkcaps.c',
|
||||
'gstmsdkcontext.c',
|
||||
'gstmsdkcontextutil.c',
|
||||
'gstmsdkdec.c',
|
||||
|
|
Loading…
Reference in a new issue