struct _GstVaapiDecoderMpeg2Private {
GstVaapiProfile profile;
+ GstVaapiProfile hw_profile;
guint width;
guint height;
guint fps_n;
memcpy(dst, src, 64);
}
+static const char *
+get_profile_str(GstVaapiProfile profile)
+{
+ char *str;
+
+ switch (profile) {
+ case GST_VAAPI_PROFILE_MPEG2_SIMPLE: str = "simple"; break;
+ case GST_VAAPI_PROFILE_MPEG2_MAIN: str = "main"; break;
+ case GST_VAAPI_PROFILE_MPEG2_HIGH: str = "high"; break;
+ default: str = "<unknown>"; break;
+ }
+ return str;
+}
+
+static GstVaapiProfile
+get_profile(GstVaapiDecoderMpeg2 *decoder, GstVaapiEntrypoint entrypoint)
+{
+ GstVaapiDisplay * const va_display = GST_VAAPI_DECODER_DISPLAY(decoder);
+ GstVaapiDecoderMpeg2Private * const priv = decoder->priv;
+ GstVaapiProfile profile = priv->profile;
+
+ do {
+ /* Return immediately if the exact same profile was found */
+ if (gst_vaapi_display_has_decoder(va_display, profile, entrypoint))
+ break;
+
+ /* Otherwise, try to map to a higher profile */
+ switch (profile) {
+ case GST_VAAPI_PROFILE_MPEG2_SIMPLE:
+ profile = GST_VAAPI_PROFILE_MPEG2_MAIN;
+ break;
+ case GST_VAAPI_PROFILE_MPEG2_MAIN:
+ profile = GST_VAAPI_PROFILE_MPEG2_HIGH;
+ break;
+ case GST_VAAPI_PROFILE_MPEG2_HIGH:
+ // Try to map to main profile if no high profile specific bits used
+ if (priv->profile == profile &&
+ !priv->has_seq_scalable_ext &&
+ (priv->has_seq_ext && priv->seq_ext.chroma_format == 1)) {
+ profile = GST_VAAPI_PROFILE_MPEG2_MAIN;
+ break;
+ }
+ // fall-through
+ default:
+ profile = GST_VAAPI_PROFILE_UNKNOWN;
+ break;
+ }
+ } while (profile != GST_VAAPI_PROFILE_UNKNOWN);
+
+ if (profile != priv->profile)
+ GST_INFO("forced %s profile to %s profile",
+ get_profile_str(priv->profile), get_profile_str(profile));
+ return profile;
+}
+
static GstVaapiDecoderStatus
ensure_context(GstVaapiDecoderMpeg2 *decoder)
{
GstVaapiDecoderMpeg2Private * const priv = decoder->priv;
- GstVaapiProfile profiles[2];
GstVaapiEntrypoint entrypoint = GST_VAAPI_ENTRYPOINT_VLD;
- guint i, n_profiles = 0;
gboolean reset_context = FALSE;
if (priv->profile_changed) {
priv->profile_changed = FALSE;
reset_context = TRUE;
- profiles[n_profiles++] = priv->profile;
- if (priv->profile == GST_VAAPI_PROFILE_MPEG2_SIMPLE)
- profiles[n_profiles++] = GST_VAAPI_PROFILE_MPEG2_MAIN;
-
- for (i = 0; i < n_profiles; i++) {
- if (gst_vaapi_display_has_decoder(GST_VAAPI_DECODER_DISPLAY(decoder),
- profiles[i], entrypoint))
- break;
- }
- if (i == n_profiles)
+ priv->hw_profile = get_profile(decoder, entrypoint);
+ if (priv->hw_profile == GST_VAAPI_PROFILE_UNKNOWN)
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
- priv->profile = profiles[i];
}
if (priv->size_changed) {
if (reset_context) {
reset_context = gst_vaapi_decoder_ensure_context(
GST_VAAPI_DECODER(decoder),
- priv->profile,
+ priv->hw_profile,
entrypoint,
priv->width, priv->height
);
case GST_MPEG_VIDEO_PROFILE_MAIN:
profile = GST_VAAPI_PROFILE_MPEG2_MAIN;
break;
+ case GST_MPEG_VIDEO_PROFILE_HIGH:
+ profile = GST_VAAPI_PROFILE_MPEG2_HIGH;
+ break;
default:
GST_ERROR("unsupported profile %d", seq_ext->profile);
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
priv->height = 0;
priv->fps_n = 0;
priv->fps_d = 0;
+ priv->hw_profile = GST_VAAPI_PROFILE_UNKNOWN;
priv->profile = GST_VAAPI_PROFILE_MPEG2_SIMPLE;
priv->current_picture = NULL;
priv->adapter = NULL;
/**
* GstVaapiProfile:
+ * @GST_VAAPI_PROFILE_UNKNOWN:
+ * Unknown profile, used for initializers
* @GST_VAAPI_PROFILE_MPEG1:
* MPEG-1
* @GST_VAAPI_PROFILE_MPEG2_SIMPLE:
* MPEG-2 simple profile
* @GST_VAAPI_PROFILE_MPEG2_MAIN:
* MPEG-2 main profile
+ * @GST_VAAPI_PROFILE_MPEG2_HIGH:
+ * MPEG-2 high profile
* @GST_VAAPI_PROFILE_MPEG4_SIMPLE:
* MPEG-4 Part-2 simple profile
* @GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE:
* The set of all profiles for #GstVaapiProfile.
*/
enum _GstVaapiProfile {
+ GST_VAAPI_PROFILE_UNKNOWN = 0,
GST_VAAPI_PROFILE_MPEG1 = GST_VAAPI_MAKE_PROFILE(MPEG1,1),
GST_VAAPI_PROFILE_MPEG2_SIMPLE = GST_VAAPI_MAKE_PROFILE(MPEG2,1),
GST_VAAPI_PROFILE_MPEG2_MAIN = GST_VAAPI_MAKE_PROFILE(MPEG2,2),
+ GST_VAAPI_PROFILE_MPEG2_HIGH = GST_VAAPI_MAKE_PROFILE(MPEG2,3),
GST_VAAPI_PROFILE_MPEG4_SIMPLE = GST_VAAPI_MAKE_PROFILE(MPEG4,1),
GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE = GST_VAAPI_MAKE_PROFILE(MPEG4,2),
GST_VAAPI_PROFILE_MPEG4_MAIN = GST_VAAPI_MAKE_PROFILE(MPEG4,3),