Merge "DO NOT MERGE Decoder: Increase memory allocation for weights & offsets for interlaced clips" into mnc-dev
diff --git a/decoder/ih264d_api.c b/decoder/ih264d_api.c
index 5321ab6..8d73fbe 100644
--- a/decoder/ih264d_api.c
+++ b/decoder/ih264d_api.c
@@ -3036,6 +3036,7 @@
             {
                 /* a start code has already been found earlier in the same process call*/
                 frame_data_left = 0;
+                header_data_left = 0;
                 continue;
             }
 
diff --git a/decoder/ih264d_parse_pslice.c b/decoder/ih264d_parse_pslice.c
index d6bea99..a33a03f 100644
--- a/decoder/ih264d_parse_pslice.c
+++ b/decoder/ih264d_parse_pslice.c
@@ -1663,11 +1663,15 @@
                 return 0;
             }
 
-            // Inserting new slice
-            ps_dec->u2_cur_slice_num++;
-             ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx;
-            ps_dec->i2_prev_slice_mby = ps_dec->u2_mby;
-            ps_dec->ps_parse_cur_slice++;
+            /* Inserting new slice only if the current slice has atleast 1 MB*/
+            if(ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice <
+                    (UWORD32)(ps_dec->u2_total_mbs_coded >> ps_slice->u1_mbaff_frame_flag))
+            {
+                ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx;
+                ps_dec->i2_prev_slice_mby = ps_dec->u2_mby;
+                ps_dec->u2_cur_slice_num++;
+                ps_dec->ps_parse_cur_slice++;
+            }
 
         }
         else
diff --git a/decoder/ih264d_parse_slice.c b/decoder/ih264d_parse_slice.c
index 054dd62..c0195d7 100644
--- a/decoder/ih264d_parse_slice.c
+++ b/decoder/ih264d_parse_slice.c
@@ -1070,8 +1070,7 @@
 
     /*we currently don not support ASO*/
     if(((u2_first_mb_in_slice << ps_cur_slice->u1_mbaff_frame_flag)
-                    <= ps_dec->u2_cur_mb_addr) && (ps_dec->u2_cur_mb_addr != 0)
-                    && (ps_dec->u4_first_slice_in_pic != 0))
+                    <= ps_dec->u2_cur_mb_addr) && (ps_dec->u4_first_slice_in_pic == 0))
     {
         return ERROR_CORRUPTED_SLICE;
     }
diff --git a/decoder/ih264d_tables.c b/decoder/ih264d_tables.c
index d49de14..c45525a 100644
--- a/decoder/ih264d_tables.c
+++ b/decoder/ih264d_tables.c
@@ -855,7 +855,8 @@
     { 0, 0 /* Junk */, /* 16x16 */
       0, 8, /* 16x8 */
       0, 2, /* 8x16 */
-      0, 2, 8, 10 /* 8x8 */
+      0, 2, 8, 10 /* 8x8 */,
+      0 /* One extra entry is read at the end of loop, but not used */
     };
 
 /*!