Make the encoder ABI check allow v3.0.0 and v3.1.x

Make the encoder ABI check allow binaries compiled against libaom v3.0.0
or v3.1.x. In those libaom releases, the value of
AOM_ENCODER_ABI_VERSION is 25. Change the encoder ABI check to also
allow the 'ver' parameter to be equal to 25.

Bug: aomedia:3288
Change-Id: I81804be92cbdc77163b415a2156679af64b59520
(cherry picked from commit 45e8b7c56953a5961742d6b7e5f7532333c49d22)
diff --git a/aom/src/aom_encoder.c b/aom/src/aom_encoder.c
index 5dfda96..6ec2f34 100644
--- a/aom/src/aom_encoder.c
+++ b/aom/src/aom_encoder.c
@@ -39,8 +39,25 @@
                                        const aom_codec_enc_cfg_t *cfg,
                                        aom_codec_flags_t flags, int ver) {
   aom_codec_err_t res;
+  // The value of AOM_ENCODER_ABI_VERSION in libaom v3.0.0 and v3.1.0 - v3.1.3.
+  //
+  // We are compatible with these older libaom releases. AOM_ENCODER_ABI_VERSION
+  // was incremented after these releases for two reasons:
+  // 1. AOM_ENCODER_ABI_VERSION takes contribution from
+  //    AOM_EXT_PART_ABI_VERSION. The external partition API is still
+  //    experimental, so it should not be considered as part of the stable ABI.
+  //    fd9ed8366 External partition: Define APIs
+  //    https://aomedia-review.googlesource.com/c/aom/+/135663
+  // 2. As a way to detect the presence of speeds 7-9 in all-intra mode. I (wtc)
+  //    suggested this change because I misunderstood how
+  //    AOM_ENCODER_ABI_VERSION was used.
+  //    bbdfa68d1 AllIntra: Redefine all-intra mode speed features for speed 7+
+  //    https://aomedia-review.googlesource.com/c/aom/+/140624
+  const int aom_encoder_abi_version_25 = 25;
 
-  if (ver != AOM_ENCODER_ABI_VERSION)
+  // TODO(bug aomedia:3228): Remove the check for aom_encoder_abi_version_25 in
+  // libaom v4.0.0.
+  if (ver != AOM_ENCODER_ABI_VERSION && ver != aom_encoder_abi_version_25)
     res = AOM_CODEC_ABI_MISMATCH;
   else if (!ctx || !iface || !cfg)
     res = AOM_CODEC_INVALID_PARAM;