rtph265depay: fix unneeded sub-buffer creation

We create a sub-buffer just to copy over its metas and then throw it
away immediately, just use the original input buffer directly.
This commit is contained in:
Luis de Bethencourt 2016-01-15 16:10:02 +00:00
parent 6f8f82164a
commit 63ffe374ab

View file

@ -1168,7 +1168,6 @@ static GstBuffer *
gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{ {
GstRtpH265Depay *rtph265depay; GstRtpH265Depay *rtph265depay;
GstBuffer *buf;
GstBuffer *outbuf = NULL; GstBuffer *outbuf = NULL;
guint8 nal_unit_type; guint8 nal_unit_type;
@ -1200,7 +1199,6 @@ gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
payload_len = gst_rtp_buffer_get_payload_len (rtp); payload_len = gst_rtp_buffer_get_payload_len (rtp);
payload = gst_rtp_buffer_get_payload (rtp); payload = gst_rtp_buffer_get_payload (rtp);
buf = gst_rtp_buffer_get_payload_buffer (rtp);
marker = gst_rtp_buffer_get_marker (rtp); marker = gst_rtp_buffer_get_marker (rtp);
GST_DEBUG_OBJECT (rtph265depay, "receiving %d bytes", payload_len); GST_DEBUG_OBJECT (rtph265depay, "receiving %d bytes", payload_len);
@ -1308,8 +1306,8 @@ gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size); memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
gst_buffer_unmap (outbuf, &map); gst_buffer_unmap (outbuf, &map);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf, buf, gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
outbuf = outbuf =
gst_rtp_h265_depay_handle_nal (rtph265depay, outbuf, timestamp, gst_rtp_h265_depay_handle_nal (rtph265depay, outbuf, timestamp,
@ -1409,8 +1407,8 @@ gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
map.data[sizeof (sync_bytes) + 1] = nal_header & 0xff; map.data[sizeof (sync_bytes) + 1] = nal_header & 0xff;
gst_buffer_unmap (outbuf, &map); gst_buffer_unmap (outbuf, &map);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf, buf, gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
GST_DEBUG_OBJECT (rtph265depay, "queueing %d bytes", outsize); GST_DEBUG_OBJECT (rtph265depay, "queueing %d bytes", outsize);
@ -1429,8 +1427,8 @@ gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
outbuf = gst_buffer_new_and_alloc (outsize); outbuf = gst_buffer_new_and_alloc (outsize);
gst_buffer_fill (outbuf, 0, payload, outsize); gst_buffer_fill (outbuf, 0, payload, outsize);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf, buf, gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
GST_DEBUG_OBJECT (rtph265depay, "queueing %d bytes", outsize); GST_DEBUG_OBJECT (rtph265depay, "queueing %d bytes", outsize);
@ -1475,8 +1473,8 @@ gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size); memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
gst_buffer_unmap (outbuf, &map); gst_buffer_unmap (outbuf, &map);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf, buf, gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR)); rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
outbuf = gst_rtp_h265_depay_handle_nal (rtph265depay, outbuf, timestamp, outbuf = gst_rtp_h265_depay_handle_nal (rtph265depay, outbuf, timestamp,
marker); marker);
@ -1485,21 +1483,17 @@ gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
} }
} }
gst_buffer_unref (buf);
return outbuf; return outbuf;
/* ERRORS */ /* ERRORS */
empty_packet: empty_packet:
{ {
GST_DEBUG_OBJECT (rtph265depay, "empty packet"); GST_DEBUG_OBJECT (rtph265depay, "empty packet");
gst_buffer_unref (buf);
return NULL; return NULL;
} }
waiting_start: waiting_start:
{ {
GST_DEBUG_OBJECT (rtph265depay, "waiting for start"); GST_DEBUG_OBJECT (rtph265depay, "waiting for start");
gst_buffer_unref (buf);
return NULL; return NULL;
} }
#if 0 #if 0
@ -1507,7 +1501,6 @@ not_implemented_donl_present:
{ {
GST_ELEMENT_ERROR (rtph265depay, STREAM, FORMAT, GST_ELEMENT_ERROR (rtph265depay, STREAM, FORMAT,
(NULL), ("DONL field present not supported yet")); (NULL), ("DONL field present not supported yet"));
gst_buffer_unref (buf);
return NULL; return NULL;
} }
#endif #endif
@ -1515,7 +1508,6 @@ not_implemented:
{ {
GST_ELEMENT_ERROR (rtph265depay, STREAM, FORMAT, GST_ELEMENT_ERROR (rtph265depay, STREAM, FORMAT,
(NULL), ("NAL unit type %d not supported yet", nal_unit_type)); (NULL), ("NAL unit type %d not supported yet", nal_unit_type));
gst_buffer_unref (buf);
return NULL; return NULL;
} }
} }