vaapidecode: make decoder work with playbin
authorLionel Landwerlin <llandwerlin@gmail.com>
Fri, 13 Jun 2014 20:45:04 +0000 (21:45 +0100)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 3 Jul 2014 21:07:51 +0000 (23:07 +0200)
When playbin/decodebin builds the pipeline, it puts decoders and sinks
into different bins and forwards the queries from bins to bins. So in
the initials steps the pipeline is built iteratively by playbin and
looks like this :

[filesrc]

[filesrc] -> [typefind]

[filesrc] -> [typefind] -> [demuxer]

[filesrc] -> [typefind] -> [demuxer] -> [decoder]

At this point the decoder is asked for its SRC caps and it will make a
choice based on what gst_pad_peer_query_caps() returns. The problem is
that the caps returns at that point includes caps features like ANY,
essentially because playbin can plug in additional elements like
videoscale, videoconv or deinterlace.

This patch adds a another call to
gst_vaapi_find_preferred_caps_feature() when the decoder decides its
allocation, to make sure we asks the downstream elements when the
entire pipeline has been built.

https://bugzilla.gnome.org/show_bug.cgi?id=731645

gst/vaapi/gstvaapidecode.c

index 0ec280d..1d97c62 100644 (file)
@@ -514,6 +514,7 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
     gboolean has_video_meta = FALSE;
     GstVideoCodecState *state;
 #if GST_CHECK_VERSION(1,1,0) && USE_GLX
+    gboolean has_texture_upload_meta = FALSE;
     GstCapsFeatures *features, *features2;
 #endif
 
@@ -534,10 +535,22 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
     features = gst_caps_get_features(state->caps, 0);
     features2 = gst_caps_features_new(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, NULL);
 
+    has_texture_upload_meta =
+        gst_vaapi_find_preferred_caps_feature(GST_VIDEO_DECODER_SRC_PAD(vdec),
+            GST_VIDEO_FORMAT_ENCODED) ==
+        GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META;
+
     /* Update src caps if feature is not handled downstream */
     if (!decode->has_texture_upload_meta &&
         gst_caps_features_is_equal(features, features2))
         gst_vaapidecode_update_src_caps (decode, state);
+    else if (has_texture_upload_meta &&
+             !gst_caps_features_is_equal(features, features2)) {
+        gst_video_info_set_format(&state->info, GST_VIDEO_FORMAT_RGBA,
+                                  state->info.width,
+                                  state->info.height);
+        gst_vaapidecode_update_src_caps(decode, state);
+    }
     gst_caps_features_free(features2);
 #endif