diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2014-06-18 14:19:28 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2014-06-18 14:54:59 +0100 |
commit | 70bfc35756288b70c810299e89f9e24220156b5e (patch) | |
tree | 1dbee1eb3542988669bfd02f8dcd2e564aebab0a /gst | |
parent | 4b1f771e4def7e80cf4fc48b9f44219859f7c70f (diff) | |
download | gstreamer-plugins-good-70bfc35756288b70c810299e89f9e24220156b5e.tar.gz |
rtpmp4vpay: pre-allocate buffer list of the right size
Diffstat (limited to 'gst')
-rw-r--r-- | gst/rtp/gstrtpmp4vpay.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gst/rtp/gstrtpmp4vpay.c b/gst/rtp/gstrtpmp4vpay.c index 8ac6d061b..56cf9f733 100644 --- a/gst/rtp/gstrtpmp4vpay.c +++ b/gst/rtp/gstrtpmp4vpay.c @@ -223,10 +223,12 @@ gst_rtp_mp4v_pay_empty (GstRtpMP4VPay * rtpmp4vpay) gst_adapter_clear (rtpmp4vpay->adapter); } +#define RTP_HEADER_LEN 12 + static GstFlowReturn gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay) { - guint avail; + guint avail, mtu; GstBuffer *outbuf; GstBuffer *outbuf_data = NULL; GstFlowReturn ret; @@ -248,12 +250,12 @@ gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay) if (!avail) return GST_FLOW_OK; - ret = GST_FLOW_OK; + mtu = GST_RTP_BASE_PAYLOAD_MTU (rtpmp4vpay); /* Use buffer lists. Each frame will be put into a list * of buffers and the whole list will be pushed downstream * at once */ - list = gst_buffer_list_new (); + list = gst_buffer_list_new_sized ((avail / (mtu - RTP_HEADER_LEN)) + 1); while (avail > 0) { guint towrite; @@ -265,7 +267,7 @@ gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay) packet_len = gst_rtp_buffer_calc_packet_len (avail, 0, 0); /* fill one MTU or all available bytes */ - towrite = MIN (packet_len, GST_RTP_BASE_PAYLOAD_MTU (rtpmp4vpay)); + towrite = MIN (packet_len, mtu); /* this is the payload length */ payload_len = gst_rtp_buffer_calc_payload_len (towrite, 0, 0); |