From bdbaa5b40603784105051039fa7d97df030763a8 Mon Sep 17 00:00:00 2001 From: Deb Mukherjee Date: Fri, 18 Jul 2014 03:06:07 -0700 Subject: [PATCH] Fix FrameSizeTestsLarge unit-test on 32-bit arch. If the img allocation fails the test used to crash before on 32 bit architecture. This patch uses null check on img in FillFrame. Also, if the first frame initialization has not been conducted VPX_CODEC_ERROR is expected to return rather than VPX_CODEC_OK. Change-Id: I5c4e59c156374009012d280d6ff971a89b43c11f --- test/encode_test_driver.cc | 5 ++++- test/video_source.h | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc index da7e32b51..6d4281d67 100644 --- a/test/encode_test_driver.cc +++ b/test/encode_test_driver.cc @@ -69,7 +69,10 @@ void Encoder::EncodeFrameInternal(const VideoSource &video, void Encoder::Flush() { const vpx_codec_err_t res = vpx_codec_encode(&encoder_, NULL, 0, 0, 0, deadline_); - ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError(); + if (!encoder_.priv) + ASSERT_EQ(VPX_CODEC_ERROR, res) << EncoderError(); + else + ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError(); } void EncoderTest::InitializeConfig() { diff --git a/test/video_source.h b/test/video_source.h index f7e31d42a..94500b43d 100644 --- a/test/video_source.h +++ b/test/video_source.h @@ -142,7 +142,7 @@ class DummyVideoSource : public VideoSource { } protected: - virtual void FillFrame() { memset(img_->img_data, 0, raw_sz_); } + virtual void FillFrame() { if (img_) memset(img_->img_data, 0, raw_sz_); } vpx_image_t *img_; size_t raw_sz_; @@ -170,11 +170,13 @@ class RandomVideoSource : public DummyVideoSource { // 15 frames of noise, followed by 15 static frames. Reset to 0 rather // than holding previous frames to encourage keyframes to be thrown. virtual void FillFrame() { - if (frame_ % 30 < 15) - for (size_t i = 0; i < raw_sz_; ++i) - img_->img_data[i] = rnd_.Rand8(); - else - memset(img_->img_data, 0, raw_sz_); + if (img_) { + if (frame_ % 30 < 15) + for (size_t i = 0; i < raw_sz_; ++i) + img_->img_data[i] = rnd_.Rand8(); + else + memset(img_->img_data, 0, raw_sz_); + } } ACMRandom rnd_;