static GstVaapiContext *
create_test_context_config (GstVaapiEncoder * encoder, GstVaapiProfile profile)
{
- const GstVaapiEncoderClassData *const cdata =
- GST_VAAPI_ENCODER_GET_CLASS (encoder)->class_data;
GstVaapiContextInfo cip = { 0, };
GstVaapiContext *ctxt;
profile = get_profile (encoder);
cip.profile = profile;
- cip.entrypoint = (cdata->codec == GST_VAAPI_CODEC_JPEG) ?
- GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE : GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
+ cip.entrypoint = gst_vaapi_encoder_get_entrypoint (encoder, profile);
+ if (cip.entrypoint == GST_VAAPI_ENTRYPOINT_INVALID) {
+ GST_INFO ("can not find %s entrypoint for profile %s to create"
+ " text context. Ignore this profile",
+ GST_VAAPI_ENCODER_TUNE (encoder) == GST_VAAPI_ENCODER_TUNE_LOW_POWER ?
+ "the low-power" : "an available",
+ gst_vaapi_profile_get_va_name (profile));
+ return NULL;
+ }
init_context_info (encoder, &cip);
ctxt = gst_vaapi_context_new (encoder->display, &cip);
return encoder->profile;
}
+/* Get the entrypoint based on the tune option. */
+/**
+ * gst_vaapi_encoder_get_entrypoint:
+ * @encoder: a #GstVaapiEncoder
+ * @profile: a #GstVaapiProfile
+ *
+ * This function will return the valid entrypoint of the @encoder for
+ * @profile. If the low-power mode(tune option) is set, only LP
+ * entrypoints will be considered. If not, the first available entry
+ * point will be return.
+ *
+ * Returns: The #GstVaapiEntrypoint.
+ **/
+GstVaapiEntrypoint
+gst_vaapi_encoder_get_entrypoint (GstVaapiEncoder * encoder,
+ GstVaapiProfile profile)
+{
+ /* XXX: The profile may not be the same with encoder->profile */
+
+ g_return_val_if_fail (encoder, GST_VAAPI_ENTRYPOINT_INVALID);
+ g_return_val_if_fail (profile != GST_VAAPI_PROFILE_UNKNOWN,
+ GST_VAAPI_ENTRYPOINT_INVALID);
+
+ if (profile == GST_VAAPI_PROFILE_JPEG_BASELINE)
+ return GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE;
+
+ if (GST_VAAPI_ENCODER_TUNE (encoder) == GST_VAAPI_ENCODER_TUNE_LOW_POWER) {
+ if (gst_vaapi_display_has_encoder (GST_VAAPI_ENCODER_DISPLAY (encoder),
+ profile, GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP))
+ return GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP;
+ } else {
+ /* If not set, choose the available one */
+ if (gst_vaapi_display_has_encoder (GST_VAAPI_ENCODER_DISPLAY (encoder),
+ profile, GST_VAAPI_ENTRYPOINT_SLICE_ENCODE))
+ return GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
+
+ if (gst_vaapi_display_has_encoder (GST_VAAPI_ENCODER_DISPLAY (encoder),
+ profile, GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP))
+ return GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP;
+ }
+
+ return GST_VAAPI_ENTRYPOINT_INVALID;
+}
+
/** Returns a GType for the #GstVaapiEncoderTune set */
GType
gst_vaapi_encoder_tune_get_type (void)
case GST_VAAPI_ENCODER_TUNE_HIGH_COMPRESSION:
success = ensure_tuning_high_compression (encoder);
break;
- case GST_VAAPI_ENCODER_TUNE_LOW_POWER:
- /* Set low-power encode entry point. If hardware doesn't have
- * support, it will fail in ensure_hw_profile() in later stage.
- * So not duplicating the profile/entrypont query mechanism
- * here as a part of optimization */
- encoder->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP;
- success = TRUE;
- break;
default:
success = TRUE;
break;
if (!ensure_profile (encoder) || !ensure_profile_limits (encoder))
return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ /* If set low-power encode entry point and hardware doesn't have
+ * support, it will fail in ensure_hw_profile() in later stage. */
+ encoder->entrypoint =
+ gst_vaapi_encoder_get_entrypoint (GST_VAAPI_ENCODER_CAST (encoder),
+ encoder->profile);
+ if (encoder->entrypoint == GST_VAAPI_ENTRYPOINT_INVALID) {
+ GST_WARNING ("Cannot find valid entrypoint");
+ return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ }
+
/* Check HW constraints */
if (!ensure_hw_profile_limits (encoder))
return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
case GST_VAAPI_ENCODER_TUNE_HIGH_COMPRESSION:
success = ensure_tuning_high_compression (encoder);
break;
- case GST_VAAPI_ENCODER_TUNE_LOW_POWER:
- encoder->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP;
- success = TRUE;
- break;
default:
success = TRUE;
break;
if (!ensure_profile (encoder) || !ensure_profile_limits (encoder))
return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ encoder->entrypoint =
+ gst_vaapi_encoder_get_entrypoint (GST_VAAPI_ENCODER_CAST (encoder),
+ encoder->profile);
+ if (encoder->entrypoint == GST_VAAPI_ENTRYPOINT_INVALID) {
+ GST_WARNING ("Cannot find valid entrypoint");
+ return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ }
+
/* Check HW constraints */
if (!ensure_hw_profile_limits (encoder))
return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE;