Don't re-randomize picture_id/tl0_pic_idx when re-initializing internal encoders.
TESTED=video_loopback and AppRTCMobile with forced encoder reinits every 30 frames. BUG=webrtc:7475 Review-Url: https://codereview.webrtc.org/2833493003 Cr-Commit-Position: refs/heads/master@{#17984}
This commit is contained in:
@ -33,6 +33,11 @@ VideoCodecTest::FakeEncodeCompleteCallback::OnEncodedImage(
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
rtc::CritScope lock(&test_->encoded_frame_section_);
|
||||
test_->encoded_frame_.emplace(frame);
|
||||
RTC_DCHECK(codec_specific_info);
|
||||
test_->codec_specific_info_.codecType = codec_specific_info->codecType;
|
||||
// Skip |codec_name|, to avoid allocating.
|
||||
test_->codec_specific_info_.codecSpecific =
|
||||
codec_specific_info->codecSpecific;
|
||||
test_->encoded_frame_event_.Set();
|
||||
return Result(Result::OK);
|
||||
}
|
||||
@ -65,7 +70,9 @@ void VideoCodecTest::SetUp() {
|
||||
InitCodecs();
|
||||
}
|
||||
|
||||
bool VideoCodecTest::WaitForEncodedFrame(EncodedImage* frame) {
|
||||
bool VideoCodecTest::WaitForEncodedFrame(
|
||||
EncodedImage* frame,
|
||||
CodecSpecificInfo* codec_specific_info) {
|
||||
bool ret = encoded_frame_event_.Wait(kEncodeTimeoutMs);
|
||||
EXPECT_TRUE(ret) << "Timed out while waiting for an encoded frame.";
|
||||
// This becomes unsafe if there are multiple threads waiting for frames.
|
||||
@ -74,6 +81,9 @@ bool VideoCodecTest::WaitForEncodedFrame(EncodedImage* frame) {
|
||||
if (encoded_frame_) {
|
||||
*frame = std::move(*encoded_frame_);
|
||||
encoded_frame_.reset();
|
||||
RTC_DCHECK(codec_specific_info);
|
||||
codec_specific_info->codecType = codec_specific_info_.codecType;
|
||||
codec_specific_info->codecSpecific = codec_specific_info_.codecSpecific;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -98,18 +108,18 @@ bool VideoCodecTest::WaitForDecodedFrame(std::unique_ptr<VideoFrame>* frame,
|
||||
}
|
||||
|
||||
void VideoCodecTest::InitCodecs() {
|
||||
VideoCodec codec_inst = codec_settings();
|
||||
codec_inst.startBitrate = kStartBitrate;
|
||||
codec_inst.targetBitrate = kTargetBitrate;
|
||||
codec_inst.maxBitrate = kMaxBitrate;
|
||||
codec_inst.maxFramerate = kMaxFramerate;
|
||||
codec_inst.width = kWidth;
|
||||
codec_inst.height = kHeight;
|
||||
codec_settings_ = codec_settings();
|
||||
codec_settings_.startBitrate = kStartBitrate;
|
||||
codec_settings_.targetBitrate = kTargetBitrate;
|
||||
codec_settings_.maxBitrate = kMaxBitrate;
|
||||
codec_settings_.maxFramerate = kMaxFramerate;
|
||||
codec_settings_.width = kWidth;
|
||||
codec_settings_.height = kHeight;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
encoder_->InitEncode(&codec_inst, 1 /* number of cores */,
|
||||
encoder_->InitEncode(&codec_settings_, 1 /* number of cores */,
|
||||
0 /* max payload size (unused) */));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->InitDecode(&codec_inst, 1 /* number of cores */));
|
||||
decoder_->InitDecode(&codec_settings_, 1 /* number of cores */));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/event.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -71,10 +72,14 @@ class VideoCodecTest : public ::testing::Test {
|
||||
|
||||
void SetUp() override;
|
||||
|
||||
bool WaitForEncodedFrame(EncodedImage* frame);
|
||||
bool WaitForEncodedFrame(EncodedImage* frame,
|
||||
CodecSpecificInfo* codec_specific_info);
|
||||
bool WaitForDecodedFrame(std::unique_ptr<VideoFrame>* frame,
|
||||
rtc::Optional<uint8_t>* qp);
|
||||
|
||||
// Populated by InitCodecs().
|
||||
VideoCodec codec_settings_;
|
||||
|
||||
std::unique_ptr<VideoFrame> input_frame_;
|
||||
|
||||
std::unique_ptr<VideoEncoder> encoder_;
|
||||
@ -89,6 +94,7 @@ class VideoCodecTest : public ::testing::Test {
|
||||
rtc::Event encoded_frame_event_;
|
||||
rtc::CriticalSection encoded_frame_section_;
|
||||
rtc::Optional<EncodedImage> encoded_frame_ GUARDED_BY(encoded_frame_section_);
|
||||
CodecSpecificInfo codec_specific_info_ GUARDED_BY(encoded_frame_section_);
|
||||
|
||||
rtc::Event decoded_frame_event_;
|
||||
rtc::CriticalSection decoded_frame_section_;
|
||||
|
||||
Reference in New Issue
Block a user