lavf/swfdec: factorize the creation of a new stream.

This also makes the changes of a3949fe11 applicable in both cases.
lavf/swfdec: support 8-bits PCM audio.
Fix bits_per_coded_sample when encoding png with frame-level multithreading.

Fixes ticket #2290.
mjpegdec: check for packed rgb mjpeg.

Fixes null pointer dereference

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>