summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2017-04-04 14:21:43 +0200
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2017-04-06 22:00:05 +0200
commitdb7268117d804a54f8be60c1046b9969ac112950 (patch)
treec5835933c4a80871d5de72b9f6eac3b4f61781d8
parent914a4712d9fc34966b22256f993899d5b581a3a6 (diff)
libs: encoder: initialize chroma_type
Instead of initialize the chroma_type with a undefined value, which will be converted to GST_VAAPI_CHROMA_TYPE_YUV420 by GstVaapiContext, this patch queries the VA config, given the received GstVaapiContextInfo's parameters, and gets the first response. In order to get the GstVaapiChromaType value, also it was needed to add a new utility function: to_GstVaapiChromaType(), which, given a VA_RT_FORMAT_* will return the associated GstVaapiChromaType. https://bugzilla.gnome.org/show_bug.cgi?id=771291
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder.c16
-rw-r--r--gst-libs/gst/vaapi/gstvaapiutils.c50
-rw-r--r--gst-libs/gst/vaapi/gstvaapiutils.h4
3 files changed, 70 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c
index 2989ff80..a1ec7913 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder.c
@@ -588,6 +588,21 @@ unsupported:
}
}
+static guint
+get_default_chroma_type (GstVaapiEncoder * encoder,
+ const GstVaapiContextInfo * cip)
+{
+ guint value;
+
+ if (!gst_vaapi_get_config_attribute (encoder->display,
+ gst_vaapi_profile_get_va_profile (cip->profile),
+ gst_vaapi_entrypoint_get_va_entrypoint (cip->entrypoint),
+ VAConfigAttribRTFormat, &value))
+ return 0;
+
+ return to_GstVaapiChromaType (value);
+}
+
static void
init_context_info (GstVaapiEncoder * encoder)
{
@@ -603,6 +618,7 @@ init_context_info (GstVaapiEncoder * encoder)
if (cip->entrypoint != GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP)
cip->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
}
+ cip->chroma_type = get_default_chroma_type (encoder, cip);
cip->width = 0;
cip->height = 0;
cip->ref_frames = encoder->num_ref_frames;
diff --git a/gst-libs/gst/vaapi/gstvaapiutils.c b/gst-libs/gst/vaapi/gstvaapiutils.c
index d583ab45..0ed1efe1 100644
--- a/gst-libs/gst/vaapi/gstvaapiutils.c
+++ b/gst-libs/gst/vaapi/gstvaapiutils.c
@@ -316,6 +316,56 @@ string_of_VARateControl (guint rate_control)
}
/**
+ * to_GstVaapiChromaType:
+ * @va_rt_format: the value of VAConfigAttribRTFormat
+ *
+ * Converts the VA_RT_FORMAT_* to #GstVaapiChromaType
+ *
+ * Returns: the #GstVaapiChromaType associated to @va_rt_format or
+ * zero.
+ **/
+guint
+to_GstVaapiChromaType (guint va_rt_format)
+{
+ guint chroma_type;
+
+ switch (va_rt_format) {
+ case VA_RT_FORMAT_YUV420:
+ chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
+ break;
+ case VA_RT_FORMAT_YUV422:
+ chroma_type = GST_VAAPI_CHROMA_TYPE_YUV422;
+ break;
+ case VA_RT_FORMAT_YUV444:
+ chroma_type = GST_VAAPI_CHROMA_TYPE_YUV444;
+ break;
+#if VA_CHECK_VERSION(0,34,0)
+ case VA_RT_FORMAT_YUV411:
+ chroma_type = GST_VAAPI_CHROMA_TYPE_YUV411;
+ break;
+ case VA_RT_FORMAT_YUV400:
+ chroma_type = GST_VAAPI_CHROMA_TYPE_YUV400;
+ break;
+ case VA_RT_FORMAT_RGB32:
+ chroma_type = GST_VAAPI_CHROMA_TYPE_RGB32;
+ break;
+ case VA_RT_FORMAT_RGB16:
+ chroma_type = GST_VAAPI_CHROMA_TYPE_RGB16;
+ break;
+#endif
+#if VA_CHECK_VERSION(0,38,1)
+ case VA_RT_FORMAT_YUV420_10BPP:
+ chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420_10BPP;
+ break;
+#endif
+ default:
+ chroma_type = 0;
+ break;
+ }
+ return chroma_type;
+}
+
+/**
* from_GstVaapiChromaType:
* @chroma_type: the #GstVaapiChromaType
*
diff --git a/gst-libs/gst/vaapi/gstvaapiutils.h b/gst-libs/gst/vaapi/gstvaapiutils.h
index b4ee99e6..41b5762b 100644
--- a/gst-libs/gst/vaapi/gstvaapiutils.h
+++ b/gst-libs/gst/vaapi/gstvaapiutils.h
@@ -87,6 +87,10 @@ string_of_VARateControl (guint rate_control);
G_GNUC_INTERNAL
guint
+to_GstVaapiChromaType (guint va_rt_format);
+
+G_GNUC_INTERNAL
+guint
from_GstVaapiChromaType (guint chroma_type);
G_GNUC_INTERNAL