The common case of the pointer having increased by one packet (which results
in no change to the modulus) can be detected with a 64-bit subtraction,
which is far cheaper than a division on many platforms.
Before After
Mean StdDev Mean StdDev Change
Divisions 248.3 8.8 51.5 7.4 +381.7%
Overall 2773.2 25.6 2372.5 43.1 +16.9%
Signed-off-by: Martin Storsjö <martin@martin.st>
When a stream contains a single program, there's no point in doing a
PID -> program lookup. Normally the one and only program isn't disabled,
so no packets should be discarded.
Before After
Mean StdDev Mean StdDev Change
discard_pid() 73.8 9.4 20.2 1.5 +264.8%
Overall 2300.8 28.0 2253.1 20.6 +2.1%
Signed-off-by: Martin Storsjö <martin@martin.st>
This was being performed to ensure that a complete packet was held in
contiguous memory, prior to parsing the packet. However, the source buffer
is typically large enough that the packet was already contiguous, so it is
beneficial to return the packet by reference in most cases.
Before After
Mean StdDev Mean StdDev Change
memcpy 720.7 32.7 649.8 25.1 +10.9%
Overall 2372.7 46.1 2291.7 21.8 +3.5%
Signed-off-by: Martin Storsjö <martin@martin.st>
As long as there is enough contiguous data in the avio buffer,
just return a pointer to it instead of copying it to the caller
provided buffer.
Signed-off-by: Martin Storsjö <martin@martin.st>
The bitstream buffers are now private and freed by libavcodec. For
backward compatibility, the hold bitstream buffer pointer is left NULL
(applications were supposed to av_freep() it).
Signed-off-by: Anton Khirnov <anton@khirnov.net>
A separate rtcp port can already be set when opening the rtp
protocol normally, but when doing port setup as in RTSP (where
we first need to open the local ports and pass them to the peer,
and only then receive the remote peer port numbers), we didn't
check the same url parameter as in the normal open routine.
Signed-off-by: Martin Storsjö <martin@martin.st>
I doubt that anyone ever would try to send a 1 byte packet
via the RTP protocol, but check just in case - it shouldn't
crash at least.
Signed-off-by: Martin Storsjö <martin@martin.st>
AVIOContext has got an av_class member that only gets set if
opening the context using avio_open2, but not if allocating a
custom IO context. A caller that wants to read AVOptions from
an AVIOContext (recursively using AV_OPT_SEARCH_CHILDREN) may
not know if the AVIOContext actually has got a class set or not.
Signed-off-by: Martin Storsjö <martin@martin.st>