goldfish-codecs: prevent context leak and fix portChange

in destroyContext, use correct memory offset so that
host side can actually find the context to destroy.

when output format changed, need to return immediately
to avoid overrun on output buffer.

BUG: 124388359

Test: atest android.media.cts.AdaptivePlaybackTest#testH264_adaptiveSmallDrc
Change-Id: Idabb2dcf383de48c3442ebdb84e1b4c5bfeb8868
diff --git a/system/codecs/omx/avcdec/GoldfishAVCDec.cpp b/system/codecs/omx/avcdec/GoldfishAVCDec.cpp
index 1da4cf0..28c5d5c 100644
--- a/system/codecs/omx/avcdec/GoldfishAVCDec.cpp
+++ b/system/codecs/omx/avcdec/GoldfishAVCDec.cpp
@@ -365,6 +365,9 @@
                     resetPlugin();
                     mWidth = myWidth;
                     mHeight = myHeight;
+                    if (portWillReset) {
+                        return;
+                    }
                 }
                 outHeader->nFilledLen =  (outputBufferWidth() * outputBufferHeight() * 3) / 2;
                 int myStride = outputBufferWidth();
diff --git a/system/codecs/omx/avcdec/MediaH264Decoder.cpp b/system/codecs/omx/avcdec/MediaH264Decoder.cpp
index 4c6d349..05111cc 100644
--- a/system/codecs/omx/avcdec/MediaH264Decoder.cpp
+++ b/system/codecs/omx/avcdec/MediaH264Decoder.cpp
@@ -77,7 +77,7 @@
     auto transport = GoldfishMediaTransport::getInstance();
     transport->writeParam((uint64_t)mHostHandle, 0, mAddressOffSet);
     transport->sendOperation(MediaCodecType::H264Codec,
-                             MediaOperation::DestroyContext);
+                             MediaOperation::DestroyContext, mAddressOffSet);
     transport->returnMemorySlot(mAddressOffSet >> 23);
     mHasAddressSpaceMemory = false;
 }