Merge "minor updates" into nextgenv2
diff --git a/README b/README
index bdeac06..3e7dfb8 100644
--- a/README
+++ b/README
@@ -122,10 +122,10 @@
 VP8/AV1 TEST VECTORS:
   The test vectors can be downloaded and verified using the build system after
   running configure. To specify an alternate directory the
-  LIBVPX_TEST_DATA_PATH environment variable can be used.
+  LIBAOM_TEST_DATA_PATH environment variable can be used.
 
   $ ./configure --enable-unit-tests
-  $ LIBVPX_TEST_DATA_PATH=../-test-data make testdata
+  $ LIBAOM_TEST_DATA_PATH=../-test-data make testdata
 
 CODE STYLE:
   The coding style used by this project is enforced with clang-format using the
diff --git a/args.c b/args.c
index e12f16b..5829857 100644
--- a/args.c
+++ b/args.c
@@ -14,6 +14,7 @@
 #include <limits.h>
 #include "args.h"
 
+#include "aom/aom_integer.h"
 #include "aom_ports/msvc.h"
 
 #if defined(__GNUC__) && __GNUC__
@@ -119,13 +120,13 @@
 }
 
 unsigned int arg_parse_uint(const struct arg *arg) {
-  long int rawval;
+  uint32_t rawval;
   char *endptr;
 
-  rawval = strtol(arg->val, &endptr, 10);
+  rawval = strtoul(arg->val, &endptr, 10);
 
   if (arg->val[0] != '\0' && endptr[0] == '\0') {
-    if (rawval >= 0 && rawval <= UINT_MAX) return rawval;
+    if (rawval <= UINT_MAX) return rawval;
 
     die("Option %s: Value %ld out of range for unsigned int\n", arg->name,
         rawval);
@@ -136,7 +137,7 @@
 }
 
 int arg_parse_int(const struct arg *arg) {
-  long int rawval;
+  int32_t rawval;
   char *endptr;
 
   rawval = strtol(arg->val, &endptr, 10);
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index b80e387..6774bb2 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3538,10 +3538,10 @@
 #if CONFIG_SUPERTX
     if (!xd->lossless[0]) update_supertx_probs(cm, header_bc);
 #endif  // CONFIG_SUPERTX
-  }
 #if CONFIG_GLOBAL_MOTION
-  write_global_motion(cpi, header_bc);
+    write_global_motion(cpi, header_bc);
 #endif  // CONFIG_GLOBAL_MOTION
+  }
 #if CONFIG_ANS
   ans_write_init(&header_ans, data);
   buf_ans_flush(header_bc, &header_ans);
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 57b42a8..8a6e134 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -164,7 +164,6 @@
   // Store the second best motion vector during full-pixel motion search
   int_mv second_best_mv;
 
-
   // use default transform and skip transform type search for intra modes
   int use_default_intra_tx_type;
   // use default transform and skip transform type search for inter modes
diff --git a/configure b/configure
index 1bc0863..e671aa5 100755
--- a/configure
+++ b/configure
@@ -605,6 +605,7 @@
         check_add_cflags -Wimplicit-function-declaration
         check_add_cflags -Wuninitialized
         check_add_cflags -Wunused-variable
+        check_add_cflags -Wsign-compare
         case ${CC} in
           *clang*) ;;
           *) check_add_cflags -Wunused-but-set-variable ;;
diff --git a/examples/aom_cx_set_ref.c b/examples/aom_cx_set_ref.c
index 43e8fe0..fdb9739 100644
--- a/examples/aom_cx_set_ref.c
+++ b/examples/aom_cx_set_ref.c
@@ -307,6 +307,7 @@
   const char *height_arg = NULL;
   const char *infile_arg = NULL;
   const char *outfile_arg = NULL;
+  const char *update_frame_num_arg = NULL;
   unsigned int limit = 0;
   exec_name = argv[0];
 
@@ -317,18 +318,21 @@
   height_arg = argv[3];
   infile_arg = argv[4];
   outfile_arg = argv[5];
+  update_frame_num_arg = argv[6];
 
   encoder = get_aom_encoder_by_name(codec_arg);
   if (!encoder) die("Unsupported codec.");
 
-  update_frame_num = atoi(argv[6]);
+  update_frame_num = (unsigned int)strtoul(update_frame_num_arg, NULL, 0);
   // In AV1, the reference buffers (cm->buffer_pool->frame_bufs[i].buf) are
   // allocated while calling aom_codec_encode(), thus, setting reference for
   // 1st frame isn't supported.
