Bug 1262335 - Part 2. Remove Android GB/HC defines from OMX. r=snorp
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 06 Apr 2016 17:30:17 +0900
changeset 348361 8a754bf61b4f24e058cc5c36707c9617ee993370
parent 348360 8292a14fe7ced3adedf5554c829ba31229fd3510
child 348362 50100a87187bf91012a817a42992f823ae567085
push id14826
push userbenj@benj.me
push dateThu, 07 Apr 2016 11:56:36 +0000
reviewerssnorp
bugs1262335
milestone48.0a1
Bug 1262335 - Part 2. Remove Android GB/HC defines from OMX. r=snorp MozReview-Commit-ID: HKbYZXftKBc
media/omx-plugin/OmxPlugin.cpp
toolkit/toolkit.mozbuild
--- a/media/omx-plugin/OmxPlugin.cpp
+++ b/media/omx-plugin/OmxPlugin.cpp
@@ -26,23 +26,17 @@
 #define MAX_DECODER_NAME_LEN 256
 #define AVC_MIME_TYPE "video/avc"
 
 #define DEFAULT_STAGEFRIGHT_FLAGS OMXCodec::kClientNeedsFramebuffer
 
 #undef LOG
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "OmxPlugin" , ## args)
 
-#if !defined(MOZ_ANDROID_GB) && !defined(MOZ_ANDROID_HC)
-#define MOZ_ANDROID_V4_OR_ABOVE
-#endif
-
-#if defined(MOZ_ANDROID_V4_OR_ABOVE)
 #include <I420ColorConverter.h>
-#endif
 
 using namespace MPAPI;
 
 #if !defined(MOZ_STAGEFRIGHT_OFF_T)
 #define MOZ_STAGEFRIGHT_OFF_T off64_t
 #endif
 
 using namespace android;
@@ -195,21 +189,19 @@ OmxDecoder::~OmxDecoder()
   if (mVideoSource.get()) {
     mVideoSource->stop();
   }
 
   if (mAudioSource.get()) {
     mAudioSource->stop();
   }
 
-#ifndef MOZ_ANDROID_HC
   if (mColorConverter) {
     delete mColorConverter;
   }
-#endif
 }
 
 class AutoStopMediaSource {
   sp<MediaSource> mMediaSource;
 public:
   AutoStopMediaSource(sp<MediaSource> aMediaSource) : mMediaSource(aMediaSource) {
   }
 
@@ -263,24 +255,22 @@ static uint32_t GetVideoCreationFlags(Pl
   // CreationFlags flags. This is useful for A/B testing hardware and software
   // decoders for performance and bugs. The interesting flag values are:
   //  0 = Let Stagefright choose hardware or software decoding (default)
   //  8 = Force software decoding
   // 16 = Force hardware decoding
   int32_t flags = 0;
   aPluginHost->GetIntPref("media.stagefright.omxcodec.flags", &flags);
   if (flags != 0) {
-#if !defined(MOZ_ANDROID_GB)
     LOG("media.stagefright.omxcodec.flags=%d", flags);
     if ((flags & OMXCodec::kHardwareCodecsOnly) != 0) {
       LOG("FORCE HARDWARE DECODING");
     } else if ((flags & OMXCodec::kSoftwareCodecsOnly) != 0) {
       LOG("FORCE SOFTWARE DECODING");
     }
-#endif
   }
 
   flags |= GetDefaultStagefrightFlags(aPluginHost);
 
   return static_cast<uint32_t>(flags);
 #endif
 }
 
@@ -305,32 +295,28 @@ IsColorFormatSupported(OMX_COLOR_FORMATT
       // slow software conversion.
       return ColorFormatSupportPreferred;
     default:
       break;
   }
 
   // These formats are okay if we can't find a better one; Android provides a
   // software conversion to a sane colour format.
-#if !defined(MOZ_ANDROID_HC)
   if (ColorConverter(aColorFormat, OMX_COLOR_Format16bitRGB565).isValid()) {
     LOG("Colour format %#x supported by Android ColorConverter.", aColorFormat);
     return ColorFormatSupportOK;
   }
-#endif
 
-#if defined(MOZ_ANDROID_V4_OR_ABOVE)
   I420ColorConverter yuvConverter;
 
   if (yuvConverter.isLoaded() &&
       yuvConverter.getDecoderOutputFormat() == aColorFormat) {
     LOG("Colour format %#x supported by Android I420ColorConverter.", aColorFormat);
     return ColorFormatSupportOK;
   }
-#endif
 
   return ColorFormatNotSupported;
 }
 
 #if defined(MOZ_ANDROID_KK)
 /**
  * Look for a decoder that supports a colour format that we support.
  */
@@ -428,21 +414,17 @@ static sp<MediaSource> CreateVideoSource
       LOG("Unknown video color format: %#x", videoColorFormat);
     } else {
       LOG("Video color format not found");
     }
 
     // Throw away the videoSource and try again with new flags.
     LOG("Falling back to software decoder");
     videoSource.clear();
-#if defined(MOZ_ANDROID_GB)
-    flags = DEFAULT_STAGEFRIGHT_FLAGS | OMXCodec::kPreferSoftwareCodecs;
-#else
     flags = DEFAULT_STAGEFRIGHT_FLAGS | OMXCodec::kSoftwareCodecsOnly;
-#endif
   }
 
   MOZ_ASSERT(flags != DEFAULT_STAGEFRIGHT_FLAGS);
   return OMXCodec::Create(aOmx, aVideoTrack->getFormat(), false, aVideoTrack,
                           nullptr, flags);
 }
 
 bool OmxDecoder::Init()
