avidec: dont randomly skip packets for offseting the index

Fixes Ticket2490

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 6c593f1b671b7725b8c36f92f7c0a23ccf8e7628)
ffmpeg: free threads on error conditions.

Fixes Ticket2562

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 1a36c756d8959207d3386f03e11c15216abc50b7)
smacker: remove av_clip_int16()

Fixes Ticket2425

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 2211c76287e073a9e176fde7dbb9a63ceb2af8d1)
avienc: Disallow the first frame to be skiped

Fixes Ticket2386

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit cc0db8cf3042186d8355dcf10be67071cfbbcc5d)

Conflicts:
	libavformat/avienc.c
h264_cavlc: fix reading skip run

Fixes Ticket2606

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 826b3a75cd295c03720e00d3de83e1abcbedd4b9)

Conflicts:
	libavcodec/h264_cavlc.c
AAC encoder: Fix rate control on twoloop.

Fixes a case where multichannel bitrate isn't accurately
targetted by psy model alone, never achieving the target bitrate.
Now fixed.

Fixes ticket #2625.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Carl Eugen Hoyos <cehoyos@ag.or.at>