Verify parsed QP value when frame is encoded instead of storing parsed value and verifying later.
Removes: - VideoProcessor: GetQpFromEncoder, GetQpFromBitstream - FrameInfo: qp_encoder, qp_bitstream BUG=webrtc:6634 Review-Url: https://codereview.webrtc.org/3007753002 Cr-Commit-Position: refs/heads/master@{#19579}
This commit is contained in:
@ -26,6 +26,7 @@
|
||||
#include "webrtc/rtc_base/logging.h"
|
||||
#include "webrtc/rtc_base/timeutils.h"
|
||||
#include "webrtc/system_wrappers/include/cpu_info.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
@ -91,6 +92,22 @@ void PrintCodecSettings(const VideoCodec& codec_settings) {
|
||||
}
|
||||
}
|
||||
|
||||
void VerifyQpParser(const EncodedImage& encoded_frame,
|
||||
const TestConfig& config) {
|
||||
if (config.hw_codec)
|
||||
return;
|
||||
|
||||
int qp;
|
||||
if (config.codec_settings.codecType == kVideoCodecVP8) {
|
||||
ASSERT_TRUE(vp8::GetQp(encoded_frame._buffer, encoded_frame._length, &qp));
|
||||
} else if (config.codec_settings.codecType == kVideoCodecVP9) {
|
||||
ASSERT_TRUE(vp9::GetQp(encoded_frame._buffer, encoded_frame._length, &qp));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(encoded_frame.qp_, qp) << "Encoder QP != parsed bitstream QP.";
|
||||
}
|
||||
|
||||
int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) {
|
||||
int64_t diff_us = (stop_ns - start_ns) / rtc::kNumNanosecsPerMicrosec;
|
||||
RTC_DCHECK_GE(diff_us, std::numeric_limits<int>::min());
|
||||
@ -263,18 +280,6 @@ void VideoProcessor::SetRates(int bitrate_kbps, int framerate_fps) {
|
||||
num_spatial_resizes_ = 0;
|
||||
}
|
||||
|
||||
int VideoProcessor::GetQpFromEncoder(int frame_number) const {
|
||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
|
||||
RTC_CHECK_LT(frame_number, frame_infos_.size());
|
||||
return frame_infos_[frame_number].qp_encoder;
|
||||
}
|
||||
|
||||
int VideoProcessor::GetQpFromBitstream(int frame_number) const {
|
||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
|
||||
RTC_CHECK_LT(frame_number, frame_infos_.size());
|
||||
return frame_infos_[frame_number].qp_bitstream;
|
||||
}
|
||||
|
||||
int VideoProcessor::NumberDroppedFrames() {
|
||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
|
||||
return num_dropped_frames_;
|
||||
@ -332,16 +337,9 @@ void VideoProcessor::FrameEncoded(webrtc::VideoCodecType codec,
|
||||
last_encoded_frame_num_ = frame_number;
|
||||
|
||||
// Frame is not dropped, so update frame information and statistics.
|
||||
VerifyQpParser(encoded_image, config_);
|
||||
RTC_CHECK_LT(frame_number, frame_infos_.size());
|
||||
FrameInfo* frame_info = &frame_infos_[frame_number];
|
||||
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];
|
||||
frame_stat->encode_time_in_us =
|
||||
GetElapsedTimeMicroseconds(frame_info->encode_start_ns, encode_stop_ns);
|
||||
|
||||
@ -159,13 +159,6 @@ class VideoProcessor {
|
||||
// Updates the encoder with target rates. Must be called at least once.
|
||||
void SetRates(int bitrate_kbps, int framerate_fps);
|
||||
|
||||
|
||||
// TODO(brandtr): Get rid of these functions by moving the corresponding QP
|
||||
// fields to the Stats object.
|
||||
int GetQpFromEncoder(int frame_number) const;
|
||||
int GetQpFromBitstream(int frame_number) const;
|
||||
|
||||
|
||||
// Return the number of dropped frames.
|
||||
int NumberDroppedFrames();
|
||||
|
||||
@ -180,8 +173,6 @@ class VideoProcessor {
|
||||
struct FrameInfo {
|
||||
int64_t encode_start_ns = 0;
|
||||
int64_t decode_start_ns = 0;
|
||||
int qp_encoder = 0;
|
||||
int qp_bitstream = 0;
|
||||
int decoded_width = 0;
|
||||
int decoded_height = 0;
|
||||
size_t manipulated_length = 0;
|
||||
|
||||
@ -391,15 +391,6 @@ class VideoProcessorIntegrationTest : public testing::Test {
|
||||
EXPECT_GT(ssim_result.min, quality_thresholds.min_min_ssim);
|
||||
}
|
||||
|
||||
void VerifyQpParser(int frame_number) {
|
||||
if (!config_.hw_codec &&
|
||||
(config_.codec_settings.codecType == kVideoCodecVP8 ||
|
||||
config_.codec_settings.codecType == kVideoCodecVP9)) {
|
||||
EXPECT_EQ(processor_->GetQpFromEncoder(frame_number),
|
||||
processor_->GetQpFromBitstream(frame_number));
|
||||
}
|
||||
}
|
||||
|
||||
static int NumberOfTemporalLayers(const VideoCodec& codec_settings) {
|
||||
if (codec_settings.codecType == kVideoCodecVP8) {
|
||||
return codec_settings.VP8().numberOfTemporalLayers;
|
||||
@ -494,7 +485,6 @@ class VideoProcessorIntegrationTest : public testing::Test {
|
||||
|
||||
while (frame_number < num_frames) {
|
||||
processor_->ProcessFrame(frame_number);
|
||||
VerifyQpParser(frame_number);
|
||||
const int tl_idx = TemporalLayerIndexForFrame(frame_number);
|
||||
++num_frames_per_update_[tl_idx];
|
||||
++num_frames_total_;
|
||||
|
||||
Reference in New Issue
Block a user