pgssubdec: handle more complex PGS scenarios

Add ability to handle multiple palettes and objects simultaneously.
Each simultaneous object is given its own AVSubtitleRect.
Note that there can be up to 64 currently valid objects, but only
2 at any one time can be "presented".

Signed-off-by: Anton Khirnov <anton@khirnov.net>
doc: remove trailing ':' at the end of sections

Also lowercase "options" in "Advanced Video Options" for consistency.
avcodec/pgssubdec: rename PICTURE_SEGMENT

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/pgssubdec: do not fail when part of the packet is faulty unless AV_EF_EXPLODE is set

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/pgssubdec: split out flush_cache()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/pgssubdec: Pass AVSubtitleRect to decode_rle()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/pgssubdec: better error codes

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/pgssubdec: Bail out of decode_rle() if error and AV_EF_EXPLODE is set

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/pgssubdec: fix end display time

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

* commit '253d0be6a1ecc343d29ff8e1df0ddf961ab9c772':
  pgssubdec: handle more complex PGS scenarios

Conflicts:
	libavcodec/pgssubdec.c

Some of this has been split out and commited in cleanly split patches immedeately
before this merge

Merged-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/pgssubdec: Check input buffer size in parse_presentation_segment()

Might fix overread, no testcase known though.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/pgssubdec: remove unused variables

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