Collect coeff level distribution in symbolrate

Change-Id: If77800c0904b5e004508274acb32ae46a641405b
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index e032af9..9b77964 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -439,7 +439,7 @@
 
 #if CONFIG_SYMBOLRATE
   unsigned int superblock_num;
-  unsigned int coeff_num[2];   // 0: zero coeff 1: non-zero coeff
+  unsigned int coeff_num[COEFF_LEVELS];  // 0: zero coeff 1: non-zero coeff
   unsigned int symbol_num[2];  // 0: entropy symbol 1: non-entropy symbol
 #endif
 
diff --git a/av1/common/enums.h b/av1/common/enums.h
index 9bfc26a..70c90da 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -622,6 +622,9 @@
   FILTER_INTRA_MODES,
 } FILTER_INTRA_MODE;
 #endif  // CONFIG_FILTER_INTRA
+#if CONFIG_SYMBOLRATE
+#define COEFF_LEVELS 18
+#endif
 
 #if CONFIG_EXT_INTRA
 #define DIRECTIONAL_MODES 8
diff --git a/av1/decoder/symbolrate.h b/av1/decoder/symbolrate.h
index 167eb19..f6688a9 100644
--- a/av1/decoder/symbolrate.h
+++ b/av1/decoder/symbolrate.h
@@ -10,6 +10,7 @@
  */
 
 #include "aom_dsp/bitreader.h"
+#include "av1/common/enums.h"
 
 #ifndef AV1_DECODER_SYMBOLRATE_H_
 #define AV1_DECODER_SYMBOLRATE_H_
@@ -17,9 +18,11 @@
 #if CONFIG_SYMBOLRATE
 static INLINE void av1_dump_symbol_rate(struct AV1Common *cm) {
   const FRAME_COUNTS *counts = &cm->counts;
-  printf("%d %d %d %d %d %d %d\n", cm->current_video_frame, cm->show_frame,
-         counts->superblock_num, counts->coeff_num[0], counts->coeff_num[1],
-         counts->symbol_num[0], counts->symbol_num[1]);
+  printf("fidx %d show %d superblock_num %d\n", cm->current_video_frame,
+         cm->show_frame, counts->superblock_num);
+  printf("%d %d\n", counts->symbol_num[0], counts->symbol_num[1]);
+  for (int i = 0; i < COEFF_LEVELS; ++i) printf("%d ", counts->coeff_num[i]);
+  printf("\n");
 }
 static INLINE int av1_read_record_symbol(FRAME_COUNTS *counts, aom_reader *r,
                                          aom_cdf_prob *cdf, int nsymbs,
@@ -63,7 +66,9 @@
 
 static INLINE void av1_record_coeff(FRAME_COUNTS *counts, tran_low_t qcoeff) {
   assert(qcoeff >= 0);
-  if (counts) ++counts->coeff_num[qcoeff != 0];
+  int abs_qc = abs(qcoeff);
+  abs_qc = clamp(abs_qc, 0, COEFF_LEVELS - 1);
+  if (counts) ++counts->coeff_num[abs_qc];
 }
 
 static INLINE void av1_record_superblock(FRAME_COUNTS *counts) {