ultrahdr: release memory if encode/decode fails am: e69d9d2e7f am: e12f984157

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/23541809

Change-Id: I75becb3cb83692ec3e1d3b5096e31ca7192b9eae
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>