| OLD | NEW |
| 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_task.h" | 8 #include "media/base/mock_task.h" |
| 9 #include "media/base/pipeline.h" | 9 #include "media/base/pipeline.h" |
| 10 #include "media/base/test_data_util.h" | 10 #include "media/base/test_data_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 ACTION_P2(DemuxComplete, engine, buffer) { | 31 ACTION_P2(DemuxComplete, engine, buffer) { |
| 32 engine->ConsumeVideoSample(buffer); | 32 engine->ConsumeVideoSample(buffer); |
| 33 } | 33 } |
| 34 | 34 |
| 35 class FFmpegVideoDecodeEngineTest | 35 class FFmpegVideoDecodeEngineTest |
| 36 : public testing::Test, | 36 : public testing::Test, |
| 37 public VideoDecodeEngine::EventHandler { | 37 public VideoDecodeEngine::EventHandler { |
| 38 public: | 38 public: |
| 39 FFmpegVideoDecodeEngineTest() | 39 FFmpegVideoDecodeEngineTest() |
| 40 : config_(kCodecVP8, kCodedSize, kVisibleRect, kNaturalSize, | 40 : config_(kCodecVP8, VideoFrame::YV12, kCodedSize, kVisibleRect, |
| 41 kFrameRate.num, kFrameRate.den, NULL, 0) { | 41 kNaturalSize, kFrameRate.num, kFrameRate.den, NULL, 0) { |
| 42 CHECK(FFmpegGlue::GetInstance()); | 42 CHECK(FFmpegGlue::GetInstance()); |
| 43 | 43 |
| 44 // Setup FFmpeg structures. | 44 // Setup FFmpeg structures. |
| 45 frame_buffer_.reset(new uint8[kCodedSize.GetArea()]); | 45 frame_buffer_.reset(new uint8[kCodedSize.GetArea()]); |
| 46 | 46 |
| 47 test_engine_.reset(new FFmpegVideoDecodeEngine()); | 47 test_engine_.reset(new FFmpegVideoDecodeEngine()); |
| 48 | 48 |
| 49 ReadTestDataFile("vp8-I-frame-320x240", &i_frame_buffer_); | 49 ReadTestDataFile("vp8-I-frame-320x240", &i_frame_buffer_); |
| 50 ReadTestDataFile("vp8-corrupt-I-frame", &corrupt_i_frame_buffer_); | 50 ReadTestDataFile("vp8-corrupt-I-frame", &corrupt_i_frame_buffer_); |
| 51 | 51 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 private: | 143 private: |
| 144 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecodeEngineTest); | 144 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecodeEngineTest); |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) { | 147 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) { |
| 148 Initialize(); | 148 Initialize(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) { | 151 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) { |
| 152 VideoDecoderConfig config(kUnknownVideoCodec, kCodedSize, kVisibleRect, | 152 VideoDecoderConfig config(kUnknownVideoCodec, VideoFrame::YV12, kCodedSize, |
| 153 kNaturalSize, kFrameRate.num, kFrameRate.den, | 153 kVisibleRect, kNaturalSize, kFrameRate.num, |
| 154 NULL, 0); | 154 kFrameRate.den, NULL, 0); |
| 155 | 155 |
| 156 // Test avcodec_find_decoder() returning NULL. | 156 // Test avcodec_find_decoder() returning NULL. |
| 157 VideoCodecInfo info; | 157 VideoCodecInfo info; |
| 158 EXPECT_CALL(*this, OnInitializeComplete(_)) | 158 EXPECT_CALL(*this, OnInitializeComplete(_)) |
| 159 .WillOnce(SaveArg<0>(&info)); | 159 .WillOnce(SaveArg<0>(&info)); |
| 160 test_engine_->Initialize(MessageLoop::current(), this, NULL, config); | 160 test_engine_->Initialize(MessageLoop::current(), this, NULL, config); |
| 161 EXPECT_FALSE(info.success); | 161 EXPECT_FALSE(info.success); |
| 162 } | 162 } |
| 163 | 163 |
| 164 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) { | 164 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) { |
| 165 // Specify Theora w/o extra data so that avcodec_open() fails. | 165 // Specify Theora w/o extra data so that avcodec_open() fails. |
| 166 VideoDecoderConfig config(kCodecTheora, kCodedSize, kVisibleRect, | 166 VideoDecoderConfig config(kCodecTheora, VideoFrame::YV12, kCodedSize, |
| 167 kNaturalSize, kFrameRate.num, kFrameRate.den, | 167 kVisibleRect, kNaturalSize, kFrameRate.num, |
| 168 NULL, 0); | 168 kFrameRate.den, NULL, 0); |
| 169 VideoCodecInfo info; | 169 VideoCodecInfo info; |
| 170 EXPECT_CALL(*this, OnInitializeComplete(_)) | 170 EXPECT_CALL(*this, OnInitializeComplete(_)) |
| 171 .WillOnce(SaveArg<0>(&info)); | 171 .WillOnce(SaveArg<0>(&info)); |
| 172 test_engine_->Initialize(MessageLoop::current(), this, NULL, config); | 172 test_engine_->Initialize(MessageLoop::current(), this, NULL, config); |
| 173 EXPECT_FALSE(info.success); | 173 EXPECT_FALSE(info.success); |
| 174 } | 174 } |
| 175 | 175 |
| 176 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) { | 176 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) { |
| 177 Initialize(); | 177 Initialize(); |
| 178 | 178 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // DecodeIFrameThenTestFile("vp8-I-frame-320x480"); | 276 // DecodeIFrameThenTestFile("vp8-I-frame-320x480"); |
| 277 //} | 277 //} |
| 278 | 278 |
| 279 // Decode |i_frame_buffer_| and then a frame with a smaller height and verify | 279 // Decode |i_frame_buffer_| and then a frame with a smaller height and verify |
| 280 // the output size didn't change. | 280 // the output size didn't change. |
| 281 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) { | 281 TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) { |
| 282 DecodeIFrameThenTestFile("vp8-I-frame-320x120"); | 282 DecodeIFrameThenTestFile("vp8-I-frame-320x120"); |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace media | 285 } // namespace media |
| OLD | NEW |