Add unit tests for qp parser.
Add test for vp8/vp9 qp parser in both videoprocessor_integrationtest. Check the qp from parser equal to that from the encoder on every frame in every test. Add test for vp8/vp9 qp parser in vp8/vp9_impl_test. Check the qp parser on a single key frame. BUG=None Review-Url: https://codereview.webrtc.org/2903163002 Cr-Commit-Position: refs/heads/master@{#18334}
This commit is contained in:
parent
6c4bbfa06f
commit
b5f5bdba77
@ -19,6 +19,8 @@
|
|||||||
#include "webrtc/base/event.h"
|
#include "webrtc/base/event.h"
|
||||||
#include "webrtc/base/thread_annotations.h"
|
#include "webrtc/base/thread_annotations.h"
|
||||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||||
|
#include "webrtc/modules/video_coding/utility/vp8_header_parser.h"
|
||||||
|
#include "webrtc/modules/video_coding/utility/vp9_uncompressed_header_parser.h"
|
||||||
#include "webrtc/test/gtest.h"
|
#include "webrtc/test/gtest.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|||||||
@ -232,6 +232,16 @@ FrameType VideoProcessorImpl::EncodedFrameType(int frame_number) {
|
|||||||
return frame_infos_[frame_number].encoded_frame_type;
|
return frame_infos_[frame_number].encoded_frame_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int VideoProcessorImpl::GetQpFromEncoder(int frame_number) {
|
||||||
|
RTC_DCHECK_LT(frame_number, frame_infos_.size());
|
||||||
|
return frame_infos_[frame_number].qp_encoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VideoProcessorImpl::GetQpFromBitstream(int frame_number) {
|
||||||
|
RTC_DCHECK_LT(frame_number, frame_infos_.size());
|
||||||
|
return frame_infos_[frame_number].qp_bitstream;
|
||||||
|
}
|
||||||
|
|
||||||
int VideoProcessorImpl::NumberDroppedFrames() {
|
int VideoProcessorImpl::NumberDroppedFrames() {
|
||||||
return num_dropped_frames_;
|
return num_dropped_frames_;
|
||||||
}
|
}
|
||||||
@ -347,6 +357,14 @@ void VideoProcessorImpl::FrameEncoded(
|
|||||||
FrameInfo* frame_info = &frame_infos_[frame_number];
|
FrameInfo* frame_info = &frame_infos_[frame_number];
|
||||||
frame_info->encoded_frame_size = encoded_image._length;
|
frame_info->encoded_frame_size = encoded_image._length;
|
||||||
frame_info->encoded_frame_type = encoded_image._frameType;
|
frame_info->encoded_frame_type = encoded_image._frameType;
|
||||||
|
frame_info->qp_encoder = encoded_image.qp_;
|
||||||
|
if (codec == kVideoCodecVP8) {
|
||||||
|
vp8::GetQp(encoded_image._buffer, encoded_image._length,
|
||||||
|
&frame_info->qp_bitstream);
|
||||||
|
} else if (codec == kVideoCodecVP9) {
|
||||||
|
vp9::GetQp(encoded_image._buffer, encoded_image._length,
|
||||||
|
&frame_info->qp_bitstream);
|
||||||
|
}
|
||||||
FrameStatistic* frame_stat = &stats_->stats_[frame_number];
|
FrameStatistic* frame_stat = &stats_->stats_[frame_number];
|
||||||
frame_stat->encode_time_in_us =
|
frame_stat->encode_time_in_us =
|
||||||
GetElapsedTimeMicroseconds(frame_info->encode_start_ns, encode_stop_ns);
|
GetElapsedTimeMicroseconds(frame_info->encode_start_ns, encode_stop_ns);
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
#include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h"
|
#include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/test/stats.h"
|
#include "webrtc/modules/video_coding/codecs/test/stats.h"
|
||||||
#include "webrtc/modules/video_coding/utility/ivf_file_writer.h"
|
#include "webrtc/modules/video_coding/utility/ivf_file_writer.h"
|
||||||
|
#include "webrtc/modules/video_coding/utility/vp8_header_parser.h"
|
||||||
|
#include "webrtc/modules/video_coding/utility/vp9_uncompressed_header_parser.h"
|
||||||
#include "webrtc/test/testsupport/frame_reader.h"
|
#include "webrtc/test/testsupport/frame_reader.h"
|
||||||
#include "webrtc/test/testsupport/frame_writer.h"
|
#include "webrtc/test/testsupport/frame_writer.h"
|
||||||
|
|
||||||
@ -153,6 +155,12 @@ class VideoProcessor {
|
|||||||
// Return the encoded frame type (key or delta).
|
// Return the encoded frame type (key or delta).
|
||||||
virtual FrameType EncodedFrameType(int frame_number) = 0;
|
virtual FrameType EncodedFrameType(int frame_number) = 0;
|
||||||
|
|
||||||
|
// Return the qp used by encoder.
|
||||||
|
virtual int GetQpFromEncoder(int frame_number) = 0;
|
||||||
|
|
||||||
|
// Return the qp from the qp parser.
|
||||||
|
virtual int GetQpFromBitstream(int frame_number) = 0;
|
||||||
|
|
||||||
// Return the number of dropped frames.
|
// Return the number of dropped frames.
|
||||||
virtual int NumberDroppedFrames() = 0;
|
virtual int NumberDroppedFrames() = 0;
|
||||||
|
|
||||||
@ -189,7 +197,9 @@ class VideoProcessorImpl : public VideoProcessor {
|
|||||||
encoded_frame_type(kVideoFrameDelta),
|
encoded_frame_type(kVideoFrameDelta),
|
||||||
decoded_width(0),
|
decoded_width(0),
|
||||||
decoded_height(0),
|
decoded_height(0),
|
||||||
manipulated_length(0) {}
|
manipulated_length(0),
|
||||||
|
qp_encoder(0),
|
||||||
|
qp_bitstream(0) {}
|
||||||
|
|
||||||
uint32_t timestamp;
|
uint32_t timestamp;
|
||||||
int64_t encode_start_ns;
|
int64_t encode_start_ns;
|
||||||
@ -199,6 +209,8 @@ class VideoProcessorImpl : public VideoProcessor {
|
|||||||
int decoded_width;
|
int decoded_width;
|
||||||
int decoded_height;
|
int decoded_height;
|
||||||
size_t manipulated_length;
|
size_t manipulated_length;
|
||||||
|
int qp_encoder;
|
||||||
|
int qp_bitstream;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Callback class required to implement according to the VideoEncoder API.
|
// Callback class required to implement according to the VideoEncoder API.
|
||||||
@ -265,6 +277,12 @@ class VideoProcessorImpl : public VideoProcessor {
|
|||||||
// Return the encoded frame type (key or delta).
|
// Return the encoded frame type (key or delta).
|
||||||
FrameType EncodedFrameType(int frame_number) override;
|
FrameType EncodedFrameType(int frame_number) override;
|
||||||
|
|
||||||
|
// Return the qp used by encoder.
|
||||||
|
int GetQpFromEncoder(int frame_number) override;
|
||||||
|
|
||||||
|
// Return the qp from the qp parser.
|
||||||
|
int GetQpFromBitstream(int frame_number) override;
|
||||||
|
|
||||||
// Return the number of dropped frames.
|
// Return the number of dropped frames.
|
||||||
int NumberDroppedFrames() override;
|
int NumberDroppedFrames() override;
|
||||||
|
|
||||||
|
|||||||
@ -494,6 +494,14 @@ class VideoProcessorIntegrationTest : public testing::Test {
|
|||||||
EXPECT_GT(ssim_result.min, quality_thresholds.min_min_ssim);
|
EXPECT_GT(ssim_result.min, quality_thresholds.min_min_ssim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VerifyQpParser(const CodecParams& process, int frame_number) {
|
||||||
|
if (!process.hw_codec && (process.codec_type == kVideoCodecVP8 ||
|
||||||
|
process.codec_type == kVideoCodecVP9)) {
|
||||||
|
EXPECT_EQ(processor_->GetQpFromEncoder(frame_number),
|
||||||
|
processor_->GetQpFromBitstream(frame_number));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Temporal layer index corresponding to frame number, for up to 3 layers.
|
// Temporal layer index corresponding to frame number, for up to 3 layers.
|
||||||
int TemporalLayerIndexForFrame(int frame_number) {
|
int TemporalLayerIndexForFrame(int frame_number) {
|
||||||
int tl_idx = -1;
|
int tl_idx = -1;
|
||||||
@ -605,7 +613,7 @@ class VideoProcessorIntegrationTest : public testing::Test {
|
|||||||
|
|
||||||
while (frame_number < num_frames) {
|
while (frame_number < num_frames) {
|
||||||
EXPECT_TRUE(processor_->ProcessFrame(frame_number));
|
EXPECT_TRUE(processor_->ProcessFrame(frame_number));
|
||||||
|
VerifyQpParser(process, frame_number);
|
||||||
++num_frames_per_update_[TemporalLayerIndexForFrame(frame_number)];
|
++num_frames_per_update_[TemporalLayerIndexForFrame(frame_number)];
|
||||||
++num_frames_total_;
|
++num_frames_total_;
|
||||||
UpdateRateControlMetrics(frame_number);
|
UpdateRateControlMetrics(frame_number);
|
||||||
|
|||||||
@ -17,9 +17,9 @@
|
|||||||
#include "webrtc/base/optional.h"
|
#include "webrtc/base/optional.h"
|
||||||
#include "webrtc/base/timeutils.h"
|
#include "webrtc/base/timeutils.h"
|
||||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||||
|
#include "webrtc/modules/video_coding/codecs/test/video_codec_test.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
|
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
|
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
|
||||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
|
||||||
#include "webrtc/test/frame_utils.h"
|
#include "webrtc/test/frame_utils.h"
|
||||||
#include "webrtc/test/gtest.h"
|
#include "webrtc/test/gtest.h"
|
||||||
#include "webrtc/test/testsupport/fileutils.h"
|
#include "webrtc/test/testsupport/fileutils.h"
|
||||||
@ -309,6 +309,18 @@ TEST_F(TestVp8Impl, DecodedQpEqualsEncodedQp) {
|
|||||||
EXPECT_EQ(encoded_frame_.qp_, *decoded_qp_);
|
EXPECT_EQ(encoded_frame_.qp_, *decoded_qp_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TestVp8Impl, ParserQpEqualsEncodedQp) {
|
||||||
|
SetUpEncodeDecode();
|
||||||
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||||
|
encoder_->Encode(*input_frame_, nullptr, nullptr));
|
||||||
|
EXPECT_GT(WaitForEncodedFrame(), 0u);
|
||||||
|
|
||||||
|
int qp = 0;
|
||||||
|
ASSERT_TRUE(vp8::GetQp(encoded_frame_._buffer, encoded_frame_._length, &qp));
|
||||||
|
|
||||||
|
EXPECT_EQ(encoded_frame_.qp_, qp);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(WEBRTC_ANDROID)
|
#if defined(WEBRTC_ANDROID)
|
||||||
#define MAYBE_AlignedStrideEncodeDecode DISABLED_AlignedStrideEncodeDecode
|
#define MAYBE_AlignedStrideEncodeDecode DISABLED_AlignedStrideEncodeDecode
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -104,6 +104,19 @@ TEST_F(TestVp9Impl, DecodedQpEqualsEncodedQp) {
|
|||||||
EXPECT_EQ(encoded_frame.qp_, *decoded_qp);
|
EXPECT_EQ(encoded_frame.qp_, *decoded_qp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TestVp9Impl, ParserQpEqualsEncodedQp) {
|
||||||
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||||
|
encoder_->Encode(*input_frame_, nullptr, nullptr));
|
||||||
|
EncodedImage encoded_frame;
|
||||||
|
CodecSpecificInfo codec_specific_info;
|
||||||
|
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||||
|
|
||||||
|
int qp = 0;
|
||||||
|
ASSERT_TRUE(vp9::GetQp(encoded_frame._buffer, encoded_frame._length, &qp));
|
||||||
|
|
||||||
|
EXPECT_EQ(encoded_frame.qp_, qp);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(TestVp9Impl, EncoderRetainsRtpStateAfterRelease) {
|
TEST_F(TestVp9Impl, EncoderRetainsRtpStateAfterRelease) {
|
||||||
// Override default settings.
|
// Override default settings.
|
||||||
codec_settings_.VP9()->numberOfTemporalLayers = 2;
|
codec_settings_.VP9()->numberOfTemporalLayers = 2;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user