Resolve some static analysis warnings

Change-Id: I5248fe646c88e914b8f0cfea11b5a19611f63572
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..eb7a8a0 100644
--- a/av1/common/blockd.c
+++ b/av1/common/blockd.c
@@ -69,6 +69,7 @@
     struct macroblockd_plane *const pd = &xd->plane[i];
     const BLOCK_SIZE plane_bsize =
         get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
+    assert(plane_bsize < BLOCK_SIZES_ALL);
     const int txs_wide = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
     const int txs_high = block_size_high[plane_bsize] >> tx_size_high_log2[0];
     memset(pd->above_context, 0, sizeof(ENTROPY_CONTEXT) * txs_wide);
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index fcf4fe7..9acec29 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -839,6 +839,7 @@
 
 static INLINE int av1_get_txb_size_index(BLOCK_SIZE bsize, int blk_row,
                                          int blk_col) {
+  assert(bsize < BLOCK_SIZES_ALL);
   TX_SIZE txs = max_txsize_rect_lookup[bsize];
   for (int level = 0; level < MAX_VARTX_DEPTH - 1; ++level)
     txs = sub_tx_size_map[txs];
@@ -854,6 +855,7 @@
 
 static INLINE int av1_get_txk_type_index(BLOCK_SIZE bsize, int blk_row,
                                          int blk_col) {
+  assert(bsize < BLOCK_SIZES_ALL);
   TX_SIZE txs = max_txsize_rect_lookup[bsize];
   for (int level = 0; level < MAX_VARTX_DEPTH; ++level)
     txs = sub_tx_size_map[txs];
@@ -1048,12 +1050,14 @@
 static INLINE int get_vartx_max_txsize(const MACROBLOCKD *xd, BLOCK_SIZE bsize,
                                        int plane) {
   if (xd->lossless[xd->mi[0]->segment_id]) return TX_4X4;
+  assert(bsize < BLOCK_SIZES_ALL);
   const TX_SIZE max_txsize = max_txsize_rect_lookup[bsize];
   if (plane == 0) return max_txsize;            // luma
   return av1_get_adjusted_tx_size(max_txsize);  // chroma
 }
 
 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 50ac585..a4f5c88 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -937,6 +937,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) &&
@@ -1096,6 +1097,7 @@
 
 static INLINE int max_block_wide(const MACROBLOCKD *xd, BLOCK_SIZE bsize,
                                  int plane) {
+  assert(bsize < BLOCK_SIZES_ALL);
   int max_blocks_wide = block_size_wide[bsize];
   const struct macroblockd_plane *const pd = &xd->plane[plane];
 
@@ -1108,6 +1110,7 @@
 
 static INLINE int max_block_high(const MACROBLOCKD *xd, BLOCK_SIZE bsize,
                                  int plane) {
+  assert(bsize < BLOCK_SIZES_ALL);
   int max_blocks_high = block_size_high[bsize];
   const struct macroblockd_plane *const pd = &xd->plane[plane];
 
diff --git a/av1/common/pred_common.h b/av1/common/pred_common.h
index 1d69ef0..00ffa23 100644
--- a/av1/common/pred_common.h
+++ b/av1/common/pred_common.h
@@ -178,6 +178,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 014426c..fb4df84 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -1106,6 +1106,7 @@
   assert(xd->mi[0]->angle_delta[PLANE_TYPE_UV] == 0);
   assert(xd->mi[0]->filter_intra_mode_info.use_filter_intra == 0);
   assert(xd->mi[0]->use_intrabc == 0);
+  assert(plane_bsize < BLOCK_SIZES_ALL);
 
   av1_predict_intra_block(
       cm, xd, pd->width, pd->height, max_txsize_rect_lookup[plane_bsize], mode,
diff --git a/av1/common/txb_common.h b/av1/common/txb_common.h
index 218bc49..2d3b1dd 100644
--- a/av1/common/txb_common.h
+++ b/av1/common/txb_common.h
@@ -433,6 +433,7 @@
     }
   } else {
     const int ctx_base = get_entropy_context(tx_size, a, l);
+    assert(plane_bsize < BLOCK_SIZES_ALL);
     const int ctx_offset = (num_pels_log2_lookup[plane_bsize] >
                             num_pels_log2_lookup[txsize_to_bsize[tx_size]])
                                ? 10
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 38d4d56..ff3151e 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1454,6 +1454,7 @@
 
   int blk_row, blk_col;
 
+  assert(plane_bsize < BLOCK_SIZES_ALL);
   const int num_4x4_w = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
   const int num_4x4_h = block_size_high[plane_bsize] >> tx_size_high_log2[0];
 
@@ -1647,6 +1648,7 @@
                            aom_writer *const w, const TOKENEXTRA **tok,
                            const TOKENEXTRA *const tok_end, int mi_row,
                            int mi_col, BLOCK_SIZE bsize) {
+  assert(bsize < BLOCK_SIZES_ALL);
   const AV1_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
   const int hbs = mi_size_wide[bsize] / 2;
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 7c26807..94f91dc 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -229,6 +229,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 599e151..32e1983 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -88,6 +88,7 @@
   const struct macroblockd_plane *const pd = &x->e_mbd.plane[plane];
   const BLOCK_SIZE plane_bsize =
       get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
+  assert(plane_bsize < BLOCK_SIZES_ALL);
   const int bw = block_size_wide[plane_bsize];
   const int bh = block_size_high[plane_bsize];
   const MACROBLOCKD *xd = &x->e_mbd;
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index fb3953c..93c84c0 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -1492,6 +1492,7 @@
                                        const struct macroblockd_plane *pd,
                                        ENTROPY_CONTEXT t_above[MAX_MIB_SIZE],
                                        ENTROPY_CONTEXT t_left[MAX_MIB_SIZE]) {
+  assert(plane_bsize < BLOCK_SIZES_ALL);
   const int num_4x4_w = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
   const int num_4x4_h = block_size_high[plane_bsize] >> tx_size_high_log2[0];
   const ENTROPY_CONTEXT *const above = pd->above_context;
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 4658267..20db1e9 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2036,6 +2036,7 @@
     struct macroblockd_plane *const pd = &xd->plane[plane];
     const BLOCK_SIZE plane_bsize =
         get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
+    assert(plane_bsize < BLOCK_SIZES_ALL);
     const int bw = block_size_wide[plane_bsize];
     const int bh = block_size_high[plane_bsize];
     int64_t sse;
@@ -5244,6 +5245,7 @@
   const struct macroblockd_plane *const pd = &xd->plane[0];
   const BLOCK_SIZE plane_bsize =
       get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
+  assert(plane_bsize < BLOCK_SIZES_ALL);
   const int mi_width = mi_size_wide[plane_bsize];
   const int mi_height = mi_size_high[plane_bsize];
   ENTROPY_CONTEXT ctxa[MAX_MIB_SIZE];
@@ -6108,6 +6110,7 @@
     struct macroblockd_plane *const pd = &xd->plane[plane];
     const BLOCK_SIZE plane_bsize =
         get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
+    assert(plane_bsize < BLOCK_SIZES_ALL);
     const int bw = block_size_wide[plane_bsize];
     const int bh = block_size_high[plane_bsize];
     int64_t sse;
@@ -9746,6 +9749,7 @@
     const struct macroblockd_plane *const pd = &xd->plane[plane];
     const BLOCK_SIZE plane_bsize =
         get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
+    assert(plane_bsize < BLOCK_SIZES_ALL);
     const int bw = block_size_wide[plane_bsize];
     const int bh = block_size_high[plane_bsize];
 
diff --git a/av1/encoder/reconinter_enc.c b/av1/encoder/reconinter_enc.c
index 4b477ce..7d12db8 100644
--- a/av1/encoder/reconinter_enc.c
+++ b/av1/encoder/reconinter_enc.c
@@ -501,6 +501,7 @@
   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);
+    assert(plane_bsize < BLOCK_SIZES_ALL);
     const int bw = block_size_wide[plane_bsize];
     const int bh = block_size_high[plane_bsize];
     build_inter_predictors_single_buf(xd, plane, bw, bh, 0, 0, bw, bh, mi_x,
@@ -598,6 +599,7 @@
   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);
+    assert(plane_bsize < BLOCK_SIZES_ALL);
     const int bw = block_size_wide[plane_bsize];
     const int bh = block_size_high[plane_bsize];
     build_wedge_inter_predictor_from_buf(
diff --git a/av1/encoder/segmentation.c b/av1/encoder/segmentation.c
index 6d0c654..7898112 100644
--- a/av1/encoder/segmentation.c
+++ b/av1/encoder/segmentation.c
@@ -88,6 +88,7 @@
                           unsigned (*temporal_predictor_count)[2],
                           unsigned *t_unpred_seg_counts, int mi_row, int mi_col,
                           BLOCK_SIZE bsize) {
+  assert(bsize < BLOCK_SIZES_ALL);
   const int mis = cm->mi_stride;
   const int bs = mi_size_wide[bsize], hbs = bs / 2;
   PARTITION_TYPE partition;