Fix for handling streams which resulted in negative num_mbs_left

Bug: 26070014
Change-Id: Id9f063a2c72a802d991b92abaf00ec687db5bb0f
diff --git a/decoder/impeg2d_dec_hdr.c b/decoder/impeg2d_dec_hdr.c
index 0abd528..9e4a9a0 100644
--- a/decoder/impeg2d_dec_hdr.c
+++ b/decoder/impeg2d_dec_hdr.c
@@ -18,6 +18,7 @@
  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
 */
 #include <string.h>
+#include <cutils/log.h>
 
 #include "iv_datatypedef.h"
 #include "iv.h"
@@ -929,6 +930,12 @@
             temp = u4_bits_read & 0xFF;
             i4_continue_decode = (((u4_bits_read >> 8) == 0x01) && (temp) && (temp <= 0xAF));
 
+            if (1 == ps_dec->i4_num_cores && 0 == ps_dec->u2_num_mbs_left)
+            {
+                i4_continue_decode = 0;
+                android_errorWriteLog(0x534e4554, "26070014");
+            }
+
             if(i4_continue_decode)
             {
                 /* If the slice is from the same row, then continue decoding without dequeue */
@@ -1191,7 +1198,7 @@
         i4_row -= 1;
 
 
-        if(i4_prev_row != i4_row)
+        if(i4_prev_row < i4_row)
         {
             /* Create a job for previous slice row */
             if(i4_start_row != -1)
@@ -1215,6 +1222,8 @@
             /* Store current slice's row position */
             i4_start_row = i4_row;
 
+        } else if (i4_prev_row > i4_row) {
+            android_errorWriteLog(0x534e4554, "26070014");
         }