Fix more warnings from static analysis

With this cange the number of shallow analysis warnings is 0 and the number of
deep analysis warnings is 18

Change-Id: Iba04f7d35ad6db60c97162a2416b997bf2713ce9
diff --git a/aom_dsp/noise_model.c b/aom_dsp/noise_model.c
index 2faee85..7e6a833 100644
--- a/aom_dsp/noise_model.c
+++ b/aom_dsp/noise_model.c
@@ -426,6 +426,9 @@
   double *AtA_inv = 0;
   double *A = 0;
   int x = 0, y = 0, i = 0, j = 0;
+  block_finder->A = NULL;
+  block_finder->AtA_inv = NULL;
+
   if (!equation_system_init(&eqns, kLowPolyNumParams)) {
     fprintf(stderr, "Failed to init equation system for block_size=%d\n",
             block_size);
diff --git a/av1/common/av1_loopfilter.c b/av1/common/av1_loopfilter.c
index cea00e8..bd99cb8 100644
--- a/av1/common/av1_loopfilter.c
+++ b/av1/common/av1_loopfilter.c
@@ -2044,6 +2044,7 @@
           const BLOCK_SIZE bsize =
               get_plane_block_size(mbmi->sb_type, plane_ptr->subsampling_x,
                                    plane_ptr->subsampling_y);
+          assert(bsize < BLOCK_SIZES_ALL);
           const int prediction_masks = edge_dir == VERT_EDGE
                                            ? block_size_wide[bsize] - 1
                                            : block_size_high[bsize] - 1;
diff --git a/av1/common/blockd.c b/av1/common/blockd.c
index 2e796b6..148f66b 100644
--- a/av1/common/blockd.c
+++ b/av1/common/blockd.c
@@ -61,6 +61,8 @@
   int i;
   int nplanes;
   int chroma_ref;
+  assert(bsize < BLOCK_SIZES_ALL);
+
   chroma_ref =
       is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
                           xd->plane[1].subsampling_y);
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index babc99e..9395c36 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -784,6 +784,8 @@
                                               int subsampling_x,
                                               int subsampling_y) {
   if (bsize == BLOCK_INVALID) return BLOCK_INVALID;
+  assert(subsampling_x >= 0 && subsampling_x < 2);
+  assert(subsampling_y >= 0 && subsampling_y < 2);
   return ss_size_lookup[bsize][subsampling_x][subsampling_y];
 }
 
