merge in nougat-cts-release history after reset to nougat-cts-dev
diff --git a/decoder/ih264d_api.c b/decoder/ih264d_api.c
index 801960b..06cc8e9 100644
--- a/decoder/ih264d_api.c
+++ b/decoder/ih264d_api.c
@@ -2143,9 +2143,10 @@
         ret1 = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, ps_dec->u1_nal_unit_type == IDR_SLICE_NAL, ps_dec->ps_cur_slice->u2_frame_num,
                                    &temp_poc, prev_slice_err);
 
-        if((ret1 == ERROR_UNAVAIL_PICBUF_T) || (ret1 == ERROR_UNAVAIL_MVBUF_T))
+        if((ret1 == ERROR_UNAVAIL_PICBUF_T) || (ret1 == ERROR_UNAVAIL_MVBUF_T) ||
+                       (ret1 == ERROR_INV_SPS_PPS_T))
         {
-            return IV_FAIL;
+            ret = ret1;
         }
     }
 
diff --git a/decoder/ih264d_inter_pred.c b/decoder/ih264d_inter_pred.c
index 01f2e01..b99a77c 100644
--- a/decoder/ih264d_inter_pred.c
+++ b/decoder/ih264d_inter_pred.c
@@ -474,7 +474,7 @@
     UWORD8 i1_mc_wd, u1_dma_ht, u1_dma_wd, u1_dx, u1_dy;
     pred_info_t * ps_pred ;
     dec_slice_params_t * const ps_cur_slice = ps_dec->ps_cur_slice;
-    const UWORD8 u1_slice_type = ps_cur_slice->u1_slice_type;
+    const UWORD8 u1_slice_type = ps_dec->ps_decode_cur_slice->slice_type;
     UWORD8 u1_pod_bot, u1_pod_top;
 
     /* load the pictype for pod u4_flag & chroma motion vector derivation */
@@ -1013,7 +1013,7 @@
     UWORD32 u2_dest_wd_y, u2_dest_wd_uv;
     UWORD32 u2_row_buf_wd_y = 0;
     UWORD32 u2_row_buf_wd_uv = 0;
-    UWORD32 u2_log2Y_crwd = ps_dec->ps_cur_slice->u2_log2Y_crwd;
+    UWORD32 u2_log2Y_crwd;
     UWORD32 u4_wd_y, u4_ht_y, u1_dir, u4_wd_uv;
     UWORD32 u4_ht_uv;
     UWORD8 *pu1_temp_mc_buffer = ps_dec->pu1_temp_mc_buffer;
@@ -1039,8 +1039,7 @@
     ps_pred_y_back = ps_pred;
     ps_pred_cr_forw = ps_pred;
 
-    if(ps_dec->u1_separate_parse)
-        u2_log2Y_crwd = ps_dec->ps_decode_cur_slice->u2_log2Y_crwd;
+    u2_log2Y_crwd = ps_dec->ps_decode_cur_slice->u2_log2Y_crwd;
 
     if(!u1_pic_fld)
     {
diff --git a/decoder/ih264d_parse_pslice.c b/decoder/ih264d_parse_pslice.c
index c712ed5..dfd1ba8 100644
--- a/decoder/ih264d_parse_pslice.c
+++ b/decoder/ih264d_parse_pslice.c
@@ -1489,10 +1489,27 @@
             if(ps_dec->ps_cur_pic != NULL)
                 poc = ps_dec->ps_cur_pic->i4_poc + 2;
 
-            j = 0;
+            j = -1;
             for(i = 0; i < MAX_NUM_PIC_PARAMS; i++)
+            {
                    if(ps_dec->ps_pps[i].u1_is_valid == TRUE)
-                       j = i;
+                   {
+                       if(ps_dec->ps_pps[i].ps_sps->u1_is_valid == TRUE)
+                       {
+                           j = i;
+                           break;
+                       }
+                   }
+            }
+
+            //if valid SPS PPS is not found return error
+            if(j == -1)
+            {
+                return ERROR_INV_SPS_PPS_T;
+            }
+
+            /* call ih264d_start_of_pic only if it was not called earlier*/
+            if(ps_dec->u4_pic_buf_got == 0)
             {
                 //initialize slice params required by ih264d_start_of_pic to valid values
                 ps_dec->ps_cur_slice->u1_slice_type = P_SLICE;
@@ -1563,7 +1580,8 @@
             && ps_parse_cur_slice == ps_dec->ps_parse_cur_slice)
         {
             // Slice data corrupted
-            u1_num_mbs = ps_dec->u4_num_mbs_cur_nmb;
+            // in the case of mbaff, conceal from the even mb.
+            u1_num_mbs = (ps_dec->u4_num_mbs_cur_nmb >> u1_mbaff ) << u1_mbaff;
 
             if(u1_num_mbs)
             {
diff --git a/decoder/ih264d_parse_slice.c b/decoder/ih264d_parse_slice.c
index 911b11d..05a82a6 100644
--- a/decoder/ih264d_parse_slice.c
+++ b/decoder/ih264d_parse_slice.c
@@ -441,6 +441,8 @@
             /*make first entry of list0 point to cur pic,so that if first Islice is in error, ref pic struct will have valid entries*/
             ps_dec->ps_ref_pic_buf_lx[0] = ps_dec->ps_dpb_mgr->ps_init_dpb[0];
             *(ps_dec->ps_dpb_mgr->ps_init_dpb[0][0]) = *ps_cur_pic;
+            /* Initialize for field reference as well */
+            *(ps_dec->ps_dpb_mgr->ps_init_dpb[0][MAX_REF_BUFS]) = *ps_cur_pic;
         }
 
         if(!ps_dec->ps_cur_pic)
@@ -1429,6 +1431,11 @@
         ps_dec->u2_cur_slice_num++;
     }
 
+    // in the case of single core increment ps_decode_cur_slice
+    if((ps_dec->u1_separate_parse == 0) && (ps_dec->u4_first_slice_in_pic == 0))
+    {
+        ps_dec->ps_decode_cur_slice++;
+    }
     ps_dec->u1_slice_header_done = 0;
 
     /*--------------------------------------------------------------------*/