avoid encoder crash with random pixel input
Merge pull request #1285 from dongzha/TestRandomEnc

avoid encoder crash with random pixel input