ext_inter: Skip compound type probs. for small block sizes.

When writing the compressed header, prob_diff_update() was called
for compound_type_prob[] for every defined block size, even though
luma never uses block sizes smaller than 4x4.

This fixes is_any_masked_compound_used() and
is_interinter_compound_used() to properly return 0 for chroma-only
block sizes, and then uses these functions to guard the probability
updates in write_compressed_header() and read_compressed_header(),
the same way the actual compound type values are guarded in
read_inter_block_mode_info() and pack_inter_mode_mvs().

Change-Id: Ib521cf53f9ec166ef634609c8b47c5814b6a9ff5
diff --git a/av1/common/reconinter.h b/av1/common/reconinter.h
index eb6fd6e..e0748b7 100644
--- a/av1/common/reconinter.h
+++ b/av1/common/reconinter.h
@@ -204,7 +204,11 @@
                                               BLOCK_SIZE sb_type) {
   (void)sb_type;
   switch (type) {
+#if CONFIG_CB4X4
+    case COMPOUND_AVERAGE: return sb_type >= BLOCK_4X4;
+#else   // CONFIG_CB4X4
     case COMPOUND_AVERAGE: return 1;
+#endif  // CONFIG_CB4X4
 #if CONFIG_WEDGE
     case COMPOUND_WEDGE: return wedge_params_lookup[sb_type].bits > 0;
 #endif  // CONFIG_WEDGE
@@ -217,6 +221,9 @@
 
 static INLINE int is_any_masked_compound_used(BLOCK_SIZE sb_type) {
   COMPOUND_TYPE comp_type;
+#if CONFIG_CB4X4
+  if (sb_type < BLOCK_4X4) return 0;
+#endif  // CONFIG_CB4X4
   for (comp_type = 0; comp_type < COMPOUND_TYPES; comp_type++) {
     if (is_masked_compound_type(comp_type) &&
         is_interinter_compound_used(comp_type, sb_type))
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index d53766f..957b618 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -5106,8 +5106,10 @@
     if (cm->reference_mode != SINGLE_REFERENCE && cm->allow_masked_compound) {
 #endif  // CONFIG_COMPOUND_SINGLEREF
       for (i = 0; i < BLOCK_SIZES; i++) {
-        for (j = 0; j < COMPOUND_TYPES - 1; j++) {
-          av1_diff_update_prob(&r, &fc->compound_type_prob[i][j], ACCT_STR);
+        if (is_any_masked_compound_used(i)) {
+          for (j = 0; j < COMPOUND_TYPES - 1; j++) {
+            av1_diff_update_prob(&r, &fc->compound_type_prob[i][j], ACCT_STR);
+          }
         }
       }
     }
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 41c925b..3fbae2a 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -5072,10 +5072,13 @@
 #else   // !CONFIG_COMPOUND_SINGLEREF
     if (cm->reference_mode != SINGLE_REFERENCE && cm->allow_masked_compound) {
 #endif  // CONFIG_COMPOUND_SINGLEREF
-      for (i = 0; i < BLOCK_SIZES; i++)
-        prob_diff_update(av1_compound_type_tree, fc->compound_type_prob[i],
-                         cm->counts.compound_interinter[i], COMPOUND_TYPES,
-                         probwt, header_bc);
+      for (i = 0; i < BLOCK_SIZES; i++) {
+        if (is_any_masked_compound_used(i)) {
+          prob_diff_update(av1_compound_type_tree, fc->compound_type_prob[i],
+                           cm->counts.compound_interinter[i], COMPOUND_TYPES,
+                           probwt, header_bc);
+        }
+      }
     }
 #endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
 #endif  // CONFIG_EXT_INTER