Use dav1d by default

This CL turns on dav1d by default. It also disables libaom to save on
binary size.

Bug: 924370
Change-Id: I4d331a3b66fe6031930f5f56880866b9a3c92df8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1539901
Commit-Queue: Chrome Cunningham <chcunningham@chromium.org>
Auto-Submit: Thomas Guilbert <tguilbert@chromium.org>
Reviewed-by: Tom Finegan <tomfinegan@chromium.org>
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#645600}
diff --git a/media/base/media_switches.cc b/media/base/media_switches.cc
index ca6a9dd..794290d 100644
--- a/media/base/media_switches.cc
+++ b/media/base/media_switches.cc
@@ -258,10 +258,6 @@
 const base::Feature kD3D11VideoDecoderIgnoreWorkarounds{
     "D3D11VideoDecoderIgnoreWorkarounds", base::FEATURE_DISABLED_BY_DEFAULT};
 
-// Enable usage of dav1d for AV1 video decoding.
-const base::Feature kDav1dVideoDecoder{"Dav1dVideoDecoder",
-                                       base::FEATURE_DISABLED_BY_DEFAULT};
-
 // Falls back to other decoders after audio/video decode error happens. The
 // implementation may choose different strategies on when to fallback. See
 // DecoderStream for details. When disabled, playback will fail immediately
diff --git a/media/base/media_switches.h b/media/base/media_switches.h
index fbde1f5..de8f2bc 100644
--- a/media/base/media_switches.h
+++ b/media/base/media_switches.h
@@ -101,7 +101,6 @@
 MEDIA_EXPORT extern const base::Feature kBackgroundVideoPauseOptimization;
 MEDIA_EXPORT extern const base::Feature kD3D11VideoDecoder;
 MEDIA_EXPORT extern const base::Feature kD3D11VideoDecoderIgnoreWorkarounds;
-MEDIA_EXPORT extern const base::Feature kDav1dVideoDecoder;
 MEDIA_EXPORT extern const base::Feature kExternalClearKeyForTesting;
 MEDIA_EXPORT extern const base::Feature kFallbackAfterDecodeError;
 MEDIA_EXPORT extern const base::Feature kHardwareMediaKeyHandling;
diff --git a/media/cdm/library_cdm/clear_key_cdm/cdm_video_decoder.cc b/media/cdm/library_cdm/clear_key_cdm/cdm_video_decoder.cc
index f568983..fc984ef 100644
--- a/media/cdm/library_cdm/clear_key_cdm/cdm_video_decoder.cc
+++ b/media/cdm/library_cdm/clear_key_cdm/cdm_video_decoder.cc
@@ -36,6 +36,10 @@
 #include "media/filters/aom_video_decoder.h"
 #endif
 
+#if BUILDFLAG(ENABLE_DAV1D_DECODER)
+#include "media/filters/dav1d_video_decoder.h"
+#endif
+
 #if BUILDFLAG(ENABLE_FFMPEG)
 #include "media/filters/ffmpeg_video_decoder.h"
 #endif
@@ -300,7 +304,10 @@
     video_decoder.reset(new VpxVideoDecoder());
 #endif
 
-#if BUILDFLAG(ENABLE_LIBAOM_DECODER)
+#if BUILDFLAG(ENABLE_DAV1D_DECODER)
+  if (config.codec == cdm::kCodecAv1)
+    video_decoder.reset(new Dav1dVideoDecoder(null_media_log.get()));
+#elif BUILDFLAG(ENABLE_LIBAOM_DECODER)
   if (config.codec == cdm::kCodecAv1)
     video_decoder.reset(new AomVideoDecoder(null_media_log.get()));
 #endif
diff --git a/media/media_options.gni b/media/media_options.gni
index 49d861e..4460ffc 100644
--- a/media/media_options.gni
+++ b/media/media_options.gni
@@ -84,12 +84,14 @@
   # are combined and we could override more logging than expected.
   enable_logging_override = !use_jumbo_build && is_chromecast
 
-  # Dav1d is only enabled when av1 decoding is enabled.
   if (is_win && target_cpu == "arm64") {
     # TODO: Enable dav1d for Windows ARM64. https://crbug.com/941022
     enable_dav1d_decoder = false
+  } else if (is_fuchsia && target_cpu == "x64") {
+    # TODO: Fix media_unittests for fuchsia X64. https://crbug.com/930300
+    enable_dav1d_decoder = false
   } else {
-    enable_dav1d_decoder = enable_libaom_decoder
+    enable_dav1d_decoder = !is_android && !is_ios
   }
 }
 
