Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: webrtc/modules/video_coding/codecs/test/videoprocessor.cc

Issue 2708103002: Revert of Add optional visualization file writers to VideoProcessor tests. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/codecs/test/videoprocessor.cc
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
index b98f1496a5843a6919cc8c900ebbcfb82701d3a4..2acc8484e295b02958c474d4045ed67d4df48ddf 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
@@ -28,10 +28,6 @@
namespace webrtc {
namespace test {
-
-namespace {
-const int k90khzTimestampFrameDiff = 3000; // Assuming 30 fps.
-} // namespace
const char* ExcludeFrameTypesToStr(ExcludeFrameTypes e) {
switch (e) {
@@ -64,24 +60,18 @@
VideoProcessorImpl::VideoProcessorImpl(webrtc::VideoEncoder* encoder,
webrtc::VideoDecoder* decoder,
- FrameReader* analysis_frame_reader,
- FrameWriter* analysis_frame_writer,
+ FrameReader* frame_reader,
+ FrameWriter* frame_writer,
PacketManipulator* packet_manipulator,
const TestConfig& config,
- Stats* stats,
- FrameWriter* source_frame_writer,
- IvfFileWriter* encoded_frame_writer,
- FrameWriter* decoded_frame_writer)
+ Stats* stats)
: encoder_(encoder),
decoder_(decoder),
- analysis_frame_reader_(analysis_frame_reader),
- analysis_frame_writer_(analysis_frame_writer),
+ frame_reader_(frame_reader),
+ frame_writer_(frame_writer),
packet_manipulator_(packet_manipulator),
config_(config),
stats_(stats),
- source_frame_writer_(source_frame_writer),
- encoded_frame_writer_(encoded_frame_writer),
- decoded_frame_writer_(decoded_frame_writer),
first_key_frame_has_been_excluded_(false),
last_frame_missing_(false),
initialized_(false),
@@ -104,8 +94,8 @@
*config.codec_settings, std::move(tl_factory));
RTC_DCHECK(encoder);
RTC_DCHECK(decoder);
- RTC_DCHECK(analysis_frame_reader);
- RTC_DCHECK(analysis_frame_writer);
+ RTC_DCHECK(frame_reader);
+ RTC_DCHECK(frame_writer);
RTC_DCHECK(packet_manipulator);
RTC_DCHECK(stats);
}
@@ -115,7 +105,7 @@
bit_rate_factor_ = config_.codec_settings->maxFramerate * 0.001 * 8; // bits
// Initialize data structures used by the encoder/decoder APIs.
- size_t frame_length_in_bytes = analysis_frame_reader_->FrameLength();
+ size_t frame_length_in_bytes = frame_reader_->FrameLength();
last_successful_frame_buffer_.reset(new uint8_t[frame_length_in_bytes]);
// Set fixed properties common for all frames.
@@ -151,8 +141,7 @@
if (config_.verbose) {
printf("Video Processor:\n");
printf(" #CPU cores used : %d\n", num_cores);
- printf(" Total # of frames: %d\n",
- analysis_frame_reader_->NumberOfFrames());
+ printf(" Total # of frames: %d\n", frame_reader_->NumberOfFrames());
printf(" Codec settings:\n");
printf(" Start bitrate : %d kbps\n",
config_.codec_settings->startBitrate);
@@ -218,26 +207,15 @@
RTC_DCHECK_GE(frame_number, 0);
RTC_CHECK(initialized_) << "Attempting to use uninitialized VideoProcessor";
- rtc::scoped_refptr<VideoFrameBuffer> buffer(
- analysis_frame_reader_->ReadFrame());
+ // |prev_time_stamp_| is used for getting number of dropped frames.
+ if (frame_number == 0) {
+ prev_time_stamp_ = -1;
+ }
+
+ rtc::scoped_refptr<VideoFrameBuffer> buffer(frame_reader_->ReadFrame());
if (buffer) {
- if (source_frame_writer_) {
- // TODO(brandtr): Introduce temp buffer as data member, to avoid
- // allocating for every frame.
- size_t length = CalcBufferSize(kI420, buffer->width(), buffer->height());
- std::unique_ptr<uint8_t[]> extracted_buffer(new uint8_t[length]);
- int extracted_length =
- ExtractBuffer(buffer, length, extracted_buffer.get());
- RTC_DCHECK_GT(extracted_length, 0);
- source_frame_writer_->WriteFrame(extracted_buffer.get());
- }
-
- // Use the frame number as basis for timestamp to identify frames. Let the
- // first timestamp be non-zero, to not make the IvfFileWriter believe that
- // we want to use capture timestamps in the IVF files.
- VideoFrame source_frame(buffer,
- (frame_number + 1) * k90khzTimestampFrameDiff, 0,
- webrtc::kVideoRotation_0);
+ // Use the frame number as "timestamp" to identify frames.
+ VideoFrame source_frame(buffer, frame_number, 0, webrtc::kVideoRotation_0);
// Ensure we have a new statistics data object we can fill.
FrameStatistic& stat = stats_->NewFrame(frame_number);
@@ -280,41 +258,30 @@
// time recordings should wrap the Encode call as tightly as possible.
int64_t encode_stop_ns = rtc::TimeNanos();
- if (encoded_frame_writer_) {
- RTC_DCHECK(encoded_frame_writer_->WriteFrame(encoded_image, codec));
- }
-
- // Timestamp is proportional to frame number, so this gives us number of
- // dropped frames.
+ // Timestamp is frame number, so this gives us #dropped frames.
int num_dropped_from_prev_encode =
- (encoded_image._timeStamp - prev_time_stamp_) / k90khzTimestampFrameDiff -
- 1;
+ encoded_image._timeStamp - prev_time_stamp_ - 1;
num_dropped_frames_ += num_dropped_from_prev_encode;
prev_time_stamp_ = encoded_image._timeStamp;
if (num_dropped_from_prev_encode > 0) {
// For dropped frames, we write out the last decoded frame to avoid getting
// out of sync for the computation of PSNR and SSIM.
for (int i = 0; i < num_dropped_from_prev_encode; i++) {
- RTC_DCHECK(analysis_frame_writer_->WriteFrame(
- last_successful_frame_buffer_.get()));
- if (decoded_frame_writer_) {
- RTC_DCHECK(decoded_frame_writer_->WriteFrame(
- last_successful_frame_buffer_.get()));
- }
- }
- }
-
+ frame_writer_->WriteFrame(last_successful_frame_buffer_.get());
+ }
+ }
// Frame is not dropped, so update the encoded frame size
// (encoder callback is only called for non-zero length frames).
encoded_frame_size_ = encoded_image._length;
encoded_frame_type_ = encoded_image._frameType;
- int frame_number = encoded_image._timeStamp / k90khzTimestampFrameDiff - 1;
+ int frame_number = encoded_image._timeStamp;
+
FrameStatistic& stat = stats_->stats_[frame_number];
stat.encode_time_in_us =
GetElapsedTimeMicroseconds(encode_start_ns_, encode_stop_ns);
stat.encoding_successful = true;
stat.encoded_frame_length_in_bytes = encoded_image._length;
- stat.frame_number = frame_number;
+ stat.frame_number = encoded_image._timeStamp;
stat.frame_type = encoded_image._frameType;
stat.bit_rate_in_kbps = encoded_image._length * bit_rate_factor_;
stat.total_packets =
@@ -371,12 +338,7 @@
if (decode_result != WEBRTC_VIDEO_CODEC_OK) {
// Write the last successful frame the output file to avoid getting it out
// of sync with the source file for SSIM and PSNR comparisons.
- RTC_DCHECK(analysis_frame_writer_->WriteFrame(
- last_successful_frame_buffer_.get()));
- if (decoded_frame_writer_) {
- RTC_DCHECK(decoded_frame_writer_->WriteFrame(
- last_successful_frame_buffer_.get()));
- }
+ frame_writer_->WriteFrame(last_successful_frame_buffer_.get());
}
// Save status for losses so we can inform the decoder for the next frame.
@@ -389,7 +351,7 @@
int64_t decode_stop_ns = rtc::TimeNanos();
// Report stats.
- int frame_number = image.timestamp() / k90khzTimestampFrameDiff - 1;
+ int frame_number = image.timestamp();
FrameStatistic& stat = stats_->stats_[frame_number];
stat.decode_time_in_us =
GetElapsedTimeMicroseconds(decode_start_ns_, decode_stop_ns);
@@ -427,10 +389,10 @@
// Update our copy of the last successful frame.
memcpy(last_successful_frame_buffer_.get(), image_buffer.get(),
extracted_length);
-
- RTC_DCHECK(analysis_frame_writer_->WriteFrame(image_buffer.get()));
- if (decoded_frame_writer_) {
- RTC_DCHECK(decoded_frame_writer_->WriteFrame(image_buffer.get()));
+ bool write_success = frame_writer_->WriteFrame(image_buffer.get());
+ RTC_DCHECK(write_success);
+ if (!write_success) {
+ fprintf(stderr, "Failed to write frame %d to disk!", frame_number);
}
} else { // No resize.
// Update our copy of the last successful frame.
@@ -450,9 +412,10 @@
memcpy(last_successful_frame_buffer_.get(), image_buffer.get(),
extracted_length);
- RTC_DCHECK(analysis_frame_writer_->WriteFrame(image_buffer.get()));
- if (decoded_frame_writer_) {
- RTC_DCHECK(decoded_frame_writer_->WriteFrame(image_buffer.get()));
+ bool write_success = frame_writer_->WriteFrame(image_buffer.get());
+ RTC_DCHECK(write_success);
+ if (!write_success) {
+ fprintf(stderr, "Failed to write frame %d to disk!", frame_number);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698