From 1dd89800b0e895b0b699889c3ef4617dca95c6c5 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Tue, 10 Dec 2013 14:20:55 +0100 Subject: [PATCH] decoder: h264: fix decoding of BA3_SVA_C.264. Conformance test Base_Ext_Main_profiles/BA3_SVA_C.264 complys with extended profile specifications. However, the SPS header has the constraint_set1_flag syntax element set to 1. This means that, if a Main profile compliant decoder is available, then it should be able to decode this stream. This changes makes it possible to fall-back from Extended profile to Main profile if constraint_set1_flag is set to 1. https://bugzilla.gnome.org/show_bug.cgi?id=720190 --- gst-libs/gst/vaapi/gstvaapidecoder_h264.c | 41 +++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c index 4fa8e50969..1d1be555ca 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c @@ -752,6 +752,23 @@ gst_vaapi_decoder_h264_create(GstVaapiDecoder *base_decoder) return TRUE; } +static void +fill_profiles(GstVaapiProfile profiles[16], guint *n_profiles_ptr, + GstVaapiProfile profile) +{ + guint n_profiles = *n_profiles_ptr; + + profiles[n_profiles++] = profile; + switch (profile) { + case GST_VAAPI_PROFILE_H264_MAIN: + profiles[n_profiles++] = GST_VAAPI_PROFILE_H264_HIGH; + break; + default: + break; + } + *n_profiles_ptr = n_profiles; +} + static GstVaapiProfile get_profile(GstVaapiDecoderH264 *decoder, GstH264SPS *sps) { @@ -764,17 +781,21 @@ get_profile(GstVaapiDecoderH264 *decoder, GstH264SPS *sps) if (!profile) return GST_VAAPI_PROFILE_UNKNOWN; - if (sps->constraint_set1_flag && profile == GST_VAAPI_PROFILE_H264_BASELINE) - profile = GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE; - - profiles[n_profiles++] = profile; + fill_profiles(profiles, &n_profiles, profile); switch (profile) { - case GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE: - profiles[n_profiles++] = GST_VAAPI_PROFILE_H264_BASELINE; - profiles[n_profiles++] = GST_VAAPI_PROFILE_H264_MAIN; - // fall-through - case GST_VAAPI_PROFILE_H264_MAIN: - profiles[n_profiles++] = GST_VAAPI_PROFILE_H264_HIGH; + case GST_VAAPI_PROFILE_H264_BASELINE: + if (sps->constraint_set1_flag) { // A.2.2 (main profile) + fill_profiles(profiles, &n_profiles, + GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE); + fill_profiles(profiles, &n_profiles, + GST_VAAPI_PROFILE_H264_MAIN); + } + break; + case GST_VAAPI_PROFILE_H264_EXTENDED: + if (sps->constraint_set1_flag) { // A.2.2 (main profile) + fill_profiles(profiles, &n_profiles, + GST_VAAPI_PROFILE_H264_MAIN); + } break; default: break;