video-info-dma: add gst_video_info_dma_drm_from_video_info()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4680>
This commit is contained in:
Víctor Manuel Jáquez Leal 2023-05-26 10:41:54 +02:00 committed by GStreamer Marge Bot
parent af7b5023bd
commit 1477ed1ae5
4 changed files with 102 additions and 0 deletions

View file

@ -11411,6 +11411,29 @@ it before calling this function.</doc>
</parameter>
</parameters>
</function>
<function name="from_video_info" c:identifier="gst_video_info_dma_drm_from_video_info" version="1.24">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">Fills @drm_info if @info's format has a valid drm format and @modifier is also
valid</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.h"/>
<return-value transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">%TRUE if @drm_info is filled correctly.</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="drm_info" direction="out" caller-allocates="1" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">#GstVideoInfoDmaDrm</doc>
<type name="VideoInfoDmaDrm" c:type="GstVideoInfoDmaDrm*"/>
</parameter>
<parameter name="info" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">a #GstVideoInfo</doc>
<type name="VideoInfo" c:type="const GstVideoInfo*"/>
</parameter>
<parameter name="modifier" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">the associated modifier value.</doc>
<type name="guint64" c:type="guint64"/>
</parameter>
</parameters>
</function>
<function name="init" c:identifier="gst_video_info_dma_drm_init" version="1.24">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">Initialize @drm_info with default values.</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.h"/>
@ -18548,6 +18571,29 @@ it before calling this function.</doc>
</parameter>
</parameters>
</function>
<function name="video_info_dma_drm_from_video_info" c:identifier="gst_video_info_dma_drm_from_video_info" moved-to="VideoInfoDmaDrm.from_video_info" version="1.24">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">Fills @drm_info if @info's format has a valid drm format and @modifier is also
valid</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.h"/>
<return-value transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">%TRUE if @drm_info is filled correctly.</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="drm_info" direction="out" caller-allocates="1" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">#GstVideoInfoDmaDrm</doc>
<type name="VideoInfoDmaDrm" c:type="GstVideoInfoDmaDrm*"/>
</parameter>
<parameter name="info" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">a #GstVideoInfo</doc>
<type name="VideoInfo" c:type="const GstVideoInfo*"/>
</parameter>
<parameter name="modifier" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">the associated modifier value.</doc>
<type name="guint64" c:type="guint64"/>
</parameter>
</parameters>
</function>
<function name="video_info_dma_drm_init" c:identifier="gst_video_info_dma_drm_init" moved-to="VideoInfoDmaDrm.init" version="1.24">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.c">Initialize @drm_info with default values.</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/video/video-info-dma.h"/>

View file

@ -398,6 +398,50 @@ gst_video_info_dma_drm_new_from_caps (const GstCaps * caps)
}
}
/**
* gst_video_info_dma_drm_from_video_info:
* @drm_info: (out caller-allocates): #GstVideoInfoDmaDrm
* @info: a #GstVideoInfo
* @modifier: the associated modifier value.
*
* Fills @drm_info if @info's format has a valid drm format and @modifier is also
* valid
*
* Returns: %TRUE if @drm_info is filled correctly.
*
* Since: 1.24
*/
gboolean
gst_video_info_dma_drm_from_video_info (GstVideoInfoDmaDrm * drm_info,
const GstVideoInfo * info, guint64 modifier)
{
GstVideoFormat format;
guint32 fourcc;
g_return_val_if_fail (drm_info != NULL, FALSE);
g_return_val_if_fail (info != NULL, FALSE);
if (modifier == DRM_FORMAT_MOD_INVALID)
return FALSE;
format = GST_VIDEO_INFO_FORMAT (info);
fourcc = gst_video_dma_drm_fourcc_from_format (format);
if (fourcc == DRM_FORMAT_INVALID)
return FALSE;
drm_info->vinfo = *info;
drm_info->drm_fourcc = fourcc;
drm_info->drm_modifier = modifier;
/* no need to change format to GST_VIDEO_INFO_ENCODED since its modifier is
* linear */
if (modifier == DRM_FORMAT_MOD_LINEAR)
return TRUE;
return gst_video_info_set_interlaced_format (&drm_info->vinfo,
GST_VIDEO_FORMAT_ENCODED, GST_VIDEO_INFO_INTERLACE_MODE (info),
GST_VIDEO_INFO_WIDTH (info), GST_VIDEO_INFO_HEIGHT (info));
}
/**
* gst_video_dma_drm_fourcc_from_string:
* @format_str: a drm format string

View file

@ -69,6 +69,12 @@ GstCaps * gst_video_info_dma_drm_to_caps (const GstVideoInfoDma
GST_VIDEO_API
gboolean gst_video_info_dma_drm_from_caps (GstVideoInfoDmaDrm * drm_info,
const GstCaps * caps);
GST_VIDEO_API
gboolean gst_video_info_dma_drm_from_video_info
(GstVideoInfoDmaDrm * drm_info,
const GstVideoInfo * info,
guint64 modifier);
GST_VIDEO_API
GstVideoInfoDmaDrm * gst_video_info_dma_drm_new_from_caps (const GstCaps * caps);

View file

@ -4160,6 +4160,12 @@ GST_START_TEST (test_info_dma_drm)
gst_caps_unref (caps);
gst_caps_unref (ncaps);
fail_unless (gst_video_info_dma_drm_from_video_info (&info, &vinfo, 0));
fail_unless (GST_VIDEO_INFO_FORMAT (&info.vinfo) == GST_VIDEO_FORMAT_NV12);
fail_unless (gst_video_info_dma_drm_from_video_info (&info, &vinfo,
0x100000000000002));
fail_unless (GST_VIDEO_INFO_FORMAT (&info.vinfo) == GST_VIDEO_FORMAT_ENCODED);
}
GST_END_TEST;