diff options
author | Ben Avison <bavison@riscosopen.org> | 2013-08-05 13:12:49 +0100 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-08-05 19:25:55 +0300 |
commit | a22ae9f0c579793f411e2bd7a8db557091a3a4ae (patch) | |
tree | 9c2c26d112c1860e0db7f915eec99214d950b342 /libavformat | |
parent | 43bacd5b7d3d265a77cd29d8abb131057796aecc (diff) | |
download | ffmpeg-a22ae9f0c579793f411e2bd7a8db557091a3a4ae.tar.gz |
mpegts: Remove one 64-bit integer modulus operation per packet
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>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mpegts.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 7a74712e04..eecf246b3e 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -28,6 +28,7 @@ #include "libavutil/opt.h" #include "libavcodec/bytestream.h" #include "libavcodec/get_bits.h" +#include "libavcodec/mathops.h" #include "avformat.h" #include "mpegts.h" #include "internal.h" @@ -98,6 +99,8 @@ struct MpegTSContext { int raw_packet_size; int pos47; + /** position corresponding to pos47, or 0 if pos47 invalid */ + int64_t pos; /** if true, all pids are analyzed to find streams */ int auto_guess; @@ -1694,7 +1697,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) return 0; pos = avio_tell(ts->stream->pb); - ts->pos47= pos % ts->raw_packet_size; + MOD_UNLIKELY(ts->pos47, pos, ts->raw_packet_size, ts->pos); if (tss->type == MPEGTS_SECTION) { if (is_start) { |