Encoding varying-size and -format images with the same JPEG encoder produces incorrect result in Jetpack 5.1.1

Hi,
For Jetpack 4, it destroys and re-create the class when resolution changes in prebuilt software stack. Since we can implement the same in application level, would suggest add the handling on Jetpack 5 release.