[LibvpxVp8Encoder] Allow I420A to be scaled to I420.

In Chromium, the I420ABufferInterface implementation uses the default
CropAndScale() implementation which converts to I420 in the process.

This should be OK, because we do not encode the alpha channel anyway,
so having WebRTC scaling ignore the alpha channel might even be a good
thing. Unfortunatety, an if statement in the LibvpxVp8Encoder did not
consider I420A and I420 to be the same, resulting in dropping perfectly
valid frames.

This CL fixes that by considering I420A and I420 "compatible" in a
comparison helper function. The problem only happens in this encoder,
so only this encoder needs to be fixed.

TBR=ilnik@chromium.org,eshr@google.com

(cherry picked from commit 065ce9cb227a86ca9c5cf1469a5edd9ffd7a662a)

Bug: chromium:1203206
Change-Id: Iec434d4ada897c79e09914cac823148fd5b05e57
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216323
Reviewed-by: Evan Shrubsole <eshr@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Original-Commit-Position: refs/heads/master@{#33845}
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216682
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/branch-heads/4472@{#9}
Cr-Branched-From: 3e0c60ba4ef28a9f26fe991e5eec3150402c7dd3-refs/heads/master@{#33644}
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index 2411c16..6a8a901 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -161,6 +161,18 @@
   }
 }
 
+bool IsCompatibleVideoFrameBufferType(VideoFrameBuffer::Type left,
+                                      VideoFrameBuffer::Type right) {
+  if (left == VideoFrameBuffer::Type::kI420 ||
+      left == VideoFrameBuffer::Type::kI420A) {
+    // LibvpxVp8Encoder does not care about the alpha channel, I420A and I420
+    // are considered compatible.
+    return right == VideoFrameBuffer::Type::kI420 ||
+           right == VideoFrameBuffer::Type::kI420A;
+  }
+  return left == right;
+}
+
 void SetRawImagePlanes(vpx_image_t* raw_image, VideoFrameBuffer* buffer) {
   switch (buffer->type()) {
     case VideoFrameBuffer::Type::kI420:
@@ -1378,7 +1390,8 @@
     }
     RTC_DCHECK_EQ(scaled_buffer->type(), mapped_buffer->type())
         << "Scaled frames must have the same type as the mapped frame.";
-    if (scaled_buffer->type() != mapped_buffer->type()) {
+    if (!IsCompatibleVideoFrameBufferType(scaled_buffer->type(),
+                                          mapped_buffer->type())) {
       RTC_LOG(LS_ERROR) << "When scaling "
                         << VideoFrameBufferTypeToString(buffer_to_scale->type())
                         << ", the image was unexpectedly converted to "