Use a separate field for the chroma stride

When both luma and chroma are copied to the local buffer (either
due to yuv format conversion, or due to padding), they have got
the same stride, but if chroma is copied while luma is used directly
from the input buffer, they might have different strides.

Therefore add a separate field for chroma stride.

This commit only adds the field, while it still has got the same
value as before.

Change-Id: I0dce97ad4d91cd1d9aba4b4472c6a0de45a314bc
diff --git a/encoder/ih264e_core_coding.c b/encoder/ih264e_core_coding.c
index 05a891d..76266d7 100644
--- a/encoder/ih264e_core_coding.c
+++ b/encoder/ih264e_core_coding.c
@@ -2022,7 +2022,7 @@
     WORD16 *pi2_res_mb = ps_proc->pi2_res_buf;
 
     /* strides */
-    WORD32 i4_src_strd = ps_proc->i4_src_strd;
+    WORD32 i4_src_strd = ps_proc->i4_src_chroma_strd;
     WORD32 i4_rec_strd = ps_proc->i4_rec_strd;
     WORD32 i4_pred_strd = ps_proc->i4_pred_strd;
     WORD32 i4_res_strd = ps_proc->i4_res_strd;
@@ -2284,7 +2284,7 @@
     WORD16 *pi2_res_mb = ps_proc->pi2_res_buf;
 
     /* strides */
-    WORD32 i4_src_strd = ps_proc->i4_src_strd;
+    WORD32 i4_src_strd = ps_proc->i4_src_chroma_strd;
     WORD32 i4_rec_strd = ps_proc->i4_rec_strd;
     WORD32 i4_pred_strd = ps_proc->i4_pred_strd;
     WORD32 i4_res_strd = ps_proc->i4_res_strd;
diff --git a/encoder/ih264e_intra_modes_eval.c b/encoder/ih264e_intra_modes_eval.c
index 74adbbc..52b3034 100644
--- a/encoder/ih264e_intra_modes_eval.c
+++ b/encoder/ih264e_intra_modes_eval.c
@@ -1318,7 +1318,7 @@
     UWORD8 *pu1_pred_mb_plane = ps_proc->pu1_pred_mb_intra_chroma_plane;
 
     /* strides */
-    WORD32 i4_src_strd_c = ps_proc->i4_src_strd;
+    WORD32 i4_src_strd_c = ps_proc->i4_src_chroma_strd;
     WORD32 i4_pred_strd = ps_proc->i4_pred_strd;
     WORD32 i4_rec_strd_c = ps_proc->i4_rec_strd;
 
diff --git a/encoder/ih264e_process.c b/encoder/ih264e_process.c
index aa84af6..ff48f7e 100644
--- a/encoder/ih264e_process.c
+++ b/encoder/ih264e_process.c
@@ -1150,6 +1150,7 @@
 
     /* strides */
     WORD32 i4_src_strd = ps_proc->i4_src_strd;
+    WORD32 i4_src_chroma_strd = ps_proc->i4_src_chroma_strd;
     WORD32 i4_rec_strd = ps_proc->i4_rec_strd;
 
     /* quant params */
@@ -1209,7 +1210,7 @@
     }
     else
     {
-        ps_proc->pu1_src_buf_chroma = ps_proc->pu1_src_buf_chroma_base + (i4_mb_x * MB_SIZE) + i4_src_strd * (i4_mb_y * BLK8x8SIZE);
+        ps_proc->pu1_src_buf_chroma = ps_proc->pu1_src_buf_chroma_base + (i4_mb_x * MB_SIZE) + i4_src_chroma_strd * (i4_mb_y * BLK8x8SIZE);
     }
 
     ps_proc->pu1_rec_buf_luma = ps_proc->pu1_rec_buf_luma_base + (i4_mb_x * MB_SIZE) + i4_rec_strd * (i4_mb_y * MB_SIZE);
