Commit 738b28e4 authored by miu's avatar miu Committed by Commit bot

[Cast] Fix referenced_frame_ids emitted by Vp8Encoder, with massive test clean-up.

The referenced_frame_ids set by Vp8Encoder were wrong in two ways:
1) A recent change introduced an off-by-one error.  2) Math was being
done with results stored in a uint8 variable, which was causing the
upper 24 bits to be stripped.

Added VideoEncoderImplTest.GeneratesKeyFrameThenOnlyDeltaFrames test to
prevent future regressions.  In addition, a lot of unit test code clean-up
was done to beef-up existing testing while also removing useless tests.

Review URL: https://codereview.chromium.org/581903002

Cr-Commit-Position: refs/heads/master@{#295493}
parent 88084c5c
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "media/cast/cast_config.h" #include "media/cast/cast_config.h"
#include "media/cast/receiver/video_decoder.h" #include "media/cast/receiver/video_decoder.h"
#include "media/cast/sender/vp8_encoder.h" #include "media/cast/sender/vp8_encoder.h"
#include "media/cast/test/utility/default_config.h"
#include "media/cast/test/utility/standalone_cast_environment.h" #include "media/cast/test/utility/standalone_cast_environment.h"
#include "media/cast/test/utility/video_utility.h" #include "media/cast/test/utility/video_utility.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -26,7 +27,7 @@ const int kHeight = 240; ...@@ -26,7 +27,7 @@ const int kHeight = 240;
const int kFrameRate = 10; const int kFrameRate = 10;
VideoSenderConfig GetVideoSenderConfigForTest() { VideoSenderConfig GetVideoSenderConfigForTest() {
VideoSenderConfig config; VideoSenderConfig config = GetDefaultVideoSenderConfig();
config.width = kWidth; config.width = kWidth;
config.height = kHeight; config.height = kHeight;
config.max_frame_rate = kFrameRate; config.max_frame_rate = kFrameRate;
...@@ -83,7 +84,12 @@ class VideoDecoderTest : public ::testing::TestWithParam<Codec> { ...@@ -83,7 +84,12 @@ class VideoDecoderTest : public ::testing::TestWithParam<Codec> {
// Test only supports VP8, currently. // Test only supports VP8, currently.
CHECK_EQ(CODEC_VIDEO_VP8, GetParam()); CHECK_EQ(CODEC_VIDEO_VP8, GetParam());
vp8_encoder_.Encode(video_frame, encoded_frame.get()); vp8_encoder_.Encode(video_frame, encoded_frame.get());
// Rewrite frame IDs for testing purposes.
encoded_frame->frame_id = last_frame_id_ + 1 + num_dropped_frames; encoded_frame->frame_id = last_frame_id_ + 1 + num_dropped_frames;
if (last_frame_id_ == 0)
encoded_frame->referenced_frame_id = encoded_frame->frame_id;
else
encoded_frame->referenced_frame_id = encoded_frame->frame_id - 1;
last_frame_id_ = encoded_frame->frame_id; last_frame_id_ = encoded_frame->frame_id;
{ {
......
...@@ -134,7 +134,7 @@ bool Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame, ...@@ -134,7 +134,7 @@ bool Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame,
raw_image_->stride[VPX_PLANE_U] = video_frame->stride(VideoFrame::kUPlane); raw_image_->stride[VPX_PLANE_U] = video_frame->stride(VideoFrame::kUPlane);
raw_image_->stride[VPX_PLANE_V] = video_frame->stride(VideoFrame::kVPlane); raw_image_->stride[VPX_PLANE_V] = video_frame->stride(VideoFrame::kVPlane);
uint8 latest_frame_id_to_reference; uint32 latest_frame_id_to_reference;
Vp8Buffers buffer_to_update; Vp8Buffers buffer_to_update;
vpx_codec_flags_t flags = 0; vpx_codec_flags_t flags = 0;
if (key_frame_requested_) { if (key_frame_requested_) {
...@@ -228,7 +228,7 @@ bool Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame, ...@@ -228,7 +228,7 @@ bool Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame,
uint32 Vp8Encoder::GetCodecReferenceFlags(vpx_codec_flags_t* flags) { uint32 Vp8Encoder::GetCodecReferenceFlags(vpx_codec_flags_t* flags) {
if (!use_multiple_video_buffers_) if (!use_multiple_video_buffers_)
return last_encoded_frame_id_ + 1; return last_encoded_frame_id_;
const uint32 kMagicFrameOffset = 512; const uint32 kMagicFrameOffset = 512;
// We set latest_frame_to_reference to an old frame so that // We set latest_frame_to_reference to an old frame so that
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment