Update plot_webrtc_test_logs.py:

- Add codec_type-implementation_name label option.
- Update figure title to exclude information that exist in legend.
- Change frame info in title from: # of frames in file -> # of processed frames.

BUG=webrtc:6634

Review-Url: https://codereview.webrtc.org/2890223002
Cr-Commit-Position: refs/heads/master@{#18209}
This commit is contained in:
asapersson
2017-05-19 04:07:38 -07:00
committed by Commit bot
parent 633e22ebbe
commit 30df64f143
4 changed files with 56 additions and 36 deletions

View File

@ -22,14 +22,14 @@ EVENT_START = 'RUN ] CodecSettings/PlotVideoProcessorIntegrationTest.'
EVENT_END = 'OK ] CodecSettings/PlotVideoProcessorIntegrationTest.'
# Metrics to plot, tuple: (name to parse in file, label to use when plotting).
BITRATE = ('Target Bitrate', 'bitrate (kbps)')
BITRATE = ('Target Bitrate', 'target bitrate (kbps)')
WIDTH = ('Width', 'width')
HEIGHT = ('Height', 'height')
FILENAME = ('Filename', 'clip')
CODEC_TYPE = ('Codec type', 'Codec')
ENCODER_IMPLEMENTATION_NAME = ('Encoder implementation name', 'enc name')
DECODER_IMPLEMENTATION_NAME = ('Decoder implementation name', 'dec name')
NUM_FRAMES = ('Total # of frames', 'num frames')
CODEC_IMPLEMENTATION_NAME = ('Codec implementation name', 'codec name')
CORES = ('#CPU cores used', 'CPU cores used')
DENOISING = ('Denoising', 'denoising')
RESILIENCE = ('Resilience', 'resilience')
@ -39,6 +39,7 @@ PSNR = ('PSNR avg', 'PSNR (dB)')
SSIM = ('SSIM avg', 'SSIM')
ENC_BITRATE = ('Encoding bitrate', 'encoded bitrate (kbps)')
FRAMERATE = ('Frame rate', 'fps')
NUM_FRAMES = ('Number of processed frames', 'num frames')
NUM_DROPPED_FRAMES = ('Number of dropped frames', 'num dropped frames')
NUM_FRAMES_TO_TARGET = ('Number of frames to approach target rate',
'frames to reach target rate')
@ -78,6 +79,7 @@ SUBPLOT_SETTINGS = [
CODEC_TYPE,
ENCODER_IMPLEMENTATION_NAME,
DECODER_IMPLEMENTATION_NAME,
CODEC_IMPLEMENTATION_NAME,
] + X_SETTINGS
# Results.
@ -99,8 +101,8 @@ METRICS_TO_PARSE = SETTINGS + SUBPLOT_SETTINGS + RESULTS
Y_METRICS = [res[1] for res in RESULTS]
# Parameters for plotting.
FIG_SIZE_SCALE_FACTOR_X = 2
FIG_SIZE_SCALE_FACTOR_Y = 2.8
FIG_SIZE_SCALE_FACTOR_X = 1.6
FIG_SIZE_SCALE_FACTOR_Y = 1.8
GRID_COLOR = [0.45, 0.45, 0.45]
@ -285,7 +287,7 @@ def Plot(y_metric, x_metric, metrics):
},
}
"""
for key in metrics:
for key in sorted(metrics):
data = metrics[key]
if y_metric not in data:
print "Failed to find metric: %s" % y_metric
@ -315,7 +317,8 @@ def PlotFigure(settings, y_metrics, x_metric, metrics, title):
"""
plt.figure()
plt.suptitle(title, fontsize='small', fontweight='bold')
plt.suptitle(title, fontsize='large', fontweight='bold')
settings.sort()
rows = len(settings)
cols = 1
pos = 1
@ -323,39 +326,47 @@ def PlotFigure(settings, y_metrics, x_metric, metrics, title):
plt.rc('grid', color=GRID_COLOR)
ax = plt.subplot(rows, cols, pos)
plt.grid()
plt.setp(ax.get_xticklabels(), visible=(pos == rows), fontsize='small')
plt.setp(ax.get_yticklabels(), fontsize='small')
plt.setp(ax.get_xticklabels(), visible=(pos == rows), fontsize='large')
plt.setp(ax.get_yticklabels(), fontsize='large')
setting = settings[pos - 1]
Plot(y_metrics[pos - 1], x_metric, metrics[setting])
plt.title(setting, fontsize='x-small')
plt.legend(fontsize='xx-small')
if setting.startswith(WIDTH[1]):
plt.title(setting, fontsize='medium')
plt.legend(fontsize='large', loc='best')
pos += 1
plt.xlabel(x_metric, fontsize='small')
plt.subplots_adjust(left=0.04, right=0.98, bottom=0.04, top=0.96, hspace=0.1)
plt.xlabel(x_metric, fontsize='large')
plt.subplots_adjust(left=0.06, right=0.98, bottom=0.05, top=0.94, hspace=0.08)
def GetTitle(filename):
def GetTitle(filename, setting):
title = ''
codec_types = ParseSetting(filename, CODEC_TYPE[1])
for i in range(0, len(codec_types)):
title += codec_types[i] + ', '
if setting != CODEC_IMPLEMENTATION_NAME[1] and setting != CODEC_TYPE[1]:
codec_types = ParseSetting(filename, CODEC_TYPE[1])
for i in range(0, len(codec_types)):
title += codec_types[i] + ', '
cores = ParseSetting(filename, CORES[1])
for i in range(0, len(cores)):
title += cores[i].split('.')[0] + ', '
if setting != CORES[1]:
cores = ParseSetting(filename, CORES[1])
for i in range(0, len(cores)):
title += cores[i].split('.')[0] + ', '
framerate = ParseSetting(filename, FRAMERATE[1])
for i in range(0, len(framerate)):
title += framerate[i].split('.')[0] + ', '
if setting != FRAMERATE[1]:
framerate = ParseSetting(filename, FRAMERATE[1])
for i in range(0, len(framerate)):
title += framerate[i].split('.')[0] + ', '
enc_names = ParseSetting(filename, ENCODER_IMPLEMENTATION_NAME[1])
for i in range(0, len(enc_names)):
title += enc_names[i] + ', '
if (setting != CODEC_IMPLEMENTATION_NAME[1] and
setting != ENCODER_IMPLEMENTATION_NAME[1]):
enc_names = ParseSetting(filename, ENCODER_IMPLEMENTATION_NAME[1])
for i in range(0, len(enc_names)):
title += enc_names[i] + ', '
dec_names = ParseSetting(filename, DECODER_IMPLEMENTATION_NAME[1])
for i in range(0, len(dec_names)):
title += dec_names[i] + ', '
if (setting != CODEC_IMPLEMENTATION_NAME[1] and
setting != DECODER_IMPLEMENTATION_NAME[1]):
dec_names = ParseSetting(filename, DECODER_IMPLEMENTATION_NAME[1])
for i in range(0, len(dec_names)):
title += dec_names[i] + ', '
filenames = ParseSetting(filename, FILENAME[1])
title += filenames[0].split('_')[0]
@ -430,7 +441,8 @@ def main():
figsize[1] *= FIG_SIZE_SCALE_FACTOR_Y
plt.rcParams["figure.figsize"] = figsize
PlotFigure(sub_keys, y_metrics, x_metric, metrics, GetTitle(filename))
PlotFigure(sub_keys, y_metrics, x_metric, metrics,
GetTitle(filename, setting2))
plt.show()

