configure: Express atomics/thread deps through the dependency system
atomics: cosmetics: Restructure ifdefs for greater clarity

Also fix the #endif comment in a few places and #include config.h to
avoid assuming it is #included implicitly.
Merge commit '8558595a59913a4667f57d5a4658b1340f1a4354'

* commit '8558595a59913a4667f57d5a4658b1340f1a4354':
  configure: Express atomics/thread deps through the dependency system

Conflicts:
	configure

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge remote-tracking branch 'qatar/master'

* qatar/master:
  atomics: cosmetics: Restructure ifdefs for greater clarity

Merged-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/mpegvideo_enc: fix integer overflow with -skip_exp >= 2

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avcodec/mpegvideo_enc: fix frame skipping with intra only codecs

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