From 0ae71b9ccb24b19060f8d860d38b5f7e1083ce47 Mon Sep 17 00:00:00 2001 From: "stefan@webrtc.org" Date: Mon, 5 Dec 2011 08:42:52 +0000 Subject: [PATCH] Disable temporal layers when building with Chromium. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/301010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1099 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../video_coding/codecs/vp8/main/interface/vp8.h | 5 ++++- .../video_coding/codecs/vp8/main/source/vp8.cc | 16 ++++++++++++++++ .../video_coding/codecs/vp8/main/source/vp8.gypi | 6 ++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/modules/video_coding/codecs/vp8/main/interface/vp8.h b/src/modules/video_coding/codecs/vp8/main/interface/vp8.h index 944fa2fcea..d8b1745741 100644 --- a/src/modules/video_coding/codecs/vp8/main/interface/vp8.h +++ b/src/modules/video_coding/codecs/vp8/main/interface/vp8.h @@ -29,8 +29,9 @@ struct vpx_codec_cx_pkt; namespace webrtc { +#if WEBRTC_LIBVPX_VERSION >= 971 class TemporalLayers; - +#endif class ReferencePictureSelection; /******************************/ @@ -175,7 +176,9 @@ private: WebRtc_UWord32 _rcMaxIntraTarget; int _tokenPartitions; ReferencePictureSelection* _rps; +#if WEBRTC_LIBVPX_VERSION >= 971 TemporalLayers* _temporalLayers; +#endif vpx_codec_ctx_t* _encoder; vpx_codec_enc_cfg_t* _cfg; diff --git a/src/modules/video_coding/codecs/vp8/main/source/vp8.cc b/src/modules/video_coding/codecs/vp8/main/source/vp8.cc index ffa64c9b3b..705d8c6e84 100644 --- a/src/modules/video_coding/codecs/vp8/main/source/vp8.cc +++ b/src/modules/video_coding/codecs/vp8/main/source/vp8.cc @@ -49,7 +49,9 @@ VP8Encoder::VP8Encoder(): _rcMaxIntraTarget(0), _tokenPartitions(VP8_ONE_TOKENPARTITION), _rps(new ReferencePictureSelection), +#if WEBRTC_LIBVPX_VERSION >= 971 _temporalLayers(NULL), +#endif _encoder(NULL), _cfg(NULL), _raw(NULL) @@ -113,11 +115,13 @@ VP8Encoder::Release() delete _raw; _raw = NULL; } +#if WEBRTC_LIBVPX_VERSION >= 971 if (_temporalLayers != NULL) { delete _temporalLayers; _temporalLayers = NULL; } +#endif _inited = false; return WEBRTC_VIDEO_CODEC_OK; @@ -172,10 +176,12 @@ VP8Encoder::SetRates(WebRtc_UWord32 newBitRateKbit, WebRtc_UWord32 newFrameRate) } _cfg->rc_target_bitrate = newBitRateKbit; // in kbit/s +#if WEBRTC_LIBVPX_VERSION >= 971 if (_temporalLayers) { _temporalLayers->ConfigureBitrates(newBitRateKbit, _cfg); } +#endif _maxFrameRate = newFrameRate; // update encoder context @@ -238,12 +244,14 @@ VP8Encoder::InitEncode(const VideoCodec* inst, _width = inst->width; _height = inst->height; +#if WEBRTC_LIBVPX_VERSION >= 971 if (inst->codecSpecific.VP8.numberOfTemporalLayers > 1) { assert(_temporalLayers == NULL); _temporalLayers = new TemporalLayers(inst->codecSpecific.VP8.numberOfTemporalLayers); } +#endif // random start 16 bits is enough. _pictureID = ((WebRtc_UWord16)rand()) & 0x7FFF; @@ -274,10 +282,12 @@ VP8Encoder::InitEncode(const VideoCodec* inst, { _cfg->rc_target_bitrate = inst->startBitrate; // in kbit/s } +#if WEBRTC_LIBVPX_VERSION >= 971 if (_temporalLayers) { _temporalLayers->ConfigureBitrates(inst->startBitrate, _cfg); } +#endif // setting the time base of the codec _cfg->g_timebase.num = 1; _cfg->g_timebase.den = 90000; @@ -436,9 +446,11 @@ VP8Encoder::Encode(const RawImage& inputImage, _raw->planes[PLANE_V] = &inputImage._buffer[_height * _width * 5 >> 2]; int flags = 0; +#if WEBRTC_LIBVPX_VERSION >= 971 if (_temporalLayers) { flags |= _temporalLayers->EncodeFlags(); } +#endif bool sendKeyFrame = frameTypes && (*frameTypes == kKeyFrame); if (sendKeyFrame) { @@ -490,13 +502,17 @@ void VP8Encoder::PopulateCodecSpecific(CodecSpecificInfo* codec_specific, vp8Info->simulcastIdx = _simulcastIdx; vp8Info->keyIdx = kNoKeyIdx; // TODO(hlundin) populate this vp8Info->nonReference = (pkt.data.frame.flags & VPX_FRAME_IS_DROPPABLE); +#if WEBRTC_LIBVPX_VERSION >= 971 if (_temporalLayers) { _temporalLayers->PopulateCodecSpecific( (pkt.data.frame.flags & VPX_FRAME_IS_KEY) ? true : false, vp8Info); } else { +#endif vp8Info->temporalIdx = kNoTemporalIdx; vp8Info->tl0PicIdx = kNoTl0PicIdx; +#if WEBRTC_LIBVPX_VERSION >= 971 } +#endif _pictureID = (_pictureID + 1) % 0x7FFF; // prepare next } diff --git a/src/modules/video_coding/codecs/vp8/main/source/vp8.gypi b/src/modules/video_coding/codecs/vp8/main/source/vp8.gypi index 4ffefcddf4..d0f37f0982 100644 --- a/src/modules/video_coding/codecs/vp8/main/source/vp8.gypi +++ b/src/modules/video_coding/codecs/vp8/main/source/vp8.gypi @@ -36,6 +36,10 @@ 'defines': [ 'WEBRTC_LIBVPX_VERSION=971' # Cayuga ], + 'sources': [ + 'temporal_layers.h', + 'temporal_layers.cc', + ], }], ], 'direct_dependent_settings': { @@ -50,8 +54,6 @@ 'reference_picture_selection.cc', '../interface/vp8.h', '../interface/vp8_simulcast.h', - 'temporal_layers.h', - 'temporal_layers.cc', 'vp8.cc', 'vp8_simulcast.cc', ],