Merge cherrypicks of [3365569, 3365570, 3366860, 3366878, 3365571, 3365572, 3366918, 3365573, 3365589, 3365590, 3366938, 3366902, 3365574, 3365575, 3365576, 3365577, 3366958, 3365824, 3365591, 3366959, 3366960, 3366961, 3366962, 3366963, 3366964, 3366965, 3366919, 3366966, 3366967, 3366968, 3366969, 3366970, 3367018, 3367019, 3365592, 3365593, 3366985, 3365825, 3366988, 3366989, 3366990, 3366991, 3366992, 3366993, 3366994, 3367004, 3367005, 3367006, 3367007, 3367008, 3367009, 3367010, 3367011, 3367012, 3367013, 3367014, 3367015, 3367016, 3367017, 3367038, 3367039, 3367040, 3367041, 3367042, 3367044, 3367045, 3367046, 3367049, 3367050, 3367052, 3367053, 3367054, 3367055, 3367056, 3366920, 3366921, 3366922, 3367079] into oc-mr1-release

Change-Id: I8d674424df5fd0bf605d90b10e8b5011c6f6f29f
diff --git a/decoder/ihevcd_parse_headers.c b/decoder/ihevcd_parse_headers.c
index 578a429..a8daa3c 100644
--- a/decoder/ihevcd_parse_headers.c
+++ b/decoder/ihevcd_parse_headers.c
@@ -1350,12 +1350,6 @@
     if((0 >= ps_sps->i2_pic_width_in_luma_samples) || (0 >= ps_sps->i2_pic_height_in_luma_samples))
         return IHEVCD_INVALID_PARAMETER;
 
-    /* i2_pic_width_in_luma_samples and i2_pic_height_in_luma_samples
-       should be multiples of min_cb_size. Here these are aligned to 8,
-       i.e. smallest CB size */
-    ps_sps->i2_pic_width_in_luma_samples = ALIGN8(ps_sps->i2_pic_width_in_luma_samples);
-    ps_sps->i2_pic_height_in_luma_samples = ALIGN8(ps_sps->i2_pic_height_in_luma_samples);
-
     BITS_PARSE("pic_cropping_flag", value, ps_bitstrm, 1);
     ps_sps->i1_pic_cropping_flag = value;
 
@@ -1496,7 +1490,9 @@
                     (ps_sps->i1_log2_diff_max_min_transform_block_size < 0) ||
                     (ps_sps->i1_log2_max_transform_block_size > ps_sps->i1_log2_ctb_size) ||
                     (ps_sps->i1_log2_ctb_size < 4) ||
-                    (ps_sps->i1_log2_ctb_size > 6))
+                    (ps_sps->i1_log2_ctb_size > 6) ||
+                    (ps_sps->i2_pic_width_in_luma_samples % (1 << ps_sps->i1_log2_min_coding_block_size) != 0) ||
+                    (ps_sps->i2_pic_height_in_luma_samples % (1 << ps_sps->i1_log2_min_coding_block_size) != 0))
     {
         return IHEVCD_INVALID_PARAMETER;
     }
diff --git a/decoder/ihevcd_parse_slice.c b/decoder/ihevcd_parse_slice.c
index c1b067e..aedfbe7 100644
--- a/decoder/ihevcd_parse_slice.c
+++ b/decoder/ihevcd_parse_slice.c
@@ -3111,15 +3111,7 @@
                 UWORD32 *pu4_nbr_pu_idx = ps_proc->pu4_pic_pu_idx_map;
                 WORD32 nbr_pu_idx_strd = MAX_CTB_SIZE / MIN_PU_SIZE + 2;
                 pu_t *ps_pu;
-
-                for(row = 0; row < ctb_size / MIN_PU_SIZE; row++)
-                {
-                    for(col = 0; col < ctb_size / MIN_PU_SIZE; col++)
-                    {
-                        pu1_pic_pu_map_ctb[row * ctb_size / MIN_PU_SIZE + col] = 0;
-                    }
-                }
-
+                WORD32 ctb_size_in_min_pu = (ctb_size / MIN_PU_SIZE);
 
                 /* Neighbor PU idx update inside CTB */
                 /* 1byte per 4x4. Indicates the PU idx that 4x4 block belongs to */
