mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
libs: encoder/context: query region of interest support
Queries if the driver supports "Region of Interest" (ROI) during the config creation. This attribute conveys whether the driver supports region-of-interest (ROI) encoding, based on user provided ROI rectangles. The attribute value is partitioned into fields as defined in the VAConfigAttribValEncROI union. If ROI encoding is supported, the ROI information is passed to the driver using VAEncMiscParameterTypeROI. https://bugzilla.gnome.org/show_bug.cgi?id=768248 Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
This commit is contained in:
parent
3ec7996d75
commit
b41d72b7c5
3 changed files with 60 additions and 1 deletions
|
@ -229,7 +229,7 @@ config_create (GstVaapiContext * context)
|
|||
{
|
||||
const GstVaapiContextInfo *const cip = &context->info;
|
||||
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (context);
|
||||
VAConfigAttrib attribs[3], *attrib = attribs;
|
||||
VAConfigAttrib attribs[4], *attrib = attribs;
|
||||
VAStatus status;
|
||||
guint value, va_chroma_format;
|
||||
|
||||
|
@ -299,6 +299,26 @@ config_create (GstVaapiContext * context)
|
|||
attrib->value = value;
|
||||
attrib++;
|
||||
}
|
||||
#endif
|
||||
#if VA_CHECK_VERSION(0,39,1)
|
||||
if (config->roi_capability) {
|
||||
VAConfigAttribValEncROI *roi_config;
|
||||
attrib->type = VAConfigAttribEncROI;
|
||||
if (!context_get_attribute (context, attrib->type, &value))
|
||||
goto cleanup;
|
||||
|
||||
roi_config = (VAConfigAttribValEncROI *) & value;
|
||||
|
||||
if (roi_config->bits.num_roi_regions != config->roi_num_supported ||
|
||||
roi_config->bits.roi_rc_qp_delat_support == 0) {
|
||||
GST_ERROR ("ROI unsupported - number of regions supported: %d"
|
||||
" ROI delta QP: %d", roi_config->bits.num_roi_regions,
|
||||
roi_config->bits.roi_rc_qp_delat_support);
|
||||
goto cleanup;
|
||||
}
|
||||
attrib->value = value;
|
||||
attrib++;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -340,6 +360,14 @@ context_update_config_encoder (GstVaapiContext * context,
|
|||
config->packed_headers = new_config->packed_headers;
|
||||
config_changed = TRUE;
|
||||
}
|
||||
|
||||
if (config->roi_capability != new_config->roi_capability ||
|
||||
config->roi_num_supported != new_config->roi_num_supported) {
|
||||
config->roi_capability = new_config->roi_capability;
|
||||
config->roi_num_supported = new_config->roi_num_supported;
|
||||
config_changed = TRUE;
|
||||
}
|
||||
|
||||
return config_changed;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,8 @@ struct _GstVaapiConfigInfoEncoder
|
|||
{
|
||||
GstVaapiRateControl rc_mode;
|
||||
guint packed_headers;
|
||||
gboolean roi_capability;
|
||||
guint roi_num_supported;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -592,6 +592,32 @@ get_packed_headers (GstVaapiEncoder * encoder)
|
|||
return encoder->packed_headers;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
get_roi_capability (GstVaapiEncoder * encoder, guint * num_roi_supported)
|
||||
{
|
||||
#if VA_CHECK_VERSION(0,39,1)
|
||||
VAConfigAttribValEncROI *roi_config;
|
||||
guint value;
|
||||
|
||||
if (!get_config_attribute (encoder, VAConfigAttribEncROI, &value))
|
||||
return FALSE;
|
||||
|
||||
roi_config = (VAConfigAttribValEncROI *) & value;
|
||||
|
||||
if (roi_config->bits.num_roi_regions == 0 ||
|
||||
roi_config->bits.roi_rc_qp_delat_support == 0)
|
||||
return FALSE;
|
||||
|
||||
GST_INFO ("Support for ROI - number of regions supported: %d",
|
||||
roi_config->bits.num_roi_regions);
|
||||
|
||||
*num_roi_supported = roi_config->bits.num_roi_regions;
|
||||
return TRUE;
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
is_chroma_type_supported (GstVaapiEncoder * encoder)
|
||||
{
|
||||
|
@ -682,6 +708,9 @@ set_context_info (GstVaapiEncoder * encoder)
|
|||
memset (config, 0, sizeof (*config));
|
||||
config->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder);
|
||||
config->packed_headers = get_packed_headers (encoder);
|
||||
config->roi_capability =
|
||||
get_roi_capability (encoder, &config->roi_num_supported);
|
||||
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
|
|
Loading…
Reference in a new issue