mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
image: add gst_vaapi_image_format_from_video() helper.
This commit is contained in:
parent
efcdec08fb
commit
55738da35b
5 changed files with 36 additions and 20 deletions
|
@ -377,6 +377,7 @@ gst_vaapi_image_format_is_yuv
|
||||||
gst_vaapi_image_format
|
gst_vaapi_image_format
|
||||||
gst_vaapi_image_format_from_caps
|
gst_vaapi_image_format_from_caps
|
||||||
gst_vaapi_image_format_from_fourcc
|
gst_vaapi_image_format_from_fourcc
|
||||||
|
gst_vaapi_image_format_from_video
|
||||||
gst_vaapi_image_format_get_va_format
|
gst_vaapi_image_format_get_va_format
|
||||||
gst_vaapi_image_format_get_caps
|
gst_vaapi_image_format_get_caps
|
||||||
gst_vaapi_image_format_get_score
|
gst_vaapi_image_format_get_score
|
||||||
|
|
|
@ -143,6 +143,7 @@ libgstvaapi_@GST_MAJORMINOR@_la_CFLAGS = \
|
||||||
-I$(top_srcdir)/gst-libs \
|
-I$(top_srcdir)/gst-libs \
|
||||||
$(GST_BASE_CFLAGS) \
|
$(GST_BASE_CFLAGS) \
|
||||||
$(GST_BASEVIDEO_CFLAGS) \
|
$(GST_BASEVIDEO_CFLAGS) \
|
||||||
|
$(GST_VIDEO_CFLAGS) \
|
||||||
$(GST_CFLAGS) \
|
$(GST_CFLAGS) \
|
||||||
$(LIBAVCODEC_CFLAGS) \
|
$(LIBAVCODEC_CFLAGS) \
|
||||||
$(LIBVA_CFLAGS) \
|
$(LIBVA_CFLAGS) \
|
||||||
|
|
|
@ -233,6 +233,35 @@ gst_vaapi_image_format_from_fourcc(guint32 fourcc)
|
||||||
return (GstVaapiImageFormat)fourcc;
|
return (GstVaapiImageFormat)fourcc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_image_format_from_video:
|
||||||
|
* @format: a #GstVideoFormat
|
||||||
|
*
|
||||||
|
* Converts a #GstVideoFormat into the corresponding
|
||||||
|
* #GstVaapiImageFormat. If the image format cannot be represented by
|
||||||
|
* #GstVaapiImageFormat, then zero is returned.
|
||||||
|
*
|
||||||
|
* Return value: the #GstVaapiImageFormat describing the video format
|
||||||
|
*/
|
||||||
|
GstVaapiImageFormat
|
||||||
|
gst_vaapi_image_format_from_video(GstVideoFormat format)
|
||||||
|
{
|
||||||
|
GstVaapiImageFormat va_format;
|
||||||
|
|
||||||
|
switch (format) {
|
||||||
|
case GST_VIDEO_FORMAT_NV12: va_format = GST_VAAPI_IMAGE_NV12; break;
|
||||||
|
case GST_VIDEO_FORMAT_YV12: va_format = GST_VAAPI_IMAGE_YV12; break;
|
||||||
|
case GST_VIDEO_FORMAT_I420: va_format = GST_VAAPI_IMAGE_I420; break;
|
||||||
|
case GST_VIDEO_FORMAT_AYUV: va_format = GST_VAAPI_IMAGE_AYUV; break;
|
||||||
|
case GST_VIDEO_FORMAT_ARGB: va_format = GST_VAAPI_IMAGE_ARGB; break;
|
||||||
|
case GST_VIDEO_FORMAT_RGBA: va_format = GST_VAAPI_IMAGE_RGBA; break;
|
||||||
|
case GST_VIDEO_FORMAT_ABGR: va_format = GST_VAAPI_IMAGE_ABGR; break;
|
||||||
|
case GST_VIDEO_FORMAT_BGRA: va_format = GST_VAAPI_IMAGE_BGRA; break;
|
||||||
|
default: va_format = (GstVaapiImageFormat)0; break;
|
||||||
|
}
|
||||||
|
return va_format;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_vaapi_image_format_get_va_format:
|
* gst_vaapi_image_format_get_va_format:
|
||||||
* @format: a #GstVaapiImageFormat
|
* @format: a #GstVaapiImageFormat
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#define GST_VAAPI_IMAGE_FORMAT_H
|
#define GST_VAAPI_IMAGE_FORMAT_H
|
||||||
|
|
||||||
#include <gst/gstvalue.h>
|
#include <gst/gstvalue.h>
|
||||||
|
#include <gst/video/video.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -75,6 +76,9 @@ gst_vaapi_image_format_from_caps(GstCaps *caps);
|
||||||
GstVaapiImageFormat
|
GstVaapiImageFormat
|
||||||
gst_vaapi_image_format_from_fourcc(guint32 fourcc);
|
gst_vaapi_image_format_from_fourcc(guint32 fourcc);
|
||||||
|
|
||||||
|
GstVaapiImageFormat
|
||||||
|
gst_vaapi_image_format_from_video(GstVideoFormat format);
|
||||||
|
|
||||||
const VAImageFormat *
|
const VAImageFormat *
|
||||||
gst_vaapi_image_format_get_va_format(GstVaapiImageFormat format);
|
gst_vaapi_image_format_get_va_format(GstVaapiImageFormat format);
|
||||||
|
|
||||||
|
|
|
@ -542,25 +542,6 @@ gst_vaapiconvert_ensure_surface_pool(GstVaapiConvert *convert, GstCaps *caps)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstVaapiImageFormat
|
|
||||||
gst_video_format_to_vaapi_image_format(GstVideoFormat vformat)
|
|
||||||
{
|
|
||||||
GstVaapiImageFormat vaformat;
|
|
||||||
|
|
||||||
switch (vformat) {
|
|
||||||
case GST_VIDEO_FORMAT_NV12: vaformat = GST_VAAPI_IMAGE_NV12; break;
|
|
||||||
case GST_VIDEO_FORMAT_YV12: vaformat = GST_VAAPI_IMAGE_YV12; break;
|
|
||||||
case GST_VIDEO_FORMAT_I420: vaformat = GST_VAAPI_IMAGE_I420; break;
|
|
||||||
case GST_VIDEO_FORMAT_AYUV: vaformat = GST_VAAPI_IMAGE_AYUV; break;
|
|
||||||
case GST_VIDEO_FORMAT_ARGB: vaformat = GST_VAAPI_IMAGE_ARGB; break;
|
|
||||||
case GST_VIDEO_FORMAT_RGBA: vaformat = GST_VAAPI_IMAGE_RGBA; break;
|
|
||||||
case GST_VIDEO_FORMAT_ABGR: vaformat = GST_VAAPI_IMAGE_ABGR; break;
|
|
||||||
case GST_VIDEO_FORMAT_BGRA: vaformat = GST_VAAPI_IMAGE_BGRA; break;
|
|
||||||
default: vaformat = (GstVaapiImageFormat)0; break;
|
|
||||||
}
|
|
||||||
return vaformat;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapiconvert_ensure_direct_rendering_caps(
|
gst_vaapiconvert_ensure_direct_rendering_caps(
|
||||||
GstVaapiConvert *convert,
|
GstVaapiConvert *convert,
|
||||||
|
@ -592,7 +573,7 @@ gst_vaapiconvert_ensure_direct_rendering_caps(
|
||||||
return;
|
return;
|
||||||
if (!gst_video_format_is_yuv(vformat))
|
if (!gst_video_format_is_yuv(vformat))
|
||||||
return;
|
return;
|
||||||
vaformat = gst_video_format_to_vaapi_image_format(vformat);
|
vaformat = gst_vaapi_image_format_from_video(vformat);
|
||||||
if (!vaformat)
|
if (!vaformat)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue