Tree clean up.

Relocate C source and include files from the root of the
repository to more appropriate places. Helps quiet linters.

- Move common app support sources and includes to common/
- Move apps to apps/
- Move stats support to stats/
- Drop unnecessary includes of aom_config.h where appropriate
- Clean up include order where appropriate
- Change CMake build to accomodate the above
- Fix resize_util and add it to app targets.

Change-Id: I268838e93400c67eb365aba9d2ecb2891538fc07
diff --git a/examples/analyzer.cc b/examples/analyzer.cc
index 0e7ba15..6a42eca 100644
--- a/examples/analyzer.cc
+++ b/examples/analyzer.cc
@@ -12,13 +12,14 @@
 #include <wx/aboutdlg.h>
 #include <wx/cmdline.h>
 #include <wx/dcbuffer.h>
-#include "./tools_common.h"
-#include "./video_reader.h"
+
 #include "aom/aom_decoder.h"
 #include "aom/aomdx.h"
-#include "av1/decoder/accounting.h"
 #include "av1/common/onyxc_int.h"
+#include "av1/decoder/accounting.h"
 #include "av1/decoder/inspection.h"
+#include "common/tools_common.h"
+#include "common/video_reader.h"
 
 #define OD_SIGNMASK(a) (-((a) < 0))
 #define OD_FLIPSIGNI(a, b) (((a) + OD_SIGNMASK(b)) ^ OD_SIGNMASK(b))
diff --git a/examples/aom_cx_set_ref.c b/examples/aom_cx_set_ref.c
index 923caa8..e02e94c 100644
--- a/examples/aom_cx_set_ref.c
+++ b/examples/aom_cx_set_ref.c
@@ -51,12 +51,12 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "aom/aomcx.h"
 #include "aom/aom_decoder.h"
 #include "aom/aom_encoder.h"
+#include "aom/aomcx.h"
+#include "common/tools_common.h"
+#include "common/video_writer.h"
 #include "examples/encoder_util.h"
-#include "./tools_common.h"
-#include "./video_writer.h"
 
 #define AOM_BORDER_IN_PIXELS 288
 
diff --git a/examples/decode_to_md5.c b/examples/decode_to_md5.c
index 0e108e2..bc127b7 100644
--- a/examples/decode_to_md5.c
+++ b/examples/decode_to_md5.c
@@ -34,13 +34,11 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "aom/aomdx.h"
 #include "aom/aom_decoder.h"
