Add bound checks and use correct index for m_vpsMaxTidIlRefPicsPlus1

This fixes out-of-bounds memory access that occurs when processing
bistreams such as SPALSCAL_A_Qualcomm_3
6 jobs for !1982 with fixmem1 in 15 minutes and 20 seconds (queued for 3 seconds)
detached
Status Job ID Name Coverage
  Build
passed #19853
macos
build_macos

00:04:43

passed #19854
ubuntu1604
build_ubuntu1604

00:05:40

passed #19855
ubuntu1804
build_ubuntu1804

00:05:33

passed #19856
ubuntu1804-gcc8
build_ubuntu1804-gcc8

00:06:13

passed #19857
vc191x
build_vc191x

00:15:18

passed #19858
vc192x
build_vc192x

00:13:56