Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: media/video/ffmpeg_video_decode_engine_unittest.cc

Issue 7587012: Remove mock_ffmpeg and update media unittests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "media/base/data_buffer.h" 7 #include "media/base/data_buffer.h"
8 #include "media/base/mock_ffmpeg.h" 8 #include "media/base/media.h"
9 #include "media/base/mock_task.h" 9 #include "media/base/mock_task.h"
10 #include "media/base/pipeline.h" 10 #include "media/base/pipeline.h"
11 #include "media/base/test_data_util.h"
12 #include "media/filters/ffmpeg_glue.h"
11 #include "media/video/ffmpeg_video_decode_engine.h" 13 #include "media/video/ffmpeg_video_decode_engine.h"
12 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 16
15 using ::testing::_; 17 using ::testing::_;
16 using ::testing::DoAll; 18 using ::testing::DoAll;
17 using ::testing::Return; 19 using ::testing::Return;
18 using ::testing::ReturnNull; 20 using ::testing::ReturnNull;
19 using ::testing::SetArgumentPointee; 21 using ::testing::SetArgumentPointee;
20 using ::testing::StrictMock; 22 using ::testing::StrictMock;
21 23
22 namespace media { 24 namespace media {
23 25
24 static const int kWidth = 320; 26 static const size_t kWidth = 320;
25 static const int kHeight = 240; 27 static const size_t kHeight = 240;
26 static const int kSurfaceWidth = 522; 28 static const int kSurfaceWidth = 522;
27 static const int kSurfaceHeight = 288; 29 static const int kSurfaceHeight = 288;
28 static const AVRational kFrameRate = { 100, 1 }; 30 static const AVRational kFrameRate = { 100, 1 };
29 31
30 static void InitializeFrame(uint8_t* data, int width, AVFrame* frame) {
31 frame->data[0] = data;
32 frame->data[1] = data;
33 frame->data[2] = data;
34 frame->linesize[0] = width;
35 frame->linesize[1] = width / 2;
36 frame->linesize[2] = width / 2;
37 }
38
39 ACTION_P(DecodeComplete, decoder) { 32 ACTION_P(DecodeComplete, decoder) {
40 decoder->set_video_frame(arg0); 33 decoder->set_video_frame(arg0);
41 } 34 }
42 35
43 ACTION_P2(DemuxComplete, engine, buffer) { 36 ACTION_P2(DemuxComplete, engine, buffer) {
44 engine->ConsumeVideoSample(buffer); 37 engine->ConsumeVideoSample(buffer);
45 } 38 }
46 39
47 ACTION_P(SaveInitializeResult, engine) { 40 ACTION_P(SaveInitializeResult, engine) {
48 engine->set_video_codec_info(arg0); 41 engine->set_video_codec_info(arg0);
49 } 42 }
50 43
51 class FFmpegVideoDecodeEngineTest 44 class FFmpegVideoDecodeEngineTest
52 : public testing::Test, 45 : public testing::Test,
53 public VideoDecodeEngine::EventHandler { 46 public VideoDecodeEngine::EventHandler {
54 public: 47 public:
55 FFmpegVideoDecodeEngineTest() 48 FFmpegVideoDecodeEngineTest()
56 : config_(kCodecH264, kWidth, kHeight, kSurfaceWidth, kSurfaceHeight, 49 : config_(kCodecVP8, kWidth, kHeight, kSurfaceWidth, kSurfaceHeight,
57 kFrameRate.num, kFrameRate.den, NULL, 0) { 50 kFrameRate.num, kFrameRate.den, NULL, 0) {
58 51
52 EXPECT_TRUE(InitializeMediaLibraryForTesting());
53 FFmpegGlue::GetInstance();
scherkus (not reviewing) 2011/08/11 01:26:29 is this to initialize the glue? hrmm.... wonder i
acolwell GONE FROM CHROMIUM 2011/08/11 23:54:40 Yes. Making this part of InitializeMediaLibraryXXX
54
59 // Setup FFmpeg structures. 55 // Setup FFmpeg structures.
60 frame_buffer_.reset(new uint8[kWidth * kHeight]); 56 frame_buffer_.reset(new uint8[kWidth * kHeight]);
61 memset(&yuv_frame_, 0, sizeof(yuv_frame_));
62 InitializeFrame(frame_buffer_.get(), kWidth, &yuv_frame_);
63
64 memset(&codec_context_, 0, sizeof(codec_context_));
65 memset(&codec_, 0, sizeof(codec_));
66
67 buffer_ = new DataBuffer(1);
68 57
69 test_engine_.reset(new FFmpegVideoDecodeEngine()); 58 test_engine_.reset(new FFmpegVideoDecodeEngine());
70 59
71 video_frame_ = VideoFrame::CreateFrame(VideoFrame::YV12, 60 video_frame_ = VideoFrame::CreateFrame(VideoFrame::YV12,
72 kWidth, 61 kWidth,
73 kHeight, 62 kHeight,
74 kNoTimestamp, 63 kNoTimestamp,
75 kNoTimestamp); 64 kNoTimestamp);
65
66 EXPECT_TRUE(ReadTestDataFile("vp8-I-frame-320x240", &i_frame_buffer_));
76 } 67 }
77 68
78 ~FFmpegVideoDecodeEngineTest() { 69 ~FFmpegVideoDecodeEngineTest() {
79 test_engine_.reset(); 70 test_engine_.reset();
80 } 71 }
81 72
82 void Initialize() { 73 void Initialize() {
83 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext())
84 .WillOnce(Return(&codec_context_));
85 EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264))
86 .WillOnce(Return(&codec_));
87 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
88 .WillOnce(Return(&yuv_frame_));
89 EXPECT_CALL(mock_ffmpeg_, AVCodecOpen(&codec_context_, &codec_))
90 .WillOnce(Return(0));
91 EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_))
92 .WillOnce(Return(0));
93 EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
94 .Times(1);
95 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_))
96 .Times(1);
97
98 EXPECT_CALL(*this, OnInitializeComplete(_)) 74 EXPECT_CALL(*this, OnInitializeComplete(_))
99 .WillOnce(SaveInitializeResult(this)); 75 .WillOnce(SaveInitializeResult(this));
100 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); 76 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_);
101 EXPECT_TRUE(info_.success); 77 EXPECT_TRUE(info_.success);
102 } 78 }
103 79
104 void Decode() { 80 void Decode(const scoped_refptr<Buffer>& buffer) {
105 EXPECT_CALL(mock_ffmpeg_, AVInitPacket(_));
106 EXPECT_CALL(mock_ffmpeg_,
107 AVCodecDecodeVideo2(&codec_context_, &yuv_frame_, _, _))
108 .WillOnce(DoAll(SetArgumentPointee<2>(1), // Simulate 1 byte frame.
109 Return(0)));
110
111 EXPECT_CALL(*this, ProduceVideoSample(_)) 81 EXPECT_CALL(*this, ProduceVideoSample(_))
112 .WillOnce(DemuxComplete(test_engine_.get(), buffer_)); 82 .WillOnce(DemuxComplete(test_engine_.get(), buffer));
113 EXPECT_CALL(*this, ConsumeVideoFrame(_, _)) 83 EXPECT_CALL(*this, ConsumeVideoFrame(_, _))
114 .WillOnce(DecodeComplete(this)); 84 .WillOnce(DecodeComplete(this));
115 test_engine_->ProduceVideoFrame(video_frame_); 85 test_engine_->ProduceVideoFrame(video_frame_);
116 } 86 }
117 87
118 void ChangeDimensions(int width, int height) {
119 frame_buffer_.reset(new uint8[width * height]);
120 InitializeFrame(frame_buffer_.get(), width, &yuv_frame_);
121 codec_context_.width = width;
122 codec_context_.height = height;
123 }
124
125 // VideoDecodeEngine::EventHandler implementation. 88 // VideoDecodeEngine::EventHandler implementation.
126 MOCK_METHOD2(ConsumeVideoFrame, 89 MOCK_METHOD2(ConsumeVideoFrame,
127 void(scoped_refptr<VideoFrame> video_frame, 90 void(scoped_refptr<VideoFrame> video_frame,
128 const PipelineStatistics& statistics)); 91 const PipelineStatistics& statistics));
129 MOCK_METHOD1(ProduceVideoSample, 92 MOCK_METHOD1(ProduceVideoSample,
130 void(scoped_refptr<Buffer> buffer)); 93 void(scoped_refptr<Buffer> buffer));
131 MOCK_METHOD1(OnInitializeComplete, 94 MOCK_METHOD1(OnInitializeComplete,
132 void(const VideoCodecInfo& info)); 95 void(const VideoCodecInfo& info));
133 MOCK_METHOD0(OnUninitializeComplete, void()); 96 MOCK_METHOD0(OnUninitializeComplete, void());
134 MOCK_METHOD0(OnFlushComplete, void()); 97 MOCK_METHOD0(OnFlushComplete, void());
135 MOCK_METHOD0(OnSeekComplete, void()); 98 MOCK_METHOD0(OnSeekComplete, void());
136 MOCK_METHOD0(OnError, void()); 99 MOCK_METHOD0(OnError, void());
137 100
138 // Used by gmock actions. 101 // Used by gmock actions.
139 void set_video_frame(scoped_refptr<VideoFrame> video_frame) { 102 void set_video_frame(scoped_refptr<VideoFrame> video_frame) {
140 video_frame_ = video_frame; 103 video_frame_ = video_frame;
141 } 104 }
142 105
143 void set_video_codec_info(const VideoCodecInfo& info) { 106 void set_video_codec_info(const VideoCodecInfo& info) {
144 info_ = info; 107 info_ = info;
145 } 108 }
146 109
147 protected: 110 protected:
148 VideoDecoderConfig config_; 111 VideoDecoderConfig config_;
149 VideoCodecInfo info_; 112 VideoCodecInfo info_;
150 scoped_refptr<VideoFrame> video_frame_; 113 scoped_refptr<VideoFrame> video_frame_;
151 scoped_ptr<FFmpegVideoDecodeEngine> test_engine_; 114 scoped_ptr<FFmpegVideoDecodeEngine> test_engine_;
152 scoped_array<uint8_t> frame_buffer_; 115 scoped_array<uint8_t> frame_buffer_;
153 StrictMock<MockFFmpeg> mock_ffmpeg_; 116 scoped_refptr<Buffer> i_frame_buffer_;
154
155 AVFrame yuv_frame_;
156 AVCodecContext codec_context_;
157 AVCodec codec_;
158 scoped_refptr<DataBuffer> buffer_;
159 117
160 private: 118 private:
161 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecodeEngineTest); 119 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecodeEngineTest);
162 }; 120 };
163 121
164 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) { 122 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) {
165 Initialize(); 123 Initialize();
166 } 124 }
167 125
168 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) { 126 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) {
127 VideoDecoderConfig config(kUnknown, kWidth, kHeight, kSurfaceWidth,
128 kSurfaceHeight, kFrameRate.num, kFrameRate.den,
129 NULL, 0);
169 // Test avcodec_find_decoder() returning NULL. 130 // Test avcodec_find_decoder() returning NULL.
170 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext())
171 .WillOnce(Return(&codec_context_));
172 EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264))
173 .WillOnce(ReturnNull());
174 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
175 .WillOnce(Return(&yuv_frame_));
176 EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_))
177 .WillOnce(Return(0));
178 EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
179 .Times(1);
180 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_))
181 .Times(1);
182
183 EXPECT_CALL(*this, OnInitializeComplete(_)) 131 EXPECT_CALL(*this, OnInitializeComplete(_))
184 .WillOnce(SaveInitializeResult(this)); 132 .WillOnce(SaveInitializeResult(this));
185 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); 133 test_engine_->Initialize(MessageLoop::current(), this, NULL, config);
186 EXPECT_FALSE(info_.success); 134 EXPECT_FALSE(info_.success);
187 } 135 }
188 136
189 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) { 137 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) {
190 // Test avcodec_open() failing. 138 // Specify Theora w/o extra data so that avcodec_open() fails.
191 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext()) 139 VideoDecoderConfig config(kCodecTheora, kWidth, kHeight, kSurfaceWidth,
192 .WillOnce(Return(&codec_context_)); 140 kSurfaceHeight, kFrameRate.num, kFrameRate.den,
193 EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264)) 141 NULL, 0);
194 .WillOnce(Return(&codec_));
195 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
196 .WillOnce(Return(&yuv_frame_));
197 EXPECT_CALL(mock_ffmpeg_, AVCodecOpen(&codec_context_, &codec_))
198 .WillOnce(Return(-1));
199 EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_))
200 .WillOnce(Return(0));
201 EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
202 .Times(1);
203 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_))
204 .Times(1);
205
206 EXPECT_CALL(*this, OnInitializeComplete(_)) 142 EXPECT_CALL(*this, OnInitializeComplete(_))
207 .WillOnce(SaveInitializeResult(this)); 143 .WillOnce(SaveInitializeResult(this));
208 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); 144 test_engine_->Initialize(MessageLoop::current(), this, NULL, config);
209 EXPECT_FALSE(info_.success); 145 EXPECT_FALSE(info_.success);
210 } 146 }
211 147
212 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) { 148 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) {
213 Initialize(); 149 Initialize();
214 150
215 // We rely on FFmpeg for timestamp and duration reporting. The one tricky 151 // We rely on FFmpeg for timestamp and duration reporting.
216 // bit is calculating the duration when |repeat_pict| > 0. 152 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(0);
217 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(123); 153 const base::TimeDelta kDuration = base::TimeDelta::FromMicroseconds(10000);
218 const base::TimeDelta kDuration = base::TimeDelta::FromMicroseconds(15000);
219 yuv_frame_.repeat_pict = 1;
220 yuv_frame_.reordered_opaque = kTimestamp.InMicroseconds();
221 154
222 // Simulate decoding a single frame. 155 // Simulate decoding a single frame.
223 Decode(); 156 Decode(i_frame_buffer_);
224 157
225 // |video_frame_| timestamp is 0 because we set the timestamp based off 158 // |video_frame_| timestamp is 0 because we set the timestamp based off
226 // the buffer timestamp. 159 // the buffer timestamp.
227 EXPECT_EQ(0, video_frame_->GetTimestamp().ToInternalValue()); 160 EXPECT_EQ(0, video_frame_->GetTimestamp().ToInternalValue());
228 EXPECT_EQ(kDuration.ToInternalValue(), 161 EXPECT_EQ(kDuration.ToInternalValue(),
229 video_frame_->GetDuration().ToInternalValue()); 162 video_frame_->GetDuration().ToInternalValue());
230 } 163 }
231 164
232 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_0ByteFrame) { 165 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_0ByteFrame) {
233 Initialize(); 166 Initialize();
234 167
235 // Expect a bunch of avcodec calls. 168 scoped_refptr<Buffer> bufferA = new DataBuffer(1);
scherkus (not reviewing) 2011/08/11 01:26:29 buffer_a
acolwell GONE FROM CHROMIUM 2011/08/11 23:54:40 Done.
236 EXPECT_CALL(mock_ffmpeg_, AVInitPacket(_))
237 .Times(2);
238 EXPECT_CALL(mock_ffmpeg_,
239 AVCodecDecodeVideo2(&codec_context_, &yuv_frame_, _, _))
240 .WillOnce(DoAll(SetArgumentPointee<2>(0), // Simulate 0 byte frame.
241 Return(0)))
242 .WillOnce(DoAll(SetArgumentPointee<2>(1), // Simulate 1 byte frame.
243 Return(0)));
244 169
245 EXPECT_CALL(*this, ProduceVideoSample(_)) 170 EXPECT_CALL(*this, ProduceVideoSample(_))
246 .WillOnce(DemuxComplete(test_engine_.get(), buffer_)) 171 .WillOnce(DemuxComplete(test_engine_.get(), bufferA))
247 .WillOnce(DemuxComplete(test_engine_.get(), buffer_)); 172 .WillOnce(DemuxComplete(test_engine_.get(), i_frame_buffer_));
248 EXPECT_CALL(*this, ConsumeVideoFrame(_, _)) 173 EXPECT_CALL(*this, ConsumeVideoFrame(_, _))
249 .WillOnce(DecodeComplete(this)); 174 .WillOnce(DecodeComplete(this));
250 test_engine_->ProduceVideoFrame(video_frame_); 175 test_engine_->ProduceVideoFrame(video_frame_);
251 176
252 EXPECT_TRUE(video_frame_.get()); 177 EXPECT_TRUE(video_frame_.get());
253 } 178 }
254 179
255 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_DecodeError) { 180 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_DecodeError) {
256 Initialize(); 181 Initialize();
257 182
258 // Expect a bunch of avcodec calls. 183 scoped_refptr<DataBuffer> buffer =
259 EXPECT_CALL(mock_ffmpeg_, AVInitPacket(_)); 184 new DataBuffer(i_frame_buffer_->GetDataSize());
260 EXPECT_CALL(mock_ffmpeg_, 185 buffer->SetDataSize(i_frame_buffer_->GetDataSize());
261 AVCodecDecodeVideo2(&codec_context_, &yuv_frame_, _, _)) 186
262 .WillOnce(Return(-1)); 187 uint8* buf = buffer->GetWritableData();
188 memcpy(buf, i_frame_buffer_->GetData(), buffer->GetDataSize());
189
190 // Corrupt bytes by flipping bits w/ xor.
scherkus (not reviewing) 2011/08/11 01:26:29 :)
191 for (size_t i = 0; i < buffer->GetDataSize(); i++)
192 buf[i] ^= 0xA5;
263 193
264 EXPECT_CALL(*this, ProduceVideoSample(_)) 194 EXPECT_CALL(*this, ProduceVideoSample(_))
265 .WillOnce(DemuxComplete(test_engine_.get(), buffer_)); 195 .WillOnce(DemuxComplete(test_engine_.get(), buffer));
266 EXPECT_CALL(*this, OnError()); 196 EXPECT_CALL(*this, OnError());
267 197
268 test_engine_->ProduceVideoFrame(video_frame_); 198 test_engine_->ProduceVideoFrame(video_frame_);
269 } 199 }
270 200
271 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_LargerWidth) { 201 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_LargerWidth) {
272 Initialize(); 202 Initialize();
273 ChangeDimensions(kWidth * 2, kHeight); 203
274 Decode(); 204 // Decode a frame and verify the width.
205 Decode(i_frame_buffer_);
206 EXPECT_EQ(video_frame_->width(), kWidth);
207 EXPECT_EQ(video_frame_->height(), kHeight);
208
209 // Now decode a frame with a larger width and verify the output size didn't
210 // change.
211 scoped_refptr<Buffer> buffer;
212 EXPECT_TRUE(ReadTestDataFile("vp8-I-frame-640x240", &buffer));
213 Decode(buffer);
214
215 EXPECT_EQ(kWidth, video_frame_->width());
216 EXPECT_EQ(kHeight, video_frame_->height());
275 } 217 }
276 218
277 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerWidth) { 219 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerWidth) {
278 Initialize(); 220 Initialize();
279 ChangeDimensions(kWidth / 2, kHeight); 221
280 Decode(); 222 // Decode a frame and verify the width.
223 Decode(i_frame_buffer_);
224 EXPECT_EQ(video_frame_->width(), kWidth);
225 EXPECT_EQ(video_frame_->height(), kHeight);
226
227 // Now decode a frame with a smaller width and verify the output size didn't
228 // change.
229 scoped_refptr<Buffer> buffer;
230 EXPECT_TRUE(ReadTestDataFile("vp8-I-frame-160x240", &buffer));
231 Decode(buffer);
232 EXPECT_EQ(video_frame_->width(), kWidth);
233 EXPECT_EQ(video_frame_->height(), kHeight);
281 } 234 }
282 235
283 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_LargerHeight) { 236 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_LargerHeight) {
284 Initialize(); 237 Initialize();
285 ChangeDimensions(kWidth, kHeight * 2); 238
286 Decode(); 239 // Decode a frame and verify the width.
240 Decode(i_frame_buffer_);
241 EXPECT_EQ(video_frame_->width(), kWidth);
242 EXPECT_EQ(video_frame_->height(), kHeight);
243
244 // Now decode a frame with a larger height and verify the output
245 // size didn't change.
246 scoped_refptr<Buffer> buffer;
247 EXPECT_TRUE(ReadTestDataFile("vp8-I-frame-320x480", &buffer));
248 Decode(buffer);
249 EXPECT_EQ(kWidth, video_frame_->width());
250 EXPECT_EQ(kHeight, video_frame_->height());
287 } 251 }
288 252
289 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) { 253 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) {
290 Initialize(); 254 Initialize();
291 ChangeDimensions(kWidth, kHeight / 2);
292 Decode();
293 }
294 255
295 TEST_F(FFmpegVideoDecodeEngineTest, GetSurfaceFormat) { 256 // Decode a frame and verify the width.
296 Initialize(); 257 Decode(i_frame_buffer_);
258 EXPECT_EQ(video_frame_->width(), kWidth);
259 EXPECT_EQ(video_frame_->height(), kHeight);
297 260
298 // YV12 formats. 261 // Now decode a frame with a smaller height and verify the output size
299 codec_context_.pix_fmt = PIX_FMT_YUV420P; 262 // didn't change.
300 EXPECT_EQ(VideoFrame::YV12, test_engine_->GetSurfaceFormat()); 263 scoped_refptr<Buffer> buffer;
301 codec_context_.pix_fmt = PIX_FMT_YUVJ420P; 264 EXPECT_TRUE(ReadTestDataFile("vp8-I-frame-320x120", &buffer));
scherkus (not reviewing) 2011/08/11 01:26:29 wow very nice!
302 EXPECT_EQ(VideoFrame::YV12, test_engine_->GetSurfaceFormat()); 265 Decode(buffer);
303 266 EXPECT_EQ(kWidth, video_frame_->width());
304 // YV16 formats. 267 EXPECT_EQ(kHeight, video_frame_->height());
305 codec_context_.pix_fmt = PIX_FMT_YUV422P;
306 EXPECT_EQ(VideoFrame::YV16, test_engine_->GetSurfaceFormat());
307 codec_context_.pix_fmt = PIX_FMT_YUVJ422P;
308 EXPECT_EQ(VideoFrame::YV16, test_engine_->GetSurfaceFormat());
309
310 // Invalid value.
311 codec_context_.pix_fmt = PIX_FMT_NONE;
312 EXPECT_EQ(VideoFrame::INVALID, test_engine_->GetSurfaceFormat());
313 } 268 }
314 269
315 } // namespace media 270 } // namespace media
OLDNEW
« media/video/ffmpeg_video_decode_engine.cc ('K') | « media/video/ffmpeg_video_decode_engine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698