Bug 1033335: Don't send IDRs to change bitrates or periodic ones to fix encoder errors r=pkerr
authorRandell Jesup <rjesup@jesup.org>
Tue, 07 Oct 2014 14:14:01 -0400
changeset 232442 a5f925b1237e90cbafa715e5181486f28a920a4a
parent 232412 e1b7ef73bdaea35e97cdd4ce48eeb12b873d1a0e
child 232443 781dd1826087adaa947f3548b4fe3126af1a612a
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspkerr
bugs1033335
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1033335: Don't send IDRs to change bitrates or periodic ones to fix encoder errors r=pkerr
media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp
media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.h
--- a/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp
@@ -783,17 +783,19 @@ private:
 // Encoder.
 WebrtcOMXH264VideoEncoder::WebrtcOMXH264VideoEncoder()
   : mOMX(nullptr)
   , mCallback(nullptr)
   , mWidth(0)
   , mHeight(0)
   , mFrameRate(0)
   , mBitRateKbps(0)
+#ifdef OMX_IDR_NEEDED_FOR_BITRATE
   , mBitRateAtLastIDR(0)
+#endif
   , mOMXConfigured(false)
   , mOMXReconfigure(false)
 {
   mReservation = new OMXCodecReservation(true);
   CODEC_LOGD("WebrtcOMXH264VideoEncoder:%p constructed", this);
 }
 
 int32_t
@@ -898,23 +900,26 @@ WebrtcOMXH264VideoEncoder::Encode(const 
                this, mWidth, mHeight, mFrameRate, mBitRateKbps);
     nsresult rv = mOMX->ConfigureDirect(format,
                                         OMXVideoEncoder::BlobFormat::AVC_NAL);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       CODEC_LOGE("WebrtcOMXH264VideoEncoder:%p FAILED configuring encoder %d", this, rv);
       return WEBRTC_VIDEO_CODEC_ERROR;
     }
     mOMXConfigured = true;
+#ifdef OMX_IDR_NEEDED_FOR_BITRATE
     mLastIDRTime = TimeStamp::Now();
     mBitRateAtLastIDR = mBitRateKbps;
+#endif
   }
 
   if (aFrameTypes && aFrameTypes->size() &&
       ((*aFrameTypes)[0] == webrtc::kKeyFrame)) {
     mOMX->RequestIDRFrame();
+#ifdef OMX_IDR_NEEDED_FOR_BITRATE
     mLastIDRTime = TimeStamp::Now();
     mBitRateAtLastIDR = mBitRateKbps;
   } else if (mBitRateKbps != mBitRateAtLastIDR) {
     // 8x10 OMX codec requires a keyframe to shift bitrates!
     TimeStamp now = TimeStamp::Now();
     if (mLastIDRTime.IsNull()) {
       // paranoia
       mLastIDRTime = now;
@@ -937,16 +942,17 @@ WebrtcOMXH264VideoEncoder::Encode(const 
         (timeSinceLastIDR >= 1000 && mBitRateKbps > mBitRateAtLastIDR)) {
       CODEC_LOGD("Requesting IDR for bitrate change from %u to %u (time since last idr %dms)",
                  mBitRateAtLastIDR, mBitRateKbps, timeSinceLastIDR);
 
       mOMX->RequestIDRFrame();
       mLastIDRTime = now;
       mBitRateAtLastIDR = mBitRateKbps;
     }
+#endif
   }
 
   // Wrap I420VideoFrame input with PlanarYCbCrImage for OMXVideoEncoder.
   layers::PlanarYCbCrData yuvData;
   yuvData.mYChannel = const_cast<uint8_t*>(aInputImage.buffer(webrtc::kYPlane));
   yuvData.mYSize = gfx::IntSize(aInputImage.width(), aInputImage.height());
   yuvData.mYStride = aInputImage.stride(webrtc::kYPlane);
   MOZ_ASSERT(aInputImage.stride(webrtc::kUPlane) == aInputImage.stride(webrtc::kVPlane));
--- a/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.h
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.h
@@ -21,16 +21,17 @@ namespace android {
 
 namespace mozilla {
 
 class WebrtcOMXDecoder;
 class OMXOutputDrain;
 
 // XXX see if we can reduce this
 #define WEBRTC_OMX_H264_MIN_DECODE_BUFFERS 10
+#define OMX_IDR_NEEDED_FOR_BITRATE 0
 
 class WebrtcOMXH264VideoEncoder : public WebrtcVideoEncoder
 {
 public:
   WebrtcOMXH264VideoEncoder();
 
   virtual ~WebrtcOMXH264VideoEncoder();
 
@@ -59,18 +60,20 @@ private:
   android::sp<android::OMXCodecReservation> mReservation;
 
   webrtc::EncodedImageCallback* mCallback;
   RefPtr<OMXOutputDrain> mOutputDrain;
   uint32_t mWidth;
   uint32_t mHeight;
   uint32_t mFrameRate;
   uint32_t mBitRateKbps;
+#ifdef OMX_IDR_NEEDED_FOR_BITRATE
   uint32_t mBitRateAtLastIDR;
   TimeStamp mLastIDRTime;
+#endif
   bool mOMXConfigured;
   bool mOMXReconfigure;
   webrtc::EncodedImage mEncodedImage;
 };
 
 class WebrtcOMXH264VideoDecoder : public WebrtcVideoDecoder
 {
 public: