From 0d9b8ad89ac34be1643765e09cdf23fdc24b8c55 Mon Sep 17 00:00:00 2001 From: Randell Jesup Date: Tue, 7 Oct 2014 14:14:01 -0400 Subject: [PATCH] Bug 1033335: Don't send IDRs to change bitrates or periodic ones to fix encoder errors r=pkerr --- .../signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp | 6 ++++++ .../signaling/src/media-conduit/WebrtcOMXH264VideoCodec.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp b/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp index 884cf64fcd403..2451f4641a369 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp +++ b/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp @@ -788,7 +788,9 @@ WebrtcOMXH264VideoEncoder::WebrtcOMXH264VideoEncoder() , mHeight(0) , mFrameRate(0) , mBitRateKbps(0) +#ifdef OMX_IDR_NEEDED_FOR_BITRATE , mBitRateAtLastIDR(0) +#endif , mOMXConfigured(false) , mOMXReconfigure(false) { @@ -903,13 +905,16 @@ WebrtcOMXH264VideoEncoder::Encode(const webrtc::I420VideoFrame& aInputImage, 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) { @@ -942,6 +947,7 @@ WebrtcOMXH264VideoEncoder::Encode(const webrtc::I420VideoFrame& aInputImage, mLastIDRTime = now; mBitRateAtLastIDR = mBitRateKbps; } +#endif } // Wrap I420VideoFrame input with PlanarYCbCrImage for OMXVideoEncoder. diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.h b/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.h index 6c5d08eb74494..a4faeab71c801 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.h +++ b/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.h @@ -26,6 +26,7 @@ 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 { @@ -64,8 +65,10 @@ class WebrtcOMXH264VideoEncoder : public WebrtcVideoEncoder 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;