]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugin-ducati.git/commitdiff
gstducati decoder: Disable externalpool acceptance
authorPooja Prajod <a0132412@ti.com>
Wed, 29 Jun 2016 15:37:46 +0000 (21:07 +0530)
committerPooja Prajod <a0132412@ti.com>
Tue, 5 Jul 2016 14:39:26 +0000 (20:09 +0530)
The decoder can know the max-ref frames for a stream.
This info can be used for optimizing buffer allocation.
But this info is available only after first buffer is
given to IVA-HD. Since this is a parameter known to the decoder,
it is better to let the decoder manage it's own pool, rather
than adapting all elements to parse the caps for this info.

We used to allocate some extra buffers taking into consideration
the buffers held by the sink (=n). This is mainly to avoid a deadlock
in case of streams with <=n max-ref frames. To optimize buffer
allocation, num_buffers is calculated as MAX(4, max-ref). This ensures
no deadlock and minimize buffer allocated incase of streams with higher max-ref.

Signed-off-by: Pooja Prajod <a0132412@ti.com>
src/gstducatividdec.c
src/gstducatividdec.h

index b02ca2942949c20e2d35c89260b0699395a45bea..aee2655fdca8b6741da31e8fd20461d730308cb6 100644 (file)
@@ -274,7 +274,7 @@ codec_buffer_pool_get (GstDucatiVidDec * self, GstBuffer * buf)
         GST_ROUND_UP_2 (self->padded_height) * 3 / 2;
 
     if (self->status->maxNumDisplayBufs)
-      num_buffers = self->status->maxNumDisplayBufs + 5;
+      num_buffers = MAX (4, self->status->maxNumDisplayBufs);
 
     GST_DEBUG_OBJECT (self, "creating bufferpool");
     GST_DEBUG_OBJECT (self, "%s\n",
@@ -596,6 +596,11 @@ codec_process (GstDucatiVidDec * self, gboolean send, gboolean flush,
           GST_ERROR_OBJECT (self, "downstream didn't accept new caps");
           err = XDM_EFAIL;
         }
+
+        if (self->pool) {
+          gst_object_unref (self->pool);
+          self->pool = NULL;
+        }
         gst_caps_unref (caps);
       }
     }
@@ -707,10 +712,6 @@ codec_process (GstDucatiVidDec * self, gboolean send, gboolean flush,
         self->pool = NULL;
       }
 
-      if (self->externalpool) {
-        gst_object_unref (self->externalpool);
-        self->externalpool = NULL;
-      }
     }
 
     if (send) {
@@ -1389,51 +1390,10 @@ normal:
   /* do this before creating codec to ensure reverse caps negotiation
    * happens first:
    */
-allocate_buffer:
-  /* For plugins like VPE that allocate buffers to peers */
-  if (!self->queried_external_pool) {
-    query =
-        gst_query_new_allocation (gst_pad_get_current_caps (self->srcpad),
-        TRUE);
-    if (gst_pad_peer_query (self->srcpad, query)) {
-      gst_query_parse_nth_allocation_pool (query, 0, &self->externalpool, &size,
-          &min, &max);
-    }
-    gst_query_unref (query);
-    self->queried_external_pool = TRUE;
-  }
-
-  if (self->externalpool) {
-    gst_buffer_pool_set_active (self->externalpool, TRUE);
-    GstFlowReturn ret_acq_buf =
-        gst_buffer_pool_acquire_buffer (GST_BUFFER_POOL (self->externalpool),
-        &outbuf,
-        NULL);
-    if (ret_acq_buf == GST_FLOW_OK) {
-      gst_buffer_add_video_crop_meta (outbuf);
-      /* Crop meta will be checked and consumed by codec_process */
-      GstMemory *mem = gst_buffer_get_memory (outbuf, 0);
-      gboolean mem_type = gst_is_drm_memory (mem);
-      gst_memory_unref (mem);
-      if (mem_type) {
-        goto common;
-      } else {
-        gst_buffer_unref (outbuf);
-      }
-    }
-    GST_WARNING_OBJECT (self, "acquire buffer from externalpool failed %s",
-        gst_flow_get_name (ret_acq_buf));
 
-  }
-
-aqcuire_from_own_pool:
-  if (self->externalpool) {
-    gst_object_unref (self->externalpool);
-    self->externalpool = NULL;
-  }
+allocate_buffer:
   outbuf = codec_buffer_pool_get (self, NULL);
 
-common:
   if (outbuf == NULL) {
     GST_WARNING_OBJECT (self, "alloc_buffer failed");
     gst_buffer_unref (buf);
@@ -1788,11 +1748,6 @@ gst_ducati_viddec_finalize (GObject * obj)
   if (self->sinkcaps)
     gst_caps_unref (self->sinkcaps);
 
-  if (self->externalpool) {
-    gst_object_unref (self->externalpool);
-    self->externalpool = NULL;
-  }
-
   if (self->pool) {
     gst_object_unref (self->pool);
     self->pool = NULL;
@@ -1916,9 +1871,6 @@ gst_ducati_viddec_init (GstDucatiVidDec * self, gpointer klass)
 
   self->pageMemType = XDM_MEMTYPE_TILEDPAGE;
 
-  self->queried_external_pool = FALSE;
-  self->externalpool = NULL;
-
   self->codecdata = NULL;
   self->codecdatasize = 0;
 
index f4fbc2b727120dc1ae93b0e87f8ebe00e26a2df9..56c57c7d94e17b36a083c69abb9367a6ce03ea23 100644 (file)
@@ -97,10 +97,6 @@ struct _GstDucatiVidDec
 
   gboolean need_out_buf;
 
-  /* For storing the external pool query history */
-  gboolean queried_external_pool;
-  GstBufferPool *externalpool;
-
   /* by default, codec_data from sinkpad is prepended to first buffer: */
 
   guint8 *codecdata;