summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordon.darling <don.darling@24075187-2e39-4e88-bbb8-bc8aa768f540>2010-11-16 20:46:52 +0000
committerdon.darling <don.darling@24075187-2e39-4e88-bbb8-bc8aa768f540>2010-11-16 20:46:52 +0000
commitd888bbd106e75bce3f42e909a4416d5ae3637c7a (patch)
treeda0f455cec7bdb26b0820202de6f3f08ea31c53b
parentdc72f091e328d23ae2d23f5a222399be6b89ade2 (diff)
Encode function now unrefs input buffer ASAP.
The chain function was unreffing the input buffer after calling the encode thread, but this was killing performance on DM6467 because the capture had to wait on the encode. Now it is released immediately after copying or color-converting the input buffer, so the capture driver gets it back sooner. git-svn-id: https://gstreamer.ti.com/svn/gstreamer_ti/trunk@870 24075187-2e39-4e88-bbb8-bc8aa768f540
-rw-r--r--gstreamer_ti/ti_build/ticodecplugin/src/gsttividenc1.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/gstreamer_ti/ti_build/ticodecplugin/src/gsttividenc1.c b/gstreamer_ti/ti_build/ticodecplugin/src/gsttividenc1.c
index 43d1225..f8d8eff 100644
--- a/gstreamer_ti/ti_build/ticodecplugin/src/gsttividenc1.c
+++ b/gstreamer_ti/ti_build/ticodecplugin/src/gsttividenc1.c
@@ -1096,7 +1096,6 @@ static GstFlowReturn gst_tividenc1_chain(GstPad * pad, GstBuffer * buf)
if (gst_tividenc1_encode(videnc1, qBuf, &outBuf) != GST_FLOW_OK) {
GST_ELEMENT_ERROR(videnc1, RESOURCE, WRITE,
("Failed to encode input buffer\n"), (NULL));
- gst_buffer_unref(qBuf);
return GST_FLOW_UNEXPECTED;
}
@@ -1107,8 +1106,6 @@ static GstFlowReturn gst_tividenc1_chain(GstPad * pad, GstBuffer * buf)
gst_buffer_unref(qBuf);
return GST_FLOW_UNEXPECTED;
}
-
- gst_buffer_unref(qBuf);
}
return GST_FLOW_OK;
@@ -1562,6 +1559,7 @@ gst_tividenc1_encode(GstTIVidenc1 *videnc1, GstBuffer *inBuf,
{
Buffer_Handle hContigInBuf = NULL;
Buffer_Handle hDstBuf = NULL;
+ GstFlowReturn flowRet = GST_FLOW_OK;
GstClockTime encDataTime;
Int ret;
@@ -1573,9 +1571,12 @@ gst_tividenc1_encode(GstTIVidenc1 *videnc1, GstBuffer *inBuf,
("input buffer is an invalid size (%lu != %lu)\n",
(guint32)GST_BUFFER_SIZE(inBuf), (guint32)videnc1->upstreamBufSize),
(NULL));
- return GST_FLOW_UNEXPECTED;
+ goto exit_fail;
}
+ /* Get the time stamp from the input buffer */
+ encDataTime = GST_BUFFER_TIMESTAMP(inBuf);
+
/* If zero-copy encode is enabled, we can pass the input buffer directly
* to the encoder without a copy. Otherwise, copy the input buffer into
* our physically contiguous buffer for the codec.
@@ -1586,7 +1587,7 @@ gst_tividenc1_encode(GstTIVidenc1 *videnc1, GstBuffer *inBuf,
gst_tividenc1_convert_gst_to_dmai(videnc1, inBuf, TRUE);
if (videnc1->hInBufRef == NULL) {
GST_ERROR("failed to get dmai buffer\n");
- return GST_FLOW_UNEXPECTED;
+ goto exit_fail;
}
} else {
Buffer_setUserPtr(videnc1->hInBufRef,
@@ -1598,17 +1599,16 @@ gst_tividenc1_encode(GstTIVidenc1 *videnc1, GstBuffer *inBuf,
hContigInBuf = videnc1->hContigInBuf;
gst_tividenc1_copy_input(videnc1, hContigInBuf, inBuf);
Buffer_setNumBytesUsed(hContigInBuf, Buffer_getSize(hContigInBuf));
+ gst_buffer_unref(inBuf);
+ inBuf = NULL;
}
- /* Get the time stamp from the input buffer */
- encDataTime = GST_BUFFER_TIMESTAMP(inBuf);
-
/* Obtain a free output buffer for the encoded data */
if (!(hDstBuf = gst_tidmaibuftab_get_buf(videnc1->hOutBufTab))) {
GST_ELEMENT_ERROR(videnc1, RESOURCE, READ,
("failed to get a free contiguous buffer from BufTab\n"),
(NULL));
- return GST_FLOW_UNEXPECTED;
+ goto exit_fail;
}
/* Make sure the whole buffer is used for output */
@@ -1621,12 +1621,18 @@ gst_tividenc1_encode(GstTIVidenc1 *videnc1, GstBuffer *inBuf,
if (ret < 0) {
GST_ELEMENT_ERROR(videnc1, STREAM, ENCODE,
("failed to encode video buffer\n"), (NULL));
- return GST_FLOW_UNEXPECTED;
+ goto exit_fail;
}
else if (ret > 0) {
GST_LOG("Venc1_process returned success code %d\n", ret);
}
+ /* Release the input buffer if we haven't already */
+ if (inBuf) {
+ gst_buffer_unref(inBuf);
+ inBuf = NULL;
+ }
+
/* Populate codec header */
gst_tividenc1_populate_codec_header(videnc1, hDstBuf);
@@ -1658,7 +1664,14 @@ gst_tividenc1_encode(GstTIVidenc1 *videnc1, GstBuffer *inBuf,
/* Release buffers no longer in use by the codec */
Buffer_freeUseMask(hDstBuf, gst_tidmaibuffer_CODEC_FREE);
- return GST_FLOW_OK;
+ goto exit_ok;
+
+exit_fail:
+ flowRet = GST_FLOW_UNEXPECTED;
+
+exit_ok:
+ if (inBuf) gst_buffer_unref(inBuf);
+ return flowRet;
}