libs: add rate-control attributes.

Add GstVaapiRateControl types and GType values in view to supporting
rate controls for encoding. This is meant to be used for instance in
GstVaapiContext.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
Wind Yuan 2013-07-12 21:33:32 +08:00 committed by Gwenole Beauchesne
parent 24835654ee
commit 082fb3f1b4
5 changed files with 123 additions and 0 deletions

View file

@ -121,6 +121,29 @@ typedef enum {
GST_VAAPI_ROTATION_270 = 270,
} GstVaapiRotation;
/**
* GstVaapiRateControl:
* @GST_VAAPI_RATECONTROL_NONE: No rate control performed by the
* underlying driver
* @GST_VAAPI_RATECONTROL_CQP: Constant QP
* @GST_VAAPI_RATECONTROL_CBR: Constant bitrate
* @GST_VAAPI_RATECONTROL_VCM: Video conference mode
* @GST_VAAPI_RATECONTROL_VBR: Variable bitrate
* @GST_VAAPI_RATECONTROL_VBR_CONSTRAINED: Variable bitrate with peak
* rate higher than average bitrate
*
* The set of allowed rate control values for #GstVaapiRateControl.
* Note: this is only valid for encoders.
*/
typedef enum {
GST_VAAPI_RATECONTROL_NONE = 0,
GST_VAAPI_RATECONTROL_CQP,
GST_VAAPI_RATECONTROL_CBR,
GST_VAAPI_RATECONTROL_VCM,
GST_VAAPI_RATECONTROL_VBR,
GST_VAAPI_RATECONTROL_VBR_CONSTRAINED,
} GstVaapiRateControl;
G_END_DECLS
#endif /* GST_VAAPI_TYPES_H */

View file

@ -210,6 +210,21 @@ string_of_VADisplayAttributeType(VADisplayAttribType attribute_type)
return "<unknown>";
}
const char *
string_of_VARateControl(guint rate_control)
{
switch (rate_control) {
case VA_RC_NONE: return "None";
case VA_RC_CQP: return "CQP";
case VA_RC_CBR: return "CBR";
case VA_RC_VCM: return "VCM";
case VA_RC_VBR: return "VBR";
case VA_RC_VBR_CONSTRAINED: return "VBR-Constrained";
default: break;
}
return "<unknown>";
}
/**
* from_GstVaapiChromaType:
* @chroma_type: the #GstVaapiChromaType
@ -441,6 +456,36 @@ to_GstVaapiRotation(guint value)
return GST_VAAPI_ROTATION_0;
}
guint
from_GstVaapiRateControl(guint value)
{
switch (value) {
case GST_VAAPI_RATECONTROL_NONE: return VA_RC_NONE;
case GST_VAAPI_RATECONTROL_CQP: return VA_RC_CQP;
case GST_VAAPI_RATECONTROL_CBR: return VA_RC_CBR;
case GST_VAAPI_RATECONTROL_VCM: return VA_RC_VCM;
case GST_VAAPI_RATECONTROL_VBR: return VA_RC_VBR;
case GST_VAAPI_RATECONTROL_VBR_CONSTRAINED: return VA_RC_VBR_CONSTRAINED;
}
GST_ERROR("unsupported GstVaapiRateControl value %u", value);
return VA_RC_NONE;
}
guint
to_GstVaapiRateControl(guint value)
{
switch (value) {
case VA_RC_NONE: return GST_VAAPI_RATECONTROL_NONE;
case VA_RC_CQP: return GST_VAAPI_RATECONTROL_CQP;
case VA_RC_CBR: return GST_VAAPI_RATECONTROL_CBR;
case VA_RC_VCM: return GST_VAAPI_RATECONTROL_VCM;
case VA_RC_VBR: return GST_VAAPI_RATECONTROL_VBR;
case VA_RC_VBR_CONSTRAINED: return GST_VAAPI_RATECONTROL_VBR_CONSTRAINED;
}
GST_ERROR("unsupported VA-API Rate Control value %u", value);
return GST_VAAPI_RATECONTROL_NONE;
}
/* VPP: translate GstVaapiDeinterlaceMethod to VA deinterlacing algorithm */
guint
from_GstVaapiDeinterlaceMethod(guint value)

View file

@ -75,6 +75,10 @@ G_GNUC_INTERNAL
const char *
string_of_VADisplayAttributeType(VADisplayAttribType attribute_type);
G_GNUC_INTERNAL
const char *
string_of_VARateControl(guint rate_control);
G_GNUC_INTERNAL
guint
from_GstVaapiChromaType(guint chroma_type);
@ -111,6 +115,14 @@ G_GNUC_INTERNAL
guint
to_GstVaapiRotation(guint value);
G_GNUC_INTERNAL
guint
from_GstVaapiRateControl(guint value);
G_GNUC_INTERNAL
guint
to_GstVaapiRateControl(guint value);
G_GNUC_INTERNAL
guint
from_GstVaapiDeinterlaceMethod(guint value);

View file

@ -119,3 +119,34 @@ gst_vaapi_rotation_get_type(void)
g_type = g_enum_register_static("GstVaapiRotation", rotation_values);
return g_type;
}
/* --- GstVaapiRateControl --- */
GType
gst_vaapi_rate_control_get_type(void)
{
static volatile gsize g_type = 0;
static const GEnumValue rate_control_values[] = {
{ GST_VAAPI_RATECONTROL_NONE,
"None", "none" },
{ GST_VAAPI_RATECONTROL_CQP,
"Constant QP", "cqp" },
{ GST_VAAPI_RATECONTROL_CBR,
"Constant bitrate", "cbr" },
{ GST_VAAPI_RATECONTROL_VCM,
"Video conference", "vcm" },
{ GST_VAAPI_RATECONTROL_VBR,
"Variable bitrate", "vbr" },
{ GST_VAAPI_RATECONTROL_VBR_CONSTRAINED,
"Variable bitrate - Constrained", "vbr_constrained" },
{ 0, NULL, NULL },
};
if (g_once_init_enter(&g_type)) {
GType type = g_enum_register_static("GstVaapiRateControl",
rate_control_values);
g_once_init_leave(&g_type, type);
}
return g_type;
}

View file

@ -68,6 +68,15 @@ G_BEGIN_DECLS
*/
#define GST_VAAPI_TYPE_ROTATION gst_vaapi_rotation_get_type()
/**
* GST_VAAPI_TYPE_RATE_CONTROL:
*
* A type that represents the VA rate control.
*
* Return value: the #GType of GstVaapiRateControl
*/
#define GST_VAAPI_TYPE_RATE_CONTROL gst_vaapi_rate_control_get_type()
GType
gst_vaapi_point_get_type(void) G_GNUC_CONST;
@ -80,6 +89,9 @@ gst_vaapi_render_mode_get_type(void) G_GNUC_CONST;
GType
gst_vaapi_rotation_get_type(void) G_GNUC_CONST;
GType
gst_vaapi_rate_control_get_type(void) G_GNUC_CONST;
G_END_DECLS
#endif /* GST_VAAPI_VALUE_H */