mpegtsmux: Fixup program array indices after stream removal
Each stream stores the program_array_index
of its position in its
program's streams
array. When we remove a stream from this array, we
need to correct the program_array_index
of all streams that were
backshifted by the removal.
Also extract the removal into a new function and add some more safety checks.