[Encoder] improve the logic of locking in the function

reviewed at: https://rbcommons.com/s/OpenH264/r/851/
improve the logic of locking in the function:
the locking should include all the operations related to 

iSliceNumInFrame
pCurLayer->sLayerInfo.pSliceInLayer[ iNextSliceIdc ]
pSliceCtx->pFirstMbInSlice[iNextSliceIdc]
pSliceCtx->pOverallMbMap (on idx-es of next slice)
pCurLayer->sMbDataP(on idx-es of next slice)

they are some other variable are not necessary to be locked, so move them out of the lock

this can make a difference on iphone5:
testing a 720p on iphone5:
multi-thread under slice-mode=4 (the condition this function will be called):
(before)21fps -- (after)39fps