Bug 1286738 - part2-HardwareCodecCapabilityUtils: Add HasHWVP9() function to check the vp9 hw decoder. r=jya
authorbechen <bechen@mozilla.com>
Wed, 26 Oct 2016 16:57:55 +0800
changeset 347169 05c8cd834019f12c20145fc88a59fe3aa5aa14da
parent 347168 e494b786169940e6495ba006d9ab43f3efec03d3
child 347170 aa540c9dbd1178a5e2e03033b0387725970b9e95
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1286738
milestone52.0a1
Bug 1286738 - part2-HardwareCodecCapabilityUtils: Add HasHWVP9() function to check the vp9 hw decoder. r=jya MozReview-Commit-ID: 1a89GQixKrO
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
widget/android/GeneratedJNIWrappers.cpp
widget/android/GeneratedJNIWrappers.h
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
@@ -19,16 +19,17 @@ public final class HardwareCodecCapabili
 
   // List of supported HW VP8 encoders.
   private static final String[] supportedVp8HwEncCodecPrefixes =
   {"OMX.qcom.", "OMX.Intel." };
   // List of supported HW VP8 decoders.
   private static final String[] supportedVp8HwDecCodecPrefixes =
   {"OMX.qcom.", "OMX.Nvidia.", "OMX.Exynos.", "OMX.Intel." };
   private static final String VP8_MIME_TYPE = "video/x-vnd.on2.vp8";
+  private static final String VP9_MIME_TYPE = "video/x-vnd.on2.vp9";
   // NV12 color format supported by QCOM codec, but not declared in MediaCodec -
   // see /hardware/qcom/media/mm-core/inc/OMX_QCOMExtns.h
   private static final int
     COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m = 0x7FA30C04;
   // Allowable color formats supported by codec - in order of preference.
   private static final int[] supportedColorList = {
     CodecCapabilities.COLOR_FormatYUV420Planar,
     CodecCapabilities.COLOR_FormatYUV420SemiPlanar,
@@ -101,25 +102,34 @@ public final class HardwareCodecCapabili
         }
       }
     }
     // No HW encoder.
     return false;
   }
 
   public static boolean getHWDecoderCapability() {
+    return getHWDecoderCapability(VP8_MIME_TYPE);
+  }
+
+  @WrapForJNI
+  public static boolean HasHWVP9() {
+    return getHWDecoderCapability(VP9_MIME_TYPE);
+  }
+
+  public static boolean getHWDecoderCapability(String aMimeType) {
     if (Versions.feature20Plus) {
       for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
         MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
         if (info.isEncoder()) {
           continue;
         }
         String name = null;
         for (String mimeType : info.getSupportedTypes()) {
-          if (mimeType.equals(VP8_MIME_TYPE)) {
+          if (mimeType.equals(aMimeType)) {
             name = info.getName();
             break;
           }
         }
         if (name == null) {
           continue;  // No HW support in this codec; try the next one.
         }
         Log.e(LOGTAG, "Found candidate decoder " + name);
@@ -133,17 +143,17 @@ public final class HardwareCodecCapabili
           }
         }
         if (!supportedCodec) {
           continue;
         }
 
         // Check if codec supports either yuv420 or nv12.
         CodecCapabilities capabilities =
-          info.getCapabilitiesForType(VP8_MIME_TYPE);
+          info.getCapabilitiesForType(aMimeType);
         for (int colorFormat : capabilities.colorFormats) {
           Log.v(LOGTAG, "   Color: 0x" + Integer.toHexString(colorFormat));
         }
         for (int supportedColorFormat : supportedColorList) {
           for (int codecColorFormat : capabilities.colorFormats) {
             if (codecColorFormat == supportedColorFormat) {
               // Found supported HW decoder.
               Log.e(LOGTAG, "Found target decoder " + name +
--- a/widget/android/GeneratedJNIWrappers.cpp
+++ b/widget/android/GeneratedJNIWrappers.cpp
@@ -1740,16 +1740,24 @@ constexpr char Clipboard::SetText_t::sig
 auto Clipboard::SetText(mozilla::jni::String::Param a0) -> void
 {
     return mozilla::jni::Method<SetText_t>::Call(Clipboard::Context(), nullptr, a0);
 }
 
 const char HardwareCodecCapabilityUtils::name[] =
         "org/mozilla/gecko/util/HardwareCodecCapabilityUtils";
 
+constexpr char HardwareCodecCapabilityUtils::HasHWVP9_t::name[];
+constexpr char HardwareCodecCapabilityUtils::HasHWVP9_t::signature[];
+
+auto HardwareCodecCapabilityUtils::HasHWVP9() -> bool
+{
+    return mozilla::jni::Method<HasHWVP9_t>::Call(HardwareCodecCapabilityUtils::Context(), nullptr);
+}
+
 constexpr char HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType_t::name[];
 constexpr char HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType_t::signature[];
 
 auto HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType(mozilla::jni::String::Param a0) -> bool
 {
     return mozilla::jni::Method<FindDecoderCodecInfoForMimeType_t>::Call(HardwareCodecCapabilityUtils::Context(), nullptr, a0);
 }
 
--- a/widget/android/GeneratedJNIWrappers.h
+++ b/widget/android/GeneratedJNIWrappers.h
@@ -4809,16 +4809,35 @@ public:
 
 class HardwareCodecCapabilityUtils : public mozilla::jni::ObjectBase<HardwareCodecCapabilityUtils>
 {
 public:
     static const char name[];
 
     explicit HardwareCodecCapabilityUtils(const Context& ctx) : ObjectBase<HardwareCodecCapabilityUtils>(ctx) {}
 
+    struct HasHWVP9_t {
+        typedef HardwareCodecCapabilityUtils Owner;
+        typedef bool ReturnType;
+        typedef bool SetterType;
+        typedef mozilla::jni::Args<> Args;
+        static constexpr char name[] = "HasHWVP9";
+        static constexpr char signature[] =
+                "()Z";
+        static const bool isStatic = true;
+        static const mozilla::jni::ExceptionMode exceptionMode =
+                mozilla::jni::ExceptionMode::ABORT;
+        static const mozilla::jni::CallingThread callingThread =
+                mozilla::jni::CallingThread::ANY;
+        static const mozilla::jni::DispatchTarget dispatchTarget =
+                mozilla::jni::DispatchTarget::CURRENT;
+    };
+
+    static auto HasHWVP9() -> bool;
+
     struct FindDecoderCodecInfoForMimeType_t {
         typedef HardwareCodecCapabilityUtils Owner;
         typedef bool ReturnType;
         typedef bool SetterType;
         typedef mozilla::jni::Args<
                 mozilla::jni::String::Param> Args;
         static constexpr char name[] = "findDecoderCodecInfoForMimeType";
         static constexpr char signature[] =