mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
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.
This commit is contained in:
parent
e311d53c8a
commit
0c5f69e0d9
1 changed files with 46 additions and 5 deletions
|
@ -62,6 +62,45 @@ static void clear_references (GstVaapiEncoderMpeg2 * encoder);
|
||||||
static void push_reference (GstVaapiEncoderMpeg2 * encoder,
|
static void push_reference (GstVaapiEncoderMpeg2 * encoder,
|
||||||
GstVaapiSurfaceProxy * ref);
|
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 */
|
/* Derives the minimum profile from the active coding tools */
|
||||||
static gboolean
|
static gboolean
|
||||||
ensure_profile (GstVaapiEncoderMpeg2 * encoder)
|
ensure_profile (GstVaapiEncoderMpeg2 * encoder)
|
||||||
|
@ -606,7 +645,7 @@ end:
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static GstVaapiEncoderStatus
|
||||||
set_context_info (GstVaapiEncoder * base_encoder)
|
set_context_info (GstVaapiEncoder * base_encoder)
|
||||||
{
|
{
|
||||||
GstVaapiEncoderMpeg2 *const encoder =
|
GstVaapiEncoderMpeg2 *const encoder =
|
||||||
|
@ -624,7 +663,9 @@ set_context_info (GstVaapiEncoder * base_encoder)
|
||||||
MAX_SLICE_HDR_SIZE = 8,
|
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;
|
base_encoder->num_ref_frames = 2;
|
||||||
|
|
||||||
/* Only YUV 4:2:0 formats are supported for now. This means that we
|
/* 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 */
|
/* Account for Slice headers. We use one slice per line of macroblock */
|
||||||
base_encoder->codedbuf_size += (GST_ROUND_UP_16 (vip->height) / 16) *
|
base_encoder->codedbuf_size += (GST_ROUND_UP_16 (vip->height) / 16) *
|
||||||
MAX_SLICE_HDR_SIZE;
|
MAX_SLICE_HDR_SIZE;
|
||||||
|
|
||||||
|
return GST_VAAPI_ENCODER_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstVaapiEncoderStatus
|
static GstVaapiEncoderStatus
|
||||||
|
@ -662,9 +705,7 @@ gst_vaapi_encoder_mpeg2_reconfigure (GstVaapiEncoder * base_encoder)
|
||||||
|
|
||||||
if (!ensure_bitrate (encoder))
|
if (!ensure_bitrate (encoder))
|
||||||
goto error;
|
goto error;
|
||||||
|
return set_context_info (base_encoder);
|
||||||
set_context_info (base_encoder);
|
|
||||||
return GST_VAAPI_ENCODER_STATUS_SUCCESS;
|
|
||||||
|
|
||||||
error:
|
error:
|
||||||
return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;
|
return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
Loading…
Reference in a new issue