diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h b/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h index 4925b93238..b3f58e20b1 100644 --- a/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h +++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h @@ -616,6 +616,16 @@ class TestVp8Simulcast : public ::testing::Test { EXPECT_EQ(0, encoder_->InitEncode(&settings_, 1, 1200)); encoder_->SetRates(settings_.startBitrate, 30); ExpectStreams(kKeyFrame, 1); + // Resize |input_frame_| to the new resolution. + half_width = (settings_.width + 1) / 2; + input_frame_.CreateEmptyFrame(settings_.width, settings_.height, + settings_.width, half_width, half_width); + memset(input_frame_.buffer(kYPlane), 0, + input_frame_.allocated_size(kYPlane)); + memset(input_frame_.buffer(kUPlane), 0, + input_frame_.allocated_size(kUPlane)); + memset(input_frame_.buffer(kVPlane), 0, + input_frame_.allocated_size(kVPlane)); EXPECT_EQ(0, encoder_->Encode(input_frame_, NULL, &frame_types)); } diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc index 9c9c22d21d..34862a46fa 100644 --- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc @@ -19,6 +19,7 @@ #include "libyuv/scale.h" // NOLINT #include "libyuv/convert.h" // NOLINT +#include "webrtc/base/checks.h" #include "webrtc/common.h" #include "webrtc/common_types.h" #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" @@ -743,6 +744,13 @@ int VP8EncoderImpl::Encode( return ret; } + // Since we are extracting raw pointers from |input_image| to + // |raw_images_[0]|, the resolution of these frames must match. Note that + // |input_image| might be scaled from |frame|. In that case, the resolution of + // |raw_images_[0]| should have been updated in UpdateCodecFrameSize. + DCHECK_EQ(input_image.width(), static_cast(raw_images_[0].d_w)); + DCHECK_EQ(input_image.height(), static_cast(raw_images_[0].d_h)); + // Image in vpx_image_t format. // Input image is const. VP8's raw image is not defined as const. raw_images_[0].planes[VPX_PLANE_Y] = diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc index 0f10c762d0..a6a7ecd4e0 100644 --- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc +++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc @@ -21,6 +21,7 @@ #include "vpx/vp8cx.h" #include "vpx/vp8dx.h" +#include "webrtc/base/checks.h" #include "webrtc/common.h" #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" #include "webrtc/modules/interface/module_common_types.h" @@ -265,6 +266,8 @@ int VP9EncoderImpl::Encode(const I420VideoFrame& input_image, if (frame_types && frame_types->size() > 0) { frame_type = (*frame_types)[0]; } + DCHECK_EQ(input_image.width(), static_cast(raw_->d_w)); + DCHECK_EQ(input_image.height(), static_cast(raw_->d_h)); // Image in vpx_image_t format. // Input image is const. VPX's raw image is not defined as const. raw_->planes[VPX_PLANE_Y] = const_cast(input_image.buffer(kYPlane));