Make sure the random test bitrate is high enough

The ForceIntraFrame test will fail (giving up after 100 skipped
frames) if the bitrate is not set high enough.

Set the minimum bitrate to w*h/50, which is a very low value,
but which still should allow getting a non-skipped frame within
a few attempts.
If lowering the maximum number of ref frames, check iNumRefFrames as well

Make sure we don't set iMaxNumRefFrames lower than iNumRefFrames.

This fixes occasional test failures in
EncodeDecodeTestAPI.SetOptionEncParamExt.
add fix for protection of wrong reading if input is invalid
put this file into good format
Merge pull request #1641 from mstorsjo/test-min-bitrate

Make sure the random test bitrate is high enough
Merge pull request #1643 from mstorsjo/check-num-refs

If lowering the maximum number of ref frames, check iNumRefFrames as well
Merge pull request #1649 from sijchen/fix_trace

[Encoder] fix a potential problem of trace
Merge remote-tracking branch 'upstream/master' into travis.osx