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

Unified Diff: media/video/ffmpeg_video_decode_engine_unittest.cc

Issue 6104007: Merge 70703 - Handle changes in video frame size.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/552d/src/
Patch Set: Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/video/ffmpeg_video_decode_engine.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/ffmpeg_video_decode_engine_unittest.cc
===================================================================
--- media/video/ffmpeg_video_decode_engine_unittest.cc (revision 70792)
+++ media/video/ffmpeg_video_decode_engine_unittest.cc (working copy)
@@ -23,6 +23,23 @@
static const int kHeight = 240;
static const AVRational kTimeBase = { 1, 100 };
+static void InitializeFrame(uint8_t* data, int width, AVFrame* frame) {
+ frame->data[0] = data;
+ frame->data[1] = data;
+ frame->data[2] = data;
+ frame->linesize[0] = width;
+ frame->linesize[1] = width / 2;
+ frame->linesize[2] = width / 2;
+}
+
+ACTION_P(DecodeComplete, decoder) {
+ decoder->video_frame_ = arg0;
+}
+
+ACTION_P2(DemuxComplete, engine, buffer) {
+ engine->ConsumeVideoSample(buffer);
+}
+
ACTION_P(SaveInitializeResult, engine) {
engine->info_ = arg0;
}
@@ -34,13 +51,8 @@
// Setup FFmpeg structures.
frame_buffer_.reset(new uint8[kWidth * kHeight]);
memset(&yuv_frame_, 0, sizeof(yuv_frame_));
+ InitializeFrame(frame_buffer_.get(), kWidth, &yuv_frame_);
- // DecodeFrame will check these pointers as non-NULL value.
- yuv_frame_.data[0] = yuv_frame_.data[1] = yuv_frame_.data[2]
- = frame_buffer_.get();
- yuv_frame_.linesize[0] = kWidth;
- yuv_frame_.linesize[1] = yuv_frame_.linesize[2] = kWidth >> 1;
-
memset(&codec_context_, 0, sizeof(codec_context_));
codec_context_.width = kWidth;
codec_context_.height = kHeight;
@@ -95,6 +107,27 @@
EXPECT_TRUE(info_.success);
}
+ void Decode() {
+ EXPECT_CALL(mock_ffmpeg_, AVInitPacket(_));
+ EXPECT_CALL(mock_ffmpeg_,
+ AVCodecDecodeVideo2(&codec_context_, &yuv_frame_, _, _))
+ .WillOnce(DoAll(SetArgumentPointee<2>(1), // Simulate 1 byte frame.
+ Return(0)));
+
+ EXPECT_CALL(*this, ProduceVideoSample(_))
+ .WillOnce(DemuxComplete(test_engine_.get(), buffer_));
+ EXPECT_CALL(*this, ConsumeVideoFrame(_))
+ .WillOnce(DecodeComplete(this));
+ test_engine_->ProduceVideoFrame(video_frame_);
+ }
+
+ void ChangeDimensions(int width, int height) {
+ frame_buffer_.reset(new uint8[width * height]);
+ InitializeFrame(frame_buffer_.get(), width, &yuv_frame_);
+ codec_context_.width = width;
+ codec_context_.height = height;
+ }
+
public:
MOCK_METHOD1(ConsumeVideoFrame,
void(scoped_refptr<VideoFrame> video_frame));
@@ -192,14 +225,6 @@
EXPECT_FALSE(info_.success);
}
-ACTION_P2(DemuxComplete, engine, buffer) {
- engine->ConsumeVideoSample(buffer);
-}
-
-ACTION_P(DecodeComplete, decoder) {
- decoder->video_frame_ = arg0;
-}
-
TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) {
Initialize();
@@ -210,19 +235,9 @@
yuv_frame_.repeat_pict = 1;
yuv_frame_.reordered_opaque = kTimestamp.InMicroseconds();
- // Expect a bunch of avcodec calls.
- EXPECT_CALL(mock_ffmpeg_, AVInitPacket(_));
- EXPECT_CALL(mock_ffmpeg_,
- AVCodecDecodeVideo2(&codec_context_, &yuv_frame_, _, _))
- .WillOnce(DoAll(SetArgumentPointee<2>(1), // Simulate 1 byte frame.
- Return(0)));
+ // Simulate decoding a single frame.
+ Decode();
- EXPECT_CALL(*this, ProduceVideoSample(_))
- .WillOnce(DemuxComplete(test_engine_.get(), buffer_));
- EXPECT_CALL(*this, ConsumeVideoFrame(_))
- .WillOnce(DecodeComplete(this));
- test_engine_->ProduceVideoFrame(video_frame_);
-
// |video_frame_| timestamp is 0 because we set the timestamp based off
// the buffer timestamp.
EXPECT_EQ(0, video_frame_->GetTimestamp().ToInternalValue());
@@ -271,6 +286,30 @@
EXPECT_FALSE(video_frame_.get());
}
+TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_LargerWidth) {
+ Initialize();
+ ChangeDimensions(kWidth * 2, kHeight);
+ Decode();
+}
+
+TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerWidth) {
+ Initialize();
+ ChangeDimensions(kWidth / 2, kHeight);
+ Decode();
+}
+
+TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_LargerHeight) {
+ Initialize();
+ ChangeDimensions(kWidth, kHeight * 2);
+ Decode();
+}
+
+TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_SmallerHeight) {
+ Initialize();
+ ChangeDimensions(kWidth, kHeight / 2);
+ Decode();
+}
+
TEST_F(FFmpegVideoDecodeEngineTest, GetSurfaceFormat) {
// YV12 formats.
codec_context_.pix_fmt = PIX_FMT_YUV420P;
« 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