avoid LTR reference frames overflow
Merge pull request #1321 from ruil2/ltr_check

avoid LTR reference frames overflow
Merge remote-tracking branch 'upstream/master' into travis.osx