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

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: Disable DecodeFrame_LargerXXX tests to make Valgrind happy. 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
« no previous file with comments | « media/video/ffmpeg_video_decode_engine.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
9 #include "media/base/mock_task.h" 8 #include "media/base/mock_task.h"
10 #include "media/base/pipeline.h" 9 #include "media/base/pipeline.h"
10 #include "media/base/test_data_util.h"
11 #include "media/filters/ffmpeg_glue.h"
11 #include "media/video/ffmpeg_video_decode_engine.h" 12 #include "media/video/ffmpeg_video_decode_engine.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 using ::testing::_; 16 using ::testing::_;
16 using ::testing::DoAll; 17 using ::testing::DoAll;
17 using ::testing::Return; 18 using ::testing::Return;
18 using ::testing::ReturnNull; 19 using ::testing::ReturnNull;
20 using ::testing::SaveArg;
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) {
40 decoder->set_video_frame(arg0);
41 }
42
43 ACTION_P2(DemuxComplete, engine, buffer) { 32 ACTION_P2(DemuxComplete, engine, buffer) {
44 engine->ConsumeVideoSample(buffer); 33 engine->ConsumeVideoSample(buffer);
45 } 34 }
46 35
47 ACTION_P(SaveInitializeResult, engine) {
48 engine->set_video_codec_info(arg0);
49 }
50
51 class FFmpegVideoDecodeEngineTest 36 class FFmpegVideoDecodeEngineTest
52 : public testing::Test, 37 : public testing::Test,
53 public VideoDecodeEngine::EventHandler { 38 public VideoDecodeEngine::EventHandler {
54 public: 39 public:
55 FFmpegVideoDecodeEngineTest() 40 FFmpegVideoDecodeEngineTest()
56 : config_(kCodecH264, kWidth, kHeight, kSurfaceWidth, kSurfaceHeight, 41 : config_(kCodecVP8, kWidth, kHeight, kSurfaceWidth, kSurfaceHeight,
57 kFrameRate.num, kFrameRate.den, NULL, 0) { 42 kFrameRate.num, kFrameRate.den, NULL, 0) {
43 CHECK(FFmpegGlue::GetInstance());
58 44
59 // Setup FFmpeg structures. 45 // Setup FFmpeg structures.
60 frame_buffer_.reset(new uint8[kWidth * kHeight]); 46 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 47
69 test_engine_.reset(new FFmpegVideoDecodeEngine()); 48 test_engine_.reset(new FFmpegVideoDecodeEngine());
70 49
71 video_frame_ = VideoFrame::CreateFrame(VideoFrame::YV12, 50 ReadTestDataFile("vp8-I-frame-320x240", &i_frame_buffer_);
72 kWidth, 51 ReadTestDataFile("vp8-corrupt-I-frame", &corrupt_i_frame_buffer_);
73 kHeight, 52
74 kNoTimestamp, 53 end_of_stream_buffer_ = new DataBuffer(0);
75 kNoTimestamp);
76 } 54 }
77 55
78 ~FFmpegVideoDecodeEngineTest() { 56 ~FFmpegVideoDecodeEngineTest() {
79 test_engine_.reset(); 57 test_engine_.reset();
80 } 58 }
81 59
82 void Initialize() { 60 void Initialize() {
83 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext()) 61 VideoCodecInfo info;
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(_)) 62 EXPECT_CALL(*this, OnInitializeComplete(_))
99 .WillOnce(SaveInitializeResult(this)); 63 .WillOnce(SaveArg<0>(&info));
100 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); 64 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_);
101 EXPECT_TRUE(info_.success); 65 EXPECT_TRUE(info.success);
102 } 66 }
103 67
104 void Decode() { 68 // Decodes the single compressed frame in |buffer| and writes the
105 EXPECT_CALL(mock_ffmpeg_, AVInitPacket(_)); 69 // uncompressed output to |video_frame|. This method works with single
106 EXPECT_CALL(mock_ffmpeg_, 70 // and multithreaded decoders. End of stream buffers are used to trigger
107 AVCodecDecodeVideo2(&codec_context_, &yuv_frame_, _, _)) 71 // the frame to be returned in the multithreaded decoder case.
108 .WillOnce(DoAll(SetArgumentPointee<2>(1), // Simulate 1 byte frame. 72 void DecodeASingleFrame(const scoped_refptr<Buffer>& buffer,
109 Return(0))); 73 scoped_refptr<VideoFrame>* video_frame) {
74 EXPECT_CALL(*this, ProduceVideoSample(_))
75 .WillOnce(DemuxComplete(test_engine_.get(), buffer))
76 .WillRepeatedly(DemuxComplete(test_engine_.get(),
77 end_of_stream_buffer_));
78
79 EXPECT_CALL(*this, ConsumeVideoFrame(_, _))
80 .WillOnce(SaveArg<0>(video_frame));
81 CallProduceVideoFrame();
82 }
83
84 // Decodes |i_frame_buffer_| and then decodes the data contained in
85 // the file named |test_file_name|. This function expects both buffers
86 // to decode to frames that are the same size.
87 void DecodeIFrameThenTestFile(const std::string& test_file_name) {
88 Initialize();
89
90 scoped_refptr<VideoFrame> video_frame_a;
91 scoped_refptr<VideoFrame> video_frame_b;
92
93 scoped_refptr<Buffer> buffer;
94 ReadTestDataFile(test_file_name, &buffer);
110 95
111 EXPECT_CALL(*this, ProduceVideoSample(_)) 96 EXPECT_CALL(*this, ProduceVideoSample(_))
112 .WillOnce(DemuxComplete(test_engine_.get(), buffer_)); 97 .WillOnce(DemuxComplete(test_engine_.get(), i_frame_buffer_))
98 .WillOnce(DemuxComplete(test_engine_.get(), buffer))
99 .WillRepeatedly(DemuxComplete(test_engine_.get(),
100 end_of_stream_buffer_));
101
113 EXPECT_CALL(*this, ConsumeVideoFrame(_, _)) 102 EXPECT_CALL(*this, ConsumeVideoFrame(_, _))
114 .WillOnce(DecodeComplete(this)); 103 .WillOnce(SaveArg<0>(&video_frame_a))
115 test_engine_->ProduceVideoFrame(video_frame_); 104 .WillOnce(SaveArg<0>(&video_frame_b));
116 } 105 CallProduceVideoFrame();
106 CallProduceVideoFrame();
117 107
118 void ChangeDimensions(int width, int height) { 108 EXPECT_EQ(kWidth, video_frame_a->width());
119 frame_buffer_.reset(new uint8[width * height]); 109 EXPECT_EQ(kHeight, video_frame_a->height());
120 InitializeFrame(frame_buffer_.get(), width, &yuv_frame_); 110 EXPECT_EQ(kWidth, video_frame_b->width());
121 codec_context_.width = width; 111 EXPECT_EQ(kHeight, video_frame_b->height());
122 codec_context_.height = height;
123 } 112 }
124 113
125 // VideoDecodeEngine::EventHandler implementation. 114 // VideoDecodeEngine::EventHandler implementation.
126 MOCK_METHOD2(ConsumeVideoFrame, 115 MOCK_METHOD2(ConsumeVideoFrame,
127 void(scoped_refptr<VideoFrame> video_frame, 116 void(scoped_refptr<VideoFrame> video_frame,
128 const PipelineStatistics& statistics)); 117 const PipelineStatistics& statistics));
129 MOCK_METHOD1(ProduceVideoSample, 118 MOCK_METHOD1(ProduceVideoSample,
130 void(scoped_refptr<Buffer> buffer)); 119 void(scoped_refptr<Buffer> buffer));
131 MOCK_METHOD1(OnInitializeComplete, 120 MOCK_METHOD1(OnInitializeComplete,
132 void(const VideoCodecInfo& info)); 121 void(const VideoCodecInfo& info));
133 MOCK_METHOD0(OnUninitializeComplete, void()); 122 MOCK_METHOD0(OnUninitializeComplete, void());
134 MOCK_METHOD0(OnFlushComplete, void()); 123 MOCK_METHOD0(OnFlushComplete, void());
135 MOCK_METHOD0(OnSeekComplete, void()); 124 MOCK_METHOD0(OnSeekComplete, void());
136 MOCK_METHOD0(OnError, void()); 125 MOCK_METHOD0(OnError, void());
137 126
138 // Used by gmock actions. 127 void CallProduceVideoFrame() {
139 void set_video_frame(scoped_refptr<VideoFrame> video_frame) { 128 test_engine_->ProduceVideoFrame(VideoFrame::CreateFrame(VideoFrame::YV12,
140 video_frame_ = video_frame; 129 kWidth,
141 } 130 kHeight,
142 131 kNoTimestamp,
143 void set_video_codec_info(const VideoCodecInfo& info) { 132 kNoTimestamp));
144 info_ = info;
145 } 133 }
146 134
147 protected: 135 protected:
148 VideoDecoderConfig config_; 136 VideoDecoderConfig config_;
149 VideoCodecInfo info_;
150 scoped_refptr<VideoFrame> video_frame_;
151 scoped_ptr<FFmpegVideoDecodeEngine> test_engine_; 137 scoped_ptr<FFmpegVideoDecodeEngine> test_engine_;
152 scoped_array<uint8_t> frame_buffer_; 138 scoped_array<uint8_t> frame_buffer_;
153 StrictMock<MockFFmpeg> mock_ffmpeg_; 139 scoped_refptr<Buffer> i_frame_buffer_;
154 140 scoped_refptr<Buffer> corrupt_i_frame_buffer_;
155 AVFrame yuv_frame_; 141 scoped_refptr<Buffer> end_of_stream_buffer_;
156 AVCodecContext codec_context_;
157 AVCodec codec_;
158 scoped_refptr<DataBuffer> buffer_;
159 142
160 private: 143 private:
161 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecodeEngineTest); 144 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecodeEngineTest);
162 }; 145 };
163 146
164 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) { 147 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) {
165 Initialize(); 148 Initialize();
166 } 149 }
167 150
168 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) { 151 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) {
152 VideoDecoderConfig config(kUnknown, kWidth, kHeight, kSurfaceWidth,
153 kSurfaceHeight, kFrameRate.num, kFrameRate.den,
154 NULL, 0);
169 // Test avcodec_find_decoder() returning NULL. 155 // Test avcodec_find_decoder() returning NULL.
170 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext()) 156 VideoCodecInfo info;
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(_)) 157 EXPECT_CALL(*this, OnInitializeComplete(_))
184 .WillOnce(SaveInitializeResult(this)); 158 .WillOnce(SaveArg<0>(&info));
185 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); 159 test_engine_->Initialize(MessageLoop::current(), this, NULL, config);
186 EXPECT_FALSE(info_.success); 160 EXPECT_FALSE(info.success);
187 } 161 }
188 162
189 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) { 163 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) {
190 // Test avcodec_open() failing. 164 // Specify Theora w/o extra data so that avcodec_open() fails.
191 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext()) 165 VideoDecoderConfig config(kCodecTheora, kWidth, kHeight, kSurfaceWidth,
192 .WillOnce(Return(&codec_context_)); 166 kSurfaceHeight, kFrameRate.num, kFrameRate.den,
193 EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264)) 167 NULL, 0);
194 .WillOnce(Return(&codec_)); 168 VideoCodecInfo info;
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(_)) 169 EXPECT_CALL(*this, OnInitializeComplete(_))
207 .WillOnce(SaveInitializeResult(this)); 170 .WillOnce(SaveArg<0>(&info));
208 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); 171 test_engine_->Initialize(MessageLoop::current(), this, NULL, config);
209 EXPECT_FALSE(info_.success); 172 EXPECT_FALSE(info.success);
210 } 173 }
211 174
212 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) { 175 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) {
213 Initialize(); 176 Initialize();
214 177
215 // We rely on FFmpeg for timestamp and duration reporting. The one tricky 178 // We rely on FFmpeg for timestamp and duration reporting.
216 // bit is calculating the duration when |repeat_pict| > 0. 179 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(0);
217 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(123); 180 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 181
222 // Simulate decoding a single frame. 182 // Simulate decoding a single frame.
223 Decode(); 183 scoped_refptr<VideoFrame> video_frame;
184 DecodeASingleFrame(i_frame_buffer_, &video_frame);
224 185
225 // |video_frame_| timestamp is 0 because we set the timestamp based off 186 // |video_frame| timestamp is 0 because we set the timestamp based off
226 // the buffer timestamp. 187 // the buffer timestamp.
227 EXPECT_EQ(0, video_frame_->GetTimestamp().ToInternalValue()); 188 ASSERT_TRUE(video_frame);
189 EXPECT_EQ(0, video_frame->GetTimestamp().ToInternalValue());
228 EXPECT_EQ(kDuration.ToInternalValue(), 190 EXPECT_EQ(kDuration.ToInternalValue(),
229 video_frame_->GetDuration().ToInternalValue()); 191 video_frame->GetDuration().ToInternalValue());
230 } 192 }
231 193
194
195 // Verify current behavior for 0 byte frames. FFmpeg simply ignores
196 // the 0 byte frames.
232 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_0ByteFrame) { 197 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_0ByteFrame) {
233 Initialize(); 198 Initialize();
234 199
235 // Expect a bunch of avcodec calls. 200 scoped_refptr<DataBuffer> zero_byte_buffer = new DataBuffer(1);
236 EXPECT_CALL(mock_ffmpeg_, AVInitPacket(_)) 201
237 .Times(2); 202 scoped_refptr<VideoFrame> video_frame_a;
238 EXPECT_CALL(mock_ffmpeg_, 203 scoped_refptr<VideoFrame> video_frame_b;
239 AVCodecDecodeVideo2(&codec_context_, &yuv_frame_, _, _)) 204 scoped_refptr<VideoFrame> video_frame_c;
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 205
245 EXPECT_CALL(*this, ProduceVideoSample(_)) 206 EXPECT_CALL(*this, ProduceVideoSample(_))
246 .WillOnce(DemuxComplete(test_engine_.get(), buffer_)) 207 .WillOnce(DemuxComplete(test_engine_.get(), i_frame_buffer_))
247 .WillOnce(DemuxComplete(test_engine_.get(), buffer_)); 208 .WillOnce(DemuxComplete(test_engine_.get(), zero_byte_buffer))
209 .WillOnce(DemuxComplete(test_engine_.get(), i_frame_buffer_))
210 .WillRepeatedly(DemuxComplete(test_engine_.get(),
211 end_of_stream_buffer_));
212
248 EXPECT_CALL(*this, ConsumeVideoFrame(_, _)) 213 EXPECT_CALL(*this, ConsumeVideoFrame(_, _))
249 .WillOnce(DecodeComplete(this)); 214 .WillOnce(SaveArg<0>(&video_frame_a))
250 test_engine_->ProduceVideoFrame(video_frame_); 215 .WillOnce(SaveArg<0>(&video_frame_b))
216 .WillOnce(SaveArg<0>(&video_frame_c));
217 CallProduceVideoFrame();
218 CallProduceVideoFrame();
219 CallProduceVideoFrame();
251 220
252 EXPECT_TRUE(video_frame_.get()); 221 EXPECT_TRUE(video_frame_a);
222 EXPECT_TRUE(video_frame_b);
223 EXPECT_FALSE(video_frame_c);
253 } 224 }
254 225
226
255 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_DecodeError) { 227 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_DecodeError) {
256 Initialize(); 228 Initialize();
257 229
258 // Expect a bunch of avcodec calls. 230 EXPECT_CALL(*this, ProduceVideoSample(_))
259 EXPECT_CALL(mock_ffmpeg_, AVInitPacket(_)); 231 .WillOnce(DemuxComplete(test_engine_.get(), corrupt_i_frame_buffer_))
260 EXPECT_CALL(mock_ffmpeg_, 232 .WillRepeatedly(DemuxComplete(test_engine_.get(), i_frame_buffer_));
261 AVCodecDecodeVideo2(&codec_context_, &yuv_frame_, _, _)) 233 EXPECT_CALL(*this, OnError());
262 .WillOnce(Return(-1)); 234
235 CallProduceVideoFrame();
236 }
237
238 // Multi-threaded decoders have different behavior than single-threaded
239 // decoders at the end of the stream. Multithreaded decoders hide errors
240 // that happen on the last |codec_context_->thread_count| frames to avoid
241 // prematurely signalling EOS. This test just exposes that behavior so we can
242 // detect if it changes.
243 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_DecodeErrorAtEndOfStream) {
244 Initialize();
263 245
264 EXPECT_CALL(*this, ProduceVideoSample(_)) 246 EXPECT_CALL(*this, ProduceVideoSample(_))
265 .WillOnce(DemuxComplete(test_engine_.get(), buffer_)); 247 .WillOnce(DemuxComplete(test_engine_.get(), corrupt_i_frame_buffer_))
266 EXPECT_CALL(*this, OnError()); 248 .WillRepeatedly(DemuxComplete(test_engine_.get(), end_of_stream_buffer_));
267 249
268 test_engine_->ProduceVideoFrame(video_frame_); 250 scoped_refptr<VideoFrame> video_frame;
251 EXPECT_CALL(*this, ConsumeVideoFrame(_, _))
252 .WillOnce(SaveArg<0>(&video_frame));
253 CallProduceVideoFrame();
254
255 EXPECT_FALSE(video_frame);
269 } 256 }
270 257
271 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_LargerWidth) { 258 // Decode |i_frame_buffer_| and then a frame with a larger width and verify
272 Initialize(); 259 // the output size didn't change.
273 ChangeDimensions(kWidth * 2, kHeight); 260 // TODO(acolwell): Fix InvalidRead detected by Valgrind
274 Decode(); 261 //TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_LargerWidth) {
262 // DecodeIFrameThenTestFile("vp8-I-frame-640x240");
263 //}
264
265 // Decode |i_frame_buffer_| and then a frame with a smaller width and verify
266 // the output size didn't change.
267 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerWidth) {
268 DecodeIFrameThenTestFile("vp8-I-frame-160x240");
275 } 269 }
276 270
277 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerWidth) { 271 // Decode |i_frame_buffer_| and then a frame with a larger height and verify
278 Initialize(); 272 // the output size didn't change.
279 ChangeDimensions(kWidth / 2, kHeight); 273 // TODO(acolwell): Fix InvalidRead detected by Valgrind
280 Decode(); 274 //TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_LargerHeight) {
281 } 275 // DecodeIFrameThenTestFile("vp8-I-frame-320x480");
276 //}
282 277
283 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_LargerHeight) { 278 // Decode |i_frame_buffer_| and then a frame with a smaller height and verify
284 Initialize(); 279 // the output size didn't change.
285 ChangeDimensions(kWidth, kHeight * 2);
286 Decode();
287 }
288
289 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) { 280 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) {
290 Initialize(); 281 DecodeIFrameThenTestFile("vp8-I-frame-320x120");
291 ChangeDimensions(kWidth, kHeight / 2);
292 Decode();
293 }
294
295 TEST_F(FFmpegVideoDecodeEngineTest, GetSurfaceFormat) {
296 Initialize();
297
298 // YV12 formats.
299 codec_context_.pix_fmt = PIX_FMT_YUV420P;
300 EXPECT_EQ(VideoFrame::YV12, test_engine_->GetSurfaceFormat());
301 codec_context_.pix_fmt = PIX_FMT_YUVJ420P;
302 EXPECT_EQ(VideoFrame::YV12, test_engine_->GetSurfaceFormat());
303
304 // YV16 formats.
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 } 282 }
314 283
315 } // namespace media 284 } // namespace media
OLDNEW
« no previous file with comments | « 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