Don't declare variables after statements

This fixes building with compilers that are strict about the pre-C99
rule about having all variable declarations before statements.

(The previous version of this commit was originally made before
the commit adding support for main profile, which added a bunch
more similar issues.)

Change-Id: I0a927deb2ef4125f79429d108439e249fa531607
diff --git a/encoder/ih264e_cabac_encode.c b/encoder/ih264e_cabac_encode.c
index ebcd418..bf3e88e 100644
--- a/encoder/ih264e_cabac_encode.c
+++ b/encoder/ih264e_cabac_encode.c
@@ -1206,11 +1206,13 @@
             }
             else
             {
+                UWORD8 u1_csbf;
+
                 PARSE_COEFF_DATA_BLOCK_4x4(pv_mb_coeff_data, ps_mb_coeff_data,
                                            u1_nnz, u2_sig_coeff_map,
                                            pi2_res_block);
 
-                UWORD8 u1_csbf = !!(u1_nnz);
+                u1_csbf = !!(u1_nnz);
                 {
                     UWORD8 u1_a, u1_b;
                     UWORD32 u4_ctx_inc;
diff --git a/encoder/ih264e_encode.c b/encoder/ih264e_encode.c
index c027321..d4d1090 100644
--- a/encoder/ih264e_encode.c
+++ b/encoder/ih264e_encode.c
@@ -393,16 +393,6 @@
     /* Only encode if the current frame is not pre-encode skip */
     if (!i4_rc_pre_enc_skip && s_inp_buf.s_raw_buf.apv_bufs[0])
     {
-        /* array giving pic cnt that is being processed in curr context set */
-        ps_codec->ai4_pic_cnt[ctxt_sel] = ps_codec->i4_pic_cnt;
-
-        /* initialize all relevant process ctxts */
-        error_status |= ih264e_pic_init(ps_codec, &s_inp_buf);
-        SET_ERROR_ON_RETURN(error_status,
-                            IVE_FATALERROR,
-                            ps_video_encode_op->s_ive_op.u4_error_code,
-                            IV_FAIL);
-
         /* proc ctxt base idx */
         WORD32 proc_ctxt_select = ctxt_sel * MAX_PROCESS_THREADS;
 
@@ -414,6 +404,16 @@
         /* number of addl. threads to be created */
         WORD32 num_thread_cnt = ps_codec->s_cfg.u4_num_cores - 1;
 
+        /* array giving pic cnt that is being processed in curr context set */
+        ps_codec->ai4_pic_cnt[ctxt_sel] = ps_codec->i4_pic_cnt;
+
+        /* initialize all relevant process ctxts */
+        error_status |= ih264e_pic_init(ps_codec, &s_inp_buf);
+        SET_ERROR_ON_RETURN(error_status,
+                            IVE_FATALERROR,
+                            ps_video_encode_op->s_ive_op.u4_error_code,
+                            IV_FAIL);
+
         for (i = 0; i < num_thread_cnt; i++)
         {
             ret = ithread_create(ps_codec->apv_proc_thread_handle[i],
diff --git a/encoder/ih264e_me.c b/encoder/ih264e_me.c
index 12a6f55..a97df3d 100644
--- a/encoder/ih264e_me.c
+++ b/encoder/ih264e_me.c
@@ -241,6 +241,9 @@
     WORD32 i4_srch_range_e = ps_me_ctxt->i4_srch_range_e;
     WORD32 i4_srch_range_w = ps_me_ctxt->i4_srch_range_w;
 
+    /* num of candidate search candidates */
+    UWORD32 u4_num_candidates = 0;
+
     ps_left_mv = &ps_proc->s_left_mb_pu_ME.s_me_info[i4_reflist].s_mv;
     ps_top_mv = &(ps_proc->ps_top_row_pu_ME + i4_mb_x)->s_me_info[i4_reflist].s_mv;
     ps_top_left_mv = &ps_proc->s_top_left_mb_pu_ME.s_me_info[i4_reflist].s_mv;
@@ -251,9 +254,6 @@
     i4_top_left_mode = ps_proc->s_top_left_mb_pu_ME.b2_pred_mode != i4_cmpl_predmode;
     i4_top_right_mode = (ps_proc->ps_top_row_pu_ME + i4_mb_x + 1)->b2_pred_mode != i4_cmpl_predmode;
 
-    /* num of candidate search candidates */
-    UWORD32 u4_num_candidates =0 ;
-
     /* Taking the Zero motion vector as one of the candidates   */
     ps_me_ctxt->as_mv_init_search[i4_reflist][u4_num_candidates].i2_mvx = 0;
     ps_me_ctxt->as_mv_init_search[i4_reflist][u4_num_candidates].i2_mvy = 0;
@@ -893,12 +893,12 @@
     /* quantization parameters */
     quant_params_t *ps_qp_params = ps_proc->ps_qp_params[0];
 
-    /* Sad therholds */
-    ps_me_ctxt->pu2_sad_thrsh = ps_qp_params->pu2_sad_thrsh;
-
     /* Mb part ctxts for SKIP */
     mb_part_ctxt s_skip_mbpart;
 
+    /* Sad therholds */
+    ps_me_ctxt->pu2_sad_thrsh = ps_qp_params->pu2_sad_thrsh;
+
     {
         WORD32 rows_above, rows_below, columns_left, columns_right;
 
@@ -1800,12 +1800,12 @@
     /* quantization parameters */
     quant_params_t *ps_qp_params = ps_proc->ps_qp_params[0];
 
-    /* Sad therholds */
-    ps_me_ctxt->pu2_sad_thrsh = ps_qp_params->pu2_sad_thrsh;
-
     /* Mb part ctxts for SKIP */
     mb_part_ctxt as_skip_mbpart[2];
 
+    /* Sad therholds */
+    ps_me_ctxt->pu2_sad_thrsh = ps_qp_params->pu2_sad_thrsh;
+
     {
         WORD32 rows_above, rows_below, columns_left, columns_right;