1. Error handling for unsupported video resolution for m4v video decoder
2. Modified the original patch to add error handling for DSP Initialization failure
   to prevent OMX client hang

Originally from: https://partner.source.android.com/g/#change,1411
diff --git a/omx/ti_omx_config_parser/inc/ti_video_config_parser.h b/omx/ti_omx_config_parser/inc/ti_video_config_parser.h
index d9455f4..0701014 100644
--- a/omx/ti_omx_config_parser/inc/ti_video_config_parser.h
+++ b/omx/ti_omx_config_parser/inc/ti_video_config_parser.h
@@ -21,6 +21,11 @@
 #include "oscl_base.h"
 #include "oscl_types.h"
 #include "pvmf_format_type.h"
+#include "oscl_stdstring.h"
+
+#define WVGA_MAX_WIDTH 864
+#define WVGA_MAX_HEIGHT WVGA_MAX_WIDTH
+#define TI_VID_DEC "OMX.TI.Video.Decoder"
 
 typedef struct
 {
@@ -39,7 +44,8 @@
 
 OSCL_IMPORT_REF int16 ti_video_config_parser(
 	tiVideoConfigParserInputs *aInputs, 
-	tiVideoConfigParserOutputs *aOutputs);
+	tiVideoConfigParserOutputs *aOutputs,
+    char * pComponentName);
 
 #endif //TI_VIDEO_CONFIG_PARSER_H_INCLUDED
 
diff --git a/omx/ti_omx_config_parser/src/ti_omx_config_parser.cpp b/omx/ti_omx_config_parser/src/ti_omx_config_parser.cpp
index c044e45..b5523b9 100644
--- a/omx/ti_omx_config_parser/src/ti_omx_config_parser.cpp
+++ b/omx/ti_omx_config_parser/src/ti_omx_config_parser.cpp
@@ -152,7 +152,7 @@
             
             if ((aInputs.iMimeType == PVMF_MIME_M4V) || (aInputs.iMimeType == PVMF_MIME_H264_VIDEO))
             {
-                Status = ti_video_config_parser((tiVideoConfigParserInputs *)&aInputs, (tiVideoConfigParserOutputs *)aOutputParameters);
+                Status = ti_video_config_parser((tiVideoConfigParserInputs *)&aInputs, (tiVideoConfigParserOutputs *)aOutputParameters, pInputs->cComponentName);
             }
             else
             {
diff --git a/omx/ti_omx_config_parser/src/ti_video_config_parser.cpp b/omx/ti_omx_config_parser/src/ti_video_config_parser.cpp
index 183fcc8..0e1aa1d 100644
--- a/omx/ti_omx_config_parser/src/ti_video_config_parser.cpp
+++ b/omx/ti_omx_config_parser/src/ti_video_config_parser.cpp
@@ -63,7 +63,7 @@
 
 int32 GetNAL_Config(uint8** bitstream, int32* size);
 
-OSCL_EXPORT_REF int16 ti_video_config_parser(tiVideoConfigParserInputs *aInputs, tiVideoConfigParserOutputs *aOutputs)
+OSCL_EXPORT_REF int16 ti_video_config_parser(tiVideoConfigParserInputs *aInputs, tiVideoConfigParserOutputs *aOutputs, char *pComponentName)
 {
     if (aInputs->iMimeType == PVMF_MIME_M4V) //m4v
     {
@@ -91,6 +91,13 @@
         aOutputs->height = (uint32)display_height;
         aOutputs->profile = (uint32)profile_level; // for mp4, profile/level info is packed
         aOutputs->level = 0;
+        /* TI Video Decoder supports up to WVGA 864x480 resolutions, PV should
+         * use another component to render higher resolutions */
+        if ((width  > WVGA_MAX_WIDTH || height > WVGA_MAX_HEIGHT) && 0 == oscl_strncmp (pComponentName, TI_VID_DEC, oscl_strlen (TI_VID_DEC)))
+        {
+            return -1;
+
+        }
     }
     else if (aInputs->iMimeType == PVMF_MIME_H2631998 ||
              aInputs->iMimeType == PVMF_MIME_H2632000)//h263
diff --git a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c
index eba38c4..5e8d267 100644
--- a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c
+++ b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c
@@ -6959,7 +6959,7 @@
         eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb);
         if (eError != OMX_ErrorNone) {
             OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...%x\n",eError);
-            eError = OMX_ErrorHardware;
+            eError = OMX_ErrorInvalidState;
             goto EXIT;
         }
     }
@@ -7149,7 +7149,7 @@
         eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb);
         if (eError != OMX_ErrorNone) {
             OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...%x\n",eError);
-            eError = OMX_ErrorHardware;
+            eError = OMX_ErrorInvalidState;
             goto EXIT;
         }
     }
@@ -7330,7 +7330,7 @@
         eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb);
         if (eError != OMX_ErrorNone) {
             OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...%x\n",eError);
-            eError = OMX_ErrorHardware;
+            eError = OMX_ErrorInvalidState;
             goto EXIT;
         }
     }
@@ -7507,7 +7507,7 @@
         eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb);
         if (eError != OMX_ErrorNone) {
             OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...%x\n",eError);
-            eError = OMX_ErrorHardware;
+            eError = OMX_ErrorInvalidState;
             goto EXIT;
         }
     }
@@ -7694,7 +7694,7 @@
         eError = LCML_InitMMCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle, NULL, &pLcmlHandle, NULL, &cb);
         if (eError != OMX_ErrorNone) {
             OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...%x\n",eError);
-            eError = OMX_ErrorHardware;
+            eError = OMX_ErrorInvalidState;
             goto EXIT;
         }
     }
@@ -8473,6 +8473,16 @@
                                                "DSP Initialization");
         goto EXIT;
     }
+    if (eError != OMX_ErrorNone){
+        OMX_PRDSP4(pComponentPrivate->dbg, "LCML Error %x\n", pComponentPrivate->eState);
+        pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
+                                               pComponentPrivate->pHandle->pApplicationPrivate,
+                                               OMX_EventError,
+                                               eError,
+                                               OMX_TI_ErrorSevere,
+                                               "DSP Initialization");
+        goto EXIT;
+    }
     #ifndef UNDER_CE
     pComponentPrivate->bLCMLOut = OMX_FALSE;
 #endif