tsmux: inline more code

With the previous commit, makes mpegtsmux 10 to 15% faster
This commit is contained in:
Edward Hervey 2012-06-05 16:59:44 +02:00 committed by Sebastian Dröge
parent e3a02ce49a
commit fa4f487d8f

View file

@ -298,8 +298,8 @@ tsmux_stream_at_pes_start (TsMuxStream * stream)
* *
* Returns: The number of bytes available. * Returns: The number of bytes available.
*/ */
gint static inline gint
tsmux_stream_bytes_avail (TsMuxStream * stream) _tsmux_stream_bytes_avail (TsMuxStream * stream)
{ {
gint bytes_avail; gint bytes_avail;
@ -308,9 +308,9 @@ tsmux_stream_bytes_avail (TsMuxStream * stream)
if (stream->cur_pes_payload_size != 0) if (stream->cur_pes_payload_size != 0)
bytes_avail = stream->cur_pes_payload_size - stream->pes_bytes_written; bytes_avail = stream->cur_pes_payload_size - stream->pes_bytes_written;
else 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 */ /* Calculate the number of bytes available in the current PES */
if (stream->state == TSMUX_STREAM_STATE_HEADER) if (stream->state == TSMUX_STREAM_STATE_HEADER)
@ -319,6 +319,14 @@ tsmux_stream_bytes_avail (TsMuxStream * stream)
return bytes_avail; 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: * tsmux_stream_bytes_in_buffer:
* @stream: a #TsMuxStream * @stream: a #TsMuxStream
@ -357,11 +365,11 @@ tsmux_stream_initialize_pes_packet (TsMuxStream * stream)
} else if (stream->is_video_stream) { } else if (stream->is_video_stream) {
/* Unbounded for video streams */ /* Unbounded for video streams */
stream->cur_pes_payload_size = 0; stream->cur_pes_payload_size = 0;
tsmux_stream_find_pts_dts_within (stream, tsmux_stream_find_pts_dts_within (stream, stream->bytes_avail, &stream->pts,
tsmux_stream_bytes_in_buffer (stream), &stream->pts, &stream->dts); &stream->dts);
} else { } else {
/* Output a PES packet of all currently available bytes otherwise */ /* 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, tsmux_stream_find_pts_dts_within (stream, stream->cur_pes_payload_size,
&stream->pts, &stream->dts); &stream->pts, &stream->dts);
} }
@ -422,7 +430,7 @@ tsmux_stream_get_data (TsMuxStream * stream, guint8 * buf, guint len)
stream->state = TSMUX_STREAM_STATE_PACKET; stream->state = TSMUX_STREAM_STATE_PACKET;
} }
if (len > (guint) tsmux_stream_bytes_avail (stream)) if (len > (guint) _tsmux_stream_bytes_avail (stream))
return FALSE; return FALSE;
stream->pes_bytes_written += len; stream->pes_bytes_written += len;