-  if (update_frame_num <= 1) die("Couldn't parse frame number '%s'\n", argv[6]);
+  if (update_frame_num <= 1) {
+    die("Couldn't parse frame number '%s'\n", update_frame_num_arg);
+  }
 
   if (argc > 7) {
-    limit = atoi(argv[7]);
+    limit = (unsigned int)strtoul(argv[7], NULL, 0);
     if (update_frame_num > limit)
       die("Update frame number couldn't larger than limit\n");
   }
diff --git a/libs.mk b/libs.mk
index 97b1347..d4a3040 100644
--- a/libs.mk
+++ b/libs.mk
@@ -356,12 +356,12 @@
 ## libaom test directives
 ##
 ifeq ($(CONFIG_UNIT_TESTS),yes)
-LIBVPX_TEST_DATA_PATH ?= .
+LIBAOM_TEST_DATA_PATH ?= .
 
 include $(SRC_PATH_BARE)/test/test.mk
 LIBAOM_TEST_SRCS=$(addprefix test/,$(call enabled,LIBAOM_TEST_SRCS))
 LIBAOM_TEST_BIN=./test_libaom$(EXE_SFX)
-LIBAOM_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
+LIBAOM_TEST_DATA=$(addprefix $(LIBAOM_TEST_DATA_PATH)/,\
                      $(call enabled,LIBAOM_TEST_DATA))
 libaom_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
 
@@ -388,7 +388,7 @@
             echo "Checking test data:";\
             for f in $(call enabled,LIBAOM_TEST_DATA); do\
                 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
-                    (cd $(LIBVPX_TEST_DATA_PATH); $${sha1sum} -c);\
+                    (cd $(LIBAOM_TEST_DATA_PATH); $${sha1sum} -c);\
             done; \
         else\
             echo "Skipping test data integrity check, sha1sum not found.";\
@@ -554,10 +554,10 @@
 endif
 utiltest utiltest-no-data-check:
 	$(qexec)$(SRC_PATH_BARE)/test/aomdec.sh \
-		--test-data-path $(LIBVPX_TEST_DATA_PATH) \
+		--test-data-path $(LIBAOM_TEST_DATA_PATH) \
 		--bin-path $(TEST_BIN_PATH)
 	$(qexec)$(SRC_PATH_BARE)/test/aomenc.sh \
-		--test-data-path $(LIBVPX_TEST_DATA_PATH) \
+		--test-data-path $(LIBAOM_TEST_DATA_PATH) \
 		--bin-path $(TEST_BIN_PATH)
 utiltest: testdata
 else
@@ -581,7 +581,7 @@
 endif
 exampletest exampletest-no-data-check: examples
 	$(qexec)$(SRC_PATH_BARE)/test/examples.sh \
-		--test-data-path $(LIBVPX_TEST_DATA_PATH) \
+		--test-data-path $(LIBAOM_TEST_DATA_PATH) \
 		--bin-path $(EXAMPLES_BIN_PATH)
 exampletest: testdata
 else
diff --git a/test/aomdec.sh b/test/aomdec.sh
index 1589184..28901ed 100755
--- a/test/aomdec.sh
+++ b/test/aomdec.sh
@@ -20,7 +20,7 @@
     if [ ! -e "${AV1_WEBM_FILE}" ] || \
       [ ! -e "${AV1_FPM_WEBM_FILE}" ] || \
       [ ! -e "${AV1_LT_50_FRAMES_WEBM_FILE}" ] ; then
-      elog "Libaom test data must exist in LIBVPX_TEST_DATA_PATH."
+      elog "Libaom test data must exist in LIBAOM_TEST_DATA_PATH."
       return 1
     fi
   fi
