Check global.pass when enforcing one-pass encoding

In parse_global_config(), when enforcing one-pass encoding in realtime
mode, check if global.pass is valid.

To reproduce this condition, pass --pass=2 --usage=1 to aomenc. After
setting global.pass to 2 and global.usage to 1 from the command-line
options, parse_global_config() performs the following two

1. It first sets global.passes to 2 to match global.pass.

2. It then changes global.passes to 1 because global.usage is 1

I propose that before changing global.passes to 1 we should check if
global.pass would be consistent with global.passes=1.

NOTE: This CL is an alternative way to fix the crash reported in


Change-Id: I29e8f7a3cda1bbd9e2e1219873dcd152fe191ca4
diff --git a/apps/aomenc.c b/apps/aomenc.c
index 11035bf..da3b914 100644
--- a/apps/aomenc.c
+++ b/apps/aomenc.c
@@ -681,6 +681,8 @@
   if (global->usage == AOM_USAGE_REALTIME && global->passes > 1) {
     warn("Enforcing one-pass encoding in realtime mode\n");
+    if (global->pass > 1)
+      die("Error: Invalid --pass=%d for one-pass encoding\n", global->pass);
     global->passes = 1;