Make VideoProcessor::Init void (always returning true).

BUG=none

Review-Url: https://codereview.webrtc.org/2946263002
Cr-Commit-Position: refs/heads/master@{#18711}
This commit is contained in:
asapersson
2017-06-22 02:18:50 -07:00
committed by Commit Bot
parent 451975206a
commit 1d29c86cbf
4 changed files with 16 additions and 26 deletions

View File

@ -135,11 +135,9 @@ VideoProcessorImpl::VideoProcessorImpl(webrtc::VideoEncoder* encoder,
config_(config),
analysis_frame_reader_(analysis_frame_reader),
analysis_frame_writer_(analysis_frame_writer),
num_frames_(analysis_frame_reader->NumberOfFrames()),
source_frame_writer_(source_frame_writer),
encoded_frame_writer_(encoded_frame_writer),
decoded_frame_writer_(decoded_frame_writer),
bit_rate_factor_(config.codec_settings->maxFramerate * 0.001 * 8),
initialized_(false),
last_encoded_frame_num_(-1),
last_decoded_frame_num_(-1),
@ -154,13 +152,12 @@ VideoProcessorImpl::VideoProcessorImpl(webrtc::VideoEncoder* encoder,
RTC_DCHECK(analysis_frame_reader);
RTC_DCHECK(analysis_frame_writer);
RTC_DCHECK(stats);
frame_infos_.reserve(num_frames_);
frame_infos_.reserve(analysis_frame_reader->NumberOfFrames());
}
bool VideoProcessorImpl::Init() {
RTC_DCHECK(!initialized_)
<< "This VideoProcessor has already been initialized.";
void VideoProcessorImpl::Init() {
RTC_DCHECK(!initialized_) << "VideoProcessor already initialized.";
initialized_ = true;
// Setup required callbacks for the encoder/decoder.
RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(encode_callback_.get()),
@ -186,7 +183,8 @@ bool VideoProcessorImpl::Init() {
if (config_.verbose) {
printf("Video Processor:\n");
printf(" #CPU cores used : %d\n", num_cores);
printf(" Total # of frames: %d\n", num_frames_);
printf(" Total # of frames: %d\n",
analysis_frame_reader_->NumberOfFrames());
printf(" Codec settings:\n");
printf(" Encoder implementation name: %s\n",
encoder_->ImplementationName());
@ -201,10 +199,6 @@ bool VideoProcessorImpl::Init() {
}
PrintCodecSettings(config_.codec_settings);
}
initialized_ = true;
return true;
}
VideoProcessorImpl::~VideoProcessorImpl() {
@ -254,7 +248,7 @@ bool VideoProcessorImpl::ProcessFrame(int frame_number) {
RTC_DCHECK_GE(frame_number, 0);
RTC_DCHECK_LE(frame_number, frame_infos_.size())
<< "Must process frames without gaps.";
RTC_DCHECK(initialized_) << "Attempting to use uninitialized VideoProcessor";
RTC_DCHECK(initialized_) << "VideoProcessor not initialized.";
rtc::scoped_refptr<I420BufferInterface> buffer(
analysis_frame_reader_->ReadFrame());
@ -373,7 +367,8 @@ void VideoProcessorImpl::FrameEncoded(
frame_stat->frame_number = frame_number;
frame_stat->frame_type = encoded_image._frameType;
frame_stat->qp = encoded_image.qp_;
frame_stat->bit_rate_in_kbps = encoded_image._length * bit_rate_factor_;
frame_stat->bit_rate_in_kbps = static_cast<int>(
encoded_image._length * config_.codec_settings->maxFramerate * 8 / 1000);
frame_stat->total_packets =
encoded_image._length / config_.networking_config.packet_size_in_bytes +
1;

View File

@ -136,9 +136,8 @@ class VideoProcessor {
public:
virtual ~VideoProcessor() {}
// Performs initial calculations about frame size, sets up callbacks etc.
// Returns false if an error has occurred, in addition to printing to stderr.
virtual bool Init() = 0;
// Sets up callbacks and initializes the encoder and decoder.
virtual void Init() = 0;
// Processes a single frame. Returns true as long as there's more frames
// available in the source clip.
@ -181,7 +180,7 @@ class VideoProcessorImpl : public VideoProcessor {
IvfFileWriter* encoded_frame_writer,
FrameWriter* decoded_frame_writer);
virtual ~VideoProcessorImpl();
bool Init() override;
void Init() override;
bool ProcessFrame(int frame_number) override;
private:
@ -304,7 +303,6 @@ class VideoProcessorImpl : public VideoProcessor {
// SSIM calculations at the end of a test run.
FrameReader* const analysis_frame_reader_;
FrameWriter* const analysis_frame_writer_;
const int num_frames_;
// These (optional) file writers are used for persistently storing the output
// of the coding pipeline at different stages: pre encode (source), post
@ -316,9 +314,6 @@ class VideoProcessorImpl : public VideoProcessor {
IvfFileWriter* const encoded_frame_writer_;
FrameWriter* const decoded_frame_writer_;
// Multiply frame length with this to get bit rate.
const double bit_rate_factor_;
bool initialized_;
// Frame metadata for all frames that have been added through a call to

View File

@ -349,7 +349,7 @@ class VideoProcessorIntegrationTest : public testing::Test {
analysis_frame_writer_.get(), packet_manipulator_.get(), config_,
&stats_, source_frame_writer_.get(), encoded_frame_writer_.get(),
decoded_frame_writer_.get()));
RTC_CHECK(processor_->Init());
processor_->Init();
}
// Reset quantities after each encoder update, update the target

View File

@ -60,7 +60,7 @@ class VideoProcessorTest : public testing::Test {
EXPECT_CALL(decoder_mock_, InitDecode(_, _)).Times(1);
EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_))
.Times(AtLeast(1));
EXPECT_CALL(frame_reader_mock_, NumberOfFrames()).WillOnce(Return(1));
EXPECT_CALL(frame_reader_mock_, NumberOfFrames()).WillRepeatedly(Return(1));
EXPECT_CALL(frame_reader_mock_, FrameLength()).WillOnce(Return(152064));
}
};
@ -72,7 +72,7 @@ TEST_F(VideoProcessorTest, Init) {
&packet_manipulator_mock_, config_, &stats_,
nullptr /* source_frame_writer */, nullptr /* encoded_frame_writer */,
nullptr /* decoded_frame_writer */);
ASSERT_TRUE(video_processor.Init());
video_processor.Init();
}
TEST_F(VideoProcessorTest, ProcessFrame) {
@ -87,7 +87,7 @@ TEST_F(VideoProcessorTest, ProcessFrame) {
&packet_manipulator_mock_, config_, &stats_,
nullptr /* source_frame_writer */, nullptr /* encoded_frame_writer */,
nullptr /* decoded_frame_writer */);
ASSERT_TRUE(video_processor.Init());
video_processor.Init();
video_processor.ProcessFrame(0);
}