diff --git a/test/aomenc.sh b/test/aomenc.sh
index 2b137ca..79f3a33 100755
--- a/test/aomenc.sh
+++ b/test/aomenc.sh
@@ -20,13 +20,13 @@
 # Environment check: Make sure input is available.
 aomenc_verify_environment() {
   if [ ! -e "${YUV_RAW_INPUT}" ]; then
-    elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBVPX_TEST_DATA_PATH."
+    elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBAOM_TEST_DATA_PATH."
     return 1
   fi
   if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
     if [ ! -e "${Y4M_NOSQ_PAR_INPUT}" ]; then
       elog "The file ${Y4M_NOSQ_PAR_INPUT##*/} must exist in"
-      elog "LIBVPX_TEST_DATA_PATH."
+      elog "LIBAOM_TEST_DATA_PATH."
       return 1
     fi
   fi
diff --git a/test/decode_perf_test.cc b/test/decode_perf_test.cc
index 00d1ed9..7035e30 100644
--- a/test/decode_perf_test.cc
+++ b/test/decode_perf_test.cc
@@ -147,7 +147,7 @@
   }
 
   virtual void BeginPassHook(unsigned int /*pass*/) {
-    const std::string data_path = getenv("LIBVPX_TEST_DATA_PATH");
+    const std::string data_path = getenv("LIBAOM_TEST_DATA_PATH");
     const std::string path_to_source = data_path + "/" + kNewEncodeOutputFile;
     outfile_ = fopen(path_to_source.c_str(), "wb");
     ASSERT_TRUE(outfile_ != NULL);
diff --git a/test/set_maps.sh b/test/set_maps.sh
index eada6d3..4f59b06 100755
--- a/test/set_maps.sh
+++ b/test/set_maps.sh
@@ -19,7 +19,7 @@
 # $LIBAOM_BIN_PATH.
 set_maps_verify_environment() {
   if [ ! -e "${YUV_RAW_INPUT}" ]; then
-    echo "Libaom test data must exist in LIBVPX_TEST_DATA_PATH."
+    echo "Libaom test data must exist in LIBAOM_TEST_DATA_PATH."
     return 1
   fi
   if [ -z "$(aom_tool_path set_maps)" ]; then
diff --git a/test/simple_encoder.sh b/test/simple_encoder.sh
index 3657156..5cd6b46 100755
--- a/test/simple_encoder.sh
+++ b/test/simple_encoder.sh
@@ -18,7 +18,7 @@
 # Environment check: $YUV_RAW_INPUT is required.
 simple_encoder_verify_environment() {
   if [ ! -e "${YUV_RAW_INPUT}" ]; then
-    echo "Libaom test data must exist in LIBVPX_TEST_DATA_PATH."
+    echo "Libaom test data must exist in LIBAOM_TEST_DATA_PATH."
     return 1
   fi
 }
diff --git a/test/tools_common.sh b/test/tools_common.sh
index 797c664..254e6b2 100755
--- a/test/tools_common.sh
+++ b/test/tools_common.sh
@@ -118,12 +118,12 @@
 }
 
 # This script requires that the LIBAOM_BIN_PATH, LIBAOM_CONFIG_PATH, and
-# LIBVPX_TEST_DATA_PATH variables are in the environment: Confirm that
+# LIBAOM_TEST_DATA_PATH variables are in the environment: Confirm that
 # the variables are set and that they all evaluate to directory paths.
 verify_aom_test_environment() {
   test_env_var_dir "LIBAOM_BIN_PATH" \
     && test_env_var_dir "LIBAOM_CONFIG_PATH" \
-    && test_env_var_dir "LIBVPX_TEST_DATA_PATH"
+    && test_env_var_dir "LIBAOM_TEST_DATA_PATH"
 }
 
 # Greps aom_config.h in LIBAOM_CONFIG_PATH for positional parameter one, which
@@ -295,7 +295,7 @@
     \$LIBAOM_CONFIG_PATH and then the current directory.
 
     When the -test-data-path option is not specified the script attempts to use
-    \$LIBVPX_TEST_DATA_PATH and then the current directory.
+    \$LIBAOM_TEST_DATA_PATH and then the current directory.
 EOF
 }
 
@@ -304,7 +304,7 @@
 aom_test_check_environment() {
   if [ -z "${LIBAOM_BIN_PATH}" ] || \
      [ -z "${LIBAOM_CONFIG_PATH}" ] || \
-     [ -z "${LIBVPX_TEST_DATA_PATH}" ]; then
+     [ -z "${LIBAOM_TEST_DATA_PATH}" ]; then
     return 1
   fi
 }
@@ -360,7 +360,7 @@
       exit
       ;;
     --test-data-path)
-      LIBVPX_TEST_DATA_PATH="$2"
+      LIBAOM_TEST_DATA_PATH="$2"
       shift
       ;;
     --prefix)
@@ -388,7 +388,7 @@
 # the tests on *nix/macosx.
 LIBAOM_BIN_PATH="${LIBAOM_BIN_PATH:-.}"
 LIBAOM_CONFIG_PATH="${LIBAOM_CONFIG_PATH:-.}"
-LIBVPX_TEST_DATA_PATH="${LIBVPX_TEST_DATA_PATH:-.}"
+LIBAOM_TEST_DATA_PATH="${LIBAOM_TEST_DATA_PATH:-.}"
 
 # Create a temporary directory for output files, and a trap to clean it up.
 if [ -n "${TMPDIR}" ]; then
@@ -413,19 +413,19 @@
 fi
 
 # Variables shared by tests.
-VP8_IVF_FILE="${LIBVPX_TEST_DATA_PATH}/vp80-00-comprehensive-001.ivf"
-AV1_IVF_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-09-subpixel-00.ivf"
+VP8_IVF_FILE="${LIBAOM_TEST_DATA_PATH}/vp80-00-comprehensive-001.ivf"
+AV1_IVF_FILE="${LIBAOM_TEST_DATA_PATH}/vp90-2-09-subpixel-00.ivf"
 