@@ -628,28 +610,24 @@ bool OmxDecoder::SetVideoFormat() {
   }
 
   if (mVideoSliceHeight <= 0) {
     LOG("slice height %d must be positive", mVideoSliceHeight);
     return false;
   }
 
   // Gingerbread does not support the kKeyCropRect key
-#if !defined(MOZ_ANDROID_GB)
   if (!format->findRect(kKeyCropRect, &mVideoCropLeft, &mVideoCropTop,
                                       &mVideoCropRight, &mVideoCropBottom)) {
-#endif
     mVideoCropLeft = 0;
     mVideoCropTop = 0;
     mVideoCropRight = mVideoStride - 1;
     mVideoCropBottom = mVideoSliceHeight - 1;
     LOG("crop rect not available, assuming no cropping");
-#if !defined(MOZ_ANDROID_GB)
   }
-#endif
 
   if (mVideoCropLeft < 0 || mVideoCropLeft >= mVideoCropRight || mVideoCropRight >= mVideoStride ||
       mVideoCropTop < 0 || mVideoCropTop >= mVideoCropBottom || mVideoCropBottom >= mVideoSliceHeight) {
     LOG("invalid crop rect %d,%d-%d,%d", mVideoCropLeft, mVideoCropTop, mVideoCropRight, mVideoCropBottom);
     return false;
   }
 
   mVideoWidth = mVideoCropRight - mVideoCropLeft + 1;
@@ -793,19 +771,16 @@ bool OmxDecoder::ToVideoFrame_RGB565(Vid
   memcpy(buffer, aData, mVideoWidth * mVideoHeight * 2);
 
   aFrame->mSize = mVideoWidth * mVideoHeight * 2;
 
   return true;
 }
 
 bool OmxDecoder::ToVideoFrame_ColorConverter(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback) {
-#ifdef MOZ_ANDROID_HC
-  return false;
-#else
   if (!mColorConverter) {
     mColorConverter = new ColorConverter((OMX_COLOR_FORMATTYPE)mVideoColorFormat,
                                          OMX_COLOR_Format16bitRGB565);
   }
 
   if (!mColorConverter->isValid()) {
     return false;
   }
@@ -815,36 +790,28 @@ bool OmxDecoder::ToVideoFrame_ColorConve
   void *buffer = (*aBufferCallback)(mVideoWidth, mVideoHeight, MPAPI::RGB565);
 
   if (!buffer) {
     return false;
   }
 
   aFrame->mSize = mVideoWidth * mVideoHeight * 2;
 
-#if defined(MOZ_ANDROID_GB)
-  mColorConverter->convert(mVideoWidth, mVideoHeight,
-                           aData, 0 /* srcSkip */,
-                           buffer, mVideoWidth * 2);
-#else
   mColorConverter->convert(aData, mVideoStride, mVideoSliceHeight,
                            mVideoCropLeft, mVideoCropTop,
                            mVideoCropLeft + mVideoWidth - 1,
                            mVideoCropTop + mVideoHeight - 1,
                            buffer, mVideoWidth, mVideoHeight,
                            0, 0, mVideoWidth - 1, mVideoHeight - 1);
-#endif
 
   return true;
-#endif
 }
 
 bool OmxDecoder::ToVideoFrame_I420ColorConverter(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback)
 {
-#if defined(MOZ_ANDROID_V4_OR_ABOVE)
   I420ColorConverter yuvConverter;
 
   if (!yuvConverter.isLoaded()) {
     return false;
   }
 
   if (yuvConverter.getDecoderOutputFormat() != mVideoColorFormat) {
     return false;
@@ -861,19 +828,16 @@ bool OmxDecoder::ToVideoFrame_I420ColorC
 
   // result is 0 on success, -1 otherwise.
   if (result == OK) {
     aFrame->mTimeUs = aTimeUs;
     aFrame->mSize = mVideoWidth * mVideoHeight * 3 / 2;
   }
 
   return result == OK;
-#else
-  return false;
-#endif
 }
 
 bool OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback) {
   switch (mVideoColorFormat) {
   case OMX_COLOR_FormatYUV420Planar: // e.g. Asus Transformer, Stagefright's software decoder
     ToVideoFrame_YUV420Planar(aFrame, aTimeUs, aData, aSize, aKeyFrame);
     break;
   case OMX_COLOR_FormatCbYCrY: // e.g. Droid 1
--- a/toolkit/toolkit.mozbuild
+++ b/toolkit/toolkit.mozbuild
@@ -61,25 +61,17 @@ if CONFIG['MOZ_WEBRTC']:
         '/media/mtransport',
     ]
 
 if CONFIG['MOZ_OMX_PLUGIN']:
     DIRS += [
         '/media/omx-plugin/lib/ics/libutils',
         '/media/omx-plugin/lib/ics/libstagefright',
         '/media/omx-plugin/lib/ics/libvideoeditorplayer',
-        '/media/omx-plugin/lib/gb/libutils',
-        '/media/omx-plugin/lib/gb/libstagefright',
-        '/media/omx-plugin/lib/gb/libstagefright_color_conversion',
-        '/media/omx-plugin/lib/gb235/libstagefright',
         '/media/omx-plugin',
-        '/media/omx-plugin/gb',
-        '/media/omx-plugin/gb235',
-        '/media/omx-plugin/lib/hc/libstagefright',
-        '/media/omx-plugin/hc',
         '/media/omx-plugin/kk',
     ]
 
 if CONFIG['ENABLE_TESTS']:
     DIRS += ['/testing/specialpowers']
 
 DIRS += [
     '/testing/gtest',