@@ -1261,7 +1262,7 @@
                 {
                     memcpy(pu1_dst, pu1_src, ps_codec->s_cfg.u4_wd);
                     pu1_src += ps_proc->s_inp_buf.s_raw_buf.au4_strd[1];
-                    pu1_dst += ps_proc->i4_src_strd;
+                    pu1_dst += ps_proc->i4_src_chroma_strd;
                 }
 
             }
@@ -1285,7 +1286,7 @@
                             ps_proc->s_inp_buf.s_raw_buf.au4_strd[0],
                             ps_proc->s_inp_buf.s_raw_buf.au4_strd[1],
                             ps_proc->s_inp_buf.s_raw_buf.au4_strd[2],
-                            ps_proc->i4_src_strd, ps_proc->i4_src_strd,
+                            ps_proc->i4_src_strd, ps_proc->i4_src_chroma_strd,
                             convert_uv_only);
             break;
 
@@ -1298,8 +1299,8 @@
                             ps_proc->pu1_src_buf_chroma,
                             ps_proc->pu1_src_buf_chroma + 1, pu1_y_buf_base,
                             ps_codec->s_cfg.u4_disp_wd, u2_num_rows,
-                            ps_proc->i4_src_strd, ps_proc->i4_src_strd,
-                            ps_proc->i4_src_strd,
+                            ps_proc->i4_src_strd, ps_proc->i4_src_chroma_strd,
+                            ps_proc->i4_src_chroma_strd,
                             ps_proc->s_inp_buf.s_raw_buf.au4_strd[0] >> 1);
             break;
 
@@ -1323,7 +1324,7 @@
 
         ih264_pad_right_chroma(
                         ps_proc->pu1_src_buf_chroma + ps_codec->s_cfg.u4_disp_wd,
-                        ps_proc->i4_src_strd, u4_pad_ht / 2, u4_pad_wd);
+                        ps_proc->i4_src_chroma_strd, u4_pad_ht / 2, u4_pad_wd);
     }
 
     /* pad bottom edge */
@@ -1332,8 +1333,8 @@
         ih264_pad_bottom(ps_proc->pu1_src_buf_luma + (MB_SIZE - u4_pad_bottom_sz) * ps_proc->i4_src_strd,
                          ps_proc->i4_src_strd, ps_proc->i4_src_strd, u4_pad_bottom_sz);
 
-        ih264_pad_bottom(ps_proc->pu1_src_buf_chroma + (MB_SIZE - u4_pad_bottom_sz) * ps_proc->i4_src_strd / 2,
-                         ps_proc->i4_src_strd, ps_proc->i4_src_strd, (u4_pad_bottom_sz / 2));
+        ih264_pad_bottom(ps_proc->pu1_src_buf_chroma + (MB_SIZE - u4_pad_bottom_sz) * ps_proc->i4_src_chroma_strd / 2,
+                         ps_proc->i4_src_chroma_strd, ps_proc->i4_src_chroma_strd, (u4_pad_bottom_sz / 2));
     }
 
 
diff --git a/encoder/ih264e_structs.h b/encoder/ih264e_structs.h
index 80f2957..28d907c 100644
--- a/encoder/ih264e_structs.h
+++ b/encoder/ih264e_structs.h
@@ -1313,12 +1313,16 @@
     mb_info_nmb_t *ps_cur_mb;
 
     /**
-     * source stride
-     * (strides for luma and chroma are the same)
+     * source luma stride
      */
     WORD32 i4_src_strd;
 
     /**
+     * source chroma stride
+     */
+    WORD32 i4_src_chroma_strd;
+
+    /**
      * recon stride & ref stride
      * (strides for luma and chroma are the same)
      */
diff --git a/encoder/ih264e_utils.c b/encoder/ih264e_utils.c
index 74fd001..f48be5b 100644
--- a/encoder/ih264e_utils.c
+++ b/encoder/ih264e_utils.c
@@ -1731,6 +1731,7 @@
 
             /* src stride */
             ps_proc->i4_src_strd = ps_codec->i4_src_strd;
+            ps_proc->i4_src_chroma_strd = ps_codec->i4_src_strd;
 
             /* rec stride */
             ps_proc->i4_rec_strd = ps_codec->i4_rec_strd;