Bug 1233410 - Support VP8 video in OpenMAX PDM. r=alfredo
authorJohn Lin <jolin@mozilla.com>
Tue, 23 Feb 2016 13:23:51 +0800
changeset 285547 f523d47054813ad85464c6dc898c24908f978b46
parent 285546 06f762ea5c7ffaf01ea1299ffc148f87a26b0264
child 285548 bb4b4249dda8b5372bac11bb36a8b3bf4c44f6c5
push id17822
push usercbook@mozilla.com
push dateThu, 25 Feb 2016 11:00:09 +0000
treeherderfx-team@1c779b0b8969 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersalfredo
bugs1233410
milestone47.0a1
Bug 1233410 - Support VP8 video in OpenMAX PDM. r=alfredo MozReview-Commit-ID: HVxynPLlXKJ
dom/media/platforms/omx/GonkOmxPlatformLayer.cpp
dom/media/platforms/omx/GonkOmxPlatformLayer.h
--- a/dom/media/platforms/omx/GonkOmxPlatformLayer.cpp
+++ b/dom/media/platforms/omx/GonkOmxPlatformLayer.cpp
@@ -30,16 +30,19 @@ extern mozilla::LogModule* GetPDMLog();
 #define LOG(arg, ...) MOZ_LOG(GetPDMLog(), mozilla::LogLevel::Debug, ("GonkOmxPlatformLayer(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 
 #define CHECK_ERR(err)                    \
   if (err != OK)                       {  \
     LOG("error %d at %s", err, __func__); \
     return NS_ERROR_FAILURE;              \
   }                                       \
 
+// Android proprietary value.
+#define ANDROID_OMX_VIDEO_CodingVP8 (static_cast<OMX_VIDEO_CODINGTYPE>(9))
+
 using namespace android;
 
 namespace mozilla {
 
 // In Gonk, the software component name has prefix "OMX.google". It needs to
 // have a way to use hardware codec first.
 bool IsSoftwareCodec(const char* aComponentName)
 {
@@ -613,22 +616,26 @@ GonkOmxPlatformLayer::FindComponents(con
   if (!IsInEmulator() &&
       (aMimeType.EqualsLiteral("video/avc") ||
        aMimeType.EqualsLiteral("video/mp4") ||
        aMimeType.EqualsLiteral("video/mp4v-es") ||
        aMimeType.EqualsLiteral("video/3gp"))) {
     useHardwareCodecOnly = true;
   }
 
+  const char* mime = aMimeType.Data();
+  // Translate VP8 MIME type to Android format.
+  if (aMimeType.EqualsLiteral("video/webm; codecs=vp8")) {
+    mime = "video/x-vnd.on2.vp8";
+  }
+
   size_t start = 0;
   bool found = false;
   while (true) {
-    ssize_t index = codecs->findCodecByType(aMimeType.Data(),
-                                            false /* encoder */,
-                                            start);
+    ssize_t index = codecs->findCodecByType(mime, false /* encoder */, start);
     if (index < 0) {
       break;
     }
     start = index + 1;
 
     const char* name = codecs->getCodecName(index);
     if (IsSoftwareCodec(name) && useHardwareCodecOnly) {
       continue;
@@ -647,9 +654,18 @@ GonkOmxPlatformLayer::FindComponents(con
     if (codecs->codecHasQuirk(index, "requires-allocate-on-output-ports")) {
       comp->mQuirks.set(kRequiresAllocateBufferOnOutputPorts);
     }
   }
 
   return found;
 }
 
+OMX_VIDEO_CODINGTYPE
+GonkOmxPlatformLayer::CompressionFormat()
+{
+  MOZ_ASSERT(mInfo);
+
+  return mInfo->mMimeType.EqualsLiteral("video/webm; codecs=vp8") ?
+    ANDROID_OMX_VIDEO_CodingVP8 : OmxPlatformLayer::CompressionFormat();
+}
+
 } // mozilla
--- a/dom/media/platforms/omx/GonkOmxPlatformLayer.h
+++ b/dom/media/platforms/omx/GonkOmxPlatformLayer.h
@@ -151,16 +151,21 @@ public:
                             OMX_U32 aParam1,
                             OMX_PTR aCmdData) override;
 
   nsresult Shutdown() override;
 
   static bool FindComponents(const nsACString& aMimeType,
                              nsTArray<ComponentInfo>* aComponents = nullptr);
 
+  // Android/QCOM decoder uses its own OMX_VIDEO_CodingVP8 definition in
+  // frameworks/native/media/include/openmax/OMX_Video.h, not the one defined
+  // in OpenMAX v1.1.2 OMX_VideoExt.h
+  OMX_VIDEO_CODINGTYPE CompressionFormat() override;
+
 protected:
   friend GonkBufferData;
 
   layers::ImageContainer* GetImageContainer();
 
   const TrackInfo* GetTrackInfo();
 
   TaskQueue* GetTaskQueue()