From fa4f487d8fd61b6e73e0433b20b4438a124accad Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 5 Jun 2012 16:59:44 +0200 Subject: [PATCH] tsmux: inline more code With the previous commit, makes mpegtsmux 10 to 15% faster --- gst/mpegtsmux/tsmux/tsmuxstream.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/gst/mpegtsmux/tsmux/tsmuxstream.c b/gst/mpegtsmux/tsmux/tsmuxstream.c index a57cb41e21..77a6133ae3 100644 --- a/gst/mpegtsmux/tsmux/tsmuxstream.c +++ b/gst/mpegtsmux/tsmux/tsmuxstream.c @@ -298,8 +298,8 @@ tsmux_stream_at_pes_start (TsMuxStream * stream) * * Returns: The number of bytes available. */ -gint -tsmux_stream_bytes_avail (TsMuxStream * stream) +static inline gint +_tsmux_stream_bytes_avail (TsMuxStream * stream) { gint bytes_avail; @@ -308,9 +308,9 @@ tsmux_stream_bytes_avail (TsMuxStream * stream) if (stream->cur_pes_payload_size != 0) bytes_avail = stream->cur_pes_payload_size - stream->pes_bytes_written; else - bytes_avail = tsmux_stream_bytes_in_buffer (stream); + bytes_avail = stream->bytes_avail; - bytes_avail = MIN (bytes_avail, tsmux_stream_bytes_in_buffer (stream)); + bytes_avail = MIN (bytes_avail, stream->bytes_avail); /* Calculate the number of bytes available in the current PES */ if (stream->state == TSMUX_STREAM_STATE_HEADER) @@ -319,6 +319,14 @@ tsmux_stream_bytes_avail (TsMuxStream * stream) return bytes_avail; } +gint +tsmux_stream_bytes_avail (TsMuxStream * stream) +{ + g_return_val_if_fail (stream != NULL, 0); + + return _tsmux_stream_bytes_avail (stream); +} + /** * tsmux_stream_bytes_in_buffer: * @stream: a #TsMuxStream @@ -357,11 +365,11 @@ tsmux_stream_initialize_pes_packet (TsMuxStream * stream) } else if (stream->is_video_stream) { /* Unbounded for video streams */ stream->cur_pes_payload_size = 0; - tsmux_stream_find_pts_dts_within (stream, - tsmux_stream_bytes_in_buffer (stream), &stream->pts, &stream->dts); + tsmux_stream_find_pts_dts_within (stream, stream->bytes_avail, &stream->pts, + &stream->dts); } else { /* Output a PES packet of all currently available bytes otherwise */ - stream->cur_pes_payload_size = tsmux_stream_bytes_in_buffer (stream); + stream->cur_pes_payload_size = stream->bytes_avail; tsmux_stream_find_pts_dts_within (stream, stream->cur_pes_payload_size, &stream->pts, &stream->dts); } @@ -422,7 +430,7 @@ tsmux_stream_get_data (TsMuxStream * stream, guint8 * buf, guint len) stream->state = TSMUX_STREAM_STATE_PACKET; } - if (len > (guint) tsmux_stream_bytes_avail (stream)) + if (len > (guint) _tsmux_stream_bytes_avail (stream)) return FALSE; stream->pes_bytes_written += len;