only compare YUV on EOS buffer if the size is non-zero

Bug: 17627977
Change-Id: I18b8924bd3f3282a7b487ca9c837da82a061cdbb
diff --git a/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java b/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
index fe28a96..a009ce2 100644
--- a/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
+++ b/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
@@ -387,31 +387,36 @@
             int res = codec.dequeueOutputBuffer(info, VIDEO_CODEC_WAIT_TIME_US);
             if (res >= 0) {
                 int outputBufIndex = res;
-                ByteBuffer buf = codecOutputBuffers[outputBufIndex];
-                if (VERBOSE && (outFrameCount == 0)) {
-                    printByteBuffer("Y ", buf, 0, 20);
-                    printByteBuffer("UV ", buf, mVideoWidth * mVideoHeight, 20);
-                    printByteBuffer("UV ", buf, mVideoWidth * mVideoHeight + mVideoWidth * 60, 20);
-                }
-                Point origin = getOrigin(outFrameCount);
-                for (int i = 0; i < PIXEL_CHECK_PER_FRAME; i++) {
-                    int w = mRandom.nextInt(mVideoWidth);
-                    int h = mRandom.nextInt(mVideoHeight);
-                    getPixelValuesFromYUVBuffers(origin.x, origin.y, w, h, expected);
-                    getPixelValuesFromOutputBuffer(buf, w, h, decoded);
-                    if (VERBOSE) {
-                        Log.i(TAG, outFrameCount + "-" + i + "- th round expcted " + expected.mY +
-                                "," + expected.mU + "," + expected.mV + "  decoded " + decoded.mY +
-                                "," + decoded.mU + "," + decoded.mV);
+
+                // only do YUV compare on EOS frame if the buffer size is none-zero
+                if (info.size > 0) {
+                    ByteBuffer buf = codecOutputBuffers[outputBufIndex];
+                    if (VERBOSE && (outFrameCount == 0)) {
+                        printByteBuffer("Y ", buf, 0, 20);
+                        printByteBuffer("UV ", buf, mVideoWidth * mVideoHeight, 20);
+                        printByteBuffer("UV ", buf,
+                                mVideoWidth * mVideoHeight + mVideoWidth * 60, 20);
                     }
-                    totalErrorSquared += expected.calcErrorSquared(decoded);
+                    Point origin = getOrigin(outFrameCount);
+                    for (int i = 0; i < PIXEL_CHECK_PER_FRAME; i++) {
+                        int w = mRandom.nextInt(mVideoWidth);
+                        int h = mRandom.nextInt(mVideoHeight);
+                        getPixelValuesFromYUVBuffers(origin.x, origin.y, w, h, expected);
+                        getPixelValuesFromOutputBuffer(buf, w, h, decoded);
+                        if (VERBOSE) {
+                            Log.i(TAG, outFrameCount + "-" + i + "- th round expcted " + expected.mY
+                                    + "," + expected.mU + "," + expected.mV + "  decoded "
+                                    + decoded.mY + "," + decoded.mU + "," + decoded.mV);
+                        }
+                        totalErrorSquared += expected.calcErrorSquared(decoded);
+                    }
+                    outFrameCount++;
                 }
                 codec.releaseOutputBuffer(outputBufIndex, false /* render */);
                 if ((info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
                     Log.d(TAG, "saw output EOS.");
                     sawOutputEOS = true;
                 }
-                outFrameCount++;
             } else if (res == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
                 codecOutputBuffers = codec.getOutputBuffers();
                 Log.d(TAG, "output buffers have changed.");