avutil: remove timer.h include from internal.h

Added libavutil/timer.h include to all files with {START,STOP}_TIMER.
mpeg12: check scantable indices in all decode_block functions

Add checks to the fast functions used with CODEC_FLAGS2_FAST and move
the check for all other functions to before the invalid memory is
accessed. Fixes https://trac.videolan.org/vlc/ticket/9713 with
CODEC_FLAGS2_FAST.

CC: libav-stable@libav.org
Merge commit 'fb0c9d41d685abb58575c5482ca33b8cd457c5ec'

* commit 'fb0c9d41d685abb58575c5482ca33b8cd457c5ec':
  avutil: remove timer.h include from internal.h

Conflicts:
	libavcodec/ffv1dec.c
	libavutil/internal.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
avutil/internal.h: add timer.h back

Without this a developer would have to add a include every time he
wants to benchmark some code, this is a moderate inconvenience.

This reverts the specific hunk from fb0c9d41d685abb58575c5482ca33b8cd457c5ec

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '6d93307f8df81808f0dcdbc064b848054a6e83b3'

* commit '6d93307f8df81808f0dcdbc064b848054a6e83b3':
  mpeg12: check scantable indices in all decode_block functions

Benchmarks

Before:
1878 decicycles in mpeg2_decode_block_non_intra, 8388487 runs, 121 skips
1700 decicycles in mpeg2_decode_block_intra, 4194239 runs, 65 skips
1808 decicycles in mpeg2_fast_decode_block_non_intra, 8388492 runs, 116 skips
1669 decicycles in mpeg2_fast_decode_block_intra, 4194248 runs, 56 skips
--
2056 decicycles in mpeg1_decode_block_inter, 65535 runs, 1 skips
2346 decicycles in mpeg1_decode_block_intra, 32768 runs, 0 skips
2011 decicycles in mpeg1_fast_decode_block_inter, 65533 runs, 3 skips
----------------
After:
1858 decicycles in mpeg2_decode_block_non_intra, 8388490 runs, 118 skips
1691 decicycles in mpeg2_decode_block_intra, 4194233 runs, 71 skips
1823 decicycles in mpeg2_fast_decode_block_non_intra, 8388493 runs, 115 skips
1681 decicycles in mpeg2_fast_decode_block_intra, 4194238 runs, 66 skips
--
2010 decicycles in mpeg1_decode_block_inter, 65535 runs, 1 skips
2322 decicycles in mpeg1_decode_block_intra, 32766 runs, 2 skips
1995 decicycles in mpeg1_fast_decode_block_inter, 65535 runs, 1 skips

All benchmarks are the best scores of several runs

Merged-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/mpeg12dec: Redesign index checks for mpeg2_fast_decode_block_intra

This fixes the speed regression from 20626f53e9f41cb3db82329ed3db7d773cfa3a8f
and still checks sufficiently to prevent out of allocated memory accesses
due to the index

Before:
1681 decicycles in mpeg2_fast_decode_block_intra, 4194238 runs, 66 skips
After:
1658 decicycles in mpeg2_fast_decode_block_intra, 4194248 runs, 56 skips

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/mpeg12dec: Revert Change to mpeg2_fast_decode_block_non_intra

This fixes the speed regression from 20626f53e9f41cb3db82329ed3db7d773cfa3a8f
and still checks sufficiently to prevent out of allocated memory accesses
due to the index

Before:
1823 decicycles in mpeg2_fast_decode_block_non_intra, 8388493 runs, 115 skips
After:
1808 decicycles in mpeg2_fast_decode_block_non_intra, 8388494 runs, 114 skips

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>