Bug 1037097: restrict image decode size in MediaFrame based on device memory size

@wilsonpage you're right.... I had it as a separate function at first, but then merged it into the promise resolve callback for some reason that I don't remember now.  I'll update the patch.