From: Tim-Philipp Müller Date: Wed, 18 Jun 2014 13:19:28 +0000 (+0100) Subject: rtpmp4vpay: pre-allocate buffer list of the right size X-Git-Tag: 1.3.3~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=70bfc35756288b70c810299e89f9e24220156b5e;p=platform%2Fupstream%2Fgst-plugins-good.git rtpmp4vpay: pre-allocate buffer list of the right size --- diff --git a/gst/rtp/gstrtpmp4vpay.c b/gst/rtp/gstrtpmp4vpay.c index 8ac6d06..56cf9f7 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);