Speed up per frame debug log in vp9 encoder wrapper

For the linked test case that speeds up chromium fuzzer by ~13%
Run time decrease from ~50 seconds to ~44 seconds

Bug: chromium:1357929
Change-Id: I702edf4fda7afd31a5288621220dac063f764ced
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/274601
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38038}
This commit is contained in:
Danil Chapovalov
2022-09-08 16:33:34 +02:00
committed by WebRTC LUCI CQ
parent 5045949490
commit 8bfec7c5bc

View File

@ -1462,7 +1462,9 @@ void LibvpxVp9Encoder::FillReferenceIndices(const vpx_codec_cx_pkt& pkt,
vpx_svc_ref_frame_config_t enc_layer_conf = {{0}};
libvpx_->codec_control(encoder_, VP9E_GET_SVC_REF_FRAME_CONFIG,
&enc_layer_conf);
int ref_buf_flags = 0;
char ref_buf_flags[] = "00000000";
// There should be one character per buffer + 1 termination '\0'.
static_assert(sizeof(ref_buf_flags) == kNumVp9Buffers + 1);
if (enc_layer_conf.reference_last[layer_id.spatial_layer_id]) {
const size_t fb_idx =
@ -1471,7 +1473,7 @@ void LibvpxVp9Encoder::FillReferenceIndices(const vpx_codec_cx_pkt& pkt,
if (std::find(ref_buf_list.begin(), ref_buf_list.end(),
ref_buf_[fb_idx]) == ref_buf_list.end()) {
ref_buf_list.push_back(ref_buf_[fb_idx]);
ref_buf_flags |= 1 << fb_idx;
ref_buf_flags[fb_idx] = '1';
}
}
@ -1482,7 +1484,7 @@ void LibvpxVp9Encoder::FillReferenceIndices(const vpx_codec_cx_pkt& pkt,
if (std::find(ref_buf_list.begin(), ref_buf_list.end(),
ref_buf_[fb_idx]) == ref_buf_list.end()) {
ref_buf_list.push_back(ref_buf_[fb_idx]);
ref_buf_flags |= 1 << fb_idx;
ref_buf_flags[fb_idx] = '1';
}
}
@ -1493,21 +1495,14 @@ void LibvpxVp9Encoder::FillReferenceIndices(const vpx_codec_cx_pkt& pkt,
if (std::find(ref_buf_list.begin(), ref_buf_list.end(),
ref_buf_[fb_idx]) == ref_buf_list.end()) {
ref_buf_list.push_back(ref_buf_[fb_idx]);
ref_buf_flags |= 1 << fb_idx;
ref_buf_flags[fb_idx] = '1';
}
}
RTC_LOG(LS_VERBOSE) << "Frame " << pic_num << " sl "
<< layer_id.spatial_layer_id << " tl "
<< layer_id.temporal_layer_id << " refered buffers "
<< (ref_buf_flags & (1 << 0) ? 1 : 0)
<< (ref_buf_flags & (1 << 1) ? 1 : 0)
<< (ref_buf_flags & (1 << 2) ? 1 : 0)
<< (ref_buf_flags & (1 << 3) ? 1 : 0)
<< (ref_buf_flags & (1 << 4) ? 1 : 0)
<< (ref_buf_flags & (1 << 5) ? 1 : 0)
<< (ref_buf_flags & (1 << 6) ? 1 : 0)
<< (ref_buf_flags & (1 << 7) ? 1 : 0);
<< ref_buf_flags;
} else if (!is_key_frame) {
RTC_DCHECK_EQ(num_spatial_layers_, 1);