@@ -1004,6 +1006,7 @@
 }
 
 static INLINE int is_motion_variation_allowed_bsize(BLOCK_SIZE bsize) {
+  assert(bsize < BLOCK_SIZES_ALL);
   return AOMMIN(block_size_wide[bsize], block_size_high[bsize]) >= 8;
 }
 
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index 3df1e83..8a069d8 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -917,6 +917,7 @@
 
 static INLINE int is_chroma_reference(int mi_row, int mi_col, BLOCK_SIZE bsize,
                                       int subsampling_x, int subsampling_y) {
+  assert(bsize < BLOCK_SIZES_ALL);
   const int bw = mi_size_wide[bsize];
   const int bh = mi_size_high[bsize];
   int ref_pos = ((mi_row & 0x01) || !(bh & 0x01) || !subsampling_y) &&
diff --git a/av1/common/pred_common.h b/av1/common/pred_common.h
index d9b30a9..a681e4e 100644
--- a/av1/common/pred_common.h
+++ b/av1/common/pred_common.h
@@ -182,6 +182,7 @@
                           uint16_t *cache);
 
 static INLINE int av1_get_palette_bsize_ctx(BLOCK_SIZE bsize) {
+  assert(bsize < BLOCK_SIZES_ALL);
   return num_pels_log2_lookup[bsize] - num_pels_log2_lookup[BLOCK_8X8];
 }
 
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index ea351cf..69da102 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -1140,6 +1140,7 @@
                                          uint8_t *pred, int stride,
                                          const BUFFER_SET *ctx, int plane,
                                          BLOCK_SIZE bsize) {
+  assert(bsize < BLOCK_SIZES_ALL);
   if (is_cur_buf_hbd(xd)) {
     DECLARE_ALIGNED(16, uint16_t, intrapredictor[MAX_SB_SQUARE]);
     av1_build_intra_predictors_for_interintra(
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index f4825dd..7849a5c 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1734,6 +1734,7 @@
 static void decode_partition(AV1Decoder *const pbi, ThreadData *const td,
                              int mi_row, int mi_col, aom_reader *reader,
                              BLOCK_SIZE bsize, int parse_decode_flag) {
+  assert(bsize < BLOCK_SIZES_ALL);
   AV1_COMMON *const cm = &pbi->common;
   MACROBLOCKD *const xd = &td->xd;
   const int bw = mi_size_wide[bsize];
diff --git a/av1/decoder/decodetxb.c b/av1/decoder/decodetxb.c
index 223e32e..71930dc 100644
--- a/av1/decoder/decodetxb.c
+++ b/av1/decoder/decodetxb.c
@@ -336,6 +336,7 @@
   struct macroblockd_plane *const pd = &xd->plane[plane];
 
   const BLOCK_SIZE bsize = mbmi->sb_type;
+  assert(bsize < BLOCK_SIZES_ALL);
   const BLOCK_SIZE plane_bsize =
       get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
 
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index d052ac6..354f9eb 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1589,6 +1589,7 @@
                            int mi_col, BLOCK_SIZE bsize) {
   const AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
+  assert(bsize < BLOCK_SIZES_ALL);
   const int hbs = mi_size_wide[bsize] / 2;
   const int quarter_step = mi_size_wide[bsize] / 4;
   int i;
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index e2f6a3f..fc341d0 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -215,6 +215,7 @@
   const AV1_COMMON *const cm = &cpi->common;
   const int num_planes = av1_num_planes(cm);
   MACROBLOCKD *const xd = &x->e_mbd;
+  assert(bsize < BLOCK_SIZES_ALL);
   const int mi_width = mi_size_wide[bsize];
   const int mi_height = mi_size_high[bsize];
 
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c
index 68225e9..808b8b7 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -86,6 +86,7 @@
 void av1_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
   struct macroblock_plane *const p = &x->plane[plane];
   const struct macroblockd_plane *const pd = &x->e_mbd.plane[plane];
+  assert(bsize < BLOCK_SIZES_ALL);
   const BLOCK_SIZE plane_bsize =
       get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
   const int bw = block_size_wide[plane_bsize];
@@ -478,6 +479,8 @@
 
   if (x->skip) return;
 
+  assert(bsize < BLOCK_SIZES_ALL);
+
   for (plane = 0; plane < num_planes; ++plane) {
     const int subsampling_x = xd->plane[plane].subsampling_x;
     const int subsampling_y = xd->plane[plane].subsampling_y;
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 7c52b21..7905a3d 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -958,6 +958,7 @@
                               const struct macroblockd_plane *pd,
                               ENTROPY_CONTEXT t_above[MAX_MIB_SIZE],
                               ENTROPY_CONTEXT t_left[MAX_MIB_SIZE]) {
+  assert(bsize < BLOCK_SIZES_ALL);
   const BLOCK_SIZE plane_bsize =
       get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
   get_entropy_contexts_plane(plane_bsize, pd, t_above, t_left);
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index b8114c7..d3349bb 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2025,6 +2025,8 @@
   int64_t dist_sum = 0;
   int64_t total_sse = 0;
 
+  assert(bsize < BLOCK_SIZES_ALL);
+
   for (plane = plane_from; plane <= plane_to; ++plane) {
     struct macroblock_plane *const p = &x->plane[plane];
     struct macroblockd_plane *const pd = &xd->plane[plane];
@@ -9739,6 +9741,7 @@
   const AV1_COMMON *cm = &cpi->common;
   const int num_planes = av1_num_planes(cm);
   MACROBLOCKD *const xd = &x->e_mbd;
+  assert(bsize < BLOCK_SIZES_ALL);
   av1_enc_build_inter_predictor(cm, xd, mi_row, mi_col, orig_dst, bsize, 0,
                                 av1_num_planes(cm) - 1);
 
diff --git a/av1/encoder/reconinter_enc.c b/av1/encoder/reconinter_enc.c
index 4b477ce..9198901 100644
--- a/av1/encoder/reconinter_enc.c
+++ b/av1/encoder/reconinter_enc.c
@@ -495,6 +495,7 @@
     MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane_from, int plane_to, int mi_row,
     int mi_col, int ref, uint8_t *ext_dst[3], int ext_dst_stride[3],
     int can_use_previous) {
+  assert(bsize < BLOCK_SIZES_ALL);
   int plane;
   const int mi_x = mi_col * MI_SIZE;
   const int mi_y = mi_row * MI_SIZE;
@@ -595,6 +596,7 @@
                                               uint8_t *ext_dst1[3],
                                               int ext_dst_stride1[3]) {
   int plane;
+  assert(bsize < BLOCK_SIZES_ALL);
   for (plane = plane_from; plane <= plane_to; ++plane) {
     const BLOCK_SIZE plane_bsize = get_plane_block_size(
         bsize, xd->plane[plane].subsampling_x, xd->plane[plane].subsampling_y);
diff --git a/av1/encoder/segmentation.c b/av1/encoder/segmentation.c
index 6d0c654..193c7a7 100644
--- a/av1/encoder/segmentation.c
+++ b/av1/encoder/segmentation.c
@@ -151,6 +151,7 @@
     case PARTITION_SPLIT: {
       const BLOCK_SIZE subsize = get_partition_subsize(bsize, PARTITION_SPLIT);
       int n;
+      assert(subsize < BLOCK_SIZES_ALL);
 
       for (n = 0; n < 4; n++) {
         const int mi_dc = hbs * (n & 1);
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index ce1a212..9b8e0eb 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -198,6 +198,8 @@
   struct tokenize_b_args arg = { cpi, td, t, 0, allow_update_cdf };
   if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return;
 
+  assert(bsize < BLOCK_SIZES_ALL);
+
   if (mbmi->skip) {
     av1_reset_skip_context(xd, mi_row, mi_col, bsize, num_planes);
     return;