-
-#include "../md5_utils.h"
-#include "../tools_common.h"
-#include "../video_reader.h"
-#include "./aom_config.h"
+#include "aom/aomdx.h"
+#include "common/md5_utils.h"
+#include "common/tools_common.h"
+#include "common/video_reader.h"
 
 static void get_image_md5(const aom_image_t *img, unsigned char digest[16]) {
   int plane, y;
diff --git a/examples/decode_with_drops.c b/examples/decode_with_drops.c
index bd32c87..2144019 100644
--- a/examples/decode_with_drops.c
+++ b/examples/decode_with_drops.c
@@ -57,12 +57,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "aom/aomdx.h"
 #include "aom/aom_decoder.h"
-
-#include "../tools_common.h"
-#include "../video_reader.h"
-#include "./aom_config.h"
+#include "aom/aomdx.h"
+#include "common/tools_common.h"
+#include "common/video_reader.h"
 
 static const char *exec_name;
 
diff --git a/examples/encoder_util.c b/examples/encoder_util.c
index 887bc55..453484c 100644
--- a/examples/encoder_util.c
+++ b/examples/encoder_util.c
@@ -11,10 +11,11 @@
 
 // Utility functions used by encoder binaries.
 
+#include "encoder_util.h"
+
 #include <assert.h>
 #include <string.h>
 
-#include "./encoder_util.h"
 #include "aom/aom_integer.h"
 
 #define mmin(a, b) ((a) < (b) ? (a) : (b))
diff --git a/examples/encoder_util.h b/examples/encoder_util.h
index a467bb1..966f5e0 100644
--- a/examples/encoder_util.h
+++ b/examples/encoder_util.h
@@ -14,7 +14,6 @@
 #ifndef EXAMPLES_ENCODER_UTIL_H_
 #define EXAMPLES_ENCODER_UTIL_H_
 
-#include "./aom_config.h"
 #include "aom/aom_image.h"
 
 // Returns mismatch location (?loc[0],?loc[1]) and the values at that location
diff --git a/examples/inspect.c b/examples/inspect.c
index ceb7fc2..3c9cba5 100644
--- a/examples/inspect.c
+++ b/examples/inspect.c
@@ -19,27 +19,27 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "./args.h"
 #ifdef __EMSCRIPTEN__
 #include <emscripten.h>
 #else
 #define EMSCRIPTEN_KEEPALIVE
 #endif
 
-#include "aom/aom_decoder.h"
 #include "./aom_config.h"
-#if CONFIG_ACCOUNTING
-#include "../av1/decoder/accounting.h"
-#endif
-#include "../av1/decoder/inspection.h"
+
+#include "aom/aom_decoder.h"
 #include "aom/aomdx.h"
+#include "av1/common/onyxc_int.h"
 
-#include "../tools_common.h"
-#include "../video_reader.h"
-// #include "av1/av1_dx_iface.c"
-#include "../av1/common/onyxc_int.h"
+#if CONFIG_ACCOUNTING
+#include "av1/decoder/accounting.h"
+#endif
 
-#include "../video_common.h"
+#include "av1/decoder/inspection.h"
+#include "common/args.h"
+#include "common/tools_common.h"
+#include "common/video_common.h"
+#include "common/video_reader.h"
 
 // Max JSON buffer size.
 const int MAX_BUFFER = 1024 * 1024 * 32;
diff --git a/examples/lightfield_decoder.c b/examples/lightfield_decoder.c
index 0fb970b..b3e1637 100644
--- a/examples/lightfield_decoder.c
+++ b/examples/lightfield_decoder.c
@@ -29,10 +29,8 @@
 
 #include "aom/aom_decoder.h"
 #include "aom/aomdx.h"
-
-#include "../tools_common.h"
-#include "../video_reader.h"
-#include "./aom_config.h"
+#include "common/tools_common.h"
+#include "common/video_reader.h"
 
 static const char *exec_name;
 
diff --git a/examples/lightfield_encoder.c b/examples/lightfield_encoder.c
index 2dfd855..92c892c 100644
--- a/examples/lightfield_encoder.c
+++ b/examples/lightfield_encoder.c
@@ -39,8 +39,8 @@
 #include "aom/aomcx.h"
 #include "av1/common/enums.h"
 
-#include "../tools_common.h"
-#include "../video_writer.h"
+#include "common/tools_common.h"
+#include "common/video_writer.h"
 
 static const char *exec_name;
 
diff --git a/examples/lossless_encoder.c b/examples/lossless_encoder.c
index 242db7b..438ff21 100644
--- a/examples/lossless_encoder.c
+++ b/examples/lossless_encoder.c
@@ -15,9 +15,8 @@
 
 #include "aom/aom_encoder.h"
 #include "aom/aomcx.h"
-
-#include "../tools_common.h"
-#include "../video_writer.h"
+#include "common/tools_common.h"
+#include "common/video_writer.h"
 
 static const char *exec_name;
 
diff --git a/examples/noise_model.c b/examples/noise_model.c
index ef1e967..78d4386 100644
--- a/examples/noise_model.c
+++ b/examples/noise_model.c
@@ -24,18 +24,20 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "../args.h"
-#include "../tools_common.h"
-#include "../video_writer.h"
 #include "aom/aom_encoder.h"
 #include "aom_dsp/aom_dsp_common.h"
+
 #if CONFIG_AV1_DECODER
 #include "aom_dsp/grain_synthesis.h"
 #endif
+
 #include "aom_dsp/grain_table.h"
 #include "aom_dsp/noise_model.h"
 #include "aom_dsp/noise_util.h"
 #include "aom_mem/aom_mem.h"
+#include "common/args.h"
+#include "common/tools_common.h"
+#include "common/video_writer.h"
 
 static const char *exec_name;
 
diff --git a/examples/resize_util.c b/examples/resize_util.c
index 5485691..6a84d57 100644
--- a/examples/resize_util.c
+++ b/examples/resize_util.c
@@ -16,8 +16,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "../tools_common.h"
-#include "../av1/encoder/av1_resize.h"
+#include "av1/common/resize.h"
+#include "common/tools_common.h"
 
 static const char *exec_name = NULL;
 
diff --git a/examples/scalable_decoder.c b/examples/scalable_decoder.c
index 37cf299..9ffdae4 100644
--- a/examples/scalable_decoder.c
+++ b/examples/scalable_decoder.c
@@ -75,11 +75,9 @@
 #include <string.h>
 
 #include "aom/aom_decoder.h"
-
-#include "../tools_common.h"
-#include "../video_reader.h"
-#include "./aom_config.h"
-#include "./obudec.h"
+#include "common/obudec.h"
+#include "common/tools_common.h"
+#include "common/video_reader.h"
 
 static const char *exec_name;
 
diff --git a/examples/scalable_encoder.c b/examples/scalable_encoder.c
index 10d647e..7af03e2 100644
--- a/examples/scalable_encoder.c
+++ b/examples/scalable_encoder.c
@@ -76,9 +76,8 @@
 #include "aom/aom_encoder.h"
 #include "aom/aomcx.h"
 #include "av1/common/enums.h"
-
-#include "../tools_common.h"
-#include "../video_writer.h"
+#include "common/tools_common.h"
+#include "common/video_writer.h"
 
 static const char *exec_name;
 
diff --git a/examples/set_maps.c b/examples/set_maps.c
index 82d98e1..9aeb96e 100644
--- a/examples/set_maps.c
+++ b/examples/set_maps.c
@@ -47,11 +47,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "aom/aomcx.h"
 #include "aom/aom_encoder.h"
-
-#include "../tools_common.h"
-#include "../video_writer.h"
+#include "aom/aomcx.h"
+#include "common/tools_common.h"
+#include "common/video_writer.h"
 
 static const char *exec_name;
 
diff --git a/examples/simple_decoder.c b/examples/simple_decoder.c
index a784f18..d098d1e 100644
--- a/examples/simple_decoder.c
+++ b/examples/simple_decoder.c
@@ -79,10 +79,8 @@
 #include <string.h>
 
 #include "aom/aom_decoder.h"
-
-#include "../tools_common.h"
-#include "../video_reader.h"
-#include "./aom_config.h"
+#include "common/tools_common.h"
+#include "common/video_reader.h"
 
 static const char *exec_name;
 
diff --git a/examples/simple_encoder.c b/examples/simple_encoder.c
index 5a54518..01a37cf 100644
--- a/examples/simple_encoder.c
+++ b/examples/simple_encoder.c
@@ -100,9 +100,8 @@
 #include <string.h>
 
 #include "aom/aom_encoder.h"
-
-#include "../tools_common.h"
-#include "../video_writer.h"
+#include "common/tools_common.h"
+#include "common/video_writer.h"
 
 static const char *exec_name;
 
diff --git a/examples/twopass_encoder.c b/examples/twopass_encoder.c
index bb4b150..1b134cc 100644
--- a/examples/twopass_encoder.c
+++ b/examples/twopass_encoder.c
@@ -52,9 +52,8 @@
 #include <string.h>
 
 #include "aom/aom_encoder.h"
-
-#include "../tools_common.h"
-#include "../video_writer.h"
+#include "common/tools_common.h"
+#include "common/video_writer.h"
 
 static const char *exec_name;