summaryrefslogtreecommitdiff
path: root/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2014-01-13 17:11:15 +0100
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2014-01-13 17:31:55 +0100
commit0c5f69e0d9b9e27c9d6f3d78b6384b98ddc70530 (patch)
treeb0cb8a60f45a4cd1d353df6a1031b749a2ffe757 /gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
parente311d53c8a18eb6b3fff2648a42d17c2e87d7b35 (diff)
encoder: mpeg2: fix hardware profile lookup.
Fix lookup for a suitable HW profile, as to be used by the underlying hardware, based on heuristics that lead to characterize the SW profile, i.e. the one used by the SW level encoding logic.
Diffstat (limited to 'gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c')
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c51
1 files changed, 46 insertions, 5 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
index db0f4477..958dd6e9 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
@@ -62,6 +62,45 @@ static void clear_references (GstVaapiEncoderMpeg2 * encoder);
static void push_reference (GstVaapiEncoderMpeg2 * encoder,
GstVaapiSurfaceProxy * ref);
+/* Derives the profile supported by the underlying hardware */
+static gboolean
+ensure_hw_profile (GstVaapiEncoderMpeg2 * encoder)
+{
+ GstVaapiDisplay *const display = GST_VAAPI_ENCODER_DISPLAY (encoder);
+ GstVaapiEntrypoint entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
+ GstVaapiProfile profile, profiles[2];
+ guint i, num_profiles = 0;
+
+ profiles[num_profiles++] = encoder->profile;
+ switch (encoder->profile) {
+ case GST_VAAPI_PROFILE_MPEG2_SIMPLE:
+ profiles[num_profiles++] = GST_VAAPI_PROFILE_MPEG2_MAIN;
+ break;
+ default:
+ break;
+ }
+
+ profile = GST_VAAPI_PROFILE_UNKNOWN;
+ for (i = 0; i < num_profiles; i++) {
+ if (gst_vaapi_display_has_encoder (display, profiles[i], entrypoint)) {
+ profile = profiles[i];
+ break;
+ }
+ }
+ if (profile == GST_VAAPI_PROFILE_UNKNOWN)
+ goto error_unsupported_profile;
+
+ GST_VAAPI_ENCODER_CAST (encoder)->profile = profile;
+ return TRUE;
+
+ /* ERRORS */
+error_unsupported_profile:
+ {
+ GST_ERROR ("unsupported HW profile (0x%08x)", encoder->profile);
+ return FALSE;
+ }
+}
+
/* Derives the minimum profile from the active coding tools */
static gboolean
ensure_profile (GstVaapiEncoderMpeg2 * encoder)
@@ -606,7 +645,7 @@ end:
return status;
}
-static void
+static GstVaapiEncoderStatus
set_context_info (GstVaapiEncoder * base_encoder)
{
GstVaapiEncoderMpeg2 *const encoder =
@@ -624,7 +663,9 @@ set_context_info (GstVaapiEncoder * base_encoder)
MAX_SLICE_HDR_SIZE = 8,
};
- base_encoder->profile = encoder->profile;
+ if (!ensure_hw_profile (encoder))
+ return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
+
base_encoder->num_ref_frames = 2;
/* Only YUV 4:2:0 formats are supported for now. This means that we
@@ -643,6 +684,8 @@ set_context_info (GstVaapiEncoder * base_encoder)
/* Account for Slice headers. We use one slice per line of macroblock */
base_encoder->codedbuf_size += (GST_ROUND_UP_16 (vip->height) / 16) *
MAX_SLICE_HDR_SIZE;
+
+ return GST_VAAPI_ENCODER_STATUS_SUCCESS;
}
static GstVaapiEncoderStatus
@@ -662,9 +705,7 @@ gst_vaapi_encoder_mpeg2_reconfigure (GstVaapiEncoder * base_encoder)
if (!ensure_bitrate (encoder))
goto error;
-
- set_context_info (base_encoder);
- return GST_VAAPI_ENCODER_STATUS_SUCCESS;
+ return set_context_info (base_encoder);
error:
return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;