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

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

Issue 8341033: Remove DemuxerStream::GetAVStream() once and for all. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now with cmath Created 9 years, 1 month 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/pipeline.h" 8 #include "media/base/pipeline.h"
9 #include "media/base/test_data_util.h" 9 #include "media/base/test_data_util.h"
10 #include "media/filters/ffmpeg_glue.h" 10 #include "media/filters/ffmpeg_glue.h"
11 #include "media/video/ffmpeg_video_decode_engine.h" 11 #include "media/video/ffmpeg_video_decode_engine.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 using ::testing::_; 15 using ::testing::_;
16 using ::testing::DoAll; 16 using ::testing::DoAll;
17 using ::testing::Return; 17 using ::testing::Return;
18 using ::testing::ReturnNull; 18 using ::testing::ReturnNull;
19 using ::testing::SaveArg; 19 using ::testing::SaveArg;
20 using ::testing::SetArgumentPointee; 20 using ::testing::SetArgumentPointee;
21 using ::testing::StrictMock; 21 using ::testing::StrictMock;
22 22
23 namespace media { 23 namespace media {
24 24
25 static const VideoFrame::Format kVideoFormat = VideoFrame::YV12; 25 static const VideoFrame::Format kVideoFormat = VideoFrame::YV12;
26 static const gfx::Size kCodedSize(320, 240); 26 static const gfx::Size kCodedSize(320, 240);
27 static const gfx::Rect kVisibleRect(320, 240); 27 static const gfx::Rect kVisibleRect(320, 240);
28 static const gfx::Size kNaturalSize(522, 288); 28 static const gfx::Size kNaturalSize(522, 288);
29 static const AVRational kFrameRate = { 100, 1 }; 29 static const AVRational kFrameRate = { 100, 1 };
30 static const AVRational kAspectRatio = { 1, 1 };
30 31
31 ACTION_P2(DemuxComplete, engine, buffer) { 32 ACTION_P2(DemuxComplete, engine, buffer) {
32 engine->ConsumeVideoSample(buffer); 33 engine->ConsumeVideoSample(buffer);
33 } 34 }
34 35
35 class FFmpegVideoDecodeEngineTest 36 class FFmpegVideoDecodeEngineTest
36 : public testing::Test, 37 : public testing::Test,
37 public VideoDecodeEngine::EventHandler { 38 public VideoDecodeEngine::EventHandler {
38 public: 39 public:
39 FFmpegVideoDecodeEngineTest() 40 FFmpegVideoDecodeEngineTest()
40 : config_(kCodecVP8, kVideoFormat, kCodedSize, kVisibleRect, 41 : config_(kCodecVP8, kVideoFormat, kCodedSize, kVisibleRect,
41 kFrameRate.num, kFrameRate.den, NULL, 0) { 42 kFrameRate.num, kFrameRate.den,
43 kAspectRatio.num, kAspectRatio.den,
44 NULL, 0) {
42 CHECK(FFmpegGlue::GetInstance()); 45 CHECK(FFmpegGlue::GetInstance());
43 46
44 // Setup FFmpeg structures. 47 // Setup FFmpeg structures.
45 frame_buffer_.reset(new uint8[kCodedSize.GetArea()]); 48 frame_buffer_.reset(new uint8[kCodedSize.GetArea()]);
46 49
47 test_engine_.reset(new FFmpegVideoDecodeEngine()); 50 test_engine_.reset(new FFmpegVideoDecodeEngine());
48 51
49 ReadTestDataFile("vp8-I-frame-320x240", &i_frame_buffer_); 52 ReadTestDataFile("vp8-I-frame-320x240", &i_frame_buffer_);
50 ReadTestDataFile("vp8-corrupt-I-frame", &corrupt_i_frame_buffer_); 53 ReadTestDataFile("vp8-corrupt-I-frame", &corrupt_i_frame_buffer_);
51 54
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 }; 142 };
140 143
141 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) { 144 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) {
142 Initialize(); 145 Initialize();
143 } 146 }
144 147
145 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) { 148 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) {
146 VideoDecoderConfig config(kUnknownVideoCodec, kVideoFormat, 149 VideoDecoderConfig config(kUnknownVideoCodec, kVideoFormat,
147 kCodedSize, kVisibleRect, 150 kCodedSize, kVisibleRect,
148 kFrameRate.num, kFrameRate.den, 151 kFrameRate.num, kFrameRate.den,
152 kAspectRatio.num, kAspectRatio.den,
149 NULL, 0); 153 NULL, 0);
150 154
151 // Test avcodec_find_decoder() returning NULL. 155 // Test avcodec_find_decoder() returning NULL.
152 EXPECT_CALL(*this, OnInitializeComplete(false)); 156 EXPECT_CALL(*this, OnInitializeComplete(false));
153 test_engine_->Initialize(MessageLoop::current(), this, NULL, config); 157 test_engine_->Initialize(MessageLoop::current(), this, NULL, config);
154 } 158 }
155 159
156 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) { 160 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) {
157 // Specify Theora w/o extra data so that avcodec_open() fails. 161 // Specify Theora w/o extra data so that avcodec_open() fails.
158 VideoDecoderConfig config(kCodecTheora, kVideoFormat, 162 VideoDecoderConfig config(kCodecTheora, kVideoFormat,
159 kCodedSize, kVisibleRect, 163 kCodedSize, kVisibleRect,
160 kFrameRate.num, kFrameRate.den, 164 kFrameRate.num, kFrameRate.den,
165 kAspectRatio.num, kAspectRatio.den,
161 NULL, 0); 166 NULL, 0);
162 EXPECT_CALL(*this, OnInitializeComplete(false)); 167 EXPECT_CALL(*this, OnInitializeComplete(false));
163 test_engine_->Initialize(MessageLoop::current(), this, NULL, config); 168 test_engine_->Initialize(MessageLoop::current(), this, NULL, config);
164 } 169 }
165 170
166 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) { 171 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) {
167 Initialize(); 172 Initialize();
168 173
169 // Simulate decoding a single frame. 174 // Simulate decoding a single frame.
170 scoped_refptr<VideoFrame> video_frame; 175 scoped_refptr<VideoFrame> video_frame;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // DecodeIFrameThenTestFile("vp8-I-frame-320x480"); 266 // DecodeIFrameThenTestFile("vp8-I-frame-320x480");
262 //} 267 //}
263 268
264 // Decode |i_frame_buffer_| and then a frame with a smaller height and verify 269 // Decode |i_frame_buffer_| and then a frame with a smaller height and verify
265 // the output size didn't change. 270 // the output size didn't change.
266 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) { 271 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) {
267 DecodeIFrameThenTestFile("vp8-I-frame-320x120"); 272 DecodeIFrameThenTestFile("vp8-I-frame-320x120");
268 } 273 }
269 274
270 } // namespace media 275 } // 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