diff --git a/media/renderers/default_decoder_factory.cc b/media/renderers/default_decoder_factory.cc
index e293551..dd7fc88 100644
--- a/media/renderers/default_decoder_factory.cc
+++ b/media/renderers/default_decoder_factory.cc
@@ -121,12 +121,7 @@
 #endif
 
 #if BUILDFLAG(ENABLE_DAV1D_DECODER)
-  if (base::FeatureList::IsEnabled(kDav1dVideoDecoder))
-    video_decoders->push_back(std::make_unique<Dav1dVideoDecoder>(media_log));
-#if BUILDFLAG(ENABLE_LIBAOM_DECODER)
-  else
-    video_decoders->push_back(std::make_unique<AomVideoDecoder>(media_log));
-#endif
+  video_decoders->push_back(std::make_unique<Dav1dVideoDecoder>(media_log));
 #elif BUILDFLAG(ENABLE_LIBAOM_DECODER)
   video_decoders->push_back(std::make_unique<AomVideoDecoder>(media_log));
 #endif
diff --git a/media/test/pipeline_integration_fuzzertest.cc b/media/test/pipeline_integration_fuzzertest.cc
index d38844c..9d69367e 100644
--- a/media/test/pipeline_integration_fuzzertest.cc
+++ b/media/test/pipeline_integration_fuzzertest.cc
@@ -252,18 +252,6 @@
       media::ProgressivePipelineIntegrationFuzzerTest test;
       test.RunTest(data, size);
     }
-
-#if BUILDFLAG(ENABLE_DAV1D_DECODER)
-    {
-      // Rerun the test with the dav1d video decoder instead of libaom. Note:
-      // this ends up running for all SRC fuzzing and not just AV1 content, but
-      // that's true for our entire corpus.
-      base::test::ScopedFeatureList features_with_dav1d;
-      features_with_dav1d.InitAndEnableFeature(media::kDav1dVideoDecoder);
-      media::ProgressivePipelineIntegrationFuzzerTest test;
-      test.RunTest(data, size);
-    }
-#endif
   } else {
     // Sequentially fuzz with new and old MSE buffering APIs.  See
     // https://crbug.com/718641.
@@ -281,17 +269,6 @@
       media::MediaSourcePipelineIntegrationFuzzerTest test;
       test.RunTest(data, size, MseFuzzerVariantEnumToMimeTypeString(variant));
     }
-
-#if BUILDFLAG(ENABLE_DAV1D_DECODER)
-    // Rerun the test with the dav1d video decoder instead of libaom. No need to
-    // run with ByPts in both configurations, just use the default.
-    if (variant == MP4_AV1) {
-      base::test::ScopedFeatureList features_with_dav1d;
-      features_with_dav1d.InitAndEnableFeature(media::kDav1dVideoDecoder);
-      media::MediaSourcePipelineIntegrationFuzzerTest test;
-      test.RunTest(data, size, MseFuzzerVariantEnumToMimeTypeString(variant));
-    }
-#endif
   }
 
   return 0;
diff --git a/media/test/pipeline_integration_test_base.cc b/media/test/pipeline_integration_test_base.cc
index 33824a8..d1fb9701 100644
--- a/media/test/pipeline_integration_test_base.cc
+++ b/media/test/pipeline_integration_test_base.cc
@@ -74,12 +74,7 @@
 #endif
 
 #if BUILDFLAG(ENABLE_DAV1D_DECODER)
-  if (base::FeatureList::IsEnabled(kDav1dVideoDecoder))
-    video_decoders.push_back(std::make_unique<Dav1dVideoDecoder>(media_log));
-#if BUILDFLAG(ENABLE_LIBAOM_DECODER)
-  else
-    video_decoders.push_back(std::make_unique<AomVideoDecoder>(media_log));
-#endif
+  video_decoders.push_back(std::make_unique<Dav1dVideoDecoder>(media_log));
 #elif BUILDFLAG(ENABLE_LIBAOM_DECODER)
   video_decoders.push_back(std::make_unique<AomVideoDecoder>(media_log));
 #endif
diff --git a/third_party/libaom/options.gni b/third_party/libaom/options.gni
index c3d0236..b9480b2 100644
--- a/third_party/libaom/options.gni
+++ b/third_party/libaom/options.gni
@@ -2,5 +2,5 @@
 
 declare_args() {
   # Enable decoding AV1 video files.
-  enable_libaom_decoder = !is_android && !is_ios
+  enable_libaom_decoder = false
 }