MediaCodec: Signal crop attrb correctly to MediaImage during instantiation

The getOutputImage() of MediaCodec API translates the decoded image data
and MediaImage2 metadata to MediaImage. MediaImage is constructed by
copying only the display section of the decoded data. For images with
cropRect set, the display section needs to be correctly identified with
fields xOffset and yOffset which correspond to cropLeft and cropTop
respectively. This was missing causing issues in the final image
received from the API. This is addressed.

Bug: 163299340
Test: atest CtsMediaV2TestCases:CodecDecoderValidationTest
Test: atest MctsMediaV2TestCases:CodecDecoderValidationTest
Flag: EXEMPT bugfix
Change-Id: I99b92821f7585da2504dfc66df7af8fc96941fdd
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp
index 8814206..9c010cc 100644
--- a/media/jni/android_media_MediaCodec.cpp
+++ b/media/jni/android_media_MediaCodec.cpp
@@ -752,7 +752,7 @@
     }
 
     jobject cropRect = NULL;
-    int32_t left, top, right, bottom;
+    int32_t left = 0, top = 0, right = 0, bottom = 0;
     if (buffer->meta()->findRect("crop-rect", &left, &top, &right, &bottom)) {
         ScopedLocalRef<jclass> rectClazz(
                 env, env->FindClass("android/graphics/Rect"));
@@ -776,7 +776,7 @@
             byteBuffer, infoBuffer,
             (jboolean)!input /* readOnly */,
             (jlong)timestamp,
-            (jint)0 /* xOffset */, (jint)0 /* yOffset */, cropRect);
+            left /* xOffset */, top /* yOffset */, cropRect);
 
     // if MediaImage creation fails, return null
     if (env->ExceptionCheck()) {