Fixes for YuvToJpegEncoder::encode

Bug: 70969260
Test: Existing CTS tests

Call jpeg_destroy_compress after compression (and failure), eliminating
a memory leak.

In addition, use a custom method for handling errors. skjpeg_error_exit
was previously used, but that method expects a skjpeg_error_mgr, which
isn't used here. skjpeg_error_mgr is more complex than necessary; it
allows for multiple methods to set their own jmp_bufs, even if they call
each other. The entire compression here is contained in one method. The
code for handling this single jmp_buf is simple, so no need to share
code.

This is a follow-on to If9a33ed10ea60131906a632a7030e0b69a21f4ea, which
removed skjpeg_error_mgr, but incorrectly left the skjpeg_error_exit.

Change-Id: Ib76e07ae0d29b093d3709f60e427b18e0e32bd9d
1 file changed