View File

@ -139,6 +139,7 @@ VideoProcessorImpl::VideoProcessorImpl(webrtc::VideoEncoder* encoder,
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),
@ -146,8 +147,7 @@ VideoProcessorImpl::VideoProcessorImpl(webrtc::VideoEncoder* encoder,
last_decoded_frame_buffer_(0, analysis_frame_reader->FrameLength()),
stats_(stats),
num_dropped_frames_(0),
num_spatial_resizes_(0),
bit_rate_factor_(0.0) {
num_spatial_resizes_(0) {
RTC_DCHECK(encoder);
RTC_DCHECK(decoder);
RTC_DCHECK(packet_manipulator);
@ -162,9 +162,6 @@ bool VideoProcessorImpl::Init() {
RTC_DCHECK(!initialized_)
<< "This VideoProcessor has already been initialized.";
// Calculate a factor used for bit rate calculations.
bit_rate_factor_ = config_.codec_settings->maxFramerate * 0.001 * 8; // bits
// Setup required callbacks for the encoder/decoder.
RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(encode_callback_.get()),
WEBRTC_VIDEO_CODEC_OK)
@ -195,6 +192,13 @@ bool VideoProcessorImpl::Init() {
encoder_->ImplementationName());
printf(" Decoder implementation name: %s\n",
decoder_->ImplementationName());
if (strcmp(encoder_->ImplementationName(),
decoder_->ImplementationName()) == 0) {
printf(" Codec implementation name: %s_%s\n",
CodecTypeToPayloadName(config_.codec_settings->codecType)
.value_or("Unknown"),
encoder_->ImplementationName());
}
PrintCodecSettings(config_.codec_settings);
}

View File

@ -298,6 +298,9 @@ 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
@ -318,7 +321,6 @@ class VideoProcessorImpl : public VideoProcessor {
Stats* stats_;
int num_dropped_frames_;
int num_spatial_resizes_;
double bit_rate_factor_; // Multiply frame length with this to get bit rate.
};
} // namespace test

View File

@ -431,10 +431,12 @@ class VideoProcessorIntegrationTest : public testing::Test {
" Frame rate: %d \n",
update_index, bit_rate_, encoding_bitrate_total_, frame_rate_);
printf(
" Number of processed frames: %d, \n"
" Number of frames to approach target rate: %d, \n"
" Number of dropped frames: %d, \n"
" Number of spatial resizes: %d, \n",
num_frames_to_hit_target_, num_dropped_frames, num_resize_actions);
num_frames_total_, num_frames_to_hit_target_, num_dropped_frames,
num_resize_actions);
EXPECT_LE(perc_encoding_rate_mismatch_,
rc_expected.max_encoding_rate_mismatch);
if (num_key_frames_ > 0) {