Update aomenc shell tests.

- Make them faster by setting cpu-used to 1.
- Drop unused cruft and redundant args to aomenc.
- Add some shell util functions for producing "fast" encode
  settings and frame count limits while ensuring lag-in-frames
  is sane for the given limit.

Change-Id: I61288f9f120201decb25fdfe9516b75d84cfb2ee
diff --git a/test/aomenc.sh b/test/aomenc.sh
index 57a4c28..5d17b0b 100755
--- a/test/aomenc.sh
+++ b/test/aomenc.sh
@@ -15,8 +15,6 @@
 ##
 . $(dirname $0)/tools_common.sh
 
-readonly TEST_FRAMES=5
-
 # Environment check: Make sure input is available.
 aomenc_verify_environment() {
   if [ ! -e "${YUV_RAW_INPUT}" ]; then
@@ -57,32 +55,6 @@
   echo ""${Y4M_720P_INPUT}""
 }
 
-# Echo default aomenc real time encoding params. $1 is the codec, which defaults
-# to av1 if unspecified.
-aomenc_rt_params() {
-  local readonly codec="${1:-av1}"
-  echo "--codec=${codec}
-    --buf-initial-sz=500
-    --buf-optimal-sz=600
-    --buf-sz=1000
-    --cpu-used=-6
-    --end-usage=cbr
-    --error-resilient=1
-    --kf-max-dist=90000
-    --lag-in-frames=0
-    --max-intra-rate=300
-    --max-q=56
-    --min-q=2
-    --noise-sensitivity=0
-    --overshoot-pct=50
-    --passes=1
-    --profile=0
-    --resize-allowed=0
-    --rt
-    --static-thresh=0
-    --undershoot-pct=50"
-}
-
 # Wrapper function for running aomenc with pipe input. Requires that
 # LIBAOM_BIN_PATH points to the directory containing aomenc. $1 is used as the
 # input file path and shifted away. All remaining parameters are passed through
@@ -112,8 +84,8 @@
   if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
     local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.ivf"
     aomenc $(yuv_raw_input) \
-      --codec=av1 \
-      --limit="${TEST_FRAMES}" \
+      $(aomenc_encode_test_fast_params) \
+      --passes=1 \
       --ivf \
       --output="${output}"
 
@@ -130,7 +102,8 @@
     local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm"
     aomenc $(yuv_raw_input) \
       --codec=av1 \
-      --limit="${TEST_FRAMES}" \
+      $(aomenc_encode_test_fast_params) \
+      --passes=1 \
       --output="${output}"
 
     if [ ! -e "${output}" ]; then
@@ -145,10 +118,9 @@
      [ "$(webm_io_available)" = "yes" ]; then
     local readonly output="${AOM_TEST_OUTPUT_DIR}/av1.webm"
     aomenc $(yuv_raw_input) \
-      --codec=av1 \
-      --limit="${TEST_FRAMES}" \
-      --output="${output}" \
-      --passes=2
+      $(aomenc_encode_test_fast_params) \
+      --passes=2 \
+      --output="${output}"
 
     if [ ! -e "${output}" ]; then
       elog "Output file does not exist."
@@ -161,8 +133,7 @@
   if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
     local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless.ivf"
     aomenc $(yuv_raw_input) \
-      --codec=av1 \
-      --limit="${TEST_FRAMES}" \
+      $(aomenc_encode_test_fast_params) \
       --ivf \
       --output="${output}" \
       --lossless=1
@@ -178,8 +149,7 @@
   if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
     local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lossless_minq0_maxq0.ivf"
     aomenc $(yuv_raw_input) \
-      --codec=av1 \
-      --limit="${TEST_FRAMES}" \
+      $(aomenc_encode_test_fast_params) \
       --ivf \
       --output="${output}" \
       --min-q=0 \
@@ -199,12 +169,11 @@
     local readonly lag_frames=5
     local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_lag5_frames10.webm"
     aomenc $(yuv_raw_input) \
-      --codec=av1 \
-      --limit="${lag_total_frames}" \
-      --lag-in-frames="${lag_frames}" \
+      $(aomenc_encode_test_fast_params) \
+      --limit=${lag_total_frames} \
+      --lag-in-frames=${lag_frames} \
       --output="${output}" \
-      --passes=2 \
-      --auto-alt-ref=1
+      --passes=2
 
     if [ ! -e "${output}" ]; then
       elog "Output file does not exist."
@@ -219,8 +188,7 @@
      [ "$(webm_io_available)" = "yes" ]; then
     local readonly output="${AOM_TEST_OUTPUT_DIR}/av1_non_square_par.webm"
     aomenc $(y4m_input_non_square_par) \
-      --codec=av1 \
-      --limit="${TEST_FRAMES}" \
+      $(aomenc_encode_test_fast_params) \
       --output="${output}"
 
     if [ ! -e "${output}" ]; then
diff --git a/test/tools_common.sh b/test/tools_common.sh
index 080d40b..0998c2b 100755
--- a/test/tools_common.sh
+++ b/test/tools_common.sh
@@ -17,6 +17,7 @@
 set -e
 devnull='> /dev/null 2>&1'
 AOM_TEST_PREFIX=""
+readonly AOM_ENCODE_TEST_FRAME_LIMIT=5
 
 elog() {
   echo "$@" 1>&2
@@ -212,6 +213,14 @@
   [ "$(aom_config_option_enabled CONFIG_AV1_ENCODER)" = "yes" ] && echo yes
 }
 
+# Echoes "fast" encode params for use with aomenc.
+aomenc_encode_test_fast_params() {
+  echo "--cpu-used=1
+        --limit=${AOM_ENCODE_TEST_FRAME_LIMIT}
+        --lag-in-frames=0
+        --test-decode=fatal"
+}
+
 # Echoes yes to stdout when aom_config_option_enabled() reports yes for
 # CONFIG_WEBM_IO.
 webm_io_available() {