Replace repeated code with a function for sgr filter
Replace repeated code with a function for sgr filter

Code cleanup.
BUG=aomedia:2044

Change-Id: I6a4bcc81ca50b2fa8ed9a95e81ae72171d2b2bd4

GrokImageCompression/aom,GrokImageCompression/aom,GrokImageCompression/aom,GrokImageCompression/aom,GrokImageCompression/aom,GrokImageCompression/aom