[ffmpeg] - backport - avio: Add an internal function for reading without copying

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>
[ffmpeg] - backport - mpegts: Remove one memcpy per packet

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>
[ffmpeg] - backport - mpegts: Make discard_pid() faster for single-program streams

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>
[ffmpeg] - backport - 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>
[ffmpeg/patches] Add backported mpegts optimisations
Merge pull request #3075 from popcornmix/ffmpeg_mepgts

[ffmpeg] Backport of mpegts optimisations