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

add unit tests
Merge pull request #21792 from davidflanagan/bug1037097

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