@@ -3170,6 +3162,27 @@
 
                     }
                 }
+
+                /* Updating the CTB level PU idx (Used for collocated MV pred)*/
+                {
+                    WORD32 ctb_row, ctb_col, index_pic_map, index_nbr_map;
+                    WORD32 first_pu_of_ctb;
+                    first_pu_of_ctb = pu4_nbr_pu_idx[1 + nbr_pu_idx_strd];
+
+                    index_pic_map = 0 * ctb_size_in_min_pu + 0;
+                    index_nbr_map = (0 + 1) * nbr_pu_idx_strd + (0 + 1);
+
+                    for(ctb_row = 0; ctb_row < ctb_size_in_min_pu; ctb_row++)
+                    {
+                        for(ctb_col = 0; ctb_col < ctb_size_in_min_pu; ctb_col++)
+                        {
+                            pu1_pic_pu_map_ctb[index_pic_map + ctb_col] = pu4_nbr_pu_idx[index_nbr_map + ctb_col]
+                                            - first_pu_of_ctb;
+                        }
+                        index_pic_map += ctb_size_in_min_pu;
+                        index_nbr_map += nbr_pu_idx_strd;
+                    }
+                }
             }
 
             /*************************************************/
diff --git a/decoder/ihevcd_process_slice.c b/decoder/ihevcd_process_slice.c
index f57cc31..72db2cc 100644
--- a/decoder/ihevcd_process_slice.c
+++ b/decoder/ihevcd_process_slice.c
@@ -704,14 +704,8 @@
                     WORD32 row, col;
                     UWORD32 *pu4_nbr_pu_idx = ps_proc->pu4_pic_pu_idx_map;
                     WORD32 nbr_pu_idx_strd = MAX_CTB_SIZE / MIN_PU_SIZE + 2;
+                    WORD32 ctb_size_in_min_pu = (ctb_size / MIN_PU_SIZE);
 
-                    for(row = 0; row < ctb_size / MIN_PU_SIZE; row++)
-                    {
-                        for(col = 0; col < ctb_size / MIN_PU_SIZE; col++)
-                        {
-                            pu1_pic_pu_map_ctb[row * ctb_size / MIN_PU_SIZE + col] = 0;
-                        }
-                    }
                     /* Neighbor PU idx update inside CTB */
                     /* 1byte per 4x4. Indicates the PU idx that 4x4 block belongs to */
 
@@ -760,6 +754,27 @@
                                             pu4_nbr_pu_idx[(ctb_size_left / MIN_PU_SIZE) * nbr_pu_idx_strd + i + 1];
 
                         }
+
+                        /* Updating the CTB level PU idx (Used for collocated MV pred)*/
+                        {
+                            WORD32 ctb_row, ctb_col, index_pic_map, index_nbr_map;
+                            WORD32 first_pu_of_ctb;
+                            first_pu_of_ctb = pu4_nbr_pu_idx[1 + nbr_pu_idx_strd];
+
+                            index_pic_map = 0 * ctb_size_in_min_pu + 0;
+                            index_nbr_map = (0 + 1) * nbr_pu_idx_strd + (0 + 1);
+
+                            for(ctb_row = 0; ctb_row < ctb_size_in_min_pu; ctb_row++)
+                            {
+                                for(ctb_col = 0; ctb_col < ctb_size_in_min_pu; ctb_col++)
+                                {
+                                    pu1_pic_pu_map_ctb[index_pic_map + ctb_col] = pu4_nbr_pu_idx[index_nbr_map + ctb_col]
+                                                    - first_pu_of_ctb;
+                                }
+                                index_pic_map += ctb_size_in_min_pu;
+                                index_nbr_map += nbr_pu_idx_strd;
+                            }
+                        }
                     }
                 }
             }