diff --git a/vp9/common/blockd.h b/vp9/common/blockd.h
index 0b1fd46b4d7a3da0fef3f7b8c88bda92458228d6..65e1e99172e779504bb922b59c66a4e09e4b10ee 100644
--- a/vp9/common/blockd.h
+++ b/vp9/common/blockd.h
@@ -483,7 +483,7 @@ static TX_TYPE get_tx_type_16x16(const MACROBLOCKD *xd, const BLOCKD *b) {
 
 static TX_TYPE get_tx_type(const MACROBLOCKD *xd, const BLOCKD *b) {
   TX_TYPE tx_type = DCT_DCT;
-  int ib = (b - xd->block);
+  int ib = (int)(b - xd->block);
   if (ib >= 16)
     return tx_type;
   if (xd->mode_info_context->mbmi.txfm_size == TX_16X16) {
diff --git a/vp9/common/quant_common.c b/vp9/common/quant_common.c
index 8c3f42732212581c3c3b276be8d273149e53f363..720b271134b9334f650bfbd0824eba34322dd6fd 100644
--- a/vp9/common/quant_common.c
+++ b/vp9/common/quant_common.c
@@ -30,9 +30,9 @@ void vp9_init_quant_tables() {
     last_val = current_val;
 
     ac_val = ac_qlookup[i];
-    dc_qlookup[i] = (0.000000305 * ac_val * ac_val * ac_val) +
-                    (-0.00065 * ac_val * ac_val) +
-                    (0.9 * ac_val) + 0.5;
+    dc_qlookup[i] = (int)((0.000000305 * ac_val * ac_val * ac_val) +
+                          (-0.00065 * ac_val * ac_val) +
+                          (0.9 * ac_val) + 0.5);
     if (dc_qlookup[i] < ACDC_MIN)
       dc_qlookup[i] = ACDC_MIN;
   }
diff --git a/vp9/decoder/dboolhuff.h b/vp9/decoder/dboolhuff.h
index 285d2a9363308967595e2acf264cef4f29518389..d46d81bb4974d8ad2915a613e2480759c028b3ed 100644
--- a/vp9/decoder/dboolhuff.h
+++ b/vp9/decoder/dboolhuff.h
@@ -56,7 +56,7 @@ int vp9_inv_recenter_nonneg(int v, int m);
   { \
     int shift = VP9_BD_VALUE_SIZE - 8 - ((_count) + 8); \
     int loop_end, x; \
-    size_t bits_left = ((_bufend)-(_bufptr))*CHAR_BIT; \
+    int bits_left = (int)(((_bufend)-(_bufptr))*CHAR_BIT); \
     \
     x = shift + CHAR_BIT - bits_left; \
     loop_end = 0; \
diff --git a/vp9/decoder/decodemv.c b/vp9/decoder/decodemv.c
index c4ff898e8a6fe6264e9a3075d8ba063e94746b80..a299b5dffba97a9aeb5d65818417be1fabbf047c 100644
--- a/vp9/decoder/decodemv.c
+++ b/vp9/decoder/decodemv.c
@@ -654,7 +654,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
   const int mis = pbi->common.mode_info_stride;
   MACROBLOCKD *const xd  = &pbi->mb;
 
-  int_mv *const mv = &mbmi->mv;
+  int_mv *const mv = &mbmi->mv[0];
   int mb_to_left_edge;
   int mb_to_right_edge;
   int mb_to_top_edge;
@@ -1172,7 +1172,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
   }
 }
 
-void vp9_decode_mode_mvs_init(VP9D_COMP *pbi, BOOL_DECODER* const bc) {
+void vp9_decode_mode_mvs_init(VP9D_COMP* const pbi, BOOL_DECODER* const bc) {
   VP9_COMMON *cm = &pbi->common;
 
   vpx_memset(cm->mbskip_pred_probs, 0, sizeof(cm->mbskip_pred_probs));
@@ -1184,8 +1184,8 @@ void vp9_decode_mode_mvs_init(VP9D_COMP *pbi, BOOL_DECODER* const bc) {
 
   mb_mode_mv_init(pbi, bc);
 }
-void vp9_decode_mb_mode_mv(VP9D_COMP *pbi,
-                           MACROBLOCKD *xd,
+void vp9_decode_mb_mode_mv(VP9D_COMP* const pbi,
+                           MACROBLOCKD* const xd,
                            int mb_row,
                            int mb_col,
                            BOOL_DECODER* const bc) {
diff --git a/vp9/decoder/decodframe.c b/vp9/decoder/decodframe.c
index 9c25afb687357eabcac324b878de81f543a781a4..60bf7bacab1ae9b96ca603077c04d0aec9876326 100644
--- a/vp9/decoder/decodframe.c
+++ b/vp9/decoder/decodframe.c
@@ -729,7 +729,8 @@ static void setup_token_decoder(VP9D_COMP *pbi,
                        "%d length", 1);
   }
 
-  if (vp9_start_decode(bool_decoder, partition, partition_size))
+  if (vp9_start_decode(bool_decoder,
+                       partition, (unsigned int)partition_size))
     vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
                        "Failed to allocate bool decoder %d", 1);
 }
@@ -986,7 +987,8 @@ int vp9_decode_frame(VP9D_COMP *pbi) {
 
   init_frame(pbi);
 
-  if (vp9_start_decode(&header_bc, data, first_partition_length_in_bytes))
+  if (vp9_start_decode(&header_bc, data,
+                       (unsigned int)first_partition_length_in_bytes))
     vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
                        "Failed to allocate bool decoder 0");
   if (pc->frame_type == KEY_FRAME) {
diff --git a/vp9/decoder/detokenize.c b/vp9/decoder/detokenize.c
index 62511f0b43a7031dde02cde31eb53bea4b9ed832..68f2c283a76901c5d3444960b07675b61351bfae 100644
--- a/vp9/decoder/detokenize.c
+++ b/vp9/decoder/detokenize.c
@@ -98,7 +98,7 @@ DECLARE_ALIGNED(16, static const int, coef_bands_x_16x16[256]) = {
 static const unsigned char cat6_prob[14] =
 { 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0 };
 
-void vp9_reset_mb_tokens_context(MACROBLOCKD *xd) {
+void vp9_reset_mb_tokens_context(MACROBLOCKD* const xd) {
   /* Clear entropy contexts for Y2 blocks */
   if ((xd->mode_info_context->mbmi.mode != B_PRED &&
       xd->mode_info_context->mbmi.mode != I8X8_PRED &&
@@ -414,7 +414,8 @@ SKIP_START:
   return c;
 }
 
-int vp9_decode_mb_tokens_16x16(VP9D_COMP *pbi, MACROBLOCKD *xd,
+int vp9_decode_mb_tokens_16x16(VP9D_COMP* const pbi,
+                               MACROBLOCKD* const xd,
                                BOOL_DECODER* const bc) {
   ENTROPY_CONTEXT* const A = (ENTROPY_CONTEXT *)xd->above_context;
   ENTROPY_CONTEXT* const L = (ENTROPY_CONTEXT *)xd->left_context;
@@ -477,7 +478,8 @@ int vp9_decode_mb_tokens_16x16(VP9D_COMP *pbi, MACROBLOCKD *xd,
   return eobtotal;
 }
 
-int vp9_decode_mb_tokens_8x8(VP9D_COMP *pbi, MACROBLOCKD *xd,
+int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi,
+                             MACROBLOCKD* const xd,
                              BOOL_DECODER* const bc) {
   ENTROPY_CONTEXT *const A = (ENTROPY_CONTEXT *)xd->above_context;
   ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
@@ -571,7 +573,8 @@ int vp9_decode_mb_tokens_8x8(VP9D_COMP *pbi, MACROBLOCKD *xd,
 }
 
 
-int vp9_decode_mb_tokens(VP9D_COMP *dx, MACROBLOCKD *xd,
+int vp9_decode_mb_tokens(VP9D_COMP* const dx,
+                         MACROBLOCKD* const xd,
                          BOOL_DECODER* const bc) {
   ENTROPY_CONTEXT *const A = (ENTROPY_CONTEXT *)xd->above_context;
   ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
diff --git a/vp9/encoder/bitstream.c b/vp9/encoder/bitstream.c
index 747434414408d4a8ec1bac1463dbab249836f835..f6046dcc146ebf66ce3c290132d9d8d81fdffa2b 100644
--- a/vp9/encoder/bitstream.c
+++ b/vp9/encoder/bitstream.c
@@ -218,7 +218,6 @@ static void update_switchable_interp_probs(VP9_COMP *cpi,
 static void update_refpred_stats(VP9_COMP *cpi) {
   VP9_COMMON *const cm = &cpi->common;
   int i;
-  int tot_count;
   vp9_prob new_pred_probs[PREDICTION_PROBS];
   int old_cost, new_cost;
 
@@ -884,7 +883,6 @@ static void update_ref_probs(VP9_COMP *const cpi) {
 }
 
 static void pack_inter_mode_mvs(VP9_COMP *const cpi, vp9_writer *const bc) {
-  int i;
   VP9_COMMON *const pc = &cpi->common;
   const nmv_context *nmvc = &pc->fc.nmvc;
   MACROBLOCK *x = &cpi->mb;
diff --git a/vp9/encoder/encodeframe.c b/vp9/encoder/encodeframe.c
index 22fcc6b0a3d7243585597a294b761932b2bf6ca1..94fa2f2658d3a7e7ff552d85358c690f004b238e 100644
--- a/vp9/encoder/encodeframe.c
+++ b/vp9/encoder/encodeframe.c
@@ -1390,7 +1390,7 @@ static void encode_frame_internal(VP9_COMP *cpi) {
         x->src.v_buffer += 16 * x->src.uv_stride - 8 * offset;
       }
 
-      cpi->tok_count = tp - cpi->tok;
+      cpi->tok_count = (unsigned int)(tp - cpi->tok);
     }
 
     vpx_usec_timer_mark(&emr_timer);
@@ -1578,7 +1578,7 @@ void vp9_encode_frame(VP9_COMP *cpi) {
     encode_frame_internal(cpi);
 
     for (i = 0; i < NB_PREDICTION_TYPES; ++i) {
-      const int diff = cpi->rd_comp_pred_diff[i] / cpi->common.MBs;
+      const int diff = (int)(cpi->rd_comp_pred_diff[i] / cpi->common.MBs);
       cpi->rd_prediction_type_threshes[frame_type][i] += diff;
       cpi->rd_prediction_type_threshes[frame_type][i] >>= 1;
     }
@@ -1588,7 +1588,7 @@ void vp9_encode_frame(VP9_COMP *cpi) {
       int diff;
       if (i == TX_MODE_SELECT)
         pd -= RDCOST(cpi->mb.rdmult, cpi->mb.rddiv, 2048 * (TX_SIZE_MAX - 1), 0);
-      diff = pd / cpi->common.MBs;
+      diff = (int)(pd / cpi->common.MBs);
       cpi->rd_tx_select_threshes[frame_type][i] += diff;
       cpi->rd_tx_select_threshes[frame_type][i] /= 2;
     }
diff --git a/vp9/encoder/encodemv.c b/vp9/encoder/encodemv.c
index 0483d81c7332c1b65600df65aef17ea829366e20..a9431bdee101d74c9accb4ed5b407adc069de9ec 100644
--- a/vp9/encoder/encodemv.c
+++ b/vp9/encoder/encodemv.c
@@ -168,7 +168,7 @@ static int update_nmv_savings(const unsigned int ct[2],
   if (cur_b - mod_b - cost > 0) {
     return cur_b - mod_b - cost;
   } else {
-    return -vp9_cost_zero(upd_p);
+    return 0 - vp9_cost_zero(upd_p);
   }
 }
 
diff --git a/vp9/encoder/encodemv.h b/vp9/encoder/encodemv.h
index f19613d0a1208debab6ee853f341e6da18b291d6..a35fabfdc19dea6c5f3f14f50053578d8f46a768 100644
--- a/vp9/encoder/encodemv.h
+++ b/vp9/encoder/encodemv.h
@@ -18,11 +18,11 @@ void vp9_write_nmvprobs(VP9_COMP* const, int usehp, vp9_writer* const);
 void vp9_encode_nmv(vp9_writer* const w, const MV* const mv,
                     const MV* const ref, const nmv_context* const mvctx);
 void vp9_encode_nmv_fp(vp9_writer* const w, const MV* const mv,
-                       const MV* const ref, const nmv_context *mvctx,
+                       const MV* const ref, const nmv_context* const mvctx,
                        int usehp);
 void vp9_build_nmv_cost_table(int *mvjoint,
                               int *mvcost[2],
-                              const nmv_context *mvctx,
+                              const nmv_context* const mvctx,
                               int usehp,
                               int mvc_flag_v,
                               int mvc_flag_h);
diff --git a/vp9/encoder/firstpass.c b/vp9/encoder/firstpass.c
index b57ce74678fabf625acd264806775bcef4e44f1e..0238232656e6aca69a0f5c96578a51c6dc6ba189 100644
--- a/vp9/encoder/firstpass.c
+++ b/vp9/encoder/firstpass.c
@@ -696,9 +696,9 @@ void vp9_first_pass(VP9_COMP *cpi) {
     FIRSTPASS_STATS fps;
 
     fps.frame      = cm->current_video_frame;
-    fps.intra_error = intra_error >> 8;
-    fps.coded_error = coded_error >> 8;
-    fps.sr_coded_error = sr_coded_error >> 8;
+    fps.intra_error = (double)(intra_error >> 8);
+    fps.coded_error = (double)(coded_error >> 8);
+    fps.sr_coded_error = (double)(sr_coded_error >> 8);
     weight = simple_weight(cpi->Source);
 
 
@@ -738,8 +738,8 @@ void vp9_first_pass(VP9_COMP *cpi) {
 
     // TODO:  handle the case when duration is set to 0, or something less
     // than the full time between subsequent cpi->source_time_stamp s  .
-    fps.duration = cpi->source->ts_end
-                   - cpi->source->ts_start;
+    fps.duration = (double)(cpi->source->ts_end
+                            - cpi->source->ts_start);
 
     // don't want to do output stats with a stack variable!
     memcpy(cpi->twopass.this_frame_stats,
@@ -901,7 +901,7 @@ static int estimate_max_q(VP9_COMP *cpi,
   double err_per_mb = section_err / num_mbs;
   double err_correction_factor;
   double speed_correction = 1.0;
-  int overhead_bits_per_mb;
+  double overhead_bits_per_mb;
 
   if (section_target_bandwitdh <= 0)
     return cpi->twopass.maxq_max_limit;          // Highest value allowed
@@ -976,7 +976,7 @@ static int estimate_max_q(VP9_COMP *cpi,
       err_correction_factor = 5.0;
 
     bits_per_mb_at_this_q =
-      vp9_bits_per_mb(INTER_FRAME, Q) + overhead_bits_per_mb;
+      vp9_bits_per_mb(INTER_FRAME, Q) + (int)overhead_bits_per_mb;
 
     bits_per_mb_at_this_q = (int)(.5 + err_correction_factor *
                                   (double)bits_per_mb_at_this_q);
@@ -1003,7 +1003,7 @@ static int estimate_max_q(VP9_COMP *cpi,
   // Give average a chance to settle though.
   // PGW TODO.. This code is broken for the extended Q range
   if ((cpi->ni_frames >
-       ((unsigned int)cpi->twopass.total_stats->count >> 8)) &&
+       ((int)cpi->twopass.total_stats->count >> 8)) &&
       (cpi->ni_frames > 150)) {
     adjust_maxq_qrange(cpi);
   }
@@ -1029,7 +1029,7 @@ static int estimate_cq(VP9_COMP *cpi,
   double speed_correction = 1.0;
   double clip_iiratio;
   double clip_iifactor;
-  int overhead_bits_per_mb;
+  double overhead_bits_per_mb;
 
 
   target_norm_bits_per_mb = (section_target_bandwitdh < (1 << 20))
@@ -1082,7 +1082,7 @@ static int estimate_cq(VP9_COMP *cpi,
       err_correction_factor = 5.0;
 
     bits_per_mb_at_this_q =
-      vp9_bits_per_mb(INTER_FRAME, Q) + overhead_bits_per_mb;
+      vp9_bits_per_mb(INTER_FRAME, Q) + (int)overhead_bits_per_mb;
 
     bits_per_mb_at_this_q = (int)(.5 + err_correction_factor *
                                   (double)bits_per_mb_at_this_q);
@@ -1417,7 +1417,7 @@ static int calc_arf_boost(
                     calc_frame_boost(cpi, &this_frame, this_frame_mv_in_out));
   }
 
-  *f_boost = boost_score;
+  *f_boost = (int)boost_score;
 
   // Reset for backward looking loop
   boost_score = 0.0;
@@ -1455,7 +1455,7 @@ static int calc_arf_boost(
                     calc_frame_boost(cpi, &this_frame, this_frame_mv_in_out));
 
   }
-  *b_boost = boost_score;
+  *b_boost = (int)boost_score;
 
   arf_boost = (*f_boost + *b_boost);
   if (arf_boost < ((b_frames + f_frames) * 20))
@@ -1477,8 +1477,8 @@ static void configure_arnr_filter(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
   // Note: this_frame->frame has been updated in the loop
   // so it now points at the ARF frame.
   half_gf_int = cpi->baseline_gf_interval >> 1;
-  frames_after_arf = cpi->twopass.total_stats->count -
-                     this_frame->frame - 1;
+  frames_after_arf = (int)(cpi->twopass.total_stats->count -
+                           this_frame->frame - 1);
 
   switch (cpi->oxcf.arnr_type) {
     case 1: // Backward filter
@@ -1701,7 +1701,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
       (cpi->twopass.kf_group_error_left > 0)) {
     cpi->twopass.gf_group_bits =
       (int)((double)cpi->twopass.kf_group_bits *
-            (gf_group_err / (double)cpi->twopass.kf_group_error_left));
+            (gf_group_err / cpi->twopass.kf_group_error_left));
   } else
     cpi->twopass.gf_group_bits = 0;
 
@@ -1767,7 +1767,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
       alt_gf_grp_bits =
         (double)cpi->twopass.kf_group_bits  *
         (mod_frame_err * (double)cpi->baseline_gf_interval) /
-        DOUBLE_DIVIDE_CHECK((double)cpi->twopass.kf_group_error_left);
+        DOUBLE_DIVIDE_CHECK(cpi->twopass.kf_group_error_left);
 
       alt_gf_bits = (int)((double)boost * (alt_gf_grp_bits /
                                            (double)allocation_chunks));
@@ -1783,7 +1783,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
       int alt_gf_bits =
         (int)((double)cpi->twopass.kf_group_bits *
               mod_frame_err /
-              DOUBLE_DIVIDE_CHECK((double)cpi->twopass.kf_group_error_left));
+              DOUBLE_DIVIDE_CHECK(cpi->twopass.kf_group_error_left));
 
       if (alt_gf_bits > gf_bits) {
         gf_bits = alt_gf_bits;
@@ -1806,7 +1806,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
 
   {
     // Adjust KF group bits and error remainin
-    cpi->twopass.kf_group_error_left -= gf_group_err;
+    cpi->twopass.kf_group_error_left -= (int64_t)gf_group_err;
     cpi->twopass.kf_group_bits -= cpi->twopass.gf_group_bits;
 
     if (cpi->twopass.kf_group_bits < 0)
@@ -1817,9 +1817,10 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
     // of the group (except in Key frame case where this has already
     // happened)
     if (!cpi->source_alt_ref_pending && cpi->common.frame_type != KEY_FRAME)
-      cpi->twopass.gf_group_error_left = gf_group_err - gf_first_frame_err;
+      cpi->twopass.gf_group_error_left = (int64_t)(gf_group_err
+                                                   - gf_first_frame_err);
     else
-      cpi->twopass.gf_group_error_left = gf_group_err;
+      cpi->twopass.gf_group_error_left = (int64_t)gf_group_err;
 
     cpi->twopass.gf_group_bits -= cpi->twopass.gf_bits - cpi->min_frame_bandwidth;
 
@@ -1839,8 +1840,8 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
         pct_extra = (boost - 100) / 50;
         pct_extra = (pct_extra > 20) ? 20 : pct_extra;
 
-        cpi->twopass.alt_extra_bits =
-          (cpi->twopass.gf_group_bits * pct_extra) / 100;
+        cpi->twopass.alt_extra_bits = (int)
+          ((cpi->twopass.gf_group_bits * pct_extra) / 100);
         cpi->twopass.gf_group_bits -= cpi->twopass.alt_extra_bits;
         cpi->twopass.alt_extra_bits /=
           ((cpi->baseline_gf_interval - 1) >> 1);
@@ -1863,9 +1864,9 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
 
     avg_stats(&sectionstats);
 
-    cpi->twopass.section_intra_rating =
-      sectionstats.intra_error /
-      DOUBLE_DIVIDE_CHECK(sectionstats.coded_error);
+    cpi->twopass.section_intra_rating = (int)
+      (sectionstats.intra_error /
+      DOUBLE_DIVIDE_CHECK(sectionstats.coded_error));
 
     reset_fpf_position(cpi, start_pos);
   }
@@ -1898,10 +1899,11 @@ static void assign_std_frame_bits(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
       target_frame_size = max_bits;
 
     if (target_frame_size > cpi->twopass.gf_group_bits)
-      target_frame_size = cpi->twopass.gf_group_bits;
+      target_frame_size = (int)cpi->twopass.gf_group_bits;
   }
 
-  cpi->twopass.gf_group_error_left -= modified_err;                                               // Adjust error remaining
+  // Adjust error remaining
+  cpi->twopass.gf_group_error_left -= (int64_t)modified_err;
   cpi->twopass.gf_group_bits -= target_frame_size;                                                // Adjust bits remaining
 
   if (cpi->twopass.gf_group_bits < 0)
@@ -2010,25 +2012,26 @@ void vp9_second_pass(VP9_COMP *cpi) {
   }
 
   // Keep a globally available copy of this and the next frame's iiratio.
-  cpi->twopass.this_iiratio = this_frame_intra_error /
-                              DOUBLE_DIVIDE_CHECK(this_frame_coded_error);
+  cpi->twopass.this_iiratio = (int)(this_frame_intra_error /
+                              DOUBLE_DIVIDE_CHECK(this_frame_coded_error));
   {
     FIRSTPASS_STATS next_frame;
     if (lookup_next_frame_stats(cpi, &next_frame) != EOF) {
-      cpi->twopass.next_iiratio = next_frame.intra_error /
-                                  DOUBLE_DIVIDE_CHECK(next_frame.coded_error);
+      cpi->twopass.next_iiratio = (int)(next_frame.intra_error /
+                                  DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
     }
   }
 
   // Set nominal per second bandwidth for this frame
-  cpi->target_bandwidth = cpi->per_frame_bandwidth * cpi->output_frame_rate;
+  cpi->target_bandwidth = (int)(cpi->per_frame_bandwidth
+                                * cpi->output_frame_rate);
   if (cpi->target_bandwidth < 0)
     cpi->target_bandwidth = 0;
 
 
   // Account for mv, mode and other overheads.
-  overhead_bits = estimate_modemvcost(
-                    cpi, cpi->twopass.total_left_stats);
+  overhead_bits = (int)estimate_modemvcost(
+                        cpi, cpi->twopass.total_left_stats);
 
   // Special case code for first frame.
   if (cpi->common.current_video_frame == 0) {
@@ -2418,9 +2421,9 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
 
     avg_stats(&sectionstats);
 
-    cpi->twopass.section_intra_rating =
-      sectionstats.intra_error
-      / DOUBLE_DIVIDE_CHECK(sectionstats.coded_error);
+    cpi->twopass.section_intra_rating = (int)
+      (sectionstats.intra_error
+      / DOUBLE_DIVIDE_CHECK(sectionstats.coded_error));
   }
 
   // Reset the first pass file position
@@ -2428,7 +2431,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
 
   // Work out how many bits to allocate for the key frame itself
   if (1) {
-    int kf_boost = boost_score;
+    int kf_boost = (int)boost_score;
     int allocation_chunks;
     int alt_kf_bits;
 
@@ -2510,10 +2513,14 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
     }
 
     cpi->twopass.kf_group_bits -= cpi->twopass.kf_bits;
-    cpi->twopass.kf_bits += cpi->min_frame_bandwidth;                                          // Add in the minimum frame allowance
-
-    cpi->per_frame_bandwidth = cpi->twopass.kf_bits;                                           // Peer frame bit target for this frame
-    cpi->target_bandwidth = cpi->twopass.kf_bits * cpi->output_frame_rate;                      // Convert to a per second bitrate
+    // Add in the minimum frame allowance
+    cpi->twopass.kf_bits += cpi->min_frame_bandwidth;
+
+    // Peer frame bit target for this frame
+    cpi->per_frame_bandwidth = cpi->twopass.kf_bits;
+    // Convert to a per second bitrate
+    cpi->target_bandwidth = (int)(cpi->twopass.kf_bits *
+                                  cpi->output_frame_rate);
   }
 
   // Note the total error score of the kf group minus the key frame itself
diff --git a/vp9/encoder/lookahead.c b/vp9/encoder/lookahead.c
index ca0b4cdf4e4876dbf2de9f57d46f1a91261dc213..c10fecd47978e9f277d505a2755812b5edddee3c 100644
--- a/vp9/encoder/lookahead.c
+++ b/vp9/encoder/lookahead.c
@@ -43,7 +43,7 @@ void
 vp9_lookahead_destroy(struct lookahead_ctx *ctx) {
   if (ctx) {
     if (ctx->buf) {
-      int i;
+      unsigned int i;
 
       for (i = 0; i < ctx->max_sz; i++)
         vp8_yv12_de_alloc_frame_buffer(&ctx->buf[i].img);
@@ -59,7 +59,6 @@ vp9_lookahead_init(unsigned int width,
                    unsigned int height,
                    unsigned int depth) {
   struct lookahead_ctx *ctx = NULL;
-  int i;
 
   /* Clamp the lookahead queue depth */
   if (depth < 1)
@@ -74,6 +73,7 @@ vp9_lookahead_init(unsigned int width,
   /* Allocate the lookahead structures */
   ctx = calloc(1, sizeof(*ctx));
   if (ctx) {
+    unsigned int i;
     ctx->max_sz = depth;
     ctx->buf = calloc(depth, sizeof(*ctx->buf));
     if (!ctx->buf)
@@ -175,9 +175,9 @@ vp9_lookahead_peek(struct lookahead_ctx *ctx,
   struct lookahead_entry *buf = NULL;
 
   assert(index < ctx->max_sz);
-  if (index < ctx->sz) {
+  if (index < (int)ctx->sz) {
     index += ctx->read_idx;
-    if (index >= ctx->max_sz)
+    if (index >= (int)ctx->max_sz)
       index -= ctx->max_sz;
     buf = ctx->buf + index;
   }
diff --git a/vp9/encoder/mbgraph.c b/vp9/encoder/mbgraph.c
index 301826e500427b450c2466180c9e05ae8ec8bffd..e7506168fc7ada4e0aaf5cca66e796c1841f7a0b 100644
--- a/vp9/encoder/mbgraph.c
+++ b/vp9/encoder/mbgraph.c
@@ -139,7 +139,7 @@ static int do_16x16_motion_search
 
   // If the current best reference mv is not centred on 0,0 then do a 0,0 based search as well
   if (ref_mv->as_int) {
-    int tmp_err;
+    unsigned int tmp_err;
     int_mv zero_ref_mv, tmp_mv;
 
     zero_ref_mv.as_int = 0;
@@ -202,7 +202,7 @@ static int find_best_16x16_intra
   MACROBLOCK   *const x  = &cpi->mb;
   MACROBLOCKD *const xd = &x->e_mbd;
   MB_PREDICTION_MODE best_mode = -1, mode;
-  int best_err = INT_MAX;
+  unsigned int best_err = INT_MAX;
 
   // calculate SATD for each intra prediction mode;
   // we're intentionally not doing 4x4, we just want a rough estimate
@@ -449,7 +449,7 @@ void vp9_update_mbgraph_stats
   // being a GF - so exit if we don't look ahead beyond that
   if (n_frames <= cpi->frames_till_gf_update_due)
     return;
-  if (n_frames > cpi->common.frames_till_alt_ref_frame)
+  if (n_frames > (int)cpi->common.frames_till_alt_ref_frame)
     n_frames = cpi->common.frames_till_alt_ref_frame;
   if (n_frames > MAX_LAG_BUFFERS)
     n_frames = MAX_LAG_BUFFERS;
diff --git a/vp9/encoder/mcomp.c b/vp9/encoder/mcomp.c
index 60ec49c95039628d79fcca5dd27555073da51738..50e7cde7c683a86e40cf45cadb22c026b3cbb5ca 100644
--- a/vp9/encoder/mcomp.c
+++ b/vp9/encoder/mcomp.c
@@ -1380,7 +1380,7 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
   int tot_steps;
   int_mv this_mv;
 
-  int bestsad = INT_MAX;
+  unsigned int bestsad = INT_MAX;
   int best_site = 0;
   int last_site = 0;
 
@@ -1674,7 +1674,7 @@ int vp9_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
   unsigned char *bestaddress;
   int_mv *best_mv = &d->bmi.as_mv.first;
   int_mv this_mv;
-  int bestsad = INT_MAX;
+  unsigned int bestsad = INT_MAX;
   int r, c;
 
   unsigned char *check_here;
@@ -1802,7 +1802,7 @@ int vp9_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
   unsigned char *bestaddress;
   int_mv *best_mv = &d->bmi.as_mv.first;
   int_mv this_mv;
-  int bestsad = INT_MAX;
+  unsigned int bestsad = INT_MAX;
   int r, c;
 
   unsigned char *check_here;
diff --git a/vp9/encoder/onyx_if.c b/vp9/encoder/onyx_if.c
index 02a3b052645ec985ab7a24ca8e3a8491e4434b76..e655bbb178e682d60af94b626c2ebf9dc2e6f397 100644
--- a/vp9/encoder/onyx_if.c
+++ b/vp9/encoder/onyx_if.c
@@ -244,14 +244,14 @@ static void init_base_skip_probs(void) {
       skip_prob = 255;
     base_skip_false_prob[i][1] = skip_prob;
 
-    skip_prob = t * 0.75;
+    skip_prob = t * 3 / 4;
     if (skip_prob < 1)
       skip_prob = 1;
     else if (skip_prob > 255)
       skip_prob = 255;
     base_skip_false_prob[i][2] = skip_prob;
 
-    skip_prob = t * 1.25;
+    skip_prob = t * 5 / 4;
     if (skip_prob < 1)
       skip_prob = 1;
     else if (skip_prob > 255)
@@ -1400,7 +1400,7 @@ rescale(int val, int num, int denom) {
   int64_t llden = denom;
   int64_t llval = val;
 
-  return llval * llnum / llden;
+  return (int)(llval * llnum / llden);
 }
 
 
@@ -1912,7 +1912,7 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
     vp9_init_first_pass(cpi);
   } else if (cpi->pass == 2) {
     size_t packet_sz = sizeof(FIRSTPASS_STATS);
-    int packets = oxcf->two_pass_stats_in.sz / packet_sz;
+    int packets = (int)(oxcf->two_pass_stats_in.sz / packet_sz);
 
     cpi->twopass.stats_in_start = oxcf->two_pass_stats_in.buf;
     cpi->twopass.stats_in = cpi->twopass.stats_in_start;
@@ -2338,7 +2338,7 @@ static void generate_psnr_packet(VP9_COMP *cpi) {
 
   for (i = 0; i < 4; i++)
     pkt.data.psnr.psnr[i] = vp9_mse2psnr(pkt.data.psnr.samples[i], 255.0,
-                                         pkt.data.psnr.sse[i]);
+                                         (double)pkt.data.psnr.sse[i]);
 
   vpx_codec_pkt_list_add(cpi->output_pkt_list, &pkt);
 }
@@ -2904,7 +2904,9 @@ static void encode_frame_to_data_rate
   // pass function that sets the target bandwidth so must set it here
   if (cpi->common.refresh_alt_ref_frame) {
     cpi->per_frame_bandwidth = cpi->twopass.gf_bits;                           // Per frame bit target for the alt ref frame
-    cpi->target_bandwidth = cpi->twopass.gf_bits * cpi->output_frame_rate;      // per second target bitrate
+    // per second target bitrate
+    cpi->target_bandwidth = (int)(cpi->twopass.gf_bits *
+                                  cpi->output_frame_rate);
   }
 
   // Default turn off buffer to buffer copying
@@ -4106,7 +4108,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
                       - cpi->last_time_stamp_seen;
       // do a step update if the duration changes by 10%
       if (last_duration)
-        step = ((this_duration - last_duration) * 10 / last_duration);
+        step = (int)((this_duration - last_duration) * 10 / last_duration);
     }
 
     if (this_duration) {
@@ -4119,7 +4121,8 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
          * frame rate. If we haven't seen 1 second yet, then average
          * over the whole interval seen.
          */
-        interval = cpi->source->ts_end - cpi->first_time_stamp_ever;
+        interval = (double)(cpi->source->ts_end
+                            - cpi->first_time_stamp_ever);
         if (interval > 10000000.0)
           interval = 10000000;
 
@@ -4221,17 +4224,17 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
         int y_samples = orig->y_height * orig->y_width;
         int uv_samples = orig->uv_height * orig->uv_width;
         int t_samples = y_samples + 2 * uv_samples;
-        int64_t sq_error;
+        double sq_error;
 
-        ye = calc_plane_error(orig->y_buffer, orig->y_stride,
+        ye = (double)calc_plane_error(orig->y_buffer, orig->y_stride,
                               recon->y_buffer, recon->y_stride, orig->y_width,
                               orig->y_height);
 
-        ue = calc_plane_error(orig->u_buffer, orig->uv_stride,
+        ue = (double)calc_plane_error(orig->u_buffer, orig->uv_stride,
                               recon->u_buffer, recon->uv_stride, orig->uv_width,
                               orig->uv_height);
 
-        ve = calc_plane_error(orig->v_buffer, orig->uv_stride,
+        ve = (double)calc_plane_error(orig->v_buffer, orig->uv_stride,
                               recon->v_buffer, recon->uv_stride, orig->uv_width,
                               orig->uv_height);
 
@@ -4252,15 +4255,15 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
 #endif
           vp9_clear_system_state();
 
-          ye = calc_plane_error(orig->y_buffer, orig->y_stride,
+          ye = (double)calc_plane_error(orig->y_buffer, orig->y_stride,
                                 pp->y_buffer, pp->y_stride, orig->y_width,
                                 orig->y_height);
 
-          ue = calc_plane_error(orig->u_buffer, orig->uv_stride,
+          ue = (double)calc_plane_error(orig->u_buffer, orig->uv_stride,
                                 pp->u_buffer, pp->uv_stride, orig->uv_width,
                                 orig->uv_height);
 
-          ve = calc_plane_error(orig->v_buffer, orig->uv_stride,
+          ve = (double)calc_plane_error(orig->v_buffer, orig->uv_stride,
                                 pp->v_buffer, pp->uv_stride, orig->uv_width,
                                 orig->uv_height);
 
diff --git a/vp9/encoder/onyx_int.h b/vp9/encoder/onyx_int.h
index 97917d6348a5de0d5d26a250cd3ccaf146bccf20..32975523c45ee1e26716fa0c25dfa7653a087511 100644
--- a/vp9/encoder/onyx_int.h
+++ b/vp9/encoder/onyx_int.h
@@ -665,7 +665,8 @@ typedef struct VP9_COMP {
     int maxq_min_limit;
     int static_scene_max_gf_interval;
     int kf_bits;
-    int gf_group_error_left;           // Remaining error from uncoded frames in a gf group. Two pass use only
+    // Remaining error from uncoded frames in a gf group. Two pass use only
+    int64_t gf_group_error_left;
 
     // Projected total bits available for a key frame group of frames
     int64_t kf_group_bits;
@@ -673,8 +674,10 @@ typedef struct VP9_COMP {
     // Error score of frames still to be coded in kf group
     int64_t kf_group_error_left;
 
-    int gf_group_bits;                // Projected Bits available for a group of frames including 1 GF or ARF
-    int gf_bits;                     // Bits for the golden frame or ARF - 2 pass only
+    // Projected Bits available for a group of frames including 1 GF or ARF
+    int64_t gf_group_bits;
+    // Bits for the golden frame or ARF - 2 pass only
+    int gf_bits;
     int alt_extra_bits;
 
     int sr_update_lag;
diff --git a/vp9/encoder/ratectrl.c b/vp9/encoder/ratectrl.c
index 62a940d2a510d586504476559f07d51818e53694..2838e26f0f1a02f3984006af1cc8455b313b9652 100644
--- a/vp9/encoder/ratectrl.c
+++ b/vp9/encoder/ratectrl.c
@@ -311,8 +311,8 @@ static void calc_iframe_target_size(VP9_COMP *cpi) {
   target = cpi->per_frame_bandwidth;
 
   if (cpi->oxcf.rc_max_intra_bitrate_pct) {
-    unsigned int max_rate = cpi->per_frame_bandwidth
-                            * cpi->oxcf.rc_max_intra_bitrate_pct / 100;
+    int max_rate = cpi->per_frame_bandwidth
+                 * cpi->oxcf.rc_max_intra_bitrate_pct / 100;
 
     if (target > max_rate)
       target = max_rate;
diff --git a/vp9/encoder/rdopt.c b/vp9/encoder/rdopt.c
index 71b8a2ea7eed1dcfa793bf1c3ef41e39cbf8cdb9..24e84da12d673e3a3b866505d8b8787a37838b5c 100644
--- a/vp9/encoder/rdopt.c
+++ b/vp9/encoder/rdopt.c
@@ -557,7 +557,7 @@ static int cost_coeffs(MACROBLOCK *mb, BLOCKD *b, PLANE_TYPE type,
       default_eob = 64;
       if (type == PLANE_TYPE_Y_WITH_DC) {
         BLOCKD *bb;
-        int ib = (b - xd->block);
+        int ib = (int)(b - xd->block);
         if (ib < 16) {
           ib = (ib & 8) + ((ib & 4) >> 1);
           bb = xd->block + ib;
@@ -1516,7 +1516,7 @@ static int64_t rd_pick_intra8x8mby_modes(VP9_COMP *cpi, MACROBLOCK *mb,
 #endif
   }
   *Rate = cost;
-  *rate_y += tot_rate_y;
+  *rate_y = tot_rate_y;
   *Distortion = distortion;
   return RDCOST(mb->rdmult, mb->rddiv, cost, distortion);
 }
@@ -2704,7 +2704,7 @@ static int rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x,
   if (mbmi->second_ref_frame)
     x->partition_info->bmi[15].second_mv.as_int = bsi.second_mvs[15].as_int;
 
-  return bsi.segment_rd;
+  return (int)(bsi.segment_rd);
 }
 
 /* Order arr in increasing order, original position stored in idx */
@@ -3390,7 +3390,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
 #endif
     }
 
-    if (sse < threshold) {
+    if ((int)sse < threshold) {
       unsigned int q2dc = xd->block[24].dequant[0];
       /* If there is no codeable 2nd order dc
        or a very small uniform pixel change change */
@@ -3873,7 +3873,7 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
                                            second_ref, best_yrd, mdcounts,
                                            &rate, &rate_y, &distortion,
                                            &skippable,
-                                           this_rd_thresh, seg_mvs,
+                                           (int)this_rd_thresh, seg_mvs,
                                            txfm_cache);
       rate2 += rate;
       distortion2 += distortion;
@@ -4205,11 +4205,12 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
   }
 
 end:
-  store_coding_context(x, &x->mb_context[xd->mb_index], best_mode_index, &best_partition,
-                       &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame],
-                       &frame_best_ref_mv[xd->mode_info_context->mbmi.second_ref_frame],
-                       best_pred_diff[0], best_pred_diff[1], best_pred_diff[2],
-                       best_txfm_diff);
+  store_coding_context(x, &x->mb_context[xd->mb_index],
+    best_mode_index, &best_partition,
+    &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame],
+    &frame_best_ref_mv[xd->mode_info_context->mbmi.second_ref_frame],
+    (int)best_pred_diff[0], (int)best_pred_diff[1], (int)best_pred_diff[2],
+    best_txfm_diff);
 }
 
 #if CONFIG_SUPERBLOCKS
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index 1572920f1cd157f44ac605095fbee33adad1ef97..1333cc127f8c27fe6c5ad0c73c6aa81b1c789198 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -174,7 +174,7 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t      *ctx,
 
   if (cfg->g_pass == VPX_RC_LAST_PASS) {
     size_t           packet_sz = sizeof(FIRSTPASS_STATS);
-    int              n_packets = cfg->rc_twopass_stats_in.sz / packet_sz;
+    int              n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz);
     FIRSTPASS_STATS *stats;
 
     if (!cfg->rc_twopass_stats_in.buf)
@@ -691,9 +691,9 @@ static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t  *ctx,
         pkt.data.frame.pts =
           (dst_time_stamp * ctx->cfg.g_timebase.den + round)
           / ctx->cfg.g_timebase.num / 10000000;
-        pkt.data.frame.duration =
-          (delta * ctx->cfg.g_timebase.den + round)
-          / ctx->cfg.g_timebase.num / 10000000;
+        pkt.data.frame.duration = (unsigned long)
+          ((delta * ctx->cfg.g_timebase.den + round)
+          / ctx->cfg.g_timebase.num / 10000000);
         pkt.data.frame.flags = lib_flags << 16;
 
         if (lib_flags & FRAMEFLAGS_KEY)
diff --git a/vpx_ports/x86.h b/vpx_ports/x86.h
index 5aeaf9d19e37841708259e243860c520b286bda9..cac805347613c874bb016caf260714d88f404756 100644
--- a/vpx_ports/x86.h
+++ b/vpx_ports/x86.h
@@ -127,20 +127,6 @@ vpx_cpu_t vpx_x86_vendor(void);
 unsigned __int64 __rdtsc(void);
 #pragma intrinsic(__rdtsc)
 #endif
-static unsigned int
-x86_readtsc(void) {
-#if defined(__GNUC__) && __GNUC__
-  unsigned int tsc;
-  __asm__ __volatile__("rdtsc\n\t":"=a"(tsc):);
-  return tsc;
-#else
-#if ARCH_X86_64
-  return __rdtsc();
-#else
-  __asm  rdtsc;
-#endif
-#endif
-}
 
 
 #if defined(__GNUC__) && __GNUC__