Revert 4597 "Don't force key frame when decoding with errors"

> Don't force key frame when decoding with errors
> 
> BUG=2241
> R=stefan@webrtc.org
> 
> Review URL: https://webrtc-codereview.appspot.com/2036004

TBR=mikhal@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2093004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4600 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrike@webrtc.org
2013-08-23 00:53:24 +00:00
parent eef29ec6cf
commit ceea41d135
11 changed files with 83 additions and 122 deletions

View File

@ -106,43 +106,6 @@ class TestVp8Impl : public ::testing::Test {
Vp8UnitTestDecodeCompleteCallback(&decoded_video_frame_));
encoder_->RegisterEncodeCompleteCallback(encode_complete_callback_.get());
decoder_->RegisterDecodeCompleteCallback(decode_complete_callback_.get());
// Using a QCIF image (aligned stride (u,v planes) > width).
// Processing only one frame.
const VideoSource source(test::ResourcePath("paris_qcif", "yuv"), kQCIF);
length_source_frame_ = source.GetFrameLength();
source_buffer_.reset(new uint8_t[length_source_frame_]);
source_file_ = fopen(source.GetFileName().c_str(), "rb");
ASSERT_TRUE(source_file_ != NULL);
// Set input frame.
ASSERT_EQ(fread(source_buffer_.get(), 1, length_source_frame_,
source_file_), length_source_frame_);
codec_inst_.width = source.GetWidth();
codec_inst_.height = source.GetHeight();
codec_inst_.maxFramerate = source.GetFrameRate();
// Setting aligned stride values.
int stride_uv = 0;
int stride_y = 0;
Calc16ByteAlignedStride(codec_inst_.width, &stride_y, &stride_uv);
EXPECT_EQ(stride_y, 176);
EXPECT_EQ(stride_uv, 96);
input_frame_.CreateEmptyFrame(codec_inst_.width, codec_inst_.height,
stride_y, stride_uv, stride_uv);
// Using ConvertToI420 to add stride to the image.
EXPECT_EQ(0, ConvertToI420(kI420, source_buffer_.get(), 0, 0,
codec_inst_.width, codec_inst_.height,
0, kRotateNone, &input_frame_));
}
void SetUpEncodeDecode() {
codec_inst_.startBitrate = 300;
codec_inst_.maxBitrate = 4000;
codec_inst_.qpMax = 56;
codec_inst_.codecSpecific.VP8.denoisingOn = true;
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
encoder_->InitEncode(&codec_inst_, 1, 1440));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1));
}
int WaitForEncodedFrame() const {
@ -180,7 +143,6 @@ class TestVp8Impl : public ::testing::Test {
scoped_ptr<Vp8UnitTestDecodeCompleteCallback> decode_complete_callback_;
scoped_array<uint8_t> source_buffer_;
FILE* source_file_;
I420VideoFrame input_frame_;
scoped_ptr<VideoEncoder> encoder_;
scoped_ptr<VideoDecoder> decoder_;
VideoFrame encoded_video_frame_;
@ -228,38 +190,49 @@ TEST_F(TestVp8Impl, EncoderParameterTest) {
}
TEST_F(TestVp8Impl, DISABLED_ON_ANDROID(AlignedStrideEncodeDecode)) {
SetUpEncodeDecode();
encoder_->Encode(input_frame_, NULL, NULL);
// Using a QCIF image (aligned stride (u,v planse) > width).
// Processing only one frame.
const VideoSource source(test::ResourcePath("paris_qcif", "yuv"), kQCIF);
length_source_frame_ = source.GetFrameLength();
source_buffer_.reset(new uint8_t[length_source_frame_]);
source_file_ = fopen(source.GetFileName().c_str(), "rb");
ASSERT_TRUE(source_file_ != NULL);
codec_inst_.maxFramerate = source.GetFrameRate();
codec_inst_.startBitrate = 300;
codec_inst_.maxBitrate = 4000;
codec_inst_.qpMax = 56;
codec_inst_.width = source.GetWidth();
codec_inst_.height = source.GetHeight();
codec_inst_.codecSpecific.VP8.denoisingOn = true;
// Get input frame.
ASSERT_EQ(fread(source_buffer_.get(), 1, length_source_frame_, source_file_),
length_source_frame_);
// Setting aligned stride values.
int stride_uv = 0;
int stride_y = 0;
Calc16ByteAlignedStride(codec_inst_.width, &stride_y, &stride_uv);
EXPECT_EQ(stride_y, 176);
EXPECT_EQ(stride_uv, 96);
I420VideoFrame input_frame;
input_frame.CreateEmptyFrame(codec_inst_.width, codec_inst_.height,
stride_y, stride_uv, stride_uv);
// Using ConvertToI420 to add stride to the image.
EXPECT_EQ(0, ConvertToI420(kI420, source_buffer_.get(), 0, 0,
codec_inst_.width, codec_inst_.height,
0, kRotateNone, &input_frame));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->InitEncode(&codec_inst_, 1, 1440));
encoder_->Encode(input_frame, NULL, NULL);
EXPECT_GT(WaitForEncodedFrame(), 0);
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1));
EncodedImage encodedImage;
VideoFrameToEncodedImage(encoded_video_frame_, encodedImage);
// First frame should be a key frame.
encodedImage._frameType = kKeyFrame;
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encodedImage, false, NULL));
EXPECT_GT(WaitForDecodedFrame(), 0);
// Compute PSNR on all planes (faster than SSIM).
EXPECT_GT(I420PSNR(&input_frame_, &decoded_video_frame_), 36);
}
TEST_F(TestVp8Impl, DecodeWithACompleteKeyFrame) {
SetUpEncodeDecode();
encoder_->Encode(input_frame_, NULL, NULL);
EXPECT_GT(WaitForEncodedFrame(), 0);
EncodedImage encodedImage;
VideoFrameToEncodedImage(encoded_video_frame_, encodedImage);
// Setting complete to false -> should return an error.
encodedImage._completeFrame = false;
EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR,
decoder_->Decode(encodedImage, false, NULL));
// Setting complete back to true.
encodedImage._completeFrame = true;
EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR,
decoder_->Decode(encodedImage, false, NULL));
// Now setting a key frame.
encodedImage._frameType = kKeyFrame;
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encodedImage, false, NULL));
EXPECT_GT(I420PSNR(&input_frame_, &decoded_video_frame_), 36);
EXPECT_GT(I420PSNR(&input_frame, &decoded_video_frame_), 36);
}
} // namespace webrtc

