omxvideodec: implement propose_allocation
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 26 Apr 2018 10:29:16 +0000 (12:29 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 8 Jun 2018 07:53:01 +0000 (09:53 +0200)
Tell upstream about how many buffer we plan to use so they can adjust
their own number of buffers accordingly if needed.

Same logic as the existing gst_omx_video_enc_propose_allocation().

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

omx/gstomxvideodec.c

index 53cc2e2..e885a99 100644 (file)
@@ -74,6 +74,8 @@ static GstFlowReturn gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
 static GstFlowReturn gst_omx_video_dec_finish (GstVideoDecoder * decoder);
 static gboolean gst_omx_video_dec_decide_allocation (GstVideoDecoder * bdec,
     GstQuery * query);
+static gboolean gst_omx_video_dec_propose_allocation (GstVideoDecoder * bdec,
+    GstQuery * query);
 
 static GstFlowReturn gst_omx_video_dec_drain (GstVideoDecoder * decoder);
 
@@ -178,6 +180,8 @@ gst_omx_video_dec_class_init (GstOMXVideoDecClass * klass)
   video_decoder_class->drain = GST_DEBUG_FUNCPTR (gst_omx_video_dec_drain);
   video_decoder_class->decide_allocation =
       GST_DEBUG_FUNCPTR (gst_omx_video_dec_decide_allocation);
+  video_decoder_class->propose_allocation =
+      GST_DEBUG_FUNCPTR (gst_omx_video_dec_propose_allocation);
 
   klass->cdata.type = GST_OMX_COMPONENT_TYPE_FILTER;
   klass->cdata.default_src_template_caps =
@@ -3232,3 +3236,21 @@ gst_omx_video_dec_decide_allocation (GstVideoDecoder * bdec, GstQuery * query)
 
   return TRUE;
 }
+
+static gboolean
+gst_omx_video_dec_propose_allocation (GstVideoDecoder * bdec, GstQuery * query)
+{
+  GstOMXVideoDec *self = GST_OMX_VIDEO_DEC (bdec);
+  guint size, num_buffers;
+
+  size = self->dec_in_port->port_def.nBufferSize;
+  num_buffers = self->dec_in_port->port_def.nBufferCountMin + 1;
+
+  GST_DEBUG_OBJECT (self,
+      "request at least %d buffers of size %d", num_buffers, size);
+  gst_query_add_allocation_pool (query, NULL, size, num_buffers, 0);
+
+  return
+      GST_VIDEO_DECODER_CLASS
+      (gst_omx_video_dec_parent_class)->propose_allocation (bdec, query);
+}