-AV1_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-00-quantizer-00.webm"
-AV1_FPM_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-07-frame_parallel-1.webm"
-AV1_LT_50_FRAMES_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-02-size-32x08.webm"
+AV1_WEBM_FILE="${LIBAOM_TEST_DATA_PATH}/vp90-2-00-quantizer-00.webm"
+AV1_FPM_WEBM_FILE="${LIBAOM_TEST_DATA_PATH}/vp90-2-07-frame_parallel-1.webm"
+AV1_LT_50_FRAMES_WEBM_FILE="${LIBAOM_TEST_DATA_PATH}/vp90-2-02-size-32x08.webm"
 
-YUV_RAW_INPUT="${LIBVPX_TEST_DATA_PATH}/hantro_collage_w352h288.yuv"
+YUV_RAW_INPUT="${LIBAOM_TEST_DATA_PATH}/hantro_collage_w352h288.yuv"
 YUV_RAW_INPUT_WIDTH=352
 YUV_RAW_INPUT_HEIGHT=288
 
-Y4M_NOSQ_PAR_INPUT="${LIBVPX_TEST_DATA_PATH}/park_joy_90p_8_420_a10-1.y4m"
-Y4M_720P_INPUT="${LIBVPX_TEST_DATA_PATH}/niklas_1280_720_30.y4m"
+Y4M_NOSQ_PAR_INPUT="${LIBAOM_TEST_DATA_PATH}/park_joy_90p_8_420_a10-1.y4m"
+Y4M_720P_INPUT="${LIBAOM_TEST_DATA_PATH}/niklas_1280_720_30.y4m"
 
 # Setup a trap function to clean up after tests complete.
 trap cleanup EXIT
@@ -433,7 +433,7 @@
 vlog "$(basename "${0%.*}") test configuration:
   LIBAOM_BIN_PATH=${LIBAOM_BIN_PATH}
   LIBAOM_CONFIG_PATH=${LIBAOM_CONFIG_PATH}
-  LIBVPX_TEST_DATA_PATH=${LIBVPX_TEST_DATA_PATH}
+  LIBAOM_TEST_DATA_PATH=${LIBAOM_TEST_DATA_PATH}
   AOM_IVF_FILE=${AOM_IVF_FILE}
   AV1_IVF_FILE=${AV1_IVF_FILE}
   AV1_WEBM_FILE=${AV1_WEBM_FILE}
diff --git a/test/twopass_encoder.sh b/test/twopass_encoder.sh
index b08de86..3abb762 100755
--- a/test/twopass_encoder.sh
+++ b/test/twopass_encoder.sh
@@ -18,7 +18,7 @@
 # Environment check: $YUV_RAW_INPUT is required.
 twopass_encoder_verify_environment() {
   if [ ! -e "${YUV_RAW_INPUT}" ]; then
-    echo "Libaom test data must exist in LIBVPX_TEST_DATA_PATH."
+    echo "Libaom test data must exist in LIBAOM_TEST_DATA_PATH."
     return 1
   fi
 }
diff --git a/test/video_source.h b/test/video_source.h
index db79308..e986ffb 100644
--- a/test/video_source.h
+++ b/test/video_source.h
@@ -25,22 +25,22 @@
 
 namespace libaom_test {
 
-// Helper macros to ensure LIBVPX_TEST_DATA_PATH is a quoted string.
+// Helper macros to ensure LIBAOM_TEST_DATA_PATH is a quoted string.
 // These are undefined right below GetDataPath
-// NOTE: LIBVPX_TEST_DATA_PATH MUST NOT be a quoted string before
+// NOTE: LIBAOM_TEST_DATA_PATH MUST NOT be a quoted string before
 // Stringification or the GetDataPath will fail at runtime
 #define TO_STRING(S) #S
 #define STRINGIFY(S) TO_STRING(S)
 
 // A simple function to encapsulate cross platform retrieval of test data path
 static std::string GetDataPath() {
-  const char *const data_path = getenv("LIBVPX_TEST_DATA_PATH");
+  const char *const data_path = getenv("LIBAOM_TEST_DATA_PATH");
   if (data_path == NULL) {
-#ifdef LIBVPX_TEST_DATA_PATH
+#ifdef LIBAOM_TEST_DATA_PATH
     // In some environments, we cannot set environment variables
     // Instead, we set the data path by using a preprocessor symbol
     // which can be set from make files
-    return STRINGIFY(LIBVPX_TEST_DATA_PATH);
+    return STRINGIFY(LIBAOM_TEST_DATA_PATH);
 #else
     return ".";
 #endif