View File

@ -502,8 +502,8 @@ VP8DecoderImpl::VP8DecoderImpl()
image_format_(VPX_IMG_FMT_NONE),
ref_frame_(NULL),
propagation_cnt_(-1),
mfqe_enabled_(false),
key_frame_required_(true) {
latest_keyframe_complete_(false),
mfqe_enabled_(false) {
memset(&codec_, 0, sizeof(codec_));
}
@ -518,6 +518,7 @@ int VP8DecoderImpl::Reset() {
}
InitDecode(&codec_, 1);
propagation_cnt_ = -1;
latest_keyframe_complete_ = false;
mfqe_enabled_ = false;
return WEBRTC_VIDEO_CODEC_OK;
}
@ -570,12 +571,9 @@ int VP8DecoderImpl::InitDecode(const VideoCodec* inst, int number_of_cores) {
}
propagation_cnt_ = -1;
latest_keyframe_complete_ = false;
inited_ = true;
// Always start with a complete key frame.
key_frame_required_ = true;
return WEBRTC_VIDEO_CODEC_OK;
}
@ -617,18 +615,6 @@ int VP8DecoderImpl::Decode(const EncodedImage& input_image,
}
#endif
// Always start with a complete key frame.
if (key_frame_required_) {
if (input_image._frameType != kKeyFrame)
return WEBRTC_VIDEO_CODEC_ERROR;
// We have a key frame - is it complete?
if (input_image._completeFrame) {
key_frame_required_ = false;
} else {
return WEBRTC_VIDEO_CODEC_ERROR;
}
}
// Restrict error propagation using key frame requests. Disabled when
// the feedback mode is enabled (RPS).
// Reset on a key frame refresh.
@ -722,7 +708,9 @@ int VP8DecoderImpl::Decode(const EncodedImage& input_image,
// Whenever we receive an incomplete key frame all reference buffers will
// be corrupt. If that happens we must request new key frames until we
// decode a complete.
if (input_image._frameType == kKeyFrame && !input_image._completeFrame)
if (input_image._frameType == kKeyFrame)
latest_keyframe_complete_ = input_image._completeFrame;
if (!latest_keyframe_complete_)
return WEBRTC_VIDEO_CODEC_ERROR;
// Check for reference updates and last reference buffer corruption and

View File

@ -226,8 +226,8 @@ class VP8DecoderImpl : public VP8Decoder {
int image_format_;
vpx_ref_frame_t* ref_frame_;
int propagation_cnt_;
bool latest_keyframe_complete_;
bool mfqe_enabled_;
bool key_frame_required_;
}; // end of VP8Decoder class
} // namespace webrtc