Add the q_segmentation experiment

This experiment implements low-cost delta q signalling on a per-block basis
for all non-inter frame types, which would allow for more efficient AQ
which bases its decisions on temporal information.

Based on an Intel proposal from March.

Change-Id: I18e73d8b12f4caa0b165df12c58ab506271bec03
diff --git a/av1/common/alloccommon.c b/av1/common/alloccommon.c
index 4f1ad49..b8e30cf 100644
--- a/av1/common/alloccommon.c
+++ b/av1/common/alloccommon.c
@@ -48,8 +48,14 @@
   cm->MBs = cm->mb_rows * cm->mb_cols;
 }
 
-static int alloc_seg_map(AV1_COMMON *cm, int seg_map_size) {
+static int alloc_seg_map(AV1_COMMON *cm, int rows, int cols) {
   int i;
+  int seg_map_size = rows * cols;
+
+#if CONFIG_Q_SEGMENTATION
+  cm->q_seg_map = (uint8_t *)aom_calloc(seg_map_size, 1);
+  if (!cm->q_seg_map) return 1;
+#endif
 
   for (i = 0; i < NUM_PING_PONG_BUFFERS; ++i) {
     cm->seg_map_array[i] = (uint8_t *)aom_calloc(seg_map_size, 1);
@@ -71,6 +77,11 @@
 static void free_seg_map(AV1_COMMON *cm) {
   int i;
 
+#if CONFIG_Q_SEGMENTATION
+  aom_free(cm->q_seg_map);
+  cm->q_seg_map = NULL;
+#endif
+
   for (i = 0; i < NUM_PING_PONG_BUFFERS; ++i) {
     aom_free(cm->seg_map_array[i]);
     cm->seg_map_array[i] = NULL;
@@ -222,7 +233,7 @@
   if (cm->seg_map_alloc_size < cm->mi_rows * cm->mi_cols) {
     // Create the segmentation map structure and set to 0.
     free_seg_map(cm);
-    if (alloc_seg_map(cm, cm->mi_rows * cm->mi_cols)) goto fail;
+    if (alloc_seg_map(cm, cm->mi_rows, cm->mi_cols)) goto fail;
   }
 
   if (cm->above_context_alloc_cols < cm->mi_cols) {