mm-video-v4l2: venc: Reject graphic buffer queued with wrong dimensions

In surface mode, if graphic-buffer queued has dimensions different
from the configured dimensions, reject the buffer

Change-Id: I4040c96af292451ccd50199d620ff01c69445798
diff --git a/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp b/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp
index 3943677..ff3f703 100644
--- a/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp
+++ b/mm-video-v4l2/vidc/venc/src/omx_video_base.cpp
@@ -4031,6 +4031,16 @@
             DEBUG_PRINT_LOW("ETB (meta-gralloc) fd = %d, offset = %d, size = %d",
                     Input_pmem_info.fd, Input_pmem_info.offset,
                     Input_pmem_info.size);
+            // if input buffer dimensions is different from what is configured,
+            // reject the buffer
+            if ((int)m_sInPortDef.format.video.nFrameWidth != handle->unaligned_width ||
+                    (int)m_sInPortDef.format.video.nFrameHeight != handle->unaligned_height) {
+                ALOGE("Graphic buf size(%dx%d) does not match configured size(%ux%u)",
+                        handle->unaligned_width, handle->unaligned_height,
+                        m_sInPortDef.format.video.nFrameWidth, m_sInPortDef.format.video.nFrameHeight);
+                post_event ((unsigned long)buffer, 0, OMX_COMPONENT_GENERATE_EBD);
+                return OMX_ErrorNone;
+            }
         }
         if (dev_use_buf(PORT_INDEX_IN) != true) {
             DEBUG_PRINT_ERROR("ERROR: in dev_use_buf");