refactor a function for further strategy adjustment
add protection for decoder and data format
Merge pull request #1378 from sijchen/ref_refac22

[Encoder] Refactor a function for further strategy adjustment
Merge pull request #1382 from huili2/dataformat_bugfix

add protection for decoder and data format
Merge remote-tracking branch 'upstream/master' into travis.android