mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
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
This commit is contained in:
parent
914a4712d9
commit
db7268117d
3 changed files with 70 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -315,6 +315,56 @@ string_of_VARateControl (guint rate_control)
|
|||
return "<unknown>";
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -85,6 +85,10 @@ G_GNUC_INTERNAL
|
|||
const gchar *
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue